Skip to content
Merged
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
6 changes: 4 additions & 2 deletions cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2462,7 +2462,7 @@ def stake_add(
)
raise typer.Exit()
if not stake_all and not amount:
amount = FloatPrompt.ask("Please enter an amount to stake.")
amount = FloatPrompt.ask("[blue bold]Amount to stake (TAO τ)[/blue bold]")
if stake_all and not amount:
if not Confirm.ask("Stake all available TAO tokens?", default=False):
raise typer.Exit()
Expand Down Expand Up @@ -2566,7 +2566,9 @@ def stake_remove(
)
raise typer.Exit()
if not unstake_all and not amount:
amount = FloatPrompt.ask("Please enter an amount to unstake.")
amount = FloatPrompt.ask(
"[blue bold]Amount to unstakestake (TAO τ)[/blue bold]"
)
if unstake_all and not amount:
if not Confirm.ask("Unstake all staked TAO tokens?", default=False):
raise typer.Exit()
Expand Down
15 changes: 8 additions & 7 deletions src/commands/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ async def add_stake_extrinsic(
# Stake it all.
staking_balance = Balance.from_tao(old_balance.tao)
else:
staking_balance = amount
staking_balance = Balance.from_tao(amount)

# Leave existential balance to keep key alive.
if staking_balance > old_balance - existential_deposit:
Expand Down Expand Up @@ -551,7 +551,8 @@ async def unstake_extrinsic(

with console.status(
f":satellite: Unstaking from chain: [white]{subtensor}[/white] ..."
):
):
unstaking_balance = Balance.from_tao(unstaking_balance)
call = await subtensor.substrate.compose_call(
call_module="SubtensorModule",
call_function="remove_stake",
Expand Down Expand Up @@ -579,7 +580,7 @@ async def unstake_extrinsic(
wallet.coldkeypub.ss58_address, block_hash=new_block_hash
),
subtensor.get_stake_for_coldkey_and_hotkey(
hotkey_ss58, wallet.coldkeypub.ss58_address, block_hash
hotkey_ss58, wallet.coldkeypub.ss58_address, new_block_hash
),
)
console.print(
Expand Down Expand Up @@ -1268,7 +1269,7 @@ async def null():
raise ValueError

# Ask to stake
if not False: # TODO no-prompt
if not True: # TODO no-prompt
if not Confirm.ask(
f"Do you want to stake to the following keys from {wallet.name}:\n"
+ "".join(
Expand All @@ -1290,7 +1291,7 @@ async def null():
hotkey_ss58=final_hotkeys[0][1],
amount=None if stake_all else final_amounts[0],
wait_for_inclusion=True,
prompt=True,
prompt=False,
)
else:
await add_stake_multiple_extrinsic(
Expand Down Expand Up @@ -1401,7 +1402,7 @@ async def unstake(
return None

# Ask to unstake
if not False: # TODO no prompt
if not True: # TODO no prompt
if not Confirm.ask(
f"Do you want to unstake from the following keys to {wallet.name}:\n"
+ "".join(
Expand All @@ -1422,7 +1423,7 @@ async def unstake(
hotkey_ss58=final_hotkeys[0][1],
amount=None if unstake_all else final_amounts[0],
wait_for_inclusion=True,
prompt=True,
prompt=False, #TODO: Add no prompt
)
else:
await unstake_multiple_extrinsic(
Expand Down
72 changes: 48 additions & 24 deletions src/commands/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,37 +175,61 @@ async def _get_all_subnets_info():
f"{delegate_info[subnet.owner_ss58].name if subnet.owner_ss58 in delegate_info else subnet.owner_ss58}",
)
)

table_width = console.width - 20

table = Table(
Column(
"[overline white]NETUID",
str(len(subnets)),
footer_style="overline white",
style="bold green",
justify="center",
),
Column(
"[overline white]N",
str(total_neurons),
footer_style="overline white",
style="green",
justify="center",
),
Column("[overline white]MAX_N", style="white", justify="center"),
Column("[overline white]EMISSION", style="white", justify="center"),
Column("[overline white]TEMPO", style="white", justify="center"),
Column("[overline white]RECYCLE", style="white", justify="center"),
Column("[overline white]POW", style="white", justify="center"),
Column("[overline white]SUDO", style="white"),
title=f"[white]Subnets - {subtensor.network}",
title=f"[bold magenta]Subnets - {subtensor.network}[/bold magenta]",
show_footer=True,
width=None,
show_edge=False,
header_style="bold white",
border_style="bright_black",
style="bold",
title_style="bold white",
title_justify="center",
show_lines=False,
expand=True,
width=table_width,
pad_edge=True,
box=None,
show_edge=True,
)

table.add_column(
"[bold white]NETUID",
footer=f"[white]{len(subnets)}[/white]",
style="white",
justify="center",
)
table.add_column(
"[bold white]N",
footer=f"[white]{total_neurons}[/white]",
style="bright_cyan",
justify="center",
)
table.add_column("[bold white]MAX_N", style="bright_yellow", justify="center")
table.add_column("[bold white]EMISSION", style="bright_yellow", justify="center")
table.add_column("[bold white]TEMPO", style="magenta", justify="center")
table.add_column("[bold white]RECYCLE", style="bright_red", justify="center")
table.add_column("[bold white]POW", style="medium_purple", justify="center")
table.add_column("[bold white]SUDO", style="bright_magenta", justify="center")

for row in rows:
table.add_row(*row)

console.print(table)
console.print(
"""
Description:
The table displays the list of subnets registered in the Bittensor network.
- NETIUID: The network identifier of the subnet.
- N: The current UIDs registered to the network.
- MAX_N: The total UIDs allowed on the network.
- EMISSION: The emission accrued by this subnet in the network.
- TEMPO: A duration of a number of blocks. Several subnet events occur at the end of every tempo period.
- RECYCLE: Cost to register to the subnet.
- POW: Proof of work metric of the subnet.
- SUDO: Owner's identity.
"""
)


async def lock_cost(subtensor: "SubtensorInterface") -> Optional[Balance]:
Expand Down
90 changes: 45 additions & 45 deletions src/commands/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,55 +104,55 @@ async def set_hyperparameter_extrinsic(
with console.status(
f":satellite: Setting hyperparameter {parameter} to {value} on subnet: {netuid} ..."
):
with subtensor.substrate as substrate:
extrinsic_params = await substrate.get_metadata_call_function(
"AdminUtils", extrinsic
)
call_params: dict[str, Union[str, bool, float]] = {"netuid": netuid}

# if input value is a list, iterate through the list and assign values
if isinstance(value, list):
# Ensure that there are enough values for all non-netuid parameters
non_netuid_fields = [
param["name"]
for param in extrinsic_params["fields"]
if "netuid" not in param["name"]
]

if len(value) < len(non_netuid_fields):
raise ValueError(
"Not enough values provided in the list for all parameters"
)

call_params.update(
{str(name): val for name, val in zip(non_netuid_fields, value)}
substrate = subtensor.substrate
extrinsic_params = await substrate.get_metadata_call_function(
"AdminUtils", extrinsic
)
call_params: dict[str, Union[str, bool, float]] = {"netuid": netuid}

# if input value is a list, iterate through the list and assign values
if isinstance(value, list):
# Ensure that there are enough values for all non-netuid parameters
non_netuid_fields = [
param["name"]
for param in extrinsic_params["fields"]
if "netuid" not in param["name"]
]

if len(value) < len(non_netuid_fields):
raise ValueError(
"Not enough values provided in the list for all parameters"
)

else:
value_argument = extrinsic_params["fields"][
len(extrinsic_params["fields"]) - 1
]
call_params[str(value_argument["name"])] = value

# create extrinsic call
call = await substrate.compose_call(
call_module="AdminUtils",
call_function=extrinsic,
call_params=call_params,
call_params.update(
{str(name): val for name, val in zip(non_netuid_fields, value)}
)
success, err_msg = await subtensor.sign_and_send_extrinsic(
call, wallet, wait_for_inclusion, wait_for_finalization

else:
value_argument = extrinsic_params["fields"][
len(extrinsic_params["fields"]) - 1
]
call_params[str(value_argument["name"])] = value

# create extrinsic call
call = await substrate.compose_call(
call_module="AdminUtils",
call_function=extrinsic,
call_params=call_params,
)
success, err_msg = await subtensor.sign_and_send_extrinsic(
call, wallet, wait_for_inclusion, wait_for_finalization
)
if not success:
err_console.print(f":cross_mark: [red]Failed[/red]: {err_msg}")
await asyncio.sleep(0.5)

# Successful registration, final check for membership
else:
console.print(
f":white_heavy_check_mark: [green]Hyper parameter {parameter} changed to {value}[/green]"
)
if not success:
err_console.print(f":cross_mark: [red]Failed[/red]: {err_msg}")
await asyncio.sleep(0.5)

# Successful registration, final check for membership
else:
console.print(
f":white_heavy_check_mark: [green]Hyper parameter {parameter} changed to {value}[/green]"
)
return True
return True


# commands
Expand Down
Loading