From 8093c91843b8dee821e4e07cdad831ae25c468b1 Mon Sep 17 00:00:00 2001 From: Christopher Searson Date: Wed, 2 Aug 2023 20:53:16 +1000 Subject: [PATCH 1/2] - Stop vali from forwarding requests if dereg --- openvalidators/run.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openvalidators/run.py b/openvalidators/run.py index cd69f6c..8707e02 100644 --- a/openvalidators/run.py +++ b/openvalidators/run.py @@ -16,6 +16,7 @@ # DEALINGS IN THE SOFTWARE. import asyncio +import time import bittensor as bt from traceback import print_exc @@ -24,6 +25,8 @@ from openvalidators.weights import should_set_weights, set_weights from openvalidators.misc import ttl_get_block +SLEEP_TIME = 180 + # Neuron run loop.` def run(self): bt.logging.info("run()") @@ -31,6 +34,10 @@ def run(self): checkpoint(self) try: while True: + if not self.wallet.hotkey.ss58_address in self.metagraph.hotkeys: + bt.logging.info(f"Validator is not registered - sleeping for {SLEEP_TIME} seconds") + time.sleep(SLEEP_TIME) + continue bt.logging.info(f"step({self.step}) block({ttl_get_block( self )})") # Run multiple forwards. @@ -58,4 +65,4 @@ async def run_forward(): except Exception as e: bt.logging.error("Error in training loop", str(e)) - bt.logging.debug(print_exc(e)) + bt.logging.debug(print_exc(e)) \ No newline at end of file From 26feb95a394a80a75c1a2590c692f679f012ad70 Mon Sep 17 00:00:00 2001 From: p-ferreira <38992619+p-ferreira@users.noreply.github.com> Date: Thu, 14 Sep 2023 14:56:00 -0400 Subject: [PATCH 2/2] complements run.py by throwing exception on dereg --- openvalidators/run.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openvalidators/run.py b/openvalidators/run.py index 3b5e871..21b2784 100644 --- a/openvalidators/run.py +++ b/openvalidators/run.py @@ -16,7 +16,6 @@ # DEALINGS IN THE SOFTWARE. import asyncio -import time import bittensor as bt from traceback import print_exception @@ -25,8 +24,6 @@ from openvalidators.weights import should_set_weights, set_weights from openvalidators.misc import ttl_get_block -SLEEP_TIME = 180 - # Neuron run loop.` def run(self): bt.logging.info("run()") @@ -35,9 +32,7 @@ def run(self): try: while True: if not self.wallet.hotkey.ss58_address in self.metagraph.hotkeys: - bt.logging.info(f"Validator is not registered - sleeping for {SLEEP_TIME} seconds") - time.sleep(SLEEP_TIME) - continue + raise Exception(f"Validator is not registered - hotkey {self.wallet.hotkey.ss58_address} not in metagraph") bt.logging.info(f"step({self.step}) block({ttl_get_block( self )})") # Run multiple forwards.