From 1ab5e20faad8dd9085f37fa5da3384f717cfa330 Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Wed, 13 Nov 2024 19:01:45 +0200 Subject: [PATCH 1/3] WIP --- bittensor_cli/cli.py | 2 +- bittensor_cli/src/commands/wallets.py | 34 ++++++++++++++++----------- 2 files changed, 21 insertions(+), 15 deletions(-) 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..11dc792c 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -1325,13 +1325,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 +1355,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 +1369,23 @@ def neuron_row_maker( ] ), ) + for x in all_delegates: + for y, z in x: + all_hotkeys.append(y.hotkey_ss58) + # all_hotkeys.extend([x.hotkey_ss58 for x in all_delegates[0]]) + print(all_hotkeys) + 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 [] From fd51a0dee600bb2a18cd8dcf92ccdf570652cd0f Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Wed, 13 Nov 2024 22:28:47 +0200 Subject: [PATCH 2/3] WIP --- bittensor_cli/src/commands/wallets.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 11dc792c..6ec399ca 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( @@ -1371,9 +1374,8 @@ def neuron_row_maker( ) for x in all_delegates: for y, z in x: - all_hotkeys.append(y.hotkey_ss58) - # all_hotkeys.extend([x.hotkey_ss58 for x in all_delegates[0]]) - print(all_hotkeys) + all_hotkeys.append(WalletLike(hotkey_ss58=y.hotkey_ss58)) + all_netuids = await subtensor.filter_netuids_by_registered_hotkeys( (await subtensor.get_all_subnet_netuids(block_hash)), netuids_filter, From 06e96a8a2e03ec67d597b4b7e1c489d745a1a4be Mon Sep 17 00:00:00 2001 From: Benjamin Himes Date: Wed, 13 Nov 2024 22:38:41 +0200 Subject: [PATCH 3/3] Capture more delegate info --- bittensor_cli/src/commands/wallets.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 6ec399ca..b593e0b9 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -1372,9 +1372,8 @@ def neuron_row_maker( ] ), ) - for x in all_delegates: - for y, z in x: - all_hotkeys.append(WalletLike(hotkey_ss58=y.hotkey_ss58)) + + 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)),