From 13192d890c04e90af9aefee6e797aa3bc013b788 Mon Sep 17 00:00:00 2001 From: jarvis8x7b <157810922+jarvis8x7b@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:20:58 +0800 Subject: [PATCH] fix: prevent miner from setting weights --- neurons/validator.py | 7 ------- template/base/miner.py | 29 +---------------------------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/neurons/validator.py b/neurons/validator.py index e033ba8a..cfec93ea 100644 --- a/neurons/validator.py +++ b/neurons/validator.py @@ -35,12 +35,6 @@ def _filter_valid_responses(responses: List[RankingRequest]) -> List[RankingRequ class Validator(BaseNeuron): - """Singleton class for validator, this means that trying to instantiate the - same validator class will always return the same instance. This prevents - trying to maintain multiple metagraphs, subtensors, etc. - - """ - def __init__(self): super(Validator, self).__init__() @@ -48,7 +42,6 @@ def __init__(self): forward_fn=self.forward_mturk_response, blacklist_fn=self.blacklist_mturk_response, ) - self.axon.serve(netuid=self.config.netuid, subtensor=self.subtensor) ##### FROM BaseValidatorNeuron ######################################## # Save a copy of the hotkeys to local memory. diff --git a/template/base/miner.py b/template/base/miner.py index 46bdd80d..29fbbad7 100644 --- a/template/base/miner.py +++ b/template/base/miner.py @@ -148,34 +148,7 @@ def __exit__(self, exc_type, exc_value, traceback): self.stop_run_thread() def set_weights(self): - """ - Self-assigns a weight of 1 to the current miner (identified by its UID) and - a weight of 0 to all other peers in the network. The weights determine the trust level the miner assigns to other nodes on the network. - - Raises: - Exception: If there's an error while setting weights, the exception is logged for diagnosis. - """ - try: - # --- query the chain for the most current number of peers on the network - chain_weights = torch.zeros( - self.subtensor.subnetwork_n(netuid=self.metagraph.netuid) - ) - chain_weights[self.uid] = 1 - - # --- Set weights. - self.subtensor.set_weights( - wallet=self.wallet, - netuid=self.metagraph.netuid, - uids=torch.arange(0, len(chain_weights)), - weights=chain_weights.to("cpu"), - wait_for_inclusion=False, - version_key=self.spec_version, - ) - - except Exception as e: - bt.logging.error(f"Failed to set weights on chain with exception: { e }") - - bt.logging.info(f"Set weights: {chain_weights}") + pass def resync_metagraph(self): """Resyncs the metagraph and updates the hotkeys and moving averages based on the new metagraph."""