From 9e22239266a74d1109c511dd67227fb7fc3b017a Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 05:12:45 -0400 Subject: [PATCH 01/15] make reg_network pays::yes --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index d7e9b9ab1e..3b88528e45 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1195,7 +1195,7 @@ mod dispatches { #[pallet::call_index(59)] #[pallet::weight((Weight::from_parts(191_600_000, 0) .saturating_add(T::DbWeight::get().reads(36)) - .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Operational, Pays::No))] + .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Operational, Pays::Yes))] pub fn register_network(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_register_network(origin, &hotkey, 1, None) } @@ -1540,7 +1540,7 @@ mod dispatches { #[pallet::call_index(79)] #[pallet::weight((Weight::from_parts(185_500_000, 0) .saturating_add(T::DbWeight::get().reads(35)) - .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Operational, Pays::No))] + .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Operational, Pays::Yes))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From 11aba9cd7e91334ebf4804472039f75bce016ca0 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 05:12:56 -0400 Subject: [PATCH 02/15] add validation for last lock to reg_network --- pallets/subtensor/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 17f7c69672..1e7ad50216 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2365,6 +2365,12 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { + let current_block = Self::get_current_block_as_u64(); + let last_lock_block = Self::get_network_last_lock_block(); + if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { + return Err(CustomTransactionError::RateLimitExceeded.into()); + } + let validity = Self::validity_ok(Self::get_priority_vanilla()); Ok((validity, Some(who.clone()), origin)) } From f90fc58e15771ac80f195d5655f718228dc0d384 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 11:41:47 -0400 Subject: [PATCH 03/15] fix references --- pallets/subtensor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 1e7ad50216..1b3d2fafdc 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2365,8 +2365,8 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { - let current_block = Self::get_current_block_as_u64(); - let last_lock_block = Self::get_network_last_lock_block(); + let current_block = Pallet::::get_current_block_as_u64(); + let last_lock_block = Pallet::::get_network_last_lock_block(); if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { return Err(CustomTransactionError::RateLimitExceeded.into()); } From 552e135d05009034c684783eb748b36f42252c60 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 12:39:11 -0400 Subject: [PATCH 04/15] fix test --- pallets/subtensor/src/tests/registration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index 09b129dc67..b9fad0be02 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -42,7 +42,7 @@ fn test_registration_subscribe_ok_dispatch_info_ok() { call_weight: frame_support::weights::Weight::from_parts(3_111_800_000, 0), extension_weight: frame_support::weights::Weight::zero(), class: DispatchClass::Normal, - pays_fee: Pays::No + pays_fee: Pays::Yes } ); }); From bc4e3f14adaa770c244b0498680715f8dd9b50de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 18:22:28 +0000 Subject: [PATCH 05/15] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 3b88528e45..5018e72a14 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -413,7 +413,7 @@ mod dispatches { /// - Attempting to set weights with max value exceeding limit. /// #[pallet::call_index(8)] - #[pallet::weight((Weight::from_parts(2_684_000, 0) + #[pallet::weight((Weight::from_parts(2_023_000, 0) .saturating_add(T::DbWeight::get().reads(0_u64)) .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn set_tao_weights( @@ -454,7 +454,7 @@ mod dispatches { /// - The hotkey we are delegating is not owned by the calling coldket. /// #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(2_363_000, 0) + #[pallet::weight((Weight::from_parts(2_864_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::Yes))] pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { @@ -827,7 +827,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(5)] - #[pallet::weight((Weight::from_parts(22_640_000, 0) + #[pallet::weight((Weight::from_parts(30_730_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_prometheus( @@ -1465,7 +1465,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(68)] - #[pallet::weight((Weight::from_parts(24_350_000, 0) + #[pallet::weight((Weight::from_parts(31_590_000, 0) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::Yes))] pub fn set_identity( @@ -1575,7 +1575,7 @@ mod dispatches { /// * `TxRateLimitExceeded`: /// - Thrown if key has hit transaction rate limit #[pallet::call_index(83)] - #[pallet::weight((Weight::from_parts(28_910_000, 0) + #[pallet::weight((Weight::from_parts(22_790_000, 0) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -1608,7 +1608,7 @@ mod dispatches { /// * `TxRateLimitExceeded`: /// - Thrown if key has hit transaction rate limit #[pallet::call_index(84)] - #[pallet::weight((Weight::from_parts(395_800_000, 0) + #[pallet::weight((Weight::from_parts(294_000_000, 0) .saturating_add(T::DbWeight::get().reads(33)) .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all_alpha(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -2075,7 +2075,7 @@ mod dispatches { /// at which or better (higher) the staking should execute. /// Without limit_price it remove all the stake similar to `remove_stake` extrinsic #[pallet::call_index(103)] - #[pallet::weight((Weight::from_parts(421_500_000, 10142) + #[pallet::weight((Weight::from_parts(321_900_000, 10142) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_full_limit( @@ -2156,7 +2156,7 @@ mod dispatches { /// Emits a `SymbolUpdated` event on success. #[pallet::call_index(112)] #[pallet::weight(( - Weight::from_parts(28_910_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), + Weight::from_parts(20_530_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), DispatchClass::Operational, Pays::Yes ))] From 90662c43baa9389a3ffed85bb51032afc4669972 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 22:05:17 +0000 Subject: [PATCH 06/15] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index e7f06df53c..afc2fdc647 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -693,7 +693,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(4)] - #[pallet::weight((Weight::from_parts(36_090_000, 0) + #[pallet::weight((Weight::from_parts(25_950_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon( @@ -827,7 +827,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(5)] - #[pallet::weight((Weight::from_parts(30_730_000, 0) + #[pallet::weight((Weight::from_parts(22_520_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_prometheus( @@ -1465,7 +1465,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(68)] - #[pallet::weight((Weight::from_parts(31_590_000, 0) + #[pallet::weight((Weight::from_parts(23_870_000, 0) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::Yes))] pub fn set_identity( @@ -1609,8 +1609,8 @@ mod dispatches { /// - Thrown if key has hit transaction rate limit #[pallet::call_index(84)] #[pallet::weight((Weight::from_parts(294_000_000, 0) - .saturating_add(T::DbWeight::get().reads(33)) - .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::Yes))] + .saturating_add(T::DbWeight::get().reads(38_u64)) + .saturating_add(T::DbWeight::get().writes(21_u64)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all_alpha(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_unstake_all_alpha(origin, hotkey) } @@ -1723,8 +1723,8 @@ mod dispatches { #[pallet::call_index(87)] #[pallet::weight(( Weight::from_parts(274_400_000, 0) - .saturating_add(T::DbWeight::get().reads(32)) - .saturating_add(T::DbWeight::get().writes(17)), + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().writes(22_u64)), DispatchClass::Operational, Pays::Yes ))] @@ -1896,8 +1896,8 @@ mod dispatches { #[pallet::call_index(90)] #[pallet::weight(( Weight::from_parts(330_400_000, 0) - .saturating_add(T::DbWeight::get().reads(32)) - .saturating_add(T::DbWeight::get().writes(17)), + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().writes(22_u64)), DispatchClass::Operational, Pays::Yes ))] From 66f08de184b29fb90b74e85251750b083bd829d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Aug 2025 18:20:51 +0000 Subject: [PATCH 07/15] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 869ead77b9..be066f0bfc 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -693,7 +693,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(4)] - #[pallet::weight((Weight::from_parts(25_950_000, 0) + #[pallet::weight((Weight::from_parts(35_800_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon( @@ -1045,7 +1045,7 @@ mod dispatches { /// #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(5_912_000, 0) + Weight::from_parts(7_394_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, From 90fb1650eeaad30a801e8b56a75ccdad6b7b6e45 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 14 Aug 2025 14:48:39 -0400 Subject: [PATCH 08/15] remove test again --- pallets/subtensor/src/tests/registration.rs | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index 173074ed4a..67c3fd3c4d 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -18,36 +18,6 @@ use crate::{AxonInfoOf, CustomTransactionError, Error, SubtensorTransactionExten subscribing::subscribe() tests *********************************************/ -// Tests a basic registration dispatch passes. -#[test] -fn test_registration_subscribe_ok_dispatch_info_ok() { - new_test_ext(1).execute_with(|| { - let block_number: u64 = 0; - let nonce: u64 = 0; - let netuid = NetUid::from(1); - let work: Vec = vec![0; 32]; - let hotkey: U256 = U256::from(0); - let coldkey: U256 = U256::from(0); - let call = RuntimeCall::SubtensorModule(SubtensorCall::register { - netuid, - block_number, - nonce, - work, - hotkey, - coldkey, - }); - assert_eq!( - call.get_dispatch_info(), - DispatchInfo { - call_weight: frame_support::weights::Weight::from_parts(3_111_800_000, 0), - extension_weight: frame_support::weights::Weight::zero(), - class: DispatchClass::Normal, - pays_fee: Pays::Yes - } - ); - }); -} - #[test] fn test_registration_difficulty() { new_test_ext(1).execute_with(|| { From c95fd8eafbf0a7da21c8139ca19235a9a5894178 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 14 Aug 2025 14:55:16 -0400 Subject: [PATCH 09/15] cargo lock --- Cargo.lock | 96 +++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 895b55e447..e0c155108a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -972,11 +972,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.4.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.4.1", + "event-listener 5.4.0", "event-listener-strategy", "pin-project-lite", ] @@ -1005,7 +1005,7 @@ dependencies = [ "async-task", "blocking", "cfg-if", - "event-listener 5.4.1", + "event-listener 5.4.0", "futures-lite", "rustix 1.0.8", ] @@ -1544,9 +1544,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.31" +version = "1.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" +checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" dependencies = [ "jobserver", "libc", @@ -3052,9 +3052,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.4.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" dependencies = [ "concurrent-queue", "parking", @@ -3067,7 +3067,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "event-listener 5.4.1", + "event-listener 5.4.0", "pin-project-lite", ] @@ -3501,12 +3501,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "flume" version = "0.11.1" @@ -4114,9 +4108,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" dependencies = [ "fastrand", "futures-core", @@ -7313,7 +7307,7 @@ dependencies = [ "expander", "indexmap 2.10.0", "itertools 0.11.0", - "petgraph 0.6.5", + "petgraph", "proc-macro-crate 3.3.0", "proc-macro2", "quote", @@ -8639,17 +8633,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ - "fixedbitset 0.4.2", - "indexmap 2.10.0", -] - -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset 0.5.7", + "fixedbitset", "indexmap 2.10.0", ] @@ -9178,9 +9162,9 @@ checksum = "23eff02c070c70f31878a3d915e88a914ecf3e153741e2fb572dde28cce20fde" [[package]] name = "polling" -version = "3.10.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829" +checksum = "8ee9b2fa7a4517d2c91ff5bc6c297a427a96749d15f98fcdbb22c05571a4d4b7" dependencies = [ "cfg-if", "concurrent-queue", @@ -9553,7 +9537,7 @@ dependencies = [ "log", "multimap", "once_cell", - "petgraph 0.7.1", + "petgraph", "prettyplease", "prost 0.13.5", "prost-types", @@ -10121,9 +10105,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.16.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecb38f82477f20c5c3d62ef52d7c4e536e38ea9b73fb570a20c5cae0e14bcf6" +checksum = "11256b5fe8c68f56ac6f39ef0720e592f33d2367a4782740d9c9142e889c7fb4" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -12023,9 +12007,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" dependencies = [ "itoa", "memchr", @@ -12177,9 +12161,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] @@ -12298,7 +12282,7 @@ dependencies = [ "derive_more 0.99.20", "ed25519-zebra", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "fnv", "futures-lite", "futures-util", @@ -12347,7 +12331,7 @@ dependencies = [ "bs58", "derive_more 0.99.20", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "fnv", "futures-channel", "futures-lite", @@ -12667,7 +12651,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12763,7 +12747,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "proc-macro2", "quote", @@ -12773,7 +12757,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "environmental", "parity-scale-codec", @@ -12983,7 +12967,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -13020,7 +13004,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "Inflector", "expander", @@ -13122,12 +13106,12 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "impl-serde 0.5.0", "parity-scale-codec", @@ -13163,7 +13147,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "parity-scale-codec", "regex", @@ -13260,7 +13244,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -13350,7 +13334,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", @@ -14373,9 +14357,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.1" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" dependencies = [ "backtrace", "bytes", @@ -14442,9 +14426,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.16" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" dependencies = [ "bytes", "futures-core", @@ -16193,9 +16177,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.3" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", From d84da7bcff59515318fdb092a8d7fe1087ea3d67 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 18 Aug 2025 20:40:49 -0400 Subject: [PATCH 10/15] use existing helpers and fix > --- pallets/subtensor/src/lib.rs | 4 +--- pallets/subtensor/src/subnets/subnet.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index f4f98c3e83..57fa5eef1b 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2361,9 +2361,7 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { - let current_block = Pallet::::get_current_block_as_u64(); - let last_lock_block = Pallet::::get_network_last_lock_block(); - if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { + if !Pallet::::passes_rate_limit(&TransactionType::RegisterNetwork, who) { return Err(CustomTransactionError::RateLimitExceeded.into()); } diff --git a/pallets/subtensor/src/subnets/subnet.rs b/pallets/subtensor/src/subnets/subnet.rs index 17e349c995..a9da369ad5 100644 --- a/pallets/subtensor/src/subnets/subnet.rs +++ b/pallets/subtensor/src/subnets/subnet.rs @@ -134,9 +134,8 @@ impl Pallet { // --- 4. Rate limit for network registrations. let current_block = Self::get_current_block_as_u64(); - let last_lock_block = Self::get_network_last_lock_block(); ensure!( - current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get(), + Self::passes_rate_limit(&TransactionType::RegisterNetwork, &coldkey), Error::::NetworkTxRateLimitExceeded ); @@ -174,7 +173,12 @@ impl Pallet { log::debug!("SubnetMechanism for netuid {netuid_to_register:?} set to: {mechid:?}"); // --- 12. Set the creation terms. - NetworkLastRegistered::::set(current_block); + Self::set_last_transaction_block_on_subnet( + &coldkey, + netuid_to_register, + &TransactionType::RegisterNetwork, + current_block, + ); NetworkRegisteredAt::::insert(netuid_to_register, current_block); // --- 13. Set the symbol. From 6b2628c57d57addab11b223c606551c5fcbf851b Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 18 Aug 2025 21:12:14 -0400 Subject: [PATCH 11/15] bump spec --- 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 16af31170e..d2b7ed9831 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -213,7 +213,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: 302, + spec_version: 303, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From d61e59d77e169a2863d545bb5f5a30b4db73feac Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 8 Sep 2025 09:08:27 -0700 Subject: [PATCH 12/15] add import --- pallets/subtensor/src/transaction_extension.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index c3eb95f54d..064a242f91 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -1,5 +1,6 @@ use crate::{ BalancesCall, Call, ColdkeySwapScheduled, Config, CustomTransactionError, Error, Pallet, + TransactionType, }; use codec::{Decode, DecodeWithMemTracking, Encode}; use frame_support::dispatch::{DispatchInfo, PostDispatchInfo}; From a6c1343a1109adacc221c7a11590e5cb5ae392d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 18:13:52 +0000 Subject: [PATCH 13/15] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 32c27f7bef..47997e55e8 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -186,7 +186,7 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(100)] - #[pallet::weight((Weight::from_parts(82_010_000, 0) + #[pallet::weight((Weight::from_parts(100_500_000, 0) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn batch_commit_weights( @@ -761,7 +761,7 @@ mod dispatches { /// Attempt to adjust the senate membership to include a hotkey #[pallet::call_index(63)] - #[pallet::weight((Weight::from_parts(75_430_000, 0) + #[pallet::weight((Weight::from_parts(58_850_000, 0) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)), DispatchClass::Normal, Pays::Yes))] pub fn adjust_senate(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -891,7 +891,7 @@ mod dispatches { /// #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(7_394_000, 0) + Weight::from_parts(5_660_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, From e9572f094e40cd0d618a820076bef79572ebb0ff Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 9 Sep 2025 14:13:19 -0400 Subject: [PATCH 14/15] bench --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index c112f35ecb..f069ff0aa5 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1041,7 +1041,7 @@ mod dispatches { #[pallet::call_index(59)] #[pallet::weight((Weight::from_parts(235_400_000, 0) .saturating_add(T::DbWeight::get().reads(36)) - .saturating_add(T::DbWeight::get().writes(51_u64)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Normal, Pays::Yes))] pub fn register_network(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_register_network(origin, &hotkey, 1, None) } @@ -1328,7 +1328,7 @@ mod dispatches { #[pallet::call_index(79)] #[pallet::weight((Weight::from_parts(234_200_000, 0) .saturating_add(T::DbWeight::get().reads(35)) - .saturating_add(T::DbWeight::get().writes(50_u64)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Normal, Pays::Yes))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From bc24c46bb61647ab2be89fe1ae2f08ad364777c3 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 9 Sep 2025 14:33:04 -0400 Subject: [PATCH 15/15] bump spec --- 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 40c76514d4..f938105bc6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -220,7 +220,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: 313, + spec_version: 314, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,