Sfoglia il codice sorgente

runtime: bounty: Update benchmarks.

Shamil Gadelshin 4 anni fa
parent
commit
27c974cd4c

+ 5 - 0
Cargo.lock

@@ -3744,6 +3744,11 @@ dependencies = [
  "frame-system",
  "pallet-balances",
  "pallet-common",
+ "pallet-council",
+ "pallet-membership",
+ "pallet-referendum",
+ "pallet-staking-handler",
+ "pallet-timestamp",
  "parity-scale-codec",
  "serde",
  "sp-arithmetic",

+ 10 - 1
runtime-modules/bounty/Cargo.toml

@@ -17,17 +17,26 @@ sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://
 
 # Benchmarking
 frame-benchmarking = { package = 'frame-benchmarking', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca', optional = true}
+council = { package = 'pallet-council', default-features = false, path = '../council'}
+referendum = { package = 'pallet-referendum', default-features = false, path = '../referendum'}
+membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
 
 [dev-dependencies]
+pallet-timestamp = { package = 'pallet-timestamp', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-io = { package = 'sp-io', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-core = { package = 'sp-core', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
 sp-runtime = { package = 'sp-runtime', default-features = false, git = 'https://github.com/paritytech/substrate.git', rev = 'a200cdb93c6af5763b9c7bf313fa708764ac88ca'}
+membership = { package = 'pallet-membership', default-features = false, path = '../membership'}
+council = { package = 'pallet-council', default-features = false, path = '../council'}
+staking-handler = { package = 'pallet-staking-handler', default-features = false, path = '../staking-handler'}
 
 [features]
 default = ['std']
 runtime-benchmarks = [
 	"frame-benchmarking",
-	"sp-runtime/runtime-benchmarks"
+	"sp-runtime/runtime-benchmarks",
+	"council/runtime-benchmarks",
+	"membership/runtime-benchmarks"
 ]
 std = [
 	'serde',

+ 142 - 10
runtime-modules/bounty/src/benchmarking.rs

@@ -1,15 +1,22 @@
 #![cfg(feature = "runtime-benchmarks")]
 
-use frame_benchmarking::benchmarks;
+use frame_benchmarking::{account, benchmarks};
+use frame_support::sp_runtime::traits::Bounded;
 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;
+use sp_runtime::traits::SaturatedConversion;
 use sp_std::boxed::Box;
 use sp_std::vec;
 use sp_std::vec::Vec;
 
-use crate::{Bounties, BountyCreationParameters, Call, Event, Module, Trait};
+use balances::Module as Balances;
+use common::council::CouncilBudgetManager;
+use membership::Module as Membership;
+
+use crate::{BalanceOf, Bounties, BountyCreationParameters, Call, Event, Module, Trait};
 
 fn assert_last_event<T: Trait>(generic_event: <T as Trait>::Event) {
     let events = System::<T>::events();
@@ -19,22 +26,75 @@ fn assert_last_event<T: Trait>(generic_event: <T as Trait>::Event) {
     assert_eq!(event, &system_event);
 }
 
+fn get_byte(num: u32, byte_number: u8) -> u8 {
+    ((num & (0xff << (8 * byte_number))) >> 8 * byte_number) as u8
+}
+
+// Method to generate a distintic valid handle
+// for a membership. For each index.
+fn handle_from_id<T: Trait + membership::Trait>(id: u32) -> Vec<u8> {
+    let mut handle = vec![];
+
+    for i in 0..4 {
+        handle.push(get_byte(id, i));
+    }
+
+    handle
+}
+
+fn member_funded_account<T: Trait + membership::Trait>(
+    name: &'static str,
+    id: u32,
+) -> (T::AccountId, T::MemberId) {
+    let account_id = account::<T::AccountId>(name, id, SEED);
+    let handle = handle_from_id::<T>(id);
+
+    // Give balance for buying membership
+    let _ = Balances::<T>::make_free_balance_be(&account_id, T::Balance::max_value());
+
+    let params = membership::BuyMembershipParameters {
+        root_account: account_id.clone(),
+        controller_account: account_id.clone(),
+        name: None,
+        handle: Some(handle),
+        avatar_uri: None,
+        about: None,
+        referrer_id: None,
+    };
+
+    Membership::<T>::buy_membership(RawOrigin::Signed(account_id.clone()).into(), params).unwrap();
+
+    let _ = Balances::<T>::make_free_balance_be(&account_id, T::Balance::max_value());
+
+    (account_id, T::MemberId::from(id.saturated_into()))
+}
+
 const MAX_BYTES: u32 = 50000;
+const SEED: u32 = 0;
 
 benchmarks! {
+    where_clause {
+        where T: council::Trait,
+              T: balances::Trait,
+              T: membership::Trait,
+    }
     _{ }
 
-    create_bounty {
+    create_bounty_by_council {
         let i in 1 .. MAX_BYTES;
         let metadata = vec![0u8].repeat(i as usize);
+        let cherry: BalanceOf<T> = 100.into();
+
+        T::CouncilBudgetManager::set_budget(cherry);
 
         let params = BountyCreationParameters::<T>{
             work_period: One::one(),
             judging_period: One::one(),
+            cherry,
             ..Default::default()
         };
 
-    }: _ (RawOrigin::Root, params.clone(), metadata)
+    }: create_bounty (RawOrigin::Root, params.clone(), metadata)
     verify {
         let bounty_id: T::BountyId = 1u32.into();
 
@@ -42,10 +102,40 @@ benchmarks! {
         assert_last_event::<T>(Event::<T>::BountyCreated(bounty_id).into());
     }
 
-    cancel_bounty {
+    create_bounty_by_member {
+        let i in 1 .. MAX_BYTES;
+        let metadata = vec![0u8].repeat(i as usize);
+        let cherry: BalanceOf<T> = 100.into();
+
+        let (account_id, member_id) = member_funded_account::<T>("member1", 0);
+
+        T::CouncilBudgetManager::set_budget(cherry);
+
         let params = BountyCreationParameters::<T>{
             work_period: One::one(),
             judging_period: One::one(),
+            cherry,
+            creator_member_id: Some(member_id),
+            ..Default::default()
+        };
+
+    }: create_bounty (RawOrigin::Signed(account_id), params.clone(), metadata)
+    verify {
+        let bounty_id: T::BountyId = 1u32.into();
+
+        assert!(Bounties::<T>::contains_key(bounty_id));
+        assert_last_event::<T>(Event::<T>::BountyCreated(bounty_id).into());
+    }
+
+    cancel_bounty_by_council {
+        let cherry: BalanceOf<T> = 100.into();
+
+        T::CouncilBudgetManager::set_budget(cherry);
+
+        let params = BountyCreationParameters::<T>{
+            work_period: One::one(),
+            judging_period: One::one(),
+            cherry,
             ..Default::default()
         };
 
@@ -53,7 +143,35 @@ benchmarks! {
 
         let bounty_id: T::BountyId = Module::<T>::bounty_count().into();
 
-    }: _ (RawOrigin::Root, None, bounty_id)
+    }: cancel_bounty(RawOrigin::Root, None, bounty_id)
+    verify {
+        assert!(!<Bounties<T>>::contains_key(&bounty_id));
+        assert_last_event::<T>(Event::<T>::BountyCanceled(bounty_id).into());
+    }
+
+    cancel_bounty_by_member {
+        let cherry: BalanceOf<T> = 100.into();
+        let (account_id, member_id) = member_funded_account::<T>("member1", 0);
+
+        T::CouncilBudgetManager::set_budget(cherry);
+
+        let params = BountyCreationParameters::<T>{
+            work_period: One::one(),
+            judging_period: One::one(),
+            cherry,
+            creator_member_id: Some(member_id),
+            ..Default::default()
+        };
+
+        Module::<T>::create_bounty(
+            RawOrigin::Signed(account_id.clone()).into(),
+            params,
+            Vec::new()
+        ).unwrap();
+
+        let bounty_id: T::BountyId = Module::<T>::bounty_count().into();
+
+    }: cancel_bounty(RawOrigin::Signed(account_id), Some(member_id), bounty_id)
     verify {
         assert!(!<Bounties<T>>::contains_key(&bounty_id));
         assert_last_event::<T>(Event::<T>::BountyCanceled(bounty_id).into());
@@ -84,16 +202,30 @@ mod tests {
     use frame_support::assert_ok;
 
     #[test]
-    fn create_bounty() {
+    fn create_bounty_by_council() {
+        build_test_externalities().execute_with(|| {
+            assert_ok!(test_benchmark_create_bounty_by_council::<Test>());
+        });
+    }
+
+    #[test]
+    fn create_bounty_by_member() {
+        build_test_externalities().execute_with(|| {
+            assert_ok!(test_benchmark_create_bounty_by_member::<Test>());
+        });
+    }
+
+    #[test]
+    fn cancel_bounty_by_council() {
         build_test_externalities().execute_with(|| {
-            assert_ok!(test_benchmark_create_bounty::<Test>());
+            assert_ok!(test_benchmark_cancel_bounty_by_council::<Test>());
         });
     }
 
     #[test]
-    fn cancel_bounty() {
+    fn cancel_bounty_by_member() {
         build_test_externalities().execute_with(|| {
-            assert_ok!(test_benchmark_cancel_bounty::<Test>());
+            assert_ok!(test_benchmark_cancel_bounty_by_member::<Test>());
         });
     }
 

+ 9 - 6
runtime-modules/bounty/src/lib.rs

@@ -1,4 +1,4 @@
-//! This pallet works with crowd funded bounties which allows a member, or the council, to crowd
+//! This pallet works with crowd funded bounties that allows a member, or the council, to crowd
 //! fund work on projects with a public benefit.
 //!
 //! A detailed description could be found [here](https://github.com/Joystream/joystream/issues/1998).
@@ -24,8 +24,10 @@ mod benchmarking;
 /// pallet_bounty WeightInfo.
 /// Note: This was auto generated through the benchmark CLI using the `--weight-trait` flag
 pub trait WeightInfo {
-    fn create_bounty(i: u32) -> Weight;
-    fn cancel_bounty() -> Weight;
+    fn create_bounty_by_council() -> Weight;
+    fn create_bounty_by_member() -> Weight;
+    fn cancel_bounty_by_member() -> Weight;
+    fn cancel_bounty_by_council() -> Weight;
     fn veto_bounty() -> Weight;
 }
 
@@ -38,7 +40,6 @@ use frame_support::{decl_error, decl_event, decl_module, decl_storage, ensure, P
 use frame_system::ensure_root;
 use sp_arithmetic::traits::Saturating;
 use sp_arithmetic::traits::Zero;
-use sp_runtime::traits::SaturatedConversion;
 use sp_std::vec::Vec;
 
 use common::council::CouncilBudgetManager;
@@ -259,7 +260,8 @@ decl_module! {
         /// - DB:
         ///    - O(1)
         /// # </weight>
-        #[weight = WeightInfoBounty::<T>::create_bounty(_metadata.len().saturated_into())]
+        #[weight = WeightInfoBounty::<T>::create_bounty_by_member()
+              .max(WeightInfoBounty::<T>::create_bounty_by_council())]
         pub fn create_bounty(origin, params: BountyCreationParameters<T>, _metadata: Vec<u8>) {
             Self::ensure_create_bounty_parameters_valid(&origin, &params)?;
 
@@ -294,7 +296,8 @@ decl_module! {
         /// - db:
         ///    - `O(1)` doesn't depend on the state or parameters
         /// # </weight>
-        #[weight = WeightInfoBounty::<T>::cancel_bounty()]
+        #[weight = WeightInfoBounty::<T>::cancel_bounty_by_member()
+              .max(WeightInfoBounty::<T>::cancel_bounty_by_council())]
         pub fn cancel_bounty(origin, creator_member_id: Option<MemberId<T>>, bounty_id: T::BountyId) {
             Self::ensure_cancel_bounty_parameters_valid(&origin, creator_member_id, bounty_id)?;
 

+ 349 - 4
runtime-modules/bounty/src/tests/mocks.rs

@@ -1,7 +1,10 @@
 #![cfg(test)]
 
-use frame_support::dispatch::DispatchError;
+use frame_support::dispatch::{DispatchError, DispatchResult};
+use frame_support::traits::{Currency, LockIdentifier};
+use frame_support::weights::Weight;
 use frame_support::{impl_outer_event, impl_outer_origin, parameter_types};
+use frame_system::{EnsureOneOf, EnsureRoot, EnsureSigned};
 use sp_core::H256;
 use sp_runtime::{
     testing::Header,
@@ -10,7 +13,7 @@ use sp_runtime::{
 };
 
 use crate::{Module, Trait};
-use frame_support::traits::Currency;
+use staking_handler::{LockComparator, StakingManager};
 
 impl_outer_origin! {
     pub enum Origin for Test {}
@@ -20,11 +23,27 @@ mod bounty {
     pub use crate::Event;
 }
 
+mod membership_mod {
+    pub use membership::Event;
+}
+
+mod council_mod {
+    pub use council::Event;
+}
+
+mod referendum_mod {
+    pub use referendum::Event;
+    pub use referendum::Instance1;
+}
+
 impl_outer_event! {
     pub enum TestEvent for Test {
         bounty<T>,
         frame_system<T>,
         balances<T>,
+        membership_mod<T>,
+        council_mod<T>,
+        referendum_mod Instance1 <T>,
     }
 }
 
@@ -99,12 +118,19 @@ impl common::council::CouncilBudgetManager<u64> for CouncilBudgetManager {
 }
 
 impl crate::WeightInfo for () {
-    fn create_bounty(_: u32) -> u64 {
+    fn create_bounty_by_member() -> u64 {
+        0
+    }
+    fn create_bounty_by_council() -> u64 {
+        0
+    }
+    fn cancel_bounty_by_member() -> u64 {
         0
     }
-    fn cancel_bounty() -> u64 {
+    fn cancel_bounty_by_council() -> u64 {
         0
     }
+
     fn veto_bounty() -> u64 {
         0
     }
@@ -130,8 +156,136 @@ impl common::origin::MemberOriginValidator<Origin, u64, u64> for () {
     }
 }
 
+parameter_types! {
+    pub const DefaultMembershipPrice: u64 = 100;
+    pub const InvitedMemberLockId: [u8; 8] = [2; 8];
+}
+
+// Weights info stub
+pub struct Weights;
+impl membership::WeightInfo for Weights {
+    fn buy_membership_without_referrer(_: u32, _: u32, _: u32, _: u32) -> Weight {
+        unimplemented!()
+    }
+    fn buy_membership_with_referrer(_: u32, _: u32, _: u32, _: 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, _: u32, _: u32, _: 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 pallet_timestamp::Trait for Test {
+    type Moment = u64;
+    type OnTimestampSet = ();
+    type MinimumPeriod = MinimumPeriod;
+    type WeightInfo = ();
+}
+
+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>;
+}
+
+impl LockComparator<<Test as balances::Trait>::Balance> for Test {
+    fn are_locks_conflicting(
+        _new_lock: &LockIdentifier,
+        _existing_locks: &[LockIdentifier],
+    ) -> bool {
+        false
+    }
+}
+
+impl common::working_group::WorkingGroupBudgetHandler<Test> for () {
+    fn get_budget() -> u64 {
+        unimplemented!()
+    }
+
+    fn set_budget(_new_value: u64) {
+        unimplemented!()
+    }
+}
+
+impl common::working_group::WorkingGroupAuthenticator<Test> for () {
+    fn ensure_worker_origin(
+        _origin: <Test as frame_system::Trait>::Origin,
+        _worker_id: &<Test as common::Trait>::ActorId,
+    ) -> DispatchResult {
+        unimplemented!();
+    }
+
+    fn ensure_leader_origin(_origin: <Test as frame_system::Trait>::Origin) -> DispatchResult {
+        unimplemented!()
+    }
+
+    fn get_leader_member_id() -> Option<<Test as common::Trait>::MemberId> {
+        unimplemented!();
+    }
+
+    fn is_leader_account_id(_account_id: &<Test as frame_system::Trait>::AccountId) -> bool {
+        unimplemented!()
+    }
+
+    fn is_worker_account_id(
+        _account_id: &<Test as frame_system::Trait>::AccountId,
+        _worker_id: &<Test as common::Trait>::ActorId,
+    ) -> bool {
+        unimplemented!()
+    }
+}
+
 parameter_types! {
     pub const ExistentialDeposit: u32 = 0;
+    pub const MinimumPeriod: u64 = 5;
 }
 
 impl balances::Trait for Test {
@@ -144,6 +298,197 @@ impl balances::Trait for Test {
     type MaxLocks = ();
 }
 
+parameter_types! {
+    pub const MinNumberOfExtraCandidates: u64 = 1;
+    pub const AnnouncingPeriodDuration: u64 = 15;
+    pub const IdlePeriodDuration: u64 = 27;
+    pub const CouncilSize: u64 = 3;
+    pub const MinCandidateStake: u64 = 11000;
+    pub const CandidacyLockId: LockIdentifier = *b"council1";
+    pub const CouncilorLockId: LockIdentifier = *b"council2";
+    pub const ElectedMemberRewardPeriod: u64 = 10;
+    pub const BudgetRefillAmount: u64 = 1000;
+    // intentionally high number that prevents side-effecting tests other than  budget refill tests
+    pub const BudgetRefillPeriod: u64 = 1000;
+}
+
+pub type ReferendumInstance = referendum::Instance1;
+
+impl council::Trait for Test {
+    type Event = TestEvent;
+
+    type Referendum = referendum::Module<Test, ReferendumInstance>;
+
+    type MinNumberOfExtraCandidates = MinNumberOfExtraCandidates;
+    type CouncilSize = CouncilSize;
+    type AnnouncingPeriodDuration = AnnouncingPeriodDuration;
+    type IdlePeriodDuration = IdlePeriodDuration;
+    type MinCandidateStake = MinCandidateStake;
+
+    type CandidacyLock = StakingManager<Self, CandidacyLockId>;
+    type CouncilorLock = StakingManager<Self, CouncilorLockId>;
+
+    type ElectedMemberRewardPeriod = ElectedMemberRewardPeriod;
+
+    type BudgetRefillPeriod = BudgetRefillPeriod;
+
+    type StakingAccountValidator = ();
+    type WeightInfo = CouncilWeightInfo;
+
+    fn new_council_elected(_: &[council::CouncilMemberOf<Self>]) {}
+
+    type MemberOriginValidator = ();
+}
+
+impl common::StakingAccountValidator<Test> for () {
+    fn is_member_staking_account(_: &u64, _: &u64) -> bool {
+        true
+    }
+}
+
+pub struct CouncilWeightInfo;
+impl council::WeightInfo for CouncilWeightInfo {
+    fn try_process_budget() -> Weight {
+        0
+    }
+    fn try_progress_stage_idle() -> Weight {
+        0
+    }
+    fn try_progress_stage_announcing_start_election(_: u32) -> Weight {
+        0
+    }
+    fn try_progress_stage_announcing_restart() -> Weight {
+        0
+    }
+    fn announce_candidacy() -> Weight {
+        0
+    }
+    fn release_candidacy_stake() -> Weight {
+        0
+    }
+    fn set_candidacy_note(_: u32) -> Weight {
+        0
+    }
+    fn withdraw_candidacy() -> Weight {
+        0
+    }
+    fn set_budget() -> Weight {
+        0
+    }
+    fn plan_budget_refill() -> Weight {
+        0
+    }
+    fn set_budget_increment() -> Weight {
+        0
+    }
+    fn set_councilor_reward() -> Weight {
+        0
+    }
+    fn funding_request(_: u32) -> Weight {
+        0
+    }
+}
+
+parameter_types! {
+    pub const VoteStageDuration: u64 = 19;
+    pub const RevealStageDuration: u64 = 23;
+    pub const MinimumVotingStake: u64 = 10000;
+    pub const MaxSaltLength: u64 = 32; // use some multiple of 8 for ez testing
+    pub const VotingLockId: LockIdentifier = *b"referend";
+    pub const MaxWinnerTargetCount: u64 = 10;
+}
+
+impl referendum::Trait<ReferendumInstance> for Test {
+    type Event = TestEvent;
+
+    type MaxSaltLength = MaxSaltLength;
+
+    type StakingHandler = staking_handler::StakingManager<Self, VotingLockId>;
+    type ManagerOrigin =
+        EnsureOneOf<Self::AccountId, EnsureSigned<Self::AccountId>, EnsureRoot<Self::AccountId>>;
+
+    type VotePower = u64;
+
+    type VoteStageDuration = VoteStageDuration;
+    type RevealStageDuration = RevealStageDuration;
+
+    type MinimumStake = MinimumVotingStake;
+
+    type WeightInfo = ReferendumWeightInfo;
+
+    type MaxWinnerTargetCount = MaxWinnerTargetCount;
+
+    fn calculate_vote_power(
+        _: &<Self as frame_system::Trait>::AccountId,
+        _: &Self::Balance,
+    ) -> Self::VotePower {
+        1
+    }
+
+    fn can_unlock_vote_stake(
+        _: &referendum::CastVote<Self::Hash, Self::Balance, Self::MemberId>,
+    ) -> bool {
+        true
+    }
+
+    fn process_results(winners: &[referendum::OptionResult<Self::MemberId, Self::VotePower>]) {
+        let tmp_winners: Vec<referendum::OptionResult<Self::MemberId, Self::VotePower>> = winners
+            .iter()
+            .map(|item| referendum::OptionResult {
+                option_id: item.option_id,
+                vote_power: item.vote_power.into(),
+            })
+            .collect();
+        <council::Module<Test> as council::ReferendumConnection<Test>>::recieve_referendum_results(
+            tmp_winners.as_slice(),
+        );
+    }
+
+    fn is_valid_option_id(option_index: &u64) -> bool {
+        <council::Module<Test> as council::ReferendumConnection<Test>>::is_valid_candidate_id(
+            option_index,
+        )
+    }
+
+    fn get_option_power(option_id: &u64) -> Self::VotePower {
+        <council::Module<Test> as council::ReferendumConnection<Test>>::get_option_power(option_id)
+    }
+
+    fn increase_option_power(option_id: &u64, amount: &Self::VotePower) {
+        <council::Module<Test> as council::ReferendumConnection<Test>>::increase_option_power(
+            option_id, amount,
+        );
+    }
+}
+
+pub struct ReferendumWeightInfo;
+impl referendum::WeightInfo for ReferendumWeightInfo {
+    fn on_initialize_revealing(_: u32) -> Weight {
+        0
+    }
+    fn on_initialize_voting() -> Weight {
+        0
+    }
+    fn vote() -> Weight {
+        0
+    }
+    fn reveal_vote_space_for_new_winner(_: u32) -> Weight {
+        0
+    }
+    fn reveal_vote_space_not_in_winners(_: u32) -> Weight {
+        0
+    }
+    fn reveal_vote_space_replace_last_winner(_: u32) -> Weight {
+        0
+    }
+    fn reveal_vote_already_existing(_: u32) -> Weight {
+        0
+    }
+    fn release_vote_stake() -> Weight {
+        0
+    }
+}
+
 pub fn build_test_externalities() -> sp_io::TestExternalities {
     let t = frame_system::GenesisConfig::default()
         .build_storage::<Test>()

+ 17 - 6
runtime/src/weights/bounty.rs

@@ -7,19 +7,30 @@ use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
 
 pub struct WeightInfo;
 impl bounty::WeightInfo for WeightInfo {
-    fn create_bounty(i: u32) -> Weight {
-        (199_304_000 as Weight)
-            .saturating_add((1_000 as Weight).saturating_mul(i as Weight))
+    // WARNING! Some components were not used: ["i"]
+    fn create_bounty_by_council() -> Weight {
+        (203_102_000 as Weight)
             .saturating_add(DbWeight::get().reads(2 as Weight))
             .saturating_add(DbWeight::get().writes(3 as Weight))
     }
-    fn cancel_bounty() -> Weight {
-        (196_000_000 as Weight)
+    // WARNING! Some components were not used: ["i"]
+    fn create_bounty_by_member() -> Weight {
+        (461_209_000 as Weight)
+            .saturating_add(DbWeight::get().reads(3 as Weight))
+            .saturating_add(DbWeight::get().writes(3 as Weight))
+    }
+    fn cancel_bounty_by_council() -> Weight {
+        (183_000_000 as Weight)
             .saturating_add(DbWeight::get().reads(1 as Weight))
             .saturating_add(DbWeight::get().writes(1 as Weight))
     }
+    fn cancel_bounty_by_member() -> Weight {
+        (275_000_000 as Weight)
+            .saturating_add(DbWeight::get().reads(2 as Weight))
+            .saturating_add(DbWeight::get().writes(1 as Weight))
+    }
     fn veto_bounty() -> Weight {
-        (212_000_000 as Weight)
+        (173_000_000 as Weight)
             .saturating_add(DbWeight::get().reads(1 as Weight))
             .saturating_add(DbWeight::get().writes(1 as Weight))
     }