From 274e207d8cfa2be16891af6fa143173fc80a9a4a Mon Sep 17 00:00:00 2001 From: Landyn Date: Thu, 16 Apr 2026 21:42:24 -0500 Subject: [PATCH] SS58-encode hotkey from query_map in read_miner_commitments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit substrate-interface's query_map over the Commitments.CommitmentOf double map returns the second-map key (hotkey AccountId) as raw bytes wrapped in a single-element tuple. Commit 47155d1 batched the commitment reads via query_map but compared the str() of that tuple against the metagraph's SS58 hotkey index — so the lookup always returned None and every miner's commitment got dropped. Result: 'alw view rates', scoring rate aggregation, and any swap that relies on a posted miner commitment returned empty. Decode the tuple to 32 bytes and ss58_encode with prefix 42 to match how the metagraph keys hotkeys. --- allways/commitments.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/allways/commitments.py b/allways/commitments.py index 18c8bde..9138f89 100644 --- a/allways/commitments.py +++ b/allways/commitments.py @@ -3,11 +3,14 @@ from typing import List, Optional import bittensor as bt +from substrateinterface.utils.ss58 import ss58_encode from allways.chains import SUPPORTED_CHAINS, canonical_pair from allways.classes import MinerPair from allways.constants import COMMITMENT_VERSION +SS58_PREFIX = 42 + def parse_commitment_data(raw: str, uid: int = 0, hotkey: str = '') -> Optional[MinerPair]: """Parse a commitment string into a MinerPair. @@ -145,7 +148,18 @@ def read_miner_commitments(subtensor: bt.Subtensor, netuid: int) -> List[MinerPa params=[netuid], ) for key, metadata in result: - hotkey = str(key.value) if hasattr(key, 'value') else str(key) + # query_map returns the second-map key (hotkey AccountId) as raw + # bytes inside a single-element tuple, not an SS58 string. Encode + # it so we can look the miner up in the metagraph's hotkey index. + raw = key.value if hasattr(key, 'value') else key + if isinstance(raw, tuple) and len(raw) == 1: + raw = raw[0] + if isinstance(raw, (tuple, list)): + raw = bytes(raw) + if isinstance(raw, (bytes, bytearray)) and len(raw) == 32: + hotkey = ss58_encode(bytes(raw), SS58_PREFIX) + else: + hotkey = str(raw) uid = hotkey_to_uid.get(hotkey) if uid is None: continue # miner dereg'd but commitment still in storage