From 5f6a29f9c63df437be54548ae0986c5ebb8a8601 Mon Sep 17 00:00:00 2001 From: Ankan Date: Sun, 25 Dec 2022 21:33:36 +0100 Subject: [PATCH 1/4] staking admin can set min commission --- bin/node/runtime/src/lib.rs | 2 +- frame/babe/src/mock.rs | 2 +- frame/fast-unstake/src/mock.rs | 2 +- frame/grandpa/src/mock.rs | 2 +- .../nomination-pools/benchmarking/src/mock.rs | 2 +- .../nomination-pools/test-staking/src/mock.rs | 2 +- frame/offences/benchmarking/src/mock.rs | 2 +- frame/root-offences/src/mock.rs | 2 +- frame/session/benchmarking/src/mock.rs | 2 +- frame/staking/src/benchmarking.rs | 7 ++++ frame/staking/src/mock.rs | 21 +++++----- frame/staking/src/pallet/mod.rs | 25 +++++++++--- frame/staking/src/tests.rs | 40 +++++++++++++++++++ frame/staking/src/weights.rs | 9 +++++ 14 files changed, 97 insertions(+), 23 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 3e2701b2278c8..0c946fa180f20 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -567,7 +567,7 @@ impl pallet_staking::Config for Runtime { type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; /// A super-majority of the council can cancel the slash. - type SlashCancelOrigin = EitherOfDiverse< + type AdminOrigin = EitherOfDiverse< EnsureRoot, pallet_collective::EnsureProportionAtLeast, >; diff --git a/frame/babe/src/mock.rs b/frame/babe/src/mock.rs index 204de8aae172e..dbeb588c1830e 100644 --- a/frame/babe/src/mock.rs +++ b/frame/babe/src/mock.rs @@ -195,7 +195,7 @@ impl pallet_staking::Config for Test { type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/fast-unstake/src/mock.rs b/frame/fast-unstake/src/mock.rs index b67dcf581ed97..3f974e5e1a9d6 100644 --- a/frame/fast-unstake/src/mock.rs +++ b/frame/fast-unstake/src/mock.rs @@ -140,7 +140,7 @@ impl pallet_staking::Config for Runtime { type Reward = (); type SessionsPerEra = (); type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/grandpa/src/mock.rs b/frame/grandpa/src/mock.rs index 1a97b1345fe5d..131f6cafcd179 100644 --- a/frame/grandpa/src/mock.rs +++ b/frame/grandpa/src/mock.rs @@ -199,7 +199,7 @@ impl pallet_staking::Config for Test { type SessionsPerEra = SessionsPerEra; type BondingDuration = BondingDuration; type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type SessionInterface = Self; type UnixTime = pallet_timestamp::Pallet; type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/nomination-pools/benchmarking/src/mock.rs b/frame/nomination-pools/benchmarking/src/mock.rs index 6959aa9783ee5..06a66838594c7 100644 --- a/frame/nomination-pools/benchmarking/src/mock.rs +++ b/frame/nomination-pools/benchmarking/src/mock.rs @@ -102,7 +102,7 @@ impl pallet_staking::Config for Runtime { type Reward = (); type SessionsPerEra = (); type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = ConstU32<3>; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/nomination-pools/test-staking/src/mock.rs b/frame/nomination-pools/test-staking/src/mock.rs index 568dec7b3a340..c67aec0134b07 100644 --- a/frame/nomination-pools/test-staking/src/mock.rs +++ b/frame/nomination-pools/test-staking/src/mock.rs @@ -116,7 +116,7 @@ impl pallet_staking::Config for Runtime { type Reward = (); type SessionsPerEra = (); type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = (); type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/offences/benchmarking/src/mock.rs b/frame/offences/benchmarking/src/mock.rs index de3a4eca6308d..223f551a6e5c1 100644 --- a/frame/offences/benchmarking/src/mock.rs +++ b/frame/offences/benchmarking/src/mock.rs @@ -173,7 +173,7 @@ impl pallet_staking::Config for Test { type Reward = (); type SessionsPerEra = (); type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/root-offences/src/mock.rs b/frame/root-offences/src/mock.rs index 65bfcad4b26fc..e1d9ee14ee2fc 100644 --- a/frame/root-offences/src/mock.rs +++ b/frame/root-offences/src/mock.rs @@ -184,7 +184,7 @@ impl pallet_staking::Config for Test { type Reward = (); type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/session/benchmarking/src/mock.rs b/frame/session/benchmarking/src/mock.rs index 2db7eb385111c..0699640bc092a 100644 --- a/frame/session/benchmarking/src/mock.rs +++ b/frame/session/benchmarking/src/mock.rs @@ -167,7 +167,7 @@ impl pallet_staking::Config for Test { type Reward = (); type SessionsPerEra = (); type SlashDeferDuration = (); - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = frame_system::EnsureRoot; type BondingDuration = (); type SessionInterface = Self; type EraPayout = pallet_staking::ConvertCurve; diff --git a/frame/staking/src/benchmarking.rs b/frame/staking/src/benchmarking.rs index 81fa0f9d81dbf..b3d32b26ec1f7 100644 --- a/frame/staking/src/benchmarking.rs +++ b/frame/staking/src/benchmarking.rs @@ -922,6 +922,13 @@ benchmarks! { ); } + set_min_commission { + let min_commission = Perbill::max_value(); + }: _(RawOrigin::Root, min_commission) + verify { + assert_eq!(MinCommission::::get(), Perbill::from_percent(100)); + } + impl_benchmark_test_suite!( Staking, crate::mock::ExtBuilder::default().has_stakers(true), diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index d3affda05277a..11a5ee8a8f87d 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -19,14 +19,12 @@ use crate::{self as pallet_staking, *}; use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight}; -use frame_support::{ - assert_ok, parameter_types, - traits::{ - ConstU32, ConstU64, Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, - OnUnbalanced, OneSessionHandler, - }, - weights::constants::RocksDbWeight, -}; +use frame_support::{assert_ok, ord_parameter_types, parameter_types, traits::{ + ConstU32, ConstU64, Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, + OnUnbalanced, OneSessionHandler, +}, weights::constants::RocksDbWeight}; +use frame_support::traits::EitherOfDiverse; +use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_io; use sp_runtime::{ @@ -292,7 +290,7 @@ impl crate::pallet::pallet::Config for Test { type Reward = MockReward; type SessionsPerEra = SessionsPerEra; type SlashDeferDuration = SlashDeferDuration; - type SlashCancelOrigin = frame_system::EnsureRoot; + type AdminOrigin = EnsureOneOrRoot; type BondingDuration = BondingDuration; type SessionInterface = Self; type EraPayout = ConvertCurve; @@ -797,6 +795,11 @@ pub(crate) fn staking_events() -> Vec> { parameter_types! { static StakingEventsIndex: usize = 0; } +ord_parameter_types! { + pub const One: u64 = 1; +} + +type EnsureOneOrRoot = EitherOfDiverse, EnsureSignedBy>; pub(crate) fn staking_events_since_last_call() -> Vec> { let all: Vec<_> = System::events() diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index f04d13d05f468..e522cc7162697 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -183,8 +183,10 @@ pub mod pallet { #[pallet::constant] type SlashDeferDuration: Get; - /// The origin which can cancel a deferred slash. Root can always do this. - type SlashCancelOrigin: EnsureOrigin; + /// The origin which can manage less critical staking parameters that does not require root. + /// + /// Supported actions: (1) cancel deferred slash, (2) set minimum commission. + type AdminOrigin: EnsureOrigin; /// Interface for interacting with a session pallet. type SessionInterface: SessionInterface; @@ -1452,7 +1454,7 @@ pub mod pallet { /// Cancel enactment of a deferred slash. /// - /// Can be called by the `T::SlashCancelOrigin`. + /// Can be called by the `T::AdminOrigin`. /// /// Parameters: era and indices of the slashes for that era to kill. #[pallet::call_index(17)] @@ -1462,7 +1464,7 @@ pub mod pallet { era: EraIndex, slash_indices: Vec, ) -> DispatchResult { - T::SlashCancelOrigin::ensure_origin(origin)?; + T::AdminOrigin::ensure_origin(origin)?; ensure!(!slash_indices.is_empty(), Error::::EmptyTargets); ensure!(is_sorted_and_unique(&slash_indices), Error::::NotSortedAndUnique); @@ -1683,7 +1685,6 @@ pub mod pallet { config_op_exp!(MinCommission, min_commission); Ok(()) } - /// Declare a `controller` to stop participating as either a validator or nominator. /// /// Effects will be felt at the beginning of the next era. @@ -1792,6 +1793,20 @@ pub mod pallet { })?; Ok(()) } + + /// Sets the minimum amount of commission that each validators must maintain. + /// + /// This call has lower privilege requirements than `set_staking_config` and can be called + /// by the `T::AdminOrigin`. Root can always call this. + /// + /// Weight: `O(1)` + #[pallet::call_index(25)] + #[pallet::weight(T::WeightInfo::set_min_commission())] + pub fn set_min_commission(origin: OriginFor, new: Perbill) -> DispatchResult { + T::AdminOrigin::ensure_origin(origin)?; + MinCommission::::put(new); + Ok(()) + } } } diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 5c2766deee307..9c13c5721de4f 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5726,6 +5726,46 @@ fn scale_validator_count_errors() { }) } +#[test] +fn set_min_commission_works_with_admin_origin() { + ExtBuilder::default().build_and_execute(|| { + // no minimum commission set initially + assert_eq!(MinCommission::::get(), Perbill::from_percent(0)); + + // root can set min commission + assert_ok!(Staking::set_min_commission( + RuntimeOrigin::root(), + Perbill::from_percent(10), + )); + + assert_eq!(MinCommission::::get(), Perbill::from_percent(10)); + + // Non privileged origin can not set min_commission + assert_noop!( + Staking::set_min_commission(RuntimeOrigin::signed(2), Perbill::from_percent(15)), + BadOrigin + ); + + // Admin Origin can set min commission + assert_ok!(Staking::set_min_commission( + RuntimeOrigin::signed(1), + Perbill::from_percent(15), + )); + + // setting commission below min_commission fails + assert_noop!(Staking::validate( + RuntimeOrigin::signed(10), + ValidatorPrefs { commission: Perbill::from_percent(14), blocked: false } + ), Error::::CommissionTooLow); + + // setting commission >= min_commission works + assert_ok!(Staking::validate( + RuntimeOrigin::signed(10), + ValidatorPrefs { commission: Perbill::from_percent(15), blocked: false } + )); + }) +} + mod staking_interface { use frame_support::storage::with_storage_layer; use sp_staking::StakingInterface; diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index aebb8eeb9b06e..33eaa3058006b 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -77,6 +77,7 @@ pub trait WeightInfo { fn set_staking_configs_all_remove() -> Weight; fn chill_other() -> Weight; fn force_apply_min_commission() -> Weight; + fn set_min_commission() -> Weight; } /// Weights for pallet_staking using the Substrate node and recommended hardware. @@ -488,6 +489,10 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } + + fn set_min_commission() -> Weight { + Weight::zero() + } } // For backwards compatibility and tests @@ -898,4 +903,8 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } + + fn set_min_commission() -> Weight { + Weight::zero() + } } From 4a4df5fcc35291a4ace371cf7f5316053a5fbecf Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Sun, 25 Dec 2022 21:29:25 +0000 Subject: [PATCH 2/4] ".git/.scripts/bench-bot.sh" pallet dev pallet_staking --- frame/staking/src/weights.rs | 384 ++++++++++++++++++----------------- 1 file changed, 197 insertions(+), 187 deletions(-) diff --git a/frame/staking/src/weights.rs b/frame/staking/src/weights.rs index 33eaa3058006b..9c283f5a065e3 100644 --- a/frame/staking/src/weights.rs +++ b/frame/staking/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-12-14, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-12-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -89,8 +89,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - // Minimum execution time: 54_402 nanoseconds. - Weight::from_ref_time(55_096_000) + // Minimum execution time: 54_884 nanoseconds. + Weight::from_ref_time(55_487_000) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(4)) } @@ -100,8 +100,8 @@ impl WeightInfo for SubstrateWeight { // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra() -> Weight { - // Minimum execution time: 94_407 nanoseconds. - Weight::from_ref_time(95_209_000) + // Minimum execution time: 95_115 nanoseconds. + Weight::from_ref_time(96_213_000) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(7)) } @@ -115,8 +115,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Bonded (r:1 w:0) // Storage: VoterList ListBags (r:2 w:2) fn unbond() -> Weight { - // Minimum execution time: 101_046 nanoseconds. - Weight::from_ref_time(101_504_000) + // Minimum execution time: 102_031 nanoseconds. + Weight::from_ref_time(102_842_000) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -126,10 +126,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 45_452 nanoseconds. - Weight::from_ref_time(47_031_537) - // Standard Error: 491 - .saturating_add(Weight::from_ref_time(67_148).saturating_mul(s.into())) + // Minimum execution time: 46_569 nanoseconds. + Weight::from_ref_time(48_034_493) + // Standard Error: 654 + .saturating_add(Weight::from_ref_time(63_628).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(3)) } @@ -149,10 +149,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 88_067 nanoseconds. - Weight::from_ref_time(93_309_587) - // Standard Error: 4_762 - .saturating_add(Weight::from_ref_time(1_114_938).saturating_mul(s.into())) + // Minimum execution time: 90_154 nanoseconds. + Weight::from_ref_time(95_725_631) + // Standard Error: 2_491 + .saturating_add(Weight::from_ref_time(1_110_795).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(13)) .saturating_add(T::DbWeight::get().writes(12)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -169,8 +169,8 @@ impl WeightInfo for SubstrateWeight { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - // Minimum execution time: 67_308 nanoseconds. - Weight::from_ref_time(68_266_000) + // Minimum execution time: 67_978 nanoseconds. + Weight::from_ref_time(69_153_000) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(5)) } @@ -178,10 +178,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Nominators (r:1 w:1) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - // Minimum execution time: 40_913 nanoseconds. - Weight::from_ref_time(48_140_584) - // Standard Error: 13_396 - .saturating_add(Weight::from_ref_time(6_862_893).saturating_mul(k.into())) + // Minimum execution time: 45_328 nanoseconds. + Weight::from_ref_time(47_719_103) + // Standard Error: 14_458 + .saturating_add(Weight::from_ref_time(6_999_252).saturating_mul(k.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -199,10 +199,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 73_490 nanoseconds. - Weight::from_ref_time(72_520_864) - // Standard Error: 7_090 - .saturating_add(Weight::from_ref_time(2_800_566).saturating_mul(n.into())) + // Minimum execution time: 74_650 nanoseconds. + Weight::from_ref_time(74_350_075) + // Standard Error: 10_527 + .saturating_add(Weight::from_ref_time(2_878_737).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(6)) @@ -215,58 +215,58 @@ impl WeightInfo for SubstrateWeight { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - // Minimum execution time: 66_293 nanoseconds. - Weight::from_ref_time(66_946_000) + // Minimum execution time: 67_790 nanoseconds. + Weight::from_ref_time(68_738_000) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - // Minimum execution time: 18_134 nanoseconds. - Weight::from_ref_time(18_497_000) + // Minimum execution time: 19_237 nanoseconds. + Weight::from_ref_time(19_534_000) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - // Minimum execution time: 26_728 nanoseconds. - Weight::from_ref_time(27_154_000) + // Minimum execution time: 27_288 nanoseconds. + Weight::from_ref_time(27_667_000) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(3)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - // Minimum execution time: 4_877 nanoseconds. - Weight::from_ref_time(5_028_000) + // Minimum execution time: 5_155 nanoseconds. + Weight::from_ref_time(5_464_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - // Minimum execution time: 5_000 nanoseconds. - Weight::from_ref_time(5_290_000) + // Minimum execution time: 5_405 nanoseconds. + Weight::from_ref_time(5_670_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - // Minimum execution time: 5_093 nanoseconds. - Weight::from_ref_time(5_378_000) + // Minimum execution time: 5_459 nanoseconds. + Weight::from_ref_time(5_616_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - // Minimum execution time: 5_144 nanoseconds. - Weight::from_ref_time(5_454_000) + // Minimum execution time: 5_476 nanoseconds. + Weight::from_ref_time(5_692_000) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking Invulnerables (r:0 w:1) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - // Minimum execution time: 5_190 nanoseconds. - Weight::from_ref_time(5_960_962) - // Standard Error: 41 - .saturating_add(Weight::from_ref_time(10_329).saturating_mul(v.into())) + // Minimum execution time: 5_544 nanoseconds. + Weight::from_ref_time(6_513_190) + // Standard Error: 76 + .saturating_add(Weight::from_ref_time(9_975).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking Bonded (r:1 w:1) @@ -284,10 +284,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - // Minimum execution time: 80_516 nanoseconds. - Weight::from_ref_time(86_317_884) - // Standard Error: 2_212 - .saturating_add(Weight::from_ref_time(1_103_962).saturating_mul(s.into())) + // Minimum execution time: 82_414 nanoseconds. + Weight::from_ref_time(88_511_246) + // Standard Error: 2_622 + .saturating_add(Weight::from_ref_time(1_131_814).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(12)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -295,10 +295,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking UnappliedSlashes (r:1 w:1) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - // Minimum execution time: 91_795 nanoseconds. - Weight::from_ref_time(904_524_900) - // Standard Error: 59_193 - .saturating_add(Weight::from_ref_time(4_944_680).saturating_mul(s.into())) + // Minimum execution time: 94_197 nanoseconds. + Weight::from_ref_time(903_418_326) + // Standard Error: 59_354 + .saturating_add(Weight::from_ref_time(4_948_354).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)) } @@ -313,10 +313,10 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - // Minimum execution time: 127_774 nanoseconds. - Weight::from_ref_time(178_857_156) - // Standard Error: 15_229 - .saturating_add(Weight::from_ref_time(22_112_174).saturating_mul(n.into())) + // Minimum execution time: 133_065 nanoseconds. + Weight::from_ref_time(197_555_906) + // Standard Error: 19_561 + .saturating_add(Weight::from_ref_time(22_683_426).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -334,10 +334,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Balances Locks (r:1 w:1) /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - // Minimum execution time: 161_910 nanoseconds. - Weight::from_ref_time(217_635_072) - // Standard Error: 30_726 - .saturating_add(Weight::from_ref_time(31_244_329).saturating_mul(n.into())) + // Minimum execution time: 164_719 nanoseconds. + Weight::from_ref_time(226_304_276) + // Standard Error: 31_675 + .saturating_add(Weight::from_ref_time(32_622_427).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(3)) @@ -351,10 +351,10 @@ impl WeightInfo for SubstrateWeight { // Storage: VoterList ListBags (r:2 w:2) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - // Minimum execution time: 92_986 nanoseconds. - Weight::from_ref_time(94_880_481) - // Standard Error: 2_007 - .saturating_add(Weight::from_ref_time(31_421).saturating_mul(l.into())) + // Minimum execution time: 95_631 nanoseconds. + Weight::from_ref_time(96_861_556) + // Standard Error: 2_114 + .saturating_add(Weight::from_ref_time(37_543).saturating_mul(l.into())) .saturating_add(T::DbWeight::get().reads(9)) .saturating_add(T::DbWeight::get().writes(8)) } @@ -373,10 +373,10 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking SpanSlash (r:0 w:1) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - // Minimum execution time: 92_750 nanoseconds. - Weight::from_ref_time(95_115_568) - // Standard Error: 2_037 - .saturating_add(Weight::from_ref_time(1_086_488).saturating_mul(s.into())) + // Minimum execution time: 95_251 nanoseconds. + Weight::from_ref_time(97_818_954) + // Standard Error: 2_356 + .saturating_add(Weight::from_ref_time(1_104_695).saturating_mul(s.into())) .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(12)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -397,19 +397,20 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumActiveStake (r:0 w:1) /// The range of component `v` is `[1, 10]`. /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 506_543 nanoseconds. - Weight::from_ref_time(507_261_000) - // Standard Error: 1_766_631 - .saturating_add(Weight::from_ref_time(59_139_153).saturating_mul(v.into())) - // Standard Error: 176_035 - .saturating_add(Weight::from_ref_time(13_512_781).saturating_mul(n.into())) + // Minimum execution time: 512_923 nanoseconds. + Weight::from_ref_time(514_740_000) + // Standard Error: 1_790_238 + .saturating_add(Weight::from_ref_time(59_320_539).saturating_mul(v.into())) + // Standard Error: 178_387 + .saturating_add(Weight::from_ref_time(13_902_705).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(206)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(T::DbWeight::get().writes(4)) .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into()))) } // Storage: VoterList CounterForListNodes (r:1 w:0) @@ -419,27 +420,29 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking Validators (r:500 w:0) // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking MinimumActiveStake (r:0 w:1) /// The range of component `v` is `[500, 1000]`. /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 24_155_382 nanoseconds. - Weight::from_ref_time(24_252_568_000) - // Standard Error: 319_250 - .saturating_add(Weight::from_ref_time(3_596_056).saturating_mul(v.into())) - // Standard Error: 319_250 - .saturating_add(Weight::from_ref_time(2_852_023).saturating_mul(n.into())) + // Minimum execution time: 24_913_316 nanoseconds. + Weight::from_ref_time(25_053_596_000) + // Standard Error: 324_610 + .saturating_add(Weight::from_ref_time(3_454_859).saturating_mul(v.into())) + // Standard Error: 324_610 + .saturating_add(Weight::from_ref_time(3_020_267).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(201)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking Validators (r:501 w:0) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - // Minimum execution time: 4_741_111 nanoseconds. - Weight::from_ref_time(113_360_179) - // Standard Error: 25_375 - .saturating_add(Weight::from_ref_time(9_494_142).saturating_mul(v.into())) + // Minimum execution time: 4_916_401 nanoseconds. + Weight::from_ref_time(81_160_966) + // Standard Error: 23_829 + .saturating_add(Weight::from_ref_time(9_883_413).saturating_mul(v.into())) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into()))) } @@ -450,8 +453,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - // Minimum execution time: 11_074 nanoseconds. - Weight::from_ref_time(11_312_000) + // Minimum execution time: 10_937 nanoseconds. + Weight::from_ref_time(11_324_000) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Staking MinCommission (r:0 w:1) @@ -461,8 +464,8 @@ impl WeightInfo for SubstrateWeight { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - // Minimum execution time: 9_795 nanoseconds. - Weight::from_ref_time(10_116_000) + // Minimum execution time: 9_424 nanoseconds. + Weight::from_ref_time(10_021_000) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Staking Ledger (r:1 w:0) @@ -476,22 +479,24 @@ impl WeightInfo for SubstrateWeight { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - // Minimum execution time: 82_914 nanoseconds. - Weight::from_ref_time(83_848_000) + // Minimum execution time: 84_495 nanoseconds. + Weight::from_ref_time(85_559_000) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - // Minimum execution time: 20_317 nanoseconds. - Weight::from_ref_time(20_639_000) + // Minimum execution time: 20_385 nanoseconds. + Weight::from_ref_time(20_824_000) .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } - + // Storage: Staking MinCommission (r:0 w:1) fn set_min_commission() -> Weight { - Weight::zero() + // Minimum execution time: 6_995 nanoseconds. + Weight::from_ref_time(7_213_000) + .saturating_add(T::DbWeight::get().writes(1)) } } @@ -503,8 +508,8 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) // Storage: Staking Payee (r:0 w:1) fn bond() -> Weight { - // Minimum execution time: 54_402 nanoseconds. - Weight::from_ref_time(55_096_000) + // Minimum execution time: 54_884 nanoseconds. + Weight::from_ref_time(55_487_000) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(4)) } @@ -514,8 +519,8 @@ impl WeightInfo for () { // Storage: VoterList ListNodes (r:3 w:3) // Storage: VoterList ListBags (r:2 w:2) fn bond_extra() -> Weight { - // Minimum execution time: 94_407 nanoseconds. - Weight::from_ref_time(95_209_000) + // Minimum execution time: 95_115 nanoseconds. + Weight::from_ref_time(96_213_000) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(7)) } @@ -529,8 +534,8 @@ impl WeightInfo for () { // Storage: Staking Bonded (r:1 w:0) // Storage: VoterList ListBags (r:2 w:2) fn unbond() -> Weight { - // Minimum execution time: 101_046 nanoseconds. - Weight::from_ref_time(101_504_000) + // Minimum execution time: 102_031 nanoseconds. + Weight::from_ref_time(102_842_000) .saturating_add(RocksDbWeight::get().reads(12)) .saturating_add(RocksDbWeight::get().writes(8)) } @@ -540,10 +545,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_update(s: u32, ) -> Weight { - // Minimum execution time: 45_452 nanoseconds. - Weight::from_ref_time(47_031_537) - // Standard Error: 491 - .saturating_add(Weight::from_ref_time(67_148).saturating_mul(s.into())) + // Minimum execution time: 46_569 nanoseconds. + Weight::from_ref_time(48_034_493) + // Standard Error: 654 + .saturating_add(Weight::from_ref_time(63_628).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(4)) .saturating_add(RocksDbWeight::get().writes(3)) } @@ -563,10 +568,10 @@ impl WeightInfo for () { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn withdraw_unbonded_kill(s: u32, ) -> Weight { - // Minimum execution time: 88_067 nanoseconds. - Weight::from_ref_time(93_309_587) - // Standard Error: 4_762 - .saturating_add(Weight::from_ref_time(1_114_938).saturating_mul(s.into())) + // Minimum execution time: 90_154 nanoseconds. + Weight::from_ref_time(95_725_631) + // Standard Error: 2_491 + .saturating_add(Weight::from_ref_time(1_110_795).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(13)) .saturating_add(RocksDbWeight::get().writes(12)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -583,8 +588,8 @@ impl WeightInfo for () { // Storage: VoterList CounterForListNodes (r:1 w:1) // Storage: Staking CounterForValidators (r:1 w:1) fn validate() -> Weight { - // Minimum execution time: 67_308 nanoseconds. - Weight::from_ref_time(68_266_000) + // Minimum execution time: 67_978 nanoseconds. + Weight::from_ref_time(69_153_000) .saturating_add(RocksDbWeight::get().reads(11)) .saturating_add(RocksDbWeight::get().writes(5)) } @@ -592,10 +597,10 @@ impl WeightInfo for () { // Storage: Staking Nominators (r:1 w:1) /// The range of component `k` is `[1, 128]`. fn kick(k: u32, ) -> Weight { - // Minimum execution time: 40_913 nanoseconds. - Weight::from_ref_time(48_140_584) - // Standard Error: 13_396 - .saturating_add(Weight::from_ref_time(6_862_893).saturating_mul(k.into())) + // Minimum execution time: 45_328 nanoseconds. + Weight::from_ref_time(47_719_103) + // Standard Error: 14_458 + .saturating_add(Weight::from_ref_time(6_999_252).saturating_mul(k.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(k.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(k.into()))) @@ -613,10 +618,10 @@ impl WeightInfo for () { // Storage: Staking CounterForNominators (r:1 w:1) /// The range of component `n` is `[1, 16]`. fn nominate(n: u32, ) -> Weight { - // Minimum execution time: 73_490 nanoseconds. - Weight::from_ref_time(72_520_864) - // Standard Error: 7_090 - .saturating_add(Weight::from_ref_time(2_800_566).saturating_mul(n.into())) + // Minimum execution time: 74_650 nanoseconds. + Weight::from_ref_time(74_350_075) + // Standard Error: 10_527 + .saturating_add(Weight::from_ref_time(2_878_737).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(12)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(6)) @@ -629,58 +634,58 @@ impl WeightInfo for () { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill() -> Weight { - // Minimum execution time: 66_293 nanoseconds. - Weight::from_ref_time(66_946_000) + // Minimum execution time: 67_790 nanoseconds. + Weight::from_ref_time(68_738_000) .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Staking Ledger (r:1 w:0) // Storage: Staking Payee (r:0 w:1) fn set_payee() -> Weight { - // Minimum execution time: 18_134 nanoseconds. - Weight::from_ref_time(18_497_000) + // Minimum execution time: 19_237 nanoseconds. + Weight::from_ref_time(19_534_000) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking Bonded (r:1 w:1) // Storage: Staking Ledger (r:2 w:2) fn set_controller() -> Weight { - // Minimum execution time: 26_728 nanoseconds. - Weight::from_ref_time(27_154_000) + // Minimum execution time: 27_288 nanoseconds. + Weight::from_ref_time(27_667_000) .saturating_add(RocksDbWeight::get().reads(3)) .saturating_add(RocksDbWeight::get().writes(3)) } // Storage: Staking ValidatorCount (r:0 w:1) fn set_validator_count() -> Weight { - // Minimum execution time: 4_877 nanoseconds. - Weight::from_ref_time(5_028_000) + // Minimum execution time: 5_155 nanoseconds. + Weight::from_ref_time(5_464_000) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_no_eras() -> Weight { - // Minimum execution time: 5_000 nanoseconds. - Weight::from_ref_time(5_290_000) + // Minimum execution time: 5_405 nanoseconds. + Weight::from_ref_time(5_670_000) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era() -> Weight { - // Minimum execution time: 5_093 nanoseconds. - Weight::from_ref_time(5_378_000) + // Minimum execution time: 5_459 nanoseconds. + Weight::from_ref_time(5_616_000) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking ForceEra (r:0 w:1) fn force_new_era_always() -> Weight { - // Minimum execution time: 5_144 nanoseconds. - Weight::from_ref_time(5_454_000) + // Minimum execution time: 5_476 nanoseconds. + Weight::from_ref_time(5_692_000) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking Invulnerables (r:0 w:1) /// The range of component `v` is `[0, 1000]`. fn set_invulnerables(v: u32, ) -> Weight { - // Minimum execution time: 5_190 nanoseconds. - Weight::from_ref_time(5_960_962) - // Standard Error: 41 - .saturating_add(Weight::from_ref_time(10_329).saturating_mul(v.into())) + // Minimum execution time: 5_544 nanoseconds. + Weight::from_ref_time(6_513_190) + // Standard Error: 76 + .saturating_add(Weight::from_ref_time(9_975).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking Bonded (r:1 w:1) @@ -698,10 +703,10 @@ impl WeightInfo for () { // Storage: Staking SpanSlash (r:0 w:2) /// The range of component `s` is `[0, 100]`. fn force_unstake(s: u32, ) -> Weight { - // Minimum execution time: 80_516 nanoseconds. - Weight::from_ref_time(86_317_884) - // Standard Error: 2_212 - .saturating_add(Weight::from_ref_time(1_103_962).saturating_mul(s.into())) + // Minimum execution time: 82_414 nanoseconds. + Weight::from_ref_time(88_511_246) + // Standard Error: 2_622 + .saturating_add(Weight::from_ref_time(1_131_814).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(11)) .saturating_add(RocksDbWeight::get().writes(12)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -709,10 +714,10 @@ impl WeightInfo for () { // Storage: Staking UnappliedSlashes (r:1 w:1) /// The range of component `s` is `[1, 1000]`. fn cancel_deferred_slash(s: u32, ) -> Weight { - // Minimum execution time: 91_795 nanoseconds. - Weight::from_ref_time(904_524_900) - // Standard Error: 59_193 - .saturating_add(Weight::from_ref_time(4_944_680).saturating_mul(s.into())) + // Minimum execution time: 94_197 nanoseconds. + Weight::from_ref_time(903_418_326) + // Standard Error: 59_354 + .saturating_add(Weight::from_ref_time(4_948_354).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(1)) .saturating_add(RocksDbWeight::get().writes(1)) } @@ -727,10 +732,10 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) /// The range of component `n` is `[0, 256]`. fn payout_stakers_dead_controller(n: u32, ) -> Weight { - // Minimum execution time: 127_774 nanoseconds. - Weight::from_ref_time(178_857_156) - // Standard Error: 15_229 - .saturating_add(Weight::from_ref_time(22_112_174).saturating_mul(n.into())) + // Minimum execution time: 133_065 nanoseconds. + Weight::from_ref_time(197_555_906) + // Standard Error: 19_561 + .saturating_add(Weight::from_ref_time(22_683_426).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2)) @@ -748,10 +753,10 @@ impl WeightInfo for () { // Storage: Balances Locks (r:1 w:1) /// The range of component `n` is `[0, 256]`. fn payout_stakers_alive_staked(n: u32, ) -> Weight { - // Minimum execution time: 161_910 nanoseconds. - Weight::from_ref_time(217_635_072) - // Standard Error: 30_726 - .saturating_add(Weight::from_ref_time(31_244_329).saturating_mul(n.into())) + // Minimum execution time: 164_719 nanoseconds. + Weight::from_ref_time(226_304_276) + // Standard Error: 31_675 + .saturating_add(Weight::from_ref_time(32_622_427).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(10)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(3)) @@ -765,10 +770,10 @@ impl WeightInfo for () { // Storage: VoterList ListBags (r:2 w:2) /// The range of component `l` is `[1, 32]`. fn rebond(l: u32, ) -> Weight { - // Minimum execution time: 92_986 nanoseconds. - Weight::from_ref_time(94_880_481) - // Standard Error: 2_007 - .saturating_add(Weight::from_ref_time(31_421).saturating_mul(l.into())) + // Minimum execution time: 95_631 nanoseconds. + Weight::from_ref_time(96_861_556) + // Standard Error: 2_114 + .saturating_add(Weight::from_ref_time(37_543).saturating_mul(l.into())) .saturating_add(RocksDbWeight::get().reads(9)) .saturating_add(RocksDbWeight::get().writes(8)) } @@ -787,10 +792,10 @@ impl WeightInfo for () { // Storage: Staking SpanSlash (r:0 w:1) /// The range of component `s` is `[1, 100]`. fn reap_stash(s: u32, ) -> Weight { - // Minimum execution time: 92_750 nanoseconds. - Weight::from_ref_time(95_115_568) - // Standard Error: 2_037 - .saturating_add(Weight::from_ref_time(1_086_488).saturating_mul(s.into())) + // Minimum execution time: 95_251 nanoseconds. + Weight::from_ref_time(97_818_954) + // Standard Error: 2_356 + .saturating_add(Weight::from_ref_time(1_104_695).saturating_mul(s.into())) .saturating_add(RocksDbWeight::get().reads(12)) .saturating_add(RocksDbWeight::get().writes(12)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(s.into()))) @@ -811,19 +816,20 @@ impl WeightInfo for () { // Storage: Staking ErasStakers (r:0 w:1) // Storage: Staking ErasTotalStake (r:0 w:1) // Storage: Staking ErasStartSessionIndex (r:0 w:1) + // Storage: Staking MinimumActiveStake (r:0 w:1) /// The range of component `v` is `[1, 10]`. /// The range of component `n` is `[0, 100]`. fn new_era(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 506_543 nanoseconds. - Weight::from_ref_time(507_261_000) - // Standard Error: 1_766_631 - .saturating_add(Weight::from_ref_time(59_139_153).saturating_mul(v.into())) - // Standard Error: 176_035 - .saturating_add(Weight::from_ref_time(13_512_781).saturating_mul(n.into())) + // Minimum execution time: 512_923 nanoseconds. + Weight::from_ref_time(514_740_000) + // Standard Error: 1_790_238 + .saturating_add(Weight::from_ref_time(59_320_539).saturating_mul(v.into())) + // Standard Error: 178_387 + .saturating_add(Weight::from_ref_time(13_902_705).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(206)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) - .saturating_add(RocksDbWeight::get().writes(3)) + .saturating_add(RocksDbWeight::get().writes(4)) .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into()))) } // Storage: VoterList CounterForListNodes (r:1 w:0) @@ -833,27 +839,29 @@ impl WeightInfo for () { // Storage: Staking Validators (r:500 w:0) // Storage: Staking Bonded (r:1500 w:0) // Storage: Staking Ledger (r:1500 w:0) + // Storage: Staking MinimumActiveStake (r:0 w:1) /// The range of component `v` is `[500, 1000]`. /// The range of component `n` is `[500, 1000]`. fn get_npos_voters(v: u32, n: u32, ) -> Weight { - // Minimum execution time: 24_155_382 nanoseconds. - Weight::from_ref_time(24_252_568_000) - // Standard Error: 319_250 - .saturating_add(Weight::from_ref_time(3_596_056).saturating_mul(v.into())) - // Standard Error: 319_250 - .saturating_add(Weight::from_ref_time(2_852_023).saturating_mul(n.into())) + // Minimum execution time: 24_913_316 nanoseconds. + Weight::from_ref_time(25_053_596_000) + // Standard Error: 324_610 + .saturating_add(Weight::from_ref_time(3_454_859).saturating_mul(v.into())) + // Standard Error: 324_610 + .saturating_add(Weight::from_ref_time(3_020_267).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(201)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(v.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(n.into()))) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Staking CounterForValidators (r:1 w:0) // Storage: Staking Validators (r:501 w:0) /// The range of component `v` is `[500, 1000]`. fn get_npos_targets(v: u32, ) -> Weight { - // Minimum execution time: 4_741_111 nanoseconds. - Weight::from_ref_time(113_360_179) - // Standard Error: 25_375 - .saturating_add(Weight::from_ref_time(9_494_142).saturating_mul(v.into())) + // Minimum execution time: 4_916_401 nanoseconds. + Weight::from_ref_time(81_160_966) + // Standard Error: 23_829 + .saturating_add(Weight::from_ref_time(9_883_413).saturating_mul(v.into())) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into()))) } @@ -864,8 +872,8 @@ impl WeightInfo for () { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_set() -> Weight { - // Minimum execution time: 11_074 nanoseconds. - Weight::from_ref_time(11_312_000) + // Minimum execution time: 10_937 nanoseconds. + Weight::from_ref_time(11_324_000) .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Staking MinCommission (r:0 w:1) @@ -875,8 +883,8 @@ impl WeightInfo for () { // Storage: Staking MaxNominatorsCount (r:0 w:1) // Storage: Staking MinNominatorBond (r:0 w:1) fn set_staking_configs_all_remove() -> Weight { - // Minimum execution time: 9_795 nanoseconds. - Weight::from_ref_time(10_116_000) + // Minimum execution time: 9_424 nanoseconds. + Weight::from_ref_time(10_021_000) .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Staking Ledger (r:1 w:0) @@ -890,21 +898,23 @@ impl WeightInfo for () { // Storage: VoterList ListBags (r:1 w:1) // Storage: VoterList CounterForListNodes (r:1 w:1) fn chill_other() -> Weight { - // Minimum execution time: 82_914 nanoseconds. - Weight::from_ref_time(83_848_000) + // Minimum execution time: 84_495 nanoseconds. + Weight::from_ref_time(85_559_000) .saturating_add(RocksDbWeight::get().reads(11)) .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Staking MinCommission (r:1 w:0) // Storage: Staking Validators (r:1 w:1) fn force_apply_min_commission() -> Weight { - // Minimum execution time: 20_317 nanoseconds. - Weight::from_ref_time(20_639_000) + // Minimum execution time: 20_385 nanoseconds. + Weight::from_ref_time(20_824_000) .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } - + // Storage: Staking MinCommission (r:0 w:1) fn set_min_commission() -> Weight { - Weight::zero() + // Minimum execution time: 6_995 nanoseconds. + Weight::from_ref_time(7_213_000) + .saturating_add(RocksDbWeight::get().writes(1)) } } From b02ce6a946dd6eade952788933e0c325bc297c22 Mon Sep 17 00:00:00 2001 From: Ankan Date: Sun, 25 Dec 2022 22:35:58 +0100 Subject: [PATCH 3/4] fmt --- frame/staking/src/mock.rs | 13 ++++++++----- frame/staking/src/tests.rs | 16 ++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/frame/staking/src/mock.rs b/frame/staking/src/mock.rs index 11a5ee8a8f87d..843e452125a6e 100644 --- a/frame/staking/src/mock.rs +++ b/frame/staking/src/mock.rs @@ -19,11 +19,14 @@ use crate::{self as pallet_staking, *}; use frame_election_provider_support::{onchain, SequentialPhragmen, VoteWeight}; -use frame_support::{assert_ok, ord_parameter_types, parameter_types, traits::{ - ConstU32, ConstU64, Currency, FindAuthor, GenesisBuild, Get, Hooks, Imbalance, - OnUnbalanced, OneSessionHandler, -}, weights::constants::RocksDbWeight}; -use frame_support::traits::EitherOfDiverse; +use frame_support::{ + assert_ok, ord_parameter_types, parameter_types, + traits::{ + ConstU32, ConstU64, Currency, EitherOfDiverse, FindAuthor, GenesisBuild, Get, Hooks, + Imbalance, OnUnbalanced, OneSessionHandler, + }, + weights::constants::RocksDbWeight, +}; use frame_system::{EnsureRoot, EnsureSignedBy}; use sp_core::H256; use sp_io; diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index 9c13c5721de4f..a4b9316663828 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5733,10 +5733,7 @@ fn set_min_commission_works_with_admin_origin() { assert_eq!(MinCommission::::get(), Perbill::from_percent(0)); // root can set min commission - assert_ok!(Staking::set_min_commission( - RuntimeOrigin::root(), - Perbill::from_percent(10), - )); + assert_ok!(Staking::set_min_commission(RuntimeOrigin::root(), Perbill::from_percent(10),)); assert_eq!(MinCommission::::get(), Perbill::from_percent(10)); @@ -5753,10 +5750,13 @@ fn set_min_commission_works_with_admin_origin() { )); // setting commission below min_commission fails - assert_noop!(Staking::validate( - RuntimeOrigin::signed(10), - ValidatorPrefs { commission: Perbill::from_percent(14), blocked: false } - ), Error::::CommissionTooLow); + assert_noop!( + Staking::validate( + RuntimeOrigin::signed(10), + ValidatorPrefs { commission: Perbill::from_percent(14), blocked: false } + ), + Error::::CommissionTooLow + ); // setting commission >= min_commission works assert_ok!(Staking::validate( From fd95c1ce6fce23af0a3da6decb5deed7560270d4 Mon Sep 17 00:00:00 2001 From: Ankan Date: Mon, 26 Dec 2022 11:55:25 +0100 Subject: [PATCH 4/4] fix for pr comments --- frame/staking/src/pallet/mod.rs | 2 -- frame/staking/src/tests.rs | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frame/staking/src/pallet/mod.rs b/frame/staking/src/pallet/mod.rs index e522cc7162697..8e8a8d9c7f600 100644 --- a/frame/staking/src/pallet/mod.rs +++ b/frame/staking/src/pallet/mod.rs @@ -1798,8 +1798,6 @@ pub mod pallet { /// /// This call has lower privilege requirements than `set_staking_config` and can be called /// by the `T::AdminOrigin`. Root can always call this. - /// - /// Weight: `O(1)` #[pallet::call_index(25)] #[pallet::weight(T::WeightInfo::set_min_commission())] pub fn set_min_commission(origin: OriginFor, new: Perbill) -> DispatchResult { diff --git a/frame/staking/src/tests.rs b/frame/staking/src/tests.rs index a4b9316663828..46c3c97441938 100644 --- a/frame/staking/src/tests.rs +++ b/frame/staking/src/tests.rs @@ -5730,10 +5730,10 @@ fn scale_validator_count_errors() { fn set_min_commission_works_with_admin_origin() { ExtBuilder::default().build_and_execute(|| { // no minimum commission set initially - assert_eq!(MinCommission::::get(), Perbill::from_percent(0)); + assert_eq!(MinCommission::::get(), Zero::zero()); // root can set min commission - assert_ok!(Staking::set_min_commission(RuntimeOrigin::root(), Perbill::from_percent(10),)); + assert_ok!(Staking::set_min_commission(RuntimeOrigin::root(), Perbill::from_percent(10))); assert_eq!(MinCommission::::get(), Perbill::from_percent(10));