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 {
1588
1588
Subtensor :: < T > :: get_commit_reveal_weights_version ( ) ,
1589
1589
) ;
1590
1590
}
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
+ }
1591
1600
}
Original file line number Diff line number Diff line change @@ -510,9 +510,9 @@ impl<T: Config> Pallet<T> {
510
510
) ;
511
511
continue ;
512
512
}
513
- let destination : T :: AccountId ;
513
+
514
514
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 ( ) ) ;
516
516
Self :: increase_stake_for_hotkey_and_coldkey_on_subnet (
517
517
& destination,
518
518
& owner,
Original file line number Diff line number Diff line change @@ -2062,16 +2062,17 @@ mod dispatches {
2062
2062
/// * `hotkey` (T::AccountId):
2063
2063
/// - The hotkey account to designate as the autostake destination.
2064
2064
#[ 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
+ ) ]
2068
2068
pub fn set_coldkey_auto_stake_hotkey (
2069
2069
origin : T :: RuntimeOrigin ,
2070
2070
hotkey : T :: AccountId ,
2071
2071
) -> DispatchResult {
2072
2072
let coldkey = ensure_signed ( origin) ?;
2073
- log :: debug! ( "set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )" ) ;
2073
+
2074
2074
AutoStakeDestination :: < T > :: insert ( coldkey, hotkey. clone ( ) ) ;
2075
+
2075
2076
Ok ( ( ) )
2076
2077
}
2077
2078
}
Original file line number Diff line number Diff line change @@ -2770,7 +2770,10 @@ fn test_incentive_is_autostaked_to_owner_destination() {
2770
2770
Uids :: < Test > :: insert ( netuid, dest_hk, 2 ) ;
2771
2771
2772
2772
// 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
+ ) ) ;
2774
2777
2775
2778
assert_eq ! (
2776
2779
SubtensorModule :: get_stake_for_hotkey_on_subnet( & miner_hk, netuid) ,
You can’t perform that action at this time.
0 commit comments