From 2c11a680de9141c8f952ea3390c0b67b4947d21a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 25 Aug 2025 16:05:33 +0300 Subject: [PATCH 1/7] =?UTF-8?q?Update=20dispatch=20class=20and=20=E2=80=9C?= =?UTF-8?q?pays::yes=E2=80=9D=20for=20extrinsics.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pallets/admin-utils/src/lib.rs | 30 ++++++++++------------ pallets/admin-utils/src/tests/mod.rs | 4 +-- pallets/subtensor/src/macros/dispatches.rs | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 4334a1f8be..44085a3121 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -378,13 +378,11 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment alpha. #[pallet::call_index(9)] - #[pallet::weight(( + #[pallet::weight( Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)) - .saturating_add(::DbWeight::get().reads(1)), - DispatchClass::Operational, - Pays::No - ))] + .saturating_add(::DbWeight::get().reads(1)) + )] pub fn sudo_set_adjustment_alpha( origin: OriginFor, netuid: NetUid, @@ -604,12 +602,10 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the network PoW registration allowed. #[pallet::call_index(20)] - #[pallet::weight(( + #[pallet::weight( Weight::from_parts(14_000_000, 0) - .saturating_add(::DbWeight::get().writes(1)), - DispatchClass::Operational, - Pays::No - ))] + .saturating_add(::DbWeight::get().writes(1)) + )] pub fn sudo_set_network_pow_registration_allowed( origin: OriginFor, netuid: NetUid, @@ -1132,7 +1128,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(50)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_liquid_alpha_enabled( origin: OriginFor, netuid: NetUid, @@ -1146,7 +1142,7 @@ pub mod pallet { /// Sets values for liquid alpha #[pallet::call_index(51)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_alpha_values( origin: OriginFor, netuid: NetUid, @@ -1385,7 +1381,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(61)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_toggle_transfer( origin: OriginFor, netuid: NetUid, @@ -1515,7 +1511,7 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(68)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_alpha_sigmoid_steepness( origin: OriginFor, netuid: NetUid, @@ -1550,7 +1546,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(69)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_yuma3_enabled( origin: OriginFor, netuid: NetUid, @@ -1574,7 +1570,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(70)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_bonds_reset_enabled( origin: OriginFor, netuid: NetUid, @@ -1619,7 +1615,7 @@ pub mod pallet { /// # Rate Limiting /// This function is rate-limited to one call per subnet per interval (e.g., one week). #[pallet::call_index(67)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_sn_owner_hotkey( origin: OriginFor, netuid: NetUid, diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 754befc805..708f293121 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -1227,8 +1227,8 @@ fn test_set_alpha_values_dispatch_info_ok() { let dispatch_info = call.get_dispatch_info(); - assert_eq!(dispatch_info.class, DispatchClass::Operational); - assert_eq!(dispatch_info.pays_fee, Pays::No); + assert_eq!(dispatch_info.class, DispatchClass::Normal); + assert_eq!(dispatch_info.pays_fee, Pays::Yes); }); } diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aed0c150de..79310aaeff 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2157,7 +2157,7 @@ mod dispatches { #[pallet::call_index(112)] #[pallet::weight(( Weight::from_parts(26_200_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), - DispatchClass::Operational, + DispatchClass::Normal, Pays::Yes ))] pub fn update_symbol( From 41876825915613c8b28b1d8cd5307ef3a41e6afe Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 26 Aug 2025 17:45:07 +0300 Subject: [PATCH 2/7] Add missing benchmarks for admin-utils --- pallets/admin-utils/src/benchmarking.rs | 179 ++++++++++++++++++++++- pallets/admin-utils/src/lib.rs | 156 ++++++++++++++++---- pallets/subtensor/src/epoch/run_epoch.rs | 7 - 3 files changed, 307 insertions(+), 35 deletions(-) diff --git a/pallets/admin-utils/src/benchmarking.rs b/pallets/admin-utils/src/benchmarking.rs index 61df5d55f8..71c221af43 100644 --- a/pallets/admin-utils/src/benchmarking.rs +++ b/pallets/admin-utils/src/benchmarking.rs @@ -17,6 +17,7 @@ use super::*; #[benchmarks] mod benchmarks { use super::*; + use subtensor_runtime_common::NetUid; #[benchmark] fn swap_authorities(a: Linear<0, 32>) { @@ -346,5 +347,181 @@ mod benchmarks { _(RawOrigin::Root, 5u16/*version*/)/*sudo_set_commit_reveal_version()*/; } - //impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test); + #[benchmark] + fn sudo_set_tx_rate_limit() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64); + } + + #[benchmark] + fn sudo_set_total_issuance() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64.into()); + } + + #[benchmark] + fn sudo_set_rao_recycled() { + let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, 100u64.into()); + } + + #[benchmark] + fn sudo_set_stake_threshold() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64); + } + + #[benchmark] + fn sudo_set_nominator_min_required_stake() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64); + } + + #[benchmark] + fn sudo_set_tx_delegate_take_rate_limit() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64); + } + + #[benchmark] + fn sudo_set_min_delegate_take() { + #[extrinsic_call] + _(RawOrigin::Root, 100u16); + } + + #[benchmark] + fn sudo_set_liquid_alpha_enabled() { + let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, true); + } + + #[benchmark] + fn sudo_set_alpha_values() { + let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + pallet_subtensor::Pallet::::set_liquid_alpha_enabled(netuid, true); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, 2000u16, 3000u16); + } + + #[benchmark] + fn sudo_set_coldkey_swap_schedule_duration() { + #[extrinsic_call] + _(RawOrigin::Root, 100u32.into()); + } + + #[benchmark] + fn sudo_set_dissolve_network_schedule_duration() { + #[extrinsic_call] + _(RawOrigin::Root, 100u32.into()); + } + + #[benchmark] + fn sudo_set_toggle_transfer() { + let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, true); + } + + #[benchmark] + fn sudo_toggle_evm_precompile() { + #[extrinsic_call] + _(RawOrigin::Root, PrecompileEnum::Staking, true); + } + + #[benchmark] + fn sudo_set_subnet_moving_alpha() { + #[extrinsic_call] + _(RawOrigin::Root, 100u64.into()); + } + + #[benchmark] + fn sudo_set_ema_price_halving_period() { + let netuid = NetUid::from(1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, 100u64); + } + + #[benchmark] + fn sudo_set_alpha_sigmoid_steepness() { + let netuid = NetUid::from(1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, 100i16); + } + + #[benchmark] + fn sudo_set_yuma3_enabled() { + let netuid = NetUid::from(1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, true); + } + + #[benchmark] + fn sudo_set_bonds_reset_enabled() { + let netuid = NetUid::from(1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, true); + } + + #[benchmark] + fn sudo_set_sn_owner_hotkey() { + let netuid = NetUid::from(1); + let hotkey: T::AccountId = account("Alice", 0, 1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, hotkey); + } + + #[benchmark] + fn sudo_set_subtoken_enabled() { + let netuid = NetUid::from(1); + + pallet_subtensor::Pallet::::init_new_network( + netuid, 1u16, // tempo + ); + + #[extrinsic_call] + _(RawOrigin::Root, netuid, true); + } } diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 44085a3121..4914977084 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -196,7 +196,12 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the transaction rate limit. #[pallet::call_index(2)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight( + (Weight::from_parts(7_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes) + )] pub fn sudo_set_tx_rate_limit(origin: OriginFor, tx_rate_limit: u64) -> DispatchResult { ensure_root(origin)?; pallet_subtensor::Pallet::::set_tx_rate_limit(tx_rate_limit); @@ -580,7 +585,7 @@ pub mod pallet { .saturating_add(::DbWeight::get().reads(0)) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_network_registration_allowed( origin: OriginFor, @@ -843,7 +848,7 @@ pub mod pallet { Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_subnet_owner_cut( origin: OriginFor, @@ -863,7 +868,7 @@ pub mod pallet { Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_network_rate_limit( origin: OriginFor, @@ -897,7 +902,12 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the issuance for the network. #[pallet::call_index(33)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(4_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_total_issuance( origin: OriginFor, total_issuance: TaoCurrency, @@ -917,7 +927,7 @@ pub mod pallet { Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_network_immunity_period( origin: OriginFor, @@ -940,7 +950,7 @@ pub mod pallet { Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_network_min_lock_cost( origin: OriginFor, @@ -978,7 +988,7 @@ pub mod pallet { Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_lock_reduction_interval( origin: OriginFor, @@ -997,7 +1007,13 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the recycled RAO. #[pallet::call_index(39)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(12_000_000, 4045) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_rao_recycled( origin: OriginFor, netuid: NetUid, @@ -1016,7 +1032,11 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the weights min stake. #[pallet::call_index(42)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(5_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_stake_threshold(origin: OriginFor, min_stake: u64) -> DispatchResult { ensure_root(origin)?; pallet_subtensor::Pallet::::set_stake_threshold(min_stake); @@ -1027,7 +1047,13 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the minimum stake required for nominators. #[pallet::call_index(43)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(23_000_000, 6792) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_nominator_min_required_stake( origin: OriginFor, // The minimum stake required for nominators. @@ -1049,7 +1075,11 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the rate limit for delegate take transactions. #[pallet::call_index(45)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_tx_delegate_take_rate_limit( origin: OriginFor, tx_rate_limit: u64, @@ -1066,7 +1096,11 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the minimum delegate take. #[pallet::call_index(46)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(5_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_min_delegate_take(origin: OriginFor, take: u16) -> DispatchResult { ensure_root(origin)?; pallet_subtensor::Pallet::::set_min_delegate_take(take); @@ -1128,7 +1162,12 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(50)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(4_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_liquid_alpha_enabled( origin: OriginFor, netuid: NetUid, @@ -1142,7 +1181,13 @@ pub mod pallet { /// Sets values for liquid alpha #[pallet::call_index(51)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(12_000_000, 4089) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_alpha_values( origin: OriginFor, netuid: NetUid, @@ -1226,7 +1271,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(54)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_coldkey_swap_schedule_duration( origin: OriginFor, duration: BlockNumberFor, @@ -1258,7 +1308,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(55)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(5_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_dissolve_network_schedule_duration( origin: OriginFor, duration: BlockNumberFor, @@ -1381,7 +1436,12 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(61)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(6_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_toggle_transfer( origin: OriginFor, netuid: NetUid, @@ -1404,7 +1464,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(62)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(5_000_000, 3507) + .saturating_add(T::DbWeight::get().reads(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_toggle_evm_precompile( origin: OriginFor, precompile_id: PrecompileEnum, @@ -1433,7 +1498,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(63)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(3_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_subnet_moving_alpha(origin: OriginFor, alpha: I96F32) -> DispatchResult { ensure_root(origin)?; pallet_subtensor::SubnetMovingAlpha::::set(alpha); @@ -1480,7 +1550,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(65)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(3_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_ema_price_halving_period( origin: OriginFor, netuid: NetUid, @@ -1511,7 +1586,13 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(68)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(10_000_000, 4045) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_alpha_sigmoid_steepness( origin: OriginFor, netuid: NetUid, @@ -1546,7 +1627,12 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(69)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(6_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_yuma3_enabled( origin: OriginFor, netuid: NetUid, @@ -1570,7 +1656,12 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(70)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(8_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_bonds_reset_enabled( origin: OriginFor, netuid: NetUid, @@ -1615,7 +1706,13 @@ pub mod pallet { /// # Rate Limiting /// This function is rate-limited to one call per subnet per interval (e.g., one week). #[pallet::call_index(67)] - #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights + #[pallet::weight(( + Weight::from_parts(17_000_000, 4204) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), + DispatchClass::Normal, + Pays::Yes + ))] pub fn sudo_set_sn_owner_hotkey( origin: OriginFor, netuid: NetUid, @@ -1637,7 +1734,12 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(66)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight(( + Weight::from_parts(3_000_000, 0) + .saturating_add(T::DbWeight::get().writes(1_u64)), + DispatchClass::Operational, + Pays::Yes + ))] pub fn sudo_set_subtoken_enabled( origin: OriginFor, netuid: NetUid, @@ -1659,7 +1761,7 @@ pub mod pallet { .saturating_add(::DbWeight::get().writes(1)) .saturating_add(::DbWeight::get().reads(0_u64)), DispatchClass::Operational, - Pays::No + Pays::Yes ))] pub fn sudo_set_commit_reveal_version( origin: OriginFor, diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 2f302c2a5e..6be16eac07 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -1380,13 +1380,8 @@ impl Pallet { alpha_low: u16, alpha_high: u16, ) -> Result<(), DispatchError> { - // --- 1. Ensure the function caller is a signed user. - ensure_signed(origin.clone())?; - - // --- 2. Ensure the function caller is the subnet owner or root. Self::ensure_subnet_owner_or_root(origin, netuid)?; - // --- 3. Ensure liquid alpha is enabled ensure!( Self::get_liquid_alpha_enabled(netuid), Error::::LiquidAlphaDisabled @@ -1396,10 +1391,8 @@ impl Pallet { let min_alpha_low: u16 = (max_u16.safe_div(40)) as u16; // 1638 let min_alpha_high: u16 = min_alpha_low; - // --- 4. Ensure alpha high is greater than the minimum ensure!(alpha_high >= min_alpha_high, Error::::AlphaHighTooLow); - // -- 5. Ensure alpha low is within range ensure!( alpha_low >= min_alpha_low && alpha_low <= alpha_high, Error::::AlphaLowOutOfRange From a3a9de844b1baa327c3b68b9e5a47a15b0827620 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 26 Aug 2025 15:47:20 +0000 Subject: [PATCH 3/7] auto-update benchmark weights --- pallets/admin-utils/src/lib.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 4914977084..a696a99f54 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -197,7 +197,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the transaction rate limit. #[pallet::call_index(2)] #[pallet::weight( - (Weight::from_parts(7_000_000, 0) + (Weight::from_parts(5_400_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes) @@ -903,7 +903,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the issuance for the network. #[pallet::call_index(33)] #[pallet::weight(( - Weight::from_parts(4_000_000, 0) + Weight::from_parts(2_875_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes @@ -1008,7 +1008,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the recycled RAO. #[pallet::call_index(39)] #[pallet::weight(( - Weight::from_parts(12_000_000, 4045) + Weight::from_parts(15_060_000, 4045) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, @@ -1048,7 +1048,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the minimum stake required for nominators. #[pallet::call_index(43)] #[pallet::weight(( - Weight::from_parts(23_000_000, 6792) + Weight::from_parts(28_050_000, 6792) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, @@ -1076,7 +1076,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the rate limit for delegate take transactions. #[pallet::call_index(45)] #[pallet::weight(( - Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), + Weight::from_parts(5_019_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes ))] @@ -1182,7 +1182,7 @@ pub mod pallet { /// Sets values for liquid alpha #[pallet::call_index(51)] #[pallet::weight(( - Weight::from_parts(12_000_000, 4089) + Weight::from_parts(14_960_000, 4089) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, @@ -1347,7 +1347,7 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(57)] - #[pallet::weight(Weight::from_parts(19_320_000, 0) + #[pallet::weight(Weight::from_parts(15_220_000, 0) .saturating_add(::DbWeight::get().reads(1_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_commit_reveal_weights_interval( @@ -1437,7 +1437,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(61)] #[pallet::weight(( - Weight::from_parts(6_000_000, 0) + Weight::from_parts(7_514_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1465,7 +1465,7 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(62)] #[pallet::weight(( - Weight::from_parts(5_000_000, 3507) + Weight::from_parts(6_392_000, 3507) .saturating_add(T::DbWeight::get().reads(1_u64)), DispatchClass::Operational, Pays::Yes @@ -1551,7 +1551,7 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(65)] #[pallet::weight(( - Weight::from_parts(3_000_000, 0) + Weight::from_parts(3_918_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes @@ -1587,7 +1587,7 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(68)] #[pallet::weight(( - Weight::from_parts(10_000_000, 4045) + Weight::from_parts(12_160_000, 4045) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, @@ -1628,7 +1628,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(6_000_000, 0) + Weight::from_parts(7_374_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1707,7 +1707,7 @@ pub mod pallet { /// This function is rate-limited to one call per subnet per interval (e.g., one week). #[pallet::call_index(67)] #[pallet::weight(( - Weight::from_parts(17_000_000, 4204) + Weight::from_parts(20_570_000, 4204) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, @@ -1735,7 +1735,7 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(66)] #[pallet::weight(( - Weight::from_parts(3_000_000, 0) + Weight::from_parts(4_448_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes From 137d9fc55bf0ea4ed85e139124757251444ec542 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 10 Sep 2025 14:03:53 +0300 Subject: [PATCH 4/7] Bump spec_version to 316 --- 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 aee1e04895..6f3929de00 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: 315, + spec_version: 316, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 29f01ff3a996d2b478297c2e661005714ea89890 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 10 Sep 2025 14:16:34 +0000 Subject: [PATCH 5/7] auto-update benchmark weights --- pallets/admin-utils/src/lib.rs | 2 +- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 7944f606c3..4f2eb31ea4 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1144,7 +1144,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(50)] #[pallet::weight(( - Weight::from_parts(4_000_000, 0) + Weight::from_parts(4_840_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index f069ff0aa5..735e702d50 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -623,7 +623,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(40)] - #[pallet::weight((Weight::from_parts(41_240_000, 0) + #[pallet::weight((Weight::from_parts(32_520_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon_tls( @@ -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(52)), DispatchClass::Normal, Pays::Yes))] + .saturating_add(T::DbWeight::get().writes(51_u64)), 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(51)), DispatchClass::Normal, Pays::Yes))] + .saturating_add(T::DbWeight::get().writes(50_u64)), DispatchClass::Normal, Pays::Yes))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From c1feba3caa13ca477971622969471323e77bea38 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Fri, 3 Oct 2025 11:48:06 -0700 Subject: [PATCH 6/7] Update benchmarking.rs --- pallets/admin-utils/src/benchmarking.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pallets/admin-utils/src/benchmarking.rs b/pallets/admin-utils/src/benchmarking.rs index c21eb43081..7e6e17dd5c 100644 --- a/pallets/admin-utils/src/benchmarking.rs +++ b/pallets/admin-utils/src/benchmarking.rs @@ -470,6 +470,7 @@ mod benchmarks { #[benchmark] fn sudo_set_liquid_alpha_enabled() { let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -481,6 +482,7 @@ mod benchmarks { #[benchmark] fn sudo_set_alpha_values() { let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -505,6 +507,7 @@ mod benchmarks { #[benchmark] fn sudo_set_toggle_transfer() { let netuid = NetUid::from(1); + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -540,7 +543,7 @@ mod benchmarks { #[benchmark] fn sudo_set_alpha_sigmoid_steepness() { let netuid = NetUid::from(1); - + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -552,7 +555,7 @@ mod benchmarks { #[benchmark] fn sudo_set_yuma3_enabled() { let netuid = NetUid::from(1); - + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -564,7 +567,7 @@ mod benchmarks { #[benchmark] fn sudo_set_bonds_reset_enabled() { let netuid = NetUid::from(1); - + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); @@ -589,7 +592,7 @@ mod benchmarks { #[benchmark] fn sudo_set_subtoken_enabled() { let netuid = NetUid::from(1); - + pallet_subtensor::Pallet::::set_admin_freeze_window(0); pallet_subtensor::Pallet::::init_new_network( netuid, 1u16, // tempo ); From 6d6e86735e771e700176c2abd69760bb2d9c8b03 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 3 Oct 2025 19:58:00 +0000 Subject: [PATCH 7/7] auto-update benchmark weights --- pallets/admin-utils/src/lib.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index d51de0fc01..9295978495 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -371,7 +371,7 @@ pub mod pallet { /// It is only callable by the root account, not changeable by the subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment interval. #[pallet::call_index(8)] - #[pallet::weight(Weight::from_parts(15_100_000, 0) + #[pallet::weight(Weight::from_parts(21_320_000, 0) .saturating_add(::DbWeight::get().reads(1_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_adjustment_interval( @@ -734,7 +734,7 @@ pub mod pallet { /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the target registrations per interval. #[pallet::call_index(21)] - #[pallet::weight(Weight::from_parts(25_860_000, 0) + #[pallet::weight(Weight::from_parts(44_320_000, 0) .saturating_add(::DbWeight::get().reads(3_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_target_registrations_per_interval( @@ -1307,7 +1307,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(50)] #[pallet::weight(( - Weight::from_parts(4_840_000, 0) + Weight::from_parts(18_300_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1335,8 +1335,8 @@ pub mod pallet { /// Sets values for liquid alpha #[pallet::call_index(51)] #[pallet::weight(( - Weight::from_parts(14_960_000, 4089) - .saturating_add(T::DbWeight::get().reads(1_u64)) + Weight::from_parts(25_280_000, 4089) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1551,7 +1551,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(61)] #[pallet::weight(( - Weight::from_parts(7_514_000, 0) + Weight::from_parts(20_460_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1745,8 +1745,8 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(68)] #[pallet::weight(( - Weight::from_parts(12_160_000, 4045) - .saturating_add(T::DbWeight::get().reads(1_u64)) + Weight::from_parts(23_140_000, 4045) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1795,7 +1795,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(7_374_000, 0) + Weight::from_parts(20_460_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1833,7 +1833,7 @@ pub mod pallet { /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(70)] #[pallet::weight(( - Weight::from_parts(8_000_000, 0) + Weight::from_parts(22_340_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Normal, Pays::Yes @@ -1920,7 +1920,7 @@ pub mod pallet { /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(66)] #[pallet::weight(( - Weight::from_parts(4_448_000, 0) + Weight::from_parts(17_980_000, 0) .saturating_add(T::DbWeight::get().writes(1_u64)), DispatchClass::Operational, Pays::Yes