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
+22 -1
View File
@@ -43,7 +43,7 @@ use frame_support::{
decl_module, decl_event, decl_error, decl_storage, Parameter, ensure, traits::{
Get, ReservableCurrency, Currency, InstanceFilter,
OriginTrait, IsType,
}, weights::{GetDispatchInfo, constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS}},
}, weights::{Weight, GetDispatchInfo, constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS}},
dispatch::{PostDispatchInfo, IsSubType},
};
use frame_system::{self as system, ensure_signed};
@@ -53,6 +53,24 @@ mod benchmarking;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
pub trait WeightInfo {
fn proxy(p: u32, ) -> Weight;
fn add_proxy(p: u32, ) -> Weight;
fn remove_proxy(p: u32, ) -> Weight;
fn remove_proxies(p: u32, ) -> Weight;
fn anonymous(p: u32, ) -> Weight;
fn kill_anonymous(p: u32, ) -> Weight;
}
impl WeightInfo for () {
fn proxy(_p: u32, ) -> Weight { 1_000_000_000 }
fn add_proxy(_p: u32, ) -> Weight { 1_000_000_000 }
fn remove_proxy(_p: u32, ) -> Weight { 1_000_000_000 }
fn remove_proxies(_p: u32, ) -> Weight { 1_000_000_000 }
fn anonymous(_p: u32, ) -> Weight { 1_000_000_000 }
fn kill_anonymous(_p: u32, ) -> Weight { 1_000_000_000 }
}
/// Configuration trait.
pub trait Trait: frame_system::Trait {
/// The overarching event type.
@@ -87,6 +105,9 @@ pub trait Trait: frame_system::Trait {
/// The maximum amount of proxies allowed for a single account.
type MaxProxies: Get<u16>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
decl_storage! {
+4
View File
@@ -86,6 +86,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;
@@ -96,10 +97,12 @@ impl pallet_balances::Trait for Test {
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
impl pallet_utility::Trait for Test {
type Event = TestEvent;
type Call = Call;
type WeightInfo = ();
}
parameter_types! {
pub const ProxyDepositBase: u64 = 1;
@@ -144,6 +147,7 @@ impl Trait for Test {
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = ();
}
type System = frame_system::Module<Test>;