Skip to content

Commit 350add1

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 b000d4a commit 350add1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,18 @@ pub struct Heartbeat<BlockNumber>
226226
pub validators_len: u32,
227227
}
228228

229+
pub trait WeightInfo {
230+
fn heartbeat(k: u32, e: u32, ) -> Weight;
231+
fn validate_unsigned(k: u32, e: u32, ) -> Weight;
232+
fn validate_unsigned_and_then_heartbeat(k: u32, e: u32, ) -> Weight;
233+
}
234+
235+
impl WeightInfo for () {
236+
fn heartbeat(_k: u32, _e: u32, ) -> Weight { 1_000_000_000 }
237+
fn validate_unsigned(_k: u32, _e: u32, ) -> Weight { 1_000_000_000 }
238+
fn validate_unsigned_and_then_heartbeat(_k: u32, _e: u32, ) -> Weight { 1_000_000_000 }
239+
}
240+
229241
pub trait Trait: SendTransactionTypes<Call<Self>> + pallet_session::historical::Trait {
230242
/// The identifier type for an authority.
231243
type AuthorityId: Member + Parameter + RuntimeAppPublic + Default + Ord;
@@ -254,6 +266,9 @@ pub trait Trait: SendTransactionTypes<Call<Self>> + pallet_session::historical::
254266
/// This is exposed so that it can be tuned for particular runtime, when
255267
/// multiple pallets send unsigned transactions.
256268
type UnsignedPriority: Get<TransactionPriority>;
269+
270+
/// Weight information for extrinsics in this pallet.
271+
type WeightInfo: WeightInfo;
257272
}
258273

259274
decl_event!(

src/mock.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl frame_system::Trait for Runtime {
134134
type AccountData = ();
135135
type OnNewAccount = ();
136136
type OnKilledAccount = ();
137+
type SystemWeightInfo = ();
137138
}
138139

139140
parameter_types! {
@@ -155,6 +156,7 @@ impl pallet_session::Trait for Runtime {
155156
type Event = ();
156157
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
157158
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
159+
type WeightInfo = ();
158160
}
159161

160162
impl pallet_session::historical::Trait for Runtime {
@@ -183,6 +185,7 @@ impl Trait for Runtime {
183185
type ReportUnresponsiveness = OffenceHandler;
184186
type SessionDuration = Period;
185187
type UnsignedPriority = UnsignedPriority;
188+
type WeightInfo = ();
186189
}
187190

188191
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Runtime where

0 commit comments

Comments
 (0)