Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pallets/subtensor/src/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1588,4 +1588,13 @@ mod pallet_benchmarks {
Subtensor::<T>::get_commit_reveal_weights_version(),
);
}

#[benchmark]
fn set_coldkey_auto_stake_hotkey() {
let coldkey: T::AccountId = whitelisted_caller();
let hot: T::AccountId = account("A", 0, 1);

#[extrinsic_call]
_(RawOrigin::Signed(coldkey.clone()), hot.clone());
}
}
4 changes: 2 additions & 2 deletions pallets/subtensor/src/coinbase/run_coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,9 @@ impl<T: Config> Pallet<T> {
);
continue;
}
let destination: T::AccountId;

let owner: T::AccountId = Owner::<T>::get(&hotkey);
destination = AutoStakeDestination::<T>::get(&owner).unwrap_or(hotkey.clone());
let destination = AutoStakeDestination::<T>::get(&owner).unwrap_or(hotkey.clone());
Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
&destination,
&owner,
Expand Down
9 changes: 5 additions & 4 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2062,16 +2062,17 @@ mod dispatches {
/// * `hotkey` (T::AccountId):
/// - The hotkey account to designate as the autostake destination.
#[pallet::call_index(114)]
#[pallet::weight((Weight::from_parts(64_530_000, 0)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::Yes))]
#[pallet::weight(
Weight::from_parts(5_170_000, 0).saturating_add(T::DbWeight::get().writes(1_u64))
)]
pub fn set_coldkey_auto_stake_hotkey(
origin: T::RuntimeOrigin,
hotkey: T::AccountId,
) -> DispatchResult {
let coldkey = ensure_signed(origin)?;
log::debug!("set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )");

AutoStakeDestination::<T>::insert(coldkey, hotkey.clone());

Ok(())
}
}
Expand Down
5 changes: 4 additions & 1 deletion pallets/subtensor/src/tests/coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2770,7 +2770,10 @@ fn test_incentive_is_autostaked_to_owner_destination() {
Uids::<Test>::insert(netuid, dest_hk, 2);

// Set autostake destination for the miner's coldkey
AutoStakeDestination::<Test>::insert(miner_ck, dest_hk);
assert_ok!(SubtensorModule::set_coldkey_auto_stake_hotkey(
RuntimeOrigin::signed(miner_ck),
dest_hk,
));

assert_eq!(
SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid),
Expand Down