From bb7499346aed092545e083ff9362e5a804d75b0e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 3 Sep 2025 13:34:57 +0300 Subject: [PATCH 1/2] Update autostake extrinsic. --- pallets/subtensor/src/benchmarks.rs | 9 +++++++++ pallets/subtensor/src/coinbase/run_coinbase.rs | 4 ++-- pallets/subtensor/src/macros/dispatches.rs | 9 +++++---- pallets/subtensor/src/tests/coinbase.rs | 5 ++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 42e3d79a23..6dd5390992 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1588,4 +1588,13 @@ mod pallet_benchmarks { Subtensor::::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()); + } } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index b14dd9e826..c143d16a16 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -510,9 +510,9 @@ impl Pallet { ); continue; } - let destination: T::AccountId; + let owner: T::AccountId = Owner::::get(&hotkey); - destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); + let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index b758bc74cc..83c637802c 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -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(4_000_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::::insert(coldkey, hotkey.clone()); + Ok(()) } } diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 4781ad2dbd..ccad86855b 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -2770,7 +2770,10 @@ fn test_incentive_is_autostaked_to_owner_destination() { Uids::::insert(netuid, dest_hk, 2); // Set autostake destination for the miner's coldkey - AutoStakeDestination::::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), From 9e2d57512028fcb192ae640ceed2bc3e9761de64 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Sep 2025 12:46:01 +0000 Subject: [PATCH 2/2] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 83c637802c..c842709208 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2063,7 +2063,7 @@ mod dispatches { /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] #[pallet::weight( - Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + 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,