Skip to content

Commit

Permalink
Merge pull request #261 from opentensor/feat/thewhaleking/handle-sett…
Browse files Browse the repository at this point in the history
…ing-sudo-hyperparams

Sudo Hyperparams
  • Loading branch information
thewhaleking authored Dec 2, 2024
2 parents c53c805 + 4f3e351 commit 6c62f4f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
53 changes: 27 additions & 26 deletions bittensor_cli/src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,32 +318,33 @@ class WalletValidationTypes(Enum):


HYPERPARAMS = {
"rho": "sudo_set_rho",
"kappa": "sudo_set_kappa",
"immunity_period": "sudo_set_immunity_period",
"min_allowed_weights": "sudo_set_min_allowed_weights",
"max_weights_limit": "sudo_set_max_weight_limit",
"tempo": "sudo_set_tempo",
"min_difficulty": "sudo_set_min_difficulty",
"max_difficulty": "sudo_set_max_difficulty",
"weights_version": "sudo_set_weights_version_key",
"weights_rate_limit": "sudo_set_weights_set_rate_limit",
"adjustment_interval": "sudo_set_adjustment_interval",
"activity_cutoff": "sudo_set_activity_cutoff",
"target_regs_per_interval": "sudo_set_target_registrations_per_interval",
"min_burn": "sudo_set_min_burn",
"max_burn": "sudo_set_max_burn",
"bonds_moving_avg": "sudo_set_bonds_moving_average",
"max_regs_per_block": "sudo_set_max_registrations_per_block",
"serving_rate_limit": "sudo_set_serving_rate_limit",
"max_validators": "sudo_set_max_allowed_validators",
"adjustment_alpha": "sudo_set_adjustment_alpha",
"difficulty": "sudo_set_difficulty",
"commit_reveal_weights_interval": "sudo_set_commit_reveal_weights_interval",
"commit_reveal_weights_enabled": "sudo_set_commit_reveal_weights_enabled",
"alpha_values": "sudo_set_alpha_values",
"liquid_alpha_enabled": "sudo_set_liquid_alpha_enabled",
"registration_allowed": "sudo_set_network_registration_allowed",
# btcli name: (subtensor method, sudo bool)
"rho": ("sudo_set_rho", False),
"kappa": ("sudo_set_kappa", False),
"immunity_period": ("sudo_set_immunity_period", False),
"min_allowed_weights": ("sudo_set_min_allowed_weights", False),
"max_weights_limit": ("sudo_set_max_weight_limit", False),
"tempo": ("sudo_set_tempo", True),
"min_difficulty": ("sudo_set_min_difficulty", False),
"max_difficulty": ("sudo_set_max_difficulty", False),
"weights_version": ("sudo_set_weights_version_key", False),
"weights_rate_limit": ("sudo_set_weights_set_rate_limit", False),
"adjustment_interval": ("sudo_set_adjustment_interval", True),
"activity_cutoff": ("sudo_set_activity_cutoff", False),
"target_regs_per_interval": ("sudo_set_target_registrations_per_interval", True),
"min_burn": ("sudo_set_min_burn", False),
"max_burn": ("sudo_set_max_burn", False),
"bonds_moving_avg": ("sudo_set_bonds_moving_average", False),
"max_regs_per_block": ("sudo_set_max_registrations_per_block", True),
"serving_rate_limit": ("sudo_set_serving_rate_limit", False),
"max_validators": ("sudo_set_max_allowed_validators", True),
"adjustment_alpha": ("sudo_set_adjustment_alpha", False),
"difficulty": ("sudo_set_difficulty", False),
"commit_reveal_weights_interval": ("sudo_set_commit_reveal_weights_interval", False),
"commit_reveal_weights_enabled": ("sudo_set_commit_reveal_weights_enabled", False),
"alpha_values": ("sudo_set_alpha_values", False),
"liquid_alpha_enabled": ("sudo_set_liquid_alpha_enabled", False),
"registration_allowed": ("sudo_set_network_registration_allowed", False),
}

# Help Panels for cli help
Expand Down
10 changes: 8 additions & 2 deletions bittensor_cli/src/commands/sudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def set_hyperparameter_extrinsic(
if not unlock_key(wallet).success:
return False

extrinsic = HYPERPARAMS.get(parameter)
extrinsic, sudo_ = HYPERPARAMS.get(parameter, ("", False))
if extrinsic is None:
err_console.print(":cross_mark: [red]Invalid hyperparameter specified.[/red]")
return False
Expand Down Expand Up @@ -144,11 +144,17 @@ async def set_hyperparameter_extrinsic(
call_params[str(value_argument["name"])] = value

# create extrinsic call
call = await substrate.compose_call(
call_ = await substrate.compose_call(
call_module="AdminUtils",
call_function=extrinsic,
call_params=call_params,
)
if sudo_:
call = await substrate.compose_call(
call_module="Sudo", call_function="sudo", call_params={"call": call_}
)
else:
call = call_
success, err_msg = await subtensor.sign_and_send_extrinsic(
call, wallet, wait_for_inclusion, wait_for_finalization
)
Expand Down

0 comments on commit 6c62f4f

Please sign in to comment.