Skip to content

Commit 5fddc85

Browse files
authored
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
1 parent db5affe commit 5fddc85

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/lib.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use frame_support::{
4343
decl_module, decl_event, decl_error, decl_storage, Parameter, ensure, traits::{
4444
Get, ReservableCurrency, Currency, InstanceFilter,
4545
OriginTrait, IsType,
46-
}, weights::{GetDispatchInfo, constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS}},
46+
}, weights::{Weight, GetDispatchInfo, constants::{WEIGHT_PER_MICROS, WEIGHT_PER_NANOS}},
4747
dispatch::{PostDispatchInfo, IsSubType},
4848
};
4949
use frame_system::{self as system, ensure_signed};
@@ -53,6 +53,24 @@ mod benchmarking;
5353

5454
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
5555

56+
pub trait WeightInfo {
57+
fn proxy(p: u32, ) -> Weight;
58+
fn add_proxy(p: u32, ) -> Weight;
59+
fn remove_proxy(p: u32, ) -> Weight;
60+
fn remove_proxies(p: u32, ) -> Weight;
61+
fn anonymous(p: u32, ) -> Weight;
62+
fn kill_anonymous(p: u32, ) -> Weight;
63+
}
64+
65+
impl WeightInfo for () {
66+
fn proxy(_p: u32, ) -> Weight { 1_000_000_000 }
67+
fn add_proxy(_p: u32, ) -> Weight { 1_000_000_000 }
68+
fn remove_proxy(_p: u32, ) -> Weight { 1_000_000_000 }
69+
fn remove_proxies(_p: u32, ) -> Weight { 1_000_000_000 }
70+
fn anonymous(_p: u32, ) -> Weight { 1_000_000_000 }
71+
fn kill_anonymous(_p: u32, ) -> Weight { 1_000_000_000 }
72+
}
73+
5674
/// Configuration trait.
5775
pub trait Trait: frame_system::Trait {
5876
/// The overarching event type.
@@ -87,6 +105,9 @@ pub trait Trait: frame_system::Trait {
87105

88106
/// The maximum amount of proxies allowed for a single account.
89107
type MaxProxies: Get<u16>;
108+
109+
/// Weight information for extrinsics in this pallet.
110+
type WeightInfo: WeightInfo;
90111
}
91112

92113
decl_storage! {

src/tests.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ impl frame_system::Trait for Test {
8686
type AccountData = pallet_balances::AccountData<u64>;
8787
type OnNewAccount = ();
8888
type OnKilledAccount = ();
89+
type SystemWeightInfo = ();
8990
}
9091
parameter_types! {
9192
pub const ExistentialDeposit: u64 = 1;
@@ -96,10 +97,12 @@ impl pallet_balances::Trait for Test {
9697
type DustRemoval = ();
9798
type ExistentialDeposit = ExistentialDeposit;
9899
type AccountStore = System;
100+
type WeightInfo = ();
99101
}
100102
impl pallet_utility::Trait for Test {
101103
type Event = TestEvent;
102104
type Call = Call;
105+
type WeightInfo = ();
103106
}
104107
parameter_types! {
105108
pub const ProxyDepositBase: u64 = 1;
@@ -144,6 +147,7 @@ impl Trait for Test {
144147
type ProxyDepositBase = ProxyDepositBase;
145148
type ProxyDepositFactor = ProxyDepositFactor;
146149
type MaxProxies = MaxProxies;
150+
type WeightInfo = ();
147151
}
148152

149153
type System = frame_system::Module<Test>;

0 commit comments

Comments
 (0)