File tree Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Expand file tree Collapse file tree 4 files changed +20
-7
lines changed Original file line number Diff line number Diff line change @@ -1588,4 +1588,13 @@ mod pallet_benchmarks {
15881588 Subtensor :: < T > :: get_commit_reveal_weights_version ( ) ,
15891589 ) ;
15901590 }
1591+
1592+ #[ benchmark]
1593+ fn set_coldkey_auto_stake_hotkey ( ) {
1594+ let coldkey: T :: AccountId = whitelisted_caller ( ) ;
1595+ let hot: T :: AccountId = account ( "A" , 0 , 1 ) ;
1596+
1597+ #[ extrinsic_call]
1598+ _ ( RawOrigin :: Signed ( coldkey. clone ( ) ) , hot. clone ( ) ) ;
1599+ }
15911600}
Original file line number Diff line number Diff line change @@ -510,9 +510,9 @@ impl<T: Config> Pallet<T> {
510510 ) ;
511511 continue ;
512512 }
513- let destination : T :: AccountId ;
513+
514514 let owner: T :: AccountId = Owner :: < T > :: get ( & hotkey) ;
515- destination = AutoStakeDestination :: < T > :: get ( & owner) . unwrap_or ( hotkey. clone ( ) ) ;
515+ let destination = AutoStakeDestination :: < T > :: get ( & owner) . unwrap_or ( hotkey. clone ( ) ) ;
516516 Self :: increase_stake_for_hotkey_and_coldkey_on_subnet (
517517 & destination,
518518 & owner,
Original file line number Diff line number Diff line change @@ -2062,16 +2062,17 @@ mod dispatches {
20622062 /// * `hotkey` (T::AccountId):
20632063 /// - The hotkey account to designate as the autostake destination.
20642064 #[ pallet:: call_index( 114 ) ]
2065- #[ pallet:: weight( ( Weight :: from_parts ( 64_530_000 , 0 )
2066- . saturating_add( T :: DbWeight :: get( ) . reads ( 7_u64 ) )
2067- . saturating_add ( T :: DbWeight :: get ( ) . writes ( 2 ) ) , DispatchClass :: Normal , Pays :: Yes ) ) ]
2065+ #[ pallet:: weight(
2066+ Weight :: from_parts ( 5_170_000 , 0 ) . saturating_add( T :: DbWeight :: get( ) . writes ( 1_u64 ) )
2067+ ) ]
20682068 pub fn set_coldkey_auto_stake_hotkey (
20692069 origin : T :: RuntimeOrigin ,
20702070 hotkey : T :: AccountId ,
20712071 ) -> DispatchResult {
20722072 let coldkey = ensure_signed ( origin) ?;
2073- log :: debug! ( "set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )" ) ;
2073+
20742074 AutoStakeDestination :: < T > :: insert ( coldkey, hotkey. clone ( ) ) ;
2075+
20752076 Ok ( ( ) )
20762077 }
20772078 }
Original file line number Diff line number Diff line change @@ -2770,7 +2770,10 @@ fn test_incentive_is_autostaked_to_owner_destination() {
27702770 Uids :: < Test > :: insert ( netuid, dest_hk, 2 ) ;
27712771
27722772 // Set autostake destination for the miner's coldkey
2773- AutoStakeDestination :: < Test > :: insert ( miner_ck, dest_hk) ;
2773+ assert_ok ! ( SubtensorModule :: set_coldkey_auto_stake_hotkey(
2774+ RuntimeOrigin :: signed( miner_ck) ,
2775+ dest_hk,
2776+ ) ) ;
27742777
27752778 assert_eq ! (
27762779 SubtensorModule :: get_stake_for_hotkey_on_subnet( & miner_hk, netuid) ,
You can’t perform that action at this time.
0 commit comments