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
+20 -1
View File
@@ -28,7 +28,7 @@ use sp_runtime::traits::{
use frame_support::{Parameter, decl_module, decl_error, decl_event, decl_storage, ensure};
use frame_support::dispatch::DispatchResult;
use frame_support::traits::{Currency, ReservableCurrency, Get, BalanceStatus::Reserved};
use frame_support::weights::constants::WEIGHT_PER_MICROS;
use frame_support::weights::{Weight, constants::WEIGHT_PER_MICROS};
use frame_system::{ensure_signed, ensure_root};
use self::address::Address as RawAddress;
@@ -40,6 +40,22 @@ mod benchmarking;
pub type Address<T> = RawAddress<<T as frame_system::Trait>::AccountId, <T as Trait>::AccountIndex>;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
pub trait WeightInfo {
fn claim(i: u32, ) -> Weight;
fn transfer(i: u32, ) -> Weight;
fn free(i: u32, ) -> Weight;
fn force_transfer(i: u32, ) -> Weight;
fn freeze(i: u32, ) -> Weight;
}
impl WeightInfo for () {
fn claim(_i: u32, ) -> Weight { 1_000_000_000 }
fn transfer(_i: u32, ) -> Weight { 1_000_000_000 }
fn free(_i: u32, ) -> Weight { 1_000_000_000 }
fn force_transfer(_i: u32, ) -> Weight { 1_000_000_000 }
fn freeze(_i: u32, ) -> Weight { 1_000_000_000 }
}
/// The module's config trait.
pub trait Trait: frame_system::Trait {
/// Type used for storing an account's index; implies the maximum number of accounts the system
@@ -54,6 +70,9 @@ pub trait Trait: frame_system::Trait {
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
decl_storage! {
+3
View File
@@ -74,6 +74,7 @@ impl frame_system::Trait for Test {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
parameter_types! {
@@ -86,6 +87,7 @@ impl pallet_balances::Trait for Test {
type Event = MetaEvent;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
@@ -97,6 +99,7 @@ impl Trait for Test {
type Currency = Balances;
type Deposit = Deposit;
type Event = MetaEvent;
type WeightInfo = ();
}
pub fn new_test_ext() -> sp_io::TestExternalities {