Revise how staking configurations are set (#10955)

* Revise how staking configurations are set

fixes #10938

* Fix and add additional tests

* Format

* Formatting

* Add doc

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update frame/staking/src/tests.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Format

* Fix build

* Update weights.rs

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_staking --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/staking/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Parity Bot <admin@parity.io>
This commit is contained in:
Falco Hirschenberger
2022-03-03 10:17:24 +01:00
committed by GitHub
parent 0b3b3e4bfd
commit b199ccf386
4 changed files with 308 additions and 188 deletions
+33 -16
View File
@@ -18,7 +18,7 @@
//! Staking pallet benchmarking.
use super::*;
use crate::Pallet as Staking;
use crate::{ConfigOp, Pallet as Staking};
use testing_utils::*;
use codec::Decode;
@@ -852,16 +852,15 @@ benchmarks! {
assert_eq!(targets.len() as u32, v);
}
set_staking_configs {
// This function always does the same thing... just write to 4 storage items.
}: _(
set_staking_configs_all_set {
}: set_staking_configs(
RawOrigin::Root,
BalanceOf::<T>::max_value(),
BalanceOf::<T>::max_value(),
Some(u32::MAX),
Some(u32::MAX),
Some(Percent::max_value()),
Perbill::max_value()
ConfigOp::Set(BalanceOf::<T>::max_value()),
ConfigOp::Set(BalanceOf::<T>::max_value()),
ConfigOp::Set(u32::MAX),
ConfigOp::Set(u32::MAX),
ConfigOp::Set(Percent::max_value()),
ConfigOp::Set(Perbill::max_value())
) verify {
assert_eq!(MinNominatorBond::<T>::get(), BalanceOf::<T>::max_value());
assert_eq!(MinValidatorBond::<T>::get(), BalanceOf::<T>::max_value());
@@ -871,6 +870,24 @@ benchmarks! {
assert_eq!(MinCommission::<T>::get(), Perbill::from_percent(100));
}
set_staking_configs_all_remove {
}: set_staking_configs(
RawOrigin::Root,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove
) verify {
assert!(!MinNominatorBond::<T>::exists());
assert!(!MinValidatorBond::<T>::exists());
assert!(!MaxNominatorsCount::<T>::exists());
assert!(!MaxValidatorsCount::<T>::exists());
assert!(!ChillThreshold::<T>::exists());
assert!(!MinCommission::<T>::exists());
}
chill_other {
// clean up any existing state.
clear_validators_and_nominators::<T>();
@@ -886,12 +903,12 @@ benchmarks! {
Staking::<T>::set_staking_configs(
RawOrigin::Root.into(),
BalanceOf::<T>::max_value(),
BalanceOf::<T>::max_value(),
Some(0),
Some(0),
Some(Percent::from_percent(0)),
Zero::zero(),
ConfigOp::Set(BalanceOf::<T>::max_value()),
ConfigOp::Set(BalanceOf::<T>::max_value()),
ConfigOp::Set(0),
ConfigOp::Set(0),
ConfigOp::Set(Percent::from_percent(0)),
ConfigOp::Set(Zero::zero()),
)?;
let caller = whitelisted_caller();
+42 -14
View File
@@ -19,6 +19,7 @@
use frame_election_provider_support::SortedListProvider;
use frame_support::{
dispatch::Codec,
pallet_prelude::*,
traits::{
Currency, CurrencyToVote, DefensiveSaturating, EnsureOrigin, EstimateNextNewSession, Get,
@@ -32,7 +33,7 @@ use sp_runtime::{
DispatchError, Perbill, Percent,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_std::{convert::From, prelude::*};
use sp_std::{cmp::max, convert::From, prelude::*};
mod impls;
@@ -60,6 +61,17 @@ pub mod pallet {
#[pallet::without_storage_info]
pub struct Pallet<T>(_);
/// Possible operations on the configuration values of this pallet.
#[derive(TypeInfo, Debug, Clone, Encode, Decode, PartialEq)]
pub enum ConfigOp<T: Default + Codec> {
/// Don't change.
Noop,
/// Set the given value.
Set(T),
/// Remove from storage.
Remove,
}
#[pallet::config]
pub trait Config: frame_system::Config + SendTransactionTypes<Call<Self>> {
/// The staking balance.
@@ -1532,23 +1544,39 @@ pub mod pallet {
///
/// NOTE: Existing nominators and validators will not be affected by this update.
/// to kick people under the new limits, `chill_other` should be called.
#[pallet::weight(T::WeightInfo::set_staking_configs())]
// We assume the worst case for this call is either: all items are set or all items are
// removed.
#[pallet::weight(max(
T::WeightInfo::set_staking_configs_all_set(),
T::WeightInfo::set_staking_configs_all_remove()
))]
pub fn set_staking_configs(
origin: OriginFor<T>,
min_nominator_bond: BalanceOf<T>,
min_validator_bond: BalanceOf<T>,
max_nominator_count: Option<u32>,
max_validator_count: Option<u32>,
chill_threshold: Option<Percent>,
min_commission: Perbill,
min_nominator_bond: ConfigOp<BalanceOf<T>>,
min_validator_bond: ConfigOp<BalanceOf<T>>,
max_nominator_count: ConfigOp<u32>,
max_validator_count: ConfigOp<u32>,
chill_threshold: ConfigOp<Percent>,
min_commission: ConfigOp<Perbill>,
) -> DispatchResult {
ensure_root(origin)?;
MinNominatorBond::<T>::set(min_nominator_bond);
MinValidatorBond::<T>::set(min_validator_bond);
MaxNominatorsCount::<T>::set(max_nominator_count);
MaxValidatorsCount::<T>::set(max_validator_count);
ChillThreshold::<T>::set(chill_threshold);
MinCommission::<T>::set(min_commission);
macro_rules! config_op_exp {
($storage:ty, $op:ident) => {
match $op {
ConfigOp::Noop => (),
ConfigOp::Set(v) => <$storage>::put(v),
ConfigOp::Remove => <$storage>::kill(),
}
};
}
config_op_exp!(MinNominatorBond<T>, min_nominator_bond);
config_op_exp!(MinValidatorBond<T>, min_validator_bond);
config_op_exp!(MaxNominatorsCount<T>, max_nominator_count);
config_op_exp!(MaxValidatorsCount<T>, max_validator_count);
config_op_exp!(ChillThreshold<T>, chill_threshold);
config_op_exp!(MinCommission<T>, min_commission);
Ok(())
}
+94 -44
View File
@@ -17,10 +17,10 @@
//! Tests for the module.
use super::{Event, MaxUnlockingChunks, *};
use super::{ConfigOp, Event, MaxUnlockingChunks, *};
use frame_election_provider_support::{ElectionProvider, SortedListProvider, Support};
use frame_support::{
assert_noop, assert_ok, bounded_vec,
assert_noop, assert_ok, assert_storage_noop, bounded_vec,
dispatch::WithPostDispatchInfo,
pallet_prelude::*,
traits::{Currency, Get, ReservableCurrency},
@@ -40,6 +40,56 @@ use sp_staking::{
use sp_std::prelude::*;
use substrate_test_utils::assert_eq_uvec;
#[test]
fn set_staking_configs_works() {
ExtBuilder::default().build_and_execute(|| {
// setting works
assert_ok!(Staking::set_staking_configs(
Origin::root(),
ConfigOp::Set(1_500),
ConfigOp::Set(2_000),
ConfigOp::Set(10),
ConfigOp::Set(20),
ConfigOp::Set(Percent::from_percent(75)),
ConfigOp::Set(Zero::zero())
));
assert_eq!(MinNominatorBond::<Test>::get(), 1_500);
assert_eq!(MinValidatorBond::<Test>::get(), 2_000);
assert_eq!(MaxNominatorsCount::<Test>::get(), Some(10));
assert_eq!(MaxValidatorsCount::<Test>::get(), Some(20));
assert_eq!(ChillThreshold::<Test>::get(), Some(Percent::from_percent(75)));
assert_eq!(MinCommission::<Test>::get(), Perbill::from_percent(0));
// noop does nothing
assert_storage_noop!(assert_ok!(Staking::set_staking_configs(
Origin::root(),
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Noop
)));
// removing works
assert_ok!(Staking::set_staking_configs(
Origin::root(),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove
));
assert_eq!(MinNominatorBond::<Test>::get(), 0);
assert_eq!(MinValidatorBond::<Test>::get(), 0);
assert_eq!(MaxNominatorsCount::<Test>::get(), None);
assert_eq!(MaxValidatorsCount::<Test>::get(), None);
assert_eq!(ChillThreshold::<Test>::get(), None);
assert_eq!(MinCommission::<Test>::get(), Perbill::from_percent(0));
});
}
#[test]
fn force_unstake_works() {
ExtBuilder::default().build_and_execute(|| {
@@ -4368,12 +4418,12 @@ fn chill_other_works() {
// Change the minimum bond... but no limits.
assert_ok!(Staking::set_staking_configs(
Origin::root(),
1_500,
2_000,
None,
None,
None,
Zero::zero()
ConfigOp::Set(1_500),
ConfigOp::Set(2_000),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove
));
// Still can't chill these users
@@ -4389,12 +4439,12 @@ fn chill_other_works() {
// Add limits, but no threshold
assert_ok!(Staking::set_staking_configs(
Origin::root(),
1_500,
2_000,
Some(10),
Some(10),
None,
Zero::zero()
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Noop,
ConfigOp::Noop
));
// Still can't chill these users
@@ -4410,12 +4460,12 @@ fn chill_other_works() {
// Add threshold, but no limits
assert_ok!(Staking::set_staking_configs(
Origin::root(),
1_500,
2_000,
None,
None,
Some(Percent::from_percent(0)),
Zero::zero()
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Noop,
ConfigOp::Noop
));
// Still can't chill these users
@@ -4431,12 +4481,12 @@ fn chill_other_works() {
// Add threshold and limits
assert_ok!(Staking::set_staking_configs(
Origin::root(),
1_500,
2_000,
Some(10),
Some(10),
Some(Percent::from_percent(75)),
Zero::zero()
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Set(Percent::from_percent(75)),
ConfigOp::Noop
));
// 16 people total because tests start with 2 active one
@@ -4476,12 +4526,12 @@ fn capped_stakers_works() {
let max = 10;
assert_ok!(Staking::set_staking_configs(
Origin::root(),
10,
10,
Some(max),
Some(max),
Some(Percent::from_percent(0)),
Zero::zero(),
ConfigOp::Set(10),
ConfigOp::Set(10),
ConfigOp::Set(max),
ConfigOp::Set(max),
ConfigOp::Remove,
ConfigOp::Remove,
));
// can create `max - validator_count` validators
@@ -4546,12 +4596,12 @@ fn capped_stakers_works() {
// No problem when we set to `None` again
assert_ok!(Staking::set_staking_configs(
Origin::root(),
10,
10,
None,
None,
None,
Zero::zero(),
ConfigOp::Noop,
ConfigOp::Noop,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Noop,
ConfigOp::Noop,
));
assert_ok!(Staking::nominate(Origin::signed(last_nominator), vec![1]));
assert_ok!(Staking::validate(Origin::signed(last_validator), ValidatorPrefs::default()));
@@ -4568,12 +4618,12 @@ fn min_commission_works() {
assert_ok!(Staking::set_staking_configs(
Origin::root(),
0,
0,
None,
None,
None,
Perbill::from_percent(10),
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Remove,
ConfigOp::Set(Perbill::from_percent(10)),
));
// can't make it less than 10 now
+139 -114
View File
@@ -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-02-09, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2022-03-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
@@ -70,7 +70,8 @@ pub trait WeightInfo {
fn new_era(v: u32, n: u32, ) -> Weight;
fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight;
fn get_npos_targets(v: u32, ) -> Weight;
fn set_staking_configs() -> Weight;
fn set_staking_configs_all_set() -> Weight;
fn set_staking_configs_all_remove() -> Weight;
fn chill_other() -> Weight;
fn force_apply_min_commission() -> Weight;
}
@@ -85,7 +86,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Payee (r:0 w:1)
fn bond() -> Weight {
(37_772_000 as Weight)
(37_238_000 as Weight)
.saturating_add(T::DbWeight::get().reads(5 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
}
@@ -95,7 +96,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: BagsList ListNodes (r:3 w:3)
// Storage: BagsList ListBags (r:2 w:2)
fn bond_extra() -> Weight {
(64_816_000 as Weight)
(64_061_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(7 as Weight))
}
@@ -109,7 +110,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Bonded (r:1 w:0)
// Storage: BagsList ListBags (r:2 w:2)
fn unbond() -> Weight {
(71_635_000 as Weight)
(70_069_000 as Weight)
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
@@ -118,9 +119,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn withdraw_unbonded_update(s: u32, ) -> Weight {
(30_612_000 as Weight)
(29_855_000 as Weight)
// Standard Error: 0
.saturating_add((59_000 as Weight).saturating_mul(s as Weight))
.saturating_add((53_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
@@ -137,8 +138,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Payee (r:0 w:1)
fn withdraw_unbonded_kill(_s: u32, ) -> Weight {
(59_116_000 as Weight)
fn withdraw_unbonded_kill(s: u32, ) -> Weight {
(57_313_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(13 as Weight))
.saturating_add(T::DbWeight::get().writes(11 as Weight))
}
@@ -154,16 +157,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: BagsList CounterForListNodes (r:1 w:1)
// Storage: Staking CounterForValidators (r:1 w:1)
fn validate() -> Weight {
(45_505_000 as Weight)
(44_448_000 as Weight)
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: Staking Nominators (r:1 w:1)
fn kick(k: u32, ) -> Weight {
(12_764_000 as Weight)
// Standard Error: 15_000
.saturating_add((8_301_000 as Weight).saturating_mul(k as Weight))
(13_902_000 as Weight)
// Standard Error: 12_000
.saturating_add((7_421_000 as Weight).saturating_mul(k as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(k as Weight)))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(k as Weight)))
@@ -180,9 +183,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: BagsList CounterForListNodes (r:1 w:1)
// Storage: Staking CounterForNominators (r:1 w:1)
fn nominate(n: u32, ) -> Weight {
(51_439_000 as Weight)
// Standard Error: 10_000
.saturating_add((3_323_000 as Weight).saturating_mul(n as Weight))
(49_580_000 as Weight)
// Standard Error: 9_000
.saturating_add((3_362_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
@@ -195,49 +198,49 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: BagsList ListBags (r:1 w:1)
// Storage: BagsList CounterForListNodes (r:1 w:1)
fn chill() -> Weight {
(44_847_000 as Weight)
(44_180_000 as Weight)
.saturating_add(T::DbWeight::get().reads(8 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: Staking Payee (r:0 w:1)
fn set_payee() -> Weight {
(7_795_000 as Weight)
(7_922_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking Bonded (r:1 w:1)
// Storage: Staking Ledger (r:2 w:2)
fn set_controller() -> Weight {
(16_051_000 as Weight)
(15_436_000 as Weight)
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
// Storage: Staking ValidatorCount (r:0 w:1)
fn set_validator_count() -> Weight {
(1_107_000 as Weight)
(1_091_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_no_eras() -> Weight {
(1_126_000 as Weight)
(1_204_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_new_era() -> Weight {
(1_183_000 as Weight)
(1_208_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_new_era_always() -> Weight {
(1_181_000 as Weight)
(1_220_000 as Weight)
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking Invulnerables (r:0 w:1)
fn set_invulnerables(v: u32, ) -> Weight {
(1_705_000 as Weight)
(1_473_000 as Weight)
// Standard Error: 0
.saturating_add((50_000 as Weight).saturating_mul(v as Weight))
.saturating_add((9_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Staking Bonded (r:1 w:1)
@@ -254,18 +257,18 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Payee (r:0 w:1)
// Storage: Staking SpanSlash (r:0 w:2)
fn force_unstake(s: u32, ) -> Weight {
(57_431_000 as Weight)
(55_815_000 as Weight)
// Standard Error: 1_000
.saturating_add((801_000 as Weight).saturating_mul(s as Weight))
.saturating_add((808_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(11 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
}
// Storage: Staking UnappliedSlashes (r:1 w:1)
fn cancel_deferred_slash(s: u32, ) -> Weight {
(950_258_000 as Weight)
// Standard Error: 56_000
.saturating_add((5_001_000 as Weight).saturating_mul(s as Weight))
(903_077_000 as Weight)
// Standard Error: 53_000
.saturating_add((4_434_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -280,9 +283,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Payee (r:2 w:0)
// Storage: System Account (r:2 w:2)
fn payout_stakers_dead_controller(n: u32, ) -> Weight {
(94_238_000 as Weight)
// Standard Error: 15_000
.saturating_add((23_978_000 as Weight).saturating_mul(n as Weight))
(79_440_000 as Weight)
// Standard Error: 14_000
.saturating_add((24_005_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(10 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
@@ -300,9 +303,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: System Account (r:2 w:2)
// Storage: Balances Locks (r:2 w:2)
fn payout_stakers_alive_staked(n: u32, ) -> Weight {
(109_323_000 as Weight)
// Standard Error: 22_000
.saturating_add((33_887_000 as Weight).saturating_mul(n as Weight))
(99_118_000 as Weight)
// Standard Error: 20_000
.saturating_add((33_274_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(11 as Weight))
.saturating_add(T::DbWeight::get().reads((5 as Weight).saturating_mul(n as Weight)))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
@@ -315,9 +318,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Bonded (r:1 w:0)
// Storage: BagsList ListBags (r:2 w:2)
fn rebond(l: u32, ) -> Weight {
(64_807_000 as Weight)
(63_335_000 as Weight)
// Standard Error: 2_000
.saturating_add((50_000 as Weight).saturating_mul(l as Weight))
.saturating_add((53_000 as Weight).saturating_mul(l as Weight))
.saturating_add(T::DbWeight::get().reads(9 as Weight))
.saturating_add(T::DbWeight::get().writes(8 as Weight))
}
@@ -332,8 +335,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking ErasStartSessionIndex (r:0 w:1)
fn set_history_depth(e: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 61_000
.saturating_add((20_457_000 as Weight).saturating_mul(e as Weight))
// Standard Error: 58_000
.saturating_add((20_386_000 as Weight).saturating_mul(e as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight))
.saturating_add(T::DbWeight::get().writes((7 as Weight).saturating_mul(e as Weight)))
@@ -352,9 +355,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Payee (r:0 w:1)
// Storage: Staking SpanSlash (r:0 w:1)
fn reap_stash(s: u32, ) -> Weight {
(62_856_000 as Weight)
(61_486_000 as Weight)
// Standard Error: 0
.saturating_add((802_000 as Weight).saturating_mul(s as Weight))
.saturating_add((809_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(12 as Weight))
.saturating_add(T::DbWeight::get().writes(12 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
@@ -379,10 +382,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking ErasStartSessionIndex (r:0 w:1)
fn new_era(v: u32, n: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 804_000
.saturating_add((226_855_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 40_000
.saturating_add((31_928_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 878_000
.saturating_add((212_233_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 44_000
.saturating_add((30_364_000 as Weight).saturating_mul(n as Weight))
.saturating_add(T::DbWeight::get().reads(208 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight)))
@@ -400,12 +403,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Nominators (r:1000 w:0)
fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 87_000
.saturating_add((18_771_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 87_000
.saturating_add((21_895_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 2_984_000
.saturating_add((8_282_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 95_000
.saturating_add((18_439_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 95_000
.saturating_add((20_382_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 3_232_000
.saturating_add((4_870_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(204 as Weight))
.saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(T::DbWeight::get().reads((4 as Weight).saturating_mul(n as Weight)))
@@ -414,8 +417,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking Validators (r:501 w:0)
fn get_npos_targets(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 28_000
.saturating_add((7_801_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 29_000
.saturating_add((7_552_000 as Weight).saturating_mul(v as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
}
@@ -425,8 +428,18 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Staking ChillThreshold (r:0 w:1)
// Storage: Staking MaxNominatorsCount (r:0 w:1)
// Storage: Staking MinNominatorBond (r:0 w:1)
fn set_staking_configs() -> Weight {
(3_680_000 as Weight)
fn set_staking_configs_all_set() -> Weight {
(3_597_000 as Weight)
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Staking MinCommission (r:0 w:1)
// Storage: Staking MinValidatorBond (r:0 w:1)
// Storage: Staking MaxValidatorsCount (r:0 w:1)
// Storage: Staking ChillThreshold (r:0 w:1)
// Storage: Staking MaxNominatorsCount (r:0 w:1)
// Storage: Staking MinNominatorBond (r:0 w:1)
fn set_staking_configs_all_remove() -> Weight {
(3_198_000 as Weight)
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
@@ -440,14 +453,14 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: BagsList ListBags (r:1 w:1)
// Storage: BagsList CounterForListNodes (r:1 w:1)
fn chill_other() -> Weight {
(55_459_000 as Weight)
(55_725_000 as Weight)
.saturating_add(T::DbWeight::get().reads(11 as Weight))
.saturating_add(T::DbWeight::get().writes(6 as Weight))
}
// Storage: Staking MinCommission (r:1 w:0)
// Storage: Staking Validators (r:1 w:1)
fn force_apply_min_commission() -> Weight {
(8_939_000 as Weight)
(8_946_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
@@ -462,7 +475,7 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Payee (r:0 w:1)
fn bond() -> Weight {
(37_772_000 as Weight)
(37_238_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(5 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
}
@@ -472,7 +485,7 @@ impl WeightInfo for () {
// Storage: BagsList ListNodes (r:3 w:3)
// Storage: BagsList ListBags (r:2 w:2)
fn bond_extra() -> Weight {
(64_816_000 as Weight)
(64_061_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
.saturating_add(RocksDbWeight::get().writes(7 as Weight))
}
@@ -486,7 +499,7 @@ impl WeightInfo for () {
// Storage: Staking Bonded (r:1 w:0)
// Storage: BagsList ListBags (r:2 w:2)
fn unbond() -> Weight {
(71_635_000 as Weight)
(70_069_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
@@ -495,9 +508,9 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn withdraw_unbonded_update(s: u32, ) -> Weight {
(30_612_000 as Weight)
(29_855_000 as Weight)
// Standard Error: 0
.saturating_add((59_000 as Weight).saturating_mul(s as Weight))
.saturating_add((53_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
@@ -514,8 +527,10 @@ impl WeightInfo for () {
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Payee (r:0 w:1)
fn withdraw_unbonded_kill(_s: u32, ) -> Weight {
(59_116_000 as Weight)
fn withdraw_unbonded_kill(s: u32, ) -> Weight {
(57_313_000 as Weight)
// Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(13 as Weight))
.saturating_add(RocksDbWeight::get().writes(11 as Weight))
}
@@ -531,16 +546,16 @@ impl WeightInfo for () {
// Storage: BagsList CounterForListNodes (r:1 w:1)
// Storage: Staking CounterForValidators (r:1 w:1)
fn validate() -> Weight {
(45_505_000 as Weight)
(44_448_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: Staking Nominators (r:1 w:1)
fn kick(k: u32, ) -> Weight {
(12_764_000 as Weight)
// Standard Error: 15_000
.saturating_add((8_301_000 as Weight).saturating_mul(k as Weight))
(13_902_000 as Weight)
// Standard Error: 12_000
.saturating_add((7_421_000 as Weight).saturating_mul(k as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(k as Weight)))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(k as Weight)))
@@ -557,9 +572,9 @@ impl WeightInfo for () {
// Storage: BagsList CounterForListNodes (r:1 w:1)
// Storage: Staking CounterForNominators (r:1 w:1)
fn nominate(n: u32, ) -> Weight {
(51_439_000 as Weight)
// Standard Error: 10_000
.saturating_add((3_323_000 as Weight).saturating_mul(n as Weight))
(49_580_000 as Weight)
// Standard Error: 9_000
.saturating_add((3_362_000 as Weight).saturating_mul(n as Weight))
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
@@ -572,49 +587,49 @@ impl WeightInfo for () {
// Storage: BagsList ListBags (r:1 w:1)
// Storage: BagsList CounterForListNodes (r:1 w:1)
fn chill() -> Weight {
(44_847_000 as Weight)
(44_180_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(8 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: Staking Payee (r:0 w:1)
fn set_payee() -> Weight {
(7_795_000 as Weight)
(7_922_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking Bonded (r:1 w:1)
// Storage: Staking Ledger (r:2 w:2)
fn set_controller() -> Weight {
(16_051_000 as Weight)
(15_436_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
}
// Storage: Staking ValidatorCount (r:0 w:1)
fn set_validator_count() -> Weight {
(1_107_000 as Weight)
(1_091_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_no_eras() -> Weight {
(1_126_000 as Weight)
(1_204_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_new_era() -> Weight {
(1_183_000 as Weight)
(1_208_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking ForceEra (r:0 w:1)
fn force_new_era_always() -> Weight {
(1_181_000 as Weight)
(1_220_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking Invulnerables (r:0 w:1)
fn set_invulnerables(v: u32, ) -> Weight {
(1_705_000 as Weight)
(1_473_000 as Weight)
// Standard Error: 0
.saturating_add((50_000 as Weight).saturating_mul(v as Weight))
.saturating_add((9_000 as Weight).saturating_mul(v as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
// Storage: Staking Bonded (r:1 w:1)
@@ -631,18 +646,18 @@ impl WeightInfo for () {
// Storage: Staking Payee (r:0 w:1)
// Storage: Staking SpanSlash (r:0 w:2)
fn force_unstake(s: u32, ) -> Weight {
(57_431_000 as Weight)
(55_815_000 as Weight)
// Standard Error: 1_000
.saturating_add((801_000 as Weight).saturating_mul(s as Weight))
.saturating_add((808_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(11 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
}
// Storage: Staking UnappliedSlashes (r:1 w:1)
fn cancel_deferred_slash(s: u32, ) -> Weight {
(950_258_000 as Weight)
// Standard Error: 56_000
.saturating_add((5_001_000 as Weight).saturating_mul(s as Weight))
(903_077_000 as Weight)
// Standard Error: 53_000
.saturating_add((4_434_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}
@@ -657,9 +672,9 @@ impl WeightInfo for () {
// Storage: Staking Payee (r:2 w:0)
// Storage: System Account (r:2 w:2)
fn payout_stakers_dead_controller(n: u32, ) -> Weight {
(94_238_000 as Weight)
// Standard Error: 15_000
.saturating_add((23_978_000 as Weight).saturating_mul(n as Weight))
(79_440_000 as Weight)
// Standard Error: 14_000
.saturating_add((24_005_000 as Weight).saturating_mul(n as Weight))
.saturating_add(RocksDbWeight::get().reads(10 as Weight))
.saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(n as Weight)))
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
@@ -677,9 +692,9 @@ impl WeightInfo for () {
// Storage: System Account (r:2 w:2)
// Storage: Balances Locks (r:2 w:2)
fn payout_stakers_alive_staked(n: u32, ) -> Weight {
(109_323_000 as Weight)
// Standard Error: 22_000
.saturating_add((33_887_000 as Weight).saturating_mul(n as Weight))
(99_118_000 as Weight)
// Standard Error: 20_000
.saturating_add((33_274_000 as Weight).saturating_mul(n as Weight))
.saturating_add(RocksDbWeight::get().reads(11 as Weight))
.saturating_add(RocksDbWeight::get().reads((5 as Weight).saturating_mul(n as Weight)))
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
@@ -692,9 +707,9 @@ impl WeightInfo for () {
// Storage: Staking Bonded (r:1 w:0)
// Storage: BagsList ListBags (r:2 w:2)
fn rebond(l: u32, ) -> Weight {
(64_807_000 as Weight)
(63_335_000 as Weight)
// Standard Error: 2_000
.saturating_add((50_000 as Weight).saturating_mul(l as Weight))
.saturating_add((53_000 as Weight).saturating_mul(l as Weight))
.saturating_add(RocksDbWeight::get().reads(9 as Weight))
.saturating_add(RocksDbWeight::get().writes(8 as Weight))
}
@@ -709,8 +724,8 @@ impl WeightInfo for () {
// Storage: Staking ErasStartSessionIndex (r:0 w:1)
fn set_history_depth(e: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 61_000
.saturating_add((20_457_000 as Weight).saturating_mul(e as Weight))
// Standard Error: 58_000
.saturating_add((20_386_000 as Weight).saturating_mul(e as Weight))
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
.saturating_add(RocksDbWeight::get().writes((7 as Weight).saturating_mul(e as Weight)))
@@ -729,9 +744,9 @@ impl WeightInfo for () {
// Storage: Staking Payee (r:0 w:1)
// Storage: Staking SpanSlash (r:0 w:1)
fn reap_stash(s: u32, ) -> Weight {
(62_856_000 as Weight)
(61_486_000 as Weight)
// Standard Error: 0
.saturating_add((802_000 as Weight).saturating_mul(s as Weight))
.saturating_add((809_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(12 as Weight))
.saturating_add(RocksDbWeight::get().writes(12 as Weight))
.saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(s as Weight)))
@@ -756,10 +771,10 @@ impl WeightInfo for () {
// Storage: Staking ErasStartSessionIndex (r:0 w:1)
fn new_era(v: u32, n: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 804_000
.saturating_add((226_855_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 40_000
.saturating_add((31_928_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 878_000
.saturating_add((212_233_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 44_000
.saturating_add((30_364_000 as Weight).saturating_mul(n as Weight))
.saturating_add(RocksDbWeight::get().reads(208 as Weight))
.saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(n as Weight)))
@@ -777,12 +792,12 @@ impl WeightInfo for () {
// Storage: Staking Nominators (r:1000 w:0)
fn get_npos_voters(v: u32, n: u32, s: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 87_000
.saturating_add((18_771_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 87_000
.saturating_add((21_895_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 2_984_000
.saturating_add((8_282_000 as Weight).saturating_mul(s as Weight))
// Standard Error: 95_000
.saturating_add((18_439_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 95_000
.saturating_add((20_382_000 as Weight).saturating_mul(n as Weight))
// Standard Error: 3_232_000
.saturating_add((4_870_000 as Weight).saturating_mul(s as Weight))
.saturating_add(RocksDbWeight::get().reads(204 as Weight))
.saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(v as Weight)))
.saturating_add(RocksDbWeight::get().reads((4 as Weight).saturating_mul(n as Weight)))
@@ -791,8 +806,8 @@ impl WeightInfo for () {
// Storage: Staking Validators (r:501 w:0)
fn get_npos_targets(v: u32, ) -> Weight {
(0 as Weight)
// Standard Error: 28_000
.saturating_add((7_801_000 as Weight).saturating_mul(v as Weight))
// Standard Error: 29_000
.saturating_add((7_552_000 as Weight).saturating_mul(v as Weight))
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(v as Weight)))
}
@@ -802,8 +817,18 @@ impl WeightInfo for () {
// Storage: Staking ChillThreshold (r:0 w:1)
// Storage: Staking MaxNominatorsCount (r:0 w:1)
// Storage: Staking MinNominatorBond (r:0 w:1)
fn set_staking_configs() -> Weight {
(3_680_000 as Weight)
fn set_staking_configs_all_set() -> Weight {
(3_597_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
// Storage: Staking MinCommission (r:0 w:1)
// Storage: Staking MinValidatorBond (r:0 w:1)
// Storage: Staking MaxValidatorsCount (r:0 w:1)
// Storage: Staking ChillThreshold (r:0 w:1)
// Storage: Staking MaxNominatorsCount (r:0 w:1)
// Storage: Staking MinNominatorBond (r:0 w:1)
fn set_staking_configs_all_remove() -> Weight {
(3_198_000 as Weight)
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
// Storage: Staking Ledger (r:1 w:0)
@@ -817,14 +842,14 @@ impl WeightInfo for () {
// Storage: BagsList ListBags (r:1 w:1)
// Storage: BagsList CounterForListNodes (r:1 w:1)
fn chill_other() -> Weight {
(55_459_000 as Weight)
(55_725_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(11 as Weight))
.saturating_add(RocksDbWeight::get().writes(6 as Weight))
}
// Storage: Staking MinCommission (r:1 w:0)
// Storage: Staking Validators (r:1 w:1)
fn force_apply_min_commission() -> Weight {
(8_939_000 as Weight)
(8_946_000 as Weight)
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
}