Skip to content

Commit c00e667

Browse files
authored
Merge pull request #2938 from opentensor/feat/roman/SubnetHyperparameters
Update `SubnetHyperparameters` with v2
2 parents 0072ec5 + a7a6276 commit c00e667

File tree

7 files changed

+40
-8
lines changed

7 files changed

+40
-8
lines changed

bittensor/core/async_subtensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ async def get_subnet_hyperparameters(
22752275
"""
22762276
result = await self.query_runtime_api(
22772277
runtime_api="SubnetInfoRuntimeApi",
2278-
method="get_subnet_hyperparams",
2278+
method="get_subnet_hyperparams_v2",
22792279
params=[netuid],
22802280
block=block,
22812281
block_hash=block_hash,

bittensor/core/chain_data/subnet_hyperparameters.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
2+
from bittensor.utils.balance import fixed_to_float
33
from bittensor.core.chain_data.info_base import InfoBase
44

55

@@ -36,6 +36,12 @@ class SubnetHyperparameters(InfoBase):
3636
alpha_high (int): High value of alpha.
3737
alpha_low (int): Low value of alpha.
3838
liquid_alpha_enabled (bool): Flag indicating if liquid alpha is enabled.
39+
alpha_sigmoid_steepness (float):
40+
yuma_version (int): Version of yuma.
41+
subnet_is_active (bool): Indicates if subnet is active after START CALL.
42+
transfers_enabled (bool): Flag indicating if transfers are enabled.
43+
bonds_reset_enabled (bool): Flag indicating if bonds are reset enabled.
44+
user_liquidity_enabled (bool): Flag indicating if user liquidity is enabled.
3945
"""
4046

4147
rho: int
@@ -65,6 +71,12 @@ class SubnetHyperparameters(InfoBase):
6571
alpha_high: int
6672
alpha_low: int
6773
liquid_alpha_enabled: bool
74+
alpha_sigmoid_steepness: float
75+
yuma_version: int
76+
subnet_is_active: bool
77+
transfers_enabled: bool
78+
bonds_reset_enabled: bool
79+
user_liquidity_enabled: bool
6880

6981
@classmethod
7082
def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
@@ -75,7 +87,11 @@ def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
7587
adjustment_interval=decoded["adjustment_interval"],
7688
alpha_high=decoded["alpha_high"],
7789
alpha_low=decoded["alpha_low"],
90+
alpha_sigmoid_steepness=fixed_to_float(
91+
decoded["alpha_sigmoid_steepness"], frac_bits=32
92+
),
7893
bonds_moving_avg=decoded["bonds_moving_avg"],
94+
bonds_reset_enabled=decoded["bonds_reset_enabled"],
7995
commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"],
8096
commit_reveal_period=decoded["commit_reveal_period"],
8197
difficulty=decoded["difficulty"],
@@ -93,8 +109,12 @@ def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
93109
registration_allowed=decoded["registration_allowed"],
94110
rho=decoded["rho"],
95111
serving_rate_limit=decoded["serving_rate_limit"],
112+
subnet_is_active=decoded["subnet_is_active"],
96113
target_regs_per_interval=decoded["target_regs_per_interval"],
97114
tempo=decoded["tempo"],
115+
transfers_enabled=decoded["transfers_enabled"],
116+
user_liquidity_enabled=decoded["user_liquidity_enabled"],
98117
weights_rate_limit=decoded["weights_rate_limit"],
99118
weights_version=decoded["weights_version"],
119+
yuma_version=decoded["yuma_version"],
100120
)

bittensor/core/subtensor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ def get_subnet_hyperparameters(
17881788
"""
17891789
result = self.query_runtime_api(
17901790
runtime_api="SubnetInfoRuntimeApi",
1791-
method="get_subnet_hyperparams",
1791+
method="get_subnet_hyperparams_v2",
17921792
params=[netuid],
17931793
block=block,
17941794
)

tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ def hyperparams():
3636
alpha_high=0,
3737
alpha_low=0,
3838
liquid_alpha_enabled=False,
39+
alpha_sigmoid_steepness=0,
40+
yuma_version=3,
41+
subnet_is_active=False,
42+
transfers_enabled=False,
43+
bonds_reset_enabled=False,
44+
user_liquidity_enabled=False,
3945
)
4046

4147

tests/unit_tests/extrinsics/test_commit_reveal.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ def hyperparams():
3737
alpha_high=0,
3838
alpha_low=0,
3939
liquid_alpha_enabled=False,
40+
alpha_sigmoid_steepness=0,
41+
yuma_version=3,
42+
subnet_is_active=False,
43+
transfers_enabled=False,
44+
bonds_reset_enabled=False,
45+
user_liquidity_enabled=False,
4046
)
4147

4248

tests/unit_tests/test_async_subtensor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ async def test_get_subnet_hyperparameters_success(subtensor, mocker):
21232123
# Asserts
21242124
mocked_query_runtime_api.assert_called_once_with(
21252125
runtime_api="SubnetInfoRuntimeApi",
2126-
method="get_subnet_hyperparams",
2126+
method="get_subnet_hyperparams_v2",
21272127
params=[fake_netuid],
21282128
block=None,
21292129
block_hash=fake_block_hash,
@@ -2147,7 +2147,7 @@ async def test_get_subnet_hyperparameters_no_data(subtensor, mocker):
21472147
# Asserts
21482148
mocked_query_runtime_api.assert_called_once_with(
21492149
runtime_api="SubnetInfoRuntimeApi",
2150-
method="get_subnet_hyperparams",
2150+
method="get_subnet_hyperparams_v2",
21512151
params=[fake_netuid],
21522152
block=None,
21532153
block_hash=None,
@@ -2177,7 +2177,7 @@ async def test_get_subnet_hyperparameters_without_0x_prefix(subtensor, mocker):
21772177
# Asserts
21782178
mocked_query_runtime_api.assert_called_once_with(
21792179
runtime_api="SubnetInfoRuntimeApi",
2180-
method="get_subnet_hyperparams",
2180+
method="get_subnet_hyperparams_v2",
21812181
params=[fake_netuid],
21822182
block=None,
21832183
block_hash=None,

tests/unit_tests/test_subtensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def test_get_subnet_hyperparameters_success(mocker, subtensor):
846846
# Asserts
847847
subtensor.query_runtime_api.assert_called_once_with(
848848
runtime_api="SubnetInfoRuntimeApi",
849-
method="get_subnet_hyperparams",
849+
method="get_subnet_hyperparams_v2",
850850
params=[netuid],
851851
block=block,
852852
)
@@ -870,7 +870,7 @@ def test_get_subnet_hyperparameters_no_data(mocker, subtensor):
870870
assert result is None
871871
subtensor.query_runtime_api.assert_called_once_with(
872872
runtime_api="SubnetInfoRuntimeApi",
873-
method="get_subnet_hyperparams",
873+
method="get_subnet_hyperparams_v2",
874874
params=[netuid],
875875
block=block,
876876
)

0 commit comments

Comments
 (0)