55import numpy as np
66from loguru import logger
77
8- from shared .constants import WHITELISTED_VALIDATORS_UIDS
98from shared .epistula import create_header_hook
109
1110
@@ -16,25 +15,23 @@ def __init__(self, metagraph: bt.Metagraph, wallet: bt.Wallet, weight_dict: dict
1615 self .wallet = wallet
1716 self .current_hotkey = wallet .hotkey .ss58_address
1817 self .uid = metagraph .hotkeys .index (self .current_hotkey )
19- # Handle testnet case.
20- validator_uids = set ([uid for uid in WHITELISTED_VALIDATORS_UIDS if uid < metagraph .n .item ()])
18+ self .validator_uids = np .where (np .array (metagraph .validator_permit ))[0 ].tolist ()
2119
22- self .weight_matrix = np .zeros ((len (validator_uids ), metagraph .n .item ()))
23- self .stake_matrix = np .array ([metagraph .S [uid ] for uid in validator_uids ])
20+ self .weight_matrix = np .zeros ((len (self . validator_uids ), metagraph .n .item ()))
21+ self .stake_matrix = np .array ([metagraph .S [uid ] for uid in self . validator_uids ])
2422
25- self .validator_uids = np .array (validator_uids )
26- self .validator_hotkeys = np .array ([metagraph .hotkeys [uid ] for uid in validator_uids ])
23+ self .validator_hotkeys = np .array ([metagraph .hotkeys [uid ] for uid in self .validator_uids ])
2724 self .validator_addresses = np .array (
2825 [
2926 f"{ metagraph .axons [uid ].ip } :{ metagraph .axons [uid ].port } "
30- for uid in validator_uids
27+ for uid in self . validator_uids
3128 if uid < metagraph .n .item ()
3229 ]
3330 )
3431
3532 self .weight_dict = weight_dict
3633
37- self .request_tracker = np .zeros (len (validator_uids ))
34+ self .request_tracker = np .zeros (len (self . validator_uids ))
3835
3936 async def make_epistula_request (self , weight_matrix : np .ndarray , validator_address : str , validator_hotkey : str ):
4037 """Make an epistula request to the validator at the given address."""
@@ -83,13 +80,9 @@ async def send_weight_matrixes(self, weight_matrix: np.ndarray):
8380
8481 async def process_weight_dict (self ):
8582 for uid , weights in self .weight_dict .items ():
86- # Verify uid is in whitelist
87- validator_indices = np .where (self .validator_uids == uid )[0 ]
88- if len (validator_indices ) == 0 :
89- logger .error (f"Invalid validator UID { uid } , not in whitelist" )
90- continue
91-
92- # Update the weight matrix for this validator
93- validator_idx = validator_indices [0 ]
94- self .weight_matrix [validator_idx ] = weights
95- self .request_tracker [validator_idx ] = 1
83+ if uid in self .validator_uids :
84+ validator_index = self .validator_uids .index (uid )
85+ self .weight_matrix [validator_index ] = weights
86+ self .request_tracker [validator_index ] = 1
87+ else :
88+ logger .warning (f"UID { uid } is not a validator, skipping" )
0 commit comments