Add WeightInfo to all pallets with benchmarks. (#6575)

* Start adding weight info

* More weightinfo

* finish weight info

* more fixes

* inital update of node runtime

* fix the rest of the compilation

* update balances

* add docs

* fix balances tests

* Fix more tests

* Fix compile

* Fix pallet-evm tests
This commit is contained in:
Shawn Tabrizi
2020-07-08 18:22:01 +02:00
committed by GitHub
parent 94cddee160
commit 2302898b8a
65 changed files with 632 additions and 7 deletions
+63
View File
@@ -201,6 +201,66 @@ type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trai
type NegativeImbalanceOf<T> =
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
pub trait WeightInfo {
fn propose(p: u32, ) -> Weight;
fn second(s: u32, ) -> Weight;
fn vote_new(r: u32, ) -> Weight;
fn vote_existing(r: u32, ) -> Weight;
fn emergency_cancel(r: u32, ) -> Weight;
fn external_propose(p: u32, v: u32, ) -> Weight;
fn external_propose_majority(p: u32, ) -> Weight;
fn external_propose_default(p: u32, ) -> Weight;
fn fast_track(p: u32, ) -> Weight;
fn veto_external(v: u32, ) -> Weight;
fn cancel_referendum(r: u32, ) -> Weight;
fn cancel_queued(r: u32, ) -> Weight;
fn on_initialize_external(r: u32, ) -> Weight;
fn on_initialize_public(r: u32, ) -> Weight;
fn on_initialize_no_launch_no_maturing(r: u32, ) -> Weight;
fn delegate(r: u32, ) -> Weight;
fn undelegate(r: u32, ) -> Weight;
fn clear_public_proposals(p: u32, ) -> Weight;
fn note_preimage(b: u32, ) -> Weight;
fn note_imminent_preimage(b: u32, ) -> Weight;
fn reap_preimage(b: u32, ) -> Weight;
fn unlock_remove(r: u32, ) -> Weight;
fn unlock_set(r: u32, ) -> Weight;
fn remove_vote(r: u32, ) -> Weight;
fn remove_other_vote(r: u32, ) -> Weight;
fn enact_proposal_execute(b: u32, ) -> Weight;
fn enact_proposal_slash(b: u32, ) -> Weight;
}
impl WeightInfo for () {
fn propose(_p: u32, ) -> Weight { 1_000_000_000 }
fn second(_s: u32, ) -> Weight { 1_000_000_000 }
fn vote_new(_r: u32, ) -> Weight { 1_000_000_000 }
fn vote_existing(_r: u32, ) -> Weight { 1_000_000_000 }
fn emergency_cancel(_r: u32, ) -> Weight { 1_000_000_000 }
fn external_propose(_p: u32, _v: u32, ) -> Weight { 1_000_000_000 }
fn external_propose_majority(_p: u32, ) -> Weight { 1_000_000_000 }
fn external_propose_default(_p: u32, ) -> Weight { 1_000_000_000 }
fn fast_track(_p: u32, ) -> Weight { 1_000_000_000 }
fn veto_external(_v: u32, ) -> Weight { 1_000_000_000 }
fn cancel_referendum(_r: u32, ) -> Weight { 1_000_000_000 }
fn cancel_queued(_r: u32, ) -> Weight { 1_000_000_000 }
fn on_initialize_external(_r: u32, ) -> Weight { 1_000_000_000 }
fn on_initialize_public(_r: u32, ) -> Weight { 1_000_000_000 }
fn on_initialize_no_launch_no_maturing(_r: u32, ) -> Weight { 1_000_000_000 }
fn delegate(_r: u32, ) -> Weight { 1_000_000_000 }
fn undelegate(_r: u32, ) -> Weight { 1_000_000_000 }
fn clear_public_proposals(_p: u32, ) -> Weight { 1_000_000_000 }
fn note_preimage(_b: u32, ) -> Weight { 1_000_000_000 }
fn note_imminent_preimage(_b: u32, ) -> Weight { 1_000_000_000 }
fn reap_preimage(_b: u32, ) -> Weight { 1_000_000_000 }
fn unlock_remove(_r: u32, ) -> Weight { 1_000_000_000 }
fn unlock_set(_r: u32, ) -> Weight { 1_000_000_000 }
fn remove_vote(_r: u32, ) -> Weight { 1_000_000_000 }
fn remove_other_vote(_r: u32, ) -> Weight { 1_000_000_000 }
fn enact_proposal_execute(_b: u32, ) -> Weight { 1_000_000_000 }
fn enact_proposal_slash(_b: u32, ) -> Weight { 1_000_000_000 }
}
pub trait Trait: frame_system::Trait + Sized {
type Proposal: Parameter + Dispatchable<Origin=Self::Origin> + From<Call<Self>>;
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
@@ -289,6 +349,9 @@ pub trait Trait: frame_system::Trait + Sized {
/// Also used to compute weight, an overly big value can
/// lead to extrinsic with very big weight: see `delegate` for instance.
type MaxVotes: Get<u32>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
#[derive(Clone, Encode, Decode, RuntimeDebug)]
+4
View File
@@ -116,6 +116,7 @@ impl frame_system::Trait for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * MaximumBlockWeight::get();
@@ -127,6 +128,7 @@ impl pallet_scheduler::Trait for Test {
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<u64>;
type WeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
@@ -137,6 +139,7 @@ impl pallet_balances::Trait for Test {
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const LaunchPeriod: u64 = 2;
@@ -199,6 +202,7 @@ impl super::Trait for Test {
type MaxVotes = MaxVotes;
type OperationalPreimageOrigin = EnsureSignedBy<Six, u64>;
type PalletsOrigin = OriginCaller;
type WeightInfo = ();
}
pub fn new_test_ext() -> sp_io::TestExternalities {