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
350 changes: 328 additions & 22 deletions bittensor_cli/cli.py

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions bittensor_cli/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,11 @@ class WalletValidationTypes(Enum):
),
"yuma3_enabled": ("sudo_set_yuma3_enabled", False),
"alpha_sigmoid_steepness": ("sudo_set_alpha_sigmoid_steepness", True),
"user_liquidity_enabled": ("toggle_user_liquidity", True),
}

HYPERPARAMS_MODULE = {
"user_liquidity_enabled": "Swap",
}

# Help Panels for cli help
Expand Down Expand Up @@ -699,6 +704,9 @@ class WalletValidationTypes(Enum):
"VIEW": {
"DASHBOARD": "Network Dashboard",
},
"LIQUIDITY": {
"LIQUIDITY_MGMT": "Liquidity Management",
},
}


Expand Down
112 changes: 79 additions & 33 deletions bittensor_cli/src/bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,49 @@ def get(self, item, default=None):

@dataclass
class SubnetHyperparameters(InfoBase):
"""Dataclass for subnet hyperparameters."""
"""
This class represents the hyperparameters for a subnet.
Attributes:
rho (int): The rate of decay of some value.
kappa (int): A constant multiplier used in calculations.
immunity_period (int): The period during which immunity is active.
min_allowed_weights (int): Minimum allowed weights.
max_weight_limit (float): Maximum weight limit.
tempo (int): The tempo or rate of operation.
min_difficulty (int): Minimum difficulty for some operations.
max_difficulty (int): Maximum difficulty for some operations.
weights_version (int): The version number of the weights used.
weights_rate_limit (int): Rate limit for processing weights.
adjustment_interval (int): Interval at which adjustments are made.
activity_cutoff (int): Activity cutoff threshold.
registration_allowed (bool): Indicates if registration is allowed.
target_regs_per_interval (int): Target number of registrations per interval.
min_burn (int): Minimum burn value.
max_burn (int): Maximum burn value.
bonds_moving_avg (int): Moving average of bonds.
max_regs_per_block (int): Maximum number of registrations per block.
serving_rate_limit (int): Limit on the rate of service.
max_validators (int): Maximum number of validators.
adjustment_alpha (int): Alpha value for adjustments.
difficulty (int): Difficulty level.
commit_reveal_period (int): Interval for commit-reveal weights.
commit_reveal_weights_enabled (bool): Flag indicating if commit-reveal weights are enabled.
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
kappa: int
immunity_period: int
min_allowed_weights: int
max_weights_limit: float
max_weight_limit: float
tempo: int
min_difficulty: int
max_difficulty: int
Expand All @@ -177,43 +213,53 @@ class SubnetHyperparameters(InfoBase):
alpha_high: int
alpha_low: int
liquid_alpha_enabled: bool
yuma3_enabled: bool
alpha_sigmoid_steepness: int
alpha_sigmoid_steepness: float
yuma_version: int
subnet_is_active: bool
transfers_enabled: bool
bonds_reset_enabled: bool
user_liquidity_enabled: bool

@classmethod
def _fix_decoded(
cls, decoded: Union[dict, "SubnetHyperparameters"]
) -> "SubnetHyperparameters":
return cls(
rho=decoded.get("rho"),
kappa=decoded.get("kappa"),
immunity_period=decoded.get("immunity_period"),
min_allowed_weights=decoded.get("min_allowed_weights"),
max_weights_limit=decoded.get("max_weights_limit"),
tempo=decoded.get("tempo"),
min_difficulty=decoded.get("min_difficulty"),
max_difficulty=decoded.get("max_difficulty"),
weights_version=decoded.get("weights_version"),
weights_rate_limit=decoded.get("weights_rate_limit"),
adjustment_interval=decoded.get("adjustment_interval"),
activity_cutoff=decoded.get("activity_cutoff"),
registration_allowed=decoded.get("registration_allowed"),
target_regs_per_interval=decoded.get("target_regs_per_interval"),
min_burn=decoded.get("min_burn"),
max_burn=decoded.get("max_burn"),
bonds_moving_avg=decoded.get("bonds_moving_avg"),
max_regs_per_block=decoded.get("max_regs_per_block"),
serving_rate_limit=decoded.get("serving_rate_limit"),
max_validators=decoded.get("max_validators"),
adjustment_alpha=decoded.get("adjustment_alpha"),
difficulty=decoded.get("difficulty"),
commit_reveal_period=decoded.get("commit_reveal_period"),
commit_reveal_weights_enabled=decoded.get("commit_reveal_weights_enabled"),
alpha_high=decoded.get("alpha_high"),
alpha_low=decoded.get("alpha_low"),
liquid_alpha_enabled=decoded.get("liquid_alpha_enabled"),
yuma3_enabled=decoded.get("yuma3_enabled"),
alpha_sigmoid_steepness=decoded.get("alpha_sigmoid_steepness"),
activity_cutoff=decoded["activity_cutoff"],
adjustment_alpha=decoded["adjustment_alpha"],
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"],
immunity_period=decoded["immunity_period"],
kappa=decoded["kappa"],
liquid_alpha_enabled=decoded["liquid_alpha_enabled"],
max_burn=decoded["max_burn"],
max_difficulty=decoded["max_difficulty"],
max_regs_per_block=decoded["max_regs_per_block"],
max_validators=decoded["max_validators"],
max_weight_limit=decoded["max_weights_limit"],
min_allowed_weights=decoded["min_allowed_weights"],
min_burn=decoded["min_burn"],
min_difficulty=decoded["min_difficulty"],
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"],
)


Expand Down
48 changes: 33 additions & 15 deletions bittensor_cli/src/bittensor/subtensor_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,33 @@ async def get_netuids_for_hotkey(
res.append(record[0])
return res

async def is_subnet_active(
self,
netuid: int,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> bool:
"""Verify if subnet with provided netuid is active.

Args:
netuid (int): The unique identifier of the subnet.
block_hash (Optional[str]): The blockchain block_hash representation of block id.
reuse_block (bool): Whether to reuse the last-used block hash.

Returns:
True if subnet is active, False otherwise.

This means whether the `start_call` was initiated or not.
"""
query = await self.substrate.query(
module="SubtensorModule",
storage_function="FirstEmissionBlockNumber",
block_hash=block_hash,
reuse_block_hash=reuse_block,
params=[netuid],
)
return True if query and query.value > 0 else False

async def subnet_exists(
self, netuid: int, block_hash: Optional[str] = None, reuse_block: bool = False
) -> bool:
Expand Down Expand Up @@ -1128,22 +1155,13 @@ async def get_subnet_hyperparameters(
Understanding the hyperparameters is crucial for comprehending how subnets are configured and
managed, and how they interact with the network's consensus and incentive mechanisms.
"""
main_result, yuma3_result, sigmoid_steepness = await asyncio.gather(
self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams",
params=[netuid],
block_hash=block_hash,
),
self.query("SubtensorModule", "Yuma3On", [netuid]),
self.query("SubtensorModule", "AlphaSigmoidSteepness", [netuid]),
result = await self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_hyperparams_v2",
params=[netuid],
block_hash=block_hash,
)
result = {
**main_result,
**{"yuma3_enabled": yuma3_result},
**{"alpha_sigmoid_steepness": sigmoid_steepness},
}
if not main_result:
if not result:
return []

return SubnetHyperparameters.from_any(result)
Expand Down
1 change: 1 addition & 0 deletions bittensor_cli/src/bittensor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,7 @@ def unlock_key(
err_msg = f"The password used to decrypt your {unlock_type.capitalize()}key Keyfile is invalid."
if print_out:
err_console.print(f":cross_mark: [red]{err_msg}[/red]")
return unlock_key(wallet, unlock_type, print_out)
return UnlockStatus(False, err_msg)
except KeyFileError:
err_msg = f"{unlock_type.capitalize()}key Keyfile is corrupt, non-writable, or non-readable, or non-existent."
Expand Down
Empty file.
Loading
Loading