From 43d48f9402dfee86b4882c8bc00342d50301fc9a Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 28 Jun 2023 17:09:55 -0400 Subject: [PATCH 1/3] add type hints --- openvalidators/neuron.py | 4 ++++ openvalidators/utils.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/openvalidators/neuron.py b/openvalidators/neuron.py index 2692227..ef15bb0 100644 --- a/openvalidators/neuron.py +++ b/openvalidators/neuron.py @@ -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) diff --git a/openvalidators/utils.py b/openvalidators/utils.py index 6c40e70..559d80d 100644 --- a/openvalidators/utils.py +++ b/openvalidators/utils.py @@ -81,7 +81,7 @@ 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()") From 6144e1f7a82168c6d62458f035a3df5db35f295a Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 28 Jun 2023 17:10:33 -0400 Subject: [PATCH 2/3] dont sync on meta init --- openvalidators/neuron.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openvalidators/neuron.py b/openvalidators/neuron.py index ef15bb0..8cc3739 100644 --- a/openvalidators/neuron.py +++ b/openvalidators/neuron.py @@ -93,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)) From ca8f2234c8b51a1d75c75028c027919fe1121a18 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 28 Jun 2023 17:10:43 -0400 Subject: [PATCH 3/3] sync using subtensor obj --- openvalidators/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openvalidators/utils.py b/openvalidators/utils.py index 559d80d..0d9f33d 100644 --- a/openvalidators/utils.py +++ b/openvalidators/utils.py @@ -89,7 +89,7 @@ def resync_metagraph(self: 'openvalidators.neuron.neuron'): 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