Skip to content

Commit 4faf933

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 d51d152 commit 4faf933

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,34 @@ mod benchmarking;
8585
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
8686
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
8787

88+
pub trait WeightInfo {
89+
fn add_registrar(r: u32, ) -> Weight;
90+
fn set_identity(r: u32, x: u32, ) -> Weight;
91+
fn set_subs(p: u32, s: u32, ) -> Weight;
92+
fn clear_identity(r: u32, s: u32, x: u32, ) -> Weight;
93+
fn request_judgement(r: u32, x: u32, ) -> Weight;
94+
fn cancel_request(r: u32, x: u32, ) -> Weight;
95+
fn set_fee(r: u32, ) -> Weight;
96+
fn set_account_id(r: u32, ) -> Weight;
97+
fn set_fields(r: u32, ) -> Weight;
98+
fn provide_judgement(r: u32, x: u32, ) -> Weight;
99+
fn kill_identity(r: u32, s: u32, x: u32, ) -> Weight;
100+
}
101+
102+
impl WeightInfo for () {
103+
fn add_registrar(_r: u32, ) -> Weight { 1_000_000_000 }
104+
fn set_identity(_r: u32, _x: u32, ) -> Weight { 1_000_000_000 }
105+
fn set_subs(_p: u32, _s: u32, ) -> Weight { 1_000_000_000 }
106+
fn clear_identity(_r: u32, _s: u32, _x: u32, ) -> Weight { 1_000_000_000 }
107+
fn request_judgement(_r: u32, _x: u32, ) -> Weight { 1_000_000_000 }
108+
fn cancel_request(_r: u32, _x: u32, ) -> Weight { 1_000_000_000 }
109+
fn set_fee(_r: u32, ) -> Weight { 1_000_000_000 }
110+
fn set_account_id(_r: u32, ) -> Weight { 1_000_000_000 }
111+
fn set_fields(_r: u32, ) -> Weight { 1_000_000_000 }
112+
fn provide_judgement(_r: u32, _x: u32, ) -> Weight { 1_000_000_000 }
113+
fn kill_identity(_r: u32, _s: u32, _x: u32, ) -> Weight { 1_000_000_000 }
114+
}
115+
88116
pub trait Trait: frame_system::Trait {
89117
/// The overarching event type.
90118
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
@@ -122,6 +150,9 @@ pub trait Trait: frame_system::Trait {
122150

123151
/// The origin which may add or remove registrars. Root can always do this.
124152
type RegistrarOrigin: EnsureOrigin<Self::Origin>;
153+
154+
/// Weight information for extrinsics in this pallet.
155+
type WeightInfo: WeightInfo;
125156
}
126157

127158
/// Either underlying data blob if it is at most 32 bytes, or a hash of it. If the data is greater
@@ -1198,6 +1229,7 @@ mod tests {
11981229
type AccountData = pallet_balances::AccountData<u64>;
11991230
type OnNewAccount = ();
12001231
type OnKilledAccount = ();
1232+
type SystemWeightInfo = ();
12011233
}
12021234
parameter_types! {
12031235
pub const ExistentialDeposit: u64 = 1;
@@ -1208,6 +1240,7 @@ mod tests {
12081240
type DustRemoval = ();
12091241
type ExistentialDeposit = ExistentialDeposit;
12101242
type AccountStore = System;
1243+
type WeightInfo = ();
12111244
}
12121245
parameter_types! {
12131246
pub const BasicDeposit: u64 = 10;
@@ -1243,6 +1276,7 @@ mod tests {
12431276
type MaxRegistrars = MaxRegistrars;
12441277
type RegistrarOrigin = EnsureOneOrRoot;
12451278
type ForceOrigin = EnsureTwoOrRoot;
1279+
type WeightInfo = ();
12461280
}
12471281
type System = frame_system::Module<Test>;
12481282
type Balances = pallet_balances::Module<Test>;

0 commit comments

Comments
 (0)