reduce exec time of fast-unstake benchmarks (#13120)

* reduce exec time of fast-unstake benchmarks

* fix test

* fmt

* fix patch the tests

* fix patch the tests

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* add batch size as well

* update some benches to be better

* fix one last test

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* reduce time even more

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* fix tests

* nit

* remove

* improve the weight calc further

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* fix benchmarks

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* update

* fix

* fix

* fmt

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* lots of changes again...

* smaller input

* update

* fmt

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* cleanup

* small simplification

* fmt

* reduce exec time a bit

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* test

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* increase again

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

* review comments

* fmt

* fix

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_fast_unstake

Co-authored-by: command-bot <>
This commit is contained in:
Kian Paimani
2023-01-25 20:59:19 -03:00
committed by GitHub
parent 73a9776266
commit 451a13c642
6 changed files with 237 additions and 263 deletions
+4 -1
View File
@@ -591,10 +591,13 @@ impl pallet_staking::Config for Runtime {
impl pallet_fast_unstake::Config for Runtime { impl pallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent; type RuntimeEvent = RuntimeEvent;
type ControlOrigin = frame_system::EnsureRoot<AccountId>; type ControlOrigin = frame_system::EnsureRoot<AccountId>;
type BatchSize = ConstU32<128>; type BatchSize = ConstU32<64>;
type Deposit = ConstU128<{ DOLLARS }>; type Deposit = ConstU128<{ DOLLARS }>;
type Currency = Balances; type Currency = Balances;
type Staking = Staking; type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = (); type WeightInfo = ();
} }
@@ -31,13 +31,11 @@ use sp_staking::{EraIndex, StakingInterface};
use sp_std::prelude::*; use sp_std::prelude::*;
const USER_SEED: u32 = 0; const USER_SEED: u32 = 0;
const DEFAULT_BACKER_PER_VALIDATOR: u32 = 128;
const MAX_VALIDATORS: u32 = 128;
type CurrencyOf<T> = <T as Config>::Currency; type CurrencyOf<T> = <T as Config>::Currency;
fn create_unexposed_nominators<T: Config>() -> Vec<T::AccountId> { fn create_unexposed_batch<T: Config>(batch_size: u32) -> Vec<T::AccountId> {
(0..T::BatchSize::get()) (0..batch_size)
.map(|i| { .map(|i| {
let account = let account =
frame_benchmarking::account::<T::AccountId>("unexposed_nominator", i, USER_SEED); frame_benchmarking::account::<T::AccountId>("unexposed_nominator", i, USER_SEED);
@@ -76,7 +74,7 @@ fn setup_staking<T: Config>(v: u32, until: EraIndex) {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for era in 0..=until { for era in 0..=until {
let others = (0..DEFAULT_BACKER_PER_VALIDATOR) let others = (0..T::MaxBackersPerValidator::get())
.map(|s| { .map(|s| {
let who = frame_benchmarking::account::<T::AccountId>("nominator", era, s); let who = frame_benchmarking::account::<T::AccountId>("nominator", era, s);
let value = ed; let value = ed;
@@ -97,8 +95,10 @@ fn on_idle_full_block<T: Config>() {
benchmarks! { benchmarks! {
// on_idle, we don't check anyone, but fully unbond them. // on_idle, we don't check anyone, but fully unbond them.
on_idle_unstake { on_idle_unstake {
let b in 1 .. T::BatchSize::get();
ErasToCheckPerBlock::<T>::put(1); ErasToCheckPerBlock::<T>::put(1);
for who in create_unexposed_nominators::<T>() { for who in create_unexposed_batch::<T>(b).into_iter() {
assert_ok!(FastUnstake::<T>::register_fast_unstake( assert_ok!(FastUnstake::<T>::register_fast_unstake(
RawOrigin::Signed(who.clone()).into(), RawOrigin::Signed(who.clone()).into(),
)); ));
@@ -114,7 +114,7 @@ benchmarks! {
checked, checked,
stashes, stashes,
.. ..
}) if checked.len() == 1 && stashes.len() as u32 == T::BatchSize::get() }) if checked.len() == 1 && stashes.len() as u32 == b
)); ));
} }
: { : {
@@ -123,25 +123,23 @@ benchmarks! {
verify { verify {
assert!(matches!( assert!(matches!(
fast_unstake_events::<T>().last(), fast_unstake_events::<T>().last(),
Some(Event::BatchFinished) Some(Event::BatchFinished { size: b })
)); ));
} }
// on_idle, when we check some number of eras, // on_idle, when we check some number of eras and the queue is already set.
on_idle_check { on_idle_check {
// number of eras multiplied by validators in that era. let v in 1 .. 256;
let x in (T::Staking::bonding_duration() * 1) .. (T::Staking::bonding_duration() * MAX_VALIDATORS); let b in 1 .. T::BatchSize::get();
let u = T::MaxErasToCheckPerBlock::get().min(T::Staking::bonding_duration());
let u = T::Staking::bonding_duration();
let v = x / u;
ErasToCheckPerBlock::<T>::put(u); ErasToCheckPerBlock::<T>::put(u);
T::Staking::set_current_era(u); T::Staking::set_current_era(u);
// setup staking with v validators and u eras of data (0..=u) // setup staking with v validators and u eras of data (0..=u+1)
setup_staking::<T>(v, u); setup_staking::<T>(v, u);
let stashes = create_unexposed_nominators::<T>().into_iter().map(|s| { let stashes = create_unexposed_batch::<T>(b).into_iter().map(|s| {
assert_ok!(FastUnstake::<T>::register_fast_unstake( assert_ok!(FastUnstake::<T>::register_fast_unstake(
RawOrigin::Signed(s.clone()).into(), RawOrigin::Signed(s.clone()).into(),
)); ));
@@ -150,6 +148,8 @@ benchmarks! {
// no one is queued thus far. // no one is queued thus far.
assert_eq!(Head::<T>::get(), None); assert_eq!(Head::<T>::get(), None);
Head::<T>::put(UnstakeRequest { stashes: stashes.clone().try_into().unwrap(), checked: Default::default() });
} }
: { : {
on_idle_full_block::<T>(); on_idle_full_block::<T>();
@@ -167,7 +167,7 @@ benchmarks! {
register_fast_unstake { register_fast_unstake {
ErasToCheckPerBlock::<T>::put(1); ErasToCheckPerBlock::<T>::put(1);
let who = create_unexposed_nominators::<T>().get(0).cloned().unwrap(); let who = create_unexposed_batch::<T>(1).get(0).cloned().unwrap();
whitelist_account!(who); whitelist_account!(who);
assert_eq!(Queue::<T>::count(), 0); assert_eq!(Queue::<T>::count(), 0);
@@ -179,7 +179,7 @@ benchmarks! {
deregister { deregister {
ErasToCheckPerBlock::<T>::put(1); ErasToCheckPerBlock::<T>::put(1);
let who = create_unexposed_nominators::<T>().get(0).cloned().unwrap(); let who = create_unexposed_batch::<T>(1).get(0).cloned().unwrap();
assert_ok!(FastUnstake::<T>::register_fast_unstake( assert_ok!(FastUnstake::<T>::register_fast_unstake(
RawOrigin::Signed(who.clone()).into(), RawOrigin::Signed(who.clone()).into(),
)); ));
@@ -194,7 +194,7 @@ benchmarks! {
control { control {
let origin = <T as Config>::ControlOrigin::successful_origin(); let origin = <T as Config>::ControlOrigin::successful_origin();
} }
: _<T::RuntimeOrigin>(origin, 128) : _<T::RuntimeOrigin>(origin, T::MaxErasToCheckPerBlock::get())
verify {} verify {}
impl_benchmark_test_suite!(Pallet, crate::mock::ExtBuilder::default().build(), crate::mock::Runtime) impl_benchmark_test_suite!(Pallet, crate::mock::ExtBuilder::default().build(), crate::mock::Runtime)
+83 -43
View File
@@ -86,12 +86,9 @@ pub mod pallet {
traits::{Defensive, ReservableCurrency, StorageVersion}, traits::{Defensive, ReservableCurrency, StorageVersion},
}; };
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
use sp_runtime::{ use sp_runtime::{traits::Zero, DispatchResult};
traits::{Saturating, Zero},
DispatchResult,
};
use sp_staking::{EraIndex, StakingInterface}; use sp_staking::{EraIndex, StakingInterface};
use sp_std::{collections::btree_set::BTreeSet, prelude::*, vec::Vec}; use sp_std::{prelude::*, vec::Vec};
pub use weights::WeightInfo; pub use weights::WeightInfo;
#[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)] #[derive(scale_info::TypeInfo, codec::Encode, codec::Decode, codec::MaxEncodedLen)]
@@ -138,6 +135,14 @@ pub mod pallet {
/// The weight information of this pallet. /// The weight information of this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
/// Maximum value for `ErasToCheckPerBlock`. This should be as close as possible, but more
/// than the actual value, in order to have accurate benchmarks.
type MaxErasToCheckPerBlock: Get<u32>;
/// Use only for benchmarking.
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator: Get<u32>;
} }
/// The current "head of the queue" being unstaked. /// The current "head of the queue" being unstaked.
@@ -173,11 +178,11 @@ pub mod pallet {
InternalError, InternalError,
/// A batch was partially checked for the given eras, but the process did not finish. /// A batch was partially checked for the given eras, but the process did not finish.
BatchChecked { eras: Vec<EraIndex> }, BatchChecked { eras: Vec<EraIndex> },
/// A batch was terminated. /// A batch of a given size was terminated.
/// ///
/// This is always follows by a number of `Unstaked` or `Slashed` events, marking the end /// This is always follows by a number of `Unstaked` or `Slashed` events, marking the end
/// of the batch. A new batch will be created upon next block. /// of the batch. A new batch will be created upon next block.
BatchFinished, BatchFinished { size: u32 },
} }
#[pallet::error] #[pallet::error]
@@ -208,6 +213,31 @@ pub mod pallet {
Self::do_on_idle(remaining_weight) Self::do_on_idle(remaining_weight)
} }
fn integrity_test() {
sp_std::if_std! {
sp_io::TestExternalities::new_empty().execute_with(|| {
// ensure that the value of `ErasToCheckPerBlock` is less than
// `T::MaxErasToCheckPerBlock`.
assert!(
ErasToCheckPerBlock::<T>::get() <= T::MaxErasToCheckPerBlock::get(),
"the value of `ErasToCheckPerBlock` is greater than `T::MaxErasToCheckPerBlock`",
);
});
}
}
#[cfg(feature = "try-runtime")]
fn try_state(_n: T::BlockNumber) -> Result<(), &'static str> {
// ensure that the value of `ErasToCheckPerBlock` is less than
// `T::MaxErasToCheckPerBlock`.
assert!(
ErasToCheckPerBlock::<T>::get() <= T::MaxErasToCheckPerBlock::get(),
"the value of `ErasToCheckPerBlock` is greater than `T::MaxErasToCheckPerBlock`",
);
Ok(())
}
} }
#[pallet::call] #[pallet::call]
@@ -288,9 +318,10 @@ pub mod pallet {
/// Dispatch origin must be signed by the [`Config::ControlOrigin`]. /// Dispatch origin must be signed by the [`Config::ControlOrigin`].
#[pallet::call_index(2)] #[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::control())] #[pallet::weight(<T as Config>::WeightInfo::control())]
pub fn control(origin: OriginFor<T>, unchecked_eras_to_check: EraIndex) -> DispatchResult { pub fn control(origin: OriginFor<T>, eras_to_check: EraIndex) -> DispatchResult {
let _ = T::ControlOrigin::ensure_origin(origin)?; let _ = T::ControlOrigin::ensure_origin(origin)?;
ErasToCheckPerBlock::<T>::put(unchecked_eras_to_check); ensure!(eras_to_check <= T::MaxErasToCheckPerBlock::get(), Error::<T>::CallNotAllowed);
ErasToCheckPerBlock::<T>::put(eras_to_check);
Ok(()) Ok(())
} }
} }
@@ -324,27 +355,38 @@ pub mod pallet {
/// found out to have no eras to check. At the end of a check cycle, even if they are fully /// found out to have no eras to check. At the end of a check cycle, even if they are fully
/// checked, we don't finish the process. /// checked, we don't finish the process.
pub(crate) fn do_on_idle(remaining_weight: Weight) -> Weight { pub(crate) fn do_on_idle(remaining_weight: Weight) -> Weight {
let mut eras_to_check_per_block = ErasToCheckPerBlock::<T>::get(); // any weight that is unaccounted for
let mut unaccounted_weight = Weight::from_ref_time(0);
let eras_to_check_per_block = ErasToCheckPerBlock::<T>::get();
if eras_to_check_per_block.is_zero() { if eras_to_check_per_block.is_zero() {
return T::DbWeight::get().reads(1) return T::DbWeight::get().reads(1).saturating_add(unaccounted_weight)
} }
// NOTE: here we're assuming that the number of validators has only ever increased, // NOTE: here we're assuming that the number of validators has only ever increased,
// meaning that the number of exposures to check is either this per era, or less. // meaning that the number of exposures to check is either this per era, or less.
let validator_count = T::Staking::desired_validator_count(); let validator_count = T::Staking::desired_validator_count();
let (next_batch_size, reads_from_queue) = Head::<T>::get()
.map_or((Queue::<T>::count().min(T::BatchSize::get()), true), |head| {
(head.stashes.len() as u32, false)
});
// determine the number of eras to check. This is based on both `ErasToCheckPerBlock` // determine the number of eras to check. This is based on both `ErasToCheckPerBlock`
// and `remaining_weight` passed on to us from the runtime executive. // and `remaining_weight` passed on to us from the runtime executive.
let max_weight = |v, u| { let max_weight = |v, b| {
<T as Config>::WeightInfo::on_idle_check(v * u) // NOTE: this potentially under-counts by up to `BatchSize` reads from the queue.
.max(<T as Config>::WeightInfo::on_idle_unstake()) <T as Config>::WeightInfo::on_idle_check(v, b)
.max(<T as Config>::WeightInfo::on_idle_unstake(b))
.saturating_add(if reads_from_queue {
T::DbWeight::get().reads(next_batch_size.into())
} else {
Zero::zero()
})
}; };
while max_weight(validator_count, eras_to_check_per_block).any_gt(remaining_weight) {
eras_to_check_per_block.saturating_dec(); if max_weight(validator_count, next_batch_size).any_gt(remaining_weight) {
if eras_to_check_per_block.is_zero() { log!(debug, "early exit because eras_to_check_per_block is zero");
log!(debug, "early existing because eras_to_check_per_block is zero"); return T::DbWeight::get().reads(3).saturating_add(unaccounted_weight)
return T::DbWeight::get().reads(2)
}
} }
if T::Staking::election_ongoing() { if T::Staking::election_ongoing() {
@@ -352,7 +394,7 @@ pub mod pallet {
// there is an ongoing election -- we better not do anything. Imagine someone is not // there is an ongoing election -- we better not do anything. Imagine someone is not
// exposed anywhere in the last era, and the snapshot for the election is already // exposed anywhere in the last era, and the snapshot for the election is already
// taken. In this time period, we don't want to accidentally unstake them. // taken. In this time period, we don't want to accidentally unstake them.
return T::DbWeight::get().reads(2) return T::DbWeight::get().reads(4).saturating_add(unaccounted_weight)
} }
let UnstakeRequest { stashes, mut checked } = match Head::<T>::take().or_else(|| { let UnstakeRequest { stashes, mut checked } = match Head::<T>::take().or_else(|| {
@@ -362,6 +404,9 @@ pub mod pallet {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.try_into() .try_into()
.expect("take ensures bound is met; qed"); .expect("take ensures bound is met; qed");
unaccounted_weight.saturating_accrue(
T::DbWeight::get().reads_writes(stashes.len() as u64, stashes.len() as u64),
);
if stashes.is_empty() { if stashes.is_empty() {
None None
} else { } else {
@@ -377,10 +422,11 @@ pub mod pallet {
log!( log!(
debug, debug,
"checking {:?} stashes, eras_to_check_per_block = {:?}, remaining_weight = {:?}", "checking {:?} stashes, eras_to_check_per_block = {:?}, checked {:?}, remaining_weight = {:?}",
stashes.len(), stashes.len(),
eras_to_check_per_block, eras_to_check_per_block,
remaining_weight checked,
remaining_weight,
); );
// the range that we're allowed to check in this round. // the range that we're allowed to check in this round.
@@ -431,11 +477,10 @@ pub mod pallet {
} }
}; };
let check_stash = |stash, deposit, eras_checked: &mut BTreeSet<EraIndex>| { let check_stash = |stash, deposit| {
let is_exposed = unchecked_eras_to_check.iter().any(|e| { let is_exposed = unchecked_eras_to_check
eras_checked.insert(*e); .iter()
T::Staking::is_exposed_in_era(&stash, e) .any(|e| T::Staking::is_exposed_in_era(&stash, e));
});
if is_exposed { if is_exposed {
T::Currency::slash_reserved(&stash, deposit); T::Currency::slash_reserved(&stash, deposit);
@@ -448,20 +493,16 @@ pub mod pallet {
}; };
if unchecked_eras_to_check.is_empty() { if unchecked_eras_to_check.is_empty() {
// `stash` is not exposed in any era now -- we can let go of them now. // `stashes` are not exposed in any era now -- we can let go of them now.
let size = stashes.len() as u32;
stashes.into_iter().for_each(|(stash, deposit)| unstake_stash(stash, deposit)); stashes.into_iter().for_each(|(stash, deposit)| unstake_stash(stash, deposit));
Self::deposit_event(Event::<T>::BatchFinished); Self::deposit_event(Event::<T>::BatchFinished { size });
<T as Config>::WeightInfo::on_idle_unstake() <T as Config>::WeightInfo::on_idle_unstake(size).saturating_add(unaccounted_weight)
} else { } else {
// eras checked so far.
let mut eras_checked = BTreeSet::<EraIndex>::new();
let pre_length = stashes.len(); let pre_length = stashes.len();
let stashes: BoundedVec<(T::AccountId, BalanceOf<T>), T::BatchSize> = stashes let stashes: BoundedVec<(T::AccountId, BalanceOf<T>), T::BatchSize> = stashes
.into_iter() .into_iter()
.filter(|(stash, deposit)| { .filter(|(stash, deposit)| check_stash(stash.clone(), *deposit))
check_stash(stash.clone(), *deposit, &mut eras_checked)
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
.try_into() .try_into()
.expect("filter can only lessen the length; still in bound; qed"); .expect("filter can only lessen the length; still in bound; qed");
@@ -469,8 +510,8 @@ pub mod pallet {
log!( log!(
debug, debug,
"checked {:?} eras, pre stashes: {:?}, post: {:?}", "checked {:?}, pre stashes: {:?}, post: {:?}",
eras_checked.len(), unchecked_eras_to_check,
pre_length, pre_length,
post_length, post_length,
); );
@@ -478,7 +519,7 @@ pub mod pallet {
match checked.try_extend(unchecked_eras_to_check.clone().into_iter()) { match checked.try_extend(unchecked_eras_to_check.clone().into_iter()) {
Ok(_) => Ok(_) =>
if stashes.is_empty() { if stashes.is_empty() {
Self::deposit_event(Event::<T>::BatchFinished); Self::deposit_event(Event::<T>::BatchFinished { size: 0 });
} else { } else {
Head::<T>::put(UnstakeRequest { stashes, checked }); Head::<T>::put(UnstakeRequest { stashes, checked });
Self::deposit_event(Event::<T>::BatchChecked { Self::deposit_event(Event::<T>::BatchChecked {
@@ -491,9 +532,8 @@ pub mod pallet {
}, },
} }
<T as Config>::WeightInfo::on_idle_check( <T as Config>::WeightInfo::on_idle_check(validator_count, pre_length as u32)
validator_count * eras_checked.len() as u32, .saturating_add(unaccounted_weight)
)
} }
} }
} }
+3
View File
@@ -185,6 +185,9 @@ impl fast_unstake::Config for Runtime {
type ControlOrigin = frame_system::EnsureRoot<Self::AccountId>; type ControlOrigin = frame_system::EnsureRoot<Self::AccountId>;
type BatchSize = BatchSize; type BatchSize = BatchSize;
type WeightInfo = (); type WeightInfo = ();
type MaxErasToCheckPerBlock = ConstU32<16>;
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator = ConstU32<128>;
} }
type Block = frame_system::mocking::MockBlock<Runtime>; type Block = frame_system::mocking::MockBlock<Runtime>;
+42 -131
View File
@@ -18,7 +18,7 @@
//! Tests for pallet-fast-unstake. //! Tests for pallet-fast-unstake.
use super::*; use super::*;
use crate::{mock::*, types::*, weights::WeightInfo, Event}; use crate::{mock::*, types::*, Event};
use frame_support::{assert_noop, assert_ok, bounded_vec, pallet_prelude::*, traits::Currency}; use frame_support::{assert_noop, assert_ok, bounded_vec, pallet_prelude::*, traits::Currency};
use pallet_staking::{CurrentEra, RewardDestination}; use pallet_staking::{CurrentEra, RewardDestination};
@@ -236,120 +236,6 @@ mod on_idle {
}); });
} }
#[test]
fn respects_weight() {
ExtBuilder::default().build_and_execute(|| {
// we want to check all eras in one block...
ErasToCheckPerBlock::<T>::put(BondingDuration::get() + 1);
CurrentEra::<T>::put(BondingDuration::get());
// given
assert_ok!(FastUnstake::register_fast_unstake(RuntimeOrigin::signed(2)));
assert_eq!(Queue::<T>::get(1), Some(Deposit::get()));
assert_eq!(Queue::<T>::count(), 1);
assert_eq!(Head::<T>::get(), None);
// when: call fast unstake with not enough weight to process the whole thing, just one
// era.
let remaining_weight = <T as Config>::WeightInfo::on_idle_check(
pallet_staking::ValidatorCount::<T>::get() * 1,
);
assert_eq!(FastUnstake::on_idle(0, remaining_weight), remaining_weight);
// then
assert_eq!(
fast_unstake_events_since_last_call(),
vec![Event::BatchChecked { eras: vec![3] }]
);
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest {
stashes: bounded_vec![(1, Deposit::get())],
checked: bounded_vec![3]
})
);
// when: another 1 era.
let remaining_weight = <T as Config>::WeightInfo::on_idle_check(
pallet_staking::ValidatorCount::<T>::get() * 1,
);
assert_eq!(FastUnstake::on_idle(0, remaining_weight), remaining_weight);
// then:
assert_eq!(
fast_unstake_events_since_last_call(),
vec![Event::BatchChecked { eras: bounded_vec![2] }]
);
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest {
stashes: bounded_vec![(1, Deposit::get())],
checked: bounded_vec![3, 2]
})
);
// when: then 5 eras, we only need 2 more.
let remaining_weight = <T as Config>::WeightInfo::on_idle_check(
pallet_staking::ValidatorCount::<T>::get() * 5,
);
assert_eq!(
FastUnstake::on_idle(0, remaining_weight),
// note the amount of weight consumed: 2 eras worth of weight.
<T as Config>::WeightInfo::on_idle_check(
pallet_staking::ValidatorCount::<T>::get() * 2,
)
);
// then:
assert_eq!(
fast_unstake_events_since_last_call(),
vec![Event::BatchChecked { eras: vec![1, 0] }]
);
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest {
stashes: bounded_vec![(1, Deposit::get())],
checked: bounded_vec![3, 2, 1, 0]
})
);
// when: not enough weight to unstake:
let remaining_weight =
<T as Config>::WeightInfo::on_idle_unstake() - Weight::from_ref_time(1);
assert_eq!(FastUnstake::on_idle(0, remaining_weight), Weight::from_ref_time(0));
// then nothing happens:
assert_eq!(fast_unstake_events_since_last_call(), vec![]);
assert_eq!(
Head::<T>::get(),
Some(UnstakeRequest {
stashes: bounded_vec![(1, Deposit::get())],
checked: bounded_vec![3, 2, 1, 0]
})
);
// when: enough weight to get over at least one iteration: then we are unblocked and can
// unstake.
let remaining_weight = <T as Config>::WeightInfo::on_idle_check(
pallet_staking::ValidatorCount::<T>::get() * 1,
);
assert_eq!(
FastUnstake::on_idle(0, remaining_weight),
<T as Config>::WeightInfo::on_idle_unstake()
);
// then we finish the unbonding:
assert_eq!(
fast_unstake_events_since_last_call(),
vec![Event::Unstaked { stash: 1, result: Ok(()) }, Event::BatchFinished],
);
assert_eq!(Head::<T>::get(), None,);
assert_unstaked(&1);
});
}
#[test] #[test]
fn if_head_not_set_one_random_fetched_from_queue() { fn if_head_not_set_one_random_fetched_from_queue() {
ExtBuilder::default().build_and_execute(|| { ExtBuilder::default().build_and_execute(|| {
@@ -410,7 +296,7 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished, Event::BatchFinished { size: 1 },
Event::BatchChecked { eras: vec![3, 2, 1, 0] } Event::BatchChecked { eras: vec![3, 2, 1, 0] }
] ]
); );
@@ -458,10 +344,10 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished, Event::BatchFinished { size: 1 },
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 3, result: Ok(()) }, Event::Unstaked { stash: 3, result: Ok(()) },
Event::BatchFinished, Event::BatchFinished { size: 1 },
] ]
); );
@@ -503,7 +389,7 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
assert_unstaked(&1); assert_unstaked(&1);
@@ -545,7 +431,7 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
assert_unstaked(&1); assert_unstaked(&1);
@@ -620,7 +506,7 @@ mod on_idle {
Event::BatchChecked { eras: vec![1] }, Event::BatchChecked { eras: vec![1] },
Event::BatchChecked { eras: vec![0] }, Event::BatchChecked { eras: vec![0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
assert_unstaked(&1); assert_unstaked(&1);
@@ -704,7 +590,7 @@ mod on_idle {
Event::BatchChecked { eras: vec![0] }, Event::BatchChecked { eras: vec![0] },
Event::BatchChecked { eras: vec![4] }, Event::BatchChecked { eras: vec![4] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
assert_unstaked(&1); assert_unstaked(&1);
@@ -799,7 +685,7 @@ mod on_idle {
Event::BatchChecked { eras: vec![4] }, Event::BatchChecked { eras: vec![4] },
Event::BatchChecked { eras: vec![1] }, Event::BatchChecked { eras: vec![1] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
@@ -843,7 +729,7 @@ mod on_idle {
Event::BatchChecked { eras: vec![3] }, Event::BatchChecked { eras: vec![3] },
Event::BatchChecked { eras: vec![2] }, Event::BatchChecked { eras: vec![2] },
Event::Slashed { stash: exposed, amount: Deposit::get() }, Event::Slashed { stash: exposed, amount: Deposit::get() },
Event::BatchFinished Event::BatchFinished { size: 0 }
] ]
); );
}); });
@@ -879,7 +765,7 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2] }, Event::BatchChecked { eras: vec![3, 2] },
Event::Slashed { stash: exposed, amount: Deposit::get() }, Event::Slashed { stash: exposed, amount: Deposit::get() },
Event::BatchFinished Event::BatchFinished { size: 0 }
] ]
); );
}); });
@@ -910,7 +796,10 @@ mod on_idle {
assert_eq!( assert_eq!(
fast_unstake_events_since_last_call(), fast_unstake_events_since_last_call(),
vec![Event::Slashed { stash: 100, amount: Deposit::get() }, Event::BatchFinished] vec![
Event::Slashed { stash: 100, amount: Deposit::get() },
Event::BatchFinished { size: 0 }
]
); );
}); });
} }
@@ -946,7 +835,7 @@ mod on_idle {
vec![ vec![
Event::BatchChecked { eras: vec![3, 2, 1, 0] }, Event::BatchChecked { eras: vec![3, 2, 1, 0] },
Event::Unstaked { stash: 42, result: Ok(()) }, Event::Unstaked { stash: 42, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 1 }
] ]
); );
}); });
@@ -1001,7 +890,7 @@ mod batched {
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::Unstaked { stash: 5, result: Ok(()) }, Event::Unstaked { stash: 5, result: Ok(()) },
Event::Unstaked { stash: 7, result: Ok(()) }, Event::Unstaked { stash: 7, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 3 }
] ]
); );
}); });
@@ -1067,7 +956,7 @@ mod batched {
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::Unstaked { stash: 5, result: Ok(()) }, Event::Unstaked { stash: 5, result: Ok(()) },
Event::Unstaked { stash: 7, result: Ok(()) }, Event::Unstaked { stash: 7, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 3 }
] ]
); );
}); });
@@ -1132,7 +1021,7 @@ mod batched {
Event::BatchChecked { eras: vec![1, 0] }, Event::BatchChecked { eras: vec![1, 0] },
Event::Unstaked { stash: 1, result: Ok(()) }, Event::Unstaked { stash: 1, result: Ok(()) },
Event::Unstaked { stash: 3, result: Ok(()) }, Event::Unstaked { stash: 3, result: Ok(()) },
Event::BatchFinished Event::BatchFinished { size: 2 }
] ]
); );
}); });
@@ -1191,10 +1080,32 @@ mod batched {
Event::Slashed { stash: 666, amount: Deposit::get() }, Event::Slashed { stash: 666, amount: Deposit::get() },
Event::BatchChecked { eras: vec![3] }, Event::BatchChecked { eras: vec![3] },
Event::Slashed { stash: 667, amount: Deposit::get() }, Event::Slashed { stash: 667, amount: Deposit::get() },
Event::BatchFinished, Event::BatchFinished { size: 0 },
Event::BatchChecked { eras: vec![3] } Event::BatchChecked { eras: vec![3] }
] ]
); );
}); });
} }
} }
#[test]
fn kusama_estimate() {
use crate::WeightInfo;
let block_time = frame_support::weights::Weight::from_ref_time(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2,
)
.ref_time() as f32;
let on_idle = crate::weights::SubstrateWeight::<T>::on_idle_check(1000, 64).ref_time() as f32;
dbg!(block_time, on_idle, on_idle / block_time);
}
#[test]
fn polkadot_estimate() {
use crate::WeightInfo;
let block_time = frame_support::weights::Weight::from_ref_time(
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND * 2,
)
.ref_time() as f32;
let on_idle = crate::weights::SubstrateWeight::<T>::on_idle_check(300, 64).ref_time() as f32;
dbg!(block_time, on_idle, on_idle / block_time);
}
+86 -69
View File
@@ -1,6 +1,6 @@
// This file is part of Substrate. // This file is part of Substrate.
// Copyright (C) 2022 Parity Technologies (UK) Ltd. // Copyright (C) 2023 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,24 +18,25 @@
//! Autogenerated weights for pallet_fast_unstake //! Autogenerated weights for pallet_fast_unstake
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command: // Executed Command:
// ./target/production/substrate // target/production/substrate
// benchmark // benchmark
// pallet // pallet
// --chain=dev
// --steps=50 // --steps=50
// --repeat=20 // --repeat=20
// --pallet=pallet_fast_unstake
// --extrinsic=* // --extrinsic=*
// --execution=wasm // --execution=wasm
// --wasm-execution=compiled // --wasm-execution=compiled
// --heap-pages=4096 // --heap-pages=4096
// --output=./frame/fast-unstake/src/weights.rs // --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json
// --pallet=pallet_fast_unstake
// --chain=dev
// --header=./HEADER-APACHE2 // --header=./HEADER-APACHE2
// --output=./frame/fast-unstake/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs // --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)] #![cfg_attr(rustfmt, rustfmt_skip)]
@@ -47,8 +48,8 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_fast_unstake. /// Weight functions needed for pallet_fast_unstake.
pub trait WeightInfo { pub trait WeightInfo {
fn on_idle_unstake() -> Weight; fn on_idle_unstake(b: u32, ) -> Weight;
fn on_idle_check(x: u32, ) -> Weight; fn on_idle_check(v: u32, b: u32, ) -> Weight;
fn register_fast_unstake() -> Weight; fn register_fast_unstake() -> Weight;
fn deregister() -> Weight; fn deregister() -> Weight;
fn control() -> Weight; fn control() -> Weight;
@@ -59,8 +60,9 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1) // Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1) // Storage: Staking Bonded (r:1 w:1)
@@ -70,29 +72,36 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1) // Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1) // Storage: Staking Payee (r:0 w:1)
fn on_idle_unstake() -> Weight { /// The range of component `b` is `[1, 64]`.
// Minimum execution time: 82_426 nanoseconds. fn on_idle_unstake(b: u32, ) -> Weight {
Weight::from_ref_time(83_422_000 as u64) // Minimum execution time: 92_833 nanoseconds.
.saturating_add(T::DbWeight::get().reads(11 as u64)) Weight::from_ref_time(62_136_346)
.saturating_add(T::DbWeight::get().writes(6 as u64)) // Standard Error: 25_541
.saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(b.into())))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1) // Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:2 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking ErasStakers (r:1344 w:0) // Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `x` is `[672, 86016]`. /// The range of component `v` is `[1, 256]`.
fn on_idle_check(x: u32, ) -> Weight { /// The range of component `b` is `[1, 64]`.
// Minimum execution time: 13_932_777 nanoseconds. fn on_idle_check(v: u32, b: u32, ) -> Weight {
Weight::from_ref_time(13_996_029_000 as u64) // Minimum execution time: 1_775_293 nanoseconds.
// Standard Error: 16_878 Weight::from_ref_time(1_787_133_000)
.saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64)) // Standard Error: 17_109_142
.saturating_add(T::DbWeight::get().reads(345 as u64)) .saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) // Standard Error: 68_455_625
.saturating_add(T::DbWeight::get().writes(3 as u64)) .saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(1))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:1) // Storage: Staking Ledger (r:1 w:1)
@@ -109,10 +118,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Balances Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight { fn register_fast_unstake() -> Weight {
// Minimum execution time: 120_190 nanoseconds. // Minimum execution time: 124_849 nanoseconds.
Weight::from_ref_time(121_337_000 as u64) Weight::from_ref_time(128_176_000)
.saturating_add(T::DbWeight::get().reads(14 as u64)) .saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().writes(9 as u64)) .saturating_add(T::DbWeight::get().writes(9))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:0) // Storage: Staking Ledger (r:1 w:0)
@@ -120,16 +129,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: FastUnstake Head (r:1 w:0) // Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight { fn deregister() -> Weight {
// Minimum execution time: 49_897 nanoseconds. // Minimum execution time: 48_246 nanoseconds.
Weight::from_ref_time(50_080_000 as u64) Weight::from_ref_time(49_720_000)
.saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2 as u64)) .saturating_add(T::DbWeight::get().writes(2))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight { fn control() -> Weight {
// Minimum execution time: 4_814 nanoseconds. // Minimum execution time: 4_611 nanoseconds.
Weight::from_ref_time(4_997_000 as u64) Weight::from_ref_time(4_844_000)
.saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes(1))
} }
} }
@@ -137,8 +146,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
impl WeightInfo for () { impl WeightInfo for () {
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1) // Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:1 w:0) // Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1) // Storage: Staking Bonded (r:1 w:1)
@@ -148,29 +158,36 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1) // Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1) // Storage: Staking Payee (r:0 w:1)
fn on_idle_unstake() -> Weight { /// The range of component `b` is `[1, 64]`.
// Minimum execution time: 82_426 nanoseconds. fn on_idle_unstake(b: u32, ) -> Weight {
Weight::from_ref_time(83_422_000 as u64) // Minimum execution time: 92_833 nanoseconds.
.saturating_add(RocksDbWeight::get().reads(11 as u64)) Weight::from_ref_time(62_136_346)
.saturating_add(RocksDbWeight::get().writes(6 as u64)) // Standard Error: 25_541
.saturating_add(Weight::from_ref_time(42_904_859).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(6))
.saturating_add(RocksDbWeight::get().reads((6_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(1))
.saturating_add(RocksDbWeight::get().writes((5_u64).saturating_mul(b.into())))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking ValidatorCount (r:1 w:0) // Storage: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1) // Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:2 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0) // Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking ErasStakers (r:1344 w:0) // Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `x` is `[672, 86016]`. /// The range of component `v` is `[1, 256]`.
fn on_idle_check(x: u32, ) -> Weight { /// The range of component `b` is `[1, 64]`.
// Minimum execution time: 13_932_777 nanoseconds. fn on_idle_check(v: u32, b: u32, ) -> Weight {
Weight::from_ref_time(13_996_029_000 as u64) // Minimum execution time: 1_775_293 nanoseconds.
// Standard Error: 16_878 Weight::from_ref_time(1_787_133_000)
.saturating_add(Weight::from_ref_time(18_113_540 as u64).saturating_mul(x as u64)) // Standard Error: 17_109_142
.saturating_add(RocksDbWeight::get().reads(345 as u64)) .saturating_add(Weight::from_ref_time(546_766_552).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64))) // Standard Error: 68_455_625
.saturating_add(RocksDbWeight::get().writes(3 as u64)) .saturating_add(Weight::from_ref_time(2_135_980_830).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(7))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(RocksDbWeight::get().writes(1))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:1) // Storage: Staking Ledger (r:1 w:1)
@@ -187,10 +204,10 @@ impl WeightInfo for () {
// Storage: Balances Locks (r:1 w:1) // Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight { fn register_fast_unstake() -> Weight {
// Minimum execution time: 120_190 nanoseconds. // Minimum execution time: 124_849 nanoseconds.
Weight::from_ref_time(121_337_000 as u64) Weight::from_ref_time(128_176_000)
.saturating_add(RocksDbWeight::get().reads(14 as u64)) .saturating_add(RocksDbWeight::get().reads(14))
.saturating_add(RocksDbWeight::get().writes(9 as u64)) .saturating_add(RocksDbWeight::get().writes(9))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0) // Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:0) // Storage: Staking Ledger (r:1 w:0)
@@ -198,15 +215,15 @@ impl WeightInfo for () {
// Storage: FastUnstake Head (r:1 w:0) // Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1) // Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight { fn deregister() -> Weight {
// Minimum execution time: 49_897 nanoseconds. // Minimum execution time: 48_246 nanoseconds.
Weight::from_ref_time(50_080_000 as u64) Weight::from_ref_time(49_720_000)
.saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().reads(5))
.saturating_add(RocksDbWeight::get().writes(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2))
} }
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1) // Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight { fn control() -> Weight {
// Minimum execution time: 4_814 nanoseconds. // Minimum execution time: 4_611 nanoseconds.
Weight::from_ref_time(4_997_000 as u64) Weight::from_ref_time(4_844_000)
.saturating_add(RocksDbWeight::get().writes(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1))
} }
} }