Skip to content

Commit ea0b035

Browse files
committed
Added block_hash specification
1 parent a90217f commit ea0b035

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

bittensor_cli/src/bittensor/subtensor_interface.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,11 @@ async def get_delegates_by_netuid_light(
11201120

11211121
return DelegateInfoLite.list_from_vec_u8(result) # TODO this won't work yet
11221122

1123-
async def get_subnet_dynamic_info(self, netuid: int) -> Optional["DynamicInfo"]:
1123+
async def get_subnet_dynamic_info(
1124+
self, netuid: int, block_hash: Optional[str] = None
1125+
) -> Optional["DynamicInfo"]:
11241126
json = await self.substrate.rpc_request(
1125-
method="subnetInfo_getDynamicInfo", params=[netuid, None]
1127+
method="subnetInfo_getDynamicInfo", params=[netuid, block_hash]
11261128
)
11271129
subnets = DynamicInfo.from_vec_u8(json["result"])
11281130
return subnets
@@ -1188,7 +1190,9 @@ async def multi_get_stake_for_coldkey_and_hotkey_on_netuid(
11881190
for netuid in netuids
11891191
]
11901192
batch_call = await self.substrate.query_multi(calls, block_hash=block_hash)
1191-
results: dict[str, dict[int, "Balance"]] = {hk_ss58: {} for hk_ss58 in hotkey_ss58s}
1193+
results: dict[str, dict[int, "Balance"]] = {
1194+
hk_ss58: {} for hk_ss58 in hotkey_ss58s
1195+
}
11921196
for idx, item in enumerate(batch_call):
11931197
hotkey_idx = idx // len(netuids)
11941198
netuid_idx = idx % len(netuids)

bittensor_cli/src/commands/stake/stake.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,19 @@ async def stake_add(
12551255
hotkey_ss58_or_name = wallet.hotkey.ss58_address
12561256
hotkeys_to_stake_to = [(None, hotkey_ss58_or_name)]
12571257

1258+
starting_chain_head = await subtensor.substrate.get_chain_head()
12581259
all_dynamic_info, initial_stake_balances = await asyncio.gather(
1259-
asyncio.gather(*[subtensor.get_subnet_dynamic_info(x) for x in netuids]),
1260+
asyncio.gather(
1261+
*[
1262+
subtensor.get_subnet_dynamic_info(x, starting_chain_head)
1263+
for x in netuids
1264+
]
1265+
),
12601266
subtensor.multi_get_stake_for_coldkey_and_hotkey_on_netuid(
12611267
hotkey_ss58s=[x[1] for x in hotkeys_to_stake_to],
12621268
coldkey_ss58=wallet.coldkeypub.ss58_address,
12631269
netuids=netuids,
1270+
block_hash=starting_chain_head,
12641271
),
12651272
)
12661273
for hk_name, hk_ss58 in hotkeys_to_stake_to:

0 commit comments

Comments
 (0)