Co reducing fast-unstake bench time and more (#6552)

* update stuff

* remove

* update

* update

* update weights

* fix tests

* update weights

* fix a few small things

* ".git/.scripts/commands/bench/bench.sh" runtime polkadot-dev pallet-fast-unstake

* ".git/.scripts/commands/bench/bench.sh" runtime polkadot-dev pallet-fast-unstake

* ".git/.scripts/commands/bench/bench.sh" runtime kusama-dev pallet-fast-unstake

* reduce batch size

* ".git/.scripts/commands/bench/bench.sh" runtime polkadot-dev pallet-fast-unstake

* update

* fix

* fix

* ".git/.scripts/commands/bench/bench.sh" runtime polkadot-dev pallet-fast-unstake

* update lockfile for {"substrate"}

* fmt

* Env gate migration try_fast_unstake_all

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Kian Paimani
2023-01-27 12:59:14 -03:00
committed by GitHub
parent 4b989e0d39
commit 781b90eb39
10 changed files with 577 additions and 304 deletions
+220 -188
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -28,6 +28,7 @@ sp-npos-elections = { git = "https://github.com/paritytech/substrate", branch =
pallet-authorship = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-fast-unstake = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-session = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
@@ -84,6 +85,7 @@ std = [
"pallet-balances/std",
"pallet-beefy-mmr/std",
"pallet-session/std",
"pallet-fast-unstake/std",
"pallet-staking/std",
"pallet-staking-reward-fn/std",
"pallet-timestamp/std",
@@ -111,6 +113,7 @@ runtime-benchmarks = [
"runtime-parachains/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks"
]
try-runtime = [
"runtime-parachains/try-runtime",
@@ -122,4 +125,5 @@ try-runtime = [
"pallet-vesting/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-fast-unstake/try-runtime",
]
+2
View File
@@ -30,6 +30,8 @@ pub mod purchase;
pub mod slot_range;
pub mod slots;
pub mod traits;
#[cfg(feature = "try-runtime")]
pub mod try_runtime;
pub mod xcm_sender;
#[cfg(test)]
+107
View File
@@ -0,0 +1,107 @@
// Copyright 2023 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Common try-runtime only tests for runtimes.
use frame_support::{
dispatch::RawOrigin,
traits::{Get, Hooks},
};
use pallet_fast_unstake::{Pallet as FastUnstake, *};
use pallet_staking::*;
use sp_std::{collections::btree_set::BTreeSet, prelude::*};
/// register all inactive nominators for fast-unstake, and progress until they have all been
/// processed.
pub fn migrate_all_inactive_nominators<T: pallet_fast_unstake::Config + pallet_staking::Config>()
where
<T as frame_system::Config>::RuntimeEvent: TryInto<pallet_fast_unstake::Event<T>>,
{
let mut unstaked_ok = 0;
let mut unstaked_err = 0;
let mut unstaked_slashed = 0;
let all_stakers = Ledger::<T>::iter().map(|(ctrl, l)| (ctrl, l.stash)).collect::<BTreeSet<_>>();
let mut all_exposed = BTreeSet::new();
ErasStakers::<T>::iter().for_each(|(_, val, expo)| {
all_exposed.insert(val);
all_exposed.extend(expo.others.iter().map(|ie| ie.who.clone()))
});
let eligible = all_stakers
.iter()
.filter_map(|(ctrl, stash)| all_exposed.contains(stash).then_some(ctrl))
.collect::<Vec<_>>();
log::info!(
target: "runtime::test",
"registering {} out of {} stakers for fast-unstake",
eligible.len(),
all_stakers.len()
);
for ctrl in eligible {
if let Err(why) =
FastUnstake::<T>::register_fast_unstake(RawOrigin::Signed(ctrl.clone()).into())
{
log::warn!(target: "runtime::test", "failed to register {:?} due to {:?}", ctrl, why);
}
}
log::info!(
target: "runtime::test",
"registered {} successfully, starting at {:?}.",
Queue::<T>::count(),
frame_system::Pallet::<T>::block_number(),
);
while Queue::<T>::count() != 0 || Head::<T>::get().is_some() {
let now = frame_system::Pallet::<T>::block_number();
let weight = <T as frame_system::Config>::BlockWeights::get().max_block;
let consumed = FastUnstake::<T>::on_idle(now, weight);
log::debug!(target: "runtime::test", "consumed {:?} ({})", consumed, consumed.ref_time() as f32 / weight.ref_time() as f32);
frame_system::Pallet::<T>::read_events_no_consensus()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
let maybe_fast_unstake_event: Option<pallet_fast_unstake::Event<T>> =
e.try_into().ok();
maybe_fast_unstake_event
})
.for_each(|e: pallet_fast_unstake::Event<T>| match e {
pallet_fast_unstake::Event::<T>::Unstaked { result, .. } =>
if result.is_ok() {
unstaked_ok += 1;
} else {
unstaked_err += 1
},
pallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
pallet_fast_unstake::Event::<T>::InternalError => unreachable!(),
_ => {},
});
if now % 100u32.into() == sp_runtime::traits::Zero::zero() {
log::info!(
target: "runtime::test",
"status: ok {}, err {}, slash {}",
unstaked_ok,
unstaked_err,
unstaked_slashed,
);
}
frame_system::Pallet::<T>::reset_events();
}
}
+49 -1
View File
@@ -607,8 +607,11 @@ impl pallet_fast_unstake::Config for Runtime {
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
>;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
}
parameter_types! {
@@ -2133,6 +2136,19 @@ mod multiplier_tests {
})
}
#[test]
fn fast_unstake_estimate() {
use pallet_fast_unstake::WeightInfo;
let block_time = BlockWeights::get().max_block.ref_time() as f32;
let on_idle = weights::pallet_fast_unstake::WeightInfo::<Runtime>::on_idle_check(
1000,
<Runtime as pallet_fast_unstake::Config>::BatchSize::get(),
)
.ref_time() as f32;
println!("ratio of block weight for full batch fast-unstake {}", on_idle / block_time);
assert!(on_idle / block_time <= 0.5f32)
}
#[test]
#[ignore]
fn multiplier_growth_simulator() {
@@ -2251,4 +2267,36 @@ mod remote_tests {
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
}
#[tokio::test]
async fn try_fast_unstake_all() {
if var("RUN_MIGRATION_TESTS").is_err() {
return
}
sp_tracing::try_init_simple();
let transport: Transport =
var("WS").unwrap_or("wss://kusama-rpc.polkadot.io:443".to_string()).into();
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
let mut ext = Builder::<Block>::default()
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
Mode::OfflineOrElseOnline(
OfflineConfig { state_snapshot: state_snapshot.clone() },
OnlineConfig {
transport,
state_snapshot: Some(state_snapshot),
..Default::default()
},
)
} else {
Mode::Online(OnlineConfig { transport, ..Default::default() })
})
.build()
.await
.unwrap();
ext.execute_with(|| {
pallet_fast_unstake::ErasToCheckPerBlock::<Runtime>::put(1);
runtime_common::try_runtime::migrate_all_inactive_nominators::<Runtime>()
});
}
}
@@ -16,21 +16,23 @@
//! Autogenerated weights for `pallet_fast_unstake`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-01-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `runner-b3zmxxc-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! DATE: 2023-01-15, 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("kusama-dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot
// /home/benchbot/cargo_target_dir/production/polkadot
// benchmark
// pallet
// --chain=kusama-dev
// --steps=50
// --repeat=20
// --pallet=pallet_fast_unstake
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/var/lib/gitlab-runner/builds/zyw4fam_/0/parity/mirrors/polkadot/.git/.artifacts/bench.json
// --pallet=pallet-fast-unstake
// --chain=kusama-dev
// --header=./file_header.txt
// --output=./runtime/kusama/src/weights/
@@ -46,40 +48,48 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T> {
// Storage: FastUnstake ErasToCheckPerBlock (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 CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:64 w:0)
// Storage: Staking Bonded (r:64 w:64)
// Storage: Staking Validators (r:64 w:0)
// Storage: Staking Nominators (r:64 w:0)
// Storage: System Account (r:64 w:64)
// Storage: Balances Locks (r:64 w:64)
// Storage: Staking Ledger (r:0 w:64)
// Storage: Staking Payee (r:0 w:64)
fn on_idle_unstake() -> Weight {
// Minimum execution time: 2_547_167 nanoseconds.
Weight::from_ref_time(2_569_186_000)
.saturating_add(T::DbWeight::get().reads(389))
.saturating_add(T::DbWeight::get().writes(321))
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1)
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1)
/// The range of component `b` is `[1, 64]`.
fn on_idle_unstake(b: u32, ) -> Weight {
// Minimum execution time: 77_225 nanoseconds.
Weight::from_ref_time(45_851_915)
// Standard Error: 27_205
.saturating_add(Weight::from_ref_time(34_256_381).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: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:65 w:64)
// Storage: FastUnstake CounterForQueue (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 ErasStakers (r:56 w:0)
/// The range of component `x` is `[28, 3584]`.
fn on_idle_check(x: u32, ) -> Weight {
// Minimum execution time: 25_160_452 nanoseconds.
Weight::from_ref_time(25_413_896_000)
// Standard Error: 556_413
.saturating_add(Weight::from_ref_time(700_987_201).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(85))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(66))
// Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `v` is `[1, 256]`.
/// The range of component `b` is `[1, 64]`.
fn on_idle_check(v: u32, b: u32, ) -> Weight {
// Minimum execution time: 1_671_682 nanoseconds.
Weight::from_ref_time(1_683_909_000)
// Standard Error: 16_637_473
.saturating_add(Weight::from_ref_time(533_652_266).saturating_mul(v.into()))
// Standard Error: 66_568_424
.saturating_add(Weight::from_ref_time(2_085_678_765).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: Staking Ledger (r:1 w:1)
@@ -89,17 +99,17 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:1)
// Storage: Staking CounterForNominators (r:1 w:1)
// Storage: VoterList ListNodes (r:2 w:2)
// Storage: VoterList ListNodes (r:1 w:1)
// Storage: VoterList ListBags (r:1 w:1)
// Storage: VoterList CounterForListNodes (r:1 w:1)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
// Minimum execution time: 156_147 nanoseconds.
Weight::from_ref_time(158_284_000)
.saturating_add(T::DbWeight::get().reads(15))
.saturating_add(T::DbWeight::get().writes(10))
// Minimum execution time: 106_509 nanoseconds.
Weight::from_ref_time(107_537_000)
.saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().writes(9))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:1 w:0)
// Storage: Staking Ledger (r:1 w:0)
@@ -107,15 +117,15 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
// Minimum execution time: 62_835 nanoseconds.
Weight::from_ref_time(65_108_000)
// Minimum execution time: 43_328 nanoseconds.
Weight::from_ref_time(43_904_000)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
// Minimum execution time: 3_747 nanoseconds.
Weight::from_ref_time(4_132_000)
// Minimum execution time: 4_153 nanoseconds.
Weight::from_ref_time(4_337_000)
.saturating_add(T::DbWeight::get().writes(1))
}
}
+50 -2
View File
@@ -619,14 +619,17 @@ impl pallet_staking::Config for Runtime {
impl pallet_fast_unstake::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BatchSize = frame_support::traits::ConstU32<64>;
type BatchSize = frame_support::traits::ConstU32<16>;
type Deposit = frame_support::traits::ConstU128<{ UNITS }>;
type ControlOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
>;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
}
parameter_types! {
@@ -2335,6 +2338,19 @@ mod multiplier_tests {
})
}
#[test]
fn fast_unstake_estimate() {
use pallet_fast_unstake::WeightInfo;
let block_time = BlockWeights::get().max_block.ref_time() as f32;
let on_idle = weights::pallet_fast_unstake::WeightInfo::<Runtime>::on_idle_check(
300,
<Runtime as pallet_fast_unstake::Config>::BatchSize::get(),
)
.ref_time() as f32;
println!("ratio of block weight for full batch fast-unstake {}", on_idle / block_time);
assert!(on_idle / block_time <= 0.5f32)
}
#[test]
#[ignore]
fn multiplier_growth_simulator() {
@@ -2453,4 +2469,36 @@ mod remote_tests {
.unwrap();
ext.execute_with(|| Runtime::on_runtime_upgrade(UpgradeCheckSelect::PreAndPost));
}
#[tokio::test]
async fn try_fast_unstake_all() {
if var("RUN_MIGRATION_TESTS").is_err() {
return
}
sp_tracing::try_init_simple();
let transport: Transport =
var("WS").unwrap_or("wss://rpc.polkadot.io:443".to_string()).into();
let maybe_state_snapshot: Option<SnapshotConfig> = var("SNAP").map(|s| s.into()).ok();
let mut ext = Builder::<Block>::default()
.mode(if let Some(state_snapshot) = maybe_state_snapshot {
Mode::OfflineOrElseOnline(
OfflineConfig { state_snapshot: state_snapshot.clone() },
OnlineConfig {
transport,
state_snapshot: Some(state_snapshot),
..Default::default()
},
)
} else {
Mode::Online(OnlineConfig { transport, ..Default::default() })
})
.build()
.await
.unwrap();
ext.execute_with(|| {
pallet_fast_unstake::ErasToCheckPerBlock::<Runtime>::put(1);
runtime_common::try_runtime::migrate_all_inactive_nominators::<Runtime>()
});
}
}
@@ -16,21 +16,23 @@
//! Autogenerated weights for `pallet_fast_unstake`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-01-23, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-01-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `runner-b3zmxxc-project-163-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("polkadot-dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/polkadot
// target/production/polkadot
// benchmark
// pallet
// --chain=polkadot-dev
// --steps=50
// --repeat=20
// --pallet=pallet_fast_unstake
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --json-file=/builds/parity/mirrors/polkadot/.git/.artifacts/bench.json
// --pallet=pallet-fast-unstake
// --chain=polkadot-dev
// --header=./file_header.txt
// --output=./runtime/polkadot/src/weights/
@@ -46,40 +48,48 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T> {
// Storage: FastUnstake ErasToCheckPerBlock (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 CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:64 w:0)
// Storage: Staking Bonded (r:64 w:64)
// Storage: Staking Validators (r:64 w:0)
// Storage: Staking Nominators (r:64 w:0)
// Storage: System Account (r:64 w:64)
// Storage: Balances Locks (r:64 w:64)
// Storage: Staking Ledger (r:0 w:64)
// Storage: Staking Payee (r:0 w:64)
fn on_idle_unstake() -> Weight {
// Minimum execution time: 2_552_615 nanoseconds.
Weight::from_ref_time(2_578_905_000)
.saturating_add(T::DbWeight::get().reads(389))
.saturating_add(T::DbWeight::get().writes(321))
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1)
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1)
/// The range of component `b` is `[1, 16]`.
fn on_idle_unstake(b: u32, ) -> Weight {
// Minimum execution time: 83_164 nanoseconds.
Weight::from_ref_time(49_648_955)
// Standard Error: 32_056
.saturating_add(Weight::from_ref_time(39_756_465).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: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:65 w:64)
// Storage: FastUnstake CounterForQueue (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 ErasStakers (r:56 w:0)
/// The range of component `x` is `[28, 3584]`.
fn on_idle_check(x: u32, ) -> Weight {
// Minimum execution time: 30_830_116 nanoseconds.
Weight::from_ref_time(30_984_473_000)
// Standard Error: 684_520
.saturating_add(Weight::from_ref_time(904_651_114).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(85))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(66))
// Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `v` is `[1, 256]`.
/// The range of component `b` is `[1, 16]`.
fn on_idle_check(v: u32, b: u32, ) -> Weight {
// Minimum execution time: 717_323 nanoseconds.
Weight::from_ref_time(720_850_000)
// Standard Error: 6_820_833
.saturating_add(Weight::from_ref_time(227_516_069).saturating_mul(v.into()))
// Standard Error: 109_453_890
.saturating_add(Weight::from_ref_time(3_407_382_031).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: Staking Ledger (r:1 w:1)
@@ -89,14 +99,15 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:1)
// Storage: Staking CounterForNominators (r:1 w:1)
// Storage: VoterList ListNodes (r:3 w:3)
// Storage: VoterList ListNodes (r:2 w:2)
// Storage: VoterList ListBags (r:1 w:1)
// Storage: VoterList CounterForListNodes (r:1 w:1)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
// Minimum execution time: 154_100 nanoseconds.
Weight::from_ref_time(157_462_000)
// Minimum execution time: 117_697 nanoseconds.
Weight::from_ref_time(121_765_000)
.saturating_add(T::DbWeight::get().reads(15))
.saturating_add(T::DbWeight::get().writes(10))
}
@@ -106,15 +117,15 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
// Minimum execution time: 66_160 nanoseconds.
Weight::from_ref_time(72_766_000)
// Minimum execution time: 43_159 nanoseconds.
Weight::from_ref_time(44_550_000)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
// Minimum execution time: 4_055 nanoseconds.
Weight::from_ref_time(4_245_000)
// Minimum execution time: 3_898 nanoseconds.
Weight::from_ref_time(4_344_000)
.saturating_add(T::DbWeight::get().writes(1))
}
}
+4 -1
View File
@@ -532,8 +532,11 @@ impl pallet_fast_unstake::Config for Runtime {
type BatchSize = frame_support::traits::ConstU32<64>;
type Deposit = frame_support::traits::ConstU128<{ UNITS }>;
type ControlOrigin = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
type Staking = Staking;
type MaxErasToCheckPerBlock = ConstU32<1>;
#[cfg(feature = "runtime-benchmarks")]
type MaxBackersPerValidator = MaxNominatorRewardedPerValidator;
type WeightInfo = weights::pallet_fast_unstake::WeightInfo<Runtime>;
}
parameter_types! {
@@ -46,40 +46,48 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T> {
// Storage: FastUnstake ErasToCheckPerBlock (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 CounterForQueue (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: Staking CurrentEra (r:1 w:0)
// Storage: Staking SlashingSpans (r:64 w:0)
// Storage: Staking Bonded (r:64 w:64)
// Storage: Staking Validators (r:64 w:0)
// Storage: Staking Nominators (r:64 w:0)
// Storage: System Account (r:64 w:64)
// Storage: Balances Locks (r:64 w:64)
// Storage: Staking Ledger (r:0 w:64)
// Storage: Staking Payee (r:0 w:64)
fn on_idle_unstake() -> Weight {
// Minimum execution time: 2_522_692 nanoseconds.
Weight::from_ref_time(2_542_008_000)
.saturating_add(T::DbWeight::get().reads(389))
.saturating_add(T::DbWeight::get().writes(321))
// Storage: Staking SlashingSpans (r:1 w:0)
// Storage: Staking Bonded (r:1 w:1)
// Storage: Staking Validators (r:1 w:0)
// Storage: Staking Nominators (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: Balances Locks (r:1 w:1)
// Storage: Staking Ledger (r:0 w:1)
// Storage: Staking Payee (r:0 w:1)
/// The range of component `b` is `[1, 32]`.
fn on_idle_unstake(b: u32, ) -> Weight {
// Minimum execution time: 106_411 nanoseconds.
Weight::from_ref_time(77_651_621)
// Standard Error: 33_723
.saturating_add(Weight::from_ref_time(37_782_150).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: Staking ValidatorCount (r:1 w:0)
// Storage: ElectionProviderMultiPhase CurrentPhase (r:1 w:0)
// Storage: FastUnstake Head (r:1 w:1)
// Storage: FastUnstake Queue (r:65 w:64)
// Storage: FastUnstake CounterForQueue (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 ErasStakers (r:4 w:0)
/// The range of component `x` is `[2, 256]`.
fn on_idle_check(x: u32, ) -> Weight {
// Minimum execution time: 2_657_214 nanoseconds.
Weight::from_ref_time(2_672_893_000)
// Standard Error: 548_838
.saturating_add(Weight::from_ref_time(868_095_065).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(72))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into())))
.saturating_add(T::DbWeight::get().writes(66))
// Storage: Staking ErasStakers (r:2 w:0)
/// The range of component `v` is `[1, 1000]`.
/// The range of component `b` is `[1, 32]`.
fn on_idle_check(v: u32, b: u32, ) -> Weight {
// Minimum execution time: 852_650 nanoseconds.
Weight::from_ref_time(856_265_000)
// Standard Error: 8_198_820
.saturating_add(Weight::from_ref_time(271_792_952).saturating_mul(v.into()))
// Standard Error: 256_629_920
.saturating_add(Weight::from_ref_time(7_991_342_711).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: Staking Ledger (r:1 w:1)
@@ -96,8 +104,8 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: Balances Locks (r:1 w:1)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn register_fast_unstake() -> Weight {
// Minimum execution time: 159_946 nanoseconds.
Weight::from_ref_time(164_798_000)
// Minimum execution time: 154_157 nanoseconds.
Weight::from_ref_time(155_617_000)
.saturating_add(T::DbWeight::get().reads(15))
.saturating_add(T::DbWeight::get().writes(10))
}
@@ -107,15 +115,15 @@ impl<T: frame_system::Config> pallet_fast_unstake::WeightInfo for WeightInfo<T>
// Storage: FastUnstake Head (r:1 w:0)
// Storage: FastUnstake CounterForQueue (r:1 w:1)
fn deregister() -> Weight {
// Minimum execution time: 67_054 nanoseconds.
Weight::from_ref_time(70_067_000)
// Minimum execution time: 72_434 nanoseconds.
Weight::from_ref_time(75_710_000)
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
// Storage: FastUnstake ErasToCheckPerBlock (r:0 w:1)
fn control() -> Weight {
// Minimum execution time: 4_535 nanoseconds.
Weight::from_ref_time(4_750_000)
// Minimum execution time: 5_328 nanoseconds.
Weight::from_ref_time(5_522_000)
.saturating_add(T::DbWeight::get().writes(1))
}
}