Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: enable the miners whitelist on the validator side, whitelist tru… #124

Merged
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
17 changes: 14 additions & 3 deletions compute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import string

# Define the version of the template module.
__version__ = "1.3.10"
__version__ = "1.3.11"
__minimal_miner_version__ = "1.3.10"
__minimal_validator_version__ = "1.3.10"

Expand Down Expand Up @@ -70,5 +70,16 @@
"5F4bqDZkx79hCxmbbsVMuq312EW9hQLvsBzKsAJgcEqpb8L9",
]

# TODO feat(Validators/Miners): Random hashes used for challenge ? maybe not necessary thanks to Blake algo.
# TODO feat(Miners): Remove docker requirement, to support containerized providers.
TRUSTED_VALIDATORS_HOTKEYS = [
"5F4tQyWrhfGVcNhoqeiNsR6KjD4wMZ2kfhLj4oHYuyHbZAc3", # Opentensor Foundation
"5Hddm3iBFD2GLT5ik7LZnT3XJUnRnN8PoeCFgGQgawUVKNm8", # τaosτaτs & Corcel
"5HEo565WAy4Dbq3Sv271SAi7syBSofyfhhwRNjFNSM2gP9M2", # Foundry
"5HK5tp6t2S59DywmHRWPBVJeJ86T61KjurYqeooqj8sREpeN", # Bittensor Guru Podcast
"5EhvL1FVkQPpMjZX4MAADcW42i3xPSF1KiCpuaxTYVr28sux", # TAO-Validator.com
"5FFApaS75bv5pJHfAp2FVLBj9ZaXuFDjEypsaBNc1wCfe52v", # RoundTable21
"5DvTpiniW9s3APmHRYn8FroUWyfnLtrsid5Mtn5EwMXHN2ed", # FirstTensor
"5HbLYXUBy1snPR8nfioQ7GoA9x76EELzEq9j7F32vWUQHm1x", # Tensorplex
"5CXRfP2ekFhe62r7q3vppRajJmGhTi7vwvb2yr79jveZ282w", # Rizzo
"5HNQURvmjjYhTSksi8Wfsw676b4owGwfLR2BFAQzG7H3HhYf", # Neural Inτerneτ
"5DnXm2tBGAD57ySJv5SfpTfLcsQbSKKp6xZKFWABw3cYUgqg", # Love
]
13 changes: 8 additions & 5 deletions neurons/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
validator_permit_stake,
miner_priority_specs,
miner_priority_allocate,
miner_priority_challenge,
miner_priority_challenge, TRUSTED_VALIDATORS_HOTKEYS,
)
from compute.axon import ComputeSubnetAxon, ComputeSubnetSubtensor
from compute.protocol import Specs, Allocate, Challenge
Expand Down Expand Up @@ -202,10 +202,12 @@ def init_config():
return config

def init_black_and_white_list(self):
default_whitelist = self.config.whitelist_hotkeys + TRUSTED_VALIDATORS_HOTKEYS

# Set blacklist and whitelist arrays
self.blacklist_hotkeys = {hotkey for hotkey in self.config.blacklist_hotkeys}
self.blacklist_coldkeys = {coldkey for coldkey in self.config.blacklist_coldkeys}
self.whitelist_hotkeys = {hotkey for hotkey in self.config.whitelist_hotkeys}
self.whitelist_hotkeys = {hotkey for hotkey in default_whitelist}
self.whitelist_coldkeys = {coldkey for coldkey in self.config.whitelist_coldkeys}

if self.config.blacklist_exploiters:
Expand Down Expand Up @@ -243,6 +245,10 @@ def base_blacklist(self, synapse: typing.Union[Specs, Allocate, Challenge]) -> t
hotkey = synapse.dendrite.hotkey
synapse_type = type(synapse).__name__

if len(self.whitelist_hotkeys) > 0 and hotkey not in self.whitelist_hotkeys:
bt.logging.trace(f"Not Blacklisting recognized hotkey {synapse.dendrite.hotkey}")
return False, "Whitelisted hotkey"

if hotkey not in self.metagraph.hotkeys:
# Ignore requests from unrecognized entities.
bt.logging.trace(f"Blacklisting unrecognized hotkey {hotkey}")
Expand All @@ -255,9 +261,6 @@ def base_blacklist(self, synapse: typing.Union[Specs, Allocate, Challenge]) -> t
bt.logging.trace(f"Not enough stake {stake}")
return True, "Not enough stake!"

if len(self.whitelist_hotkeys) > 0 and hotkey not in self.whitelist_hotkeys:
return True, "Not whitelisted"

if len(self.blacklist_hotkeys) > 0 and hotkey in self.blacklist_hotkeys:
return True, "Blacklisted hotkey"

Expand Down
4 changes: 3 additions & 1 deletion neurons/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def filter_axon_version(self, dict_filtered_axons: dict):

dict_filtered_axons_version = {}
for uid, axon in dict_filtered_axons.items():
if latest_version and axon.version >= latest_version:
if latest_version and latest_version <= axon.version < 600:
dict_filtered_axons_version[uid] = axon
return dict_filtered_axons_version

Expand Down Expand Up @@ -413,10 +413,12 @@ def is_blacklisted(self, neuron: bt.NeuronInfoLite):

def get_valid_tensors(self, metagraph):
tensors = []
self.total_current_miners = 0
for uid in metagraph.uids:
neuron = metagraph.neurons[uid]

if neuron.axon_info.ip != "0.0.0.0" and not self.is_blacklisted(neuron=neuron):
self.total_current_miners += 1
tensors.append(True)
else:
tensors.append(False)
Expand Down