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
+13
View File
@@ -70,6 +70,16 @@ use sp_runtime::{DispatchError, DispatchResult, traits::Dispatchable};
mod tests;
mod benchmarking;
pub trait WeightInfo {
fn batch(c: u32, ) -> Weight;
fn as_derivative(u: u32, ) -> Weight;
}
impl WeightInfo for () {
fn batch(_c: u32, ) -> Weight { 1_000_000_000 }
fn as_derivative(_u: u32, ) -> Weight { 1_000_000_000 }
}
/// Configuration trait.
pub trait Trait: frame_system::Trait {
/// The overarching event type.
@@ -79,6 +89,9 @@ pub trait Trait: frame_system::Trait {
type Call: Parameter + Dispatchable<Origin=Self::Origin, PostInfo=PostDispatchInfo>
+ GetDispatchInfo + From<frame_system::Call<Self>>
+ UnfilteredDispatchable<Origin=Self::Origin>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
decl_storage! {
+3
View File
@@ -83,6 +83,7 @@ impl frame_system::Trait for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
parameter_types! {
pub const ExistentialDeposit: u64 = 1;
@@ -93,6 +94,7 @@ impl pallet_balances::Trait for Test {
type Event = TestEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const MultisigDepositBase: u64 = 1;
@@ -113,6 +115,7 @@ impl Filter<Call> for TestBaseCallFilter {
impl Trait for Test {
type Event = TestEvent;
type Call = Call;
type WeightInfo = ();
}
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;