Skip to content

Commit 79d519e

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 2e8e99f commit 79d519e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/lib.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,30 @@ pub type MemberCount = u32;
7676
/// + This pallet assumes that dependents keep to the limit without enforcing it.
7777
pub const MAX_MEMBERS: MemberCount = 100;
7878

79+
pub trait WeightInfo {
80+
fn set_members(m: u32, n: u32, p: u32, ) -> Weight;
81+
fn execute(m: u32, b: u32, ) -> Weight;
82+
fn propose_execute(m: u32, b: u32, ) -> Weight;
83+
fn propose_proposed(m: u32, p: u32, b: u32, ) -> Weight;
84+
fn vote(m: u32, ) -> Weight;
85+
fn close_early_disapproved(m: u32, p: u32, b: u32, ) -> Weight;
86+
fn close_early_approved(m: u32, p: u32, b: u32, ) -> Weight;
87+
fn close_disapproved(m: u32, p: u32, b: u32, ) -> Weight;
88+
fn close_approved(m: u32, p: u32, b: u32, ) -> Weight;
89+
}
90+
91+
impl WeightInfo for () {
92+
fn set_members(_m: u32, _n: u32, _p: u32, ) -> Weight { 1_000_000_000 }
93+
fn execute(_m: u32, _b: u32, ) -> Weight { 1_000_000_000 }
94+
fn propose_execute(_m: u32, _b: u32, ) -> Weight { 1_000_000_000 }
95+
fn propose_proposed(_m: u32, _p: u32, _b: u32, ) -> Weight { 1_000_000_000 }
96+
fn vote(_m: u32, ) -> Weight { 1_000_000_000 }
97+
fn close_early_disapproved(_m: u32, _p: u32, _b: u32, ) -> Weight { 1_000_000_000 }
98+
fn close_early_approved(_m: u32, _p: u32, _b: u32, ) -> Weight { 1_000_000_000 }
99+
fn close_disapproved(_m: u32, _p: u32, _b: u32, ) -> Weight { 1_000_000_000 }
100+
fn close_approved(_m: u32, _p: u32, _b: u32, ) -> Weight { 1_000_000_000 }
101+
}
102+
79103
pub trait Trait<I: Instance=DefaultInstance>: frame_system::Trait {
80104
/// The outer origin type.
81105
type Origin: From<RawOrigin<Self::AccountId, I>>;
@@ -94,6 +118,9 @@ pub trait Trait<I: Instance=DefaultInstance>: frame_system::Trait {
94118

95119
/// Maximum number of proposals allowed to be active in parallel.
96120
type MaxProposals: Get<u32>;
121+
122+
/// Weight information for extrinsics in this pallet.
123+
type WeightInfo: WeightInfo;
97124
}
98125

99126
/// Origin for the collective module.
@@ -1039,20 +1066,23 @@ mod tests {
10391066
type AccountData = ();
10401067
type OnNewAccount = ();
10411068
type OnKilledAccount = ();
1069+
type SystemWeightInfo = ();
10421070
}
10431071
impl Trait<Instance1> for Test {
10441072
type Origin = Origin;
10451073
type Proposal = Call;
10461074
type Event = Event;
10471075
type MotionDuration = MotionDuration;
10481076
type MaxProposals = MaxProposals;
1077+
type WeightInfo = ();
10491078
}
10501079
impl Trait for Test {
10511080
type Origin = Origin;
10521081
type Proposal = Call;
10531082
type Event = Event;
10541083
type MotionDuration = MotionDuration;
10551084
type MaxProposals = MaxProposals;
1085+
type WeightInfo = ();
10561086
}
10571087

10581088
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;

0 commit comments

Comments
 (0)