Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] wallet inspect improvements #243

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bittensor_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
37 changes: 22 additions & 15 deletions bittensor_cli/src/commands/wallets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -1362,24 +1358,35 @@ 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)
for w in wallets_with_ckp_file
]
),
)

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 []
Expand Down
Loading