From 60e462e2cbfeb4445ae1aa84f1fc020329949157 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Tue, 9 Jun 2026 12:12:18 -0400 Subject: [PATCH 1/6] Add min_childkey_take_per_subnet hyperparameter --- pallets/subtensor/src/rpc_info/subnet_info.rs | 5 +++++ pallets/subtensor/src/tests/subnet_info.rs | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/pallets/subtensor/src/rpc_info/subnet_info.rs b/pallets/subtensor/src/rpc_info/subnet_info.rs index 00c3f1b18f..dc0b819404 100644 --- a/pallets/subtensor/src/rpc_info/subnet_info.rs +++ b/pallets/subtensor/src/rpc_info/subnet_info.rs @@ -617,6 +617,11 @@ impl Pallet { HyperparamValue::Bool(Self::get_owner_cut_auto_lock_enabled(netuid)), ) .into(), + ( + "min_childkey_take_per_subnet", + HyperparamValue::U16(Self::get_effective_min_childkey_take(netuid).into()), + ) + .into(), ]) } } diff --git a/pallets/subtensor/src/tests/subnet_info.rs b/pallets/subtensor/src/tests/subnet_info.rs index fcf597f4ff..a867ea645f 100644 --- a/pallets/subtensor/src/tests/subnet_info.rs +++ b/pallets/subtensor/src/tests/subnet_info.rs @@ -43,6 +43,7 @@ const EXPECTED_V3_NAMES: &[&[u8]] = &[ b"user_liquidity_enabled", b"owner_cut_enabled", b"owner_cut_auto_lock_enabled", + b"min_childkey_take_per_subnet", ]; fn find<'a>(params: &'a [HyperparamEntry], name: &[u8]) -> &'a HyperparamValue { @@ -121,6 +122,7 @@ fn test_get_subnet_hyperparams_v3_values_reflect_storage() { SubtensorModule::set_bonds_reset(netuid, true); SubtensorModule::set_owner_cut_enabled_flag(netuid, true); SubtensorModule::set_owner_cut_auto_lock_enabled(netuid, true); + SubtensorModule::set_min_childkey_take_for_subnet(netuid, 31); let result = SubtensorModule::get_subnet_hyperparams_v3(netuid).unwrap(); let p = &result; @@ -180,6 +182,10 @@ fn test_get_subnet_hyperparams_v3_values_reflect_storage() { &HyperparamValue::U16(Compact(30)) ); assert_eq!(find(p, b"yuma_version"), &HyperparamValue::U16(Compact(3))); + assert_eq!( + find(p, b"min_childkey_take_per_subnet"), + &HyperparamValue::U16(Compact(31)) + ); // U64 variants assert_eq!( From bde66c53e19a6f1602a2574db91327fdcb16bbbe Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 11 Jun 2026 14:33:55 -0400 Subject: [PATCH 2/6] Fix main merge broken test --- 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 From 62db84b35f7fae8dd386c47c60f4c1d30aff4b5a Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 11 Jun 2026 14:47:29 -0400 Subject: [PATCH 3/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 aadd7afe93218c254bc48bbb5da3da02d3d83ea4 Mon Sep 17 00:00:00 2001 From: gztensor <166415444+gztensor@users.noreply.github.com> Date: Thu, 11 Jun 2026 12:33:52 -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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 39b53cffdb..7ea9360684 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -46,17 +46,20 @@ impl Pallet { Error::::NonAssociatedColdKey ); - // 3. If the new hotkey already exists globally, ensure the coldkey owns it + // 3. Initialize the weight for this operation. The coldkey/old_hotkey + // ownership check above reads Owner twice. + let mut weight = T::DbWeight::get().reads(2); + + // 4. If the new hotkey already exists globally, ensure the coldkey owns it + weight.saturating_accrue(T::DbWeight::get().reads(1)); 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 ); } - // 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 2a0fd3c09dc9ed8c758a6ee9367f408ce78440ea Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 18 Jun 2026 15:51:09 +0300 Subject: [PATCH 5/6] Fix test_swap_owner_new_hotkey_already_exists --- pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs index 3fb8288f94..beb8ec9a75 100644 --- a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs +++ b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs @@ -900,22 +900,23 @@ fn test_swap_owner_old_hotkey_not_exist() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test swap_hotkey_with_subnet -- test_swap_owner_new_hotkey_already_exists --exact --nocapture +// SKIP_WASM_BUILD=1 cargo test --package pallet-subtensor --lib -- tests::swap_hotkey_with_subnet::test_swap_owner_new_hotkey_already_exists --exact --nocapture #[test] fn test_swap_owner_new_hotkey_already_exists() { new_test_ext(1).execute_with(|| { let old_hotkey = U256::from(1); let new_hotkey = U256::from(2); let coldkey = U256::from(3); + let another_coldkey = U256::from(4); - let netuid = add_dynamic_network(&new_hotkey, &coldkey); + let netuid = add_dynamic_network(&old_hotkey, &coldkey); add_balance_to_coldkey_account(&coldkey, 1_000_000_000_000_u64.into()); // old_hotkey is owned by coldkey; new_hotkey was already registered on `netuid` // by add_dynamic_network (the condition under test). Do NOT reassign new_hotkey to // a foreign coldkey — the new_hotkey-ownership check (NonAssociatedColdKey) would // then fire before the already-registered-in-subnet check this test targets. - Owner::::insert(old_hotkey, coldkey); + Owner::::insert(new_hotkey, another_coldkey); // Perform the swap System::set_block_number(System::block_number() + HotkeySwapOnSubnetInterval::get()); From f173757b50582b801a0b1facb539b742577c4a28 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Thu, 18 Jun 2026 15:56:55 +0300 Subject: [PATCH 6/6] merge devnet-ready --- pallets/subtensor/src/tests/subnet_info.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pallets/subtensor/src/tests/subnet_info.rs b/pallets/subtensor/src/tests/subnet_info.rs index 342b3bc885..378d641343 100644 --- a/pallets/subtensor/src/tests/subnet_info.rs +++ b/pallets/subtensor/src/tests/subnet_info.rs @@ -122,12 +122,8 @@ fn test_get_subnet_hyperparams_v3_values_reflect_storage() { SubtensorModule::set_bonds_reset(netuid, true); SubtensorModule::set_owner_cut_enabled_flag(netuid, true); SubtensorModule::set_owner_cut_auto_lock_enabled(netuid, true); -<<<<<<< HEAD - SubtensorModule::set_min_childkey_take_for_subnet(netuid, 31); -======= SubtensorModule::set_min_childkey_take(31); SubtensorModule::set_min_childkey_take_for_subnet(netuid, 32); ->>>>>>> devnet-ready let result = SubtensorModule::get_subnet_hyperparams_v3(netuid).unwrap(); let p = &result; @@ -187,16 +183,10 @@ fn test_get_subnet_hyperparams_v3_values_reflect_storage() { &HyperparamValue::U16(Compact(30)) ); assert_eq!(find(p, b"yuma_version"), &HyperparamValue::U16(Compact(3))); -<<<<<<< HEAD - assert_eq!( - find(p, b"min_childkey_take_per_subnet"), - &HyperparamValue::U16(Compact(31)) -======= // Effective min childkey take = max(global, per-subnet). assert_eq!( find(p, b"min_childkey_take"), &HyperparamValue::U16(Compact(32)) ->>>>>>> devnet-ready ); // U64 variants