diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 0956de62..49a4718b 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -1568,7 +1568,7 @@ def wallet_inspect( verbose: bool = Options.verbose, ): """ - Displays the details of the user's wallet pairs (coldkey, hotkey) on the Bittensor network. + Displays the details of the user's wallet pairs (coldkey to delegated and owned hotkeys) on the Bittensor network. The output is presented as a table with the below columns: diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 69188053..b593e0b9 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -3,7 +3,7 @@ import itertools import os import sys -from collections import defaultdict +from collections import defaultdict, namedtuple from functools import partial from sys import getsizeof from typing import Collection, Generator, Optional @@ -60,10 +60,13 @@ class WalletLike: + hotkey = namedtuple("hotkey", ["ss58_address"]) + def __init__(self, name=None, hotkey_ss58=None, hotkey_str=None): self.name = name self.hotkey_ss58 = hotkey_ss58 self.hotkey_str = hotkey_str + self.hotkey = self.hotkey(hotkey_ss58) async def regen_coldkey( @@ -1325,13 +1328,6 @@ def neuron_row_maker( block_hash = await subtensor.substrate.get_chain_head() await subtensor.substrate.init_runtime(block_hash=block_hash) - print_verbose("Fetching netuids of registered hotkeys", status) - all_netuids = await subtensor.filter_netuids_by_registered_hotkeys( - (await subtensor.get_all_subnet_netuids(block_hash)), - netuids_filter, - all_hotkeys, - block_hash=block_hash, - ) # bittensor.logging.debug(f"Netuids to check: {all_netuids}") with console.status("Pulling delegates info...", spinner="aesthetic"): registered_delegate_info = await subtensor.get_delegate_identities() @@ -1362,17 +1358,13 @@ def neuron_row_maker( ] all_delegates: list[list[tuple[DelegateInfo, Balance]]] with console.status("Pulling balance data...", spinner="aesthetic"): - balances, all_neurons, all_delegates = await asyncio.gather( + # print_verbose("Fetching netuids of registered hotkeys", status) + # TODO this fetches only netuids where the hotkey is on the device. I don't think this is intended. + balances, all_delegates = await asyncio.gather( subtensor.get_balance( *[w.coldkeypub.ss58_address for w in wallets_with_ckp_file], block_hash=block_hash, ), - asyncio.gather( - *[ - subtensor.neurons_lite(netuid=netuid, block_hash=block_hash) - for netuid in all_netuids - ] - ), asyncio.gather( *[ subtensor.get_delegated(w.coldkeypub.ss58_address) @@ -1380,6 +1372,21 @@ def neuron_row_maker( ] ), ) + + all_hotkeys.extend([WalletLike(hotkey_ss58=y.hotkey_ss58) for x in all_delegates for (y, _) in x]) + + all_netuids = await subtensor.filter_netuids_by_registered_hotkeys( + (await subtensor.get_all_subnet_netuids(block_hash)), + netuids_filter, + all_hotkeys, + block_hash=block_hash, + ) + all_neurons = await asyncio.gather( + *[ + subtensor.neurons_lite(netuid=netuid, block_hash=block_hash) + for netuid in all_netuids + ] + ) neuron_state_dict = {} for netuid, neuron in zip(all_netuids, all_neurons): neuron_state_dict[netuid] = neuron if neuron else []