From bb091a266ef5f59b1a965209c3dafdbd5c817581 Mon Sep 17 00:00:00 2001 From: muharem Date: Wed, 3 Aug 2022 16:25:40 +0200 Subject: [PATCH 01/15] Alliance pallet: retirement notice --- bin/node/runtime/src/lib.rs | 6 ++- frame/alliance/README.md | 1 + frame/alliance/src/benchmarking.rs | 31 ++++++++++--- frame/alliance/src/lib.rs | 71 ++++++++++++++++++++---------- frame/alliance/src/mock.rs | 10 ++--- frame/alliance/src/tests.rs | 70 ++++++++++++++++++++--------- 6 files changed, 134 insertions(+), 55 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 2ac1e6444f119..c8b6b1aaa79f1 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1514,8 +1514,10 @@ impl pallet_state_trie_migration::Config for Runtime { type WeightInfo = (); } +const ALLIANCE_MOTION_DURATION: BlockNumber = 5 * DAYS; + parameter_types! { - pub const AllianceMotionDuration: BlockNumber = 5 * DAYS; + pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION; pub const AllianceMaxProposals: u32 = 100; pub const AllianceMaxMembers: u32 = 100; } @@ -1537,6 +1539,7 @@ parameter_types! { pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFounders::get(); pub const MaxAllies: u32 = 100; pub const AllyDeposit: Balance = 10 * DOLLARS; + pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION + (1 * DAYS); } impl pallet_alliance::Config for Runtime { @@ -1573,6 +1576,7 @@ impl pallet_alliance::Config for Runtime { type MaxMembersCount = AllianceMaxMembers; type AllyDeposit = AllyDeposit; type WeightInfo = pallet_alliance::weights::SubstrateWeight; + type RetirementPeriod = RetirementPeriod; } construct_runtime!( diff --git a/frame/alliance/README.md b/frame/alliance/README.md index f0900c84cbd85..9e9b9c9f83bde 100644 --- a/frame/alliance/README.md +++ b/frame/alliance/README.md @@ -43,6 +43,7 @@ to update the Alliance's rule and make announcements. #### For Members (All) +- `retirement_notice` - Give a retirement notice and start a retirement period required to pass in order to retire. - `retire` - Retire from the Alliance and release the caller's deposit. #### For Members (Founders/Fellows) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 527c35b58a5d8..3bff9137221d5 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -691,12 +691,37 @@ benchmarks_instance_pallet! { assert_last_event::(Event::AllyElevated { ally: ally1 }.into()); } + retirement_notice { + set_members::(); + let fellow2 = fellow::(2); + + assert!(Alliance::::is_fellow(&fellow2)); + }: _(SystemOrigin::Signed(fellow2.clone())) + verify { + assert!(Alliance::::is_member_of(&fellow2, MemberRole::Retiring)); + + assert_eq!( + RetiringMembers::::get(&fellow2), + Some(System::::block_number() + T::RetirementPeriod::get()) + ); + assert_last_event::( + Event::MemberRetirementPeriodStarted {member: fellow2}.into() + ); + } + retire { set_members::(); let fellow2 = fellow::(2); assert!(Alliance::::is_fellow(&fellow2)); - assert!(!Alliance::::is_up_for_kicking(&fellow2)); + + assert_eq!( + Alliance::::retirement_notice( + SystemOrigin::Signed(fellow2.clone()).into() + ), + Ok(()) + ); + System::::set_block_number(System::::block_number() + T::RetirementPeriod::get()); assert_eq!(DepositOf::::get(&fellow2), Some(T::AllyDeposit::get())); }: _(SystemOrigin::Signed(fellow2.clone())) @@ -713,11 +738,7 @@ benchmarks_instance_pallet! { set_members::(); let fellow2 = fellow::(2); - UpForKicking::::insert(&fellow2, true); - assert!(Alliance::::is_member_of(&fellow2, MemberRole::Fellow)); - assert!(Alliance::::is_up_for_kicking(&fellow2)); - assert_eq!(DepositOf::::get(&fellow2), Some(T::AllyDeposit::get())); let fellow2_lookup: ::Source = T::Lookup::unlookup(fellow2.clone()); diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 111ea5dc6e507..85f024260521f 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -60,6 +60,8 @@ //! //! #### For Members (All) //! +//! - `retirement_notice` - Give a retirement notice and start a retirement period required to pass +//! in order to retire. //! - `retire` - Retire from the Alliance and release the caller's deposit. //! //! #### For Members (Founders/Fellows) @@ -198,6 +200,7 @@ pub enum MemberRole { Founder, Fellow, Ally, + Retiring, } /// The type of item that may be deemed unscrupulous. @@ -306,6 +309,10 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + /// The period required to pass from retirement notice for a member to retire. + /// Supposed to be greater than time required to `kick_member`. + type RetirementPeriod: Get; } #[pallet::error] @@ -322,8 +329,6 @@ pub mod pallet { NotAlly, /// Account is not a founder. NotFounder, - /// This member is up for being kicked from the Alliance and cannot perform this operation. - UpForKicking, /// Account does not have voting rights. NoVotingRights, /// Account is already an elevated (fellow) member. @@ -355,6 +360,12 @@ pub mod pallet { TooManyMembers, /// Number of announcements exceeds `MaxAnnouncementsCount`. TooManyAnnouncements, + /// Account is already gave retirement notice + AlreadyRetiring, + /// Account did not give a retirement notice required to retire. + RetirementNoticeNotGiven, + /// Retirement period is not passed. + RetirementPeriodNotPassed, } #[pallet::event] @@ -380,6 +391,8 @@ pub mod pallet { }, /// An ally has been elevated to Fellow. AllyElevated { ally: T::AccountId }, + /// A member gave retirement notice and retirement period started. + MemberRetirementPeriodStarted { member: T::AccountId }, /// A member has retired with its deposit unreserved. MemberRetired { member: T::AccountId, unreserved: Option> }, /// A member has been kicked out with its deposit slashed. @@ -483,12 +496,12 @@ pub mod pallet { ValueQuery, >; - /// A set of members that are (potentially) being kicked out. They cannot retire until the - /// motion is settled. + /// A set of members who gave a retirement notice. They can retire after the end of retirement + /// period stored as a future block number. #[pallet::storage] - #[pallet::getter(fn up_for_kicking)] - pub type UpForKicking, I: 'static = ()> = - StorageMap<_, Blake2_128Concat, T::AccountId, bool, ValueQuery>; + #[pallet::getter(fn retiring_members)] + pub type RetiringMembers, I: 'static = ()> = + StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber, OptionQuery>; /// The current list of accounts deemed unscrupulous. These accounts non grata cannot submit /// candidacy. @@ -523,11 +536,6 @@ pub mod pallet { let proposor = ensure_signed(origin)?; ensure!(Self::has_voting_rights(&proposor), Error::::NoVotingRights); - if let Some(Call::kick_member { who }) = proposal.is_sub_type() { - let strike = T::Lookup::lookup(who.clone())?; - >::insert(strike, true); - } - T::ProposalProvider::propose_proposal(proposor, threshold, proposal, length_bound)?; Ok(()) } @@ -787,15 +795,39 @@ pub mod pallet { Ok(()) } + /// As a member, give a retirement notice and start a retirement period required to pass in + /// order to retire. + // TODO setup weight T::WeightInfo::retirement_notice() + #[pallet::weight(0)] + pub fn retirement_notice(origin: OriginFor) -> DispatchResult { + let who = ensure_signed(origin)?; + let role = Self::member_role_of(&who).ok_or(Error::::NotMember)?; + ensure!(!role.eq(&MemberRole::Retiring), Error::::AlreadyRetiring); + + Self::remove_member(&who, role)?; + Self::add_member(&who, MemberRole::Retiring)?; + >::insert( + &who, + frame_system::Pallet::::block_number() + T::RetirementPeriod::get(), + ); + + Self::deposit_event(Event::MemberRetirementPeriodStarted { member: who }); + Ok(()) + } + /// As a member, retire from the alliance and unreserve the deposit. #[pallet::weight(T::WeightInfo::retire())] pub fn retire(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; - // A member up for kicking cannot retire. - ensure!(!Self::is_up_for_kicking(&who), Error::::UpForKicking); + let retirement_period_end = RetiringMembers::::get(&who) + .ok_or(Error::::RetirementNoticeNotGiven)?; + ensure!( + frame_system::Pallet::::block_number() >= retirement_period_end, + Error::::RetirementPeriodNotPassed + ); - let role = Self::member_role_of(&who).ok_or(Error::::NotMember)?; - Self::remove_member(&who, role)?; + Self::remove_member(&who, MemberRole::Retiring)?; + >::remove(&who); let deposit = DepositOf::::take(&who); if let Some(deposit) = deposit { let err_amount = T::Currency::unreserve(&who, deposit); @@ -821,8 +853,6 @@ pub mod pallet { T::Slashed::on_unbalanced(T::Currency::slash_reserved(&member, deposit).0); } - >::remove(&member); - Self::deposit_event(Event::MemberKicked { member, slashed: deposit }); Ok(()) } @@ -937,11 +967,6 @@ impl, I: 'static> Pallet { founders.into() } - /// Check if an account's forced removal is up for consideration. - fn is_up_for_kicking(who: &T::AccountId) -> bool { - >::contains_key(&who) - } - /// Add a user to the sorted alliance member set. fn add_member(who: &T::AccountId, role: MemberRole) -> DispatchResult { >::try_mutate(role, |members| -> DispatchResult { diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 91986300aa2e1..242aa3d3906e5 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -83,8 +83,10 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; } +const MOTION_DURATION: u64 = 3; + parameter_types! { - pub const MotionDuration: u64 = 3; + pub const MotionDuration: u64 = MOTION_DURATION; pub const MaxProposals: u32 = 100; pub const MaxMembers: u32 = 100; } @@ -199,6 +201,7 @@ parameter_types! { pub const MaxFellows: u32 = MaxMembers::get() - MaxFounders::get(); pub const MaxAllies: u32 = 100; pub const AllyDeposit: u64 = 25; + pub const RetirementPeriod: u64 = MOTION_DURATION + 1; } impl Config for Test { type Event = Event; @@ -225,6 +228,7 @@ impl Config for Test { type MaxMembersCount = MaxMembers; type AllyDeposit = AllyDeposit; type WeightInfo = (); + type RetirementPeriod = RetirementPeriod; } type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -324,7 +328,3 @@ pub fn make_proposal(value: u64) -> Call { pub fn make_set_rule_proposal(rule: Cid) -> Call { Call::Alliance(pallet_alliance::Call::set_rule { rule }) } - -pub fn make_kick_member_proposal(who: u64) -> Call { - Call::Alliance(pallet_alliance::Call::kick_member { who }) -} diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 85c91b451d351..1b9c09667cd8b 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -19,7 +19,7 @@ use sp_runtime::traits::Hash; -use frame_support::{assert_noop, assert_ok, Hashable}; +use frame_support::{assert_noop, assert_ok, error::BadOrigin, Hashable}; use frame_system::{EventRecord, Phase}; use super::*; @@ -396,42 +396,70 @@ fn elevate_ally_works() { } #[test] -fn retire_works() { +fn retirement_notice_work() { new_test_ext().execute_with(|| { - let proposal = make_kick_member_proposal(2); - let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - assert_ok!(Alliance::propose( - Origin::signed(1), - 3, - Box::new(proposal.clone()), - proposal_len + assert_noop!(Alliance::retirement_notice(Origin::signed(4)), Error::::NotMember); + + assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]); + assert_ok!(Alliance::retirement_notice(Origin::signed(3))); + assert_eq!(Alliance::members(MemberRole::Fellow), Vec::::new()); + assert_eq!(Alliance::members(MemberRole::Retiring), vec![3]); + System::assert_last_event(mock::Event::Alliance( + crate::Event::MemberRetirementPeriodStarted { member: (3) }, )); - assert_noop!(Alliance::retire(Origin::signed(2)), Error::::UpForKicking); - assert_noop!(Alliance::retire(Origin::signed(4)), Error::::NotMember); + assert_noop!( + Alliance::retirement_notice(Origin::signed(3)), + Error::::AlreadyRetiring + ); + }); +} + +#[test] +fn retire_works() { + new_test_ext().execute_with(|| { + assert_noop!( + Alliance::retire(Origin::signed(2)), + Error::::RetirementNoticeNotGiven + ); + + assert_noop!( + Alliance::retire(Origin::signed(4)), + Error::::RetirementNoticeNotGiven + ); assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]); + assert_ok!(Alliance::retirement_notice(Origin::signed(3))); + assert_noop!( + Alliance::retire(Origin::signed(3)), + Error::::RetirementPeriodNotPassed + ); + System::set_block_number(System::block_number() + RetirementPeriod::get()); assert_ok!(Alliance::retire(Origin::signed(3))); assert_eq!(Alliance::members(MemberRole::Fellow), Vec::::new()); + System::assert_last_event(mock::Event::Alliance(crate::Event::MemberRetired { + member: (3), + unreserved: None, + })); }); } #[test] fn kick_member_works() { new_test_ext().execute_with(|| { - let proposal = make_kick_member_proposal(2); - let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32); - assert_ok!(Alliance::propose( - Origin::signed(1), - 3, - Box::new(proposal.clone()), - proposal_len - )); - assert_eq!(Alliance::up_for_kicking(2), true); - assert_eq!(Alliance::members(MemberRole::Founder), vec![1, 2]); + assert_noop!(Alliance::kick_member(Origin::signed(4), 4), BadOrigin); + + assert_noop!(Alliance::kick_member(Origin::signed(2), 4), Error::::NotMember); + >::insert(2, 25); + assert_eq!(Alliance::members(MemberRole::Founder), vec![1, 2]); assert_ok!(Alliance::kick_member(Origin::signed(2), 2)); assert_eq!(Alliance::members(MemberRole::Founder), vec![1]); + assert_eq!(>::get(2), None); + System::assert_last_event(mock::Event::Alliance(crate::Event::MemberKicked { + member: (2), + slashed: Some(25), + })); }); } From decd293e35c2d28a70cb66adb75dcef666ce10a3 Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 4 Aug 2022 12:17:50 +0200 Subject: [PATCH 02/15] add alliance pallet to benchmark list for dev chain --- bin/node/runtime/src/lib.rs | 1 + frame/alliance/src/weights.rs | 445 +++++++++++++++++++--------------- 2 files changed, 248 insertions(+), 198 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index c8b6b1aaa79f1..3ff652cd97c99 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1703,6 +1703,7 @@ extern crate frame_benchmarking; mod benches { define_benchmarks!( [frame_benchmarking, BaselineBench::] + [pallet_alliance, Alliance] [pallet_assets, Assets] [pallet_babe, Babe] [pallet_bags_list, BagsList] diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 495dd1b83df93..4e4ca841bfa18 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2021 Parity Technologies (UK) Ltd. +// Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,24 +18,24 @@ //! Autogenerated weights for pallet_alliance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-10-11, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 +//! DATE: 2022-08-04, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `cob`, CPU: `` +//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: // ./target/release/substrate // benchmark +// pallet // --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_alliance +// --steps=2 +// --repeat=1 +// --pallet=pallet-alliance // --extrinsic=* -// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 // --output=./frame/alliance/src/weights.rs // --template=./.maintain/frame-weight-template.hbs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -59,6 +59,7 @@ pub trait WeightInfo { fn join_alliance() -> Weight; fn nominate_ally() -> Weight; fn elevate_ally() -> Weight; + fn retirement_notice() -> Weight; fn retire() -> Weight; fn kick_member() -> Weight; fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight; @@ -73,149 +74,165 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Proposals (r:1 w:1) // Storage: AllianceMotion ProposalCount (r:1 w:1) // Storage: AllianceMotion Voting (r:0 w:1) - fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (39_992_000 as Weight) - // Standard Error: 2_000 - .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((323_000 as Weight).saturating_mul(p as Weight)) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[0, 90]`. + /// The range of component `p` is `[1, 100]`. + fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (26_231_000 as Weight) + // Standard Error: 170_000 + .saturating_add((16_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 15_000 + .saturating_add((1_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 13_000 + .saturating_add((86_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Alliance Members (r:2 w:0) // Storage: AllianceMotion Voting (r:1 w:1) + /// The range of component `x` is `[3, 10]`. + /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (36_649_000 as Weight) - // Standard Error: 90_000 - .saturating_add((42_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((195_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) + (24_913_000 as Weight) + // Standard Error: 87_000 + .saturating_add((36_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 6_000 + .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Proposals (r:1 w:1) // Storage: AllianceMotion Voting (r:0 w:1) + /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (30_301_000 as Weight) - // Standard Error: 1_000 - .saturating_add((330_000 as Weight).saturating_mul(p as Weight)) + (26_626_000 as Weight) + // Standard Error: 23_000 + .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (40_472_000 as Weight) - // Standard Error: 69_000 - .saturating_add((485_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 2_000 - .saturating_add((192_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((330_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { + (27_222_000 as Weight) + // Standard Error: 12_000 + .saturating_add((36_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 11_000 + .saturating_add((64_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) + // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (52_076_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 77_000 - .saturating_add((194_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((188_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((329_000 as Weight).saturating_mul(p as Weight)) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (35_149_000 as Weight) + // Standard Error: 20_000 + .saturating_add((37_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 18_000 + .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Prime (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (47_009_000 as Weight) - // Standard Error: 66_000 - .saturating_add((256_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 2_000 - .saturating_add((176_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((327_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + (29_334_000 as Weight) + // Standard Error: 155_000 + .saturating_add((37_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 14_000 + .saturating_add((12_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 12_000 + .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Prime (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (43_650_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 85_000 - .saturating_add((124_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((199_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((326_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_approved(_b: u32, _x: u32, _y: u32, p: u32, ) -> Weight { + (34_914_000 as Weight) + // Standard Error: 11_000 + .saturating_add((61_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Alliance Members (r:3 w:3) + // Storage: Alliance Members (r:2 w:3) // Storage: AllianceMotion Members (r:1 w:1) - fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (45_100_000 as Weight) - // Standard Error: 4_000 - .saturating_add((162_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 4_000 - .saturating_add((151_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[0, 90]`. + /// The range of component `z` is `[0, 100]`. + fn init_members(x: u32, y: u32, z: u32, ) -> Weight { + (13_372_000 as Weight) + // Standard Error: 110_000 + .saturating_add((508_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 9_000 + .saturating_add((94_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 8_000 + .saturating_add((85_000 as Weight).saturating_mul(z as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (14_517_000 as Weight) + (13_000_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (16_801_000 as Weight) + (18_000_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_133_000 as Weight) + (16_000_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } + // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) - // Storage: Alliance Members (r:4 w:0) // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (95_370_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + (53_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } - // Storage: Alliance Members (r:4 w:0) + // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (44_764_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) + (39_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:3 w:2) @@ -223,23 +240,29 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (44_013_000 as Weight) + (29_000_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } - // Storage: Alliance KickingMembers (r:1 w:0) - // Storage: Alliance Members (r:3 w:1) + // Storage: Alliance Members (r:4 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) - fn retire() -> Weight { - (60_183_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + // Storage: Alliance RetiringMembers (r:0 w:1) + fn retirement_notice() -> Weight { + (34_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } - // Storage: Alliance KickingMembers (r:1 w:0) + // Storage: Alliance RetiringMembers (r:1 w:1) + // Storage: Alliance Members (r:1 w:1) + // Storage: Alliance DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn retire() -> Weight { + (32_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(4 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) + } // Storage: Alliance Members (r:3 w:1) // Storage: AllianceMotion Proposals (r:1 w:0) // Storage: Alliance DepositOf (r:1 w:1) @@ -247,29 +270,31 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (67_467_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) + (50_000_000 as Weight) + .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) - fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 16_000 - .saturating_add((2_673_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 7_000 - .saturating_add((224_000 as Weight).saturating_mul(l as Weight)) + /// The range of component `n` is `[1, 100]`. + /// The range of component `l` is `[1, 255]`. + fn add_unscrupulous_items(n: u32, _l: u32, ) -> Weight { + (20_893_000 as Weight) + // Standard Error: 32_000 + .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// The range of component `n` is `[1, 100]`. + /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 343_000 - .saturating_add((59_025_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 153_000 - .saturating_add((6_725_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 1_714_000 + .saturating_add((12_158_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 667_000 + .saturating_add((839_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -282,149 +307,165 @@ impl WeightInfo for () { // Storage: AllianceMotion Proposals (r:1 w:1) // Storage: AllianceMotion ProposalCount (r:1 w:1) // Storage: AllianceMotion Voting (r:0 w:1) - fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (39_992_000 as Weight) - // Standard Error: 2_000 - .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((323_000 as Weight).saturating_mul(p as Weight)) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[0, 90]`. + /// The range of component `p` is `[1, 100]`. + fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (26_231_000 as Weight) + // Standard Error: 170_000 + .saturating_add((16_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 15_000 + .saturating_add((1_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 13_000 + .saturating_add((86_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: Alliance Members (r:2 w:0) // Storage: AllianceMotion Voting (r:1 w:1) + /// The range of component `x` is `[3, 10]`. + /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (36_649_000 as Weight) - // Standard Error: 90_000 - .saturating_add((42_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((195_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) + (24_913_000 as Weight) + // Standard Error: 87_000 + .saturating_add((36_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 6_000 + .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:1 w:0) // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Proposals (r:1 w:1) // Storage: AllianceMotion Voting (r:0 w:1) + /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (30_301_000 as Weight) - // Standard Error: 1_000 - .saturating_add((330_000 as Weight).saturating_mul(p as Weight)) + (26_626_000 as Weight) + // Standard Error: 23_000 + .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (40_472_000 as Weight) - // Standard Error: 69_000 - .saturating_add((485_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 2_000 - .saturating_add((192_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((330_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { + (27_222_000 as Weight) + // Standard Error: 12_000 + .saturating_add((36_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 11_000 + .saturating_add((64_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) + // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (52_076_000 as Weight) - // Standard Error: 0 - .saturating_add((4_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 77_000 - .saturating_add((194_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((188_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((329_000 as Weight).saturating_mul(p as Weight)) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (35_149_000 as Weight) + // Standard Error: 20_000 + .saturating_add((37_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 18_000 + .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Prime (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. fn close_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (47_009_000 as Weight) - // Standard Error: 66_000 - .saturating_add((256_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 2_000 - .saturating_add((176_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((327_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + (29_334_000 as Weight) + // Standard Error: 155_000 + .saturating_add((37_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 14_000 + .saturating_add((12_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 12_000 + .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:1 w:0) - // Storage: AllianceMotion ProposalOf (r:1 w:1) // Storage: AllianceMotion Voting (r:1 w:1) // Storage: AllianceMotion Members (r:1 w:0) // Storage: AllianceMotion Prime (r:1 w:0) // Storage: AllianceMotion Proposals (r:1 w:1) - fn close_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (43_650_000 as Weight) - // Standard Error: 0 - .saturating_add((3_000 as Weight).saturating_mul(b as Weight)) - // Standard Error: 85_000 - .saturating_add((124_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 3_000 - .saturating_add((199_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((326_000 as Weight).saturating_mul(p as Weight)) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + // Storage: AllianceMotion ProposalOf (r:0 w:1) + /// The range of component `b` is `[1, 1024]`. + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[2, 90]`. + /// The range of component `p` is `[1, 100]`. + fn close_approved(_b: u32, _x: u32, _y: u32, p: u32, ) -> Weight { + (34_914_000 as Weight) + // Standard Error: 11_000 + .saturating_add((61_000 as Weight).saturating_mul(p as Weight)) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Alliance Members (r:3 w:3) + // Storage: Alliance Members (r:2 w:3) // Storage: AllianceMotion Members (r:1 w:1) - fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (45_100_000 as Weight) - // Standard Error: 4_000 - .saturating_add((162_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 4_000 - .saturating_add((151_000 as Weight).saturating_mul(z as Weight)) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + /// The range of component `x` is `[2, 10]`. + /// The range of component `y` is `[0, 90]`. + /// The range of component `z` is `[0, 100]`. + fn init_members(x: u32, y: u32, z: u32, ) -> Weight { + (13_372_000 as Weight) + // Standard Error: 110_000 + .saturating_add((508_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 9_000 + .saturating_add((94_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 8_000 + .saturating_add((85_000 as Weight).saturating_mul(z as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (14_517_000 as Weight) + (13_000_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (16_801_000 as Weight) + (18_000_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_133_000 as Weight) + (16_000_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } + // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) - // Storage: Alliance Members (r:4 w:0) // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (95_370_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + (53_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } - // Storage: Alliance Members (r:4 w:0) + // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (44_764_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) + (39_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:3 w:2) @@ -432,23 +473,29 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (44_013_000 as Weight) + (29_000_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } - // Storage: Alliance KickingMembers (r:1 w:0) - // Storage: Alliance Members (r:3 w:1) + // Storage: Alliance Members (r:4 w:2) // Storage: AllianceMotion Proposals (r:1 w:0) - // Storage: Alliance DepositOf (r:1 w:1) - // Storage: System Account (r:1 w:1) // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) - fn retire() -> Weight { - (60_183_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + // Storage: Alliance RetiringMembers (r:0 w:1) + fn retirement_notice() -> Weight { + (34_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } - // Storage: Alliance KickingMembers (r:1 w:0) + // Storage: Alliance RetiringMembers (r:1 w:1) + // Storage: Alliance Members (r:1 w:1) + // Storage: Alliance DepositOf (r:1 w:1) + // Storage: System Account (r:1 w:1) + fn retire() -> Weight { + (32_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(4 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) + } // Storage: Alliance Members (r:3 w:1) // Storage: AllianceMotion Proposals (r:1 w:0) // Storage: Alliance DepositOf (r:1 w:1) @@ -456,29 +503,31 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (67_467_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) + (50_000_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) - fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { - (0 as Weight) - // Standard Error: 16_000 - .saturating_add((2_673_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 7_000 - .saturating_add((224_000 as Weight).saturating_mul(l as Weight)) + /// The range of component `n` is `[1, 100]`. + /// The range of component `l` is `[1, 255]`. + fn add_unscrupulous_items(n: u32, _l: u32, ) -> Weight { + (20_893_000 as Weight) + // Standard Error: 32_000 + .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } // Storage: Alliance UnscrupulousAccounts (r:1 w:1) // Storage: Alliance UnscrupulousWebsites (r:1 w:1) + /// The range of component `n` is `[1, 100]`. + /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 343_000 - .saturating_add((59_025_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 153_000 - .saturating_add((6_725_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 1_714_000 + .saturating_add((12_158_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 667_000 + .saturating_add((839_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From 7b09b07955b972b69fb176a993a5cf51a445c82a Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 4 Aug 2022 12:20:46 +0200 Subject: [PATCH 03/15] fix type --- frame/alliance/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 85f024260521f..a3d7e585ac853 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -360,7 +360,7 @@ pub mod pallet { TooManyMembers, /// Number of announcements exceeds `MaxAnnouncementsCount`. TooManyAnnouncements, - /// Account is already gave retirement notice + /// Account already gave retirement notice AlreadyRetiring, /// Account did not give a retirement notice required to retire. RetirementNoticeNotGiven, From 524988ba7fd4477d9c2e0498c434a7cf3c9cfbf4 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 4 Aug 2022 13:18:13 +0000 Subject: [PATCH 04/15] ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance --- frame/alliance/src/weights.rs | 281 +++++++++++++++++----------------- 1 file changed, 141 insertions(+), 140 deletions(-) diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 4e4ca841bfa18..5b1ff3a866d17 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -18,21 +18,22 @@ //! Autogenerated weights for pallet_alliance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-04, STEPS: `2`, REPEAT: 1, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `cob`, CPU: `` -//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 +//! DATE: 2022-08-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: -// ./target/release/substrate +// /home/benchbot/cargo_target_dir/production/substrate // benchmark // pallet -// --chain=dev -// --steps=2 -// --repeat=1 -// --pallet=pallet-alliance +// --steps=50 +// --repeat=20 // --extrinsic=* +// --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 +// --pallet=pallet_alliance +// --chain=dev // --output=./frame/alliance/src/weights.rs // --template=./.maintain/frame-weight-template.hbs @@ -78,14 +79,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (26_231_000 as Weight) - // Standard Error: 170_000 - .saturating_add((16_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 15_000 - .saturating_add((1_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 13_000 - .saturating_add((86_000 as Weight).saturating_mul(p as Weight)) + fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (47_061_000 as Weight) + // Standard Error: 3_000 + .saturating_add((33_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((109_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -93,13 +92,11 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. - fn vote(x: u32, y: u32, ) -> Weight { - (24_913_000 as Weight) - // Standard Error: 87_000 - .saturating_add((36_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 6_000 - .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) + fn vote(_x: u32, y: u32, ) -> Weight { + (42_746_000 as Weight) + // Standard Error: 3_000 + .saturating_add((25_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:1 w:0) @@ -108,9 +105,9 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (26_626_000 as Weight) - // Standard Error: 23_000 - .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) + (28_937_000 as Weight) + // Standard Error: 2_000 + .saturating_add((111_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -123,11 +120,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (27_222_000 as Weight) - // Standard Error: 12_000 - .saturating_add((36_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 11_000 - .saturating_add((64_000 as Weight).saturating_mul(p as Weight)) + (45_044_000 as Weight) + // Standard Error: 4_000 + .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -140,12 +137,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (35_149_000 as Weight) - // Standard Error: 20_000 - .saturating_add((37_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 18_000 - .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) + fn close_early_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (51_296_000 as Weight) + // Standard Error: 41_000 + .saturating_add((29_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 4_000 + .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((95_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -158,14 +157,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (29_334_000 as Weight) - // Standard Error: 155_000 - .saturating_add((37_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 14_000 - .saturating_add((12_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 12_000 - .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) + fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { + (45_174_000 as Weight) + // Standard Error: 4_000 + .saturating_add((42_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((85_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -179,10 +176,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, _x: u32, _y: u32, p: u32, ) -> Weight { - (34_914_000 as Weight) - // Standard Error: 11_000 - .saturating_add((61_000 as Weight).saturating_mul(p as Weight)) + fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (40_548_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 3_000 + .saturating_add((57_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((80_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -191,31 +192,29 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. - fn init_members(x: u32, y: u32, z: u32, ) -> Weight { - (13_372_000 as Weight) - // Standard Error: 110_000 - .saturating_add((508_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 9_000 - .saturating_add((94_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 8_000 - .saturating_add((85_000 as Weight).saturating_mul(z as Weight)) + fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { + (37_098_000 as Weight) + // Standard Error: 2_000 + .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((74_000 as Weight).saturating_mul(z as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (13_000_000 as Weight) + (15_246_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (18_000_000 as Weight) + (17_206_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (16_000_000 as Weight) + (17_668_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -224,14 +223,14 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (53_000_000 as Weight) + (49_167_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (39_000_000 as Weight) + (37_971_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -240,7 +239,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (29_000_000 as Weight) + (31_995_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -250,7 +249,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn retirement_notice() -> Weight { - (34_000_000 as Weight) + (36_210_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -259,7 +258,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (32_000_000 as Weight) + (38_039_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -270,7 +269,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (50_000_000 as Weight) + (55_209_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -278,10 +277,12 @@ impl WeightInfo for SubstrateWeight { // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. - fn add_unscrupulous_items(n: u32, _l: u32, ) -> Weight { - (20_893_000 as Weight) - // Standard Error: 32_000 - .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) + fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 2_000 + .saturating_add((1_299_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_000 + .saturating_add((120_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -291,10 +292,10 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 1_714_000 - .saturating_add((12_158_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 667_000 - .saturating_add((839_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 150_000 + .saturating_add((21_271_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 58_000 + .saturating_add((3_761_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -311,14 +312,12 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (26_231_000 as Weight) - // Standard Error: 170_000 - .saturating_add((16_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 15_000 - .saturating_add((1_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 13_000 - .saturating_add((86_000 as Weight).saturating_mul(p as Weight)) + fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (47_061_000 as Weight) + // Standard Error: 3_000 + .saturating_add((33_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((109_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -326,13 +325,11 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. - fn vote(x: u32, y: u32, ) -> Weight { - (24_913_000 as Weight) - // Standard Error: 87_000 - .saturating_add((36_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 6_000 - .saturating_add((44_000 as Weight).saturating_mul(y as Weight)) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + fn vote(_x: u32, y: u32, ) -> Weight { + (42_746_000 as Weight) + // Standard Error: 3_000 + .saturating_add((25_000 as Weight).saturating_mul(y as Weight)) + .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Members (r:1 w:0) @@ -341,9 +338,9 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (26_626_000 as Weight) - // Standard Error: 23_000 - .saturating_add((41_000 as Weight).saturating_mul(p as Weight)) + (28_937_000 as Weight) + // Standard Error: 2_000 + .saturating_add((111_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -356,11 +353,11 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (27_222_000 as Weight) - // Standard Error: 12_000 - .saturating_add((36_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 11_000 - .saturating_add((64_000 as Weight).saturating_mul(p as Weight)) + (45_044_000 as Weight) + // Standard Error: 4_000 + .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -373,12 +370,14 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (35_149_000 as Weight) - // Standard Error: 20_000 - .saturating_add((37_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 18_000 - .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) + fn close_early_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (51_296_000 as Weight) + // Standard Error: 41_000 + .saturating_add((29_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 4_000 + .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((95_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -391,14 +390,12 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_disapproved(x: u32, y: u32, p: u32, ) -> Weight { - (29_334_000 as Weight) - // Standard Error: 155_000 - .saturating_add((37_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 14_000 - .saturating_add((12_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 12_000 - .saturating_add((68_000 as Weight).saturating_mul(p as Weight)) + fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { + (45_174_000 as Weight) + // Standard Error: 4_000 + .saturating_add((42_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((85_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -412,10 +409,14 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, _x: u32, _y: u32, p: u32, ) -> Weight { - (34_914_000 as Weight) - // Standard Error: 11_000 - .saturating_add((61_000 as Weight).saturating_mul(p as Weight)) + fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (40_548_000 as Weight) + // Standard Error: 0 + .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 3_000 + .saturating_add((57_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 3_000 + .saturating_add((80_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -424,31 +425,29 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. - fn init_members(x: u32, y: u32, z: u32, ) -> Weight { - (13_372_000 as Weight) - // Standard Error: 110_000 - .saturating_add((508_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 9_000 - .saturating_add((94_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 8_000 - .saturating_add((85_000 as Weight).saturating_mul(z as Weight)) + fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { + (37_098_000 as Weight) + // Standard Error: 2_000 + .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((74_000 as Weight).saturating_mul(z as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (13_000_000 as Weight) + (15_246_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (18_000_000 as Weight) + (17_206_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (16_000_000 as Weight) + (17_668_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -457,14 +456,14 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (53_000_000 as Weight) + (49_167_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (39_000_000 as Weight) + (37_971_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -473,7 +472,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (29_000_000 as Weight) + (31_995_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -483,7 +482,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn retirement_notice() -> Weight { - (34_000_000 as Weight) + (36_210_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -492,7 +491,7 @@ impl WeightInfo for () { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (32_000_000 as Weight) + (38_039_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -503,7 +502,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (50_000_000 as Weight) + (55_209_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -511,10 +510,12 @@ impl WeightInfo for () { // Storage: Alliance UnscrupulousWebsites (r:1 w:1) /// The range of component `n` is `[1, 100]`. /// The range of component `l` is `[1, 255]`. - fn add_unscrupulous_items(n: u32, _l: u32, ) -> Weight { - (20_893_000 as Weight) - // Standard Error: 32_000 - .saturating_add((541_000 as Weight).saturating_mul(n as Weight)) + fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { + (0 as Weight) + // Standard Error: 2_000 + .saturating_add((1_299_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 1_000 + .saturating_add((120_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -524,10 +525,10 @@ impl WeightInfo for () { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 1_714_000 - .saturating_add((12_158_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 667_000 - .saturating_add((839_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 150_000 + .saturating_add((21_271_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 58_000 + .saturating_add((3_761_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From ea78b191aa2d184ecc7be787e88a596a34335d10 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Thu, 4 Aug 2022 13:38:59 +0000 Subject: [PATCH 05/15] ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance --- frame/alliance/src/weights.rs | 176 +++++++++++++++++----------------- 1 file changed, 86 insertions(+), 90 deletions(-) diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 5b1ff3a866d17..0faae19aafe1c 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -80,11 +80,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (47_061_000 as Weight) + (45_021_000 as Weight) // Standard Error: 3_000 - .saturating_add((33_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((109_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((120_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -92,10 +92,12 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. - fn vote(_x: u32, y: u32, ) -> Weight { - (42_746_000 as Weight) - // Standard Error: 3_000 - .saturating_add((25_000 as Weight).saturating_mul(y as Weight)) + fn vote(x: u32, y: u32, ) -> Weight { + (32_677_000 as Weight) + // Standard Error: 51_000 + .saturating_add((219_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 4_000 + .saturating_add((72_000 as Weight).saturating_mul(y as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -105,9 +107,9 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (28_937_000 as Weight) + (28_950_000 as Weight) // Standard Error: 2_000 - .saturating_add((111_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((113_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -120,11 +122,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (45_044_000 as Weight) + (39_407_000 as Weight) // Standard Error: 4_000 - .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((53_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -137,14 +139,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (51_296_000 as Weight) - // Standard Error: 41_000 - .saturating_add((29_000 as Weight).saturating_mul(x as Weight)) + fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (51_269_000 as Weight) // Standard Error: 4_000 - .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((95_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((91_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -158,11 +158,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (45_174_000 as Weight) + (43_301_000 as Weight) // Standard Error: 4_000 - .saturating_add((42_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((40_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((85_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((74_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -176,14 +176,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (40_548_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (46_796_000 as Weight) // Standard Error: 3_000 - .saturating_add((57_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((27_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((80_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((70_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -193,28 +191,28 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (37_098_000 as Weight) + (35_328_000 as Weight) // Standard Error: 2_000 - .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 2_000 - .saturating_add((74_000 as Weight).saturating_mul(z as Weight)) + .saturating_add((97_000 as Weight).saturating_mul(z as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (15_246_000 as Weight) + (15_105_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (17_206_000 as Weight) + (17_237_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_668_000 as Weight) + (17_851_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -223,14 +221,14 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (49_167_000 as Weight) + (49_135_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (37_971_000 as Weight) + (36_990_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -239,7 +237,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (31_995_000 as Weight) + (31_254_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -249,7 +247,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn retirement_notice() -> Weight { - (36_210_000 as Weight) + (35_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -258,7 +256,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (38_039_000 as Weight) + (36_821_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -269,7 +267,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (55_209_000 as Weight) + (54_118_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -280,9 +278,9 @@ impl WeightInfo for SubstrateWeight { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) // Standard Error: 2_000 - .saturating_add((1_299_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((1_288_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 1_000 - .saturating_add((120_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((123_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -292,10 +290,10 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 150_000 - .saturating_add((21_271_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 149_000 + .saturating_add((21_129_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 58_000 - .saturating_add((3_761_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((3_751_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -313,11 +311,11 @@ impl WeightInfo for () { /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (47_061_000 as Weight) + (45_021_000 as Weight) // Standard Error: 3_000 - .saturating_add((33_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((109_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((120_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -325,10 +323,12 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:1 w:1) /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. - fn vote(_x: u32, y: u32, ) -> Weight { - (42_746_000 as Weight) - // Standard Error: 3_000 - .saturating_add((25_000 as Weight).saturating_mul(y as Weight)) + fn vote(x: u32, y: u32, ) -> Weight { + (32_677_000 as Weight) + // Standard Error: 51_000 + .saturating_add((219_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 4_000 + .saturating_add((72_000 as Weight).saturating_mul(y as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -338,9 +338,9 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (28_937_000 as Weight) + (28_950_000 as Weight) // Standard Error: 2_000 - .saturating_add((111_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((113_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -353,11 +353,11 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (45_044_000 as Weight) + (39_407_000 as Weight) // Standard Error: 4_000 - .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((53_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((69_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -370,14 +370,12 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { - (51_296_000 as Weight) - // Standard Error: 41_000 - .saturating_add((29_000 as Weight).saturating_mul(x as Weight)) + fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (51_269_000 as Weight) // Standard Error: 4_000 - .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((95_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((91_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -391,11 +389,11 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (45_174_000 as Weight) + (43_301_000 as Weight) // Standard Error: 4_000 - .saturating_add((42_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((40_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((85_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((74_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -409,14 +407,12 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (40_548_000 as Weight) - // Standard Error: 0 - .saturating_add((1_000 as Weight).saturating_mul(b as Weight)) + fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { + (46_796_000 as Weight) // Standard Error: 3_000 - .saturating_add((57_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((27_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 3_000 - .saturating_add((80_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((70_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -426,28 +422,28 @@ impl WeightInfo for () { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (37_098_000 as Weight) + (35_328_000 as Weight) // Standard Error: 2_000 - .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) // Standard Error: 2_000 - .saturating_add((74_000 as Weight).saturating_mul(z as Weight)) + .saturating_add((97_000 as Weight).saturating_mul(z as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (15_246_000 as Weight) + (15_105_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (17_206_000 as Weight) + (17_237_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_668_000 as Weight) + (17_851_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -456,14 +452,14 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (49_167_000 as Weight) + (49_135_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (37_971_000 as Weight) + (36_990_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -472,7 +468,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (31_995_000 as Weight) + (31_254_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -482,7 +478,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn retirement_notice() -> Weight { - (36_210_000 as Weight) + (35_563_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -491,7 +487,7 @@ impl WeightInfo for () { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (38_039_000 as Weight) + (36_821_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -502,7 +498,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (55_209_000 as Weight) + (54_118_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -513,9 +509,9 @@ impl WeightInfo for () { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) // Standard Error: 2_000 - .saturating_add((1_299_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((1_288_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 1_000 - .saturating_add((120_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((123_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -525,10 +521,10 @@ impl WeightInfo for () { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 150_000 - .saturating_add((21_271_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 149_000 + .saturating_add((21_129_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 58_000 - .saturating_add((3_761_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((3_751_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From 37ff3c298152add961f9f576a61e75f8e9666c8d Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 5 Aug 2022 11:38:19 +0200 Subject: [PATCH 06/15] link weight generated by bench for retirement_notice method --- frame/alliance/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index a3d7e585ac853..e94f076dc0c73 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -797,8 +797,7 @@ pub mod pallet { /// As a member, give a retirement notice and start a retirement period required to pass in /// order to retire. - // TODO setup weight T::WeightInfo::retirement_notice() - #[pallet::weight(0)] + #[pallet::weight(T::WeightInfo::retirement_notice())] pub fn retirement_notice(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; let role = Self::member_role_of(&who).ok_or(Error::::NotMember)?; From d7cf5f3e29a01909ce7fe3595c8825bb6de5c4ad Mon Sep 17 00:00:00 2001 From: muharem Date: Thu, 11 Aug 2022 17:34:39 +0200 Subject: [PATCH 07/15] migration to clear UpForKicking storage prefix --- bin/node/runtime/src/lib.rs | 9 +++- frame/alliance/src/lib.rs | 5 +++ frame/alliance/src/migration.rs | 73 +++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 frame/alliance/src/migration.rs diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 3ff652cd97c99..57625ab63798b 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1682,9 +1682,16 @@ pub type Executive = frame_executive::Executive< frame_system::ChainContext, Runtime, AllPalletsWithSystem, - pallet_nomination_pools::migration::v2::MigrateToV2, + Migrations, >; +// All migrations executed on runtime upgrade as a nested tuple of types implementing +// `OnRuntimeUpgrade`. +type Migrations = ( + pallet_nomination_pools::migration::v2::MigrateToV2, + pallet_alliance::migration::Migration, +); + /// MMR helper types. mod mmr { use super::Runtime; diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index e94f076dc0c73..e6c580d74894c 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -95,6 +95,7 @@ mod tests; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; +pub mod migration; mod types; pub mod weights; @@ -126,6 +127,9 @@ pub use pallet::*; pub use types::*; pub use weights::*; +/// The log target of this pallet. +pub const LOG_TARGET: &'static str = "runtime::alliance"; + /// Simple index type for proposal counting. pub type ProposalIndex = u32; @@ -219,6 +223,7 @@ pub mod pallet { #[pallet::pallet] #[pallet::generate_store(pub (super) trait Store)] + #[pallet::storage_version(migration::STORAGE_VERSION)] pub struct Pallet(PhantomData<(T, I)>); #[pallet::config] diff --git a/frame/alliance/src/migration.rs b/frame/alliance/src/migration.rs new file mode 100644 index 0000000000000..30bc5cda8b7df --- /dev/null +++ b/frame/alliance/src/migration.rs @@ -0,0 +1,73 @@ +// This file is part of Substrate. + +// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd. +// SPDX-License-Identifier: Apache-2.0 + +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::{Config, Pallet, Weight, LOG_TARGET}; +use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgrade}; +use log; + +/// The current storage version. +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + +/// Wrapper for all migrations of this pallet. +pub fn migrate, I: 'static>() -> Weight { + let onchain_version = Pallet::::on_chain_storage_version(); + let mut weight: Weight = 0; + + if onchain_version < 1 { + weight = weight.saturating_add(v1::migrate::()); + } + + STORAGE_VERSION.put::>(); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + weight +} + +/// Implements `OnRuntimeUpgrade` trait. +pub struct Migration(PhantomData<(T, I)>); + +impl, I: 'static> OnRuntimeUpgrade for Migration { + fn on_runtime_upgrade() -> Weight { + migrate::() + } +} + +/// V1: `UpForKicking` blacklist is replaced by the retirement period feature not letting members up +/// for kicking to leave without being slashed. +mod v1 { + use super::*; + + pub fn migrate, I: 'static>() -> Weight { + if migration::clear_storage_prefix( + >::name().as_bytes(), + b"UpForKicking", + b"", + None, + None, + ) + .maybe_cursor + .is_some() + { + log::error!( + target: LOG_TARGET, + "Storage prefix 'UpForKicking' is not completely cleared." + ); + } + + T::DbWeight::get().writes(1) + } +} From 95859d2cc4f82eb5636a960cb4fa92103086c83b Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 12 Aug 2022 10:41:43 +0200 Subject: [PATCH 08/15] rename migration from v1 to v0_to_v1 --- frame/alliance/src/migration.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frame/alliance/src/migration.rs b/frame/alliance/src/migration.rs index 30bc5cda8b7df..8427bf4e523b8 100644 --- a/frame/alliance/src/migration.rs +++ b/frame/alliance/src/migration.rs @@ -28,7 +28,7 @@ pub fn migrate, I: 'static>() -> Weight { let mut weight: Weight = 0; if onchain_version < 1 { - weight = weight.saturating_add(v1::migrate::()); + weight = weight.saturating_add(v0_to_v1::migrate::()); } STORAGE_VERSION.put::>(); @@ -46,9 +46,9 @@ impl, I: 'static> OnRuntimeUpgrade for Migration { } } -/// V1: `UpForKicking` blacklist is replaced by the retirement period feature not letting members up -/// for kicking to leave without being slashed. -mod v1 { +/// v0_to_v1: `UpForKicking` blacklist is replaced by the retirement period feature not letting members +/// up for kicking to leave without being slashed. +mod v0_to_v1 { use super::*; pub fn migrate, I: 'static>() -> Weight { From 8e67bcb40b34e92720c1f40ff85a66f72c972807 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Tue, 16 Aug 2022 11:20:03 +0200 Subject: [PATCH 09/15] Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --- frame/alliance/src/lib.rs | 4 ++-- frame/alliance/src/migration.rs | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index e6c580d74894c..a5af208eece2b 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -369,7 +369,7 @@ pub mod pallet { AlreadyRetiring, /// Account did not give a retirement notice required to retire. RetirementNoticeNotGiven, - /// Retirement period is not passed. + /// Retirement period has not passed. RetirementPeriodNotPassed, } @@ -396,7 +396,7 @@ pub mod pallet { }, /// An ally has been elevated to Fellow. AllyElevated { ally: T::AccountId }, - /// A member gave retirement notice and retirement period started. + /// A member gave retirement notice and their retirement period started. MemberRetirementPeriodStarted { member: T::AccountId }, /// A member has retired with its deposit unreserved. MemberRetired { member: T::AccountId, unreserved: Option> }, diff --git a/frame/alliance/src/migration.rs b/frame/alliance/src/migration.rs index 8427bf4e523b8..cd54eed7a9a75 100644 --- a/frame/alliance/src/migration.rs +++ b/frame/alliance/src/migration.rs @@ -1,6 +1,6 @@ // This file is part of Substrate. -// Copyright (C) 2018-2022 Parity Technologies (UK) Ltd. +// Copyright (C) 2022 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,8 +46,7 @@ impl, I: 'static> OnRuntimeUpgrade for Migration { } } -/// v0_to_v1: `UpForKicking` blacklist is replaced by the retirement period feature not letting members -/// up for kicking to leave without being slashed. +/// v0_to_v1: `UpForKicking` is replaced by a retirement period. mod v0_to_v1 { use super::*; From 9de7e0cd796849666d316904e859e12857bb2ffc Mon Sep 17 00:00:00 2001 From: muharem Date: Tue, 16 Aug 2022 11:37:25 +0200 Subject: [PATCH 10/15] rename `retirement-notice to give-retirement-notice --- frame/alliance/README.md | 2 +- frame/alliance/src/benchmarking.rs | 4 ++-- frame/alliance/src/lib.rs | 8 ++++---- frame/alliance/src/tests.rs | 13 ++++++++----- frame/alliance/src/weights.rs | 6 +++--- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/frame/alliance/README.md b/frame/alliance/README.md index 9e9b9c9f83bde..f91475a5984ea 100644 --- a/frame/alliance/README.md +++ b/frame/alliance/README.md @@ -43,7 +43,7 @@ to update the Alliance's rule and make announcements. #### For Members (All) -- `retirement_notice` - Give a retirement notice and start a retirement period required to pass in order to retire. +- `give_retirement_notice` - Give a retirement notice and start a retirement period required to pass in order to retire. - `retire` - Retire from the Alliance and release the caller's deposit. #### For Members (Founders/Fellows) diff --git a/frame/alliance/src/benchmarking.rs b/frame/alliance/src/benchmarking.rs index 3bff9137221d5..155cfbc240c8b 100644 --- a/frame/alliance/src/benchmarking.rs +++ b/frame/alliance/src/benchmarking.rs @@ -691,7 +691,7 @@ benchmarks_instance_pallet! { assert_last_event::(Event::AllyElevated { ally: ally1 }.into()); } - retirement_notice { + give_retirement_notice { set_members::(); let fellow2 = fellow::(2); @@ -716,7 +716,7 @@ benchmarks_instance_pallet! { assert!(Alliance::::is_fellow(&fellow2)); assert_eq!( - Alliance::::retirement_notice( + Alliance::::give_retirement_notice( SystemOrigin::Signed(fellow2.clone()).into() ), Ok(()) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index a5af208eece2b..3d9289a098860 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -60,8 +60,8 @@ //! //! #### For Members (All) //! -//! - `retirement_notice` - Give a retirement notice and start a retirement period required to pass -//! in order to retire. +//! - `give_retirement_notice` - Give a retirement notice and start a retirement period required to +//! pass in order to retire. //! - `retire` - Retire from the Alliance and release the caller's deposit. //! //! #### For Members (Founders/Fellows) @@ -802,8 +802,8 @@ pub mod pallet { /// As a member, give a retirement notice and start a retirement period required to pass in /// order to retire. - #[pallet::weight(T::WeightInfo::retirement_notice())] - pub fn retirement_notice(origin: OriginFor) -> DispatchResult { + #[pallet::weight(T::WeightInfo::give_retirement_notice())] + pub fn give_retirement_notice(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; let role = Self::member_role_of(&who).ok_or(Error::::NotMember)?; ensure!(!role.eq(&MemberRole::Retiring), Error::::AlreadyRetiring); diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 1b9c09667cd8b..3cad0028f27f2 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -396,12 +396,15 @@ fn elevate_ally_works() { } #[test] -fn retirement_notice_work() { +fn give_retirement_notice_work() { new_test_ext().execute_with(|| { - assert_noop!(Alliance::retirement_notice(Origin::signed(4)), Error::::NotMember); + assert_noop!( + Alliance::give_retirement_notice(Origin::signed(4)), + Error::::NotMember + ); assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]); - assert_ok!(Alliance::retirement_notice(Origin::signed(3))); + assert_ok!(Alliance::give_retirement_notice(Origin::signed(3))); assert_eq!(Alliance::members(MemberRole::Fellow), Vec::::new()); assert_eq!(Alliance::members(MemberRole::Retiring), vec![3]); System::assert_last_event(mock::Event::Alliance( @@ -409,7 +412,7 @@ fn retirement_notice_work() { )); assert_noop!( - Alliance::retirement_notice(Origin::signed(3)), + Alliance::give_retirement_notice(Origin::signed(3)), Error::::AlreadyRetiring ); }); @@ -429,7 +432,7 @@ fn retire_works() { ); assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]); - assert_ok!(Alliance::retirement_notice(Origin::signed(3))); + assert_ok!(Alliance::give_retirement_notice(Origin::signed(3))); assert_noop!( Alliance::retire(Origin::signed(3)), Error::::RetirementPeriodNotPassed diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 0faae19aafe1c..1828895eb345b 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -60,7 +60,7 @@ pub trait WeightInfo { fn join_alliance() -> Weight; fn nominate_ally() -> Weight; fn elevate_ally() -> Weight; - fn retirement_notice() -> Weight; + fn give_retirement_notice() -> Weight; fn retire() -> Weight; fn kick_member() -> Weight; fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight; @@ -246,7 +246,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) - fn retirement_notice() -> Weight { + fn give_retirement_notice() -> Weight { (35_563_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) @@ -477,7 +477,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) - fn retirement_notice() -> Weight { + fn give_retirement_notice() -> Weight { (35_563_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) From 114e94b53b8aec0c07c456c33df6b32de20cf594 Mon Sep 17 00:00:00 2001 From: Muharem Ismailov Date: Fri, 19 Aug 2022 13:27:36 +0200 Subject: [PATCH 11/15] Apply suggestions from code review Co-authored-by: Squirrel --- frame/alliance/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 3d9289a098860..33a7c60af503f 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -128,7 +128,7 @@ pub use types::*; pub use weights::*; /// The log target of this pallet. -pub const LOG_TARGET: &'static str = "runtime::alliance"; +pub const LOG_TARGET: &str = "runtime::alliance"; /// Simple index type for proposal counting. pub type ProposalIndex = u32; @@ -820,6 +820,7 @@ pub mod pallet { } /// As a member, retire from the alliance and unreserve the deposit. + /// This can only be done once you have `give_retirement_notice` and it has expired. #[pallet::weight(T::WeightInfo::retire())] pub fn retire(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; From 4786244154cfe926a00fead634895ea0dc045fd3 Mon Sep 17 00:00:00 2001 From: muharem Date: Wed, 24 Aug 2022 18:38:53 +0200 Subject: [PATCH 12/15] review fixes: update doc, saturating add, BlockNumber type alias --- frame/alliance/src/lib.rs | 9 +++++---- frame/alliance/src/mock.rs | 12 +++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/frame/alliance/src/lib.rs b/frame/alliance/src/lib.rs index 33a7c60af503f..6f86da83427b3 100644 --- a/frame/alliance/src/lib.rs +++ b/frame/alliance/src/lib.rs @@ -102,7 +102,7 @@ pub mod weights; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::{ - traits::{StaticLookup, Zero}, + traits::{Saturating, StaticLookup, Zero}, RuntimeDebug, }; use sp_std::{convert::TryInto, prelude::*}; @@ -315,7 +315,7 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; - /// The period required to pass from retirement notice for a member to retire. + /// The number of blocks a member must wait between giving a retirement notice and retiring. /// Supposed to be greater than time required to `kick_member`. type RetirementPeriod: Get; } @@ -806,13 +806,14 @@ pub mod pallet { pub fn give_retirement_notice(origin: OriginFor) -> DispatchResult { let who = ensure_signed(origin)?; let role = Self::member_role_of(&who).ok_or(Error::::NotMember)?; - ensure!(!role.eq(&MemberRole::Retiring), Error::::AlreadyRetiring); + ensure!(role.ne(&MemberRole::Retiring), Error::::AlreadyRetiring); Self::remove_member(&who, role)?; Self::add_member(&who, MemberRole::Retiring)?; >::insert( &who, - frame_system::Pallet::::block_number() + T::RetirementPeriod::get(), + frame_system::Pallet::::block_number() + .saturating_add(T::RetirementPeriod::get()), ); Self::deposit_event(Event::MemberRetirementPeriodStarted { member: who }); diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index 242aa3d3906e5..fb4913e3352c4 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -37,8 +37,10 @@ pub use crate as pallet_alliance; use super::*; +type BlockNumber = u64; + parameter_types! { - pub const BlockHashCount: u64 = 250; + pub const BlockHashCount: BlockNumber = 250; } impl frame_system::Config for Test { type BaseCallFilter = frame_support::traits::Everything; @@ -47,7 +49,7 @@ impl frame_system::Config for Test { type Origin = Origin; type Call = Call; type Index = u64; - type BlockNumber = u64; + type BlockNumber = BlockNumber; type Hash = H256; type Hashing = BlakeTwo256; type AccountId = u64; @@ -83,10 +85,10 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; } -const MOTION_DURATION: u64 = 3; +const MOTION_DURATION: BlockNumber = 3; parameter_types! { - pub const MotionDuration: u64 = MOTION_DURATION; + pub const MotionDuration: BlockNumber = MOTION_DURATION; pub const MaxProposals: u32 = 100; pub const MaxMembers: u32 = 100; } @@ -201,7 +203,7 @@ parameter_types! { pub const MaxFellows: u32 = MaxMembers::get() - MaxFounders::get(); pub const MaxAllies: u32 = 100; pub const AllyDeposit: u64 = 25; - pub const RetirementPeriod: u64 = MOTION_DURATION + 1; + pub const RetirementPeriod: BlockNumber = MOTION_DURATION + 1; } impl Config for Test { type Event = Event; From 090a179b5d90634739b21b65e4a8ecd6715182af Mon Sep 17 00:00:00 2001 From: muharem Date: Fri, 26 Aug 2022 12:23:16 +0200 Subject: [PATCH 13/15] add suffix to duratin consts *_IN_BLOCKS --- bin/node/runtime/src/lib.rs | 6 +++--- frame/alliance/src/mock.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index 57625ab63798b..0fa1d21706e0a 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -1514,10 +1514,10 @@ impl pallet_state_trie_migration::Config for Runtime { type WeightInfo = (); } -const ALLIANCE_MOTION_DURATION: BlockNumber = 5 * DAYS; +const ALLIANCE_MOTION_DURATION_IN_BLOCKS: BlockNumber = 5 * DAYS; parameter_types! { - pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION; + pub const AllianceMotionDuration: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS; pub const AllianceMaxProposals: u32 = 100; pub const AllianceMaxMembers: u32 = 100; } @@ -1539,7 +1539,7 @@ parameter_types! { pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFounders::get(); pub const MaxAllies: u32 = 100; pub const AllyDeposit: Balance = 10 * DOLLARS; - pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION + (1 * DAYS); + pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS); } impl pallet_alliance::Config for Runtime { diff --git a/frame/alliance/src/mock.rs b/frame/alliance/src/mock.rs index fb4913e3352c4..adc313e28ed7e 100644 --- a/frame/alliance/src/mock.rs +++ b/frame/alliance/src/mock.rs @@ -85,10 +85,10 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; } -const MOTION_DURATION: BlockNumber = 3; +const MOTION_DURATION_IN_BLOCKS: BlockNumber = 3; parameter_types! { - pub const MotionDuration: BlockNumber = MOTION_DURATION; + pub const MotionDuration: BlockNumber = MOTION_DURATION_IN_BLOCKS; pub const MaxProposals: u32 = 100; pub const MaxMembers: u32 = 100; } @@ -203,7 +203,7 @@ parameter_types! { pub const MaxFellows: u32 = MaxMembers::get() - MaxFounders::get(); pub const MaxAllies: u32 = 100; pub const AllyDeposit: u64 = 25; - pub const RetirementPeriod: BlockNumber = MOTION_DURATION + 1; + pub const RetirementPeriod: BlockNumber = MOTION_DURATION_IN_BLOCKS + 1; } impl Config for Test { type Event = Event; From 69f0802cf1bf09016e2ea11caabd75485958a162 Mon Sep 17 00:00:00 2001 From: command-bot <> Date: Fri, 26 Aug 2022 11:58:04 +0000 Subject: [PATCH 14/15] ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance --- frame/alliance/src/weights.rs | 234 ++++++++++++++++++---------------- 1 file changed, 125 insertions(+), 109 deletions(-) diff --git a/frame/alliance/src/weights.rs b/frame/alliance/src/weights.rs index 1828895eb345b..aa9ebde528683 100644 --- a/frame/alliance/src/weights.rs +++ b/frame/alliance/src/weights.rs @@ -18,7 +18,7 @@ //! Autogenerated weights for pallet_alliance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2022-08-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 @@ -79,12 +79,16 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (45_021_000 as Weight) - // Standard Error: 3_000 - .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + fn propose_proposed(b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (22_575_000 as Weight) + // Standard Error: 0 + .saturating_add((11_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 23_000 + .saturating_add((158_000 as Weight).saturating_mul(x as Weight)) // Standard Error: 2_000 - .saturating_add((120_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((90_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((216_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -93,11 +97,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (32_677_000 as Weight) - // Standard Error: 51_000 - .saturating_add((219_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 4_000 - .saturating_add((72_000 as Weight).saturating_mul(y as Weight)) + (45_486_000 as Weight) + // Standard Error: 29_000 + .saturating_add((78_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 2_000 + .saturating_add((128_000 as Weight).saturating_mul(y as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -107,9 +111,9 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (28_950_000 as Weight) + (35_296_000 as Weight) // Standard Error: 2_000 - .saturating_add((113_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((171_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -121,12 +125,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (39_407_000 as Weight) - // Standard Error: 4_000 - .saturating_add((53_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) + fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { + (39_252_000 as Weight) + // Standard Error: 18_000 + .saturating_add((75_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 1_000 + .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((170_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -140,11 +146,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (51_269_000 as Weight) - // Standard Error: 4_000 - .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((91_000 as Weight).saturating_mul(p as Weight)) + (50_357_000 as Weight) + // Standard Error: 1_000 + .saturating_add((103_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -158,11 +164,11 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (43_301_000 as Weight) - // Standard Error: 4_000 - .saturating_add((40_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((74_000 as Weight).saturating_mul(p as Weight)) + (41_258_000 as Weight) + // Standard Error: 1_000 + .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((186_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -176,12 +182,14 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (46_796_000 as Weight) - // Standard Error: 3_000 - .saturating_add((27_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((70_000 as Weight).saturating_mul(p as Weight)) + fn close_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (40_490_000 as Weight) + // Standard Error: 16_000 + .saturating_add((119_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 1_000 + .saturating_add((93_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((195_000 as Weight).saturating_mul(p as Weight)) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -191,28 +199,28 @@ impl WeightInfo for SubstrateWeight { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (35_328_000 as Weight) - // Standard Error: 2_000 - .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((97_000 as Weight).saturating_mul(z as Weight)) + (35_186_000 as Weight) + // Standard Error: 1_000 + .saturating_add((161_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((127_000 as Weight).saturating_mul(z as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (15_105_000 as Weight) + (18_189_000 as Weight) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (17_237_000 as Weight) + (21_106_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_851_000 as Weight) + (22_208_000 as Weight) .saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -221,14 +229,14 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (49_135_000 as Weight) + (53_771_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (36_990_000 as Weight) + (41_912_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight)) } @@ -237,7 +245,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (31_254_000 as Weight) + (36_811_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -247,7 +255,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn give_retirement_notice() -> Weight { - (35_563_000 as Weight) + (41_079_000 as Weight) .saturating_add(T::DbWeight::get().reads(5 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -256,7 +264,7 @@ impl WeightInfo for SubstrateWeight { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (36_821_000 as Weight) + (42_703_000 as Weight) .saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight)) } @@ -267,7 +275,7 @@ impl WeightInfo for SubstrateWeight { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (54_118_000 as Weight) + (61_370_000 as Weight) .saturating_add(T::DbWeight::get().reads(6 as Weight)) .saturating_add(T::DbWeight::get().writes(5 as Weight)) } @@ -278,9 +286,9 @@ impl WeightInfo for SubstrateWeight { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) // Standard Error: 2_000 - .saturating_add((1_288_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((1_385_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 1_000 - .saturating_add((123_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((119_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -290,10 +298,10 @@ impl WeightInfo for SubstrateWeight { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 149_000 - .saturating_add((21_129_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 58_000 - .saturating_add((3_751_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 153_000 + .saturating_add((21_484_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 59_000 + .saturating_add((3_772_000 as Weight).saturating_mul(l as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight)) } @@ -310,12 +318,16 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[0, 90]`. /// The range of component `p` is `[1, 100]`. - fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (45_021_000 as Weight) - // Standard Error: 3_000 - .saturating_add((51_000 as Weight).saturating_mul(y as Weight)) + fn propose_proposed(b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (22_575_000 as Weight) + // Standard Error: 0 + .saturating_add((11_000 as Weight).saturating_mul(b as Weight)) + // Standard Error: 23_000 + .saturating_add((158_000 as Weight).saturating_mul(x as Weight)) // Standard Error: 2_000 - .saturating_add((120_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((90_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 2_000 + .saturating_add((216_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -324,11 +336,11 @@ impl WeightInfo for () { /// The range of component `x` is `[3, 10]`. /// The range of component `y` is `[2, 90]`. fn vote(x: u32, y: u32, ) -> Weight { - (32_677_000 as Weight) - // Standard Error: 51_000 - .saturating_add((219_000 as Weight).saturating_mul(x as Weight)) - // Standard Error: 4_000 - .saturating_add((72_000 as Weight).saturating_mul(y as Weight)) + (45_486_000 as Weight) + // Standard Error: 29_000 + .saturating_add((78_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 2_000 + .saturating_add((128_000 as Weight).saturating_mul(y as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -338,9 +350,9 @@ impl WeightInfo for () { // Storage: AllianceMotion Voting (r:0 w:1) /// The range of component `p` is `[1, 100]`. fn veto(p: u32, ) -> Weight { - (28_950_000 as Weight) + (35_296_000 as Weight) // Standard Error: 2_000 - .saturating_add((113_000 as Weight).saturating_mul(p as Weight)) + .saturating_add((171_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -352,12 +364,14 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_early_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (39_407_000 as Weight) - // Standard Error: 4_000 - .saturating_add((53_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((81_000 as Weight).saturating_mul(p as Weight)) + fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight { + (39_252_000 as Weight) + // Standard Error: 18_000 + .saturating_add((75_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 1_000 + .saturating_add((107_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((170_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -371,11 +385,11 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_early_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (51_269_000 as Weight) - // Standard Error: 4_000 - .saturating_add((38_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((91_000 as Weight).saturating_mul(p as Weight)) + (50_357_000 as Weight) + // Standard Error: 1_000 + .saturating_add((103_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((204_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -389,11 +403,11 @@ impl WeightInfo for () { /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight { - (43_301_000 as Weight) - // Standard Error: 4_000 - .saturating_add((40_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((74_000 as Weight).saturating_mul(p as Weight)) + (41_258_000 as Weight) + // Standard Error: 1_000 + .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((186_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -407,12 +421,14 @@ impl WeightInfo for () { /// The range of component `x` is `[2, 10]`. /// The range of component `y` is `[2, 90]`. /// The range of component `p` is `[1, 100]`. - fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight { - (46_796_000 as Weight) - // Standard Error: 3_000 - .saturating_add((27_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 3_000 - .saturating_add((70_000 as Weight).saturating_mul(p as Weight)) + fn close_approved(_b: u32, x: u32, y: u32, p: u32, ) -> Weight { + (40_490_000 as Weight) + // Standard Error: 16_000 + .saturating_add((119_000 as Weight).saturating_mul(x as Weight)) + // Standard Error: 1_000 + .saturating_add((93_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((195_000 as Weight).saturating_mul(p as Weight)) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -422,28 +438,28 @@ impl WeightInfo for () { /// The range of component `y` is `[0, 90]`. /// The range of component `z` is `[0, 100]`. fn init_members(_x: u32, y: u32, z: u32, ) -> Weight { - (35_328_000 as Weight) - // Standard Error: 2_000 - .saturating_add((111_000 as Weight).saturating_mul(y as Weight)) - // Standard Error: 2_000 - .saturating_add((97_000 as Weight).saturating_mul(z as Weight)) + (35_186_000 as Weight) + // Standard Error: 1_000 + .saturating_add((161_000 as Weight).saturating_mul(y as Weight)) + // Standard Error: 1_000 + .saturating_add((127_000 as Weight).saturating_mul(z as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: Alliance Rule (r:0 w:1) fn set_rule() -> Weight { - (15_105_000 as Weight) + (18_189_000 as Weight) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn announce() -> Weight { - (17_237_000 as Weight) + (21_106_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } // Storage: Alliance Announcements (r:1 w:1) fn remove_announcement() -> Weight { - (17_851_000 as Weight) + (22_208_000 as Weight) .saturating_add(RocksDbWeight::get().reads(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -452,14 +468,14 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: Alliance DepositOf (r:0 w:1) fn join_alliance() -> Weight { - (49_135_000 as Weight) + (53_771_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } // Storage: Alliance Members (r:4 w:1) // Storage: Alliance UnscrupulousAccounts (r:1 w:0) fn nominate_ally() -> Weight { - (36_990_000 as Weight) + (41_912_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight)) } @@ -468,7 +484,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn elevate_ally() -> Weight { - (31_254_000 as Weight) + (36_811_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -478,7 +494,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Prime (r:0 w:1) // Storage: Alliance RetiringMembers (r:0 w:1) fn give_retirement_notice() -> Weight { - (35_563_000 as Weight) + (41_079_000 as Weight) .saturating_add(RocksDbWeight::get().reads(5 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -487,7 +503,7 @@ impl WeightInfo for () { // Storage: Alliance DepositOf (r:1 w:1) // Storage: System Account (r:1 w:1) fn retire() -> Weight { - (36_821_000 as Weight) + (42_703_000 as Weight) .saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } @@ -498,7 +514,7 @@ impl WeightInfo for () { // Storage: AllianceMotion Members (r:0 w:1) // Storage: AllianceMotion Prime (r:0 w:1) fn kick_member() -> Weight { - (54_118_000 as Weight) + (61_370_000 as Weight) .saturating_add(RocksDbWeight::get().reads(6 as Weight)) .saturating_add(RocksDbWeight::get().writes(5 as Weight)) } @@ -509,9 +525,9 @@ impl WeightInfo for () { fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) // Standard Error: 2_000 - .saturating_add((1_288_000 as Weight).saturating_mul(n as Weight)) + .saturating_add((1_385_000 as Weight).saturating_mul(n as Weight)) // Standard Error: 1_000 - .saturating_add((123_000 as Weight).saturating_mul(l as Weight)) + .saturating_add((119_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } @@ -521,10 +537,10 @@ impl WeightInfo for () { /// The range of component `l` is `[1, 255]`. fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight { (0 as Weight) - // Standard Error: 149_000 - .saturating_add((21_129_000 as Weight).saturating_mul(n as Weight)) - // Standard Error: 58_000 - .saturating_add((3_751_000 as Weight).saturating_mul(l as Weight)) + // Standard Error: 153_000 + .saturating_add((21_484_000 as Weight).saturating_mul(n as Weight)) + // Standard Error: 59_000 + .saturating_add((3_772_000 as Weight).saturating_mul(l as Weight)) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight)) } From 23bdc2e234c7b75b21476485fcda399abab262a1 Mon Sep 17 00:00:00 2001 From: Squirrel Date: Fri, 26 Aug 2022 15:43:56 +0100 Subject: [PATCH 15/15] add negative tests (#11995) * add negative tests * remove tests powerless asserts checking against announcment origin * assert bad origin from announcement origin checks Co-authored-by: muharem --- frame/alliance/src/tests.rs | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/frame/alliance/src/tests.rs b/frame/alliance/src/tests.rs index 979af76afbd52..918cfa840c3f0 100644 --- a/frame/alliance/src/tests.rs +++ b/frame/alliance/src/tests.rs @@ -241,6 +241,9 @@ fn set_rule_works() { fn announce_works() { new_test_ext().execute_with(|| { let cid = test_cid(); + + assert_noop!(Alliance::announce(Origin::signed(2), cid.clone()), BadOrigin); + assert_ok!(Alliance::announce(Origin::signed(3), cid.clone())); assert_eq!(Alliance::announcements(), vec![cid.clone()]); @@ -438,9 +441,39 @@ fn retire_works() { member: (3), unreserved: None, })); + + // Move time on: + System::set_block_number(System::block_number() + RetirementPeriod::get()); + + assert_powerless(Origin::signed(3)); }); } +fn assert_powerless(user: Origin) { + //vote / veto with a valid propsal + let cid = test_cid(); + let proposal = make_proposal(42); + + assert_noop!(Alliance::init_members(user.clone(), vec![], vec![], vec![]), BadOrigin); + + assert_noop!(Alliance::set_rule(user.clone(), cid.clone()), BadOrigin); + + assert_noop!(Alliance::retire(user.clone()), Error::::RetirementNoticeNotGiven); + + assert_noop!(Alliance::give_retirement_notice(user.clone()), Error::::NotMember); + + assert_noop!(Alliance::elevate_ally(user.clone(), 4), BadOrigin); + + assert_noop!(Alliance::kick_member(user.clone(), 1), BadOrigin); + + assert_noop!(Alliance::nominate_ally(user.clone(), 4), Error::::NoVotingRights); + + assert_noop!( + Alliance::propose(user.clone(), 5, Box::new(proposal), 1000), + Error::::NoVotingRights + ); +} + #[test] fn kick_member_works() { new_test_ext().execute_with(|| { @@ -463,6 +496,8 @@ fn kick_member_works() { #[test] fn add_unscrupulous_items_works() { new_test_ext().execute_with(|| { + assert_noop!(Alliance::add_unscrupulous_items(Origin::signed(2), vec![]), BadOrigin); + assert_ok!(Alliance::add_unscrupulous_items( Origin::signed(3), vec![ @@ -486,6 +521,8 @@ fn add_unscrupulous_items_works() { #[test] fn remove_unscrupulous_items_works() { new_test_ext().execute_with(|| { + assert_noop!(Alliance::remove_unscrupulous_items(Origin::signed(2), vec![]), BadOrigin); + assert_noop!( Alliance::remove_unscrupulous_items( Origin::signed(3),