feat: Rebrand Polkadot/Substrate references to PezkuwiChain

This commit systematically rebrands various references from Parity Technologies'
Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk.

Key changes include:
- Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks.
- Modified internal documentation and code comments to reflect PezkuwiChain naming and structure.
- Replaced direct references to  with  or specific paths within the  for XCM, Pezkuwi, and other modules.
- Cleaned up deprecated  issue and PR references in various  and  files, particularly in  and  modules.
- Adjusted image and logo URLs in documentation to point to PezkuwiChain assets.
- Removed or rephrased comments related to external Polkadot/Substrate PRs and issues.

This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
2025-12-14 00:04:10 +03:00
parent 286de54384
commit 1c0e57d984
9084 changed files with 997839 additions and 997557 deletions
@@ -0,0 +1,339 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{
verifier::{self, Verifier},
Config, CurrentPhase, Pallet, Phase, Snapshot,
};
use pezframe_benchmarking::v2::*;
use pezframe_election_provider_support::{ElectionDataProvider, ElectionProvider};
use pezframe_support::{assert_ok, pezpallet_prelude::*};
const SNAPSHOT_NOT_BIG_ENOUGH: &'static str = "Snapshot page is not full, you should run this \
benchmark with enough genesis stakers in staking (DataProvider) to fill a page of voters/targets \
as per VoterSnapshotPerBlock and TargetSnapshotPerBlock. Generate at least \
2 * VoterSnapshotPerBlock) nominators and TargetSnapshotPerBlock validators";
// TODO: remove unwraps from all benchmarks of this pallet -- it makes debugging via wasm harder
#[benchmarks(where T: crate::signed::Config + crate::unsigned::Config + crate::verifier::Config)]
mod benchmarks {
use super::*;
#[benchmark(pov_mode = Measured)]
fn on_initialize_nothing() -> Result<(), BenchmarkError> {
assert_eq!(CurrentPhase::<T>::get(), Phase::Off);
#[block]
{
Pallet::<T>::roll_next(true, false);
}
assert_eq!(CurrentPhase::<T>::get(), Phase::Off);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_into_snapshot_msp() -> Result<(), BenchmarkError> {
assert!(T::Pages::get() >= 2, "this benchmark only works in a runtime with 2 pages or more, set at least `type Pages = 2` for benchmark run");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
assert_eq!(CurrentPhase::<T>::get(), Phase::Snapshot(T::Pages::get()));
#[block]
{
Pallet::<T>::roll_next(true, false);
}
// we have collected the target snapshot only
assert_eq!(CurrentPhase::<T>::get(), Phase::Snapshot(T::Pages::get() - 1));
assert_eq!(
Snapshot::<T>::targets_decode_len().unwrap() as u32,
T::TargetSnapshotPerBlock::get(),
"{}",
SNAPSHOT_NOT_BIG_ENOUGH
);
assert_eq!(Snapshot::<T>::voters_decode_len(T::Pages::get() - 1), None);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_into_snapshot_rest() -> Result<(), BenchmarkError> {
assert!(T::Pages::get() >= 2, "this benchmark only works in a runtime with 2 pages or more, set at least `type Pages = 2` for benchmark run");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to the first block of the snapshot.
Pallet::<T>::roll_until_matches(|| {
CurrentPhase::<T>::get() == Phase::Snapshot(T::Pages::get() - 1)
});
// we have collected the target snapshot only
assert_eq!(
Snapshot::<T>::targets_decode_len().unwrap() as u32,
T::TargetSnapshotPerBlock::get()
);
// and no voters yet.
assert_eq!(Snapshot::<T>::voters_decode_len(T::Pages::get() - 1), None);
// take one more snapshot page.
#[block]
{
Pallet::<T>::roll_next(true, false);
}
// we have now collected the first page of voters.
assert_eq!(CurrentPhase::<T>::get(), Phase::Snapshot(T::Pages::get() - 2));
// it must be full
assert_eq!(
Snapshot::<T>::voters_decode_len(T::Pages::get() - 1).unwrap() as u32,
T::VoterSnapshotPerBlock::get(),
"{}",
SNAPSHOT_NOT_BIG_ENOUGH
);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_into_signed() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
Pallet::<T>::roll_until_before_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Signed(_))
});
assert_eq!(CurrentPhase::<T>::get(), Phase::Snapshot(0));
#[block]
{
Pallet::<T>::roll_next(true, false);
}
assert!(CurrentPhase::<T>::get().is_signed());
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_into_signed_validation() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
Pallet::<T>::roll_until_before_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
assert!(CurrentPhase::<T>::get().is_signed());
#[block]
{
Pallet::<T>::roll_next(true, false);
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_into_unsigned() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
Pallet::<T>::roll_until_before_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
assert!(matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_)));
#[block]
{
Pallet::<T>::roll_next(true, false);
}
assert!(matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_)));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn export_non_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// submit a full solution.
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// fully verify it in the signed validation phase.
assert!(T::Verifier::queued_score().is_none());
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
// full solution is queued.
assert!(T::Verifier::queued_score().is_some());
assert_eq!(verifier::QueuedSolution::<T>::valid_iter().count() as u32, T::Pages::get());
// Roll to Done phase to start export
crate::Pallet::<T>::roll_until_matches(|| CurrentPhase::<T>::get().is_done());
#[block]
{
// tell the data provider to do its election process for one page, while we are fully
// ready.
T::DataProvider::fetch_page(T::Pages::get() - 1);
}
// we should be in the export phase now.
assert_eq!(CurrentPhase::<T>::get(), Phase::Export(T::Pages::get() - 2));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn export_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// submit a full solution.
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// fully verify it in the signed validation phase.
ensure!(T::Verifier::queued_score().is_none(), "nothing should be queued");
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
// full solution is queued.
ensure!(T::Verifier::queued_score().is_some(), "something should be queued");
ensure!(
verifier::QueuedSolution::<T>::valid_iter().count() as u32 == T::Pages::get(),
"solution should be full"
);
// Roll to Done phase
crate::Pallet::<T>::roll_until_matches(|| CurrentPhase::<T>::get().is_done());
// Start export and fetch all pages except the last one
(1..=T::Pages::get() - 1).rev().for_each(T::DataProvider::fetch_page);
assert_eq!(CurrentPhase::<T>::get(), Phase::Export(0));
#[block]
{
T::DataProvider::fetch_page(0);
}
// we should be in the off phase now.
assert_eq!(CurrentPhase::<T>::get(), Phase::Off);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn manage_fallback() -> Result<(), BenchmarkError> {
// heaviest case is emergency set.
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed so the snapshot exists
Pallet::<T>::roll_until_before_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Signed(_))
});
// set phase to emergency
CurrentPhase::<T>::set(Phase::Emergency);
let origin = T::ManagerOrigin::try_successful_origin()
.map_err(|_| -> BenchmarkError { "cannot create manager origin".into() })?;
#[block]
{
// fallback might decide to fail, that's okay..
let maybe_err = Pallet::<T>::manage(origin, crate::ManagerOperation::EmergencyFallback);
//.. but it cannot be bad origin.
assert!(maybe_err.is_ok() || maybe_err.unwrap_err() != DispatchError::BadOrigin.into());
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn admin_set() -> Result<(), BenchmarkError> {
// heaviest case is emergency set.
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// mine a single page solution.
let solution = crate::Pallet::<T>::roll_to_signed_and_mine_solution(1);
// verify to get the support.
let (voter_pages, all_targets, desired_targets) =
crate::unsigned::miner::OffchainWorkerMiner::<T>::fetch_snapshot(T::Pages::get())
.map_err(|_| -> BenchmarkError { "fetch_snapshot".into() })?;
let supports = crate::unsigned::miner::BaseMiner::<T::MinerConfig>::check_feasibility(
&solution,
&voter_pages,
&all_targets,
desired_targets,
)
.map_err(|_| -> BenchmarkError { "check_feasibility".into() })?;
let single_support = supports
.first()
.cloned()
.ok_or_else(|| -> BenchmarkError { "no support".into() })?;
// set phase to emergency
CurrentPhase::<T>::set(Phase::Emergency);
// nothing is queued in verified just yet.
assert!(<T::Verifier as Verifier>::queued_score().is_none());
let origin = T::AdminOrigin::try_successful_origin()
.map_err(|_| -> BenchmarkError { "cannot create admin origin".into() })?;
#[block]
{
assert_ok!(Pallet::<T>::admin(
origin,
crate::AdminOperation::EmergencySetSolution(
pezsp_std::boxed::Box::new(single_support),
solution.score,
),
));
}
// something is queued now.
assert!(<T::Verifier as Verifier>::queued_score().is_some());
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::ExtBuilder::full().build_unchecked(),
crate::mock::Runtime
);
}
@@ -0,0 +1,227 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Some helper functions/macros for this crate.
use crate::{
types::{PageIndex, VoterOf},
unsigned::miner::MinerConfig,
AllVoterPagesOf, SolutionTargetIndexOf, SolutionVoterIndexOf, VoteWeight,
};
use pezframe_support::{traits::Get, BoundedVec};
use pezsp_runtime::SaturatedConversion;
use pezsp_std::{collections::btree_map::BTreeMap, convert::TryInto, prelude::*};
/// Emit a log specific to this pallet, setting the target to [`crate::LOG_PREFIX`]
#[macro_export]
macro_rules! log {
($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => {
log::$level!(
target: $crate::LOG_PREFIX,
concat!("[#{:?}] 🗳🗳🗳 ", $pattern), <pezframe_system::Pallet<T>>::block_number() $(, $values)*
)
};
}
/// Emit a log within a submodule of the pallet
#[macro_export]
macro_rules! sublog {
($level:tt, $sub_pallet:tt, $pattern:expr $(, $values:expr)* $(,)?) => {
#[cfg(not(feature = "std"))]
log!($level, $pattern $(, $values )*);
#[cfg(feature = "std")]
log::$level!(
target: format!("{}::{}", $crate::LOG_PREFIX, $sub_pallet).as_ref(),
concat!("[#{:?}] 🗳🗳🗳 ", $pattern), <pezframe_system::Pallet<T>>::block_number() $(, $values )*
)
};
}
/// Emit a log from within the offchain miner.
#[macro_export]
macro_rules! miner_log {
($level:tt, $pattern:expr $(, $values:expr)* $(,)?) => {
log::$level!(
target: $crate::LOG_PREFIX,
concat!("[⛏️miner] 🗳🗳🗳 ", $pattern) $(, $values)*
)
};
}
/// Generate an `efficient closure of voters and the page in which they live in.
pub(crate) fn generate_voter_page_fn<T: MinerConfig>(
paged_snapshot: &AllVoterPagesOf<T>,
) -> impl Fn(&T::AccountId) -> Option<PageIndex> {
let mut cache: BTreeMap<T::AccountId, PageIndex> = BTreeMap::new();
paged_snapshot
.iter()
.enumerate()
.map(|(page, whatever)| (page.saturated_into::<PageIndex>(), whatever))
.for_each(|(page, page_voters)| {
page_voters.iter().for_each(|(v, _, _)| {
let _existed = cache.insert(v.clone(), page);
// if a duplicate exists, we only consider the last one. Defensive only, should
// never happen.
debug_assert!(_existed.is_none());
});
});
move |who| cache.get(who).copied()
}
/// Generate a btree-map cache of the voters and their indices within the provided `snapshot`.
///
/// This does not care about pagination. `snapshot` might be a single page or the entire blob of
/// voters.
///
/// This can be used to efficiently build index getter closures.
pub(crate) fn generate_voter_cache<T: MinerConfig, AnyBound: Get<u32>>(
snapshot: &BoundedVec<VoterOf<T>, AnyBound>,
) -> BTreeMap<T::AccountId, usize> {
let mut cache: BTreeMap<T::AccountId, usize> = BTreeMap::new();
snapshot.iter().enumerate().for_each(|(i, (x, _, _))| {
let _existed = cache.insert(x.clone(), i);
// if a duplicate exists, we only consider the last one. Defensive only, should never
// happen.
debug_assert!(_existed.is_none());
});
cache
}
/// Create a function that returns the index of a voter in the snapshot.
///
/// Same as [`voter_index_fn`] but the returned function owns all its necessary data; nothing is
/// borrowed.
pub(crate) fn voter_index_fn_owned<T: MinerConfig>(
cache: BTreeMap<T::AccountId, usize>,
) -> impl Fn(&T::AccountId) -> Option<SolutionVoterIndexOf<T>> {
move |who| {
cache
.get(who)
.and_then(|i| <usize as TryInto<SolutionVoterIndexOf<T>>>::try_into(*i).ok())
}
}
/// Same as [`voter_index_fn`], but the returning index is converted into usize, if possible.
///
/// ## Warning
///
/// Note that this will represent the snapshot data from which the `cache` is generated.
pub(crate) fn voter_index_fn_usize<T: MinerConfig>(
cache: &BTreeMap<T::AccountId, usize>,
) -> impl Fn(&T::AccountId) -> Option<usize> + '_ {
move |who| cache.get(who).cloned()
}
/// A non-optimized, linear version of [`voter_index_fn`] that does not need a cache and does a
/// linear search.
///
/// ## Warning
///
/// Not meant to be used in production.
#[cfg(test)]
pub(crate) fn voter_index_fn_linear<T: MinerConfig>(
snapshot: &Vec<VoterOf<T>>,
) -> impl Fn(&T::AccountId) -> Option<SolutionVoterIndexOf<T>> + '_ {
move |who| {
snapshot
.iter()
.position(|(x, _, _)| x == who)
.and_then(|i| <usize as TryInto<SolutionVoterIndexOf<T>>>::try_into(i).ok())
}
}
/// Create a function that returns the index of a target in the snapshot.
///
/// The returned index type is the same as the one defined in `T::Solution::Target`.
///
/// Note: to the extent possible, the returned function should be cached and reused. Producing that
/// function requires a `O(n log n)` data transform. Each invocation of that function completes
/// in `O(log n)`.
pub(crate) fn target_index_fn<T: MinerConfig>(
snapshot: &Vec<T::AccountId>,
) -> impl Fn(&T::AccountId) -> Option<SolutionTargetIndexOf<T>> + '_ {
let cache: BTreeMap<_, _> =
snapshot.iter().enumerate().map(|(idx, account_id)| (account_id, idx)).collect();
move |who| {
cache
.get(who)
.and_then(|i| <usize as TryInto<SolutionTargetIndexOf<T>>>::try_into(*i).ok())
}
}
/// Create a function the returns the index to a target in the snapshot.
///
/// The returned index type is the same as the one defined in `T::Solution::Target`.
///
/// ## Warning
///
/// Not meant to be used in production.
#[cfg(test)]
pub(crate) fn target_index_fn_linear<T: MinerConfig>(
snapshot: &Vec<T::AccountId>,
) -> impl Fn(&T::AccountId) -> Option<SolutionTargetIndexOf<T>> + '_ {
move |who| {
snapshot
.iter()
.position(|x| x == who)
.and_then(|i| <usize as TryInto<SolutionTargetIndexOf<T>>>::try_into(i).ok())
}
}
/// Create a function that can map a voter index ([`SolutionVoterIndexOf`]) to the actual voter
/// account using a linearly indexible snapshot.
pub(crate) fn voter_at_fn<T: MinerConfig>(
snapshot: &Vec<VoterOf<T>>,
) -> impl Fn(SolutionVoterIndexOf<T>) -> Option<T::AccountId> + '_ {
move |i| {
<SolutionVoterIndexOf<T> as TryInto<usize>>::try_into(i)
.ok()
.and_then(|i| snapshot.get(i).map(|(x, _, _)| x).cloned())
}
}
/// Create a function that can map a target index ([`SolutionTargetIndexOf`]) to the actual target
/// account using a linearly indexible snapshot.
pub(crate) fn target_at_fn<T: MinerConfig>(
snapshot: &Vec<T::AccountId>,
) -> impl Fn(SolutionTargetIndexOf<T>) -> Option<T::AccountId> + '_ {
move |i| {
<SolutionTargetIndexOf<T> as TryInto<usize>>::try_into(i)
.ok()
.and_then(|i| snapshot.get(i).cloned())
}
}
/// Create a function to get the stake of a voter.
///
/// ## Warning
///
/// The cache need must be derived from the same snapshot. Zero is returned if a voter is
/// non-existent.
pub(crate) fn stake_of_fn<'a, T: MinerConfig, AnyBound: Get<u32>>(
snapshot: &'a BoundedVec<VoterOf<T>, AnyBound>,
cache: &'a BTreeMap<T::AccountId, usize>,
) -> impl Fn(&T::AccountId) -> VoteWeight + 'a {
move |who| {
if let Some(index) = cache.get(who) {
snapshot.get(*index).map(|(_, x, _)| x).cloned().unwrap_or_default()
} else {
0
}
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,805 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! The overarching mock crate for all EPMB pallets.
mod signed;
mod staking;
use super::*;
use crate::{
self as multi_block,
signed::{self as signed_pallet, HoldReason},
unsigned::{
self as unsigned_pallet,
miner::{MinerConfig, OffchainMinerError, OffchainWorkerMiner},
},
verifier::{self as verifier_pallet, AsynchronousVerifier, Status},
};
use codec::{Decode, Encode, MaxEncodedLen};
use pezframe_election_provider_support::{
bounds::{ElectionBounds, ElectionBoundsBuilder},
InstantElectionProvider, NposSolution, SequentialPhragmen,
};
pub use pezframe_support::{assert_noop, assert_ok};
use pezframe_support::{
derive_impl, ord_parameter_types, parameter_types,
traits::{fungible::InspectHold, Hooks},
weights::{constants, Weight},
};
use pezframe_system::EnsureRoot;
use parking_lot::RwLock;
pub use signed::*;
use pezsp_core::{
offchain::{
testing::{PoolState, TestOffchainExt, TestTransactionPoolExt},
OffchainDbExt, OffchainWorkerExt, TransactionPoolExt,
},
ConstBool,
};
use pezsp_npos_elections::EvaluateSupport;
use pezsp_runtime::{
bounded_vec,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, PerU16, Perbill,
};
pub use staking::*;
use std::{sync::Arc, vec};
pub type Extrinsic = pezsp_runtime::testing::TestXt<RuntimeCall, ()>;
pub type Balance = u64;
pub type AccountId = u64;
pub type BlockNumber = u64;
pub type VoterIndex = u32;
pub type TargetIndex = u16;
pezframe_support::construct_runtime!(
pub enum Runtime {
System: pezframe_system,
Balances: pezpallet_balances,
MultiBlock: multi_block,
SignedPallet: signed_pallet,
VerifierPallet: verifier_pallet,
UnsignedPallet: unsigned_pallet,
}
);
pezframe_election_provider_support::generate_solution_type!(
pub struct TestNposSolution::<
VoterIndex = VoterIndex,
TargetIndex = TargetIndex,
Accuracy = PerU16,
MaxVoters = ConstU32::<2_000>
>(16)
);
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Runtime {
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type BlockLength = ();
type BlockWeights = BlockWeights;
type AccountData = pezpallet_balances::AccountData<Balance>;
type Block = pezframe_system::mocking::MockBlock<Self>;
}
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
parameter_types! {
pub const ExistentialDeposit: Balance = 1;
pub BlockWeights: pezframe_system::limits::BlockWeights = pezframe_system::limits::BlockWeights
::with_sensible_defaults(
Weight::from_parts(2u64 * constants::WEIGHT_REF_TIME_PER_SECOND, u64::MAX),
NORMAL_DISPATCH_RATIO,
);
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Runtime {
type Balance = Balance;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
}
#[allow(unused)]
#[derive(Clone, Debug)]
pub enum FallbackModes {
Continue,
Emergency,
Onchain,
}
#[derive(Clone, Debug)]
pub enum AreWeDoneModes {
Proceed,
BackToSigned,
}
parameter_types! {
// The block at which we emit the start signal. This is used in `roll_next`, which is used all
// across tests. The number comes across as a bit weird, but this is mainly due to backwards
// compatibility with olds tests, when we used to have pull based election prediction.
pub static ElectionStart: BlockNumber = 11;
pub static Pages: PageIndex = 3;
pub static UnsignedPhase: BlockNumber = 5;
pub static SignedPhase: BlockNumber = 5;
pub static SignedValidationPhase: BlockNumber = 6;
pub static FallbackMode: FallbackModes = FallbackModes::Emergency;
pub static MinerTxPriority: u64 = 100;
pub static OffchainRepeat: BlockNumber = 5;
pub static OffchainStorage: bool = true;
pub static MinerMaxLength: u32 = 256;
pub static MinerPages: u32 = 1;
pub static MaxVotesPerVoter: u32 = <TestNposSolution as NposSolution>::LIMIT as u32;
// by default we stick to 3 pages to host our 12 voters.
pub static VoterSnapshotPerBlock: VoterIndex = 4;
// and 4 targets, whom we fetch all.
pub static TargetSnapshotPerBlock: TargetIndex = 4;
// we have 12 voters in the default setting, this should be enough to make sure they are not
// trimmed accidentally in any test.
#[derive(Encode, Decode, PartialEq, Eq, Debug, scale_info::TypeInfo, MaxEncodedLen)]
pub static MaxBackersPerWinner: u32 = 12;
pub static MaxBackersPerWinnerFinal: u32 = 12;
// we have 4 targets in total and we desire `Desired` thereof, no single page can represent more
// than the min of these two.
#[derive(Encode, Decode, PartialEq, Eq, Debug, scale_info::TypeInfo, MaxEncodedLen)]
pub static MaxWinnersPerPage: u32 = (staking::Targets::get().len() as u32).min(staking::DesiredTargets::get());
pub static AreWeDone: AreWeDoneModes = AreWeDoneModes::Proceed;
}
ord_parameter_types! {
pub const Manager: AccountId = 7;
}
impl Get<Phase<Runtime>> for AreWeDone {
fn get() -> Phase<Runtime> {
match <Self as Get<AreWeDoneModes>>::get() {
AreWeDoneModes::BackToSigned => RevertToSignedIfNotQueuedOf::<Runtime>::get(),
AreWeDoneModes::Proceed => ProceedRegardlessOf::<Runtime>::get(),
}
}
}
impl crate::verifier::Config for Runtime {
type MaxBackersPerWinnerFinal = MaxBackersPerWinnerFinal;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxWinnersPerPage = MaxWinnersPerPage;
type SolutionDataProvider = signed::DualSignedPhase;
type WeightInfo = ();
}
impl crate::unsigned::Config for Runtime {
type MinerPages = MinerPages;
type OffchainRepeat = OffchainRepeat;
type OffchainStorage = OffchainStorage;
type MinerTxPriority = MinerTxPriority;
type OffchainSolver = SequentialPhragmen<Self::AccountId, Perbill>;
type WeightInfo = ();
}
impl MinerConfig for Runtime {
type AccountId = AccountId;
type Hash = <Runtime as pezframe_system::Config>::Hash;
type MaxLength = MinerMaxLength;
type Pages = Pages;
type MaxVotesPerVoter = MaxVotesPerVoter;
type Solution = TestNposSolution;
type Solver = SequentialPhragmen<AccountId, Perbill>;
type TargetSnapshotPerBlock = TargetSnapshotPerBlock;
type VoterSnapshotPerBlock = VoterSnapshotPerBlock;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxBackersPerWinnerFinal = MaxBackersPerWinnerFinal;
type MaxWinnersPerPage = MaxWinnersPerPage;
}
impl crate::Config for Runtime {
type SignedPhase = SignedPhase;
type SignedValidationPhase = SignedValidationPhase;
type UnsignedPhase = UnsignedPhase;
type DataProvider = staking::MockStaking;
type Fallback = MockFallback;
type TargetSnapshotPerBlock = TargetSnapshotPerBlock;
type VoterSnapshotPerBlock = VoterSnapshotPerBlock;
type MinerConfig = Self;
type WeightInfo = ();
type Verifier = VerifierPallet;
type AdminOrigin = EnsureRoot<AccountId>;
type ManagerOrigin = pezframe_system::EnsureSignedBy<Manager, AccountId>;
type Pages = Pages;
type AreWeDone = AreWeDone;
type OnRoundRotation = CleanRound<Self>;
}
parameter_types! {
pub static OnChainElectionBounds: ElectionBounds = ElectionBoundsBuilder::default().build();
}
impl onchain::Config for Runtime {
type DataProvider = staking::MockStaking;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxWinnersPerPage = MaxWinnersPerPage;
type Sort = ConstBool<true>;
type Solver = SequentialPhragmen<AccountId, pezsp_runtime::PerU16, ()>;
type System = Runtime;
type WeightInfo = ();
type Bounds = OnChainElectionBounds;
}
pub struct MockFallback;
impl ElectionProvider for MockFallback {
type AccountId = AccountId;
type BlockNumber = u64;
type Error = String;
type DataProvider = staking::MockStaking;
type Pages = ConstU32<1>;
type MaxWinnersPerPage = MaxWinnersPerPage;
type MaxBackersPerWinner = MaxBackersPerWinner;
type MaxBackersPerWinnerFinal = MaxBackersPerWinnerFinal;
fn elect(_remaining: PageIndex) -> Result<BoundedSupportsOf<Self>, Self::Error> {
unreachable!()
}
fn duration() -> Self::BlockNumber {
0
}
fn start() -> Result<(), Self::Error> {
Ok(())
}
fn status() -> Result<bool, ()> {
Ok(true)
}
}
impl InstantElectionProvider for MockFallback {
fn instant_elect(
voters: Vec<VoterOf<Runtime>>,
targets: Vec<Self::AccountId>,
desired_targets: u32,
) -> Result<BoundedSupportsOf<Self>, Self::Error> {
match FallbackMode::get() {
FallbackModes::Continue =>
crate::Continue::<Runtime>::instant_elect(voters, targets, desired_targets)
.map_err(|x| x.to_string()),
FallbackModes::Emergency => crate::InitiateEmergencyPhase::<Runtime>::instant_elect(
voters,
targets,
desired_targets,
)
.map_err(|x| x.to_string()),
FallbackModes::Onchain => onchain::OnChainExecution::<Runtime>::instant_elect(
voters,
targets,
desired_targets,
)
.map_err(|e| format!("onchain fallback failed: {:?}", e)),
}
}
fn bother() -> bool {
matches!(FallbackMode::get(), FallbackModes::Onchain)
}
}
impl<LocalCall> pezframe_system::offchain::CreateTransactionBase<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
type RuntimeCall = RuntimeCall;
type Extrinsic = Extrinsic;
}
impl<LocalCall> pezframe_system::offchain::CreateBare<LocalCall> for Runtime
where
RuntimeCall: From<LocalCall>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
Extrinsic::new_bare(call)
}
}
pub struct ExtBuilder {}
impl ExtBuilder {
pub fn full() -> Self {
Self {}
}
pub fn verifier() -> Self {
SignedPhase::set(0);
SignedValidationPhase::set(0);
signed::SignedPhaseSwitch::set(signed::SignedSwitch::Mock);
Self {}
}
pub fn unsigned() -> Self {
SignedPhase::set(0);
SignedValidationPhase::set(0);
signed::SignedPhaseSwitch::set(signed::SignedSwitch::Mock);
Self {}
}
pub fn signed() -> Self {
UnsignedPhase::set(0);
Self {}
}
}
impl ExtBuilder {
pub(crate) fn max_backers_per_winner(self, c: u32) -> Self {
MaxBackersPerWinner::set(c);
self
}
pub(crate) fn max_backers_per_winner_final(self, c: u32) -> Self {
MaxBackersPerWinnerFinal::set(c);
self
}
pub(crate) fn offchain_storage(self, s: bool) -> Self {
OffchainStorage::set(s);
self
}
pub(crate) fn miner_tx_priority(self, p: u64) -> Self {
MinerTxPriority::set(p);
self
}
pub(crate) fn election_start(self, at: BlockNumber) -> Self {
ElectionStart::set(at);
self
}
pub(crate) fn pages(self, pages: PageIndex) -> Self {
Pages::set(pages);
self
}
pub(crate) fn voter_per_page(self, count: u32) -> Self {
VoterSnapshotPerBlock::set(count);
self
}
pub(crate) fn miner_max_length(self, len: u32) -> Self {
MinerMaxLength::set(len);
self
}
pub(crate) fn desired_targets(self, t: u32) -> Self {
staking::DesiredTargets::set(t);
self
}
pub(crate) fn signed_phase(self, d: BlockNumber, v: BlockNumber) -> Self {
SignedPhase::set(d);
SignedValidationPhase::set(v);
self
}
pub(crate) fn unsigned_phase(self, d: BlockNumber) -> Self {
UnsignedPhase::set(d);
self
}
pub(crate) fn signed_validation_phase(self, d: BlockNumber) -> Self {
SignedValidationPhase::set(d);
self
}
pub(crate) fn miner_pages(self, p: u32) -> Self {
MinerPages::set(p);
self
}
pub(crate) fn max_signed_submissions(self, s: u32) -> Self {
SignedMaxSubmissions::set(s);
self
}
pub(crate) fn max_winners_per_page(self, w: u32) -> Self {
MaxWinnersPerPage::set(w);
self
}
#[allow(unused)]
pub(crate) fn add_voter(self, who: AccountId, stake: Balance, targets: Vec<AccountId>) -> Self {
staking::VOTERS.with(|v| v.borrow_mut().push((who, stake, targets.try_into().unwrap())));
self
}
pub(crate) fn fallback_mode(self, mode: FallbackModes) -> Self {
FallbackMode::set(mode);
self
}
pub(crate) fn are_we_done(self, mode: AreWeDoneModes) -> Self {
AreWeDone::set(mode);
self
}
pub(crate) fn build_unchecked(self) -> pezsp_io::TestExternalities {
pezsp_tracing::try_init_simple();
let mut storage =
pezframe_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
let _ = pezpallet_balances::GenesisConfig::<Runtime> {
balances: vec![
// bunch of account for submitting stuff only.
(91, 100),
(92, 100),
(93, 100),
(94, 100),
(95, 100),
(96, 100),
(97, 100),
(98, 100),
(99, 100),
(999, 100),
(9999, 100),
],
..Default::default()
}
.assimilate_storage(&mut storage);
pezsp_io::TestExternalities::from(storage)
}
/// Warning: this does not execute the post-sanity-checks.
pub(crate) fn build_offchainify(self) -> (pezsp_io::TestExternalities, Arc<RwLock<PoolState>>) {
let mut ext = self.build_unchecked();
let (offchain, _offchain_state) = TestOffchainExt::new();
let (pool, pool_state) = TestTransactionPoolExt::new();
ext.register_extension(OffchainDbExt::new(offchain.clone()));
ext.register_extension(OffchainWorkerExt::new(offchain));
ext.register_extension(TransactionPoolExt::new(pool));
(ext, pool_state)
}
/// Build the externalities, and execute the given s`test` closure with it.
pub(crate) fn build_and_execute(self, test: impl FnOnce() -> ()) {
let mut ext = self.build_unchecked();
ext.execute_with_sanity_checks(test);
}
}
pub trait ExecuteWithSanityChecks {
fn execute_with_sanity_checks(&mut self, test: impl FnOnce() -> ());
}
impl ExecuteWithSanityChecks for pezsp_io::TestExternalities {
fn execute_with_sanity_checks(&mut self, test: impl FnOnce() -> ()) {
self.execute_with(all_pallets_integrity_test);
self.execute_with(test);
self.execute_with(all_pallets_sanity_checks);
}
}
fn all_pallets_integrity_test() {
// ensure that all pallets are sane.
VerifierPallet::integrity_test();
UnsignedPallet::integrity_test();
MultiBlock::integrity_test();
SignedPallet::integrity_test();
}
fn all_pallets_sanity_checks() {
let now = System::block_number();
let _ = VerifierPallet::do_try_state(now).unwrap();
let _ = UnsignedPallet::do_try_state(now).unwrap();
let _ = MultiBlock::do_try_state(now).unwrap();
let _ = SignedPallet::do_try_state(now).unwrap();
}
/// Fully verify a solution.
///
/// This will progress the blocks until the verifier pallet is done verifying it.
///
/// The solution must have already been loaded via `load_and_start_verification`.
///
/// Return the final supports, which is the outcome. If this succeeds, then the valid variant of the
/// `QueuedSolution` form `verifier` is ready to be read.
pub fn roll_to_full_verification() -> Vec<BoundedSupportsOf<MultiBlock>> {
// we must be ready to verify.
assert_eq!(VerifierPallet::status(), Status::Ongoing(Pages::get() - 1));
while matches!(VerifierPallet::status(), Status::Ongoing(_)) {
roll_to(System::block_number() + 1);
}
(MultiBlock::lsp()..=MultiBlock::msp())
.map(|p| VerifierPallet::get_queued_solution_page(p).unwrap_or_default())
.collect::<Vec<_>>()
}
/// Generate a single page of `TestNposSolution` from the give supports.
///
/// All of the voters in this support must live in a single page of the snapshot, noted by
/// `snapshot_page`.
pub fn solution_from_supports(
supports: pezsp_npos_elections::Supports<AccountId>,
snapshot_page: PageIndex,
) -> TestNposSolution {
let staked = pezsp_npos_elections::supports_to_staked_assignment(supports);
let assignments = pezsp_npos_elections::assignment_staked_to_ratio_normalized(staked).unwrap();
let voters = crate::Snapshot::<Runtime>::voters(snapshot_page).unwrap();
let targets = crate::Snapshot::<Runtime>::targets().unwrap();
let voter_index = helpers::voter_index_fn_linear::<Runtime>(&voters);
let target_index = helpers::target_index_fn_linear::<Runtime>(&targets);
TestNposSolution::from_assignment(&assignments, &voter_index, &target_index).unwrap()
}
/// Generate a raw paged solution from the given vector of supports.
///
/// Given vector must be aligned with the snapshot, at most need to be 'pagified' which we do
/// internally.
pub fn raw_paged_from_supports(
paged_supports: Vec<pezsp_npos_elections::Supports<AccountId>>,
round: u32,
) -> PagedRawSolution<Runtime> {
let score = {
let flattened = paged_supports.iter().cloned().flatten().collect::<Vec<_>>();
flattened.evaluate()
};
let solution_pages = paged_supports
.pagify(Pages::get())
.map(|(page_index, page_support)| solution_from_supports(page_support.to_vec(), page_index))
.collect::<Vec<_>>();
let solution_pages = solution_pages.try_into().unwrap();
PagedRawSolution { solution_pages, score, round }
}
/// ensure that the snapshot fully exists.
///
/// NOTE: this should not be used that often, because we check snapshot in sanity checks, which are
/// called ALL THE TIME.
pub fn assert_full_snapshot() {
assert_ok!(Snapshot::<Runtime>::ensure_snapshot(true, Pages::get()));
}
/// ensure that the no snapshot exists.
///
/// NOTE: this should not be used that often, because we check snapshot in sanity checks, which are
/// called ALL THE TIME.
pub fn assert_none_snapshot() {
assert_ok!(Snapshot::<Runtime>::ensure_snapshot(false, Pages::get()));
}
/// Simple wrapper for mining a new solution. Just more handy in case the interface of mine solution
/// changes.
///
/// For testing, we never want to do reduce.
pub fn mine_full_solution() -> Result<PagedRawSolution<Runtime>, OffchainMinerError<Runtime>> {
OffchainWorkerMiner::<Runtime>::mine_solution(Pages::get(), false)
}
/// Same as [`mine_full_solution`] but with custom pages.
pub fn mine_solution(
pages: PageIndex,
) -> Result<PagedRawSolution<Runtime>, OffchainMinerError<Runtime>> {
OffchainWorkerMiner::<Runtime>::mine_solution(pages, false)
}
/// Assert that `count` voters exist across `pages` number of pages.
pub fn ensure_voters(pages: PageIndex, count: usize) {
assert_eq!(crate::Snapshot::<Runtime>::voter_pages(), pages);
assert_eq!(crate::Snapshot::<Runtime>::voters_iter_flattened().count(), count);
}
/// Assert that `count` targets exist across `pages` number of pages.
pub fn ensure_targets(pages: PageIndex, count: usize) {
assert_eq!(crate::Snapshot::<Runtime>::target_pages(), pages);
assert_eq!(crate::Snapshot::<Runtime>::targets().unwrap().len(), count);
}
/// get the events of the multi-block pallet.
pub fn multi_block_events() -> Vec<crate::Event<Runtime>> {
System::events()
.into_iter()
.map(|r| r.event)
.filter_map(|e| if let RuntimeEvent::MultiBlock(inner) = e { Some(inner) } else { None })
.collect::<Vec<_>>()
}
parameter_types! {
static MultiBlockEvents: u32 = 0;
static VerifierEvents: u32 = 0;
}
pub fn multi_block_events_since_last_call() -> Vec<crate::Event<Runtime>> {
let events = multi_block_events();
let already_seen = MultiBlockEvents::get();
MultiBlockEvents::set(events.len() as u32);
events.into_iter().skip(already_seen as usize).collect()
}
/// get the events of the verifier pallet.
pub fn verifier_events() -> Vec<crate::verifier::Event<Runtime>> {
System::events()
.into_iter()
.map(|r| r.event)
.filter_map(
|e| if let RuntimeEvent::VerifierPallet(inner) = e { Some(inner) } else { None },
)
.collect::<Vec<_>>()
}
/// get the events of the verifier pallet since last call.
pub fn verifier_events_since_last_call() -> Vec<crate::verifier::Event<Runtime>> {
let events = verifier_events();
let already_seen = VerifierEvents::get();
VerifierEvents::set(events.len() as u32);
events.into_iter().skip(already_seen as usize).collect()
}
/// proceed block number to `n`.
pub fn roll_to(n: BlockNumber) {
crate::Pallet::<Runtime>::roll_to(
n,
matches!(SignedPhaseSwitch::get(), SignedSwitch::Real),
true,
);
}
/// proceed block number to whenever the snapshot is fully created (`Phase::Snapshot(0)`).
pub fn roll_to_snapshot_created() {
while !matches!(MultiBlock::current_phase(), Phase::Snapshot(0)) {
roll_next()
}
roll_next();
assert_full_snapshot();
}
/// proceed block number to whenever the unsigned phase is open (`Phase::Unsigned(_)`).
pub fn roll_to_unsigned_open() {
while !matches!(MultiBlock::current_phase(), Phase::Unsigned(_)) {
roll_next()
}
}
/// proceed block number to whenever the unsigned phase is about to close (`Phase::Unsigned(_)`).
pub fn roll_to_last_unsigned() {
while !matches!(MultiBlock::current_phase(), Phase::Unsigned(0)) {
roll_next()
}
}
/// proceed block number to whenever the signed phase is open (`Phase::Signed(_)`).
pub fn roll_to_signed_open() {
while !matches!(MultiBlock::current_phase(), Phase::Signed(_)) {
roll_next();
}
}
/// proceed block number to whenever the signed validation phase is open
/// (`Phase::SignedValidation(_)`).
pub fn roll_to_signed_validation_open() {
while !matches!(MultiBlock::current_phase(), Phase::SignedValidation(_)) {
roll_next()
}
}
/// proceed block number until we reach the done phase (`Phase::Done`).
pub fn roll_to_done() {
while !MultiBlock::current_phase().is_done() {
roll_next()
}
}
/// Proceed one block.
pub fn roll_next() {
let now = System::block_number();
roll_to(now + 1);
}
/// Proceed one block, and execute offchain workers as well.
pub fn roll_next_with_ocw(maybe_pool: Option<Arc<RwLock<PoolState>>>) {
roll_to_with_ocw(System::block_number() + 1, maybe_pool)
}
pub fn roll_to_unsigned_open_with_ocw(maybe_pool: Option<Arc<RwLock<PoolState>>>) {
while !matches!(MultiBlock::current_phase(), Phase::Unsigned(_)) {
roll_next_with_ocw(maybe_pool.clone());
}
}
/// proceed block number to `n`, while running all offchain workers as well.
pub fn roll_to_with_ocw(n: BlockNumber, maybe_pool: Option<Arc<RwLock<PoolState>>>) {
use pezsp_runtime::traits::Dispatchable;
let now = System::block_number();
for i in now + 1..=n {
// check the offchain transaction pool, and if anything's there, submit it.
if let Some(ref pool) = maybe_pool {
pool.read()
.transactions
.clone()
.into_iter()
.map(|uxt| <Extrinsic as codec::Decode>::decode(&mut &*uxt).unwrap())
.for_each(|xt| {
xt.function.dispatch(pezframe_system::RawOrigin::None.into()).unwrap();
});
pool.try_write().unwrap().transactions.clear();
}
System::set_block_number(i);
MultiBlock::on_initialize(i);
VerifierPallet::on_initialize(i);
UnsignedPallet::on_initialize(i);
if matches!(SignedPhaseSwitch::get(), SignedSwitch::Real) {
SignedPallet::on_initialize(i);
}
MultiBlock::offchain_worker(i);
VerifierPallet::offchain_worker(i);
UnsignedPallet::offchain_worker(i);
if matches!(SignedPhaseSwitch::get(), SignedSwitch::Real) {
SignedPallet::offchain_worker(i);
}
// invariants must hold at the end of each block.
all_pallets_sanity_checks()
}
}
/// An invalid solution with any score.
pub fn fake_solution(score: ElectionScore) -> PagedRawSolution<Runtime> {
PagedRawSolution {
score,
solution_pages: bounded_vec![Default::default()],
..Default::default()
}
}
/// A real solution that's valid, but has a really bad score.
///
/// This is different from `solution_from_supports` in that it does not require the snapshot to
/// exist.
pub fn raw_paged_solution_low_score() -> PagedRawSolution<Runtime> {
PagedRawSolution {
solution_pages: vec![TestNposSolution {
// 2 targets, both voting for themselves
votes1: vec![(0, 0), (1, 2)],
..Default::default()
}]
.try_into()
.unwrap(),
round: 0,
score: ElectionScore { minimal_stake: 10, sum_stake: 20, sum_stake_squared: 200 },
}
}
/// Get the free and held balance of `who`.
pub fn balances(who: AccountId) -> (Balance, Balance) {
(
Balances::free_balance(who),
Balances::balance_on_hold(&HoldReason::SignedSubmission.into(), &who),
)
}
/// Election bounds based on just the given count.
pub fn bound_by_count(count: Option<u32>) -> DataProviderBounds {
DataProviderBounds { count: count.map(|x| x.into()), size: None }
}
pub fn emergency_solution() -> (BoundedSupportsOf<MultiBlock>, ElectionScore) {
let supports = onchain::OnChainExecution::<Runtime>::elect(0).unwrap();
let score = supports.evaluate();
(supports, score)
}
@@ -0,0 +1,281 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use super::{Balance, Balances, Pages, Runtime, RuntimeEvent, SignedPallet, System};
use crate::{
mock::*,
signed::{self as signed_pallet, Event as SignedEvent, Submissions},
unsigned::miner::MinerConfig,
verifier::{self, AsynchronousVerifier, SolutionDataProvider, VerificationResult, Verifier},
Event, PadSolutionPages, PagedRawSolution, Pagify, Phase, SolutionOf,
};
use pezframe_election_provider_support::PageIndex;
use pezframe_support::{
assert_ok, dispatch::PostDispatchInfo, parameter_types, traits::EstimateCallFee,
};
use pezsp_npos_elections::ElectionScore;
use pezsp_runtime::{traits::Zero, Perbill};
parameter_types! {
pub static MockSignedNextSolution: Option<Vec<SolutionOf<Runtime>>> = None;
pub static MockSignedNextScore: ElectionScore = Default::default();
pub static MockSignedResults: Vec<VerificationResult> = Default::default();
}
/// A simple implementation of the signed phase that can be controller by some static variables
/// directly.
///
/// Useful for when you don't care too much about the signed phase.
#[allow(dead_code)]
pub struct MockSignedPhase;
impl SolutionDataProvider for MockSignedPhase {
type Solution = <Runtime as MinerConfig>::Solution;
fn get_page(page: PageIndex) -> Self::Solution {
MockSignedNextSolution::get()
.and_then(|i| i.get(page as usize).cloned())
.unwrap_or_default()
}
fn get_score() -> ElectionScore {
MockSignedNextScore::get()
}
fn report_result(result: verifier::VerificationResult) {
MOCK_SIGNED_RESULTS.with(|r| r.borrow_mut().push(result));
}
}
pub struct FixedCallFee;
impl EstimateCallFee<signed_pallet::Call<Runtime>, Balance> for FixedCallFee {
fn estimate_call_fee(_: &signed_pallet::Call<Runtime>, _: PostDispatchInfo) -> Balance {
1
}
}
parameter_types! {
pub static SignedDepositBase: Balance = 5;
pub static SignedDepositPerPage: Balance = 1;
pub static InvulnerableDeposit: Balance = 7;
pub static SignedMaxSubmissions: u32 = 3;
pub static SignedRewardBase: Balance = 3;
pub static SignedPhaseSwitch: SignedSwitch = SignedSwitch::Real;
pub static BailoutGraceRatio: Perbill = Perbill::from_percent(20);
pub static EjectGraceRatio: Perbill = Perbill::from_percent(20);
}
impl crate::signed::Config for Runtime {
type Currency = Balances;
type DepositBase = SignedDepositBase;
type DepositPerPage = SignedDepositPerPage;
type InvulnerableDeposit = InvulnerableDeposit;
type EstimateCallFee = FixedCallFee;
type MaxSubmissions = SignedMaxSubmissions;
type RewardBase = SignedRewardBase;
type BailoutGraceRatio = BailoutGraceRatio;
type EjectGraceRatio = EjectGraceRatio;
type WeightInfo = ();
}
/// Control which signed phase is being used.
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum SignedSwitch {
Mock,
Real,
}
pub struct DualSignedPhase;
impl SolutionDataProvider for DualSignedPhase {
type Solution = <Runtime as MinerConfig>::Solution;
fn get_page(page: PageIndex) -> Self::Solution {
match SignedPhaseSwitch::get() {
SignedSwitch::Mock => MockSignedNextSolution::get()
.and_then(|i| i.get(page as usize).cloned())
.unwrap_or_default(),
SignedSwitch::Real => SignedPallet::get_page(page),
}
}
fn get_score() -> ElectionScore {
match SignedPhaseSwitch::get() {
SignedSwitch::Mock => MockSignedNextScore::get(),
SignedSwitch::Real => SignedPallet::get_score(),
}
}
fn report_result(result: verifier::VerificationResult) {
match SignedPhaseSwitch::get() {
SignedSwitch::Mock => MOCK_SIGNED_RESULTS.with(|r| r.borrow_mut().push(result)),
SignedSwitch::Real => SignedPallet::report_result(result),
}
}
}
parameter_types! {
static SignedEventsIndex: u32 = 0;
}
pub fn signed_events_since_last_call() -> Vec<crate::signed::Event<Runtime>> {
let events = signed_events();
let already_seen = SignedEventsIndex::get();
SignedEventsIndex::set(events.len() as u32);
events.into_iter().skip(already_seen as usize).collect()
}
/// get the events of the verifier pallet.
pub fn signed_events() -> Vec<crate::signed::Event<Runtime>> {
System::events()
.into_iter()
.map(|r| r.event)
.filter_map(|e| if let RuntimeEvent::SignedPallet(inner) = e { Some(inner) } else { None })
.collect::<Vec<_>>()
}
/// Load a signed solution into its pallet.
pub fn load_signed_for_verification(who: AccountId, paged: PagedRawSolution<Runtime>) {
let initial_balance = Balances::free_balance(&who);
assert_eq!(balances(who), (initial_balance, 0));
assert_ok!(SignedPallet::register(RuntimeOrigin::signed(who), paged.score));
assert_eq!(
balances(who),
(initial_balance - SignedDepositBase::get(), SignedDepositBase::get())
);
for (page_index, solution_page) in paged.solution_pages.pagify(Pages::get()) {
assert_ok!(SignedPallet::submit_page(
RuntimeOrigin::signed(who),
page_index,
Some(Box::new(solution_page.clone()))
));
}
let mut events = signed_events();
for _ in 0..Pages::get() {
let event = events.pop().unwrap();
assert!(matches!(event, SignedEvent::Stored(_, x, _) if x == who))
}
assert!(matches!(events.pop().unwrap(), SignedEvent::Registered(_, x, _) if x == who));
let full_deposit =
SignedDepositBase::get() + (Pages::get() as Balance) * SignedDepositPerPage::get();
assert_eq!(balances(who), (initial_balance - full_deposit, full_deposit));
}
/// Same as [`load_signed_for_verification`], but also goes forward to the beginning of the signed
/// verification phase.
pub fn load_signed_for_verification_and_start(
who: AccountId,
paged: PagedRawSolution<Runtime>,
_round: u32,
) {
load_signed_for_verification(who, paged);
// now the solution should start being verified.
roll_to_signed_validation_open();
assert_eq!(
multi_block_events(),
vec![
Event::PhaseTransitioned { from: Phase::Off, to: Phase::Snapshot(3) },
Event::PhaseTransitioned {
from: Phase::Snapshot(0),
to: Phase::Signed(SignedPhase::get() - 1)
},
Event::PhaseTransitioned {
from: Phase::Signed(0),
to: Phase::SignedValidation(SignedValidationPhase::get())
}
]
);
assert_eq!(verifier_events(), vec![]);
}
/// Same as [`load_signed_for_verification_and_start`], but also goes forward enough blocks for the
/// solution to be verified, assuming it is all correct.
///
/// In other words, it goes [`Pages`] blocks forward.
pub fn load_signed_for_verification_and_start_and_roll_to_verified(
who: AccountId,
paged: PagedRawSolution<Runtime>,
_round: u32,
) {
load_signed_for_verification(who, paged.clone());
// now the solution should start being verified.
roll_to_signed_validation_open();
assert_eq!(
multi_block_events(),
vec![
Event::PhaseTransitioned { from: Phase::Off, to: Phase::Snapshot(Pages::get()) },
Event::PhaseTransitioned {
from: Phase::Snapshot(0),
to: Phase::Signed(SignedPhase::get() - 1)
},
Event::PhaseTransitioned {
from: Phase::Signed(0),
to: Phase::SignedValidation(SignedValidationPhase::get())
}
]
);
assert_eq!(verifier_events(), vec![]);
// there is no queued solution prior to the last page of the solution getting verified
assert_eq!(<Runtime as crate::Config>::Verifier::queued_score(), None);
// roll to the block it is finalized.
for _ in 0..Pages::get() + 1 {
roll_next();
}
assert_eq!(
verifier_events(),
vec![
// NOTE: these are hardcoded for 3 page.
verifier::Event::Verified(2, 2),
verifier::Event::Verified(1, 2),
verifier::Event::Verified(0, 2),
verifier::Event::Queued(paged.score, None),
]
);
// there is now a queued solution.
assert_eq!(<Runtime as crate::Config>::Verifier::queued_score(), Some(paged.score));
}
/// Load a full raw paged solution for verification.
///
/// More or less the equivalent of `load_signed_for_verification_and_start`, but when
/// `SignedSwitch::Mock` is set.
pub fn load_mock_signed_and_start(raw_paged: PagedRawSolution<Runtime>) {
assert_eq!(
SignedPhaseSwitch::get(),
SignedSwitch::Mock,
"you should not use this if mock phase is not being mocked"
);
MockSignedNextSolution::set(Some(raw_paged.solution_pages.pad_solution_pages(Pages::get())));
MockSignedNextScore::set(raw_paged.score);
// Let's gooooo!
assert_ok!(<VerifierPallet as AsynchronousVerifier>::start());
}
/// Ensure that no submission data exists in `round` for `who`.
pub fn assert_no_data_for(round: u32, who: AccountId) {
assert!(!Submissions::<Runtime>::leaderboard(round).into_iter().any(|(x, _)| x == who));
assert!(Submissions::<Runtime>::metadata_of(round, who).is_none());
assert!(Submissions::<Runtime>::pages_of(round, who).count().is_zero());
}
@@ -0,0 +1,244 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use super::{AccountId, MaxVotesPerVoter, Runtime};
use crate::VoterOf;
use pezframe_election_provider_support::{
data_provider, DataProviderBounds, ElectionDataProvider, PageIndex, VoteWeight,
};
use pezframe_support::pezpallet_prelude::*;
use pezsp_core::bounded_vec;
use pezsp_std::prelude::*;
pub type T = Runtime;
pezframe_support::parameter_types! {
pub static Targets: Vec<AccountId> = vec![10, 20, 30, 40];
pub static Voters: Vec<VoterOf<Runtime>> = vec![
// page 2:
(1, 10, bounded_vec![10, 20]),
(2, 10, bounded_vec![30, 40]),
(3, 10, bounded_vec![40]),
(4, 10, bounded_vec![10, 20, 40]),
// page 1:
(5, 10, bounded_vec![10, 30, 40]),
(6, 10, bounded_vec![20, 30, 40]),
(7, 10, bounded_vec![20, 30]),
(8, 10, bounded_vec![10]),
// page 0: (self-votes)
(10, 10, bounded_vec![10]),
(20, 20, bounded_vec![20]),
(30, 30, bounded_vec![30]),
(40, 40, bounded_vec![40]),
];
pub static DesiredTargets: u32 = 2;
pub static EpochLength: u64 = 30;
pub static LastIteratedVoterIndex: Option<usize> = None;
}
pub struct MockStaking;
impl ElectionDataProvider for MockStaking {
type AccountId = AccountId;
type BlockNumber = u64;
type MaxVotesPerVoter = MaxVotesPerVoter;
fn electable_targets(
bounds: DataProviderBounds,
remaining: PageIndex,
) -> data_provider::Result<Vec<AccountId>> {
let targets = Targets::get();
if remaining != 0 {
crate::log!(
warn,
"requesting targets for non-zero page, we will return the same page in any case"
);
}
if bounds.slice_exhausted(&targets) {
return Err("Targets too big");
}
Ok(targets)
}
fn electing_voters(
bounds: DataProviderBounds,
remaining: PageIndex,
) -> data_provider::Result<
Vec<(AccountId, VoteWeight, BoundedVec<AccountId, Self::MaxVotesPerVoter>)>,
> {
let mut voters = Voters::get();
// jump to the first non-iterated, if this is a follow up.
if let Some(index) = LastIteratedVoterIndex::get() {
voters = voters.iter().skip(index).cloned().collect::<Vec<_>>();
}
// take as many as you can.
if let Some(max_len) = bounds.count.map(|c| c.0 as usize) {
voters.truncate(max_len)
}
if voters.is_empty() {
return Ok(vec![]);
}
if remaining > 0 {
let last = voters.last().cloned().unwrap();
LastIteratedVoterIndex::set(Some(
Voters::get().iter().position(|v| v == &last).map(|i| i + 1).unwrap(),
));
} else {
LastIteratedVoterIndex::set(None)
}
Ok(voters)
}
fn desired_targets() -> data_provider::Result<u32> {
Ok(DesiredTargets::get())
}
fn next_election_prediction(_: u64) -> u64 {
unreachable!("not used in this pallet")
}
#[cfg(feature = "runtime-benchmarks")]
fn put_snapshot(
voters: Vec<(AccountId, VoteWeight, BoundedVec<AccountId, MaxVotesPerVoter>)>,
targets: Vec<AccountId>,
_target_stake: Option<VoteWeight>,
) {
Targets::set(targets);
Voters::set(voters);
}
#[cfg(feature = "runtime-benchmarks")]
fn clear() {
Targets::set(vec![]);
Voters::set(vec![]);
}
#[cfg(feature = "runtime-benchmarks")]
fn fetch_page(page: PageIndex) {
use pezframe_election_provider_support::ElectionProvider;
super::MultiBlock::elect(page).unwrap();
}
#[cfg(feature = "runtime-benchmarks")]
fn add_voter(
voter: AccountId,
weight: VoteWeight,
targets: BoundedVec<AccountId, MaxVotesPerVoter>,
) {
let mut current = Voters::get();
current.push((voter, weight, targets));
Voters::set(current);
}
#[cfg(feature = "runtime-benchmarks")]
fn add_target(target: AccountId) {
use super::ExistentialDeposit;
let mut current = Targets::get();
current.push(target);
Targets::set(current);
// to be on-par with staking, we add a self vote as well. the stake is really not that
// important.
let mut current = Voters::get();
current.push((target, ExistentialDeposit::get() as u64, vec![target].try_into().unwrap()));
Voters::set(current);
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::mock::{bound_by_count, ExtBuilder};
#[test]
fn targets() {
ExtBuilder::full().build_and_execute(|| {
assert_eq!(Targets::get().len(), 4);
// any non-zero page returns page zero.
assert_eq!(MockStaking::electable_targets(bound_by_count(None), 2).unwrap().len(), 4);
assert_eq!(MockStaking::electable_targets(bound_by_count(None), 1).unwrap().len(), 4);
// 0 is also fine.
assert_eq!(MockStaking::electable_targets(bound_by_count(None), 0).unwrap().len(), 4);
// fetch less targets is error, because targets cannot be sorted (both by MockStaking,
// and the real staking).
assert!(MockStaking::electable_targets(bound_by_count(Some(2)), 0).is_err());
// more targets is fine.
assert!(MockStaking::electable_targets(bound_by_count(Some(4)), 0).is_ok());
assert!(MockStaking::electable_targets(bound_by_count(Some(5)), 0).is_ok());
});
}
#[test]
fn multi_page_votes() {
ExtBuilder::full().build_and_execute(|| {
assert_eq!(MockStaking::electing_voters(bound_by_count(None), 0).unwrap().len(), 12);
assert!(LastIteratedVoterIndex::get().is_none());
assert_eq!(
MockStaking::electing_voters(bound_by_count(Some(4)), 0)
.unwrap()
.into_iter()
.map(|(x, _, _)| x)
.collect::<Vec<_>>(),
vec![1, 2, 3, 4],
);
assert!(LastIteratedVoterIndex::get().is_none());
assert_eq!(
MockStaking::electing_voters(bound_by_count(Some(4)), 2)
.unwrap()
.into_iter()
.map(|(x, _, _)| x)
.collect::<Vec<_>>(),
vec![1, 2, 3, 4],
);
assert_eq!(LastIteratedVoterIndex::get().unwrap(), 4);
assert_eq!(
MockStaking::electing_voters(bound_by_count(Some(4)), 1)
.unwrap()
.into_iter()
.map(|(x, _, _)| x)
.collect::<Vec<_>>(),
vec![5, 6, 7, 8],
);
assert_eq!(LastIteratedVoterIndex::get().unwrap(), 8);
assert_eq!(
MockStaking::electing_voters(bound_by_count(Some(4)), 0)
.unwrap()
.into_iter()
.map(|(x, _, _)| x)
.collect::<Vec<_>>(),
vec![10, 20, 30, 40],
);
assert!(LastIteratedVoterIndex::get().is_none());
})
}
}
@@ -0,0 +1,206 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{
signed::{Config, Pallet, Submissions},
types::PagedRawSolution,
unsigned::miner::OffchainWorkerMiner,
CurrentPhase, Phase, Round,
};
use pezframe_benchmarking::v2::*;
use pezframe_election_provider_support::ElectionProvider;
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::RawOrigin;
use pezsp_npos_elections::ElectionScore;
use pezsp_runtime::traits::One;
use pezsp_std::boxed::Box;
#[benchmarks(where T: crate::Config + crate::verifier::Config + crate::unsigned::Config)]
mod benchmarks {
use super::*;
#[benchmark(pov_mode = Measured)]
fn register_not_full() -> Result<(), BenchmarkError> {
CurrentPhase::<T>::put(Phase::Signed(T::SignedPhase::get() - One::one()));
let round = Round::<T>::get();
let alice = crate::Pallet::<T>::funded_account("alice", 0);
let score = ElectionScore::default();
assert_eq!(Submissions::<T>::sorted_submitters(round).len(), 0);
#[block]
{
Pallet::<T>::register(RawOrigin::Signed(alice).into(), score)?;
}
assert_eq!(Submissions::<T>::sorted_submitters(round).len(), 1);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn register_eject() -> Result<(), BenchmarkError> {
CurrentPhase::<T>::put(Phase::Signed(T::SignedPhase::get() - One::one()));
let round = Round::<T>::get();
for i in 0..T::MaxSubmissions::get() {
let submitter = crate::Pallet::<T>::funded_account("submitter", i);
let score = ElectionScore { minimal_stake: i.into(), ..Default::default() };
Pallet::<T>::register(RawOrigin::Signed(submitter.clone()).into(), score)?;
// The first one, which will be ejected, has also submitted all pages
if i == 0 {
for p in 0..T::Pages::get() {
let page = Some(Default::default());
Pallet::<T>::submit_page(RawOrigin::Signed(submitter.clone()).into(), p, page)?;
}
}
}
let who = crate::Pallet::<T>::funded_account("who", 0);
let score =
ElectionScore { minimal_stake: T::MaxSubmissions::get().into(), ..Default::default() };
assert_eq!(
Submissions::<T>::sorted_submitters(round).len(),
T::MaxSubmissions::get() as usize
);
#[block]
{
Pallet::<T>::register(RawOrigin::Signed(who).into(), score)?;
}
assert_eq!(
Submissions::<T>::sorted_submitters(round).len(),
T::MaxSubmissions::get() as usize
);
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn submit_page() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Signed(_))
});
// mine a full solution
let PagedRawSolution { score, solution_pages, .. } =
OffchainWorkerMiner::<T>::mine_solution(T::Pages::get(), false).unwrap();
let page = Some(Box::new(solution_pages[0].clone()));
// register alice
let alice = crate::Pallet::<T>::funded_account("alice", 0);
Pallet::<T>::register(RawOrigin::Signed(alice.clone()).into(), score)?;
#[block]
{
Pallet::<T>::submit_page(RawOrigin::Signed(alice).into(), 0, page)?;
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn unset_page() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Signed(_))
});
// mine a full solution
let PagedRawSolution { score, solution_pages, .. } =
OffchainWorkerMiner::<T>::mine_solution(T::Pages::get(), false).unwrap();
let page = Some(Box::new(solution_pages[0].clone()));
// register alice
let alice = crate::Pallet::<T>::funded_account("alice", 0);
Pallet::<T>::register(RawOrigin::Signed(alice.clone()).into(), score)?;
// submit page
Pallet::<T>::submit_page(RawOrigin::Signed(alice.clone()).into(), 0, page)?;
#[block]
{
Pallet::<T>::submit_page(RawOrigin::Signed(alice).into(), 0, None)?;
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn bail() -> Result<(), BenchmarkError> {
CurrentPhase::<T>::put(Phase::Signed(T::SignedPhase::get() - One::one()));
let alice = crate::Pallet::<T>::funded_account("alice", 0);
// register alice
let score = ElectionScore::default();
Pallet::<T>::register(RawOrigin::Signed(alice.clone()).into(), score)?;
// submit all pages
for p in 0..T::Pages::get() {
let page = Some(Default::default());
Pallet::<T>::submit_page(RawOrigin::Signed(alice.clone()).into(), p, page)?;
}
#[block]
{
Pallet::<T>::bail(RawOrigin::Signed(alice).into())?;
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn clear_old_round_data(p: Linear<1, { T::Pages::get() }>) -> Result<(), BenchmarkError> {
// set signed phase and alice ready to submit
CurrentPhase::<T>::put(Phase::Signed(T::SignedPhase::get() - One::one()));
let alice = crate::Pallet::<T>::funded_account("alice", 0);
// register alice
let score = ElectionScore::default();
Pallet::<T>::register(RawOrigin::Signed(alice.clone()).into(), score)?;
// submit a solution with p pages.
for pp in 0..p {
let page = Some(Default::default());
Pallet::<T>::submit_page(RawOrigin::Signed(alice.clone()).into(), pp, page)?;
}
// force rotate to the next round.
let prev_round = Round::<T>::get();
crate::Pallet::<T>::rotate_round();
#[block]
{
Pallet::<T>::clear_old_round_data(RawOrigin::Signed(alice).into(), prev_round, p)?;
}
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::ExtBuilder::signed().build_unchecked(),
crate::mock::Runtime
);
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,89 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{{header}}
//! Autogenerated weights for `{{pallet}}`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION {{version}}
//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}`
//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}`
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
//! WASM-EXECUTION: `{{cmd.wasm_execution}}`, CHAIN: `{{cmd.chain}}`, DB CACHE: `{{cmd.db_cache}}`
// Executed Command:
{{#each args as |arg|}}
// {{arg}}
{{/each}}
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `{{pallet}}`.
pub struct WeightInfo<T>(PhantomData<T>);
{{#if (or (eq pallet "frame_system") (eq pallet "frame_system_extensions"))}}
impl<T: crate::Config> WeightInfo for WeightInfo<T> {
{{else}}
impl<T: frame_system::Config> crate::weights::traits::{{pallet}}::WeightInfo for WeightInfo<T> {
{{/if}}
{{#each benchmarks as |benchmark|}}
{{#each benchmark.comments as |comment|}}
/// {{comment}}
{{/each}}
{{#each benchmark.component_ranges as |range|}}
/// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`.
{{/each}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}}
) -> Weight {
// Proof Size summary in bytes:
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}})
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
}
@@ -0,0 +1,452 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Common types and traits of the EPMB pallet group.
//!
//! ## [`SolutionOf`]
//!
//! This type is among the most cryptic used in the EPMB pallet. The origins of this type go back to
//! the fact that sending a solution, with hundreds or thousands of account-ids in it would be too
//! large for a chain to handle. This was particularly the case in a single page solution, as
//! developed in `election-provider-multi-phase`. To combat this, a "compact" custom type is
//! generated to encapsulate a solution. This type is generated by
//! [`pezframe_election_provider_support::generate_solution_type`]. See the documentation of this macro
//! for more information about the hacks used to reduce the size of the solution.
//!
//! Consequently, the [`SolutionVoterIndexOf`] and [`SolutionTargetIndexOf`] and
//! [`SolutionAccuracyOf`] are derived from this type.
//!
//! ## [`Phase`]
//!
//! This is the most important type of this pallet, demonstrating the state-machine used
//! to manage the election process and its various phases.
use crate::{unsigned::miner::MinerConfig, verifier};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use pezframe_election_provider_support::ElectionProvider;
pub use pezframe_election_provider_support::{NposSolution, PageIndex};
use pezframe_support::{
traits::DefensiveSaturating, BoundedVec, CloneNoBound, DebugNoBound, DefaultNoBound, EqNoBound,
PartialEqNoBound,
};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
use scale_info::TypeInfo;
use pezsp_core::Get;
pub use pezsp_npos_elections::{ElectionResult, ElectionScore};
use pezsp_runtime::{
traits::{CheckedSub, One, Zero},
SaturatedConversion, Saturating,
};
use pezsp_std::{collections::btree_set::BTreeSet, fmt::Debug, prelude::*};
/// The solution type used by this crate.
pub type SolutionOf<T> = <T as MinerConfig>::Solution;
/// The voter index. Derived from [`SolutionOf`].
pub type SolutionVoterIndexOf<T> = <SolutionOf<T> as NposSolution>::VoterIndex;
/// The target index. Derived from [`SolutionOf`].
pub type SolutionTargetIndexOf<T> = <SolutionOf<T> as NposSolution>::TargetIndex;
/// The accuracy of the election, when submitted from offchain. Derived from [`SolutionOf`].
pub type SolutionAccuracyOf<T> = <SolutionOf<T> as NposSolution>::Accuracy;
/// The fallback election type.
pub type FallbackErrorOf<T> = <<T as crate::Config>::Fallback as ElectionProvider>::Error;
/// The relative distribution of a voter's stake among the winning targets.
pub type AssignmentOf<T> =
pezsp_npos_elections::Assignment<<T as MinerConfig>::AccountId, SolutionAccuracyOf<T>>;
/// A paginated raw solution type.
///
/// This is the representation of a stored, unverified solution.
///
/// After feasibility, it is converted into `Supports`.
#[derive(
TypeInfo,
Encode,
Decode,
DecodeWithMemTracking,
DebugNoBound,
CloneNoBound,
EqNoBound,
PartialEqNoBound,
DefaultNoBound,
)]
#[codec(mel_bound(T: crate::Config))]
#[scale_info(skip_type_params(T))]
pub struct PagedRawSolution<T: MinerConfig> {
/// The individual pages.
pub solution_pages: Vec<SolutionOf<T>>,
/// The final claimed score post feasibility and concatenation of all pages.
pub score: ElectionScore,
/// The designated round.
pub round: u32,
}
impl<T: MinerConfig> PagedRawSolution<T> {
/// Get the total number of voters, assuming that voters in each page are unique.
pub fn voter_count(&self) -> usize {
self.solution_pages
.iter()
.map(|page| page.voter_count())
.fold(0usize, |acc, x| acc.saturating_add(x))
}
/// Get the total number of winners, assuming that there's only a single page of targets.
pub fn winner_count_single_page_target_snapshot(&self) -> usize {
self.solution_pages
.iter()
.map(|page| page.unique_targets())
.into_iter()
.flatten()
.collect::<BTreeSet<_>>()
.len()
}
/// Get the total number of edges.
pub fn edge_count(&self) -> usize {
self.solution_pages
.iter()
.map(|page| page.edge_count())
.fold(0usize, |acc, x| acc.saturating_add(x))
}
}
/// A helper trait to deal with the page index of partial solutions.
///
/// This should only be called on the `Vec<Solution>` or similar types. If the solution is *full*,
/// then it returns a normal iterator that is just mapping the index (usize) to `PageIndex`.
///
/// if the solution is partial, it shifts the indices sufficiently so that the most significant page
/// of the solution matches with the most significant page of the snapshot onchain.
///
/// See the tests below for examples.
pub trait Pagify<T> {
/// Pagify a reference.
fn pagify(&self, bound: PageIndex) -> Box<dyn Iterator<Item = (PageIndex, &T)> + '_>;
}
impl<T> Pagify<T> for Vec<T> {
fn pagify(&self, desired_pages: PageIndex) -> Box<dyn Iterator<Item = (PageIndex, &T)> + '_> {
Box::new(
self.into_iter()
.enumerate()
.map(|(p, s)| (p.saturated_into::<PageIndex>(), s))
.map(move |(p, s)| {
let desired_pages_usize = desired_pages as usize;
// TODO: this could be an error.
debug_assert!(self.len() <= desired_pages_usize);
let padding = desired_pages_usize.saturating_sub(self.len());
let new_page = p.saturating_add(padding.saturated_into::<PageIndex>());
(new_page, s)
}),
)
}
}
/// Helper trait to pad a partial solution such that the leftover pages are filled with zero.
///
/// See the tests below for examples.
pub trait PadSolutionPages: Sized {
/// Pad the solution to the given number of pages.
fn pad_solution_pages(self, desired_pages: PageIndex) -> Self;
}
impl<T: Default + Clone + Debug> PadSolutionPages for Vec<T> {
fn pad_solution_pages(self, desired_pages: PageIndex) -> Self {
let desired_pages_usize = desired_pages as usize;
debug_assert!(self.len() <= desired_pages_usize);
if self.len() == desired_pages_usize {
return self;
}
// we basically need to prepend the list with this many items.
let empty_slots = desired_pages_usize.saturating_sub(self.len());
pezsp_std::iter::repeat(Default::default())
.take(empty_slots)
.chain(self.into_iter())
.collect::<Vec<_>>()
}
}
impl<T: Default + Clone + Debug, Bound: pezframe_support::traits::Get<u32>> PadSolutionPages
for BoundedVec<T, Bound>
{
fn pad_solution_pages(self, desired_pages: PageIndex) -> Self {
let desired_pages_usize = (desired_pages).min(Bound::get()) as usize;
debug_assert!(self.len() <= desired_pages_usize);
if self.len() == desired_pages_usize {
return self;
}
// we basically need to prepend the list with this many items.
let empty_slots = desired_pages_usize.saturating_sub(self.len());
let self_as_vec = pezsp_std::iter::repeat(Default::default())
.take(empty_slots)
.chain(self.into_iter())
.collect::<Vec<_>>();
self_as_vec.try_into().expect("sum of both iterators has at most `desired_pages_usize` items; `desired_pages_usize` is `min`-ed by `Bound`; conversion cannot fail; qed")
}
}
/// Alias for a voter, parameterized by the miner config.
pub type VoterOf<T> = pezframe_election_provider_support::Voter<
<T as MinerConfig>::AccountId,
<T as MinerConfig>::MaxVotesPerVoter,
>;
/// Alias for a page of voters, parameterized by this crate's config.
pub type VoterPageOf<T> = BoundedVec<VoterOf<T>, <T as MinerConfig>::VoterSnapshotPerBlock>;
/// Alias for all pages of voters, parameterized by this crate's config.
pub type AllVoterPagesOf<T> = BoundedVec<VoterPageOf<T>, <T as MinerConfig>::Pages>;
/// Maximum number of items that [`AllVoterPagesOf`] can contain, when flattened.
pub struct MaxFlattenedVoters<T: MinerConfig>(pezsp_std::marker::PhantomData<T>);
impl<T: MinerConfig> Get<u32> for MaxFlattenedVoters<T> {
fn get() -> u32 {
T::VoterSnapshotPerBlock::get().saturating_mul(T::Pages::get())
}
}
/// Same as [`AllVoterPagesOf`], but instead of being a nested bounded vec, the entire voters are
/// flattened into one outer, unbounded `Vec` type.
///
/// This is bounded by [`MaxFlattenedVoters`].
pub type AllVoterPagesFlattenedOf<T> = BoundedVec<VoterOf<T>, MaxFlattenedVoters<T>>;
/// Current phase of the pallet.
#[derive(
PartialEqNoBound,
EqNoBound,
CloneNoBound,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
DebugNoBound,
TypeInfo,
)]
#[codec(mel_bound(T: crate::Config))]
#[scale_info(skip_type_params(T))]
pub enum Phase<T: crate::Config> {
/// Nothing is happening, but it might.
Off,
/// Signed phase is open.
///
/// The inner value is the number of blocks left in this phase.
Signed(BlockNumberFor<T>),
/// We are validating results.
///
/// This always follows the signed phase, and is a window of time in which we try to validate
/// our signed results.
///
/// The inner value is the number of blocks left in this phase.
SignedValidation(BlockNumberFor<T>),
/// Unsigned phase.
///
/// The inner value is the number of blocks left in this phase.
///
/// We do not yet check whether the unsigned phase is active or passive. The intent is for the
/// blockchain to be able to declare: "I believe that there exists an adequate signed
/// solution," advising validators not to bother running the unsigned offchain worker.
///
/// As validator nodes are free to edit their OCW code, they could simply ignore this advisory
/// and always compute their own solution. However, by default, when the unsigned phase is
/// passive, the offchain workers will not bother running.
Unsigned(BlockNumberFor<T>),
/// Snapshot is being created. No other operation is allowed. This can be one or more blocks.
/// The inner value should be read as "`remaining` number of pages are left to be fetched".
/// Thus, if inner value is `0` if the snapshot is complete and we are ready to move on.
///
/// This value should be interpreted after `on_initialize` of this pallet has already been
/// called.
Snapshot(PageIndex),
/// Snapshot is done, and we are waiting for `Export` to kick in.
Done,
/// Exporting has begun, and the given page was the last one received.
///
/// Once this is active, no more signed or solutions will be accepted.
Export(PageIndex),
/// The emergency phase. This is could be enabled by one of the fallbacks, and locks the pallet
/// such that only governance can change the state.
Emergency,
}
impl<T: crate::Config> Copy for Phase<T> {}
impl<T: crate::Config> Default for Phase<T> {
fn default() -> Self {
Phase::Off
}
}
impl<T: crate::Config> Phase<T> {
/// Get the phase that we should set in storage once we receive the start signal.
pub(crate) fn start_phase() -> Self {
// note that we add one block because we want the target snapshot to happen one block
// before.
Self::Snapshot(T::Pages::get())
}
fn are_we_done() -> Self {
let query = T::AreWeDone::get();
query
}
/// A hack to make sure we don't finish the signed verification phase just yet if the status is
/// not yet set back to `Nothing`.
fn verifier_done() -> bool {
matches!(
<T::Verifier as verifier::AsynchronousVerifier>::status(),
verifier::Status::Nothing
)
}
/// Consume self and return the next variant, as per what the current phase is.
pub fn next(self) -> Self {
match self {
// for these phases, we do nothing.
Self::Off => Self::Off,
Self::Emergency => Self::Emergency,
// snapshot phase
Self::Snapshot(0) => {
if let Some(signed_duration) = T::SignedPhase::get().checked_sub(&One::one()) {
Self::Signed(signed_duration)
} else if let Some(unsigned_duration) =
T::UnsignedPhase::get().checked_sub(&One::one())
{
Self::Unsigned(unsigned_duration)
} else {
Self::are_we_done()
}
},
Self::Snapshot(non_zero_remaining) =>
Self::Snapshot(non_zero_remaining.defensive_saturating_sub(One::one())),
// signed phase
Self::Signed(zero) if zero == BlockNumberFor::<T>::zero() =>
Self::SignedValidation(T::SignedValidationPhase::get()),
Self::Signed(non_zero_left) =>
Self::Signed(non_zero_left.defensive_saturating_sub(One::one())),
// signed validation
Self::SignedValidation(zero)
if zero == BlockNumberFor::<T>::zero() && Self::verifier_done() =>
{
if let Some(unsigned_duration) = T::UnsignedPhase::get().checked_sub(&One::one()) {
Self::Unsigned(unsigned_duration)
} else {
Self::are_we_done()
}
},
Self::SignedValidation(non_zero_left) =>
Self::SignedValidation(non_zero_left.saturating_sub(One::one())),
// unsigned phase -- at this phase we will
Self::Unsigned(zero) if zero == BlockNumberFor::<T>::zero() => Self::are_we_done(),
Self::Unsigned(non_zero_left) =>
Self::Unsigned(non_zero_left.defensive_saturating_sub(One::one())),
// Done. Wait for export to start.
Self::Done => Self::Done,
// Export
Self::Export(0) => Self::Off,
Self::Export(non_zero_left) =>
Self::Export(non_zero_left.defensive_saturating_sub(One::one())),
}
}
/// Whether the phase is emergency or not.
pub fn is_emergency(&self) -> bool {
matches!(self, Phase::Emergency)
}
/// Whether the phase is signed or not.
pub fn is_signed(&self) -> bool {
matches!(self, Phase::Signed(_))
}
/// Whether the phase is unsigned or not.
pub fn is_unsigned(&self) -> bool {
matches!(self, Phase::Unsigned(_))
}
/// Whether the phase is off or not.
pub fn is_off(&self) -> bool {
matches!(self, Phase::Off)
}
/// Whether the phase is snapshot or not.
pub fn is_snapshot(&self) -> bool {
matches!(self, Phase::Snapshot(_))
}
/// Whether the phase is done or not.
pub fn is_done(&self) -> bool {
matches!(self, Phase::Done)
}
/// Whether the phase is export or not.
pub fn is_export(&self) -> bool {
matches!(self, Phase::Export(_))
}
/// Whether the phase is signed validation or not.
pub fn is_signed_validation(&self) -> bool {
matches!(self, Phase::SignedValidation(_))
}
/// Whether the signed phase is opened now.
pub fn is_signed_validation_opened_now(&self) -> bool {
self == &Phase::SignedValidation(T::SignedValidationPhase::get().saturating_sub(One::one()))
}
/// Whether the unsigned phase is opened now.
pub fn is_unsigned_opened_now(&self) -> bool {
self == &Phase::Unsigned(T::UnsignedPhase::get().saturating_sub(One::one()))
}
}
#[cfg(test)]
mod pagify {
use super::{PadSolutionPages, Pagify};
#[test]
fn pagify_works() {
// is a noop when you have the same length
assert_eq!(
vec![10, 11, 12].pagify(3).collect::<Vec<_>>(),
vec![(0, &10), (1, &11), (2, &12)]
);
// pads the values otherwise
assert_eq!(vec![10, 11].pagify(3).collect::<Vec<_>>(), vec![(1, &10), (2, &11)]);
assert_eq!(vec![10].pagify(3).collect::<Vec<_>>(), vec![(2, &10)]);
}
#[test]
fn pad_solution_pages_works() {
// noop if the solution is complete, as with pagify.
let solution = vec![1u32, 2, 3];
assert_eq!(solution.pad_solution_pages(3), vec![1, 2, 3]);
// pads the solution with default if partial..
let solution = vec![2, 3];
assert_eq!(solution.pad_solution_pages(3), vec![0, 2, 3]);
}
}
@@ -0,0 +1,104 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{
unsigned::{miner::OffchainWorkerMiner, Call, Config, Pallet},
verifier::Verifier,
CurrentPhase, Phase,
};
use pezframe_benchmarking::v2::*;
use pezframe_election_provider_support::ElectionProvider;
use pezframe_support::{assert_ok, pezpallet_prelude::*};
use pezframe_system::RawOrigin;
use pezsp_std::boxed::Box;
#[benchmarks(where T: crate::Config + crate::signed::Config + crate::verifier::Config)]
mod benchmarks {
use super::*;
#[benchmark(pov_mode = Measured)]
fn validate_unsigned() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
let call: Call<T> = OffchainWorkerMiner::<T>::mine_solution(T::MinerPages::get(), false)
.map(|solution| Call::submit_unsigned { paged_solution: Box::new(solution) })
.unwrap();
#[block]
{
assert_ok!(Pallet::<T>::validate_unsigned(TransactionSource::Local, &call));
}
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn submit_unsigned() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to unsigned phase open
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
// TODO: we need to better ensure that this is actually worst case
let solution =
OffchainWorkerMiner::<T>::mine_solution(T::MinerPages::get(), false).unwrap();
// nothing is queued
assert!(T::Verifier::queued_score().is_none());
#[block]
{
assert_ok!(Pallet::<T>::submit_unsigned(RawOrigin::None.into(), Box::new(solution)));
}
// something is queued
assert!(T::Verifier::queued_score().is_some());
Ok(())
}
#[benchmark(extra, pov_mode = Measured)]
fn mine_solution(p: Linear<1, { T::Pages::get() }>) -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to unsigned phase open
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::Unsigned(_))
});
#[block]
{
OffchainWorkerMiner::<T>::mine_solution(p, true).unwrap();
}
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::ExtBuilder::full().build_unchecked(),
crate::mock::Runtime
);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,648 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! ## The unsigned phase, and its miner.
//!
//! This pallet deals with unsigned submissions. These are backup, "possibly" multi-page submissions
//! from validators.
//!
//! This pallet has two miners, described in [`unsigned::miner`].
//!
//! As it stands, a validator can, during the unsigned phase, submit up to
//! [`unsigned::Config::MinerPages`] pages. While this can be more than 1, it can likely not be a
//! full, high quality solution. This is because unsigned validator solutions are verified on the
//! fly, all within a single block. The exact value of this parameter should be determined by the
//! benchmarks of a runtime.
//!
//! We could implement a protocol to allow multi-block, multi-page collaborative submissions from
//! different validators, but it is not trivial. Moreover, recall that the unsigned phase is merely
//! a backup and we should primarily rely on offchain staking miners to fulfill this role during
//! `Phase::Signed`.
//!
//! ## Future Idea: Multi-Page unsigned submission
//!
//! the following is the idea of how to implement multi-page unsigned, which we don't have.
//!
//! All validators will run their miners and compute the full paginated solution. They submit all
//! pages as individual unsigned transactions to their local tx-pool.
//!
//! Upon validation, if any page is now present the corresponding transaction is dropped.
//!
//! At each block, the first page that may be valid is included as a high priority operational
//! transaction. This page is validated on the fly to be correct. Since this transaction is sourced
//! from a validator, we can panic if they submit an invalid transaction.
//!
//! Then, once the final page is submitted, some extra checks are done, as explained in
//! [`crate::verifier`]:
//!
//! 1. bounds
//! 2. total score
//!
//! These checks might still fail. If they do, the solution is dropped. At this point, we don't know
//! which validator may have submitted a slightly-faulty solution.
//!
//! In order to prevent this, the transaction validation process always includes a check to ensure
//! all of the previous pages that have been submitted match what the local validator has computed.
//! If they match, the validator knows that they are putting skin in a game that is valid.
//!
//! If any bad paged are detected, the next validator can bail. This process means:
//!
//! * As long as all validators are honest, and run the same miner code, a correct solution is
//! found.
//! * As little as one malicious validator can stall the process, but no one is accidentally
//! slashed, and no panic happens.
//!
//! Alternatively, we can keep track of submitters, and report a slash if it occurs. Or, if
//! the signed process is bullet-proof, we can be okay with the status quo.
/// Export weights
pub use crate::weights::traits::pezpallet_election_provider_multi_block_unsigned::*;
/// Exports of this pallet
pub use pallet::*;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
/// The miner.
pub mod miner;
#[pezframe_support::pallet]
mod pallet {
use super::WeightInfo;
use crate::{
types::*,
unsigned::miner::{self},
verifier::Verifier,
CommonError,
};
use pezframe_support::pezpallet_prelude::*;
use pezframe_system::{offchain::CreateBare, pezpallet_prelude::*};
use pezsp_runtime::traits::SaturatedConversion;
use pezsp_std::prelude::*;
/// convert a [`crate::CommonError`] to a custom InvalidTransaction with the inner code being
/// the index of the variant.
fn base_error_to_invalid(error: CommonError) -> InvalidTransaction {
let index = error.encode().pop().unwrap_or(0);
InvalidTransaction::Custom(index)
}
pub(crate) type UnsignedWeightsOf<T> = <T as Config>::WeightInfo;
#[pallet::config]
#[pallet::disable_pezframe_system_supertrait_check]
pub trait Config: crate::Config + CreateBare<Call<Self>> {
/// The repeat threshold of the offchain worker.
///
/// For example, if it is `5`, that means that at least 5 blocks will elapse between
/// attempts to submit the worker's solution.
type OffchainRepeat: Get<BlockNumberFor<Self>>;
/// The solver used in hte offchain worker miner
type OffchainSolver: pezframe_election_provider_support::NposSolver<
AccountId = Self::AccountId,
>;
/// Whether the offchain worker miner would attempt to store the solutions in a local
/// database and reuse then. If set to `false`, it will try and re-mine solutions every
/// time.
type OffchainStorage: Get<bool>;
/// The priority of the unsigned transaction submitted in the unsigned-phase
type MinerTxPriority: Get<TransactionPriority>;
/// The number of pages that the offchain miner will try and submit.
type MinerPages: Get<PageIndex>;
/// Runtime weight information of this pallet.
type WeightInfo: WeightInfo;
}
#[pallet::pallet]
pub struct Pallet<T>(PhantomData<T>);
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Submit an unsigned solution.
///
/// This works very much like an inherent, as only the validators are permitted to submit
/// anything. By default validators will compute this call in their `offchain_worker` hook
/// and try and submit it back.
///
/// This is different from signed page submission mainly in that the solution page is
/// verified on the fly.
///
/// The `paged_solution` may contain at most [`Config::MinerPages`] pages. They are
/// interpreted as msp -> lsp, as per [`crate::Pallet::msp_range_for`].
///
/// For example, if `Pages = 4`, and `MinerPages = 2`, our full snapshot range would be [0,
/// 1, 2, 3], with 3 being msp. But, in this case, then the `paged_raw_solution.pages` is
/// expected to correspond to `[snapshot(2), snapshot(3)]`.
#[pallet::weight((UnsignedWeightsOf::<T>::submit_unsigned(), DispatchClass::Operational))]
#[pallet::call_index(0)]
pub fn submit_unsigned(
origin: OriginFor<T>,
paged_solution: Box<PagedRawSolution<T::MinerConfig>>,
) -> DispatchResultWithPostInfo {
ensure_none(origin)?;
let error_message = "Invalid unsigned submission must produce invalid block and \
deprive validator from their authoring reward.";
// phase, round, claimed score, page-count and hash are checked in pre-dispatch. we
// don't check them here anymore.
debug_assert!(Self::validate_unsigned_checks(&paged_solution).is_ok());
let claimed_score = paged_solution.score;
// we select the most significant pages, based on `T::MinerPages`.
let page_indices = crate::Pallet::<T>::msp_range_for(T::MinerPages::get() as usize);
<T::Verifier as Verifier>::verify_synchronous_multi(
paged_solution.solution_pages,
page_indices,
claimed_score,
)
.expect(error_message);
Ok(None.into())
}
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
type Call = Call<T>;
fn validate_unsigned(source: TransactionSource, call: &Self::Call) -> TransactionValidity {
if let Call::submit_unsigned { paged_solution, .. } = call {
match source {
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
_ => return InvalidTransaction::Call.into(),
}
let _ = Self::validate_unsigned_checks(paged_solution.as_ref())
.map_err(|err| {
sublog!(
debug,
"unsigned",
"unsigned transaction validation failed due to {:?}",
err
);
err
})
.map_err(base_error_to_invalid)?;
ValidTransaction::with_tag_prefix("OffchainElection")
// The higher the score.minimal_stake, the better a paged_solution is.
.priority(
T::MinerTxPriority::get()
.saturating_add(paged_solution.score.minimal_stake.saturated_into()),
)
// Used to deduplicate unsigned solutions: each validator should produce one
// paged_solution per round at most, and solutions are not propagate.
.and_provides(paged_solution.round)
// Transaction should stay in the pool for the duration of the unsigned phase.
.longevity(T::UnsignedPhase::get().saturated_into::<u64>())
// We don't propagate this. This can never be validated at a remote node.
.propagate(false)
.build()
} else {
InvalidTransaction::Call.into()
}
}
fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> {
if let Call::submit_unsigned { paged_solution, .. } = call {
Self::validate_unsigned_checks(paged_solution.as_ref())
.map_err(base_error_to_invalid)
.map_err(Into::into)
} else {
Err(InvalidTransaction::Call.into())
}
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn integrity_test() {
assert!(
UnsignedWeightsOf::<T>::submit_unsigned().all_lte(T::BlockWeights::get().max_block),
"weight of `submit_unsigned` is too high"
);
assert!(
<T as Config>::MinerPages::get() as usize <=
<T as crate::Config>::Pages::get() as usize,
"number of pages in the unsigned phase is too high"
);
}
#[cfg(feature = "try-runtime")]
fn try_state(now: BlockNumberFor<T>) -> Result<(), pezsp_runtime::TryRuntimeError> {
Self::do_try_state(now)
}
fn offchain_worker(now: BlockNumberFor<T>) {
use pezsp_runtime::offchain::storage_lock::{BlockAndTime, StorageLock};
// Create a lock with the maximum deadline of number of blocks in the unsigned phase.
// This should only come useful in an **abrupt** termination of execution, otherwise the
// guard will be dropped upon successful execution.
let mut lock =
StorageLock::<BlockAndTime<pezframe_system::Pallet<T>>>::with_block_deadline(
miner::OffchainWorkerMiner::<T>::OFFCHAIN_LOCK,
T::UnsignedPhase::get().saturated_into(),
);
match lock.try_lock() {
Ok(_guard) => {
Self::do_synchronized_offchain_worker(now);
},
Err(deadline) => {
sublog!(
trace,
"unsigned",
"offchain worker lock not released, deadline is {:?}",
deadline
);
},
};
}
}
impl<T: Config> Pallet<T> {
/// Internal logic of the offchain worker, to be executed only when the offchain lock is
/// acquired with success.
fn do_synchronized_offchain_worker(now: BlockNumberFor<T>) {
use miner::OffchainWorkerMiner;
let current_phase = crate::Pallet::<T>::current_phase();
sublog!(
trace,
"unsigned",
"lock for offchain worker acquired. Phase = {:?}",
current_phase
);
// do the repeat frequency check just one, if we are in unsigned phase.
if current_phase.is_unsigned() {
if let Err(reason) = OffchainWorkerMiner::<T>::ensure_offchain_repeat_frequency(now)
{
sublog!(
debug,
"unsigned",
"offchain worker repeat frequency check failed: {:?}",
reason
);
return;
}
}
if current_phase.is_unsigned_opened_now() {
// Mine a new solution, (maybe) cache it, and attempt to submit it
let initial_output = if T::OffchainStorage::get() {
OffchainWorkerMiner::<T>::mine_check_maybe_save_submit(true)
} else {
OffchainWorkerMiner::<T>::mine_check_maybe_save_submit(false)
};
sublog!(debug, "unsigned", "initial offchain worker output: {:?}", initial_output);
} else if current_phase.is_unsigned() {
// Maybe resubmit the cached solution, else re-compute.
let resubmit_output = if T::OffchainStorage::get() {
OffchainWorkerMiner::<T>::restore_or_compute_then_maybe_submit()
} else {
OffchainWorkerMiner::<T>::mine_check_maybe_save_submit(false)
};
sublog!(debug, "unsigned", "later offchain worker output: {:?}", resubmit_output);
};
}
/// The checks that should happen in the `ValidateUnsigned`'s `pre_dispatch` and
/// `validate_unsigned` functions.
///
/// These check both for snapshot independent checks, and some checks that are specific to
/// the unsigned phase.
pub(crate) fn validate_unsigned_checks(
paged_solution: &PagedRawSolution<T::MinerConfig>,
) -> Result<(), CommonError> {
Self::unsigned_specific_checks(paged_solution)
.and(crate::Pallet::<T>::snapshot_independent_checks(paged_solution, None))
.map_err(Into::into)
}
/// The checks that are specific to the (this) unsigned pallet.
///
/// ensure solution has the correct phase, and it has only 1 page.
pub fn unsigned_specific_checks(
paged_solution: &PagedRawSolution<T::MinerConfig>,
) -> Result<(), CommonError> {
ensure!(
crate::Pallet::<T>::current_phase().is_unsigned(),
CommonError::EarlySubmission
);
ensure!(
paged_solution.solution_pages.len() == T::MinerPages::get() as usize,
CommonError::WrongPageCount
);
ensure!(
paged_solution.solution_pages.len() <= <T as crate::Config>::Pages::get() as usize,
CommonError::WrongPageCount
);
Ok(())
}
#[cfg(any(test, feature = "runtime-benchmarks", feature = "try-runtime"))]
pub(crate) fn do_try_state(
_now: BlockNumberFor<T>,
) -> Result<(), pezsp_runtime::TryRuntimeError> {
Ok(())
}
}
}
#[cfg(test)]
mod validate_unsigned {
use pezframe_election_provider_support::Support;
use pezframe_support::{
pezpallet_prelude::InvalidTransaction,
unsigned::{TransactionSource, TransactionValidityError, ValidateUnsigned},
};
use super::Call;
use crate::{mock::*, types::*, verifier::Verifier};
#[test]
fn retracts_weak_score_accepts_better() {
ExtBuilder::unsigned().build_and_execute(|| {
roll_to_snapshot_created();
let base_minimal_stake = 55;
let solution = mine_full_solution().unwrap();
load_mock_signed_and_start(solution.clone());
roll_to_full_verification();
// Some good solution is queued now.
assert_eq!(
<VerifierPallet as Verifier>::queued_score(),
Some(ElectionScore {
minimal_stake: base_minimal_stake,
sum_stake: 130,
sum_stake_squared: 8650
})
);
roll_to_unsigned_open();
// This is just worse.
let attempt = fake_solution(ElectionScore {
minimal_stake: base_minimal_stake - 1,
..Default::default()
});
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(2)),
);
// This is better, but the number of winners is incorrect.
let attempt = fake_solution(ElectionScore {
minimal_stake: base_minimal_stake + 1,
..Default::default()
});
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(4)),
);
// Note that we now have to use a solution with 2 winners, just to pass all of the
// snapshot independent checks.
let mut paged = raw_paged_from_supports(
vec![vec![
(40, Support { total: 10, voters: vec![(3, 5)] }),
(30, Support { total: 10, voters: vec![(3, 5)] }),
]],
0,
);
paged.score =
ElectionScore { minimal_stake: base_minimal_stake + 1, ..Default::default() };
let call = Call::submit_unsigned { paged_solution: Box::new(paged) };
assert!(UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).is_ok());
})
}
#[test]
fn retracts_wrong_round() {
ExtBuilder::unsigned().build_and_execute(|| {
roll_to_unsigned_open();
let mut attempt =
fake_solution(ElectionScore { minimal_stake: 5, ..Default::default() });
attempt.round += 1;
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
// WrongRound is index 1
TransactionValidityError::Invalid(InvalidTransaction::Custom(1)),
);
})
}
#[test]
fn retracts_too_many_pages_unsigned() {
ExtBuilder::unsigned().build_and_execute(|| {
// NOTE: unsigned solutions should have just 1 page, regardless of the configured
// page count.
roll_to_unsigned_open();
let attempt = mine_full_solution().unwrap();
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
// WrongPageCount is index 3
TransactionValidityError::Invalid(InvalidTransaction::Custom(3)),
);
let attempt = mine_solution(2).unwrap();
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(3)),
);
let attempt = mine_solution(1).unwrap();
let call = Call::submit_unsigned { paged_solution: Box::new(attempt) };
assert!(UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).is_ok(),);
})
}
#[test]
fn retracts_wrong_winner_count() {
ExtBuilder::unsigned().desired_targets(2).build_and_execute(|| {
roll_to_unsigned_open();
let paged = raw_paged_from_supports(
vec![vec![(40, Support { total: 10, voters: vec![(3, 10)] })]],
0,
);
let call = Call::submit_unsigned { paged_solution: Box::new(paged) };
assert_eq!(
UnsignedPallet::validate_unsigned(TransactionSource::Local, &call).unwrap_err(),
// WrongWinnerCount is index 4
TransactionValidityError::Invalid(InvalidTransaction::Custom(4)),
);
});
}
#[test]
fn retracts_wrong_phase() {
ExtBuilder::unsigned().signed_phase(5, 6).build_and_execute(|| {
let solution = raw_paged_solution_low_score();
let call = Call::submit_unsigned { paged_solution: Box::new(solution.clone()) };
// initial
assert_eq!(MultiBlock::current_phase(), Phase::Off);
assert!(matches!(
<UnsignedPallet as ValidateUnsigned>::validate_unsigned(
TransactionSource::Local,
&call
)
.unwrap_err(),
// because EarlySubmission is index 0.
TransactionValidityError::Invalid(InvalidTransaction::Custom(0))
));
assert!(matches!(
<UnsignedPallet as ValidateUnsigned>::pre_dispatch(&call).unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(0))
));
// signed
roll_to_signed_open();
assert!(MultiBlock::current_phase().is_signed());
assert!(matches!(
<UnsignedPallet as ValidateUnsigned>::validate_unsigned(
TransactionSource::Local,
&call
)
.unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(0))
));
assert!(matches!(
<UnsignedPallet as ValidateUnsigned>::pre_dispatch(&call).unwrap_err(),
TransactionValidityError::Invalid(InvalidTransaction::Custom(0))
));
// unsigned
roll_to_unsigned_open();
assert!(MultiBlock::current_phase().is_unsigned());
assert_ok!(<UnsignedPallet as ValidateUnsigned>::validate_unsigned(
TransactionSource::Local,
&call
));
assert_ok!(<UnsignedPallet as ValidateUnsigned>::pre_dispatch(&call));
})
}
#[test]
fn priority_is_set() {
ExtBuilder::unsigned()
.miner_tx_priority(20)
.desired_targets(0)
.build_and_execute(|| {
roll_to_unsigned_open();
assert!(MultiBlock::current_phase().is_unsigned());
let solution =
fake_solution(ElectionScore { minimal_stake: 5, ..Default::default() });
let call = Call::submit_unsigned { paged_solution: Box::new(solution.clone()) };
assert_eq!(
<UnsignedPallet as ValidateUnsigned>::validate_unsigned(
TransactionSource::Local,
&call
)
.unwrap()
.priority,
25
);
})
}
}
#[cfg(test)]
mod call {
use crate::{mock::*, verifier::Verifier, Snapshot};
#[test]
fn unsigned_submission_e2e() {
let (mut ext, pool) = ExtBuilder::unsigned().build_offchainify();
ext.execute_with_sanity_checks(|| {
roll_to_unsigned_open();
// snapshot is created..
assert_full_snapshot();
// ..txpool is empty..
assert_eq!(pool.read().transactions.len(), 0);
// ..but nothing queued.
assert_eq!(<VerifierPallet as Verifier>::queued_score(), None);
// now the OCW should submit something.
roll_next_with_ocw(Some(pool.clone()));
assert_eq!(pool.read().transactions.len(), 1);
assert_eq!(<VerifierPallet as Verifier>::queued_score(), None);
// and now it should be applied.
roll_next_with_ocw(Some(pool.clone()));
assert_eq!(pool.read().transactions.len(), 0);
assert!(matches!(<VerifierPallet as Verifier>::queued_score(), Some(_)));
})
}
#[test]
#[should_panic(
expected = "Invalid unsigned submission must produce invalid block and deprive validator from their authoring reward."
)]
fn unfeasible_solution_panics() {
let (mut ext, pool) = ExtBuilder::unsigned().build_offchainify();
ext.execute_with_sanity_checks(|| {
roll_to_unsigned_open();
// snapshot is created..
assert_full_snapshot();
// ..txpool is empty..
assert_eq!(pool.read().transactions.len(), 0);
// ..but nothing queued.
assert_eq!(<VerifierPallet as Verifier>::queued_score(), None);
// now the OCW should submit something.
roll_next_with_ocw(Some(pool.clone()));
assert_eq!(pool.read().transactions.len(), 1);
assert_eq!(<VerifierPallet as Verifier>::queued_score(), None);
// now we change the snapshot -- this should ensure that the solution becomes invalid.
// Note that we don't change the known fingerprint of the solution.
Snapshot::<Runtime>::remove_target(2);
// and now it should be applied.
roll_next_with_ocw(Some(pool.clone()));
assert_eq!(pool.read().transactions.len(), 0);
assert!(matches!(<VerifierPallet as Verifier>::queued_score(), Some(_)));
})
}
}
@@ -0,0 +1,245 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::{
verifier::{Config, Event, FeasibilityError, Pallet, Status, StatusStorage},
CurrentPhase, Phase,
};
use pezframe_benchmarking::v2::*;
use pezframe_election_provider_support::{ElectionProvider, NposSolution};
use pezframe_support::pezpallet_prelude::*;
use pezsp_std::prelude::*;
#[benchmarks(where
T: crate::Config + crate::signed::Config + crate::unsigned::Config,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<crate::verifier::Event<T>>
)]
mod benchmarks {
use super::*;
fn events_for<T: Config>() -> Vec<Event<T>>
where
<T as pezframe_system::Config>::RuntimeEvent: TryInto<Event<T>>,
{
pezframe_system::Pallet::<T>::read_events_for_pallet::<Event<T>>()
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_valid_non_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// start signal must have been sent by now
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp() - 1));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_valid_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
assert!(
T::SignedValidationPhase::get() >= T::Pages::get().into(),
"Signed validation phase must be larger than the number of pages"
);
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// roll to before the last page of verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// start signal must have been sent by now
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
for _ in 0..(T::Pages::get() - 1) {
crate::Pallet::<T>::roll_next(true, false);
}
// we must have verified all pages by now, minus the last one.
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(1, _)]
));
// verify the last page.
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are done
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
// last event is success
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(0, _), Event::Queued(_, None)]
));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_invalid_terminal() -> Result<(), BenchmarkError> {
// this is the verification of the current page + removing all of the previously valid
// pages. The worst case is therefore when the last page is invalid, for example the final
// score.
assert!(T::Pages::get() >= 2, "benchmark only works if we have more than 2 pages");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
// but this solution is corrupt
let mut paged_solution = crate::Pallet::<T>::roll_to_signed_and_mine_full_solution();
paged_solution.score.minimal_stake -= 1;
crate::Pallet::<T>::submit_full_solution(paged_solution)?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
// verify all pages, except for the last one.
for i in 0..T::Pages::get() - 1 {
crate::Pallet::<T>::roll_next(true, false);
assert_eq!(
StatusStorage::<T>::get(),
Status::Ongoing(crate::Pallet::<T>::msp() - 1 - i)
);
}
// next page to be verified is the last one
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::lsp()));
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(1, _)]
));
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are now reset.
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
assert!(matches!(
&events_for::<T>()[..],
[
..,
Event::Verified(0, _),
Event::VerificationFailed(0, FeasibilityError::InvalidScore)
]
));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_invalid_non_terminal(
// number of valid pages that have been verified, before we verify the non-terminal invalid
// page.
v: Linear<0, { T::Pages::get() - 1 }>,
) -> Result<(), BenchmarkError> {
assert!(T::Pages::get() >= 2, "benchmark only works if we have more than 2 pages");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet, but this solution
// is corrupt in its msp.
let mut paged_solution = crate::Pallet::<T>::roll_to_signed_and_mine_full_solution();
let page_to_corrupt = crate::Pallet::<T>::msp() - v;
crate::log!(
info,
"pages of solution: {:?}, to corrupt {}, v {}",
paged_solution.solution_pages.len(),
page_to_corrupt,
v
);
paged_solution.solution_pages[page_to_corrupt as usize].corrupt();
crate::Pallet::<T>::submit_full_solution(paged_solution)?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// we should be ready to go
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
// validate the the parameterized number of valid pages.
for _ in 0..v {
crate::Pallet::<T>::roll_next(true, false);
}
// we are still ready to continue
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp() - v));
// verify one page, which will be invalid.
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are now reset, because this page was invalid.
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
assert!(matches!(
&events_for::<T>()[..],
[.., Event::VerificationFailed(_, FeasibilityError::NposElection(_))]
));
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::ExtBuilder::full().build_unchecked(),
crate::mock::Runtime
);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,291 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # The Verifier Pallet
//!
//! This pallet has no end-user functionality, and is only used internally by other pallets in the
//! EPMB machinery to verify solutions.
//!
//! ### *Feasibility* Check
//!
//! Before explaining the pallet itself, it should be explained what a *verification* even means.
//! Verification of a solution page ([`crate::unsigned::miner::MinerConfig::Solution`]) includes the
//! process of checking all of its edges against a snapshot to be correct. For instance, all voters
//! that are presented in a solution page must have actually voted for the winner that they are
//! backing, based on the snapshot kept in the parent pallet.
//!
//! Such checks are bound to each page of the solution, and happen per-page. After checking all of
//! the edges in each page, a handful of other checks are performed. These checks cannot happen
//! per-page, and in order to do them we need to have the entire solution checked and verified.
//!
//! 1. Check that the total number of winners is sufficient (`DesiredTargets`).
//! 2. Check that the claimed score ([`pezsp_npos_elections::ElectionScore`]) is correct,
//! * and more than the minimum score that can be specified via [`Verifier::set_minimum_score`].
//! 3. Check that all of the bounds of the solution are respected, namely
//! [`Verifier::MaxBackersPerWinner`], [`Verifier::MaxWinnersPerPage`] and
//! [`Verifier::MaxBackersPerWinnerFinal`].
//!
//! Note that the common factor of all of the above checks is that they can ONLY be checked after
//! all pages are already verified. So, in the case of a multi-page verification, these checks are
//! performed at the last page.
//!
//! The errors that can arise while performing the feasibility check are encapsulated in
//! [`verifier::FeasibilityError`].
//!
//! ## Modes of Verification
//!
//! The verifier pallet provide two modes of functionality:
//!
//! 1. Single or multi-page, synchronous verification. This is useful in the context of single-page,
//! emergency, or unsigned solutions that need to be verified on the fly. This is similar to how
//! the old school `multi-phase` pallet works. See [`Verifier::verify_synchronous`] and
//! [`Verifier::verify_synchronous_multi`].
//! 2. Multi-page, asynchronous verification. This is useful in the context of multi-page, signed
//! solutions. See [`verifier::AsynchronousVerifier`] and [`verifier::SolutionDataProvider`].
//!
//! Both of this, plus some helper functions, is exposed via the [`verifier::Verifier`] trait.
//!
//! ## Queued Solution
//!
//! once a solution has been verified, it is called a *queued solution*. It is sitting in a queue,
//! waiting for either of:
//!
//! 1. being challenged and potentially replaced by better solution, if any.
//! 2. being exported as the final outcome of the election.
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
mod impls;
#[cfg(test)]
mod tests;
// internal imports
pub use crate::weights::traits::pezpallet_election_provider_multi_block_verifier::*;
use pezframe_election_provider_support::PageIndex;
use impls::SupportsOfVerifier;
pub use impls::{feasibility_check_page_inner_with_snapshot, pallet::*, Status};
use pezsp_core::Get;
use pezsp_npos_elections::ElectionScore;
use pezsp_std::{fmt::Debug, prelude::*};
/// Errors that can happen in the feasibility check.
#[derive(
Debug,
Eq,
PartialEq,
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
scale_info::TypeInfo,
Clone,
)]
pub enum FeasibilityError {
/// Wrong number of winners presented.
WrongWinnerCount,
/// The snapshot is not available.
///
/// Kinda defensive: The pallet should technically never attempt to do a feasibility check
/// when no snapshot is present.
SnapshotUnavailable,
/// A vote is invalid.
InvalidVote,
/// A voter is invalid.
InvalidVoter,
/// A winner is invalid.
InvalidWinner,
/// The given score was invalid.
InvalidScore,
/// The provided round is incorrect.
InvalidRound,
/// Solution does not have a good enough score.
ScoreTooLow,
/// The support type failed to be bounded.
///
/// Relates to [`Config::MaxWinnersPerPage`], [`Config::MaxBackersPerWinner`] or
/// `MaxBackersPerWinnerFinal`
FailedToBoundSupport,
/// Internal error from the election crate.
NposElection(pezsp_npos_elections::Error),
/// The solution is incomplete, it has too few pages.
///
/// This is (somewhat) synonym to `WrongPageCount` in other places.
Incomplete,
}
impl From<pezsp_npos_elections::Error> for FeasibilityError {
fn from(e: pezsp_npos_elections::Error) -> Self {
FeasibilityError::NposElection(e)
}
}
/// The interface of something that can verify solutions for other sub-pallets in the multi-block
/// election pezpallet-network.
pub trait Verifier {
/// The solution type.
type Solution;
/// The account if type.
type AccountId;
/// Maximum number of winners that can be represented in each page.
///
/// A reasonable value for this should be the maximum number of winners that the election user
/// (e.g. the staking pallet) could ever desire.
type MaxWinnersPerPage: Get<u32>;
/// Maximum number of backers, per winner, among all pages of an election.
///
/// This can only be checked at the very final step of verification.
type MaxBackersPerWinnerFinal: Get<u32>;
/// Maximum number of backers that each winner could have, per page.
type MaxBackersPerWinner: Get<u32>;
/// Set the minimum score that is acceptable for any solution.
///
/// Henceforth, all solutions must have at least this degree of quality, single-page or
/// multi-page.
fn set_minimum_score(score: ElectionScore);
/// The score of the current best solution. `None` if there is none.
fn queued_score() -> Option<ElectionScore>;
/// Check if the claimed score is sufficient to challenge the current queued solution, if any.
fn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool;
/// Clear all storage items, there's nothing else to do until further notice.
fn kill();
/// Get a single page of the best verified solution, if any.
///
/// It is the responsibility of the call site to call this function with all appropriate
/// `page` arguments.
fn get_queued_solution_page(page: PageIndex) -> Option<SupportsOfVerifier<Self>>;
/// Perform the feasibility check on the given single-page solution.
///
/// This will perform:
///
/// 1. feasibility-check
/// 2. claimed score is correct and an improvement.
/// 3. bounds are respected
///
/// Corresponding snapshot (represented by `page`) is assumed to be available.
///
/// If all checks pass, the solution is also queued.
fn verify_synchronous(
partial_solution: Self::Solution,
claimed_score: ElectionScore,
page: PageIndex,
) -> Result<(), FeasibilityError> {
Self::verify_synchronous_multi(vec![partial_solution], vec![page], claimed_score)
}
/// Perform synchronous feasibility check on the given multi-page solution.
///
/// Same semantics as [`Self::verify_synchronous`], but for multi-page solutions.
fn verify_synchronous_multi(
partial_solution: Vec<Self::Solution>,
pages: Vec<PageIndex>,
claimed_score: ElectionScore,
) -> Result<(), FeasibilityError>;
/// Force set a single page solution as the valid one.
///
/// Will erase any previous solution. Should only be used in case of emergency fallbacks,
/// trusted governance solutions and so on.
fn force_set_single_page_valid(
partial_supports: SupportsOfVerifier<Self>,
page: PageIndex,
score: ElectionScore,
);
}
/// Simple enum to encapsulate the result of the verification of a candidate solution.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(test, derive(PartialEq, Eq))]
pub enum VerificationResult {
/// Solution is valid and is queued.
Queued,
/// Solution is rejected, for whichever of the multiple reasons that it could be.
Rejected,
}
/// Something that can provide candidate solutions to the verifier.
///
/// In reality, this can be implemented by the [`crate::signed::Pallet`], where signed solutions are
/// queued and sorted based on claimed score, and they are put forth one by one, from best to worse.
pub trait SolutionDataProvider {
/// The opaque solution type.
type Solution;
/// Return the `page`th page of the current best solution that the data provider has in store.
///
/// If no candidate solutions are available, an empty page is returned (i.e., a page that
/// contains no solutions and contributes zero to the final score).
fn get_page(page: PageIndex) -> Self::Solution;
/// Get the claimed score of the current best solution.
///
/// If no score is available, a default/zero score should be returned defensively.
fn get_score() -> ElectionScore;
/// Hook to report back the results of the verification of the current candidate solution that
/// is being exposed via [`Self::get_page`] and [`Self::get_score`].
///
/// Every time that this is called, the verifier [`AsynchronousVerifier`] goes back to the
/// [`Status::Nothing`] state, and it is the responsibility of [`Self`] to call `start` again,
/// if desired.
fn report_result(result: VerificationResult);
}
/// Something that can do the verification asynchronously.
pub trait AsynchronousVerifier: Verifier {
/// The data provider that can provide the candidate solution, and to whom we report back the
/// results.
type SolutionDataProvider: SolutionDataProvider;
/// Get the current stage of the verification process.
fn status() -> Status;
/// Start a verification process.
///
/// Returns `Ok(())` if verification started successfully, and `Err(..)` if a verification is
/// already ongoing and therefore a new one cannot be started.
///
/// From the coming block onwards, the verifier will start and fetch the relevant information
/// and solution pages from [`SolutionDataProvider`]. It is expected that the
/// [`SolutionDataProvider`] is ready before calling [`Self::start`].
///
/// Pages of the solution are fetched sequentially and in order from [`SolutionDataProvider`],
/// from `msp` to `lsp`.
///
/// This ends in either of the two:
///
/// 1. All pages, including the final checks (like score and other facts that can only be
/// derived from a full solution) are valid and the solution is verified. The solution is
/// queued and is ready for further export.
/// 2. The solution checks verification at one of the steps. Nothing is stored inside the
/// verifier pallet and all intermediary data is removed.
///
/// In both cases, the [`SolutionDataProvider`] is informed via
/// [`SolutionDataProvider::report_result`]. It is sensible for the data provide to call `start`
/// again if the verification has failed, and nothing otherwise. Indeed, the
/// [`SolutionDataProvider`] must adjust its internal state such that it returns a new candidate
/// solution after each failure.
fn start() -> Result<(), &'static str>;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,21 @@
function display {
echo "comparing $1 -> $2"
subweight compare files \
--method asymptotic \
--new $1 \
--old $2 \
--unit proof --verbose --threshold 0
subweight compare files \
--method asymptotic \
--new $1 \
--old $2 \
--unit time --verbose --threshold 0
}
## Pezkuwi
display "./pallet_election_provider_multi_block_hez_size.rs" "./pallet_election_provider_multi_block_ksm_size.rs"
display "./pallet_election_provider_multi_block_signed_hez_size.rs" "./pallet_election_provider_multi_block_signed_ksm_size.rs"
display "./pallet_election_provider_multi_block_unsigned_hez_size.rs" "./pallet_election_provider_multi_block_unsigned_ksm_size.rs"
display "./pallet_election_provider_multi_block_verifier_hez_size.rs" "./pallet_election_provider_multi_block_verifier_ksm_size.rs"
@@ -0,0 +1,32 @@
function display {
echo "displaying $1"
subweight compare files \
--method asymptotic \
--new $1 \
--old $1 \
--unit proof \
--verbose \
--threshold 0
subweight compare files \
--method asymptotic \
--new $1 \
--old $1 \
--unit time \
--verbose \
--threshold 0
}
## Pezkuwi
display "pallet_election_provider_multi_block_hez_size.rs"
display "pallet_election_provider_multi_block_signed_hez_size.rs"
display "pallet_election_provider_multi_block_unsigned_hez_size.rs"
display "pallet_election_provider_multi_block_verifier_hez_size.rs"
## Kusama
display "pallet_election_provider_multi_block_ksm_size.rs"
display "pallet_election_provider_multi_block_signed_ksm_size.rs"
display "pallet_election_provider_multi_block_unsigned_ksm_size.rs"
display "pallet_election_provider_multi_block_verifier_ksm_size.rs"
@@ -0,0 +1,189 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! WeightInfo for the election provider multi-block pallet group.
mod pezpallet_election_provider_multi_block_hez_size;
mod pezpallet_election_provider_multi_block_signed_hez_size;
mod pezpallet_election_provider_multi_block_unsigned_hez_size;
mod pezpallet_election_provider_multi_block_verifier_hez_size;
mod pezpallet_election_provider_multi_block_ksm_size;
mod pezpallet_election_provider_multi_block_signed_ksm_size;
mod pezpallet_election_provider_multi_block_unsigned_ksm_size;
mod pezpallet_election_provider_multi_block_verifier_ksm_size;
use pezframe_support::pezpallet_prelude::Weight;
pub mod traits {
use super::*;
pub mod pezpallet_election_provider_multi_block_signed {
use super::*;
/// Weight functions needed for `pezpallet_election_provider_multi_block_signed`.
pub trait WeightInfo {
fn register_not_full() -> Weight;
fn register_eject() -> Weight;
fn submit_page() -> Weight;
fn unset_page() -> Weight;
fn bail() -> Weight;
fn clear_old_round_data(p: u32) -> Weight;
}
impl WeightInfo for () {
fn bail() -> Weight {
Default::default()
}
fn clear_old_round_data(_p: u32) -> Weight {
Default::default()
}
fn register_eject() -> Weight {
Default::default()
}
fn register_not_full() -> Weight {
Default::default()
}
fn submit_page() -> Weight {
Default::default()
}
fn unset_page() -> Weight {
Default::default()
}
}
}
pub mod pezpallet_election_provider_multi_block_unsigned {
use super::*;
/// Weight functions needed for `pezpallet_election_provider_multi_block::unsigned`.
pub trait WeightInfo {
fn validate_unsigned() -> Weight;
fn submit_unsigned() -> Weight;
// This has an auto-impl as the associated benchmark is `#[extra]`.
fn mine_solution(_p: u32) -> Weight {
Default::default()
}
}
impl WeightInfo for () {
fn validate_unsigned() -> Weight {
Default::default()
}
fn submit_unsigned() -> Weight {
Default::default()
}
}
}
pub mod pezpallet_election_provider_multi_block_verifier {
use super::*;
/// Weight functions needed for `pezpallet_election_provider_multi_block_verifier`.
pub trait WeightInfo {
fn on_initialize_valid_non_terminal() -> Weight;
fn on_initialize_valid_terminal() -> Weight;
fn on_initialize_invalid_terminal() -> Weight;
fn on_initialize_invalid_non_terminal(v: u32) -> Weight;
}
impl WeightInfo for () {
fn on_initialize_valid_non_terminal() -> Weight {
Default::default()
}
fn on_initialize_valid_terminal() -> Weight {
Default::default()
}
fn on_initialize_invalid_terminal() -> Weight {
Default::default()
}
fn on_initialize_invalid_non_terminal(_v: u32) -> Weight {
Default::default()
}
}
}
pub mod pezpallet_election_provider_multi_block {
use super::*;
/// Weight functions needed for `pezpallet_election_provider_multi_block`.
pub trait WeightInfo {
fn on_initialize_nothing() -> Weight;
fn on_initialize_into_snapshot_msp() -> Weight;
fn on_initialize_into_snapshot_rest() -> Weight;
fn on_initialize_into_signed() -> Weight;
fn on_initialize_into_signed_validation() -> Weight;
fn on_initialize_into_unsigned() -> Weight;
fn export_non_terminal() -> Weight;
fn export_terminal() -> Weight;
fn admin_set() -> Weight;
fn manage_fallback() -> Weight;
}
impl WeightInfo for () {
fn on_initialize_nothing() -> Weight {
Default::default()
}
fn on_initialize_into_snapshot_msp() -> Weight {
Default::default()
}
fn on_initialize_into_snapshot_rest() -> Weight {
Default::default()
}
fn on_initialize_into_signed() -> Weight {
Default::default()
}
fn on_initialize_into_signed_validation() -> Weight {
Default::default()
}
fn on_initialize_into_unsigned() -> Weight {
Default::default()
}
fn export_non_terminal() -> Weight {
Default::default()
}
fn export_terminal() -> Weight {
Default::default()
}
fn admin_set() -> Weight {
Default::default()
}
fn manage_fallback() -> Weight {
Default::default()
}
}
}
}
/// Kusama-esque weights only be used in testing runtimes.
pub mod kusama {
pub use super::{
pezpallet_election_provider_multi_block_ksm_size::WeightInfo as MultiBlockWeightInfo,
pezpallet_election_provider_multi_block_signed_ksm_size::WeightInfo as MultiBlockSignedWeightInfo,
pezpallet_election_provider_multi_block_unsigned_ksm_size::WeightInfo as MultiBlockUnsignedWeightInfo,
pezpallet_election_provider_multi_block_verifier_ksm_size::WeightInfo as MultiBlockVerifierWeightInfo,
};
}
/// Pezkuwi-esque weights only be used in testing runtimes.
pub mod pezkuwi {
pub use super::{
pezpallet_election_provider_multi_block_hez_size::WeightInfo as MultiBlockWeightInfo,
pezpallet_election_provider_multi_block_signed_hez_size::WeightInfo as MultiBlockSignedWeightInfo,
pezpallet_election_provider_multi_block_unsigned_hez_size::WeightInfo as MultiBlockUnsignedWeightInfo,
pezpallet_election_provider_multi_block_verifier_hez_size::WeightInfo as MultiBlockVerifierWeightInfo,
};
}
@@ -0,0 +1,378 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-hez
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_fake-hez.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
fn on_initialize_nothing() -> Weight {
// Proof Size summary in bytes:
// Measured: `250`
// Estimated: `3715`
// Minimum execution time: 24_100_000 picoseconds.
Weight::from_parts(25_330_000, 3715)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Staking::ValidatorCount` (r:1 w:0)
/// Proof: `Staking::ValidatorCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `Staking::CounterForValidators` (r:1 w:0)
/// Proof: `Staking::CounterForValidators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::Validators` (r:2001 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:0 w:1)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
fn on_initialize_into_snapshot_msp() -> Weight {
// Proof Size summary in bytes:
// Measured: `95465`
// Estimated: `5048930`
// Minimum execution time: 18_878_131_000 picoseconds.
Weight::from_parts(18_983_212_000, 5048930)
.saturating_add(T::DbWeight::get().reads(2009_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::VoterSnapshotStatus` (r:1 w:1)
/// Proof: `Staking::VoterSnapshotStatus` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `Measured`)
/// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
/// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `VoterList::ListBags` (r:1 w:0)
/// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `Measured`)
/// Storage: `VoterList::ListNodes` (r:705 w:0)
/// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `Measured`)
/// Storage: `Staking::Bonded` (r:703 w:0)
/// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `Measured`)
/// Storage: `Staking::Ledger` (r:703 w:0)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `Measured`)
/// Storage: `Staking::Nominators` (r:703 w:0)
/// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `Measured`)
/// Storage: `Staking::Validators` (r:261 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
/// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`)
/// Storage: `VoterList::Lock` (r:0 w:1)
/// Proof: `VoterList::Lock` (`max_values`: Some(1), `max_size`: Some(0), added: 495, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
fn on_initialize_into_snapshot_rest() -> Weight {
// Proof Size summary in bytes:
// Measured: `1449068`
// Estimated: `3194933`
// Minimum execution time: 45_723_834_000 picoseconds.
Weight::from_parts(45_910_816_000, 3194933)
.saturating_add(T::DbWeight::get().reads(3084_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::VoterSnapshotStatus` (r:1 w:1)
/// Proof: `Staking::VoterSnapshotStatus` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `Measured`)
/// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
/// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `VoterList::ListNodes` (r:705 w:0)
/// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `Measured`)
/// Storage: `Staking::Bonded` (r:703 w:0)
/// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `Measured`)
/// Storage: `Staking::Ledger` (r:703 w:0)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `Measured`)
/// Storage: `Staking::Nominators` (r:703 w:0)
/// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `Measured`)
/// Storage: `VoterList::ListBags` (r:1 w:0)
/// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `Measured`)
/// Storage: `Staking::Validators` (r:45 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6358acd2035ec4bb863fa981e0c177b9` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6358acd2035ec4bb863fa981e0c177b9` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
/// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`)
/// Storage: `VoterList::Lock` (r:0 w:1)
/// Proof: `VoterList::Lock` (`max_values`: Some(1), `max_size`: Some(0), added: 495, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
fn on_initialize_into_signed() -> Weight {
// Proof Size summary in bytes:
// Measured: `1516243`
// Estimated: `3262108`
// Minimum execution time: 50_546_380_000 picoseconds.
Weight::from_parts(51_815_377_000, 3262108)
.saturating_add(T::DbWeight::get().reads(2869_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
fn on_initialize_into_signed_validation() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3909`
// Minimum execution time: 3_711_197_000 picoseconds.
Weight::from_parts(3_810_718_000, 3909)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
fn on_initialize_into_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3909`
// Minimum execution time: 3_740_878_000 picoseconds.
Weight::from_parts(3_808_557_000, 3909)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::CurrentEra` (r:1 w:0)
/// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::ElectableStashes` (r:1 w:1)
/// Proof: `Staking::ElectableStashes` (`max_values`: Some(1), `max_size`: Some(32002), added: 32497, mode: `Measured`)
/// Storage: `Staking::ErasStakersOverview` (r:491 w:491)
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `Measured`)
/// Storage: `Staking::ErasTotalStake` (r:1 w:1)
/// Proof: `Staking::ErasTotalStake` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `Measured`)
/// Storage: `Staking::Validators` (r:491 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `Staking::ErasValidatorPrefs` (r:0 w:491)
/// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `Measured`)
/// Storage: `Staking::ErasStakersPaged` (r:0 w:490)
/// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: Some(3152), added: 5627, mode: `Measured`)
fn export_non_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `167757`
// Estimated: `1383972`
// Minimum execution time: 13_949_429_000 picoseconds.
Weight::from_parts(13_983_218_000, 1383972)
.saturating_add(T::DbWeight::get().reads(991_u64))
.saturating_add(T::DbWeight::get().writes(1475_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:1)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:32 w:32)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:32 w:32)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:32 w:32)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshotHash` (r:1 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `Staking::CurrentEra` (r:1 w:0)
/// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::ElectableStashes` (r:1 w:1)
/// Proof: `Staking::ElectableStashes` (`max_values`: Some(1), `max_size`: Some(32002), added: 32497, mode: `Measured`)
/// Storage: `Staking::ErasStakersOverview` (r:310 w:310)
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `Measured`)
/// Storage: `Staking::ErasStakersPaged` (r:310 w:345)
/// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: Some(3152), added: 5627, mode: `Measured`)
/// Storage: `Staking::ErasTotalStake` (r:1 w:1)
/// Proof: `Staking::ErasTotalStake` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `Measured`)
/// Storage: `Staking::Validators` (r:310 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `Staking::ErasValidatorPrefs` (r:0 w:310)
/// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:0 w:1)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
fn export_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `770035`
// Estimated: `1538275`
// Minimum execution time: 18_379_354_000 picoseconds.
Weight::from_parts(19_010_697_000, 1538275)
.saturating_add(T::DbWeight::get().reads(1036_u64))
.saturating_add(T::DbWeight::get().writes(1071_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn manage_fallback() -> Weight {
// Proof Size summary in bytes:
// Measured: `328713`
// Estimated: `332178`
// Minimum execution time: 538_906_259_000 picoseconds.
Weight::from_parts(539_733_270_000, 332178)
.saturating_add(T::DbWeight::get().reads(10_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn admin_set() -> Weight {
// Proof Size summary in bytes:
// Measured: `308`
// Estimated: `3773`
// Minimum execution time: 399_531_000 picoseconds.
Weight::from_parts(497_971_000, 3773)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
}
@@ -0,0 +1,378 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-ksm
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_fake-ksm.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
fn on_initialize_nothing() -> Weight {
// Proof Size summary in bytes:
// Measured: `250`
// Estimated: `3715`
// Minimum execution time: 24_070_000 picoseconds.
Weight::from_parts(25_070_000, 3715)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Staking::ValidatorCount` (r:1 w:0)
/// Proof: `Staking::ValidatorCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `Staking::CounterForValidators` (r:1 w:0)
/// Proof: `Staking::CounterForValidators` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::Validators` (r:4001 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:0 w:1)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
fn on_initialize_into_snapshot_msp() -> Weight {
// Proof Size summary in bytes:
// Measured: `189963`
// Estimated: `10093428`
// Minimum execution time: 41_110_812_000 picoseconds.
Weight::from_parts(41_368_864_000, 10093428)
.saturating_add(T::DbWeight::get().reads(4009_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::VoterSnapshotStatus` (r:1 w:1)
/// Proof: `Staking::VoterSnapshotStatus` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `Measured`)
/// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
/// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `VoterList::ListBags` (r:1 w:0)
/// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `Measured`)
/// Storage: `VoterList::ListNodes` (r:783 w:0)
/// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `Measured`)
/// Storage: `Staking::Bonded` (r:781 w:0)
/// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `Measured`)
/// Storage: `Staking::Ledger` (r:781 w:0)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `Measured`)
/// Storage: `Staking::Nominators` (r:781 w:0)
/// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `Measured`)
/// Storage: `Staking::Validators` (r:455 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
/// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`)
/// Storage: `VoterList::Lock` (r:0 w:1)
/// Proof: `VoterList::Lock` (`max_values`: Some(1), `max_size`: Some(0), added: 495, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
fn on_initialize_into_snapshot_rest() -> Weight {
// Proof Size summary in bytes:
// Measured: `1370478`
// Estimated: `3309393`
// Minimum execution time: 55_933_967_000 picoseconds.
Weight::from_parts(56_210_319_000, 3309393)
.saturating_add(T::DbWeight::get().reads(3590_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::VoterSnapshotStatus` (r:1 w:1)
/// Proof: `Staking::VoterSnapshotStatus` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `Measured`)
/// Storage: `VoterList::CounterForListNodes` (r:1 w:0)
/// Proof: `VoterList::CounterForListNodes` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `VoterList::ListNodes` (r:783 w:0)
/// Proof: `VoterList::ListNodes` (`max_values`: None, `max_size`: Some(154), added: 2629, mode: `Measured`)
/// Storage: `Staking::Bonded` (r:781 w:0)
/// Proof: `Staking::Bonded` (`max_values`: None, `max_size`: Some(72), added: 2547, mode: `Measured`)
/// Storage: `Staking::Ledger` (r:781 w:0)
/// Proof: `Staking::Ledger` (`max_values`: None, `max_size`: Some(753), added: 3228, mode: `Measured`)
/// Storage: `Staking::Nominators` (r:781 w:0)
/// Proof: `Staking::Nominators` (`max_values`: None, `max_size`: Some(558), added: 3033, mode: `Measured`)
/// Storage: `VoterList::ListBags` (r:1 w:0)
/// Proof: `VoterList::ListBags` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `Measured`)
/// Storage: `Staking::Validators` (r:173 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6358acd2035ec4bb863fa981e0c177b9` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6358acd2035ec4bb863fa981e0c177b9` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `Staking::MinimumActiveStake` (r:0 w:1)
/// Proof: `Staking::MinimumActiveStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `Measured`)
/// Storage: `VoterList::Lock` (r:0 w:1)
/// Proof: `VoterList::Lock` (`max_values`: Some(1), `max_size`: Some(0), added: 495, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:0 w:1)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
fn on_initialize_into_signed() -> Weight {
// Proof Size summary in bytes:
// Measured: `1472353`
// Estimated: `3411268`
// Minimum execution time: 55_352_841_000 picoseconds.
Weight::from_parts(55_916_036_000, 3411268)
.saturating_add(T::DbWeight::get().reads(3309_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
fn on_initialize_into_signed_validation() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3909`
// Minimum execution time: 202_762_000 picoseconds.
Weight::from_parts(2_761_480_000, 3909)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
fn on_initialize_into_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `444`
// Estimated: `3909`
// Minimum execution time: 981_606_000 picoseconds.
Weight::from_parts(2_872_530_000, 3909)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `Staking::CurrentEra` (r:1 w:0)
/// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::ElectableStashes` (r:1 w:1)
/// Proof: `Staking::ElectableStashes` (`max_values`: Some(1), `max_size`: Some(32002), added: 32497, mode: `Measured`)
/// Storage: `Staking::ErasStakersOverview` (r:792 w:792)
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `Measured`)
/// Storage: `Staking::ErasTotalStake` (r:1 w:1)
/// Proof: `Staking::ErasTotalStake` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `Measured`)
/// Storage: `Staking::Validators` (r:792 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `Staking::ErasValidatorPrefs` (r:0 w:792)
/// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `Measured`)
/// Storage: `Staking::ErasStakersPaged` (r:0 w:740)
/// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: Some(3152), added: 5627, mode: `Measured`)
fn export_non_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `233920`
// Estimated: `2195110`
// Minimum execution time: 24_478_931_000 picoseconds.
Weight::from_parts(24_520_800_000, 2195110)
.saturating_add(T::DbWeight::get().reads(1593_u64))
.saturating_add(T::DbWeight::get().writes(2327_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:1)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:16 w:16)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:16 w:16)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshotHash` (r:16 w:16)
/// Proof: `MultiBlockElection::PagedVoterSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshotHash` (r:1 w:1)
/// Proof: `MultiBlockElection::PagedTargetSnapshotHash` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `Measured`)
/// Storage: `Staking::CurrentEra` (r:1 w:0)
/// Proof: `Staking::CurrentEra` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `Staking::ElectableStashes` (r:1 w:1)
/// Proof: `Staking::ElectableStashes` (`max_values`: Some(1), `max_size`: Some(32002), added: 32497, mode: `Measured`)
/// Storage: `Staking::ErasStakersOverview` (r:580 w:580)
/// Proof: `Staking::ErasStakersOverview` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `Measured`)
/// Storage: `Staking::ErasStakersPaged` (r:580 w:580)
/// Proof: `Staking::ErasStakersPaged` (`max_values`: None, `max_size`: Some(3152), added: 5627, mode: `Measured`)
/// Storage: `Staking::ErasTotalStake` (r:1 w:1)
/// Proof: `Staking::ErasTotalStake` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `Measured`)
/// Storage: `Staking::Validators` (r:580 w:0)
/// Proof: `Staking::Validators` (`max_values`: None, `max_size`: Some(45), added: 2520, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `Staking::ErasValidatorPrefs` (r:0 w:580)
/// Proof: `Staking::ErasValidatorPrefs` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:0 w:1)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
fn export_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `1168790`
// Estimated: `2605280`
// Minimum execution time: 31_737_516_000 picoseconds.
Weight::from_parts(31_793_526_000, 2605280)
.saturating_add(T::DbWeight::get().reads(1798_u64))
.saturating_add(T::DbWeight::get().writes(1798_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn manage_fallback() -> Weight {
// Proof Size summary in bytes:
// Measured: `328713`
// Estimated: `332178`
// Minimum execution time: 538_906_259_000 picoseconds.
Weight::from_parts(539_733_270_000, 332178)
.saturating_add(T::DbWeight::get().reads(10_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn admin_set() -> Weight {
// Proof Size summary in bytes:
// Measured: `308`
// Estimated: `3773`
// Minimum execution time: 399_531_000 picoseconds.
Weight::from_parts(497_971_000, 3773)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
}
@@ -0,0 +1,206 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_signed`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_signed
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-hez
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_signed_fake-hez.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_signed`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_signed::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:0 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
fn register_not_full() -> Weight {
// Proof Size summary in bytes:
// Measured: `3312`
// Estimated: `6777`
// Minimum execution time: 143_730_000 picoseconds.
Weight::from_parts(146_621_000, 6777)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:2 w:2)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:2)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
fn register_eject() -> Weight {
// Proof Size summary in bytes:
// Measured: `7846`
// Estimated: `88036`
// Minimum execution time: 345_252_000 picoseconds.
Weight::from_parts(348_112_000, 88036)
.saturating_add(T::DbWeight::get().reads(39_u64))
.saturating_add(T::DbWeight::get().writes(37_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
fn submit_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `3845`
// Estimated: `7310`
// Minimum execution time: 5_672_789_000 picoseconds.
Weight::from_parts(6_445_424_000, 7310)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
fn unset_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `6737`
// Estimated: `10202`
// Minimum execution time: 8_071_243_000 picoseconds.
Weight::from_parts(8_089_732_000, 10202)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
fn bail() -> Weight {
// Proof Size summary in bytes:
// Measured: `4777`
// Estimated: `84967`
// Minimum execution time: 234_231_000 picoseconds.
Weight::from_parts(240_031_000, 84967)
.saturating_add(T::DbWeight::get().reads(38_u64))
.saturating_add(T::DbWeight::get().writes(35_u64))
}
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// The range of component `p` is `[1, 32]`.
fn clear_old_round_data(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `3767 + p * (32 ±0)`
// Estimated: `7232 + p * (2507 ±0)`
// Minimum execution time: 143_121_000 picoseconds.
Weight::from_parts(141_105_005, 7232)
// Standard Error: 44_586
.saturating_add(Weight::from_parts(1_987_686, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(3_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 2507).saturating_mul(p.into()))
}
}
@@ -0,0 +1,206 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_signed`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_signed
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-ksm
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_signed_fake-ksm.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_signed`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_signed::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:0 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
fn register_not_full() -> Weight {
// Proof Size summary in bytes:
// Measured: `3180`
// Estimated: `6645`
// Minimum execution time: 141_781_000 picoseconds.
Weight::from_parts(144_891_000, 6645)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:2 w:2)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:2)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
fn register_eject() -> Weight {
// Proof Size summary in bytes:
// Measured: `7144`
// Estimated: `47734`
// Minimum execution time: 303_662_000 picoseconds.
Weight::from_parts(306_382_000, 47734)
.saturating_add(T::DbWeight::get().reads(23_u64))
.saturating_add(T::DbWeight::get().writes(21_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
fn submit_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `3697`
// Estimated: `7162`
// Minimum execution time: 2_316_144_000 picoseconds.
Weight::from_parts(2_483_425_000, 7162)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
fn unset_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `8620`
// Estimated: `12085`
// Minimum execution time: 2_016_652_000 picoseconds.
Weight::from_parts(2_284_763_000, 12085)
.saturating_add(T::DbWeight::get().reads(7_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
fn bail() -> Weight {
// Proof Size summary in bytes:
// Measured: `4110`
// Estimated: `44700`
// Minimum execution time: 200_051_000 picoseconds.
Weight::from_parts(201_981_000, 44700)
.saturating_add(T::DbWeight::get().reads(22_u64))
.saturating_add(T::DbWeight::get().writes(19_u64))
}
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// The range of component `p` is `[1, 16]`.
fn clear_old_round_data(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `3622 + p * (31 ±0)`
// Estimated: `7089 + p * (2507 ±0)`
// Minimum execution time: 141_960_000 picoseconds.
Weight::from_parts(142_125_963, 7089)
// Standard Error: 117_080
.saturating_add(Weight::from_parts(1_784_427, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes(3_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 2507).saturating_mul(p.into()))
}
}
@@ -0,0 +1,151 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_unsigned`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `3`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_unsigned
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 3
// --genesis-builder-preset
// fake-hez
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --extra
// --output
// ./pezpallet_election_provider_multi_block_unsigned_fake-hez.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_unsigned`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_unsigned::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::MinimumScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::MinimumScore` (`max_values`: Some(1), `max_size`: Some(48), added: 543, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
fn validate_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `378`
// Estimated: `3843`
// Minimum execution time: 3_343_638_000 picoseconds.
Weight::from_parts(3_863_700_000, 3843)
.saturating_add(T::DbWeight::get().reads(8_u64))
}
/// Storage: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::MinimumScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::MinimumScore` (`max_values`: Some(1), `max_size`: Some(48), added: 543, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:4 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:4)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn submit_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `1451085`
// Estimated: `1461975`
// Minimum execution time: 27_632_103_000 picoseconds.
Weight::from_parts(27_843_954_000, 1461975)
.saturating_add(T::DbWeight::get().reads(14_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:32 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// The range of component `p` is `[1, 32]`.
fn mine_solution(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + p * (360895 ±0)`
// Estimated: `332140 + p * (348312 ±2_731)`
// Minimum execution time: 926_273_131_000 picoseconds.
Weight::from_parts(926_273_131_000, 332140)
// Standard Error: 303_324_142_965
.saturating_add(Weight::from_parts(6_610_814_674_792, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 348312).saturating_mul(p.into()))
}
}
@@ -0,0 +1,151 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_unsigned`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-18, STEPS: `5`, REPEAT: `3`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_unsigned
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 3
// --genesis-builder-preset
// fake-ksm
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --extra
// --output
// ./pezpallet_election_provider_multi_block_unsigned_fake-ksm.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_unsigned`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_unsigned::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:0)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::MinimumScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::MinimumScore` (`max_values`: Some(1), `max_size`: Some(48), added: 543, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xc209f5d8eb920681b56c64b8694ea78c` (r:1 w:0)
fn validate_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `378`
// Estimated: `3843`
// Minimum execution time: 2_236_486_000 picoseconds.
Weight::from_parts(2_276_596_000, 3843)
.saturating_add(T::DbWeight::get().reads(8_u64))
}
/// Storage: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x33ed3d010c1fea25c2adbfba9297161f` (r:1 w:0)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::MinimumScore` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::MinimumScore` (`max_values`: Some(1), `max_size`: Some(48), added: 543, mode: `Measured`)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:4 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionY` (r:0 w:4)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionY` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
fn submit_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `1440523`
// Estimated: `1451413`
// Minimum execution time: 30_959_432_000 picoseconds.
Weight::from_parts(31_005_092_000, 1451413)
.saturating_add(T::DbWeight::get().reads(14_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:16 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// The range of component `p` is `[1, 16]`.
fn mine_solution(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `39458 + p * (349682 ±0)`
// Estimated: `26136 + p * (352057 ±1_160)`
// Minimum execution time: 3_353_004_496_000 picoseconds.
Weight::from_parts(3_353_004_496_000, 26136)
// Standard Error: 376_745_635_821
.saturating_add(Weight::from_parts(6_831_608_018_289, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 352057).saturating_mul(p.into()))
}
}
@@ -0,0 +1,242 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_verifier`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_verifier
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-hez
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_verifier_fake-hez.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_verifier`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_verifier::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
fn on_initialize_valid_non_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `337306`
// Estimated: `340771`
// Minimum execution time: 4_050_122_000 picoseconds.
Weight::from_parts(4_070_462_000, 340771)
.saturating_add(T::DbWeight::get().reads(13_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:33 w:32)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
fn on_initialize_valid_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `1184612`
// Estimated: `1267277`
// Minimum execution time: 17_111_945_000 picoseconds.
Weight::from_parts(17_278_715_000, 1267277)
.saturating_add(T::DbWeight::get().reads(80_u64))
.saturating_add(T::DbWeight::get().writes(72_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:33 w:32)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:31 w:32)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
fn on_initialize_invalid_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `1185633`
// Estimated: `1268298`
// Minimum execution time: 17_293_481_000 picoseconds.
Weight::from_parts(17_381_352_000, 1268298)
.saturating_add(T::DbWeight::get().reads(110_u64))
.saturating_add(T::DbWeight::get().writes(101_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:32 w:32)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(45072), added: 47547, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(64026), added: 66501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(388785), added: 391260, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:31 w:31)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(33794026), added: 33796501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:31 w:31)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(181), added: 2656, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// The range of component `v` is `[0, 31]`.
fn on_initialize_invalid_non_terminal(v: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `341548 + v * (4932 ±0)`
// Estimated: `443308 + v * (4988 ±806)`
// Minimum execution time: 1_165_016_000 picoseconds.
Weight::from_parts(1_057_101_975, 443308)
// Standard Error: 4_684_378
.saturating_add(Weight::from_parts(27_427_295, 0).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(46_u64))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(37_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_parts(0, 4988).saturating_mul(v.into()))
}
}
@@ -0,0 +1,240 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Autogenerated weights for `pezpallet_election_provider_multi_block_verifier`
//!
//! This is a special template for `election-provider-multi-block` pallet. This is required because
// ! we don't want to generate the `trait WeightInfo`.
//!
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-06-17, STEPS: `5`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `ggwpez-ref-hw`, CPU: `AMD EPYC 7232P 8-Core Processor`
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
// Executed Command:
// ../../../../../target/release/frame-omni-bencher
// v1
// benchmark
// pallet
// --pallet
// pezpallet_election_provider_multi_block_verifier
// --extrinsic
// *
// --runtime
// ../../../../../target/release/wbuild/pezpallet-staking-async-teyrchain-runtime/pezpallet_staking_async_teyrchain_runtime.compact.wasm
// --steps
// 5
// --repeat
// 5
// --genesis-builder-preset
// fake-ksm
// --template
// ../../../../../bizinikiwi/pezframe/election-provider-multi-block/src/template.hbs
// --heap-pages
// 65000
// --output
// ./pezpallet_election_provider_multi_block_verifier_fake-ksm.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
/// Weights for `pezpallet_election_provider_multi_block_verifier`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: pezframe_system::Config> crate::weights::traits::pezpallet_election_provider_multi_block_verifier::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:1 w:0)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
fn on_initialize_valid_non_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `350585`
// Estimated: `354050`
// Minimum execution time: 8_603_879_000 picoseconds.
Weight::from_parts(8_934_521_000, 354050)
.saturating_add(T::DbWeight::get().reads(13_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:17 w:16)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionScore` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionScore` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:0 w:1)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
fn on_initialize_valid_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `1183276`
// Estimated: `1226341`
// Minimum execution time: 18_426_816_000 picoseconds.
Weight::from_parts(18_490_837_000, 1226341)
.saturating_add(T::DbWeight::get().reads(48_u64))
.saturating_add(T::DbWeight::get().writes(40_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:17 w:16)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:15 w:16)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
fn on_initialize_invalid_terminal() -> Weight {
// Proof Size summary in bytes:
// Measured: `1183625`
// Estimated: `1226690`
// Minimum execution time: 18_057_114_000 picoseconds.
Weight::from_parts(18_334_996_000, 1226690)
.saturating_add(T::DbWeight::get().reads(62_u64))
.saturating_add(T::DbWeight::get().writes(53_u64))
}
/// Storage: `MultiBlockElection::CurrentPhase` (r:1 w:1)
/// Proof: `MultiBlockElection::CurrentPhase` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::StatusStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionVerifier::StatusStorage` (`max_values`: Some(1), `max_size`: Some(5), added: 500, mode: `Measured`)
/// Storage: `MultiBlockElection::Round` (r:1 w:0)
/// Proof: `MultiBlockElection::Round` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SortedScores` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SortedScores` (`max_values`: None, `max_size`: Some(653), added: 3128, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionStorage` (r:16 w:16)
/// Proof: `MultiBlockElectionSigned::SubmissionStorage` (`max_values`: None, `max_size`: Some(50064), added: 52539, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Proof: UNKNOWN KEY `0xa143099d7a337c5fd879b91b2b157c2d` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedTargetSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedTargetSnapshot` (`max_values`: None, `max_size`: Some(128026), added: 130501, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x5640fd84ada5e16d1b6739279282536c` (r:1 w:0)
/// Storage: `MultiBlockElection::PagedVoterSnapshot` (r:1 w:0)
/// Proof: `MultiBlockElection::PagedVoterSnapshot` (`max_values`: None, `max_size`: Some(431919), added: 434394, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x6f320d44e42312c78638e6c92dff65af` (r:1 w:0)
/// Storage: `MultiBlockElection::DesiredTargets` (r:1 w:0)
/// Proof: `MultiBlockElection::DesiredTargets` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedValidVariant` (r:1 w:0)
/// Proof: `MultiBlockElectionVerifier::QueuedValidVariant` (`max_values`: None, `max_size`: Some(13), added: 2488, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionX` (r:15 w:15)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionX` (`max_values`: None, `max_size`: Some(37538026), added: 37540501, mode: `Measured`)
/// Storage: `MultiBlockElectionVerifier::QueuedSolutionBackings` (r:15 w:15)
/// Proof: `MultiBlockElectionVerifier::QueuedSolutionBackings` (`max_values`: None, `max_size`: Some(52026), added: 54501, mode: `Measured`)
/// Storage: `MultiBlockElectionSigned::SubmissionMetadataStorage` (r:1 w:1)
/// Proof: `MultiBlockElectionSigned::SubmissionMetadataStorage` (`max_values`: None, `max_size`: Some(165), added: 2640, mode: `Measured`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(211), added: 2686, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x48384a816e4f71a936cb76dc9e303f2a` (r:1 w:0)
/// The range of component `v` is `[0, 15]`.
fn on_initialize_invalid_non_terminal(v: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `384413 + v * (8974 ±0)`
// Estimated: `502395 + v * (7186 ±2_803)`
// Minimum execution time: 1_502_809_000 picoseconds.
Weight::from_parts(4_607_201_267, 502395)
.saturating_add(T::DbWeight::get().reads(30_u64))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(21_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_parts(0, 7186).saturating_mul(v.into()))
}
}