Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
aadfd4b
Introduce `cancel_proposal`
gavofyork Sep 15, 2020
a67a018
Support proposal cancellation from runtime.
gavofyork Sep 15, 2020
bec8bad
Fixes
gavofyork Sep 15, 2020
06c97f2
Fixes
gavofyork Sep 15, 2020
693fc82
Fixes
gavofyork Sep 15, 2020
bbe86b6
Fixes
gavofyork Sep 16, 2020
083ba8d
Fixes
gavofyork Sep 16, 2020
3626e8e
Fixes
gavofyork Sep 16, 2020
c93eedb
Fixes
gavofyork Sep 16, 2020
2274fa3
Merge remote-tracking branch 'origin/master' into gav-cancel-proposal
gavofyork Sep 17, 2020
400d8e4
Merge remote-tracking branch 'origin/master' into gav-cancel-proposal
gavofyork Sep 17, 2020
a8e9fe8
Fix benchmarks
shawntabrizi Sep 21, 2020
764ea77
fix benchmark
shawntabrizi Sep 21, 2020
a5dfded
whitelisted caller weights
shawntabrizi Sep 21, 2020
4aaa1e8
Merge branch 'master' into gav-cancel-proposal
shawntabrizi Sep 22, 2020
a36189f
fix build
shawntabrizi Sep 22, 2020
1254cf6
Merge remote-tracking branch 'origin/master' into gav-cancel-proposal
gavofyork Sep 23, 2020
f60cccc
Fixes
gavofyork Sep 23, 2020
13cace0
Fixes
gavofyork Sep 23, 2020
02e4fe8
Fixes
gavofyork Sep 23, 2020
88dc626
Fixes
gavofyork Sep 23, 2020
a1ebcb1
Merge remote-tracking branch 'origin/master' into gav-cancel-proposal
gavofyork Sep 23, 2020
775b637
Update frame/democracy/src/lib.rs
gavofyork Sep 24, 2020
9c0cf8d
Fixes
gavofyork Sep 24, 2020
2ba9cdd
Fixes
gavofyork Sep 24, 2020
847414f
Merge branch 'gav-cancel-proposal' of github.com:paritytech/substrate…
gavofyork Sep 24, 2020
4ecbddf
Fixes
gavofyork Sep 24, 2020
2f84c91
Fixes
gavofyork Sep 24, 2020
42b9093
Fixes
gavofyork Sep 24, 2020
97af811
doc updates
shawntabrizi Sep 24, 2020
b466e1f
new weights
shawntabrizi Sep 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix benchmarks
  • Loading branch information
shawntabrizi committed Sep 21, 2020
commit a8e9fe8db8dc528cd05cf954d3aa192b6db82abd
121 changes: 63 additions & 58 deletions bin/node/runtime/src/weights/pallet_democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,151 +14,156 @@
// limitations under the License.

//! Weights for the Democracy Pallet
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6

#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

pub struct WeightInfo;
impl pallet_democracy::WeightInfo for WeightInfo {
fn propose(p: u32, ) -> Weight {
(49113000 as Weight)
.saturating_add((220000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
(173882000 as Weight)
.saturating_add((58000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(4 as Weight))
.saturating_add(DbWeight::get().writes(4 as Weight))
}
fn second(s: u32, ) -> Weight {
(42067000 as Weight)
.saturating_add((220000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
(111076000 as Weight)
.saturating_add((551000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn vote_new(r: u32, ) -> Weight {
(54159000 as Weight)
.saturating_add((252000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
(150748000 as Weight)
.saturating_add((396000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(4 as Weight))
.saturating_add(DbWeight::get().writes(4 as Weight))
}
fn vote_existing(r: u32, ) -> Weight {
(54145000 as Weight)
.saturating_add((262000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
(118820000 as Weight)
.saturating_add((1193000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(4 as Weight))
.saturating_add(DbWeight::get().writes(4 as Weight))
}
fn emergency_cancel() -> Weight {
(31071000 as Weight)
(43278000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn blacklist() -> Weight {
(31071000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
fn blacklist(p: u32, ) -> Weight {
(442525000 as Weight)
.saturating_add((515000 as Weight).saturating_mul(p as Weight))
.saturating_add(DbWeight::get().reads(5 as Weight))
.saturating_add(DbWeight::get().writes(6 as Weight))
}
fn external_propose(v: u32, ) -> Weight {
(14282000 as Weight)
.saturating_add((109000 as Weight).saturating_mul(v as Weight))
(20349000 as Weight)
.saturating_add((114000 as Weight).saturating_mul(v as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn external_propose_majority() -> Weight {
(3478000 as Weight)
(4889000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn external_propose_default() -> Weight {
(3442000 as Weight)
(4875000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn fast_track() -> Weight {
(30820000 as Weight)
(41326000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
}
fn veto_external(v: u32, ) -> Weight {
(30971000 as Weight)
.saturating_add((184000 as Weight).saturating_mul(v as Weight))
(42518000 as Weight)
.saturating_add((191000 as Weight).saturating_mul(v as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn cancel_proposal() -> Weight {
(20431000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
(65871000 as Weight)
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
}
fn cancel_referendum() -> Weight {
(20431000 as Weight)
(26151000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn cancel_queued(r: u32, ) -> Weight {
(42438000 as Weight)
.saturating_add((3284000 as Weight).saturating_mul(r as Weight))
(0 as Weight)
.saturating_add((8246000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn on_initialize_base(r: u32, ) -> Weight {
(70826000 as Weight)
.saturating_add((10716000 as Weight).saturating_mul(r as Weight))
(302489000 as Weight)
.saturating_add((21766000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(6 as Weight))
.saturating_add(DbWeight::get().reads((2 as Weight).saturating_mul(r as Weight)))
.saturating_add(DbWeight::get().writes(5 as Weight))
}
fn delegate(r: u32, ) -> Weight {
(72046000 as Weight)
.saturating_add((7837000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(4 as Weight))
(178766000 as Weight)
.saturating_add((19805000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(5 as Weight))
.saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight)))
.saturating_add(DbWeight::get().writes(4 as Weight))
.saturating_add(DbWeight::get().writes(5 as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight)))
}
fn undelegate(r: u32, ) -> Weight {
(41028000 as Weight)
.saturating_add((7810000 as Weight).saturating_mul(r as Weight))
(163433000 as Weight)
.saturating_add((8980000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().reads((1 as Weight).saturating_mul(r as Weight)))
.saturating_add(DbWeight::get().writes(2 as Weight))
.saturating_add(DbWeight::get().writes((1 as Weight).saturating_mul(r as Weight)))
}
fn clear_public_proposals() -> Weight {
(3643000 as Weight)
(4854000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn note_preimage(b: u32, ) -> Weight {
(46629000 as Weight)
(63227000 as Weight)
.saturating_add((4000 as Weight).saturating_mul(b as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn note_imminent_preimage(b: u32, ) -> Weight {
(31147000 as Weight)
.saturating_add((3000 as Weight).saturating_mul(b as Weight))
(42569000 as Weight)
.saturating_add((4000 as Weight).saturating_mul(b as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn reap_preimage(b: u32, ) -> Weight {
(42848000 as Weight)
(57894000 as Weight)
.saturating_add((3000 as Weight).saturating_mul(b as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn unlock_remove(r: u32, ) -> Weight {
(45333000 as Weight)
.saturating_add((171000 as Weight).saturating_mul(r as Weight))
(57008000 as Weight)
.saturating_add((275000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
}
fn unlock_set(r: u32, ) -> Weight {
(44424000 as Weight)
.saturating_add((291000 as Weight).saturating_mul(r as Weight))
(53179000 as Weight)
.saturating_add((460000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(3 as Weight))
.saturating_add(DbWeight::get().writes(3 as Weight))
}
fn remove_vote(r: u32, ) -> Weight {
(28250000 as Weight)
.saturating_add((283000 as Weight).saturating_mul(r as Weight))
(31536000 as Weight)
.saturating_add((445000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn remove_other_vote(r: u32, ) -> Weight {
(28250000 as Weight)
.saturating_add((283000 as Weight).saturating_mul(r as Weight))
(31418000 as Weight)
.saturating_add((446000 as Weight).saturating_mul(r as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
Expand Down
9 changes: 9 additions & 0 deletions frame/benchmarking/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,12 @@ pub fn account<AccountId: Decode + Default>(name: &'static str, index: u32, seed
pub fn whitelisted_caller<AccountId: Decode + Default>() -> AccountId {
account::<AccountId>("whitelisted_caller", 0, 0)
}

#[macro_export]
macro_rules! whitelist_account {
($acc:ident) => {
frame_benchmarking::benchmarking::add_to_whitelist(
frame_system::Account::<T>::hashed_key_for(&$acc).into()
);
}
}
20 changes: 15 additions & 5 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

use super::*;

use frame_benchmarking::{benchmarks, account};
use frame_benchmarking::{benchmarks, account, whitelist_account};
use frame_support::{
IterableStorageMap,
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
Expand Down Expand Up @@ -109,6 +109,7 @@ benchmarks! {
let caller = funded_account::<T>("caller", 0);
let proposal_hash: T::Hash = T::Hashing::hash_of(&0);
let value = T::MinimumDeposit::get();
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), proposal_hash, value.into(), MAX_PROPOSALS)
verify {
assert_eq!(Democracy::<T>::public_props().len(), p as usize, "Proposals not created.");
Expand All @@ -128,6 +129,7 @@ benchmarks! {

let deposits = Democracy::<T>::deposit_of(0).ok_or("Proposal not created")?;
assert_eq!(deposits.0.len(), (s + 1) as usize, "Seconds not recorded");
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), 0, u32::max_value())
verify {
let deposits = Democracy::<T>::deposit_of(0).ok_or("Proposal not created")?;
Expand All @@ -152,7 +154,7 @@ benchmarks! {
assert_eq!(votes.len(), r as usize, "Votes were not recorded.");

let referendum_index = add_referendum::<T>(r)?;

whitelist_account!(caller);
}: vote(RawOrigin::Signed(caller.clone()), referendum_index, account_vote)
verify {
let votes = match VotingOf::<T>::get(&caller) {
Expand Down Expand Up @@ -185,6 +187,7 @@ benchmarks! {
let referendum_index = Democracy::<T>::referendum_count() - 1;

// This tests when a user changes a vote
whitelist_account!(caller);
}: vote(RawOrigin::Signed(caller.clone()), referendum_index, new_vote)
verify {
let votes = match VotingOf::<T>::get(&caller) {
Expand Down Expand Up @@ -230,7 +233,7 @@ benchmarks! {
let referendum_index = add_referendum::<T>(0)?;
assert!(Democracy::<T>::referendum_status(referendum_index).is_ok());

let call = Call::<T>::blacklist(hash, Some(referendum_index));
let call = Call::<T>::blacklist(hash, Some(referendum_index), p);
let origin = T::BlacklistOrigin::successful_origin();
}: { call.dispatch_bypass_filter(origin)? }
verify {
Expand Down Expand Up @@ -473,6 +476,7 @@ benchmarks! {
_ => return Err("Votes are not direct"),
};
assert_eq!(votes.len(), r as usize, "Votes were not recorded.");
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller.clone()), new_delegate.clone(), Conviction::Locked1x, delegated_balance)
verify {
let (target, balance) = match VotingOf::<T>::get(&caller) {
Expand Down Expand Up @@ -524,6 +528,7 @@ benchmarks! {
_ => return Err("Votes are not direct"),
};
assert_eq!(votes.len(), r as usize, "Votes were not recorded.");
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller.clone()))
verify {
// Voting should now be direct
Expand All @@ -544,6 +549,7 @@ benchmarks! {

let caller = funded_account::<T>("caller", 0);
let encoded_proposal = vec![1; b as usize];
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), encoded_proposal.clone())
verify {
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
Expand All @@ -565,6 +571,7 @@ benchmarks! {

let caller = funded_account::<T>("caller", 0);
let encoded_proposal = vec![1; b as usize];
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), encoded_proposal.clone())
verify {
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
Expand All @@ -591,6 +598,7 @@ benchmarks! {
assert!(Preimages::<T>::contains_key(proposal_hash));

let caller = funded_account::<T>("caller", 0);
whitelist_account!(caller);
}: _(RawOrigin::Signed(caller), proposal_hash.clone(), u32::max_value())
verify {
let proposal_hash = T::Hashing::hash(&encoded_proposal[..]);
Expand All @@ -613,6 +621,7 @@ benchmarks! {
}

let caller = funded_account::<T>("caller", 0);
whitelist_account!(caller);
}: unlock(RawOrigin::Signed(caller), locker.clone())
verify {
// Note that we may want to add a `get_lock` api to actually verify
Expand Down Expand Up @@ -650,6 +659,7 @@ benchmarks! {
Democracy::<T>::remove_vote(RawOrigin::Signed(locker.clone()).into(), referendum_index)?;

let caller = funded_account::<T>("caller", 0);
whitelist_account!(caller);
}: unlock(RawOrigin::Signed(caller), locker.clone())
verify {
let votes = match VotingOf::<T>::get(&locker) {
Expand Down Expand Up @@ -681,7 +691,7 @@ benchmarks! {
assert_eq!(votes.len(), r as usize, "Votes not created");

let referendum_index = r - 1;

whitelist_account!(caller);
}: _(RawOrigin::Signed(caller.clone()), referendum_index)
verify {
let votes = match VotingOf::<T>::get(&caller) {
Expand Down Expand Up @@ -710,7 +720,7 @@ benchmarks! {
assert_eq!(votes.len(), r as usize, "Votes not created");

let referendum_index = r - 1;

whitelist_account!(caller);
}: _(RawOrigin::Signed(caller.clone()), caller.clone(), referendum_index)
verify {
let votes = match VotingOf::<T>::get(&caller) {
Expand Down
Loading