diff --git a/bittensor_cli/cli.py b/bittensor_cli/cli.py index 9fd55345c..871c76900 100755 --- a/bittensor_cli/cli.py +++ b/bittensor_cli/cli.py @@ -2068,8 +2068,8 @@ def config_get_proxies(self): """ table = Table( Column("[bold white]Name", style=f"{COLORS.G.ARG}"), - Column("Address", style="gold1"), - Column("Spawner/Delegator", style="medium_purple"), + Column("Address/Delegator", style="gold1"), + Column("Spawner/Delegatee", style="medium_purple"), Column("Proxy Type", style="medium_purple"), Column("Delay", style="dim"), Column("Note", style="dim"), diff --git a/bittensor_cli/src/commands/proxy.py b/bittensor_cli/src/commands/proxy.py index f3d4cf747..5438c9c17 100644 --- a/bittensor_cli/src/commands/proxy.py +++ b/bittensor_cli/src/commands/proxy.py @@ -577,6 +577,9 @@ async def execute_announced( show_choices=True, ) for arg in fns[module][call_fn].keys(): + if not isinstance(fns[module][call_fn][arg], dict): + # _docs usually + continue type_name = fns[module][call_fn][arg]["typeName"] if type_name == "AccountIdLookupOf": value = is_valid_ss58_address_prompt( diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index 305a2de64..77c9a16b7 100644 --- a/bittensor_cli/src/commands/subnets/subnets.py +++ b/bittensor_cli/src/commands/subnets/subnets.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Optional, cast from async_substrate_interface import AsyncExtrinsicReceipt +from async_substrate_interface.utils.storage import StorageKey from bittensor_wallet import Wallet from rich.prompt import Prompt from rich.console import Group @@ -1846,6 +1847,18 @@ async def register( proxy: Optional[str] = None, ): """Register neuron by recycling some TAO.""" + + async def _storage_key(storage_fn: str) -> StorageKey: + """ + Generates a SubtensorModule storage key with [netuid] as the param for a given storage function + """ + return await subtensor.substrate.create_storage_key( + pallet="SubtensorModule", + storage_function=storage_fn, + params=[netuid], + block_hash=block_hash, + ) + coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address # Verify subnet exists print_verbose("Checking subnet status") @@ -1862,76 +1875,6 @@ async def register( ) return - print_verbose("Checking registration allowed and limits") - ( - registration_allowed, - target_registrations_per_interval, - registrations_this_interval, - last_adjustment_block, - adjustment_interval, - current_block, - ) = await asyncio.gather( - subtensor.query( - module="SubtensorModule", - storage_function="NetworkRegistrationAllowed", - params=[netuid], - block_hash=block_hash, - ), - subtensor.query( - module="SubtensorModule", - storage_function="TargetRegistrationsPerInterval", - params=[netuid], - block_hash=block_hash, - ), - subtensor.query( - module="SubtensorModule", - storage_function="RegistrationsThisInterval", - params=[netuid], - block_hash=block_hash, - ), - subtensor.query( - module="SubtensorModule", - storage_function="LastAdjustmentBlock", - params=[netuid], - block_hash=block_hash, - ), - subtensor.query( - module="SubtensorModule", - storage_function="AdjustmentInterval", - params=[netuid], - block_hash=block_hash, - ), - subtensor.substrate.get_block_number(block_hash), - ) - - if not registration_allowed: - err_console.print(f"[red]Registration to subnet {netuid} is not allowed[/red]") - if json_output: - json_console.print_json( - data={ - "success": False, - "msg": f"Registration to subnet {netuid} is not allowed", - "extrinsic_identifier": None, - } - ) - return - - if registrations_this_interval >= target_registrations_per_interval * 3: - next_adjustment_block = int(last_adjustment_block) + int(adjustment_interval) - remaining_blocks = next_adjustment_block - int(current_block) - err_console.print( - f"[red]Registration to subnet {netuid} is full for this interval. Try again in {remaining_blocks} blocks.[/red]" - ) - if json_output: - json_console.print_json( - data={ - "success": False, - "msg": f"Registration to subnet {netuid} is full for this interval. Try again in {remaining_blocks} blocks.", - "extrinsic_identifier": None, - } - ) - return - # Check current recycle amount print_verbose("Fetching recycle amount") current_recycle_, balance = await asyncio.gather( @@ -2033,13 +1976,64 @@ async def register( era=era, proxy=proxy, ) + if not success: + err_console.print(f":cross_mark:[red]Failure[/red]: {msg}") + print_verbose("Checking registration allowed and limits") + storage_key_results, current_block = await asyncio.gather( + subtensor.substrate.query_multi( + [ + await _storage_key("NetworkRegistrationAllowed"), + await _storage_key("TargetRegistrationsPerInterval"), + await _storage_key("RegistrationsThisInterval"), + await _storage_key("LastAdjustmentBlock"), + await _storage_key("AdjustmentInterval"), + ] + ), + subtensor.substrate.get_block_number(block_hash), + ) + ( + registration_allowed, + target_registrations_per_interval, + registrations_this_interval, + last_adjustment_block, + adjustment_interval, + ) = [x[1] for x in storage_key_results] + + if not registration_allowed: + err_console.print( + f"[red]Registration to subnet {netuid} is not allowed[/red]" + ) + if json_output: + json_console.print_json( + data={ + "success": False, + "msg": f"Registration to subnet {netuid} is not allowed", + "extrinsic_identifier": None, + } + ) + return + + if registrations_this_interval >= target_registrations_per_interval * 3: + next_adjustment_block = last_adjustment_block + adjustment_interval + remaining_blocks = next_adjustment_block - current_block + err_console.print( + f"[red]Registration to subnet {netuid} is full for this interval.[/red] " + f"Try again in {remaining_blocks} blocks." + ) + if json_output: + json_console.print_json( + data={ + "success": False, + "msg": f"Registration to subnet {netuid} is full for this interval. " + f"Try again in {remaining_blocks} blocks.", + "extrinsic_identifier": None, + } + ) + return if json_output: json_console.print( json.dumps({"success": success, "msg": msg, "extrinsic_identifier": ext_id}) ) - else: - if not success: - err_console.print(f"Failure: {msg}") # TODO: Confirm emissions, incentive, Dividends are to be fetched from subnet_state or keep NeuronInfo