From f3d7798e353e16056de274c5f4eb64e83822fb5f Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 13:43:13 -0700 Subject: [PATCH 01/22] pallet-collective Add option to not vote `aye` with `propose` --- frame/collective/src/lib.rs | 64 +++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index a7039887db606..20c3d1d8b954e 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -405,6 +405,9 @@ decl_module! { /// `threshold` determines whether `proposal` is executed directly (`threshold < 2`) /// or put up for voting. /// + /// `include_aye_vote` determines wether or not the caller will include an aye vote for + /// the proposal. + /// /// # /// ## Weight /// - `O(B + M + P1)` or `O(B + M + P2)` where: @@ -443,7 +446,8 @@ decl_module! { fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<>::Proposal>, - #[compact] length_bound: u32 + #[compact] length_bound: u32, + include_aye_vote: bool, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let members = Self::members(); @@ -476,8 +480,13 @@ decl_module! { let index = Self::proposal_count(); >::mutate(|i| *i += 1); >::insert(proposal_hash, *proposal); - let end = system::Pallet::::block_number() + T::MotionDuration::get(); - let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end }; + + let votes = { + let end = system::Pallet::::block_number() + T::MotionDuration::get(); + let ayes = if include_aye_vote { vec![who.clone()] } else { vec![] }; + Votes { index, threshold, ayes, nays: vec![], end } + }; + >::insert(proposal_hash, votes); Self::deposit_event(RawEvent::Proposed(who, index, proposal_hash, threshold)); @@ -1093,7 +1102,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(3); @@ -1124,7 +1133,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); // Set 1 as prime voter Prime::::set(Some(1)); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); // With 1's prime vote, this should pass System::set_block_number(4); assert_noop!( @@ -1143,7 +1152,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); // No votes, this proposal wont pass System::set_block_number(4); assert_ok!( @@ -1161,7 +1170,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(3), MaxMembers::get())); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1186,7 +1195,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(1), MaxMembers::get())); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1212,7 +1221,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(CollectiveMajority::set_members(Origin::root(), vec![1, 2, 3, 4, 5], Some(5), MaxMembers::get())); - assert_ok!(CollectiveMajority::propose(Origin::signed(1), 5, Box::new(proposal.clone()), proposal_len)); + assert_ok!(CollectiveMajority::propose(Origin::signed(1), 5, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(CollectiveMajority::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(CollectiveMajority::vote(Origin::signed(3), hash.clone(), 0, true)); @@ -1238,7 +1247,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1253,7 +1262,7 @@ mod tests { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1274,7 +1283,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1289,7 +1298,7 @@ mod tests { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1310,7 +1319,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_eq!(*Collective::proposals(), vec![hash]); assert_eq!(Collective::proposal_of(&hash), Some(proposal)); assert_eq!( @@ -1339,12 +1348,12 @@ mod tests { for i in 0..MaxProposals::get() { let proposal = make_proposal(i as u64); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); } let proposal = make_proposal(MaxProposals::get() as u64 + 1); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); assert_noop!( - Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len), + Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true), Error::::TooManyProposals ); }) @@ -1355,7 +1364,7 @@ mod tests { new_test_ext().execute_with(|| { let proposal = Call::Collective(crate::Call::set_members(vec![1, 2, 3], None, MaxMembers::get())); let length = proposal.encode().len() as u32; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), length)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), length, true)); let hash = BlakeTwo256::hash_of(&proposal); let weight = proposal.get_dispatch_info().weight; @@ -1385,7 +1394,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); assert_noop!( - Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone()), proposal_len), + Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone()), proposal_len, true), Error::::NotMember ); }); @@ -1397,7 +1406,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_noop!( Collective::vote(Origin::signed(42), hash.clone(), 0, true), Error::::NotMember, @@ -1412,7 +1421,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_noop!( Collective::vote(Origin::signed(2), hash.clone(), 1, true), Error::::WrongIndex, @@ -1427,7 +1436,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) @@ -1485,6 +1494,7 @@ mod tests { 2, Box::new(proposal.clone()), proposal_len, + true ) ); assert_eq!( @@ -1569,11 +1579,11 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); assert_eq!(*Collective::proposals(), vec![]); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); assert_eq!(*Collective::proposals(), vec![hash]); }); } @@ -1585,7 +1595,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1637,7 +1647,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1698,7 +1708,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); // First we make the proposal succeed assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // It will not close with bad weight/len information @@ -1724,7 +1734,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); // Proposal would normally succeed assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // But Root can disapprove and remove it anyway From 202a3e6b0915aab91537b64c30db940aae6be3e4 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 14:29:58 -0700 Subject: [PATCH 02/22] Test: propose_with_no_self_vote_works --- frame/collective/src/lib.rs | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 20c3d1d8b954e..72993caed611b 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -1342,6 +1342,45 @@ mod tests { }); } + #[test] + fn propose_with_no_self_vote_works() { + new_test_ext().execute_with(|| { + let proposal = make_proposal(42); + let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); + let hash = proposal.blake2_256().into(); + let end = 4; + assert_ok!(Collective::propose( + Origin::signed(1), + 3, + Box::new(proposal.clone()), + proposal_len, + false, // Do not include an aye vote on behalf of the caller. + )); + assert_eq!(*Collective::proposals(), vec![hash]); + assert_eq!(Collective::proposal_of(&hash), Some(proposal)); + assert_eq!( + Collective::voting(&hash), + // No aye (or nay) votes leaked into storage while proposing. + Some(Votes { index: 0, threshold: 3, ayes: vec![], nays: vec![], end }) + ); + + assert_eq!( + System::events(), + vec![EventRecord { + phase: Phase::Initialization, + event: Event::Collective(RawEvent::Proposed( + 1, + 0, + hex!["68eea8f20b542ec656c6ac2d10435ae3bd1729efc34d1354ab85af840aad2d35"] + .into(), + 3, + )), + topics: vec![], + }] + ); + }); + } + #[test] fn limit_active_proposals() { new_test_ext().execute_with(|| { From 9eeb07103eb25cf59515fefe0f6a99305f6974b0 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 14:47:40 -0700 Subject: [PATCH 03/22] Param doc grammar --- frame/collective/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 72993caed611b..f9f1684921424 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -405,7 +405,7 @@ decl_module! { /// `threshold` determines whether `proposal` is executed directly (`threshold < 2`) /// or put up for voting. /// - /// `include_aye_vote` determines wether or not the caller will include an aye vote for + /// `include_aye_vote` determines whether or not the caller will record an aye vote for /// the proposal. /// /// # From ca24990ff37bf0f48165df518745fa72b9eb6c45 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 15:25:04 -0700 Subject: [PATCH 04/22] Update benchmarks --- frame/collective/src/benchmarking.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 1f78f07cf9234..37cac1dd3c354 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -76,6 +76,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), MAX_BYTES, + true, // Include aye vote on behalf of proposer. )?; let hash = T::Hashing::hash_of(&proposal); // Vote on the proposal to increase state relevant for `set_members`. @@ -159,7 +160,7 @@ benchmarks_instance! { let proposal: T::Proposal = SystemCall::::remark(vec![1; b as usize]).into(); let threshold = 1; - }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage) + }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage, true) verify { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin @@ -196,6 +197,7 @@ benchmarks_instance! { threshold, Box::new(proposal), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; } @@ -203,7 +205,7 @@ benchmarks_instance! { let proposal: T::Proposal = SystemCall::::remark(vec![p as u8; b as usize]).into(); - }: propose(SystemOrigin::Signed(caller.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage) + }: propose(SystemOrigin::Signed(caller.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage, true) verify { // New proposal is recorded assert_eq!(Collective::::proposals().len(), p as usize); @@ -244,6 +246,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -320,6 +323,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -398,6 +402,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -484,6 +489,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -556,6 +562,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -619,6 +626,7 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, + true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } From 1cefd1688c8f47fb570b8748dee2d08f508164ef Mon Sep 17 00:00:00 2001 From: Zeke Mostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 16:12:59 -0700 Subject: [PATCH 05/22] Revert changes --- frame/collective/src/lib.rs | 64 ++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 37 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index f9f1684921424..8cc16e7a3f02b 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -405,9 +405,6 @@ decl_module! { /// `threshold` determines whether `proposal` is executed directly (`threshold < 2`) /// or put up for voting. /// - /// `include_aye_vote` determines whether or not the caller will record an aye vote for - /// the proposal. - /// /// # /// ## Weight /// - `O(B + M + P1)` or `O(B + M + P2)` where: @@ -446,8 +443,7 @@ decl_module! { fn propose(origin, #[compact] threshold: MemberCount, proposal: Box<>::Proposal>, - #[compact] length_bound: u32, - include_aye_vote: bool, + #[compact] length_bound: u32 ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let members = Self::members(); @@ -480,13 +476,8 @@ decl_module! { let index = Self::proposal_count(); >::mutate(|i| *i += 1); >::insert(proposal_hash, *proposal); - - let votes = { - let end = system::Pallet::::block_number() + T::MotionDuration::get(); - let ayes = if include_aye_vote { vec![who.clone()] } else { vec![] }; - Votes { index, threshold, ayes, nays: vec![], end } - }; - + let end = system::Pallet::::block_number() + T::MotionDuration::get(); + let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end }; >::insert(proposal_hash, votes); Self::deposit_event(RawEvent::Proposed(who, index, proposal_hash, threshold)); @@ -1102,7 +1093,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(3); @@ -1133,7 +1124,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); // Set 1 as prime voter Prime::::set(Some(1)); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); // With 1's prime vote, this should pass System::set_block_number(4); assert_noop!( @@ -1152,7 +1143,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); // No votes, this proposal wont pass System::set_block_number(4); assert_ok!( @@ -1170,7 +1161,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(3), MaxMembers::get())); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1195,7 +1186,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(1), MaxMembers::get())); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1221,7 +1212,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(CollectiveMajority::set_members(Origin::root(), vec![1, 2, 3, 4, 5], Some(5), MaxMembers::get())); - assert_ok!(CollectiveMajority::propose(Origin::signed(1), 5, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(CollectiveMajority::propose(Origin::signed(1), 5, Box::new(proposal.clone()), proposal_len)); assert_ok!(CollectiveMajority::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(CollectiveMajority::vote(Origin::signed(3), hash.clone(), 0, true)); @@ -1247,7 +1238,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1262,7 +1253,7 @@ mod tests { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1283,7 +1274,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1298,7 +1289,7 @@ mod tests { let proposal = make_proposal(69); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); - assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1319,7 +1310,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_eq!(*Collective::proposals(), vec![hash]); assert_eq!(Collective::proposal_of(&hash), Some(proposal)); assert_eq!( @@ -1387,12 +1378,12 @@ mod tests { for i in 0..MaxProposals::get() { let proposal = make_proposal(i as u64); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); } let proposal = make_proposal(MaxProposals::get() as u64 + 1); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); assert_noop!( - Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true), + Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len), Error::::TooManyProposals ); }) @@ -1403,7 +1394,7 @@ mod tests { new_test_ext().execute_with(|| { let proposal = Call::Collective(crate::Call::set_members(vec![1, 2, 3], None, MaxMembers::get())); let length = proposal.encode().len() as u32; - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), length, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), length)); let hash = BlakeTwo256::hash_of(&proposal); let weight = proposal.get_dispatch_info().weight; @@ -1433,7 +1424,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); assert_noop!( - Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone()), proposal_len, true), + Collective::propose(Origin::signed(42), 3, Box::new(proposal.clone()), proposal_len), Error::::NotMember ); }); @@ -1445,7 +1436,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_noop!( Collective::vote(Origin::signed(42), hash.clone(), 0, true), Error::::NotMember, @@ -1460,7 +1451,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_noop!( Collective::vote(Origin::signed(2), hash.clone(), 1, true), Error::::WrongIndex, @@ -1475,7 +1466,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) @@ -1533,7 +1524,6 @@ mod tests { 2, Box::new(proposal.clone()), proposal_len, - true ) ); assert_eq!( @@ -1618,11 +1608,11 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); assert_eq!(*Collective::proposals(), vec![]); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); assert_eq!(*Collective::proposals(), vec![hash]); }); } @@ -1634,7 +1624,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1686,7 +1676,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1747,7 +1737,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); // First we make the proposal succeed assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // It will not close with bad weight/len information @@ -1773,7 +1763,7 @@ mod tests { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len, true)); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); // Proposal would normally succeed assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // But Root can disapprove and remove it anyway From c8f4f976c3eb37b17b1343704cf941984278b73e Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 17:24:13 -0700 Subject: [PATCH 06/22] Do note vote when proposing --- frame/collective/src/lib.rs | 131 +++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 47 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 8cc16e7a3f02b..3b9a73661a4aa 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -476,8 +476,10 @@ decl_module! { let index = Self::proposal_count(); >::mutate(|i| *i += 1); >::insert(proposal_hash, *proposal); - let end = system::Pallet::::block_number() + T::MotionDuration::get(); - let votes = Votes { index, threshold, ayes: vec![who.clone()], nays: vec![], end }; + let votes = { + let end = system::Pallet::::block_number() + T::MotionDuration::get(); + Votes { index, threshold, ayes: vec![], nays: vec![], end } + }; >::insert(proposal_hash, votes); Self::deposit_event(RawEvent::Proposed(who, index, proposal_hash, threshold)); @@ -1094,6 +1096,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(3); @@ -1108,6 +1111,7 @@ mod tests { let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; assert_eq!(System::events(), vec![ record(Event::Collective(RawEvent::Proposed(1, 0, hash.clone(), 3))), + record(Event::Collective(RawEvent::Voted(1, hash.clone(), true, 1, 0))), record(Event::Collective(RawEvent::Voted(2, hash.clone(), true, 2, 0))), record(Event::Collective(RawEvent::Closed(hash.clone(), 2, 1))), record(Event::Collective(RawEvent::Disapproved(hash.clone()))) @@ -1125,6 +1129,7 @@ mod tests { // Set 1 as prime voter Prime::::set(Some(1)); assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); // With 1's prime vote, this should pass System::set_block_number(4); assert_noop!( @@ -1162,6 +1167,7 @@ mod tests { assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(3), MaxMembers::get())); assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1170,6 +1176,7 @@ mod tests { let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; assert_eq!(System::events(), vec![ record(Event::Collective(RawEvent::Proposed(1, 0, hash.clone(), 3))), + record(Event::Collective(RawEvent::Voted(1, hash.clone(), true, 1, 0))), record(Event::Collective(RawEvent::Voted(2, hash.clone(), true, 2, 0))), record(Event::Collective(RawEvent::Closed(hash.clone(), 2, 1))), record(Event::Collective(RawEvent::Disapproved(hash.clone()))) @@ -1187,6 +1194,7 @@ mod tests { assert_ok!(Collective::set_members(Origin::root(), vec![1, 2, 3], Some(1), MaxMembers::get())); assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); System::set_block_number(4); @@ -1195,6 +1203,7 @@ mod tests { let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; assert_eq!(System::events(), vec![ record(Event::Collective(RawEvent::Proposed(1, 0, hash.clone(), 3))), + record(Event::Collective(RawEvent::Voted(1, hash.clone(), true, 1, 0))), record(Event::Collective(RawEvent::Voted(2, hash.clone(), true, 2, 0))), record(Event::Collective(RawEvent::Closed(hash.clone(), 3, 0))), record(Event::Collective(RawEvent::Approved(hash.clone()))), @@ -1213,6 +1222,7 @@ mod tests { assert_ok!(CollectiveMajority::set_members(Origin::root(), vec![1, 2, 3, 4, 5], Some(5), MaxMembers::get())); assert_ok!(CollectiveMajority::propose(Origin::signed(1), 5, Box::new(proposal.clone()), proposal_len)); + assert_ok!(CollectiveMajority::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(CollectiveMajority::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(CollectiveMajority::vote(Origin::signed(3), hash.clone(), 0, true)); @@ -1222,6 +1232,7 @@ mod tests { let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; assert_eq!(System::events(), vec![ record(Event::CollectiveMajority(RawEvent::Proposed(1, 0, hash.clone(), 5))), + record(Event::CollectiveMajority(RawEvent::Voted(1, hash.clone(), true, 1, 0))), record(Event::CollectiveMajority(RawEvent::Voted(2, hash.clone(), true, 2, 0))), record(Event::CollectiveMajority(RawEvent::Voted(3, hash.clone(), true, 3, 0))), record(Event::CollectiveMajority(RawEvent::Closed(hash.clone(), 5, 0))), @@ -1239,6 +1250,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); let end = 4; assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1254,6 +1266,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 1, true)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1275,6 +1288,7 @@ mod tests { let hash = BlakeTwo256::hash_of(&proposal); let end = 4; assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), @@ -1290,6 +1304,7 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash = BlakeTwo256::hash_of(&proposal); assert_ok!(Collective::propose(Origin::signed(2), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 1, true)); assert_ok!(Collective::vote(Origin::signed(3), hash.clone(), 1, false)); assert_eq!( Collective::voting(&hash), @@ -1315,7 +1330,7 @@ mod tests { assert_eq!(Collective::proposal_of(&hash), Some(proposal)); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 3, ayes: vec![1], nays: vec![], end }) + Some(Votes { index: 0, threshold: 3, ayes: vec![], nays: vec![], end }) ); assert_eq!(System::events(), vec![ @@ -1333,52 +1348,18 @@ mod tests { }); } - #[test] - fn propose_with_no_self_vote_works() { - new_test_ext().execute_with(|| { - let proposal = make_proposal(42); - let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - let hash = proposal.blake2_256().into(); - let end = 4; - assert_ok!(Collective::propose( - Origin::signed(1), - 3, - Box::new(proposal.clone()), - proposal_len, - false, // Do not include an aye vote on behalf of the caller. - )); - assert_eq!(*Collective::proposals(), vec![hash]); - assert_eq!(Collective::proposal_of(&hash), Some(proposal)); - assert_eq!( - Collective::voting(&hash), - // No aye (or nay) votes leaked into storage while proposing. - Some(Votes { index: 0, threshold: 3, ayes: vec![], nays: vec![], end }) - ); - - assert_eq!( - System::events(), - vec![EventRecord { - phase: Phase::Initialization, - event: Event::Collective(RawEvent::Proposed( - 1, - 0, - hex!["68eea8f20b542ec656c6ac2d10435ae3bd1729efc34d1354ab85af840aad2d35"] - .into(), - 3, - )), - topics: vec![], - }] - ); - }); - } - #[test] fn limit_active_proposals() { new_test_ext().execute_with(|| { - for i in 0..MaxProposals::get() { + for i in 0 .. MaxProposals::get() { let proposal = make_proposal(i as u64); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose( + Origin::signed(1), + 3, + Box::new(proposal.clone()), + proposal_len + )); } let proposal = make_proposal(MaxProposals::get() as u64 + 1); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); @@ -1460,31 +1441,48 @@ mod tests { } #[test] - fn motions_revoting_works() { + fn motions_vote_after_works() { new_test_ext().execute_with(|| { let proposal = make_proposal(42); let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::propose( + Origin::signed(1), + 2, + Box::new(proposal.clone()), + proposal_len + )); + // Initially there a no votes when the motion is proposed. + assert_eq!( + Collective::voting(&hash), + Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![], end }) + ); + // Cast first vote as aye. + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) ); + // Try to cast a duplicate aye. assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, true), Error::::DuplicateVote, ); + // Cast a vote as nay. assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, false)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![1], end }) ); + // Try to cast a duplicate nay. assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, false), Error::::DuplicateVote, ); + let events = System::events(); + assert_eq!(events.len(), 3); assert_eq!(System::events(), vec![ EventRecord { phase: Phase::Initialization, @@ -1496,6 +1494,18 @@ mod tests { )), topics: vec![], }, + EventRecord { + phase: Phase::Initialization, + event: Event::Collective(RawEvent::Voted( + 1, + hex!["68eea8f20b542ec656c6ac2d10435ae3bd1729efc34d1354ab85af840aad2d35"] + .into(), + true, + 1, + 0, + )), + topics: vec![], + }, EventRecord { phase: Phase::Initialization, event: Event::Collective(RawEvent::Voted( @@ -1528,7 +1538,7 @@ mod tests { ); assert_eq!( Collective::voting(&hash), - Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) + Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![], end }) ); // For the motion, acc 2's first vote, expecting Ok with Pays::No. @@ -1625,6 +1635,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, false)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1640,6 +1651,17 @@ mod tests { )), topics: vec![], }, + EventRecord { + phase: Phase::Initialization, + event: Event::Collective(RawEvent::Voted( + 1, + hex!["68eea8f20b542ec656c6ac2d10435ae3bd1729efc34d1354ab85af840aad2d35"].into(), + true, + 1, + 0, + )), + topics: vec![], + }, EventRecord { phase: Phase::Initialization, event: Event::Collective(RawEvent::Voted( @@ -1677,6 +1699,7 @@ mod tests { let proposal_weight = proposal.get_dispatch_info().weight; let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); @@ -1691,6 +1714,17 @@ mod tests { )), topics: vec![], }, + EventRecord { + phase: Phase::Initialization, + event: Event::Collective(RawEvent::Voted( + 1, + hex!["68eea8f20b542ec656c6ac2d10435ae3bd1729efc34d1354ab85af840aad2d35"].into(), + true, + 1, + 0, + )), + topics: vec![], + }, EventRecord { phase: Phase::Initialization, event: Event::Collective(RawEvent::Voted( @@ -1739,6 +1773,7 @@ mod tests { let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); // First we make the proposal succeed + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // It will not close with bad weight/len information assert_noop!( @@ -1765,12 +1800,14 @@ mod tests { let hash: H256 = proposal.blake2_256().into(); assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); // Proposal would normally succeed + assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_ok!(Collective::vote(Origin::signed(2), hash.clone(), 0, true)); // But Root can disapprove and remove it anyway assert_ok!(Collective::disapprove_proposal(Origin::root(), hash.clone())); let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; assert_eq!(System::events(), vec![ record(Event::Collective(RawEvent::Proposed(1, 0, hash.clone(), 2))), + record(Event::Collective(RawEvent::Voted(1, hash.clone(), true, 1, 0))), record(Event::Collective(RawEvent::Voted(2, hash.clone(), true, 2, 0))), record(Event::Collective(RawEvent::Disapproved(hash.clone()))), ]); From 4bf3c936d695db5128058d59c35c9195efff3dfd Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 18:25:47 -0700 Subject: [PATCH 07/22] Update benchmarks --- frame/collective/src/benchmarking.rs | 30 +++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 37cac1dd3c354..09c1dfc99cb83 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -76,7 +76,6 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), MAX_BYTES, - true, // Include aye vote on behalf of proposer. )?; let hash = T::Hashing::hash_of(&proposal); // Vote on the proposal to increase state relevant for `set_members`. @@ -160,7 +159,7 @@ benchmarks_instance! { let proposal: T::Proposal = SystemCall::::remark(vec![1; b as usize]).into(); let threshold = 1; - }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage, true) + }: propose(SystemOrigin::Signed(caller), threshold, Box::new(proposal.clone()), bytes_in_storage) verify { let proposal_hash = T::Hashing::hash_of(&proposal); // Note that execution fails due to mis-matched origin @@ -197,7 +196,6 @@ benchmarks_instance! { threshold, Box::new(proposal), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; } @@ -205,7 +203,7 @@ benchmarks_instance! { let proposal: T::Proposal = SystemCall::::remark(vec![p as u8; b as usize]).into(); - }: propose(SystemOrigin::Signed(caller.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage, true) + }: propose(SystemOrigin::Signed(caller.clone()), threshold, Box::new(proposal.clone()), bytes_in_storage) verify { // New proposal is recorded assert_eq!(Collective::::proposals().len(), p as usize); @@ -246,15 +244,13 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } let index = p - 1; // Have almost everyone vote aye on last proposal, while keeping it from passing. - // Proposer already voted aye so we start at 1. - for j in 1 .. m - 3 { + for j in 0 .. m - 3 { let voter = &members[j as usize]; let approve = true; Collective::::vote( @@ -323,15 +319,13 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } let index = p - 1; // Have most everyone vote aye on last proposal, while keeping it from passing. - // Proposer already voted aye so we start at 1. - for j in 1 .. m - 2 { + for j in 0 .. m - 2 { let voter = &members[j as usize]; let approve = true; Collective::::vote( @@ -402,7 +396,6 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -416,7 +409,7 @@ benchmarks_instance! { )?; // Have almost everyone vote nay on last proposal, while keeping it from failing. - for j in 2 .. m - 1 { + for j in 1 .. m - 1 { let voter = &members[j as usize]; let approve = false; Collective::::vote( @@ -489,7 +482,6 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } @@ -545,7 +537,7 @@ benchmarks_instance! { Collective::::set_members( SystemOrigin::Root.into(), members.clone(), - Some(caller.clone()), + Some(caller.clone()), // Set caller as the prime member. T::MaxMembers::get(), )?; @@ -562,11 +554,18 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } + // The prime member votes aye, so abstentions default to aye. + Collective::::vote( + SystemOrigin::Signed(caller.clone()).into(), + last_hash.clone(), + p - 1, + true // Vote aye. + )?; + // Have almost everyone vote nay on last proposal, while keeping it from failing. // A few abstainers will be the aye votes needed to pass the vote. for j in 2 .. m - 1 { @@ -626,7 +625,6 @@ benchmarks_instance! { threshold, Box::new(proposal.clone()), bytes_in_storage, - true, // Include aye vote on behalf of proposer. )?; last_hash = T::Hashing::hash_of(&proposal); } From bd144f2bbca101882d1c76778e847f54d5fb1b5c Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 18:29:01 -0700 Subject: [PATCH 08/22] Reduce diff on benchmarks --- frame/collective/src/benchmarking.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frame/collective/src/benchmarking.rs b/frame/collective/src/benchmarking.rs index 09c1dfc99cb83..7faaa31dc8012 100644 --- a/frame/collective/src/benchmarking.rs +++ b/frame/collective/src/benchmarking.rs @@ -409,7 +409,7 @@ benchmarks_instance! { )?; // Have almost everyone vote nay on last proposal, while keeping it from failing. - for j in 1 .. m - 1 { + for j in 2 .. m - 1 { let voter = &members[j as usize]; let approve = false; Collective::::vote( @@ -537,7 +537,7 @@ benchmarks_instance! { Collective::::set_members( SystemOrigin::Root.into(), members.clone(), - Some(caller.clone()), // Set caller as the prime member. + Some(caller.clone()), T::MaxMembers::get(), )?; From 53365dfdd9d546969e31bc80c66d956d12f69384 Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Sat, 10 Jul 2021 18:33:28 -0700 Subject: [PATCH 09/22] Reduce diff on tests --- frame/collective/src/lib.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 3b9a73661a4aa..0ec06f7185ed9 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -1447,35 +1447,30 @@ mod tests { let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); let hash: H256 = proposal.blake2_256().into(); let end = 4; - assert_ok!(Collective::propose( - Origin::signed(1), - 2, - Box::new(proposal.clone()), - proposal_len - )); + assert_ok!(Collective::propose(Origin::signed(1), 2, Box::new(proposal.clone()), proposal_len)); // Initially there a no votes when the motion is proposed. assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![], end }) ); - // Cast first vote as aye. + // Cast first aye vote. assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, true)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![1], nays: vec![], end }) ); - // Try to cast a duplicate aye. + // Try to cast a duplicate aye vote. assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, true), Error::::DuplicateVote, ); - // Cast a vote as nay. + // Cast a nay vote. assert_ok!(Collective::vote(Origin::signed(1), hash.clone(), 0, false)); assert_eq!( Collective::voting(&hash), Some(Votes { index: 0, threshold: 2, ayes: vec![], nays: vec![1], end }) ); - // Try to cast a duplicate nay. + // Try to cast a duplicate nay vote. assert_noop!( Collective::vote(Origin::signed(1), hash.clone(), 0, false), Error::::DuplicateVote, From d10a84594bd7d14ef3e9b2aa4bdd39d7dc251460 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 00:25:14 +0000 Subject: [PATCH 10/22] cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index b22380e3c476c..8ac1273d497c7 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_treasury //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-13, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (41_763_000 as Weight) + (52_013_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_049_000 as Weight) + (48_704_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (13_547_000 as Weight) - // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) + (16_600_000 as Weight) + // Standard Error: 2_000 + .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (48_990_000 as Weight) - // Standard Error: 19_000 - .saturating_add((59_621_000 as Weight).saturating_mul(p as Weight)) + (58_414_000 as Weight) + // Standard Error: 29_000 + .saturating_add((76_495_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (41_763_000 as Weight) + (52_013_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_049_000 as Weight) + (48_704_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (13_547_000 as Weight) - // Standard Error: 0 - .saturating_add((124_000 as Weight).saturating_mul(p as Weight)) + (16_600_000 as Weight) + // Standard Error: 2_000 + .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (48_990_000 as Weight) - // Standard Error: 19_000 - .saturating_add((59_621_000 as Weight).saturating_mul(p as Weight)) + (58_414_000 as Weight) + // Standard Error: 29_000 + .saturating_add((76_495_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 53bacb890c7579889003ea2e12c7c0714b9ef0c5 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 01:05:53 +0000 Subject: [PATCH 11/22] cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 8ac1273d497c7..8c8c8321fda87 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (52_013_000 as Weight) + (50_049_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_704_000 as Weight) + (46_409_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_600_000 as Weight) - // Standard Error: 2_000 + (16_197_000 as Weight) + // Standard Error: 3_000 .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (58_414_000 as Weight) - // Standard Error: 29_000 - .saturating_add((76_495_000 as Weight).saturating_mul(p as Weight)) + (45_896_000 as Weight) + // Standard Error: 46_000 + .saturating_add((75_215_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (52_013_000 as Weight) + (50_049_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_704_000 as Weight) + (46_409_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_600_000 as Weight) - // Standard Error: 2_000 + (16_197_000 as Weight) + // Standard Error: 3_000 .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (58_414_000 as Weight) - // Standard Error: 29_000 - .saturating_add((76_495_000 as Weight).saturating_mul(p as Weight)) + (45_896_000 as Weight) + // Standard Error: 46_000 + .saturating_add((75_215_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 3d86ca9990939afc1ec91e3561c84496874716d9 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 01:22:19 +0000 Subject: [PATCH 12/22] manual bench --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 8c8c8321fda87..104e21a88183d 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (50_049_000 as Weight) + (41_988_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (46_409_000 as Weight) + (39_621_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_197_000 as Weight) - // Standard Error: 3_000 - .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) + (14_873_000 as Weight) + // Standard Error: 2_000 + .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (45_896_000 as Weight) - // Standard Error: 46_000 - .saturating_add((75_215_000 as Weight).saturating_mul(p as Weight)) + (52_112_000 as Weight) + // Standard Error: 23_000 + .saturating_add((60_546_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (50_049_000 as Weight) + (41_988_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (46_409_000 as Weight) + (39_621_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_197_000 as Weight) - // Standard Error: 3_000 - .saturating_add((122_000 as Weight).saturating_mul(p as Weight)) + (14_873_000 as Weight) + // Standard Error: 2_000 + .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (45_896_000 as Weight) - // Standard Error: 46_000 - .saturating_add((75_215_000 as Weight).saturating_mul(p as Weight)) + (52_112_000 as Weight) + // Standard Error: 23_000 + .saturating_add((60_546_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From d4f298f84b2914e6a02c6193bb6270b6266df503 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 01:28:45 +0000 Subject: [PATCH 13/22] manual bench 2 --- frame/treasury/src/weights.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 104e21a88183d..cafaaae3a72e5 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (41_988_000 as Weight) + (42_126_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_621_000 as Weight) + (39_698_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (14_873_000 as Weight) + (14_901_000 as Weight) // Standard Error: 2_000 .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (52_112_000 as Weight) - // Standard Error: 23_000 - .saturating_add((60_546_000 as Weight).saturating_mul(p as Weight)) + (51_149_000 as Weight) + // Standard Error: 34_000 + .saturating_add((59_822_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (41_988_000 as Weight) + (42_126_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_621_000 as Weight) + (39_698_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (14_873_000 as Weight) + (14_901_000 as Weight) // Standard Error: 2_000 .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (52_112_000 as Weight) - // Standard Error: 23_000 - .saturating_add((60_546_000 as Weight).saturating_mul(p as Weight)) + (51_149_000 as Weight) + // Standard Error: 34_000 + .saturating_add((59_822_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 0f752a2b1dcfb5b8cac5fad3bcd94d8fc69cd34e Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 02:44:40 +0000 Subject: [PATCH 14/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index cafaaae3a72e5..4a644f86b3d2c 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (42_126_000 as Weight) + (52_266_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_698_000 as Weight) + (47_963_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (14_901_000 as Weight) - // Standard Error: 2_000 - .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) + (15_893_000 as Weight) + // Standard Error: 0 + .saturating_add((164_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (51_149_000 as Weight) - // Standard Error: 34_000 - .saturating_add((59_822_000 as Weight).saturating_mul(p as Weight)) + (59_424_000 as Weight) + // Standard Error: 35_000 + .saturating_add((76_365_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (42_126_000 as Weight) + (52_266_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (39_698_000 as Weight) + (47_963_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (14_901_000 as Weight) - // Standard Error: 2_000 - .saturating_add((97_000 as Weight).saturating_mul(p as Weight)) + (15_893_000 as Weight) + // Standard Error: 0 + .saturating_add((164_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (51_149_000 as Weight) - // Standard Error: 34_000 - .saturating_add((59_822_000 as Weight).saturating_mul(p as Weight)) + (59_424_000 as Weight) + // Standard Error: 35_000 + .saturating_add((76_365_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 91247925dffbaf2adb35e0ae8da3e5e6ef6c7664 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 02:59:29 +0000 Subject: [PATCH 15/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 4a644f86b3d2c..7e909f448107c 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (52_266_000 as Weight) + (51_197_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (47_963_000 as Weight) + (48_470_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (15_893_000 as Weight) - // Standard Error: 0 - .saturating_add((164_000 as Weight).saturating_mul(p as Weight)) + (17_007_000 as Weight) + // Standard Error: 2_000 + .saturating_add((115_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (59_424_000 as Weight) - // Standard Error: 35_000 - .saturating_add((76_365_000 as Weight).saturating_mul(p as Weight)) + (52_761_000 as Weight) + // Standard Error: 39_000 + .saturating_add((76_469_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (52_266_000 as Weight) + (51_197_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (47_963_000 as Weight) + (48_470_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (15_893_000 as Weight) - // Standard Error: 0 - .saturating_add((164_000 as Weight).saturating_mul(p as Weight)) + (17_007_000 as Weight) + // Standard Error: 2_000 + .saturating_add((115_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (59_424_000 as Weight) - // Standard Error: 35_000 - .saturating_add((76_365_000 as Weight).saturating_mul(p as Weight)) + (52_761_000 as Weight) + // Standard Error: 39_000 + .saturating_add((76_469_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 52c21574d0b577ec7b8bcfd40a0f852c40e30290 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 03:04:55 +0000 Subject: [PATCH 16/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 7e909f448107c..a0084b7fbb0d4 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (51_197_000 as Weight) + (50_991_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_470_000 as Weight) + (48_055_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_007_000 as Weight) - // Standard Error: 2_000 - .saturating_add((115_000 as Weight).saturating_mul(p as Weight)) + (17_461_000 as Weight) + // Standard Error: 3_000 + .saturating_add((92_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (52_761_000 as Weight) - // Standard Error: 39_000 - .saturating_add((76_469_000 as Weight).saturating_mul(p as Weight)) + (51_659_000 as Weight) + // Standard Error: 46_000 + .saturating_add((75_747_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (51_197_000 as Weight) + (50_991_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_470_000 as Weight) + (48_055_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_007_000 as Weight) - // Standard Error: 2_000 - .saturating_add((115_000 as Weight).saturating_mul(p as Weight)) + (17_461_000 as Weight) + // Standard Error: 3_000 + .saturating_add((92_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (52_761_000 as Weight) - // Standard Error: 39_000 - .saturating_add((76_469_000 as Weight).saturating_mul(p as Weight)) + (51_659_000 as Weight) + // Standard Error: 46_000 + .saturating_add((75_747_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From fb17dcb9eeb7dc018c74dd4782655b220279408c Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 04:34:35 +0000 Subject: [PATCH 17/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index a0084b7fbb0d4..6463a713ef1ee 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (50_991_000 as Weight) + (54_772_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_055_000 as Weight) + (48_798_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_461_000 as Weight) - // Standard Error: 3_000 - .saturating_add((92_000 as Weight).saturating_mul(p as Weight)) + (16_251_000 as Weight) + // Standard Error: 2_000 + .saturating_add((138_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (51_659_000 as Weight) - // Standard Error: 46_000 - .saturating_add((75_747_000 as Weight).saturating_mul(p as Weight)) + (54_385_000 as Weight) + // Standard Error: 35_000 + .saturating_add((75_842_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (50_991_000 as Weight) + (54_772_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_055_000 as Weight) + (48_798_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_461_000 as Weight) - // Standard Error: 3_000 - .saturating_add((92_000 as Weight).saturating_mul(p as Weight)) + (16_251_000 as Weight) + // Standard Error: 2_000 + .saturating_add((138_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (51_659_000 as Weight) - // Standard Error: 46_000 - .saturating_add((75_747_000 as Weight).saturating_mul(p as Weight)) + (54_385_000 as Weight) + // Standard Error: 35_000 + .saturating_add((75_842_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 53afff9fbca141f312fd6b234970dd5c2afa8639 Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 05:00:10 +0000 Subject: [PATCH 18/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 6463a713ef1ee..9db5776b6c7f0 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (54_772_000 as Weight) + (51_464_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_798_000 as Weight) + (48_566_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_251_000 as Weight) - // Standard Error: 2_000 - .saturating_add((138_000 as Weight).saturating_mul(p as Weight)) + (17_173_000 as Weight) + // Standard Error: 3_000 + .saturating_add((107_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (54_385_000 as Weight) - // Standard Error: 35_000 - .saturating_add((75_842_000 as Weight).saturating_mul(p as Weight)) + (85_793_000 as Weight) + // Standard Error: 40_000 + .saturating_add((76_507_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (54_772_000 as Weight) + (51_464_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_798_000 as Weight) + (48_566_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (16_251_000 as Weight) - // Standard Error: 2_000 - .saturating_add((138_000 as Weight).saturating_mul(p as Weight)) + (17_173_000 as Weight) + // Standard Error: 3_000 + .saturating_add((107_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (54_385_000 as Weight) - // Standard Error: 35_000 - .saturating_add((75_842_000 as Weight).saturating_mul(p as Weight)) + (85_793_000 as Weight) + // Standard Error: 40_000 + .saturating_add((76_507_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) From 7410417dad63c3eef38cc221964bf689e25a781b Mon Sep 17 00:00:00 2001 From: Parity Bot Date: Tue, 13 Jul 2021 05:25:45 +0000 Subject: [PATCH 19/22] cargo run --quiet --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_collective --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/collective/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/collective/src/weights.rs | 144 ++++++++++++++++---------------- 1 file changed, 72 insertions(+), 72 deletions(-) diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index 46bd999344add..de314f9148038 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -17,8 +17,8 @@ //! Autogenerated weights for pallet_collective //! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 -//! DATE: 2021-06-19, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2021-07-13, STEPS: `[50, ]`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 // Executed Command: @@ -61,95 +61,95 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn set_members(m: u32, n: u32, p: u32, ) -> Weight { (0 as Weight) - // Standard Error: 5_000 - .saturating_add((15_266_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 5_000 - .saturating_add((39_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 5_000 - .saturating_add((20_899_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 10_000 + .saturating_add((15_653_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 10_000 + .saturating_add((184_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 10_000 + .saturating_add((22_814_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } fn execute(b: u32, m: u32, ) -> Weight { - (21_945_000 as Weight) + (25_988_000 as Weight) // Standard Error: 0 .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((93_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((98_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } fn propose_execute(b: u32, m: u32, ) -> Weight { - (26_316_000 as Weight) + (32_279_000 as Weight) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((184_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((187_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) } fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (42_664_000 as Weight) + (61_554_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((166_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((435_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((480_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn vote(m: u32, ) -> Weight { - (43_750_000 as Weight) - // Standard Error: 3_000 - .saturating_add((198_000 as Weight).saturating_mul(m as Weight)) + (42_996_000 as Weight) + // Standard Error: 0 + .saturating_add((222_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (44_153_000 as Weight) + (50_677_000 as Weight) // Standard Error: 0 - .saturating_add((185_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((194_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((454_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((365_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (65_478_000 as Weight) + (72_651_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((167_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((176_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((434_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((500_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_disapproved(m: u32, p: u32, ) -> Weight { - (49_001_000 as Weight) + (57_300_000 as Weight) // Standard Error: 0 - .saturating_add((189_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((200_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((464_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((519_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (65_049_000 as Weight) + (76_082_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 1_000 .saturating_add((192_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 1_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 0 + .saturating_add((517_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn disapprove_proposal(p: u32, ) -> Weight { - (27_288_000 as Weight) - // Standard Error: 1_000 - .saturating_add((477_000 as Weight).saturating_mul(p as Weight)) + (32_415_000 as Weight) + // Standard Error: 0 + .saturating_add((521_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -159,95 +159,95 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { fn set_members(m: u32, n: u32, p: u32, ) -> Weight { (0 as Weight) - // Standard Error: 5_000 - .saturating_add((15_266_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 5_000 - .saturating_add((39_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 5_000 - .saturating_add((20_899_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 10_000 + .saturating_add((15_653_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 10_000 + .saturating_add((184_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 10_000 + .saturating_add((22_814_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } fn execute(b: u32, m: u32, ) -> Weight { - (21_945_000 as Weight) + (25_988_000 as Weight) // Standard Error: 0 .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((93_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((98_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } fn propose_execute(b: u32, m: u32, ) -> Weight { - (26_316_000 as Weight) + (32_279_000 as Weight) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((184_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((187_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) } fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (42_664_000 as Weight) + (61_554_000 as Weight) // Standard Error: 0 .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((166_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((435_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((480_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn vote(m: u32, ) -> Weight { - (43_750_000 as Weight) - // Standard Error: 3_000 - .saturating_add((198_000 as Weight).saturating_mul(m as Weight)) + (42_996_000 as Weight) + // Standard Error: 0 + .saturating_add((222_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (44_153_000 as Weight) + (50_677_000 as Weight) // Standard Error: 0 - .saturating_add((185_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((194_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((454_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((365_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (65_478_000 as Weight) + (72_651_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((167_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((176_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((434_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((500_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_disapproved(m: u32, p: u32, ) -> Weight { - (49_001_000 as Weight) + (57_300_000 as Weight) // Standard Error: 0 - .saturating_add((189_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((200_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((464_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((519_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (65_049_000 as Weight) + (76_082_000 as Weight) + // Standard Error: 0 + .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 1_000 .saturating_add((192_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 1_000 - .saturating_add((469_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 0 + .saturating_add((517_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn disapprove_proposal(p: u32, ) -> Weight { - (27_288_000 as Weight) - // Standard Error: 1_000 - .saturating_add((477_000 as Weight).saturating_mul(p as Weight)) + (32_415_000 as Weight) + // Standard Error: 0 + .saturating_add((521_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } From bac19fa73f93accc540e063ecdc2464bb0aac3de Mon Sep 17 00:00:00 2001 From: emostov <32168567+emostov@users.noreply.github.com> Date: Mon, 12 Jul 2021 23:28:23 -0700 Subject: [PATCH 20/22] motion_with_no_votes_closes_with_disapproval --- frame/collective/src/lib.rs | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/frame/collective/src/lib.rs b/frame/collective/src/lib.rs index 0ec06f7185ed9..e53df80751beb 100644 --- a/frame/collective/src/lib.rs +++ b/frame/collective/src/lib.rs @@ -1476,8 +1476,6 @@ mod tests { Error::::DuplicateVote, ); - let events = System::events(); - assert_eq!(events.len(), 3); assert_eq!(System::events(), vec![ EventRecord { phase: Phase::Initialization, @@ -1757,6 +1755,37 @@ mod tests { }); } + #[test] + fn motion_with_no_votes_closes_with_disapproval() { + new_test_ext().execute_with(|| { + let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] }; + let proposal = make_proposal(42); + let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); + let proposal_weight = proposal.get_dispatch_info().weight; + let hash: H256 = proposal.blake2_256().into(); + assert_ok!(Collective::propose(Origin::signed(1), 3, Box::new(proposal.clone()), proposal_len)); + assert_eq!(System::events()[0], record(Event::Collective(RawEvent::Proposed(1, 0, hash.clone(), 3)))); + + // Closing the motion too early is not possible because it has neither + // an approving or disapproving simple majority due to the lack of votes. + assert_noop!( + Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len), + Error::::TooEarly + ); + + // Once the motion duration passes, + let closing_block = System::block_number() + MotionDuration::get(); + System::set_block_number(closing_block); + // we can successfully close the motion. + assert_ok!(Collective::close(Origin::signed(2), hash.clone(), 0, proposal_weight, proposal_len)); + + // Events show that the close ended in a disapproval. + assert_eq!(System::events()[1], record(Event::Collective(RawEvent::Closed(hash.clone(), 0, 3)))); + assert_eq!(System::events()[2], record(Event::Collective(RawEvent::Disapproved(hash.clone())))); + }) + + } + #[test] fn close_disapprove_does_not_care_about_weight_or_len() { // This test confirms that if you close a proposal that would be disapproved, From 88b913391f78caccd255f00a329d2c11ac6aa207 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 13 Jul 2021 06:56:26 +0000 Subject: [PATCH 21/22] cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_collective --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/collective/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/collective/src/weights.rs | 148 ++++++++++++++++---------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/frame/collective/src/weights.rs b/frame/collective/src/weights.rs index de314f9148038..2bbec4d7cc3d8 100644 --- a/frame/collective/src/weights.rs +++ b/frame/collective/src/weights.rs @@ -61,95 +61,95 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn set_members(m: u32, n: u32, p: u32, ) -> Weight { (0 as Weight) - // Standard Error: 10_000 - .saturating_add((15_653_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 10_000 - .saturating_add((184_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 10_000 - .saturating_add((22_814_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 5_000 + .saturating_add((14_534_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 5_000 + .saturating_add((160_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 5_000 + .saturating_add((20_189_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } fn execute(b: u32, m: u32, ) -> Weight { - (25_988_000 as Weight) + (23_177_000 as Weight) // Standard Error: 0 .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((98_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((89_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) } fn propose_execute(b: u32, m: u32, ) -> Weight { - (32_279_000 as Weight) + (28_063_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((187_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((174_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) } fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (61_554_000 as Weight) + (46_515_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((91_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((480_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((486_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } fn vote(m: u32, ) -> Weight { - (42_996_000 as Weight) + (38_491_000 as Weight) // Standard Error: 0 - .saturating_add((222_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((209_000 as Weight).saturating_mul(m as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (50_677_000 as Weight) + (44_903_000 as Weight) // Standard Error: 0 - .saturating_add((194_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((181_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((365_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((350_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (72_651_000 as Weight) + (57_416_000 as Weight) // Standard Error: 0 .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 2_000 - .saturating_add((176_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 2_000 - .saturating_add((500_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 1_000 + .saturating_add((217_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 1_000 + .saturating_add((485_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_disapproved(m: u32, p: u32, ) -> Weight { - (57_300_000 as Weight) + (50_134_000 as Weight) // Standard Error: 0 - .saturating_add((200_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((189_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((519_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((487_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (76_082_000 as Weight) + (65_901_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((192_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((517_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 1_000 + .saturating_add((186_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 1_000 + .saturating_add((482_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } fn disapprove_proposal(p: u32, ) -> Weight { - (32_415_000 as Weight) - // Standard Error: 0 - .saturating_add((521_000 as Weight).saturating_mul(p as Weight)) + (28_849_000 as Weight) + // Standard Error: 1_000 + .saturating_add((494_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -159,95 +159,95 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { fn set_members(m: u32, n: u32, p: u32, ) -> Weight { (0 as Weight) - // Standard Error: 10_000 - .saturating_add((15_653_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 10_000 - .saturating_add((184_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 10_000 - .saturating_add((22_814_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 5_000 + .saturating_add((14_534_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 5_000 + .saturating_add((160_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 5_000 + .saturating_add((20_189_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes((1 as Weight).saturating_mul(p as Weight))) } fn execute(b: u32, m: u32, ) -> Weight { - (25_988_000 as Weight) + (23_177_000 as Weight) // Standard Error: 0 .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((98_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((89_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) } fn propose_execute(b: u32, m: u32, ) -> Weight { - (32_279_000 as Weight) + (28_063_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 0 - .saturating_add((187_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((174_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) } fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (61_554_000 as Weight) + (46_515_000 as Weight) // Standard Error: 0 - .saturating_add((2_000 as Weight).saturating_mul(b as Weight)) + .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) // Standard Error: 2_000 - .saturating_add((56_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((91_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 2_000 - .saturating_add((480_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((486_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } fn vote(m: u32, ) -> Weight { - (42_996_000 as Weight) + (38_491_000 as Weight) // Standard Error: 0 - .saturating_add((222_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((209_000 as Weight).saturating_mul(m as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (50_677_000 as Weight) + (44_903_000 as Weight) // Standard Error: 0 - .saturating_add((194_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((181_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((365_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((350_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (72_651_000 as Weight) + (57_416_000 as Weight) // Standard Error: 0 .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 2_000 - .saturating_add((176_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 2_000 - .saturating_add((500_000 as Weight).saturating_mul(p as Weight)) + // Standard Error: 1_000 + .saturating_add((217_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 1_000 + .saturating_add((485_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_disapproved(m: u32, p: u32, ) -> Weight { - (57_300_000 as Weight) + (50_134_000 as Weight) // Standard Error: 0 - .saturating_add((200_000 as Weight).saturating_mul(m as Weight)) + .saturating_add((189_000 as Weight).saturating_mul(m as Weight)) // Standard Error: 0 - .saturating_add((519_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((487_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (76_082_000 as Weight) + (65_901_000 as Weight) // Standard Error: 0 - .saturating_add((5_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 0 - .saturating_add((192_000 as Weight).saturating_mul(m as Weight)) - // Standard Error: 0 - .saturating_add((517_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 1_000 + .saturating_add((186_000 as Weight).saturating_mul(m as Weight)) + // Standard Error: 1_000 + .saturating_add((482_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } fn disapprove_proposal(p: u32, ) -> Weight { - (32_415_000 as Weight) - // Standard Error: 0 - .saturating_add((521_000 as Weight).saturating_mul(p as Weight)) + (28_849_000 as Weight) + // Standard Error: 1_000 + .saturating_add((494_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } From 898963ba41e7785f0d9669fa9676701d453e4528 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 13 Jul 2021 07:02:03 +0000 Subject: [PATCH 22/22] cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_treasury --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/treasury/src/weights.rs --template=./.maintain/frame-weight-template.hbs --- frame/treasury/src/weights.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/frame/treasury/src/weights.rs b/frame/treasury/src/weights.rs index 9db5776b6c7f0..d293399e7b480 100644 --- a/frame/treasury/src/weights.rs +++ b/frame/treasury/src/weights.rs @@ -54,26 +54,26 @@ pub trait WeightInfo { pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn propose_spend() -> Weight { - (51_464_000 as Weight) + (42_325_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_566_000 as Weight) + (39_633_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_173_000 as Weight) - // Standard Error: 3_000 - .saturating_add((107_000 as Weight).saturating_mul(p as Weight)) + (14_337_000 as Weight) + // Standard Error: 2_000 + .saturating_add((116_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (85_793_000 as Weight) - // Standard Error: 40_000 - .saturating_add((76_507_000 as Weight).saturating_mul(p as Weight)) + (50_379_000 as Weight) + // Standard Error: 18_000 + .saturating_add((59_595_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(T::DbWeight::get().writes(2 as Weight)) @@ -84,26 +84,26 @@ impl WeightInfo for SubstrateWeight { // For backwards compatibility and tests impl WeightInfo for () { fn propose_spend() -> Weight { - (51_464_000 as Weight) + (42_325_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn reject_proposal() -> Weight { - (48_566_000 as Weight) + (39_633_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } fn approve_proposal(p: u32, ) -> Weight { - (17_173_000 as Weight) - // Standard Error: 3_000 - .saturating_add((107_000 as Weight).saturating_mul(p as Weight)) + (14_337_000 as Weight) + // Standard Error: 2_000 + .saturating_add((116_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } fn on_initialize_proposals(p: u32, ) -> Weight { - (85_793_000 as Weight) - // Standard Error: 40_000 - .saturating_add((76_507_000 as Weight).saturating_mul(p as Weight)) + (50_379_000 as Weight) + // Standard Error: 18_000 + .saturating_add((59_595_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().reads((3 as Weight).saturating_mul(p as Weight))) .saturating_add(RocksDbWeight::get().writes(2 as Weight))