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
+24 -2
View File
@@ -53,10 +53,10 @@ use codec::{Encode, Decode};
use sp_runtime::{DispatchResult, RuntimeDebug, traits::{
StaticLookup, Zero, AtLeast32BitUnsigned, MaybeSerializeDeserialize, Convert
}};
use frame_support::{decl_module, decl_event, decl_storage, decl_error, ensure};
use frame_support::{decl_module, decl_event, decl_storage, decl_error, ensure, weights::Weight};
use frame_support::traits::{
Currency, LockableCurrency, VestingSchedule, WithdrawReason, LockIdentifier,
ExistenceRequirement, Get
ExistenceRequirement, Get,
};
use frame_system::{ensure_signed, ensure_root};
@@ -64,6 +64,22 @@ mod benchmarking;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
pub trait WeightInfo {
fn vest_locked(l: u32, ) -> Weight;
fn vest_unlocked(l: u32, ) -> Weight;
fn vest_other_locked(l: u32, ) -> Weight;
fn vest_other_unlocked(l: u32, ) -> Weight;
fn vested_transfer(l: u32, ) -> Weight;
}
impl WeightInfo for () {
fn vest_locked(_l: u32, ) -> Weight { 1_000_000_000 }
fn vest_unlocked(_l: u32, ) -> Weight { 1_000_000_000 }
fn vest_other_locked(_l: u32, ) -> Weight { 1_000_000_000 }
fn vest_other_unlocked(_l: u32, ) -> Weight { 1_000_000_000 }
fn vested_transfer(_l: u32, ) -> Weight { 1_000_000_000 }
}
pub trait Trait: frame_system::Trait {
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
@@ -76,6 +92,9 @@ pub trait Trait: frame_system::Trait {
/// The minimum amount transferred to call `vested_transfer`.
type MinVestedTransfer: Get<BalanceOf<Self>>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
const VESTING_ID: LockIdentifier = *b"vesting ";
@@ -446,6 +465,7 @@ mod tests {
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
}
impl pallet_balances::Trait for Test {
type Balance = u64;
@@ -453,6 +473,7 @@ mod tests {
type Event = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
}
parameter_types! {
pub const MinVestedTransfer: u64 = 256 * 2;
@@ -462,6 +483,7 @@ mod tests {
type Currency = Balances;
type BlockNumberToBalance = Identity;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = ();
}
type System = frame_system::Module<Test>;
type Balances = pallet_balances::Module<Test>;