From 5d27fc6bfa2bedbe89889aace5d7615c1eeb261a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 25 Aug 2025 16:05:33 +0300 Subject: [PATCH] =?UTF-8?q?Update=20dispatch=20class=20and=20=E2=80=9Cpays?= =?UTF-8?q?::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 abc5e7a443..3f0c19f7a9 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -376,13 +376,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, @@ -602,12 +600,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, @@ -1095,7 +1091,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, @@ -1109,7 +1105,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, @@ -1288,7 +1284,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, @@ -1418,7 +1414,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, @@ -1453,7 +1449,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, @@ -1477,7 +1473,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, @@ -1522,7 +1518,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 5290d3ddfc..1ad4a20d63 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 0383f3edee..1a712276fa 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1987,7 +1987,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(