Unverified Commit 4817654f authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Companion PR: add weightinfo for democracy (#1522)



* add weight for democracy

* update companion

* update companion

* remove democracy weight tests

* fix import

* fix name

* fix merge

* cargo update -p sp-io

* fix compile

Co-authored-by: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>
parent 19b88fff
Pipeline #102926 failed with stages
in 11 minutes and 45 seconds
This diff is collapsed.
......@@ -404,7 +404,7 @@ impl pallet_democracy::Trait for Runtime {
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilCollective>;
type WeightInfo = ();
type WeightInfo = weights::pallet_democracy::WeightInfo;
}
parameter_types! {
......
......@@ -17,3 +17,4 @@
/// A collection of weight modules used for pallets in the runtime.
pub mod pallet_balances;
pub mod pallet_democracy;
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Weights for the Democracy Pallet
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
pub struct WeightInfo;
impl pallet_democracy::WeightInfo for WeightInfo {
fn propose() -> Weight {
(49113000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(3 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))
}
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))
}
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))
}
fn emergency_cancel() -> Weight {
(31071000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn external_propose(v: u32, ) -> Weight {
(14282000 as Weight)
.saturating_add((109000 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)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn external_propose_default() -> Weight {
(3442000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn fast_track() -> Weight {
(30820000 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))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn cancel_referendum() -> Weight {
(20431000 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))
.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))
.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))
.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((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))
.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)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn note_preimage(b: u32, ) -> Weight {
(46629000 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 note_imminent_preimage(b: u32, ) -> Weight {
(31147000 as Weight)
.saturating_add((3000 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)
.saturating_add((3000 as Weight).saturating_mul(b as Weight))
.saturating_add(DbWeight::get().reads(2 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))
.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))
.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))
.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))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
}
......@@ -458,7 +458,7 @@ impl pallet_democracy::Trait for Runtime {
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = ();
type WeightInfo = weights::pallet_democracy::WeightInfo;
}
parameter_types! {
......
......@@ -17,3 +17,4 @@
/// A collection of weight modules used for pallets in the runtime.
pub mod pallet_balances;
pub mod pallet_democracy;
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.
// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Weights for the Democracy Pallet
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc5
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
pub struct WeightInfo;
impl pallet_democracy::WeightInfo for WeightInfo {
fn propose() -> Weight {
(49113000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(3 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))
}
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))
}
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))
}
fn emergency_cancel() -> Weight {
(31071000 as Weight)
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn external_propose(v: u32, ) -> Weight {
(14282000 as Weight)
.saturating_add((109000 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)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn external_propose_default() -> Weight {
(3442000 as Weight)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn fast_track() -> Weight {
(30820000 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))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn cancel_referendum() -> Weight {
(20431000 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))
.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))
.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))
.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((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))
.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)
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn note_preimage(b: u32, ) -> Weight {
(46629000 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 note_imminent_preimage(b: u32, ) -> Weight {
(31147000 as Weight)
.saturating_add((3000 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)
.saturating_add((3000 as Weight).saturating_mul(b as Weight))
.saturating_add(DbWeight::get().reads(2 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))
.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))
.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))
.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))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
}
......@@ -32,7 +32,6 @@ use polkadot_runtime::{self, Runtime};
use primitives::v0::AccountId;
use runtime_common::MaximumBlockWeight;
use pallet_democracy::Call as DemocracyCall;
use pallet_elections_phragmen::Call as PhragmenCall;
use pallet_session::Call as SessionCall;
use pallet_staking::Call as StakingCall;
......@@ -159,40 +158,6 @@ fn weight_of_session_purge_keys_is_correct() {
assert_eq!(weight, expected_weight);
}
#[test]
fn weight_of_democracy_propose_is_correct() {
// #[weight = 50_000_000 + T::DbWeight::get().reads_writes(2, 3)]
let expected_weight = 50_000_000 + (DbWeight::get().read * 2) + (DbWeight::get().write * 3);
let weight = DemocracyCall::propose::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;
assert_eq!(weight, expected_weight);
}
#[test]
fn weight_of_democracy_vote_is_correct() {
use pallet_democracy::AccountVote;
let vote = AccountVote::Standard { vote: Default::default(), balance: Default::default() };
// #[weight = 50_000_000 + 350_000 * Weight::from(T::MaxVotes::get()) + T::DbWeight::get().reads_writes(3, 3)]
let expected_weight = 50_000_000
+ 350_000 * (Weight::from(polkadot_runtime::MaxVotes::get()))
+ (DbWeight::get().read * 3)
+ (DbWeight::get().write * 3);
let weight = DemocracyCall::vote::<Runtime>(Default::default(), vote).get_dispatch_info().weight;
assert_eq!(weight, expected_weight);
}
#[test]
fn weight_of_democracy_enact_proposal_is_correct() {
// #[weight = T::MaximumBlockWeight::get()]
let expected_weight = MaximumBlockWeight::get();
let weight =
DemocracyCall::enact_proposal::<Runtime>(Default::default(), Default::default()).get_dispatch_info().weight;
assert_eq!(weight, expected_weight);
}
#[test]
fn weight_of_phragmen_vote_is_correct() {
// #[weight = 100_000_000]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment