@@ -524,9 +524,11 @@ async def get_neuron_for_pubkey_and_subnet():
524
524
if prompt :
525
525
if not Confirm .ask (
526
526
f"Continue Registration?\n "
527
- f" hotkey [{ COLOR_PALETTE ['GENERAL' ]['HOTKEY' ]} ]({ wallet .hotkey_str } )[/{ COLOR_PALETTE ['GENERAL' ]['HOTKEY' ]} ]:\t [{ COLOR_PALETTE ['GENERAL' ]['HOTKEY' ]} ]{ wallet .hotkey .ss58_address } [/{ COLOR_PALETTE ['GENERAL' ]['HOTKEY' ]} ]\n "
528
- f" coldkey [{ COLOR_PALETTE ['GENERAL' ]['COLDKEY' ]} ]({ wallet .name } )[/{ COLOR_PALETTE ['GENERAL' ]['COLDKEY' ]} ]:\t [{ COLOR_PALETTE ['GENERAL' ]['COLDKEY' ]} ]{ wallet .coldkeypub .ss58_address } [/{ COLOR_PALETTE ['GENERAL' ]['COLDKEY' ]} ]\n "
529
- f" network:\t \t [{ COLOR_PALETTE ['GENERAL' ]['LINKS' ]} ]{ subtensor .network } [/{ COLOR_PALETTE ['GENERAL' ]['LINKS' ]} ]\n "
527
+ f" hotkey [{ COLOR_PALETTE .G .HK } ]({ wallet .hotkey_str } )[/{ COLOR_PALETTE .G .HK } ]:"
528
+ f"\t [{ COLOR_PALETTE .G .HK } ]{ wallet .hotkey .ss58_address } [/{ COLOR_PALETTE .G .HK } ]\n "
529
+ f" coldkey [{ COLOR_PALETTE .G .CK } ]({ wallet .name } )[/{ COLOR_PALETTE .G .CK } ]:"
530
+ f"\t [{ COLOR_PALETTE .G .CK } ]{ wallet .coldkeypub .ss58_address } [/{ COLOR_PALETTE .G .CK } ]\n "
531
+ f" network:\t \t [{ COLOR_PALETTE .G .LINKS } ]{ subtensor .network } [/{ COLOR_PALETTE .G .LINKS } ]\n "
530
532
):
531
533
return False
532
534
@@ -611,7 +613,6 @@ async def get_neuron_for_pubkey_and_subnet():
611
613
if not wait_for_finalization and not wait_for_inclusion :
612
614
success , err_msg = True , ""
613
615
else :
614
- await response .process_events ()
615
616
success = await response .is_success
616
617
if not success :
617
618
success , err_msg = (
@@ -676,8 +677,9 @@ async def burned_register_extrinsic(
676
677
old_balance : Balance ,
677
678
wait_for_inclusion : bool = True ,
678
679
wait_for_finalization : bool = True ,
680
+ era : Optional [int ] = None ,
679
681
prompt : bool = False ,
680
- ) -> bool :
682
+ ) -> tuple [ bool , str ] :
681
683
"""Registers the wallet to chain by recycling TAO.
682
684
683
685
:param subtensor: The SubtensorInterface object to use for the call, initialized
@@ -688,10 +690,11 @@ async def burned_register_extrinsic(
688
690
`False` if the extrinsic fails to enter the block within the timeout.
689
691
:param wait_for_finalization: If set, waits for the extrinsic to be finalized on the chain before returning `True`,
690
692
or returns `False` if the extrinsic fails to be finalized within the timeout.
693
+ :param era: the period (in blocks) for which the transaction should remain valid.
691
694
:param prompt: If `True`, the call waits for confirmation from the user before proceeding.
692
695
693
- :return: Flag is `True` if extrinsic was finalized or included in the block. If we did not wait for
694
- finalization/inclusion, the response is `True`.
696
+ :return: (success, msg), where success is `True` if extrinsic was finalized or included in the block. If we did not
697
+ wait for finalization/inclusion, the response is `True`.
695
698
"""
696
699
697
700
if not (unlock_status := unlock_key (wallet , print_out = False )).success :
@@ -704,23 +707,42 @@ async def burned_register_extrinsic(
704
707
my_uid = await subtensor .query (
705
708
"SubtensorModule" , "Uids" , [netuid , wallet .hotkey .ss58_address ]
706
709
)
710
+ block_hash = await subtensor .substrate .get_chain_head ()
707
711
708
712
print_verbose ("Checking if already registered" , status )
709
713
neuron = await subtensor .neuron_for_uid (
710
- uid = my_uid ,
711
- netuid = netuid ,
712
- block_hash = subtensor .substrate .last_block_hash ,
714
+ uid = my_uid , netuid = netuid , block_hash = block_hash
713
715
)
716
+ if not era :
717
+ current_block , tempo , blocks_since_last_step = await asyncio .gather (
718
+ subtensor .substrate .get_block_number (block_hash = block_hash ),
719
+ subtensor .get_hyperparameter (
720
+ "Tempo" , netuid = netuid , block_hash = block_hash
721
+ ),
722
+ subtensor .query (
723
+ "SubtensorModule" ,
724
+ "BlocksSinceLastStep" ,
725
+ [netuid ],
726
+ block_hash = block_hash ,
727
+ ),
728
+ )
729
+ validity_period = tempo - blocks_since_last_step
730
+ era_ = {
731
+ "period" : validity_period ,
732
+ "current" : current_block ,
733
+ }
734
+ else :
735
+ era_ = {"period" : era }
714
736
715
737
if not neuron .is_null :
716
738
console .print (
717
739
":white_heavy_check_mark: [dark_sea_green3]Already Registered[/dark_sea_green3]:\n "
718
- f"uid: [{ COLOR_PALETTE [ 'GENERAL' ][ ' NETUID_EXTRA' ] } ]{ neuron .uid } [/{ COLOR_PALETTE [ 'GENERAL' ][ ' NETUID_EXTRA' ] } ]\n "
719
- f"netuid: [{ COLOR_PALETTE [ 'GENERAL' ][ ' NETUID' ] } ]{ neuron .netuid } [/{ COLOR_PALETTE [ 'GENERAL' ][ ' NETUID' ] } ]\n "
720
- f"hotkey: [{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]{ neuron .hotkey } [/{ COLOR_PALETTE [ 'GENERAL' ][ 'HOTKEY' ] } ]\n "
721
- f"coldkey: [{ COLOR_PALETTE [ 'GENERAL' ][ 'COLDKEY' ] } ]{ neuron .coldkey } [/{ COLOR_PALETTE [ 'GENERAL' ][ 'COLDKEY' ] } ]"
740
+ f"uid: [{ COLOR_PALETTE . G . NETUID_EXTRA } ]{ neuron .uid } [/{ COLOR_PALETTE . G . NETUID_EXTRA } ]\n "
741
+ f"netuid: [{ COLOR_PALETTE . G . NETUID } ]{ neuron .netuid } [/{ COLOR_PALETTE . G . NETUID } ]\n "
742
+ f"hotkey: [{ COLOR_PALETTE . G . HK } ]{ neuron .hotkey } [/{ COLOR_PALETTE . G . HK } ]\n "
743
+ f"coldkey: [{ COLOR_PALETTE . G . CK } ]{ neuron .coldkey } [/{ COLOR_PALETTE . G . CK } ]"
722
744
)
723
- return True
745
+ return True , "Already registered"
724
746
725
747
with console .status (
726
748
":satellite: Recycling TAO for Registration..." , spinner = "aesthetic"
@@ -734,13 +756,13 @@ async def burned_register_extrinsic(
734
756
},
735
757
)
736
758
success , err_msg = await subtensor .sign_and_send_extrinsic (
737
- call , wallet , wait_for_inclusion , wait_for_finalization
759
+ call , wallet , wait_for_inclusion , wait_for_finalization , era = era_
738
760
)
739
761
740
762
if not success :
741
763
err_console .print (f":cross_mark: [red]Failed[/red]: { err_msg } " )
742
764
await asyncio .sleep (0.5 )
743
- return False
765
+ return False , err_msg
744
766
# Successful registration, final check for neuron and pubkey
745
767
else :
746
768
with console .status (":satellite: Checking Balance..." , spinner = "aesthetic" ):
@@ -761,20 +783,21 @@ async def burned_register_extrinsic(
761
783
762
784
console .print (
763
785
"Balance:\n "
764
- f" [blue]{ old_balance } [/blue] :arrow_right: [{ COLOR_PALETTE ['STAKE' ]['STAKE_AMOUNT' ]} ]{ new_balance } [/{ COLOR_PALETTE ['STAKE' ]['STAKE_AMOUNT' ]} ]"
786
+ f" [blue]{ old_balance } [/blue] :arrow_right: "
787
+ f"[{ COLOR_PALETTE .S .STAKE_AMOUNT } ]{ new_balance } [/{ COLOR_PALETTE .S .STAKE_AMOUNT } ]"
765
788
)
766
789
767
790
if len (netuids_for_hotkey ) > 0 :
768
791
console .print (
769
792
f":white_heavy_check_mark: [green]Registered on netuid { netuid } with UID { my_uid } [/green]"
770
793
)
771
- return True
794
+ return True , f"Registered on { netuid } with UID { my_uid } "
772
795
else :
773
796
# neuron not found, try again
774
797
err_console .print (
775
798
":cross_mark: [red]Unknown error. Neuron not found.[/red]"
776
799
)
777
- return False
800
+ return False , "Unknown error. Neuron not found."
778
801
779
802
780
803
async def run_faucet_extrinsic (
@@ -894,7 +917,6 @@ async def run_faucet_extrinsic(
894
917
)
895
918
896
919
# process if registration successful, try again if pow is still valid
897
- await response .process_events ()
898
920
if not await response .is_success :
899
921
err_console .print (
900
922
f":cross_mark: [red]Failed[/red]: "
@@ -1737,7 +1759,8 @@ async def swap_hotkey_extrinsic(
1737
1759
)
1738
1760
if not len (netuids_registered ) > 0 :
1739
1761
err_console .print (
1740
- f"Destination hotkey [dark_orange]{ new_wallet .hotkey .ss58_address } [/dark_orange] is not registered. Please register and try again"
1762
+ f"Destination hotkey [dark_orange]{ new_wallet .hotkey .ss58_address } [/dark_orange] is not registered. "
1763
+ f"Please register and try again"
1741
1764
)
1742
1765
return False
1743
1766
@@ -1754,7 +1777,8 @@ async def swap_hotkey_extrinsic(
1754
1777
):
1755
1778
return False
1756
1779
print_verbose (
1757
- f"Swapping { wallet .name } 's hotkey ({ wallet .hotkey .ss58_address } ) with { new_wallet .name } s hotkey ({ new_wallet .hotkey .ss58_address } )"
1780
+ f"Swapping { wallet .name } 's hotkey ({ wallet .hotkey .ss58_address } ) with "
1781
+ f"{ new_wallet .name } s hotkey ({ new_wallet .hotkey .ss58_address } )"
1758
1782
)
1759
1783
with console .status (":satellite: Swapping hotkeys..." , spinner = "aesthetic" ):
1760
1784
call = await subtensor .substrate .compose_call (
0 commit comments