-
Notifications
You must be signed in to change notification settings - Fork 446
Fix: burned_register supports root subnet (netuid=0 param) #2732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b557952
4859c76
d7e9589
f43b004
36f12f6
77bb23b
2756671
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
|
|
||
| from bittensor.core.errors import SubstrateRequestException | ||
| from bittensor.utils import u16_normalized_float, format_error_message, unlock_key | ||
| from bittensor.utils.balance import Balance | ||
| from bittensor.utils.btlogging import logging | ||
| from bittensor.utils.weight_utils import ( | ||
| normalize_max_weight, | ||
|
|
@@ -62,6 +63,38 @@ async def root_register_extrinsic( | |
| the response is `True`. | ||
| """ | ||
| netuid = 0 | ||
| logging.info( | ||
| f"Registering on netuid [blue]{netuid}[/blue] on network: [blue]{subtensor.network}[/blue]" | ||
| ) | ||
|
|
||
| logging.info("Fetching recycle amount & balance.") | ||
| block_hash = await subtensor.get_block_hash() | ||
|
|
||
| try: | ||
| recycle_call, balance = await asyncio.gather( | ||
| subtensor.get_hyperparameter( | ||
| param_name="Burn", | ||
| netuid=netuid, | ||
| block_hash=block_hash, | ||
| ), | ||
| subtensor.get_balance( | ||
| wallet.coldkeypub.ss58_address, | ||
| block_hash=block_hash, | ||
| ), | ||
| ) | ||
| except TypeError as e: | ||
|
||
| logging.error(f"Unable to retrieve current recycle. {e}") | ||
| return False | ||
|
|
||
| current_recycle = Balance.from_rao(int(recycle_call)) | ||
|
|
||
| if balance < current_recycle: | ||
| logging.error( | ||
| f"[red]Insufficient balance {balance} to register neuron. " | ||
| f"Current recycle is {current_recycle} TAO[/red]." | ||
| ) | ||
| return False | ||
|
|
||
| if not (unlock := unlock_key(wallet)).success: | ||
| logging.error(unlock.message) | ||
| return False | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is unrelated to this PR, but why do we do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably to make sure Subtensor/Substrate is properly initialized?