Browse Source

Membership benchmarking: major mock runtimes upgrade

iorveth 4 years ago
parent
commit
f18aa3884d

+ 72 - 3
runtime-modules/council/src/mock.rs

@@ -278,7 +278,7 @@ impl referendum::Trait<ReferendumInstance> for Runtime {
     type RevealStageDuration = RevealStageDuration;
 
     type MinimumStake = MinimumVotingStake;
-    type WeightInfo = ReferendumWeightInfo;
+    type WeightInfo = Weights;
 
     type MaxWinnerTargetCount = MaxWinnerTargetCount;
 
@@ -335,8 +335,9 @@ impl referendum::Trait<ReferendumInstance> for Runtime {
     }
 }
 
-pub struct ReferendumWeightInfo;
-impl referendum::WeightInfo for ReferendumWeightInfo {
+// Weights info stub
+pub struct Weights;
+impl referendum::WeightInfo for Weights {
     fn on_initialize_revealing(_: u32) -> Weight {
         0
     }
@@ -363,6 +364,63 @@ impl referendum::WeightInfo for ReferendumWeightInfo {
     }
 }
 
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl balances::Trait for Runtime {
     type Balance = u64;
     type Event = TestEvent;
@@ -377,10 +435,21 @@ impl membership::Trait for Runtime {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Runtime> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Runtime as frame_system::Trait>::AccountId,
+        _member_id: <Runtime as common::Trait>::MemberId,
+    ) -> <Runtime as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupBudgetHandler<Runtime> for () {
     fn get_budget() -> u64 {
         unimplemented!()

+ 88 - 1
runtime-modules/forum/src/mock.rs

@@ -7,6 +7,7 @@ use sp_core::H256;
 
 use crate::{GenesisConfig, Module, Trait};
 use frame_support::traits::{LockIdentifier, OnFinalize, OnInitialize};
+use sp_std::cell::RefCell;
 use staking_handler::LockComparator;
 
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
@@ -223,11 +224,87 @@ impl working_group::WeightInfo for Weights {
     }
 }
 
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
+pub const WORKING_GROUP_BUDGET: u64 = 100;
+
+thread_local! {
+    pub static WG_BUDGET: RefCell<u64> = RefCell::new(WORKING_GROUP_BUDGET);
+}
+
+impl common::working_group::WorkingGroupBudgetHandler<Runtime> for () {
+    fn get_budget() -> u64 {
+        WG_BUDGET.with(|val| *val.borrow())
+    }
+
+    fn set_budget(new_value: u64) {
+        WG_BUDGET.with(|val| {
+            *val.borrow_mut() = new_value;
+        });
+    }
+}
+
 impl membership::Trait for Runtime {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
-    type WorkingGroup = working_group::Module<Self, ForumWorkingGroupInstance>;
+    type WorkingGroup = ();
+    type WeightInfo = Weights;
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InviteMemberLockId>;
 }
 
@@ -324,6 +401,16 @@ impl common::working_group::WorkingGroupAuthenticator<Runtime> for () {
     }
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Runtime> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Runtime as frame_system::Trait>::AccountId,
+        _member_id: <Runtime as common::Trait>::MemberId,
+    ) -> <Runtime as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl WeightInfo for () {
     fn create_category(_: u32, _: u32, _: u32) -> Weight {
         0

+ 1 - 2
runtime-modules/membership/Cargo.toml

@@ -15,10 +15,10 @@ sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://
 pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 balances = { package = 'pallet-balances', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 common = { package = 'pallet-common', default-features = false, path = '../common'}
+staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler'}
 
 # Benchmarking dependencies
 frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
-staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler', optional = true}
 
 [dev-dependencies]
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
@@ -29,7 +29,6 @@ working-group = { package = 'pallet-working-group', default-features = false, pa
 default = ['std']
 runtime-benchmarks = [
     'frame-benchmarking',
-	'staking-handler',
 ]
 std = [
 	'serde',

+ 67 - 7
runtime-modules/membership/src/benchmarking.rs

@@ -13,7 +13,7 @@ use frame_support::storage::StorageMap;
 use frame_support::traits::Currency;
 use frame_system::Module as System;
 use frame_system::{EventRecord, RawOrigin};
-use sp_arithmetic::traits::{One, Zero};
+use sp_arithmetic::traits::One;
 use sp_runtime::traits::Bounded;
 use sp_std::prelude::*;
 
@@ -161,11 +161,11 @@ benchmarks! {
             referrer_id: None,
         };
 
-        Module::<T>::buy_membership(RawOrigin::Signed(account_id.clone()).into(), params.clone());
+        Module::<T>::buy_membership(RawOrigin::Signed(account_id.clone()).into(), params.clone()).unwrap();
 
         let referral_cut: BalanceOf<T> = 1.into();
 
-        Module::<T>::set_referral_cut(RawOrigin::Root.into(), referral_cut);
+        Module::<T>::set_referral_cut(RawOrigin::Root.into(), referral_cut).unwrap();
 
         let member_id = T::MemberId::from(member_id.try_into().unwrap());
 
@@ -228,7 +228,7 @@ benchmarks! {
             referrer_id: None,
         };
 
-        Module::<T>::buy_membership(RawOrigin::Signed(account_id.clone()).into(), params.clone());
+        Module::<T>::buy_membership(RawOrigin::Signed(account_id.clone()).into(), params.clone()).unwrap();
 
         let handle_updated = handle_from_id::<T>(i + 1);
 
@@ -381,7 +381,6 @@ benchmarks! {
             root_account: first_account_id.clone(),
             controller_account: first_account_id.clone(),
             verified: false,
-            // Save the updated profile.
             invites: 0,
         };
 
@@ -390,7 +389,6 @@ benchmarks! {
             root_account: second_account_id.clone(),
             controller_account: second_account_id.clone(),
             verified: false,
-            // Save the updated profile.
             invites: 10,
         };
 
@@ -440,7 +438,6 @@ benchmarks! {
             root_account: account_id.clone(),
             controller_account: account_id.clone(),
             verified: false,
-            // Save the updated profile.
             invites: 0,
         };
 
@@ -466,6 +463,50 @@ benchmarks! {
         assert_last_event::<T>(RawEvent::MembershipPriceUpdated(membership_price).into());
     }
 
+    update_profile_verification {
+
+        let member_id = 0;
+
+        let handle = handle_from_id::<T>(member_id);
+        let (account_id, member_id) = member_funded_account::<T>("member", member_id);
+
+        Module::<T>::add_staking_account_candidate(
+            RawOrigin::Signed(account_id.clone()).into(),
+            member_id.clone(),
+        )
+        .unwrap();
+        Module::<T>::confirm_staking_account(
+            RawOrigin::Signed(account_id.clone()).into(),
+            member_id.clone(),
+            account_id.clone(),
+        )
+        .unwrap();
+
+        // Set leader member id
+        let leader_id = T::WorkingGroup::insert_a_lead(0, &account_id, member_id);
+
+        let is_verified = true;
+
+        let leader_member_id = T::WorkingGroup::get_leader_member_id();
+    }: _(RawOrigin::Signed(account_id.clone()), leader_id, member_id, is_verified)
+
+    verify {
+
+        let handle_hash = T::Hashing::hash(&handle).as_ref().to_vec();
+
+        let membership: Membership<T> = MembershipObject {
+            handle_hash: handle_hash.clone(),
+            root_account: account_id.clone(),
+            controller_account: account_id.clone(),
+            verified: is_verified,
+            invites: 5,
+        };
+
+        assert_eq!(MembershipById::<T>::get(member_id), membership);
+
+        assert_last_event::<T>(RawEvent::MemberVerificationStatusUpdated(member_id, is_verified).into());
+    }
+
     set_leader_invitation_quota {
         // Set leader member id
 
@@ -473,6 +514,18 @@ benchmarks! {
 
         let (account_id, member_id) = member_funded_account::<T>("member", member_id);
 
+        Module::<T>::add_staking_account_candidate(
+            RawOrigin::Signed(account_id.clone()).into(),
+            member_id.clone(),
+        )
+        .unwrap();
+        Module::<T>::confirm_staking_account(
+            RawOrigin::Signed(account_id.clone()).into(),
+            member_id.clone(),
+            account_id.clone(),
+        )
+        .unwrap();
+
         // Set leader member id
         T::WorkingGroup::insert_a_lead(0, &account_id, member_id);
 
@@ -692,4 +745,11 @@ mod tests {
             assert_ok!(test_benchmark_remove_staking_account::<Test>());
         });
     }
+
+    #[test]
+    fn update_profile_verification() {
+        build_test_externalities().execute_with(|| {
+            assert_ok!(test_benchmark_update_profile_verification::<Test>());
+        });
+    }
 }

+ 29 - 0
runtime-modules/membership/src/lib.rs

@@ -51,6 +51,7 @@ mod tests;
 use codec::{Decode, Encode};
 use frame_support::dispatch::DispatchError;
 use frame_support::traits::{Currency, Get, WithdrawReason, WithdrawReasons};
+pub use frame_support::weights::Weight;
 use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure};
 use frame_system::{ensure_root, ensure_signed};
 use sp_arithmetic::traits::{One, Zero};
@@ -64,6 +65,31 @@ use staking_handler::StakingHandler;
 // Balance type alias
 type BalanceOf<T> = <T as balances::Trait>::Balance;
 
+type WeightInfoMembership<T> = <T as Trait>::WeightInfo;
+
+/// pallet_forum WeightInfo.
+/// Note: This was auto generated through the benchmark CLI using the `--weight-trait` flag
+pub trait WeightInfo {
+    fn buy_membership_without_referrer(i: u32) -> Weight;
+    fn buy_membership_with_referrer(i: u32) -> Weight;
+    fn update_profile(i: u32) -> Weight;
+    fn update_accounts_none() -> Weight;
+    fn update_accounts_root() -> Weight;
+    fn update_accounts_controller() -> Weight;
+    fn update_accounts_both() -> Weight;
+    fn set_referral_cut() -> Weight;
+    fn transfer_invites() -> Weight;
+    fn invite_member(i: u32) -> Weight;
+    fn set_membership_price() -> Weight;
+    fn update_profile_verification() -> Weight;
+    fn set_leader_invitation_quota() -> Weight;
+    fn set_initial_invitation_balance() -> Weight;
+    fn set_initial_invitation_count() -> Weight;
+    fn add_staking_account_candidate() -> Weight;
+    fn confirm_staking_account() -> Weight;
+    fn remove_staking_account() -> Weight;
+}
+
 pub trait Trait:
     frame_system::Trait + balances::Trait + pallet_timestamp::Trait + common::Trait
 {
@@ -87,6 +113,9 @@ pub trait Trait:
         BalanceOf<Self>,
         Self::MemberId,
     >;
+
+    /// Weight information for extrinsics in this pallet.
+    type WeightInfo: WeightInfo;
 }
 
 pub(crate) const DEFAULT_MEMBER_INVITES_COUNT: u32 = 5;

+ 60 - 2
runtime-modules/membership/src/tests/mock.rs

@@ -1,6 +1,6 @@
 #![cfg(test)]
 
-pub use crate::{GenesisConfig, Trait};
+pub use crate::{GenesisConfig, Trait, Weight, WeightInfo};
 
 pub use frame_support::traits::{Currency, LockIdentifier};
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
@@ -225,6 +225,63 @@ impl working_group::WeightInfo for Weights {
     }
 }
 
+impl WeightInfo for () {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        0
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        0
+    }
+    fn update_profile(_: u32) -> Weight {
+        0
+    }
+    fn update_accounts_none() -> Weight {
+        0
+    }
+    fn update_accounts_root() -> Weight {
+        0
+    }
+    fn update_accounts_controller() -> Weight {
+        0
+    }
+    fn update_accounts_both() -> Weight {
+        0
+    }
+    fn set_referral_cut() -> Weight {
+        0
+    }
+    fn transfer_invites() -> Weight {
+        0
+    }
+    fn invite_member(_: u32) -> Weight {
+        0
+    }
+    fn set_membership_price() -> Weight {
+        0
+    }
+    fn update_profile_verification() -> Weight {
+        0
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        0
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        0
+    }
+    fn set_initial_invitation_count() -> Weight {
+        0
+    }
+    fn add_staking_account_candidate() -> Weight {
+        0
+    }
+    fn confirm_staking_account() -> Weight {
+        0
+    }
+    fn remove_staking_account() -> Weight {
+        0
+    }
+}
+
 impl common::origin::MemberOriginValidator<Origin, u64, u64> for () {
     fn ensure_member_controller_account_origin(
         origin: Origin,
@@ -246,6 +303,7 @@ impl Trait for Test {
     type WorkingGroup = ();
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
+    type WeightInfo = ();
 }
 
 pub const WORKING_GROUP_BUDGET: u64 = 100;
@@ -275,7 +333,7 @@ impl common::working_group::WorkingGroupAuthenticator<Test> for () {
             origin.into();
 
         if let RawOrigin::Signed(_) = raw_origin.unwrap() {
-            if *worker_id == 1 {
+            if *worker_id == 1 || *worker_id == 0 {
                 Ok(())
             } else {
                 Err(working_group::Error::<Test, MembershipWorkingGroupInstance>::WorkerDoesNotExist.into())

+ 70 - 0
runtime-modules/proposals/codex/src/tests/mock.rs

@@ -49,14 +49,84 @@ impl common::Trait for Test {
     type ActorId = u64;
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl membership::Trait for Test {
     type Event = ();
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Test> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Test as frame_system::Trait>::AccountId,
+        _member_id: <Test as common::Trait>::MemberId,
+    ) -> <Test as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
     fn get_budget() -> u64 {
         unimplemented!()

+ 70 - 0
runtime-modules/proposals/discussion/src/tests/mock.rs

@@ -65,6 +65,65 @@ parameter_types! {
     pub const InvitedMemberLockId: [u8; 8] = [2; 8];
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl balances::Trait for Test {
     type Balance = u64;
     type DustRemoval = ();
@@ -84,6 +143,7 @@ impl membership::Trait for Test {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
@@ -107,6 +167,16 @@ impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
     }
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Test> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Test as frame_system::Trait>::AccountId,
+        _member_id: <Test as common::Trait>::MemberId,
+    ) -> <Test as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupAuthenticator<Test> for () {
     fn ensure_worker_origin(
         _origin: <Test as frame_system::Trait>::Origin,

+ 70 - 0
runtime-modules/proposals/engine/src/tests/mock/mod.rs

@@ -188,10 +188,80 @@ impl common::Trait for Test {
     type ActorId = u64;
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Test> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Test as frame_system::Trait>::AccountId,
+        _member_id: <Test as common::Trait>::MemberId,
+    ) -> <Test as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl membership::Trait for Test {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }

+ 70 - 0
runtime-modules/referendum/src/mock.rs

@@ -171,6 +171,65 @@ impl WeightInfo for () {
     }
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 parameter_types! {
     pub const DefaultMembershipPrice: u64 = 100;
     pub const DefaultInitialInvitationBalance: u64 = 100;
@@ -181,6 +240,7 @@ impl membership::Trait for Runtime {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
@@ -192,6 +252,16 @@ impl pallet_timestamp::Trait for Runtime {
     type WeightInfo = ();
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Runtime> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Runtime as frame_system::Trait>::AccountId,
+        _member_id: <Runtime as common::Trait>::MemberId,
+    ) -> <Runtime as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupBudgetHandler<Runtime> for () {
     fn get_budget() -> u64 {
         unimplemented!()

+ 70 - 0
runtime-modules/service-discovery/src/mock.rs

@@ -93,14 +93,84 @@ impl common::Trait for Test {
     type ActorId = u64;
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl membership::Trait for Test {
     type Event = MetaEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Test> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Test as frame_system::Trait>::AccountId,
+        _member_id: <Test as common::Trait>::MemberId,
+    ) -> <Test as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
     fn get_budget() -> u64 {
         unimplemented!()

+ 70 - 0
runtime-modules/storage/src/tests/mock.rs

@@ -243,6 +243,65 @@ impl working_group::WeightInfo for WorkingGroupWeightInfo {
     }
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl common::origin::MemberOriginValidator<Origin, u64, u64> for () {
     fn ensure_member_controller_account_origin(
         origin: Origin,
@@ -294,6 +353,7 @@ impl membership::Trait for Test {
     type Event = MetaEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = ();
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }
@@ -308,6 +368,16 @@ impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
     }
 }
 
+impl common::working_group::MembershipWorkingGroupHelper<Test> for () {
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &<Test as frame_system::Trait>::AccountId,
+        _member_id: <Test as common::Trait>::MemberId,
+    ) -> <Test as common::Trait>::ActorId {
+        unimplemented!()
+    }
+}
+
 impl common::working_group::WorkingGroupAuthenticator<Test> for () {
     fn ensure_worker_origin(
         _origin: <Test as frame_system::Trait>::Origin,

+ 13 - 0
runtime-modules/working-group/src/lib.rs

@@ -1401,3 +1401,16 @@ impl<T: Trait<I>, I: Instance> common::working_group::WorkingGroupBudgetHandler<
         Self::set_working_group_budget(new_value);
     }
 }
+
+#[cfg(not(feature = "runtime-benchmarks"))]
+impl<T: Trait<I>, I: Instance> common::working_group::MembershipWorkingGroupHelper<T>
+    for Module<T, I>
+{
+    fn insert_a_lead(
+        _opening_id: u32,
+        _caller_id: &T::AccountId,
+        _member_id: T::MemberId,
+    ) -> T::ActorId {
+        unimplemented!()
+    }
+}

+ 60 - 0
runtime-modules/working-group/src/tests/mock.rs

@@ -97,10 +97,70 @@ impl common::Trait for Test {
     type ActorId = u64;
 }
 
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_profile(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_none() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_root() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_controller() -> Weight {
+        unimplemented!()
+    }
+    fn update_accounts_both() -> Weight {
+        unimplemented!()
+    }
+    fn set_referral_cut() -> Weight {
+        unimplemented!()
+    }
+    fn transfer_invites() -> Weight {
+        unimplemented!()
+    }
+    fn invite_member(_: u32) -> Weight {
+        unimplemented!()
+    }
+    fn set_membership_price() -> Weight {
+        unimplemented!()
+    }
+    fn update_profile_verification() -> Weight {
+        unimplemented!()
+    }
+    fn set_leader_invitation_quota() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_balance() -> Weight {
+        unimplemented!()
+    }
+    fn set_initial_invitation_count() -> Weight {
+        unimplemented!()
+    }
+    fn add_staking_account_candidate() -> Weight {
+        unimplemented!()
+    }
+    fn confirm_staking_account() -> Weight {
+        unimplemented!()
+    }
+    fn remove_staking_account() -> Weight {
+        unimplemented!()
+    }
+}
+
 impl membership::Trait for Test {
     type Event = TestEvent;
     type DefaultMembershipPrice = DefaultMembershipPrice;
     type WorkingGroup = Module<Test>;
+    type WeightInfo = Weights;
     type DefaultInitialInvitationBalance = ();
     type InvitedMemberStakingHandler = staking_handler::StakingManager<Self, InvitedMemberLockId>;
 }

+ 1 - 0
runtime/src/lib.rs

@@ -612,6 +612,7 @@ impl membership::Trait for Runtime {
     type DefaultInitialInvitationBalance = DefaultInitialInvitationBalance;
     type InvitedMemberStakingHandler = InvitedMemberStakingManager;
     type WorkingGroup = MembershipWorkingGroup;
+    type WeightInfo = weights::membership::WeightInfo;
 }
 
 parameter_types! {

+ 1 - 0
runtime/src/weights/mod.rs

@@ -26,6 +26,7 @@ pub mod pallet_utility;
 // Joystream pallets
 pub mod council;
 pub mod forum;
+pub mod membership;
 pub mod pallet_constitution;
 pub mod proposals_discussion;
 pub mod proposals_engine;

+ 7 - 6
scripts/generate-weights.sh

@@ -45,10 +45,11 @@ benchmark() {
 # benchmark pallet_im_online
 
 # Joystrem benchmarks
-benchmark proposals_discussion
-benchmark proposals_engine
-benchmark pallet_constitution
-benchmark working_group
-benchmark council
-benchmark referendum
+# benchmark proposals_discussion
+# benchmark proposals_engine
+# benchmark pallet_constitution
+# benchmark working_group
+# benchmark council
+# benchmark referendum
+# benchmark forum
 benchmark membership