Skip to content

Commit 8bf7ef6

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 ce97a0d commit 8bf7ef6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ use sp_timestamp::{
115115
OnTimestampSet,
116116
};
117117

118+
pub trait WeightInfo {
119+
fn set(t: u32, ) -> Weight;
120+
fn on_finalize(t: u32, ) -> Weight;
121+
}
122+
123+
impl WeightInfo for () {
124+
fn set(_t: u32, ) -> Weight { 1_000_000_000 }
125+
fn on_finalize(_t: u32, ) -> Weight { 1_000_000_000 }
126+
}
127+
118128
/// The module configuration trait
119129
pub trait Trait: frame_system::Trait {
120130
/// Type used for expressing timestamp.
@@ -129,6 +139,9 @@ pub trait Trait: frame_system::Trait {
129139
/// work with this to determine a sensible block time. e.g. For Aura, it will be double this
130140
/// period on default settings.
131141
type MinimumPeriod: Get<Self::Moment>;
142+
143+
/// Weight information for extrinsics in this pallet.
144+
type WeightInfo: WeightInfo;
132145
}
133146

134147
decl_module! {
@@ -338,6 +351,7 @@ mod tests {
338351
type AccountData = ();
339352
type OnNewAccount = ();
340353
type OnKilledAccount = ();
354+
type SystemWeightInfo = ();
341355
}
342356
parameter_types! {
343357
pub const MinimumPeriod: u64 = 5;
@@ -346,6 +360,7 @@ mod tests {
346360
type Moment = u64;
347361
type OnTimestampSet = ();
348362
type MinimumPeriod = MinimumPeriod;
363+
type WeightInfo = ();
349364
}
350365
type Timestamp = Module<Test>;
351366

0 commit comments

Comments
 (0)