From 9acdcc511acaf8b82ebfd4502adb9345bba11633 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Tue, 11 Feb 2025 17:28:46 -0800 Subject: [PATCH 1/4] Adds Tao emissions to subnets list --- bittensor_cli/src/bittensor/chain_data.py | 12 +++++++++++- bittensor_cli/src/commands/stake/list.py | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bittensor_cli/src/bittensor/chain_data.py b/bittensor_cli/src/bittensor/chain_data.py index 3b5a4c89a..42beef3d0 100644 --- a/bittensor_cli/src/bittensor/chain_data.py +++ b/bittensor_cli/src/bittensor/chain_data.py @@ -197,6 +197,7 @@ class StakeInfo(InfoBase): stake: Balance # Stake for the hotkey-coldkey pair locked: Balance # Stake which is locked. emission: Balance # Emission for the hotkey-coldkey pair + tao_emission: Balance # TAO emission for the hotkey-coldkey pair drain: int is_registered: bool @@ -208,11 +209,20 @@ def _fix_decoded(cls, decoded: Any) -> "StakeInfo": stake = Balance.from_rao(decoded.get("stake")).set_unit(netuid) locked = Balance.from_rao(decoded.get("locked")).set_unit(netuid) emission = Balance.from_rao(decoded.get("emission")).set_unit(netuid) + tao_emission = Balance.from_rao(decoded.get("tao_emission")) drain = int(decoded.get("drain")) is_registered = bool(decoded.get("is_registered")) return StakeInfo( - hotkey, coldkey, netuid, stake, locked, emission, drain, is_registered + hotkey, + coldkey, + netuid, + stake, + locked, + emission, + tao_emission, + drain, + is_registered, ) diff --git a/bittensor_cli/src/commands/stake/list.py b/bittensor_cli/src/commands/stake/list.py index 9f2ba7763..21fc46fcb 100644 --- a/bittensor_cli/src/commands/stake/list.py +++ b/bittensor_cli/src/commands/stake/list.py @@ -130,6 +130,11 @@ def define_table( style=COLOR_PALETTE["POOLS"]["EMISSION"], justify="right", ) + table.add_column( + f"[white]Emission \n({Balance.get_unit(0)}/block)", + style=COLOR_PALETTE["POOLS"]["EMISSION"], + justify="right", + ) return table def create_table(hotkey_: str, substakes: list[StakeInfo]): @@ -200,6 +205,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]): # Per block emission cell per_block_emission = substake_.emission.tao / pool.tempo + per_block_tao_emission = substake_.tao_emission.tao / pool.tempo # Alpha ownership and TAO ownership cells if alpha_value.tao > 0.00009: if issuance.tao != 0: @@ -243,6 +249,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]): # Removing this flag for now, TODO: Confirm correct values are here w.r.t CHKs # if substake_.is_registered # else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]N/A", # Emission(α/block) + str(Balance.from_tao(per_block_tao_emission)), ] ) table = define_table( @@ -343,6 +350,7 @@ def format_cell( "swapped_value": swapped_tao_value.tao, "emission": substake.emission.tao / pool.tempo, "tao_ownership": tao_ownership.tao, + "tao_emission": substake.tao_emission.tao / pool.tempo, } # Get previous values for delta tracking @@ -408,6 +416,16 @@ def format_cell( unit_first=unit_first, precision=4, ) + + tao_emission_value = substake.tao_emission.tao / pool.tempo + tao_emission_cell = format_cell( + tao_emission_value, + prev.get("tao_emission"), + unit="τ", + unit_first=unit_first, + precision=4, + ) + subnet_name_cell = ( f"[{COLOR_PALETTE['GENERAL']['SYMBOL']}]{symbol if netuid != 0 else 'τ'}[/{COLOR_PALETTE['GENERAL']['SYMBOL']}]" f" {get_subnet_name(dynamic_info[netuid])}" @@ -425,6 +443,7 @@ def format_cell( if substake.is_registered else f"[{COLOR_PALETTE['STAKE']['NOT_REGISTERED']}]NO", # Registration status emission_cell, # Emission rate + tao_emission_cell, # TAO emission rate ] ) From c27246fba3cc9d102a4be525567219f5875e620b Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Tue, 18 Feb 2025 08:23:48 -0800 Subject: [PATCH 2/4] merges staging --- bittensor_cli/src/commands/stake/list.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor_cli/src/commands/stake/list.py b/bittensor_cli/src/commands/stake/list.py index 64914c2ed..ab14ba433 100644 --- a/bittensor_cli/src/commands/stake/list.py +++ b/bittensor_cli/src/commands/stake/list.py @@ -206,7 +206,7 @@ def create_table(hotkey_: str, substakes: list[StakeInfo]): # Per block emission cell per_block_emission = substake_.emission.tao / (pool.tempo or 1) - per_block_tao_emission = unstake.tao_emission.tao / (pool.tempo or 1) + per_block_tao_emission = substake_.tao_emission.tao / (pool.tempo or 1) # Alpha ownership and TAO ownership cells if alpha_value.tao > 0.00009: if issuance.tao != 0: From de235ac630b1324b9c471443fbc97c4b62048093 Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Tue, 18 Feb 2025 08:27:14 -0800 Subject: [PATCH 3/4] Handles div by zero --- bittensor_cli/src/commands/stake/list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bittensor_cli/src/commands/stake/list.py b/bittensor_cli/src/commands/stake/list.py index ab14ba433..2545725ec 100644 --- a/bittensor_cli/src/commands/stake/list.py +++ b/bittensor_cli/src/commands/stake/list.py @@ -351,7 +351,7 @@ def format_cell( "swapped_value": swapped_tao_value.tao, "emission": substake.emission.tao / (pool.tempo or 1), "tao_ownership": tao_ownership.tao, - "tao_emission": substake.tao_emission.tao / pool.tempo, + "tao_emission": substake.tao_emission.tao (pool.tempo or 1), } # Get previous values for delta tracking @@ -418,7 +418,7 @@ def format_cell( precision=4, ) - tao_emission_value = substake.tao_emission.tao / pool.tempo + tao_emission_value = substake.tao_emission.tao / (pool.tempo or 1) tao_emission_cell = format_cell( tao_emission_value, prev.get("tao_emission"), From 44e124fe492558adc14b6001b49ad2b30aec115e Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Tue, 18 Feb 2025 08:34:45 -0800 Subject: [PATCH 4/4] Updates chain_data -> cls() --- bittensor_cli/src/bittensor/chain_data.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bittensor_cli/src/bittensor/chain_data.py b/bittensor_cli/src/bittensor/chain_data.py index f534d2246..9d71c675e 100644 --- a/bittensor_cli/src/bittensor/chain_data.py +++ b/bittensor_cli/src/bittensor/chain_data.py @@ -156,7 +156,7 @@ class SubnetHyperparameters(InfoBase): def _fix_decoded( cls, decoded: Union[dict, "SubnetHyperparameters"] ) -> "SubnetHyperparameters": - return SubnetHyperparameters( + return cls( rho=decoded.get("rho"), kappa=decoded.get("kappa"), immunity_period=decoded.get("immunity_period"), @@ -213,7 +213,7 @@ def _fix_decoded(cls, decoded: Any) -> "StakeInfo": drain = int(decoded.get("drain")) is_registered = bool(decoded.get("is_registered")) - return StakeInfo( + return cls( hotkey, coldkey, netuid, @@ -303,7 +303,7 @@ def _fix_decoded(cls, decoded: Any) -> "NeuronInfo": axon_info = decoded.get("axon_info", {}) coldkey = decode_account_id(decoded.get("coldkey")) hotkey = decode_account_id(decoded.get("hotkey")) - return NeuronInfo( + return cls( hotkey=hotkey, coldkey=coldkey, uid=decoded.get("uid"), @@ -565,7 +565,7 @@ class SubnetInfo(InfoBase): @classmethod def _fix_decoded(cls, decoded: "SubnetInfo") -> "SubnetInfo": - return SubnetInfo( + return cls( netuid=decoded.get("netuid"), rho=decoded.get("rho"), kappa=decoded.get("kappa"), @@ -604,7 +604,7 @@ class SubnetIdentity(InfoBase): @classmethod def _fix_decoded(cls, decoded: dict) -> "SubnetIdentity": - return SubnetIdentity( + return cls( subnet_name=bytes(decoded["subnet_name"]).decode(), github_repo=bytes(decoded["github_repo"]).decode(), subnet_contact=bytes(decoded["subnet_contact"]).decode(), @@ -838,7 +838,7 @@ class SubnetState(InfoBase): @classmethod def _fix_decoded(cls, decoded: Any) -> "SubnetState": netuid = decoded.get("netuid") - return SubnetState( + return cls( netuid=netuid, hotkeys=[decode_account_id(val) for val in decoded.get("hotkeys")], coldkeys=[decode_account_id(val) for val in decoded.get("coldkeys")],