From 9bdae1fa8db6ed9fdf1cca9c0ac8b79f78e6b9bf Mon Sep 17 00:00:00 2001 From: kianenigma Date: Fri, 3 Feb 2023 01:39:06 -0300 Subject: [PATCH 01/14] configurable council elections pallet --- frame/elections-phragmen/src/benchmarking.rs | 88 +++----------------- frame/elections-phragmen/src/lib.rs | 52 +++++++----- 2 files changed, 42 insertions(+), 98 deletions(-) diff --git a/frame/elections-phragmen/src/benchmarking.rs b/frame/elections-phragmen/src/benchmarking.rs index 1fc500a8e3464..b7c04bad318b0 100644 --- a/frame/elections-phragmen/src/benchmarking.rs +++ b/frame/elections-phragmen/src/benchmarking.rs @@ -148,7 +148,7 @@ fn clean() { benchmarks! { // -- Signed ones vote_equal { - let v in 1 .. (MAXIMUM_VOTE as u32); + let v in 1 .. T::MaxVotesPerVoter::get(); clean::(); // 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::(); // create a bunch of candidates. @@ -190,7 +190,7 @@ benchmarks! { }: vote(RawOrigin::Signed(caller), votes, stake / >::from(10u32)) vote_less { - let v in 2 .. (MAXIMUM_VOTE as u32); + let v in 2 .. T::MaxVotesPerVoter::get(); clean::(); // 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::(); // create a bunch of candidates. @@ -368,7 +368,7 @@ benchmarks! { clean::(); let all_candidates = submit_candidates::(T::MaxCandidates::get(), "candidates")?; - distribute_voters::(all_candidates, v, MAXIMUM_VOTE)?; + distribute_voters::(all_candidates, v, T::MaxVotesPerVoter::get() as usize)?; // all candidates leave. >::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::(); // 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::(c, "candidates")?; let _ = distribute_voters::(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::(); - - let votes_per_voter = e / fixed_v; - - let all_candidates = submit_candidates_with_self_vote::(c, "candidates")?; - let _ = distribute_voters::( - all_candidates, - fixed_v - c, - votes_per_voter as usize, - )?; - }: { - >::on_initialize(T::TermDuration::get()); - } - verify { - assert_eq!(>::members().len() as u32, T::DesiredMembers::get().min(c)); - assert_eq!( - >::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::(); - - let votes_per_voter = fixed_e / v; - - let all_candidates = submit_candidates_with_self_vote::(fixed_c, "candidates")?; - let _ = distribute_voters::(all_candidates, v, votes_per_voter as usize)?; - }: { - >::on_initialize(T::TermDuration::get()); - } - verify { - assert_eq!(>::members().len() as u32, T::DesiredMembers::get().min(fixed_c)); - assert_eq!( - >::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), diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 1a020adb28632..e51c372c419ac 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -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 [`T::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 = <::Currency as Currency<::AccountId>>::Balance; type NegativeImbalanceOf = <::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; /// 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; + /// 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; + /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; } @@ -307,10 +314,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. - /// - /// # - /// We assume the maximum weight among all 3 cases: vote_equal, vote_more and vote_less. - /// # #[pallet::call_index(0)] #[pallet::weight( T::WeightInfo::vote_more(votes.len() as u32) @@ -324,8 +327,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::::MaximumVotesExceeded); + ensure!( + votes.len() <= T::MaxVotesPerVoter::get() as usize, + Error::::MaximumVotesExceeded + ); ensure!(!votes.is_empty(), Error::::NoVotes); let candidates_count = >::decode_len().unwrap_or(0); @@ -1006,7 +1011,7 @@ impl Pallet { // 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::::zero())) @@ -1014,7 +1019,7 @@ impl Pallet { 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] @@ -1297,6 +1302,7 @@ mod tests { type KickedMember = (); type WeightInfo = (); type MaxVoters = PhragmenMaxVoters; + type MaxVotesPerVoter = ConstU32<16>; type MaxCandidates = PhragmenMaxCandidates; } From 17ef86746af8a5915cc3396648d62bd6071d3786 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Fri, 3 Feb 2023 01:45:42 -0300 Subject: [PATCH 02/14] configurable council elections pallet --- bin/node/runtime/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 8e8ecc125dba4..540349359a45d 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1003,6 +1003,7 @@ parameter_types! { pub const TermDuration: BlockNumber = 7 * DAYS; pub const DesiredMembers: u32 = 13; pub const DesiredRunnersUp: u32 = 7; + pub const MaxVotesPerVoter: u32 = 16; pub const MaxVoters: u32 = 10 * 1000; pub const MaxCandidates: u32 = 1000; 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; } From c7136d53ad4a585d68ca8eb6ea9568b286e18ace Mon Sep 17 00:00:00 2001 From: kianenigma Date: Fri, 3 Feb 2023 02:22:50 -0300 Subject: [PATCH 03/14] add warning --- frame/elections-phragmen/src/lib.rs | 28 +++++++++++++++++++ .../procedural/src/construct_runtime/mod.rs | 1 + 2 files changed, 29 insertions(+) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index e51c372c419ac..e27fe1f18ffd0 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -291,6 +291,34 @@ 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 + }; + if election_weight.any_gt(block_weight) { + frame_support::log::error!( + target: LOG_TARGET, + "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] diff --git a/frame/support/procedural/src/construct_runtime/mod.rs b/frame/support/procedural/src/construct_runtime/mod.rs index 9e22037a6782e..18b66ddff5ffa 100644 --- a/frame/support/procedural/src/construct_runtime/mod.rs +++ b/frame/support/procedural/src/construct_runtime/mod.rs @@ -579,6 +579,7 @@ fn decl_integrity_test(scrate: &TokenStream2) -> TokenStream2 { #[test] pub fn runtime_integrity_tests() { + #scrate::sp_tracing::try_init_simple(); ::integrity_test(); } } From 38926b47f11620672ad449fa2fd3a91f475ced22 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Fri, 3 Feb 2023 13:18:26 -0300 Subject: [PATCH 04/14] reduce sizes --- bin/node/runtime/src/lib.rs | 4 +- frame/elections-phragmen/src/lib.rs | 1 + frame/elections-phragmen/src/weights.rs | 216 ++++++++++++------------ 3 files changed, 111 insertions(+), 110 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 540349359a45d..e5ecabac3032b 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1004,8 +1004,8 @@ parameter_types! { pub const DesiredMembers: u32 = 13; pub const DesiredRunnersUp: u32 = 7; pub const MaxVotesPerVoter: u32 = 16; - pub const MaxVoters: u32 = 10 * 1000; - pub const MaxCandidates: u32 = 1000; + pub const MaxVoters: u32 = 512; + pub const MaxCandidates: u32 = 64; pub const ElectionsPhragmenPalletId: LockIdentifier = *b"phrelect"; } diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index e27fe1f18ffd0..f567f1f256759 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -305,6 +305,7 @@ pub mod pallet { w.ref_time() as f32 / frame_support::weights::constants::WEIGHT_REF_TIME_PER_SECOND as f32 }; + if election_weight.any_gt(block_weight) { frame_support::log::error!( target: LOG_TARGET, diff --git a/frame/elections-phragmen/src/weights.rs b/frame/elections-phragmen/src/weights.rs index dc5d937e33eaf..72a5f824e3899 100644 --- a/frame/elections-phragmen/src/weights.rs +++ b/frame/elections-phragmen/src/weights.rs @@ -18,25 +18,25 @@ //! 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: `10`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! HOSTNAME: `Kians-MacBook-Pro-2.local`, CPU: `` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/production/substrate +// target/debug/substrate // benchmark // pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_elections_phragmen +// --steps=10 +// --repeat=10 // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./frame/elections-phragmen/src/weights.rs +// --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 +80,10 @@ impl WeightInfo for SubstrateWeight { // 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: 415_000 nanoseconds. + Weight::from_parts(421_838_802, 9726) + // Standard Error: 133_238 + .saturating_add(Weight::from_ref_time(326_568).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 +103,10 @@ impl WeightInfo for SubstrateWeight { // 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: 558_000 nanoseconds. + Weight::from_parts(556_163_102, 9598) + // Standard Error: 738_644 + .saturating_add(Weight::from_ref_time(3_391_887).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 +126,8 @@ impl WeightInfo for SubstrateWeight { // 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: 568_000 nanoseconds. + Weight::from_parts(621_939_239, 9726) .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 +140,8 @@ impl WeightInfo for SubstrateWeight { // 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: 504_000 nanoseconds. + Weight::from_parts(512_000_000, 7238) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -156,12 +154,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1687 + c * (48 ±0)` + // Measured: `1690 + 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())) + // Minimum execution time: 368_000 nanoseconds. + Weight::from_parts(406_083_483, 6540) + // Standard Error: 11_995 + .saturating_add(Weight::from_ref_time(161_971).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())) @@ -171,12 +169,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `c` is `[1, 1000]`. 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: `347 + c * (48 ±0)` + // Estimated: `825 + c * (48 ±0)` + // Minimum execution time: 332_000 nanoseconds. + Weight::from_parts(374_734_634, 825) + // Standard Error: 10_531 + .saturating_add(Weight::from_ref_time(35_062).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 +193,8 @@ impl WeightInfo for SubstrateWeight { // 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: 521_000 nanoseconds. + Weight::from_parts(531_000_000, 12115) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -206,8 +204,8 @@ impl WeightInfo for SubstrateWeight { // 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: 345_000 nanoseconds. + Weight::from_parts(381_000_000, 1470) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -236,8 +234,8 @@ impl WeightInfo for SubstrateWeight { // 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: 601_000 nanoseconds. + Weight::from_parts(610_000_000, 14718) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -257,16 +255,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `d` is `[0, 5000]`. 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: `36373 + v * (872 ±0)` + // Estimated: `32033948 + v * (9658 ±0)` + // Minimum execution time: 5_401_340_000 nanoseconds. + Weight::from_parts(5_410_097_000_000, 32033948) + // Standard Error: 13_924_977 + .saturating_add(Weight::from_ref_time(686_578_019).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(9658).saturating_mul(v.into())) } /// Storage: Elections Candidates (r:1 w:1) /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) @@ -291,22 +289,24 @@ impl WeightInfo for SubstrateWeight { /// The range of component `e` is `[10000, 160000]`. 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: `5586978 + v * (5383 ±21) + e * (99 ±1) + c * (2478 ±6)` + // Minimum execution time: 337_238_000 nanoseconds. + Weight::from_parts(338_755_000_000, 5586978) + // Standard Error: 16_598_609 + .saturating_add(Weight::from_ref_time(8_686_952).saturating_mul(c.into())) + // Standard Error: 1_659_179 + .saturating_add(Weight::from_ref_time(102_136_811).saturating_mul(v.into())) + // Standard Error: 106_480 + .saturating_add(Weight::from_ref_time(331).saturating_mul(e.into())) + .saturating_add(T::DbWeight::get().reads(448_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(5383).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(99).saturating_mul(e.into())) + .saturating_add(Weight::from_proof_size(2478).saturating_mul(c.into())) } } @@ -327,10 +327,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: 415_000 nanoseconds. + Weight::from_parts(421_838_802, 9726) + // Standard Error: 133_238 + .saturating_add(Weight::from_ref_time(326_568).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 +350,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: 558_000 nanoseconds. + Weight::from_parts(556_163_102, 9598) + // Standard Error: 738_644 + .saturating_add(Weight::from_ref_time(3_391_887).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 +373,8 @@ 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: 568_000 nanoseconds. + Weight::from_parts(621_939_239, 9726) .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 +387,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: 504_000 nanoseconds. + Weight::from_parts(512_000_000, 7238) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -403,12 +401,12 @@ impl WeightInfo for () { /// The range of component `c` is `[1, 1000]`. fn submit_candidacy(c: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1687 + c * (48 ±0)` + // Measured: `1690 + 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())) + // Minimum execution time: 368_000 nanoseconds. + Weight::from_parts(406_083_483, 6540) + // Standard Error: 11_995 + .saturating_add(Weight::from_ref_time(161_971).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())) @@ -418,12 +416,12 @@ impl WeightInfo for () { /// The range of component `c` is `[1, 1000]`. 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: `347 + c * (48 ±0)` + // Estimated: `825 + c * (48 ±0)` + // Minimum execution time: 332_000 nanoseconds. + Weight::from_parts(374_734_634, 825) + // Standard Error: 10_531 + .saturating_add(Weight::from_ref_time(35_062).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 +440,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: 521_000 nanoseconds. + Weight::from_parts(531_000_000, 12115) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -453,8 +451,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: 345_000 nanoseconds. + Weight::from_parts(381_000_000, 1470) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -483,8 +481,8 @@ 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: 601_000 nanoseconds. + Weight::from_parts(610_000_000, 14718) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -504,16 +502,16 @@ impl WeightInfo for () { /// The range of component `d` is `[0, 5000]`. 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: `36373 + v * (872 ±0)` + // Estimated: `32033948 + v * (9658 ±0)` + // Minimum execution time: 5_401_340_000 nanoseconds. + Weight::from_parts(5_410_097_000_000, 32033948) + // Standard Error: 13_924_977 + .saturating_add(Weight::from_ref_time(686_578_019).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(9658).saturating_mul(v.into())) } /// Storage: Elections Candidates (r:1 w:1) /// Proof Skipped: Elections Candidates (max_values: Some(1), max_size: None, mode: Measured) @@ -538,21 +536,23 @@ impl WeightInfo for () { /// The range of component `e` is `[10000, 160000]`. 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: `5586978 + v * (5383 ±21) + e * (99 ±1) + c * (2478 ±6)` + // Minimum execution time: 337_238_000 nanoseconds. + Weight::from_parts(338_755_000_000, 5586978) + // Standard Error: 16_598_609 + .saturating_add(Weight::from_ref_time(8_686_952).saturating_mul(c.into())) + // Standard Error: 1_659_179 + .saturating_add(Weight::from_ref_time(102_136_811).saturating_mul(v.into())) + // Standard Error: 106_480 + .saturating_add(Weight::from_ref_time(331).saturating_mul(e.into())) + .saturating_add(RocksDbWeight::get().reads(448_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(5383).saturating_mul(v.into())) + .saturating_add(Weight::from_proof_size(99).saturating_mul(e.into())) + .saturating_add(Weight::from_proof_size(2478).saturating_mul(c.into())) } } From c6c4f5818091e7175b28d2588ebbcb30e2179be4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 3 Feb 2023 16:56:41 +0000 Subject: [PATCH 05/14] ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_elections_phragmen --- frame/elections-phragmen/src/weights.rs | 259 ++++++++++++------------ 1 file changed, 130 insertions(+), 129 deletions(-) diff --git a/frame/elections-phragmen/src/weights.rs b/frame/elections-phragmen/src/weights.rs index 72a5f824e3899..a13dadf210ec0 100644 --- a/frame/elections-phragmen/src/weights.rs +++ b/frame/elections-phragmen/src/weights.rs @@ -18,21 +18,22 @@ //! Autogenerated weights for pallet_elections_phragmen //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-02-03, STEPS: `10`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-02-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Kians-MacBook-Pro-2.local`, CPU: `` +//! 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/debug/substrate +// target/production/substrate // benchmark // pallet -// --steps=10 -// --repeat=10 +// --steps=50 +// --repeat=20 // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --json-file=/builds/parity/mirrors/substrate/.git/.artifacts/bench.json // --pallet=pallet_elections_phragmen // --chain=dev // --header=./HEADER-APACHE2 @@ -80,10 +81,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `499 + v * (80 ±0)` // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 415_000 nanoseconds. - Weight::from_parts(421_838_802, 9726) - // Standard Error: 133_238 - .saturating_add(Weight::from_ref_time(326_568).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 WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `467 + v * (80 ±0)` // Estimated: `9598 + v * (320 ±0)` - // Minimum execution time: 558_000 nanoseconds. - Weight::from_parts(556_163_102, 9598) - // Standard Error: 738_644 - .saturating_add(Weight::from_ref_time(3_391_887).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,8 +127,10 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `499 + v * (80 ±0)` // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 568_000 nanoseconds. - Weight::from_parts(621_939_239, 9726) + // 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())) @@ -140,8 +143,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `989` // Estimated: `7238` - // Minimum execution time: 504_000 nanoseconds. - Weight::from_parts(512_000_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)) } @@ -151,30 +154,30 @@ impl WeightInfo for SubstrateWeight { /// 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: `1690 + c * (48 ±0)` - // Estimated: `6540 + c * (144 ±0)` - // Minimum execution time: 368_000 nanoseconds. - Weight::from_parts(406_083_483, 6540) - // Standard Error: 11_995 - .saturating_add(Weight::from_ref_time(161_971).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: `347 + c * (48 ±0)` - // Estimated: `825 + c * (48 ±0)` - // Minimum execution time: 332_000 nanoseconds. - Weight::from_parts(374_734_634, 825) - // Standard Error: 10_531 - .saturating_add(Weight::from_ref_time(35_062).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())) @@ -193,8 +196,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2027` // Estimated: `12115` - // Minimum execution time: 521_000 nanoseconds. - Weight::from_parts(531_000_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)) } @@ -204,8 +207,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `975` // Estimated: `1470` - // Minimum execution time: 345_000 nanoseconds. - Weight::from_parts(381_000_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)) } @@ -234,12 +237,12 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `2027` // Estimated: `14718` - // Minimum execution time: 601_000 nanoseconds. - Weight::from_parts(610_000_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) @@ -247,24 +250,24 @@ impl WeightInfo for SubstrateWeight { /// 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: `36373 + v * (872 ±0)` - // Estimated: `32033948 + v * (9658 ±0)` - // Minimum execution time: 5_401_340_000 nanoseconds. - Weight::from_parts(5_410_097_000_000, 32033948) - // Standard Error: 13_924_977 - .saturating_add(Weight::from_ref_time(686_578_019).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(9658).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) @@ -272,11 +275,11 @@ impl WeightInfo for SubstrateWeight { /// 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) @@ -284,29 +287,27 @@ impl WeightInfo for SubstrateWeight { /// 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 * (638 ±0) + e * (28 ±0)` - // Estimated: `5586978 + v * (5383 ±21) + e * (99 ±1) + c * (2478 ±6)` - // Minimum execution time: 337_238_000 nanoseconds. - Weight::from_parts(338_755_000_000, 5586978) - // Standard Error: 16_598_609 - .saturating_add(Weight::from_ref_time(8_686_952).saturating_mul(c.into())) - // Standard Error: 1_659_179 - .saturating_add(Weight::from_ref_time(102_136_811).saturating_mul(v.into())) - // Standard Error: 106_480 - .saturating_add(Weight::from_ref_time(331).saturating_mul(e.into())) - .saturating_add(T::DbWeight::get().reads(448_u64)) + // 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(5383).saturating_mul(v.into())) - .saturating_add(Weight::from_proof_size(99).saturating_mul(e.into())) - .saturating_add(Weight::from_proof_size(2478).saturating_mul(c.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: 415_000 nanoseconds. - Weight::from_parts(421_838_802, 9726) - // Standard Error: 133_238 - .saturating_add(Weight::from_ref_time(326_568).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: 558_000 nanoseconds. - Weight::from_parts(556_163_102, 9598) - // Standard Error: 738_644 - .saturating_add(Weight::from_ref_time(3_391_887).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,8 +374,10 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `499 + v * (80 ±0)` // Estimated: `9726 + v * (320 ±0)` - // Minimum execution time: 568_000 nanoseconds. - Weight::from_parts(621_939_239, 9726) + // 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())) @@ -387,8 +390,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `989` // Estimated: `7238` - // Minimum execution time: 504_000 nanoseconds. - Weight::from_parts(512_000_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)) } @@ -398,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: `1690 + c * (48 ±0)` - // Estimated: `6540 + c * (144 ±0)` - // Minimum execution time: 368_000 nanoseconds. - Weight::from_parts(406_083_483, 6540) - // Standard Error: 11_995 - .saturating_add(Weight::from_ref_time(161_971).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: `347 + c * (48 ±0)` - // Estimated: `825 + c * (48 ±0)` - // Minimum execution time: 332_000 nanoseconds. - Weight::from_parts(374_734_634, 825) - // Standard Error: 10_531 - .saturating_add(Weight::from_ref_time(35_062).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())) @@ -440,8 +443,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2027` // Estimated: `12115` - // Minimum execution time: 521_000 nanoseconds. - Weight::from_parts(531_000_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)) } @@ -451,8 +454,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `975` // Estimated: `1470` - // Minimum execution time: 345_000 nanoseconds. - Weight::from_parts(381_000_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)) } @@ -481,12 +484,12 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `2027` // Estimated: `14718` - // Minimum execution time: 601_000 nanoseconds. - Weight::from_parts(610_000_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) @@ -494,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: `36373 + v * (872 ±0)` - // Estimated: `32033948 + v * (9658 ±0)` - // Minimum execution time: 5_401_340_000 nanoseconds. - Weight::from_parts(5_410_097_000_000, 32033948) - // Standard Error: 13_924_977 - .saturating_add(Weight::from_ref_time(686_578_019).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(9658).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) @@ -519,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) @@ -531,28 +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 * (638 ±0) + e * (28 ±0)` - // Estimated: `5586978 + v * (5383 ±21) + e * (99 ±1) + c * (2478 ±6)` - // Minimum execution time: 337_238_000 nanoseconds. - Weight::from_parts(338_755_000_000, 5586978) - // Standard Error: 16_598_609 - .saturating_add(Weight::from_ref_time(8_686_952).saturating_mul(c.into())) - // Standard Error: 1_659_179 - .saturating_add(Weight::from_ref_time(102_136_811).saturating_mul(v.into())) - // Standard Error: 106_480 - .saturating_add(Weight::from_ref_time(331).saturating_mul(e.into())) - .saturating_add(RocksDbWeight::get().reads(448_u64)) + // 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(5383).saturating_mul(v.into())) - .saturating_add(Weight::from_proof_size(99).saturating_mul(e.into())) - .saturating_add(Weight::from_proof_size(2478).saturating_mul(c.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())) } } From 8fcf10bbd0024eda072a9b8035ef965f92b26128 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Mon, 6 Feb 2023 16:02:10 -0300 Subject: [PATCH 06/14] fix stuff --- frame/elections-phragmen/src/lib.rs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index f567f1f256759..8bc2b478ccf2d 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -306,18 +306,26 @@ pub mod pallet { 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, + ); if election_weight.any_gt(block_weight) { frame_support::log::error!( - target: LOG_TARGET, - "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(), - ); + target: LOG_TARGET, + "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(), + ); } } } From 897f11125f063173d6d667c83e85a25a655fd3cd Mon Sep 17 00:00:00 2001 From: kianenigma Date: Tue, 7 Feb 2023 10:28:31 -0300 Subject: [PATCH 07/14] make assert --- frame/elections-phragmen/src/lib.rs | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 8bc2b478ccf2d..328851842c957 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -314,19 +314,17 @@ pub mod pallet { to_seconds(&block_weight), block_weight, ); - if election_weight.any_gt(block_weight) { - frame_support::log::error!( - target: LOG_TARGET, - "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(), - ); - } + 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(), + ); } } From cc74b3be7aa3eeb5399fcf08aa79a5defe8ce0ce Mon Sep 17 00:00:00 2001 From: kianenigma Date: Tue, 7 Feb 2023 10:35:08 -0300 Subject: [PATCH 08/14] fix docs --- frame/elections-phragmen/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 328851842c957..4501d88fb42d5 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -43,14 +43,14 @@ //! ### Voting //! //! Voters can vote for a limited number of the candidates by providing a list of account ids, -//! bounded by [`T::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. +//! bounded by [`T::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`]. //! From 3d4ed6cf293b0a13ddc2036bc53f82048b4a6800 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Tue, 7 Feb 2023 10:39:18 -0300 Subject: [PATCH 09/14] fix docs again --- frame/elections-phragmen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 4501d88fb42d5..20f3a27cbc881 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -43,7 +43,7 @@ //! ### Voting //! //! Voters can vote for a limited number of the candidates by providing a list of account ids, -//! bounded by [`T::Config::MaxVotesPerVoter`]. Invalid votes (voting for non-candidates) and +//! 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 From 93f0d501ba18bbe6f989f0deff366abc3fff2b61 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Tue, 7 Feb 2023 10:39:28 -0300 Subject: [PATCH 10/14] fix docs again --- frame/elections-phragmen/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 20f3a27cbc881..f5d70a1c4806f 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -43,14 +43,14 @@ //! ### Voting //! //! Voters can vote for a limited number of the candidates by providing a list of account ids, -//! 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. +//! 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`]. //! From f94174ea0c346d1f56edb395e674ce187cd2c596 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:47:07 -0300 Subject: [PATCH 11/14] Update frame/elections-phragmen/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gonçalo Pestana --- frame/elections-phragmen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index f5d70a1c4806f..85154198496c2 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -252,7 +252,7 @@ pub mod pallet { /// The maximum number of candidates in a phragmen 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`. + /// consider how it will impact `T::WeightInfo::election_phragmen`. /// /// When this limit is reached no more candidates are accepted in the election. #[pallet::constant] From e1b53dac2d3510872f7accf4600a45287ca5c7a9 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:47:15 -0300 Subject: [PATCH 12/14] Update frame/elections-phragmen/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gonçalo Pestana --- frame/elections-phragmen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 85154198496c2..2fbf90af1d2f8 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -261,7 +261,7 @@ pub mod pallet { /// The maximum number of voters to allow in a phragmen 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`. + /// consider how it will impact `T::WeightInfo::election_phragmen`. /// /// When the limit is reached the new voters are ignored. #[pallet::constant] From dce84c063c53687f1d9298695ff429d68f014f20 Mon Sep 17 00:00:00 2001 From: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:47:23 -0300 Subject: [PATCH 13/14] Update frame/elections-phragmen/src/lib.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Gonçalo Pestana --- frame/elections-phragmen/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index 2fbf90af1d2f8..8dd060a78695b 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -270,7 +270,7 @@ pub mod pallet { /// 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`. + /// consider how it will impact `T::WeightInfo::election_phragmen`. #[pallet::constant] type MaxVotesPerVoter: Get; From 446443375c36cf9195a7c3cc19a3a5723f6022b1 Mon Sep 17 00:00:00 2001 From: kianenigma Date: Wed, 8 Feb 2023 10:15:39 -0300 Subject: [PATCH 14/14] fix docs --- frame/elections-phragmen/src/lib.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/frame/elections-phragmen/src/lib.rs b/frame/elections-phragmen/src/lib.rs index f5d70a1c4806f..7a9923bf6a673 100644 --- a/frame/elections-phragmen/src/lib.rs +++ b/frame/elections-phragmen/src/lib.rs @@ -1213,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;