Configurable voting-degree in council elections pallet (#13305)

* configurable council elections pallet

* configurable council elections pallet

* add warning

* reduce sizes

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

* fix stuff

* make assert

* fix docs

* fix docs again

* fix docs again

* Update frame/elections-phragmen/src/lib.rs

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>

* Update frame/elections-phragmen/src/lib.rs

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>

* Update frame/elections-phragmen/src/lib.rs

Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>

* fix docs

---------

Co-authored-by: command-bot <>
Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com>
This commit is contained in:
Kian Paimani
2023-02-08 11:37:36 -03:00
committed by GitHub
parent 2f3f7d6b07
commit 928a12405b
5 changed files with 216 additions and 240 deletions
+4 -2
View File
@@ -1003,8 +1003,9 @@ parameter_types! {
pub const TermDuration: BlockNumber = 7 * DAYS;
pub const DesiredMembers: u32 = 13;
pub const DesiredRunnersUp: u32 = 7;
pub const MaxVoters: u32 = 10 * 1000;
pub const MaxCandidates: u32 = 1000;
pub const MaxVotesPerVoter: u32 = 16;
pub const MaxVoters: u32 = 512;
pub const MaxCandidates: u32 = 64;
pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect";
}
@@ -1029,6 +1030,7 @@ impl pallet_elections_phragmen::Config for Runtime {
type DesiredRunnersUp = DesiredRunnersUp;
type TermDuration = TermDuration;
type MaxVoters = MaxVoters;
type MaxVotesPerVoter = MaxVotesPerVoter;
type MaxCandidates = MaxCandidates;
type WeightInfo = pallet_elections_phragmen::weights::SubstrateWeight<Runtime>;
}
@@ -148,7 +148,7 @@ fn clean<T: Config>() {
benchmarks! {
// -- Signed ones
vote_equal {
let v in 1 .. (MAXIMUM_VOTE as u32);
let v in 1 .. T::MaxVotesPerVoter::get();
clean::<T>();
// create a bunch of candidates.
@@ -168,7 +168,7 @@ benchmarks! {
}: vote(RawOrigin::Signed(caller), votes, stake)
vote_more {
let v in 2 .. (MAXIMUM_VOTE as u32);
let v in 2 .. T::MaxVotesPerVoter::get();
clean::<T>();
// create a bunch of candidates.
@@ -190,7 +190,7 @@ benchmarks! {
}: vote(RawOrigin::Signed(caller), votes, stake / <BalanceOf<T>>::from(10u32))
vote_less {
let v in 2 .. (MAXIMUM_VOTE as u32);
let v in 2 .. T::MaxVotesPerVoter::get();
clean::<T>();
// create a bunch of candidates.
@@ -212,7 +212,7 @@ benchmarks! {
remove_voter {
// we fix the number of voted candidates to max
let v = MAXIMUM_VOTE as u32;
let v = T::MaxVotesPerVoter::get();
clean::<T>();
// create a bunch of candidates.
@@ -368,7 +368,7 @@ benchmarks! {
clean::<T>();
let all_candidates = submit_candidates::<T>(T::MaxCandidates::get(), "candidates")?;
distribute_voters::<T>(all_candidates, v, MAXIMUM_VOTE)?;
distribute_voters::<T>(all_candidates, v, T::MaxVotesPerVoter::get() as usize)?;
// all candidates leave.
<Candidates<T>>::kill();
@@ -389,17 +389,17 @@ benchmarks! {
// that we give all candidates a self vote to make sure they are all considered.
let c in 1 .. T::MaxCandidates::get();
let v in 1 .. T::MaxVoters::get();
let e in (T::MaxVoters::get()) .. T::MaxVoters::get() as u32 * MAXIMUM_VOTE as u32;
let e in (T::MaxVoters::get()) .. T::MaxVoters::get() * T::MaxVotesPerVoter::get();
clean::<T>();
// so we have a situation with v and e. we want e to basically always be in the range of `e
// -> e * MAXIMUM_VOTE`, but we cannot express that now with the benchmarks. So what we do
// is: when c is being iterated, v, and e are max and fine. when v is being iterated, e is
// being set to max and this is a problem. In these cases, we cap e to a lower value, namely
// v * MAXIMUM_VOTE. when e is being iterated, v is at max, and again fine. all in all,
// votes_per_voter can never be more than MAXIMUM_VOTE. Note that this might cause `v` to be
// an overestimate.
let votes_per_voter = (e / v).min(MAXIMUM_VOTE as u32);
// -> e * T::MaxVotesPerVoter::get()`, but we cannot express that now with the benchmarks.
// So what we do is: when c is being iterated, v, and e are max and fine. when v is being
// iterated, e is being set to max and this is a problem. In these cases, we cap e to a
// lower value, namely v * T::MaxVotesPerVoter::get(). when e is being iterated, v is at
// max, and again fine. all in all, votes_per_voter can never be more than
// T::MaxVotesPerVoter::get(). Note that this might cause `v` to be an overestimate.
let votes_per_voter = (e / v).min(T::MaxVotesPerVoter::get());
let all_candidates = submit_candidates_with_self_vote::<T>(c, "candidates")?;
let _ = distribute_voters::<T>(all_candidates, v.saturating_sub(c), votes_per_voter as usize)?;
@@ -421,68 +421,6 @@ benchmarks! {
}
}
#[extra]
election_phragmen_c_e {
let c in 1 .. T::MaxCandidates::get();
let e in (T::MaxVoters::get()) .. T::MaxVoters::get() * MAXIMUM_VOTE as u32;
let fixed_v = T::MaxVoters::get();
clean::<T>();
let votes_per_voter = e / fixed_v;
let all_candidates = submit_candidates_with_self_vote::<T>(c, "candidates")?;
let _ = distribute_voters::<T>(
all_candidates,
fixed_v - c,
votes_per_voter as usize,
)?;
}: {
<Elections<T>>::on_initialize(T::TermDuration::get());
}
verify {
assert_eq!(<Elections<T>>::members().len() as u32, T::DesiredMembers::get().min(c));
assert_eq!(
<Elections<T>>::runners_up().len() as u32,
T::DesiredRunnersUp::get().min(c.saturating_sub(T::DesiredMembers::get())),
);
#[cfg(test)]
{
// reset members in between benchmark tests.
use crate::tests::MEMBERS;
MEMBERS.with(|m| *m.borrow_mut() = vec![]);
}
}
#[extra]
election_phragmen_v {
let v in 4 .. 16;
let fixed_c = T::MaxCandidates::get() / 10;
let fixed_e = 64;
clean::<T>();
let votes_per_voter = fixed_e / v;
let all_candidates = submit_candidates_with_self_vote::<T>(fixed_c, "candidates")?;
let _ = distribute_voters::<T>(all_candidates, v, votes_per_voter as usize)?;
}: {
<Elections<T>>::on_initialize(T::TermDuration::get());
}
verify {
assert_eq!(<Elections<T>>::members().len() as u32, T::DesiredMembers::get().min(fixed_c));
assert_eq!(
<Elections<T>>::runners_up().len() as u32,
T::DesiredRunnersUp::get().min(fixed_c.saturating_sub(T::DesiredMembers::get())),
);
#[cfg(test)]
{
// reset members in between benchmark tests.
use crate::tests::MEMBERS;
MEMBERS.with(|m| *m.borrow_mut() = vec![]);
}
}
impl_benchmark_test_suite!(
Elections,
crate::tests::ExtBuilder::default().desired_members(13).desired_runners_up(7),
+65 -31
View File
@@ -43,14 +43,14 @@
//! ### Voting
//!
//! Voters can vote for a limited number of the candidates by providing a list of account ids,
//! bounded by [`MAXIMUM_VOTE`]. Invalid votes (voting for non-candidates) and duplicate votes are
//! ignored during election. Yet, a voter _might_ vote for a future candidate. Voters reserve a bond
//! as they vote. Each vote defines a `value`. This amount is locked from the account of the voter
//! and indicates the weight of the vote. Voters can update their votes at any time by calling
//! `vote()` again. This can update the vote targets (which might update the deposit) or update the
//! vote's stake ([`Voter::stake`]). After a round, votes are kept and might still be valid for
//! further rounds. A voter is responsible for calling `remove_voter` once they are done to have
//! their bond back and remove the lock.
//! bounded by [`Config::MaxVotesPerVoter`]. Invalid votes (voting for non-candidates) and duplicate
//! votes are ignored during election. Yet, a voter _might_ vote for a future candidate. Voters
//! reserve a bond as they vote. Each vote defines a `value`. This amount is locked from the account
//! of the voter and indicates the weight of the vote. Voters can update their votes at any time by
//! calling `vote()` again. This can update the vote targets (which might update the deposit) or
//! update the vote's stake ([`Voter::stake`]). After a round, votes are kept and might still be
//! valid for further rounds. A voter is responsible for calling `remove_voter` once they are done
//! to have their bond back and remove the lock.
//!
//! See [`Call::vote`], [`Call::remove_voter`].
//!
@@ -124,9 +124,6 @@ pub mod migrations;
const LOG_TARGET: &str = "runtime::elections-phragmen";
/// The maximum votes allowed per voter.
pub const MAXIMUM_VOTE: usize = 16;
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency<
@@ -254,19 +251,29 @@ pub mod pallet {
/// The maximum number of candidates in a phragmen election.
///
/// Warning: The election happens onchain, and this value will determine
/// the size of the election. When this limit is reached no more
/// candidates are accepted in the election.
/// Warning: This impacts the size of the election which is run onchain. Chose wisely, and
/// consider how it will impact `T::WeightInfo::election_phragmen`.
///
/// When this limit is reached no more candidates are accepted in the election.
#[pallet::constant]
type MaxCandidates: Get<u32>;
/// The maximum number of voters to allow in a phragmen election.
///
/// Warning: This impacts the size of the election which is run onchain.
/// Warning: This impacts the size of the election which is run onchain. Chose wisely, and
/// consider how it will impact `T::WeightInfo::election_phragmen`.
///
/// When the limit is reached the new voters are ignored.
#[pallet::constant]
type MaxVoters: Get<u32>;
/// Maximum numbers of votes per voter.
///
/// Warning: This impacts the size of the election which is run onchain. Chose wisely, and
/// consider how it will impact `T::WeightInfo::election_phragmen`.
#[pallet::constant]
type MaxVotesPerVoter: Get<u32>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
@@ -284,6 +291,41 @@ pub mod pallet {
Weight::zero()
}
}
fn integrity_test() {
let block_weight = T::BlockWeights::get().max_block;
// mind the order.
let election_weight = T::WeightInfo::election_phragmen(
T::MaxCandidates::get(),
T::MaxVoters::get(),
T::MaxVotesPerVoter::get() * T::MaxVoters::get(),
);
let to_seconds = |w: &Weight| {
w.ref_time() as f32 /
frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND as f32
};
frame_support::log::debug!(
target: LOG_TARGET,
"election weight {}s ({:?}) // chain's block weight {}s ({:?})",
to_seconds(&election_weight),
election_weight,
to_seconds(&block_weight),
block_weight,
);
assert!(
election_weight.all_lt(block_weight),
"election weight {}s ({:?}) will exceed a {}s chain's block weight ({:?}) (MaxCandidates {}, MaxVoters {}, MaxVotesPerVoter {} -- tweak these parameters)",
election_weight,
to_seconds(&election_weight),
to_seconds(&block_weight),
block_weight,
T::MaxCandidates::get(),
T::MaxVoters::get(),
T::MaxVotesPerVoter::get(),
);
}
}
#[pallet::call]
@@ -307,10 +349,6 @@ pub mod pallet {
///
/// It is the responsibility of the caller to **NOT** place all of their balance into the
/// lock and keep some for further operations.
///
/// # <weight>
/// We assume the maximum weight among all 3 cases: vote_equal, vote_more and vote_less.
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(
T::WeightInfo::vote_more(votes.len() as u32)
@@ -324,8 +362,10 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;
// votes should not be empty and more than `MAXIMUM_VOTE` in any case.
ensure!(votes.len() <= MAXIMUM_VOTE, Error::<T>::MaximumVotesExceeded);
ensure!(
votes.len() <= T::MaxVotesPerVoter::get() as usize,
Error::<T>::MaximumVotesExceeded
);
ensure!(!votes.is_empty(), Error::<T>::NoVotes);
let candidates_count = <Candidates<T>>::decode_len().unwrap_or(0);
@@ -1006,7 +1046,7 @@ impl<T: Config> Pallet<T> {
// count](https://en.wikipedia.org/wiki/Borda_count). We weigh everyone's vote for
// that new member by a multiplier based on the order of the votes. i.e. the
// first person a voter votes for gets a 16x multiplier, the next person gets a
// 15x multiplier, an so on... (assuming `MAXIMUM_VOTE` = 16)
// 15x multiplier, an so on... (assuming `T::MaxVotesPerVoter` = 16)
let mut prime_votes = new_members_sorted_by_id
.iter()
.map(|c| (&c.0, BalanceOf::<T>::zero()))
@@ -1014,7 +1054,7 @@ impl<T: Config> Pallet<T> {
for (_, stake, votes) in voters_and_stakes.into_iter() {
for (vote_multiplier, who) in
votes.iter().enumerate().map(|(vote_position, who)| {
((MAXIMUM_VOTE - vote_position) as u32, who)
((T::MaxVotesPerVoter::get() as usize - vote_position) as u32, who)
}) {
if let Ok(i) = prime_votes.binary_search_by_key(&who, |k| k.0) {
prime_votes[i].1 = prime_votes[i]
@@ -1173,16 +1213,9 @@ mod tests {
};
use substrate_test_utils::assert_eq_uvec;
parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(
frame_support::weights::Weight::from_ref_time(1024).set_proof_size(u64::MAX),
);
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = BlockWeights;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
@@ -1297,6 +1330,7 @@ mod tests {
type KickedMember = ();
type WeightInfo = ();
type MaxVoters = PhragmenMaxVoters;
type MaxVotesPerVoter = ConstU32<16>;
type MaxCandidates = PhragmenMaxCandidates;
}
+133 -132
View File
@@ -18,25 +18,26 @@
//! Autogenerated weights for pallet_elections_phragmen
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-01-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! DATE: 2023-02-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! HOSTNAME: `runner-b3zmxxc-project-145-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/substrate
// target/production/substrate
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_elections_phragmen
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./frame/elections-phragmen/src/weights.rs
// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json
// --pallet=pallet_elections_phragmen
// --chain=dev
// --header=./HEADER-APACHE2
// --output=./frame/elections-phragmen/src/weights.rs
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
@@ -80,10 +81,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `499 + v * (80 ±0)`
// Estimated: `9726 + v * (320 ±0)`
// Minimum execution time: 25_407 nanoseconds.
Weight::from_parts(26_035_742, 9726)
// Standard Error: 2_162
.saturating_add(Weight::from_ref_time(120_321).saturating_mul(v.into()))
// Minimum execution time: 27_362 nanoseconds.
Weight::from_parts(28_497_963, 9726)
// Standard Error: 3_968
.saturating_add(Weight::from_ref_time(176_840).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -103,10 +104,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `467 + v * (80 ±0)`
// Estimated: `9598 + v * (320 ±0)`
// Minimum execution time: 34_477 nanoseconds.
Weight::from_parts(35_197_694, 9598)
// Standard Error: 2_089
.saturating_add(Weight::from_ref_time(116_792).saturating_mul(v.into()))
// Minimum execution time: 37_120 nanoseconds.
Weight::from_parts(38_455_302, 9598)
// Standard Error: 5_478
.saturating_add(Weight::from_ref_time(219_678).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -126,10 +127,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `499 + v * (80 ±0)`
// Estimated: `9726 + v * (320 ±0)`
// Minimum execution time: 34_573 nanoseconds.
Weight::from_parts(35_254_508, 9726)
// Standard Error: 2_076
.saturating_add(Weight::from_ref_time(110_656).saturating_mul(v.into()))
// Minimum execution time: 36_928 nanoseconds.
Weight::from_parts(38_334_669, 9726)
// Standard Error: 5_271
.saturating_add(Weight::from_ref_time(232_355).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -142,8 +143,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `989`
// Estimated: `7238`
// Minimum execution time: 31_469 nanoseconds.
Weight::from_parts(31_877_000, 7238)
// Minimum execution time: 34_338 nanoseconds.
Weight::from_parts(35_672_000, 7238)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
@@ -153,30 +154,30 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections RunnersUp (r:1 w:0)
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `c` is `[1, 64]`.
fn submit_candidacy(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1687 + c * (48 ±0)`
// Estimated: `6540 + c * (144 ±0)`
// Minimum execution time: 26_969 nanoseconds.
Weight::from_parts(28_584_266, 6540)
// Standard Error: 93
.saturating_add(Weight::from_ref_time(52_393).saturating_mul(c.into()))
// Measured: `1697 + c * (48 ±0)`
// Estimated: `6576 + c * (144 ±0)`
// Minimum execution time: 31_864 nanoseconds.
Weight::from_parts(33_490_161, 6576)
// Standard Error: 2_643
.saturating_add(Weight::from_ref_time(158_386).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
.saturating_add(Weight::from_proof_size(144).saturating_mul(c.into()))
}
/// Storage: Elections Candidates (r:1 w:1)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `c` is `[1, 64]`.
fn renounce_candidacy_candidate(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `348 + c * (48 ±0)`
// Estimated: `830 + c * (48 ±0)`
// Minimum execution time: 23_635 nanoseconds.
Weight::from_parts(23_482_193, 830)
// Standard Error: 103
.saturating_add(Weight::from_ref_time(33_759).saturating_mul(c.into()))
// Measured: `349 + c * (48 ±0)`
// Estimated: `844 + c * (48 ±0)`
// Minimum execution time: 27_292 nanoseconds.
Weight::from_parts(28_364_955, 844)
// Standard Error: 1_335
.saturating_add(Weight::from_ref_time(78_086).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
.saturating_add(Weight::from_proof_size(48).saturating_mul(c.into()))
@@ -195,8 +196,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `2027`
// Estimated: `12115`
// Minimum execution time: 39_124 nanoseconds.
Weight::from_parts(39_575_000, 12115)
// Minimum execution time: 45_975 nanoseconds.
Weight::from_parts(47_103_000, 12115)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
@@ -206,8 +207,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `975`
// Estimated: `1470`
// Minimum execution time: 25_377 nanoseconds.
Weight::from_parts(25_696_000, 1470)
// Minimum execution time: 29_243 nanoseconds.
Weight::from_parts(30_582_000, 1470)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -236,12 +237,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Proof Size summary in bytes:
// Measured: `2027`
// Estimated: `14718`
// Minimum execution time: 44_919 nanoseconds.
Weight::from_parts(45_548_000, 14718)
// Minimum execution time: 52_527 nanoseconds.
Weight::from_parts(53_538_000, 14718)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
/// Storage: Elections Voting (r:10001 w:10000)
/// Storage: Elections Voting (r:513 w:512)
/// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured)
/// Storage: Elections Members (r:1 w:0)
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
@@ -249,24 +250,24 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections Candidates (r:1 w:0)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Balances Locks (r:10000 w:10000)
/// Storage: Balances Locks (r:512 w:512)
/// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
/// Storage: System Account (r:10000 w:10000)
/// Storage: System Account (r:512 w:512)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// The range of component `v` is `[5000, 10000]`.
/// The range of component `d` is `[0, 5000]`.
/// The range of component `v` is `[256, 512]`.
/// The range of component `d` is `[0, 256]`.
fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `36028 + v * (872 ±0)`
// Estimated: `149172 + v * (12340 ±0)`
// Minimum execution time: 297_544_939 nanoseconds.
Weight::from_parts(298_088_024_000, 149172)
// Standard Error: 264_599
.saturating_add(Weight::from_ref_time(38_142_857).saturating_mul(v.into()))
// Measured: `1115 + v * (875 ±0)`
// Estimated: `8448 + v * (12352 ±0)`
// Minimum execution time: 14_934_185 nanoseconds.
Weight::from_parts(15_014_057_000, 8448)
// Standard Error: 245_588
.saturating_add(Weight::from_ref_time(35_586_946).saturating_mul(v.into()))
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_proof_size(12340).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(12352).saturating_mul(v.into()))
}
/// Storage: Elections Candidates (r:1 w:1)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
@@ -274,11 +275,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections RunnersUp (r:1 w:1)
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections Voting (r:10001 w:0)
/// Storage: Elections Voting (r:513 w:0)
/// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured)
/// Storage: Council Proposals (r:1 w:0)
/// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: System Account (r:980 w:980)
/// Storage: System Account (r:44 w:44)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Elections ElectionRounds (r:1 w:1)
/// Proof Skipped: Elections ElectionRounds (max_values: Some(1), max_size: None, mode: Measured)
@@ -286,27 +287,27 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Council Prime (r:0 w:1)
/// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `v` is `[1, 10000]`.
/// The range of component `e` is `[10000, 160000]`.
/// The range of component `c` is `[1, 64]`.
/// The range of component `v` is `[1, 512]`.
/// The range of component `e` is `[512, 8192]`.
fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + v * (639 ±0) + e * (28 ±0)`
// Estimated: `5350105 + c * (2582 ±0) + v * (5721 ±6) + e * (123 ±0)`
// Minimum execution time: 21_844_965 nanoseconds.
Weight::from_parts(21_979_826_000, 5350105)
// Standard Error: 229_799
.saturating_add(Weight::from_ref_time(24_976_612).saturating_mul(v.into()))
// Standard Error: 14_747
.saturating_add(Weight::from_ref_time(1_025_848).saturating_mul(e.into()))
.saturating_add(T::DbWeight::get().reads(280_u64))
// Measured: `0 + v * (638 ±0) + e * (28 ±0)`
// Estimated: `330033 + v * (5229 ±6) + e * (89 ±0) + c * (2135 ±7)`
// Minimum execution time: 1_273_671 nanoseconds.
Weight::from_parts(1_279_716_000, 330033)
// Standard Error: 543_277
.saturating_add(Weight::from_ref_time(20_613_753).saturating_mul(v.into()))
// Standard Error: 34_857
.saturating_add(Weight::from_ref_time(688_354).saturating_mul(e.into()))
.saturating_add(T::DbWeight::get().reads(21_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(T::DbWeight::get().writes(6_u64))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_proof_size(2582).saturating_mul(c.into()))
.saturating_add(Weight::from_proof_size(5721).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(123).saturating_mul(e.into()))
.saturating_add(Weight::from_proof_size(5229).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(89).saturating_mul(e.into()))
.saturating_add(Weight::from_proof_size(2135).saturating_mul(c.into()))
}
}
@@ -327,10 +328,10 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `499 + v * (80 ±0)`
// Estimated: `9726 + v * (320 ±0)`
// Minimum execution time: 25_407 nanoseconds.
Weight::from_parts(26_035_742, 9726)
// Standard Error: 2_162
.saturating_add(Weight::from_ref_time(120_321).saturating_mul(v.into()))
// Minimum execution time: 27_362 nanoseconds.
Weight::from_parts(28_497_963, 9726)
// Standard Error: 3_968
.saturating_add(Weight::from_ref_time(176_840).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -350,10 +351,10 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `467 + v * (80 ±0)`
// Estimated: `9598 + v * (320 ±0)`
// Minimum execution time: 34_477 nanoseconds.
Weight::from_parts(35_197_694, 9598)
// Standard Error: 2_089
.saturating_add(Weight::from_ref_time(116_792).saturating_mul(v.into()))
// Minimum execution time: 37_120 nanoseconds.
Weight::from_parts(38_455_302, 9598)
// Standard Error: 5_478
.saturating_add(Weight::from_ref_time(219_678).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -373,10 +374,10 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `499 + v * (80 ±0)`
// Estimated: `9726 + v * (320 ±0)`
// Minimum execution time: 34_573 nanoseconds.
Weight::from_parts(35_254_508, 9726)
// Standard Error: 2_076
.saturating_add(Weight::from_ref_time(110_656).saturating_mul(v.into()))
// Minimum execution time: 36_928 nanoseconds.
Weight::from_parts(38_334_669, 9726)
// Standard Error: 5_271
.saturating_add(Weight::from_ref_time(232_355).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(Weight::from_proof_size(320).saturating_mul(v.into()))
@@ -389,8 +390,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `989`
// Estimated: `7238`
// Minimum execution time: 31_469 nanoseconds.
Weight::from_parts(31_877_000, 7238)
// Minimum execution time: 34_338 nanoseconds.
Weight::from_parts(35_672_000, 7238)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
@@ -400,30 +401,30 @@ impl WeightInfo for () {
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections RunnersUp (r:1 w:0)
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `c` is `[1, 64]`.
fn submit_candidacy(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1687 + c * (48 ±0)`
// Estimated: `6540 + c * (144 ±0)`
// Minimum execution time: 26_969 nanoseconds.
Weight::from_parts(28_584_266, 6540)
// Standard Error: 93
.saturating_add(Weight::from_ref_time(52_393).saturating_mul(c.into()))
// Measured: `1697 + c * (48 ±0)`
// Estimated: `6576 + c * (144 ±0)`
// Minimum execution time: 31_864 nanoseconds.
Weight::from_parts(33_490_161, 6576)
// Standard Error: 2_643
.saturating_add(Weight::from_ref_time(158_386).saturating_mul(c.into()))
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
.saturating_add(Weight::from_proof_size(144).saturating_mul(c.into()))
}
/// Storage: Elections Candidates (r:1 w:1)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `c` is `[1, 64]`.
fn renounce_candidacy_candidate(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `348 + c * (48 ±0)`
// Estimated: `830 + c * (48 ±0)`
// Minimum execution time: 23_635 nanoseconds.
Weight::from_parts(23_482_193, 830)
// Standard Error: 103
.saturating_add(Weight::from_ref_time(33_759).saturating_mul(c.into()))
// Measured: `349 + c * (48 ±0)`
// Estimated: `844 + c * (48 ±0)`
// Minimum execution time: 27_292 nanoseconds.
Weight::from_parts(28_364_955, 844)
// Standard Error: 1_335
.saturating_add(Weight::from_ref_time(78_086).saturating_mul(c.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
.saturating_add(Weight::from_proof_size(48).saturating_mul(c.into()))
@@ -442,8 +443,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `2027`
// Estimated: `12115`
// Minimum execution time: 39_124 nanoseconds.
Weight::from_parts(39_575_000, 12115)
// Minimum execution time: 45_975 nanoseconds.
Weight::from_parts(47_103_000, 12115)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
@@ -453,8 +454,8 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `975`
// Estimated: `1470`
// Minimum execution time: 25_377 nanoseconds.
Weight::from_parts(25_696_000, 1470)
// Minimum execution time: 29_243 nanoseconds.
Weight::from_parts(30_582_000, 1470)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
@@ -483,12 +484,12 @@ impl WeightInfo for () {
// Proof Size summary in bytes:
// Measured: `2027`
// Estimated: `14718`
// Minimum execution time: 44_919 nanoseconds.
Weight::from_parts(45_548_000, 14718)
// Minimum execution time: 52_527 nanoseconds.
Weight::from_parts(53_538_000, 14718)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
/// Storage: Elections Voting (r:10001 w:10000)
/// Storage: Elections Voting (r:513 w:512)
/// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured)
/// Storage: Elections Members (r:1 w:0)
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
@@ -496,24 +497,24 @@ impl WeightInfo for () {
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections Candidates (r:1 w:0)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Balances Locks (r:10000 w:10000)
/// Storage: Balances Locks (r:512 w:512)
/// Proof: Balances Locks (max_values: None, max_size: Some(1299), added: 3774, mode: MaxEncodedLen)
/// Storage: System Account (r:10000 w:10000)
/// Storage: System Account (r:512 w:512)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// The range of component `v` is `[5000, 10000]`.
/// The range of component `d` is `[0, 5000]`.
/// The range of component `v` is `[256, 512]`.
/// The range of component `d` is `[0, 256]`.
fn clean_defunct_voters(v: u32, _d: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `36028 + v * (872 ±0)`
// Estimated: `149172 + v * (12340 ±0)`
// Minimum execution time: 297_544_939 nanoseconds.
Weight::from_parts(298_088_024_000, 149172)
// Standard Error: 264_599
.saturating_add(Weight::from_ref_time(38_142_857).saturating_mul(v.into()))
// Measured: `1115 + v * (875 ±0)`
// Estimated: `8448 + v * (12352 ±0)`
// Minimum execution time: 14_934_185 nanoseconds.
Weight::from_parts(15_014_057_000, 8448)
// Standard Error: 245_588
.saturating_add(Weight::from_ref_time(35_586_946).saturating_mul(v.into()))
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(v.into())))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(v.into())))
.saturating_add(Weight::from_proof_size(12340).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(12352).saturating_mul(v.into()))
}
/// Storage: Elections Candidates (r:1 w:1)
/// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured)
@@ -521,11 +522,11 @@ impl WeightInfo for () {
/// Proof Skipped: Elections Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections RunnersUp (r:1 w:1)
/// Proof Skipped: Elections RunnersUp (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Elections Voting (r:10001 w:0)
/// Storage: Elections Voting (r:513 w:0)
/// Proof Skipped: Elections Voting (max_values: None, max_size: None, mode: Measured)
/// Storage: Council Proposals (r:1 w:0)
/// Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: System Account (r:980 w:980)
/// Storage: System Account (r:44 w:44)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: Elections ElectionRounds (r:1 w:1)
/// Proof Skipped: Elections ElectionRounds (max_values: Some(1), max_size: None, mode: Measured)
@@ -533,26 +534,26 @@ impl WeightInfo for () {
/// Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Council Prime (r:0 w:1)
/// Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured)
/// The range of component `c` is `[1, 1000]`.
/// The range of component `v` is `[1, 10000]`.
/// The range of component `e` is `[10000, 160000]`.
/// The range of component `c` is `[1, 64]`.
/// The range of component `v` is `[1, 512]`.
/// The range of component `e` is `[512, 8192]`.
fn election_phragmen(c: u32, v: u32, e: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + v * (639 ±0) + e * (28 ±0)`
// Estimated: `5350105 + c * (2582 ±0) + v * (5721 ±6) + e * (123 ±0)`
// Minimum execution time: 21_844_965 nanoseconds.
Weight::from_parts(21_979_826_000, 5350105)
// Standard Error: 229_799
.saturating_add(Weight::from_ref_time(24_976_612).saturating_mul(v.into()))
// Standard Error: 14_747
.saturating_add(Weight::from_ref_time(1_025_848).saturating_mul(e.into()))
.saturating_add(RocksDbWeight::get().reads(280_u64))
// Measured: `0 + v * (638 ±0) + e * (28 ±0)`
// Estimated: `330033 + v * (5229 ±6) + e * (89 ±0) + c * (2135 ±7)`
// Minimum execution time: 1_273_671 nanoseconds.
Weight::from_parts(1_279_716_000, 330033)
// Standard Error: 543_277
.saturating_add(Weight::from_ref_time(20_613_753).saturating_mul(v.into()))
// Standard Error: 34_857
.saturating_add(Weight::from_ref_time(688_354).saturating_mul(e.into()))
.saturating_add(RocksDbWeight::get().reads(21_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(v.into())))
.saturating_add(RocksDbWeight::get().writes(6_u64))
.saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_proof_size(2582).saturating_mul(c.into()))
.saturating_add(Weight::from_proof_size(5721).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(123).saturating_mul(e.into()))
.saturating_add(Weight::from_proof_size(5229).saturating_mul(v.into()))
.saturating_add(Weight::from_proof_size(89).saturating_mul(e.into()))
.saturating_add(Weight::from_proof_size(2135).saturating_mul(c.into()))
}
}
@@ -579,6 +579,7 @@ fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 {
#[test]
pub fn runtime_integrity_tests() {
#scrate::sp_tracing::try_init_simple();
<AllPalletsWithSystem as #scrate::traits::IntegrityTest>::integrity_test();
}
}