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
2 changes: 1 addition & 1 deletion bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,7 @@ async def get_subnet_hyperparameters(
"""
result = await self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[netuid],
block=block,
block_hash=block_hash,
Expand Down
22 changes: 21 additions & 1 deletion bittensor/core/chain_data/subnet_hyperparameters.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataclasses import dataclass

from bittensor.utils.balance import fixed_to_float
from bittensor.core.chain_data.info_base import InfoBase


Expand Down Expand Up @@ -36,6 +36,12 @@ class SubnetHyperparameters(InfoBase):
alpha_high (int): High value of alpha.
alpha_low (int): Low value of alpha.
liquid_alpha_enabled (bool): Flag indicating if liquid alpha is enabled.
alpha_sigmoid_steepness (float):
yuma_version (int): Version of yuma.
subnet_is_active (bool): Indicates if subnet is active after START CALL.
transfers_enabled (bool): Flag indicating if transfers are enabled.
bonds_reset_enabled (bool): Flag indicating if bonds are reset enabled.
user_liquidity_enabled (bool): Flag indicating if user liquidity is enabled.
"""

rho: int
Expand Down Expand Up @@ -65,6 +71,12 @@ class SubnetHyperparameters(InfoBase):
alpha_high: int
alpha_low: int
liquid_alpha_enabled: bool
alpha_sigmoid_steepness: float
yuma_version: int
subnet_is_active: bool
transfers_enabled: bool
bonds_reset_enabled: bool
user_liquidity_enabled: bool

@classmethod
def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
Expand All @@ -75,7 +87,11 @@ def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
adjustment_interval=decoded["adjustment_interval"],
alpha_high=decoded["alpha_high"],
alpha_low=decoded["alpha_low"],
alpha_sigmoid_steepness=fixed_to_float(
decoded["alpha_sigmoid_steepness"], frac_bits=32
),
bonds_moving_avg=decoded["bonds_moving_avg"],
bonds_reset_enabled=decoded["bonds_reset_enabled"],
commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"],
commit_reveal_period=decoded["commit_reveal_period"],
difficulty=decoded["difficulty"],
Expand All @@ -93,8 +109,12 @@ def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters":
registration_allowed=decoded["registration_allowed"],
rho=decoded["rho"],
serving_rate_limit=decoded["serving_rate_limit"],
subnet_is_active=decoded["subnet_is_active"],
target_regs_per_interval=decoded["target_regs_per_interval"],
tempo=decoded["tempo"],
transfers_enabled=decoded["transfers_enabled"],
user_liquidity_enabled=decoded["user_liquidity_enabled"],
weights_rate_limit=decoded["weights_rate_limit"],
weights_version=decoded["weights_version"],
yuma_version=decoded["yuma_version"],
)
2 changes: 1 addition & 1 deletion bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,7 @@ def get_subnet_hyperparameters(
"""
result = self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[netuid],
block=block,
)
Expand Down
6 changes: 6 additions & 0 deletions tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ def hyperparams():
alpha_high=0,
alpha_low=0,
liquid_alpha_enabled=False,
alpha_sigmoid_steepness=0,
yuma_version=3,
subnet_is_active=False,
transfers_enabled=False,
bonds_reset_enabled=False,
user_liquidity_enabled=False,
)


Expand Down
6 changes: 6 additions & 0 deletions tests/unit_tests/extrinsics/test_commit_reveal.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ def hyperparams():
alpha_high=0,
alpha_low=0,
liquid_alpha_enabled=False,
alpha_sigmoid_steepness=0,
yuma_version=3,
subnet_is_active=False,
transfers_enabled=False,
bonds_reset_enabled=False,
user_liquidity_enabled=False,
)


Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ async def test_get_subnet_hyperparameters_success(subtensor, mocker):
# Asserts
mocked_query_runtime_api.assert_called_once_with(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[fake_netuid],
block=None,
block_hash=fake_block_hash,
Expand All @@ -2147,7 +2147,7 @@ async def test_get_subnet_hyperparameters_no_data(subtensor, mocker):
# Asserts
mocked_query_runtime_api.assert_called_once_with(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[fake_netuid],
block=None,
block_hash=None,
Expand Down Expand Up @@ -2177,7 +2177,7 @@ async def test_get_subnet_hyperparameters_without_0x_prefix(subtensor, mocker):
# Asserts
mocked_query_runtime_api.assert_called_once_with(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[fake_netuid],
block=None,
block_hash=None,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def test_get_subnet_hyperparameters_success(mocker, subtensor):
# Asserts
subtensor.query_runtime_api.assert_called_once_with(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[netuid],
block=block,
)
Expand All @@ -870,7 +870,7 @@ def test_get_subnet_hyperparameters_no_data(mocker, subtensor):
assert result is None
subtensor.query_runtime_api.assert_called_once_with(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
method="get_subnet_hyperparams_v2",
params=[netuid],
block=block,
)
Expand Down