Skip to content

Commit 015ceed

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 9b20bff commit 015ceed

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,32 @@ type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trai
6464
/// Just a bunch of bytes, but they should decode to a valid `Call`.
6565
pub type OpaqueCall = Vec<u8>;
6666

67+
pub trait WeightInfo {
68+
fn as_multi_threshold_1(z: u32, ) -> Weight;
69+
fn as_multi_create(s: u32, z: u32, ) -> Weight;
70+
fn as_multi_create_store(s: u32, z: u32, ) -> Weight;
71+
fn as_multi_approve(s: u32, z: u32, ) -> Weight;
72+
fn as_multi_complete(s: u32, z: u32, ) -> Weight;
73+
fn approve_as_multi_create(s: u32, z: u32, ) -> Weight;
74+
fn approve_as_multi_approve(s: u32, z: u32, ) -> Weight;
75+
fn approve_as_multi_complete(s: u32, z: u32, ) -> Weight;
76+
fn cancel_as_multi(s: u32, z: u32, ) -> Weight;
77+
fn cancel_as_multi_store(s: u32, z: u32, ) -> Weight;
78+
}
79+
80+
impl WeightInfo for () {
81+
fn as_multi_threshold_1(_z: u32, ) -> Weight { 1_000_000_000 }
82+
fn as_multi_create(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
83+
fn as_multi_create_store(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
84+
fn as_multi_approve(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
85+
fn as_multi_complete(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
86+
fn approve_as_multi_create(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
87+
fn approve_as_multi_approve(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
88+
fn approve_as_multi_complete(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
89+
fn cancel_as_multi(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
90+
fn cancel_as_multi_store(_s: u32, _z: u32, ) -> Weight { 1_000_000_000 }
91+
}
92+
6793
/// Configuration trait.
6894
pub trait Trait: frame_system::Trait {
6995
/// The overarching event type.
@@ -91,6 +117,9 @@ pub trait Trait: frame_system::Trait {
91117

92118
/// The maximum amount of signatories allowed in the multisig.
93119
type MaxSignatories: Get<u16>;
120+
121+
/// Weight information for extrinsics in this pallet.
122+
type WeightInfo: WeightInfo;
94123
}
95124

96125
/// A global extrinsic index, formed as the extrinsic index within a block, together with that

src/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ impl frame_system::Trait for Test {
8484
type AccountData = pallet_balances::AccountData<u64>;
8585
type OnNewAccount = ();
8686
type OnKilledAccount = ();
87+
type SystemWeightInfo = ();
8788
}
8889
parameter_types! {
8990
pub const ExistentialDeposit: u64 = 1;
@@ -94,6 +95,7 @@ impl pallet_balances::Trait for Test {
9495
type DustRemoval = ();
9596
type ExistentialDeposit = ExistentialDeposit;
9697
type AccountStore = System;
98+
type WeightInfo = ();
9799
}
98100
parameter_types! {
99101
pub const DepositBase: u64 = 1;
@@ -118,6 +120,7 @@ impl Trait for Test {
118120
type DepositBase = DepositBase;
119121
type DepositFactor = DepositFactor;
120122
type MaxSignatories = MaxSignatories;
123+
type WeightInfo = ();
121124
}
122125
type System = frame_system::Module<Test>;
123126
type Balances = pallet_balances::Module<Test>;

0 commit comments

Comments
 (0)