From 3257a91826b4516856c1a3fe2f2b656923153586 Mon Sep 17 00:00:00 2001 From: BD Himes Date: Thu, 18 Dec 2025 14:47:11 +0200 Subject: [PATCH 1/5] Add success path. --- bittensor_cli/src/commands/subnets/subnets.py | 140 +++++++++--------- 1 file changed, 68 insertions(+), 72 deletions(-) diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index 305a2de64..4d738ae17 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,66 @@ 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}") + console.print(f":white_check_mark:[green]Success:[/green] {msg}") # TODO: Confirm emissions, incentive, Dividends are to be fetched from subnet_state or keep NeuronInfo From bdb91374a8d1d10d9e446cf47ff474a4a4c3ccf2 Mon Sep 17 00:00:00 2001 From: BD Himes Date: Thu, 18 Dec 2025 14:51:37 +0200 Subject: [PATCH 2/5] Removed success path (it's already done in the inner fns) --- bittensor_cli/src/commands/subnets/subnets.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/bittensor_cli/src/commands/subnets/subnets.py b/bittensor_cli/src/commands/subnets/subnets.py index 4d738ae17..77c9a16b7 100644 --- a/bittensor_cli/src/commands/subnets/subnets.py +++ b/bittensor_cli/src/commands/subnets/subnets.py @@ -2034,8 +2034,6 @@ async def _storage_key(storage_fn: str) -> StorageKey: json_console.print( json.dumps({"success": success, "msg": msg, "extrinsic_identifier": ext_id}) ) - else: - console.print(f":white_check_mark:[green]Success:[/green] {msg}") # TODO: Confirm emissions, incentive, Dividends are to be fetched from subnet_state or keep NeuronInfo From f3204871527921af8b2022166cf332453ebf260d Mon Sep 17 00:00:00 2001 From: BD Himes Date: Thu, 18 Dec 2025 15:22:14 +0200 Subject: [PATCH 3/5] Update proxy Address book col headings --- bittensor_cli/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"), From 139bafff431a92b77865f32c53045583d59531ba Mon Sep 17 00:00:00 2001 From: BD Himes Date: Thu, 18 Dec 2025 17:27:18 +0200 Subject: [PATCH 4/5] Handle docs in args --- bittensor_cli/src/commands/proxy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bittensor_cli/src/commands/proxy.py b/bittensor_cli/src/commands/proxy.py index f3d4cf747..e10c37853 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(arg, dict): + # _docs usually + continue type_name = fns[module][call_fn][arg]["typeName"] if type_name == "AccountIdLookupOf": value = is_valid_ss58_address_prompt( From 32f15f86a158d528b01123951fdb6d43445fb191 Mon Sep 17 00:00:00 2001 From: BD Himes Date: Thu, 18 Dec 2025 17:42:38 +0200 Subject: [PATCH 5/5] Oepsie --- bittensor_cli/src/commands/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor_cli/src/commands/proxy.py b/bittensor_cli/src/commands/proxy.py index e10c37853..5438c9c17 100644 --- a/bittensor_cli/src/commands/proxy.py +++ b/bittensor_cli/src/commands/proxy.py @@ -577,7 +577,7 @@ async def execute_announced( show_choices=True, ) for arg in fns[module][call_fn].keys(): - if not isinstance(arg, dict): + if not isinstance(fns[module][call_fn][arg], dict): # _docs usually continue type_name = fns[module][call_fn][arg]["typeName"]