You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Initiates and manages the main loop for the miner on the Bittensor network. The main loop handles graceful shutdown on keyboard interrupts and logs unforeseen errors.
122
-
123
-
This function performs the following primary tasks:
124
-
1. Check for registration on the Bittensor network.
125
-
2. Continuously forwards queries to the miners on the network, rewarding their responses and updating the scores accordingly.
126
-
3. Periodically resynchronizes with the chain; updating the metagraph with the latest network state and setting weights.
127
-
128
-
The essence of the validator's operations is in the forward function, which is called every step. The forward function is responsible for querying the network and scoring the responses.
129
-
130
-
Note:
131
-
- The function leverages the global configurations set during the initialization of the miner.
132
-
- The miner's axon serves as its interface to the Bittensor network, handling incoming and outgoing requests.
133
-
134
-
Raises:
135
-
KeyboardInterrupt: If the miner is stopped by a manual interruption.
136
-
Exception: For unforeseen errors during the miner's operation, which are logged for diagnosis.
137
-
"""
138
-
139
-
# Check that validator is registered on the network.
140
-
self.sync()
141
-
142
-
bt.logging.info(f"Validator starting at block: {self.block}")
143
-
144
-
# This loop maintains the validator's operations until intentionally stopped.
145
-
try:
146
-
whileTrue:
147
-
# Our BaseValidator logic is intentionally as generic as possible so that the Validator neuron can apply problem-specific logic
Stops the validator's background operations upon exiting the context.
248
-
This method facilitates the use of the validator in a 'with' statement.
249
-
250
-
Args:
251
-
exc_type: The type of the exception that caused the context to be exited.
252
-
None if the context was exited without an exception.
253
-
exc_value: The instance of the exception that caused the context to be exited.
254
-
None if the context was exited without an exception.
255
-
traceback: A traceback object encoding the stack trace.
256
-
None if the context was exited without an exception.
257
-
"""
258
-
ifself.is_running:
259
-
bt.logging.debug("Stopping validator in background thread.")
260
-
self.should_exit=True
261
-
self.thread.join(5)
262
-
self.is_running=False
263
-
bt.logging.debug("Stopped")
264
-
265
113
defset_weights(self):
266
114
"""
267
115
Sets the validator weights to the metagraph hotkeys based on the scores it has received from the miners. The weights determine the trust and incentive level the validator assigns to miner nodes on the network.
0 commit comments