Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion openvalidators/neuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def config(cls):
def run(self):
run(self)

subtensor: "bt.subtensor"
wallet: "bt.wallet"
metagraph: "bt.metagraph"

def __init__(self):
self.config = neuron.config()
self.check_config(self.config)
Expand Down Expand Up @@ -89,7 +93,8 @@ def __init__(self):

# Init metagraph.
bt.logging.debug("loading", "metagraph")
self.metagraph = bt.metagraph(netuid=self.config.netuid, network=self.subtensor.network)
self.metagraph = bt.metagraph(netuid=self.config.netuid, network=self.subtensor.network, sync=False) # Make sure not to sync without passing subtensor
self.metagraph.sync(subtensor=self.subtensor) # Sync metagraph with subtensor.
self.hotkeys = copy.deepcopy(self.metagraph.hotkeys)
bt.logging.debug(str(self.metagraph))

Expand Down
4 changes: 2 additions & 2 deletions openvalidators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ def checkpoint(self):
save_state(self)


def resync_metagraph(self):
def resync_metagraph(self: 'openvalidators.neuron.neuron'):
"""Resyncs the metagraph and updates the hotkeys and moving averages based on the new metagraph."""
bt.logging.info("resync_metagraph()")

# Copies state of metagraph before syncing.
previous_metagraph = copy.deepcopy(self.metagraph)

# Sync the metagraph.
self.metagraph.sync()
self.metagraph.sync(subtensor=self.subtensor)

# Check if the metagraph axon info has changed.
metagraph_axon_info_updated = previous_metagraph.axons != self.metagraph.axons
Expand Down