Skip to content

Commit

Permalink
Adds recycle cost to s show
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheem-opentensor committed Feb 6, 2025
1 parent 093b1e0 commit d1c59a5
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions bittensor_cli/src/commands/subnets/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,16 +810,17 @@ async def show(
prompt: bool = True,
) -> Optional[str]:
async def show_root():
all_subnets = await subtensor.all_subnets()
block_hash = await subtensor.substrate.get_chain_head()
all_subnets = await subtensor.all_subnets(block_hash=block_hash)
root_info = next((s for s in all_subnets if s.netuid == 0), None)
if root_info is None:
print_error("The root subnet does not exist")
raise typer.Exit()

root_state, identities, old_identities = await asyncio.gather(
subtensor.get_subnet_state(netuid=0),
subtensor.query_all_identities(),
subtensor.get_delegate_identities(),
subtensor.get_subnet_state(netuid=0, block_hash=block_hash),
subtensor.query_all_identities(block_hash=block_hash),
subtensor.get_delegate_identities(block_hash=block_hash),
)

if root_state is None:
Expand Down Expand Up @@ -1031,16 +1032,21 @@ async def show_subnet(netuid_: int):
if not await subtensor.subnet_exists(netuid=netuid):
err_console.print(f"[red]Subnet {netuid} does not exist[/red]")
raise typer.Exit()
block_hash = await subtensor.substrate.get_chain_head()
(
subnet_info,
subnet_state,
identities,
old_identities,
current_burn_cost,
) = await asyncio.gather(
subtensor.subnet(netuid=netuid_),
subtensor.get_subnet_state(netuid=netuid_),
subtensor.query_all_identities(),
subtensor.get_delegate_identities(),
subtensor.subnet(netuid=netuid_, block_hash=block_hash),
subtensor.get_subnet_state(netuid=netuid_, block_hash=block_hash),
subtensor.query_all_identities(block_hash=block_hash),
subtensor.get_delegate_identities(block_hash=block_hash),
subtensor.get_hyperparameter(
param_name="Burn", netuid=netuid_, block_hash=block_hash
),
)
if subnet_state is None:
print_error(f"Subnet {netuid_} does not exist")
Expand Down Expand Up @@ -1281,6 +1287,11 @@ async def show_subnet(netuid_: int):
if not verbose
else f"{subnet_info.alpha_in.tao:,.4f}"
)
current_registration_burn = (
Balance.from_rao(int(current_burn_cost))
if current_burn_cost
else Balance(0)
)

console.print(
f"[{COLOR_PALETTE['GENERAL']['SUBHEADING']}]Subnet {netuid_}{subnet_name_display}[/{COLOR_PALETTE['GENERAL']['SUBHEADING']}]"
Expand All @@ -1291,6 +1302,7 @@ async def show_subnet(netuid_: int):
f"\n Alpha Pool: [{COLOR_PALETTE['POOLS']['ALPHA_IN']}]{alpha_pool} {subnet_info.symbol}[/{COLOR_PALETTE['POOLS']['ALPHA_IN']}]"
# f"\n Stake: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{subnet_info.alpha_out.tao:,.5f} {subnet_info.symbol}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
f"\n Tempo: [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]{subnet_info.blocks_since_last_step}/{subnet_info.tempo}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
f"\n Registration cost (recycled): [{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}{current_registration_burn.tao:.4f}[/{COLOR_PALETTE['STAKE']['STAKE_ALPHA']}]"
)
# console.print(
# """
Expand Down

0 comments on commit d1c59a5

Please sign in to comment.