diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 3b6096047..669459ddc 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -13,7 +13,7 @@ import warnings from dataclasses import fields from pathlib import Path -from typing import Coroutine, Optional, Union, Literal +from typing import Coroutine, Optional, Union import numpy as np import rich @@ -93,7 +93,6 @@ subnets, mechanisms as subnet_mechanisms, ) -from bittensor_cli.src.commands.wallets import SortByBalance from bittensor_cli.version import __version__, __version_as_int__ try: @@ -1343,6 +1342,7 @@ async def _run(): except Exception as e: # ensures we always exit cleanly if not isinstance(e, (typer.Exit, RuntimeError)): err_console.print(f"An unknown error has occurred: {e}") + traceback.print_exc() if exception_occurred: raise typer.Exit() diff --git a/bittensor_cli/src/bittensor/subtensor_interface.py b/bittensor_cli/src/bittensor/subtensor_interface.py index 2ef90d284..12b0b6139 100644 --- a/bittensor_cli/src/bittensor/subtensor_interface.py +++ b/bittensor_cli/src/bittensor/subtensor_interface.py @@ -1,4 +1,5 @@ import asyncio +import logging import os import time from typing import Optional, Any, Union, TypedDict, Iterable @@ -45,6 +46,8 @@ get_hotkey_pub_ss58, ) +logger = logging.getLogger("btcli") + class ParamWithTypes(TypedDict): name: str # Name of the parameter. @@ -113,6 +116,7 @@ def __init__(self, network, use_disk_cache: bool = False): if (use_disk_cache or os.getenv("DISK_CACHE", "0") == "1") else AsyncSubstrateInterface ) + logger.debug(f"Using substrate class {substrate_class.__name__}") self.substrate = substrate_class( url=self.chain_endpoint, ss58_format=SS58_FORMAT, @@ -438,11 +442,11 @@ async def get_total_stake_for_coldkey( :return: {address: Balance objects} """ - sub_stakes = await self.get_stake_for_coldkeys( - list(ss58_addresses), block_hash=block_hash + sub_stakes, dynamic_info = await asyncio.gather( + self.get_stake_for_coldkeys(list(ss58_addresses), block_hash=block_hash), + # Token pricing info + self.all_subnets(block_hash=block_hash), ) - # Token pricing info - dynamic_info = await self.all_subnets() results = {} for ss58, stake_info_list in sub_stakes.items(): diff --git a/bittensor_cli/src/commands/wallets.py b/bittensor_cli/src/commands/wallets.py index 6473f2c69..607c71962 100644 --- a/bittensor_cli/src/commands/wallets.py +++ b/bittensor_cli/src/commands/wallets.py @@ -697,7 +697,6 @@ async def wallet_balance( str(total_free_balance + total_staked_balance), ) console.print(Padding(table, (0, 0, 0, 4))) - await subtensor.substrate.close() if json_output: output_balances = { key: { @@ -2175,7 +2174,10 @@ async def find_coldkey_swap_extrinsic( ): console.print("Querying archive node for coldkey swap events...") await subtensor.substrate.close() - subtensor = SubtensorInterface("archive") + subtensor.substrate.chain_endpoint = Constants.archive_entrypoint + subtensor.substrate.url = Constants.archive_entrypoint + subtensor.substrate.initialized = False + await subtensor.substrate.initialize() block_hashes = await asyncio.gather( *[