From e2eafe6edb70034b40344b1b447f2662c8c1bfea Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 11 Jun 2026 13:08:34 -0400 Subject: [PATCH 1/6] Make setting ck take extrinsics payable --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- pallets/subtensor/src/tests/staking.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index b471328aec..9afa16922e 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -611,7 +611,7 @@ mod dispatches { /// - The delegate is setting a take which is not lower than the previous. /// #[pallet::call_index(65)] - #[pallet::weight((::WeightInfo::decrease_take(), DispatchClass::Normal, Pays::No))] + #[pallet::weight((::WeightInfo::decrease_take(), DispatchClass::Normal, Pays::Yes))] pub fn decrease_take( origin: OriginFor, hotkey: T::AccountId, @@ -651,7 +651,7 @@ mod dispatches { /// - The delegate is setting a take which is not greater than the previous. /// #[pallet::call_index(66)] - #[pallet::weight((::WeightInfo::increase_take(), DispatchClass::Normal, Pays::No))] + #[pallet::weight((::WeightInfo::increase_take(), DispatchClass::Normal, Pays::Yes))] pub fn increase_take( origin: OriginFor, hotkey: T::AccountId, diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index 7906c8b798..46b938b484 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -22,6 +22,26 @@ use crate::*; staking::add_stake() tests ************************************************************/ +#[test] +fn test_delegate_take_dispatch_info_pays_fee() { + new_test_ext(1).execute_with(|| { + let hotkey = U256::from(1); + let take = SubtensorModule::get_min_delegate_take(); + + let decrease_take_call = + RuntimeCall::SubtensorModule(SubtensorCall::decrease_take { hotkey, take }); + let decrease_take_dispatch_info = decrease_take_call.get_dispatch_info(); + assert_eq!(decrease_take_dispatch_info.class, DispatchClass::Normal); + assert_eq!(decrease_take_dispatch_info.pays_fee, Pays::Yes); + + let increase_take_call = + RuntimeCall::SubtensorModule(SubtensorCall::increase_take { hotkey, take }); + let increase_take_dispatch_info = increase_take_call.get_dispatch_info(); + assert_eq!(increase_take_dispatch_info.class, DispatchClass::Normal); + assert_eq!(increase_take_dispatch_info.pays_fee, Pays::Yes); + }); +} + #[test] fn test_add_stake_dispatch_info_ok() { new_test_ext(1).execute_with(|| { From 7d11d6d1bb3342b0411de255cb7a58098dd5bd1e Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 11 Jun 2026 14:46:42 -0400 Subject: [PATCH 2/6] spec bump --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index df8d3a1a4a..7bc7028f68 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -234,7 +234,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 417, + spec_version: 418, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 593ceba74645367ec49db3c1f755c2a398a2517b Mon Sep 17 00:00:00 2001 From: gztensor <166415444+gztensor@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:33:24 -0700 Subject: [PATCH 3/6] Update pallets/subtensor/src/swap/swap_hotkey.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- pallets/subtensor/src/swap/swap_hotkey.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 39b53cffdb..55a067732b 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -46,17 +46,21 @@ impl Pallet { Error::::NonAssociatedColdKey ); - // 3. If the new hotkey already exists globally, ensure the coldkey owns it + // 3. Initialize the weight for this operation. This includes the old-hotkey + // owner check above. + let mut weight = T::DbWeight::get().reads(2); + + // 4. If the new hotkey already exists globally, ensure the coldkey owns it if Self::hotkey_account_exists(new_hotkey) { + weight.saturating_accrue(T::DbWeight::get().reads(2)); ensure!( Self::coldkey_owns_hotkey(&coldkey, new_hotkey), Error::::NonAssociatedColdKey ); + } else { + weight.saturating_accrue(T::DbWeight::get().reads(1)); } - // 4. Initialize the weight for this operation - let mut weight = T::DbWeight::get().reads(2); - // 5. Ensure the new hotkey is different from the old one ensure!(old_hotkey != new_hotkey, Error::::NewHotKeyIsSameWithOld); From 485071c128c1e6f373dd8bde2b046d4acc10e76e Mon Sep 17 00:00:00 2001 From: gztensor <166415444+gztensor@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:20:17 -0700 Subject: [PATCH 4/6] Update pallets/subtensor/src/swap/swap_hotkey.rs Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- pallets/subtensor/src/swap/swap_hotkey.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 55a067732b..cac71b25a4 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -52,7 +52,7 @@ impl Pallet { // 4. If the new hotkey already exists globally, ensure the coldkey owns it if Self::hotkey_account_exists(new_hotkey) { - weight.saturating_accrue(T::DbWeight::get().reads(2)); +weight.saturating_accrue(T::DbWeight::get().reads(3)); ensure!( Self::coldkey_owns_hotkey(&coldkey, new_hotkey), Error::::NonAssociatedColdKey From 0a52e4106a68dabd3253882c42cee0b513c5e02a Mon Sep 17 00:00:00 2001 From: "subtensor-ai-review[bot]" Date: Thu, 11 Jun 2026 20:26:24 +0000 Subject: [PATCH 5/6] chore: auditor auto-fix --- pallets/subtensor/src/swap/swap_hotkey.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index cac71b25a4..8f81327e31 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -52,7 +52,7 @@ impl Pallet { // 4. If the new hotkey already exists globally, ensure the coldkey owns it if Self::hotkey_account_exists(new_hotkey) { -weight.saturating_accrue(T::DbWeight::get().reads(3)); + weight.saturating_accrue(T::DbWeight::get().reads(3)); ensure!( Self::coldkey_owns_hotkey(&coldkey, new_hotkey), Error::::NonAssociatedColdKey From 51068415bce36b1d9874ce1f7c67b046b3941c47 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 11 Jun 2026 16:44:03 -0400 Subject: [PATCH 6/6] Fix test_swap_owner_new_hotkey_already_exists --- pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs index 426572bdcd..76dcd0a9ad 100644 --- a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs +++ b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs @@ -926,7 +926,7 @@ fn test_swap_owner_new_hotkey_already_exists() { Some(netuid), false ), - Error::::HotKeyAlreadyRegisteredInSubNet + Error::::NonAssociatedColdKey ); // Verify the swap