mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
Alliance pallet: add force_set_members instead of init_members function (#11997)
* Alliance pallet: add force_set_members instead of init_members function * benchmark with witness data * remove invalid limit for clear * Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Revert "remove invalid limit for clear" This reverts commit dba54e3071b63bfea908087aef213f4640e3ccbf. * compile constructor only for test * Update comments for force_set_members Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * benchmark - founders count range * Revert "benchmark - founders count range" This reverts commit aad16796f8dfed48079fb7f587b8f5b59382cda6. * witness members count instead votable members count * update the doc * use decode_len for witness data checks * change witness data member count to voting member count; update clear limits * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance * merge master * fixes after merge master * revert to cb3e63 * disband alliance and return deposits * revert debug changes * weights * update docs * update test comments * Apply Joe suggestions from code review Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * rename event from AllianceDisband to AllianceDisbanded * ".git/.scripts/bench-bot.sh" pallet dev pallet_alliance Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: command-bot <>
This commit is contained in:
@@ -18,7 +18,8 @@
|
||||
//! Some configurable implementations as associated type for the substrate runtime.
|
||||
|
||||
use crate::{
|
||||
AccountId, AllianceMotion, Assets, Authorship, Balances, Call, Hash, NegativeImbalance, Runtime,
|
||||
AccountId, AllianceCollective, AllianceMotion, Assets, Authorship, Balances, Call, Hash,
|
||||
NegativeImbalance, Runtime,
|
||||
};
|
||||
use frame_support::{
|
||||
pallet_prelude::*,
|
||||
@@ -112,6 +113,15 @@ impl ProposalProvider<AccountId, Hash, Call> for AllianceProposalProvider {
|
||||
fn proposal_of(proposal_hash: Hash) -> Option<Call> {
|
||||
AllianceMotion::proposal_of(proposal_hash)
|
||||
}
|
||||
|
||||
fn proposals() -> Vec<Hash> {
|
||||
AllianceMotion::proposals().into_inner()
|
||||
}
|
||||
|
||||
fn proposals_count() -> u32 {
|
||||
pallet_collective::Proposals::<Runtime, AllianceCollective>::decode_len().unwrap_or(0)
|
||||
as u32
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -66,4 +66,4 @@ to update the Alliance's rule and make announcements.
|
||||
|
||||
#### Root Calls
|
||||
|
||||
- `init_founders` - Initialize the founding members.
|
||||
- `force_set_members` - Set the members via chain governance.
|
||||
|
||||
@@ -38,6 +38,11 @@ fn assert_last_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::
|
||||
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
|
||||
}
|
||||
|
||||
fn assert_prev_event<T: Config<I>, I: 'static>(generic_event: <T as Config<I>>::Event) {
|
||||
let events = frame_system::Pallet::<T>::events();
|
||||
assert_eq!(events.get(events.len() - 2).expect("events expected").event, generic_event.into());
|
||||
}
|
||||
|
||||
fn cid(input: impl AsRef<[u8]>) -> Cid {
|
||||
use sha2::{Digest, Sha256};
|
||||
let mut hasher = Sha256::new();
|
||||
@@ -121,7 +126,13 @@ benchmarks_instance_pallet! {
|
||||
let proposer = founders[0].clone();
|
||||
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
let threshold = m;
|
||||
// Add previous proposals.
|
||||
@@ -167,7 +178,13 @@ benchmarks_instance_pallet! {
|
||||
members.extend(founders.clone());
|
||||
members.extend(fellows.clone());
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
// Threshold is 1 less than the number of members so that one person can vote nay
|
||||
let threshold = m - 1;
|
||||
@@ -230,7 +247,13 @@ benchmarks_instance_pallet! {
|
||||
let founders = (0 .. m).map(founder::<T, I>).collect::<Vec<_>>();
|
||||
let vetor = founders[0].clone();
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, vec![], vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
vec![],
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
// Threshold is one less than total members so that two nays will disapprove the vote
|
||||
let threshold = m - 1;
|
||||
@@ -276,7 +299,13 @@ benchmarks_instance_pallet! {
|
||||
members.extend(founders.clone());
|
||||
members.extend(fellows.clone());
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
@@ -356,7 +385,13 @@ benchmarks_instance_pallet! {
|
||||
members.extend(founders.clone());
|
||||
members.extend(fellows.clone());
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
@@ -442,7 +477,13 @@ benchmarks_instance_pallet! {
|
||||
members.extend(founders.clone());
|
||||
members.extend(fellows.clone());
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
@@ -513,7 +554,13 @@ benchmarks_instance_pallet! {
|
||||
members.extend(founders.clone());
|
||||
members.extend(fellows.clone());
|
||||
|
||||
Alliance::<T, I>::init_members(SystemOrigin::Root.into(), founders, fellows, vec![])?;
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
founders,
|
||||
fellows,
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
let proposer = members[0].clone();
|
||||
let voter = members[1].clone();
|
||||
@@ -568,21 +615,124 @@ benchmarks_instance_pallet! {
|
||||
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
|
||||
}
|
||||
|
||||
init_members {
|
||||
// at least 2 founders
|
||||
let x in 2 .. T::MaxFounders::get();
|
||||
force_set_members {
|
||||
// at least 1 founders
|
||||
let x in 1 .. T::MaxFounders::get();
|
||||
let y in 0 .. T::MaxFellows::get();
|
||||
let z in 0 .. T::MaxAllies::get();
|
||||
let p in 0 .. T::MaxProposals::get();
|
||||
let c in 0 .. T::MaxFounders::get() + T::MaxFellows::get();
|
||||
let m in 0 .. T::MaxAllies::get();
|
||||
|
||||
let mut founders = (2 .. x).map(founder::<T, I>).collect::<Vec<_>>();
|
||||
let mut founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
|
||||
let mut proposer = founders[0].clone();
|
||||
let mut fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
let mut allies = (0 .. z).map(ally::<T, I>).collect::<Vec<_>>();
|
||||
let witness = ForceSetWitness{
|
||||
proposals: p,
|
||||
voting_members: c,
|
||||
ally_members: m,
|
||||
};
|
||||
let mut old_fellows: Vec<T::AccountId> = Vec::new();
|
||||
let mut old_allies: Vec<T::AccountId> = Vec::new();
|
||||
|
||||
}: _(SystemOrigin::Root, founders.clone(), fellows.clone(), allies.clone())
|
||||
let mut cc = c;
|
||||
if (m > 0 && c == 0) || (p > 0 && c == 0) {
|
||||
// if total member count `m` greater than zero,
|
||||
// one voting member required to set non voting members.
|
||||
// OR
|
||||
// if some proposals,
|
||||
// one voting member required to create proposal.
|
||||
cc = 1;
|
||||
}
|
||||
|
||||
// setting the Alliance to disband on the benchmark call
|
||||
if cc > 0 {
|
||||
old_fellows = (0..cc).map(fellow::<T, I>).collect::<Vec<_>>();
|
||||
old_allies = (0..m).map(ally::<T, I>).collect::<Vec<_>>();
|
||||
|
||||
// used later for proposal creation.
|
||||
proposer = old_fellows[0].clone();
|
||||
|
||||
// set alliance before benchmarked call to include alliance disband.
|
||||
Alliance::<T, I>::force_set_members(
|
||||
SystemOrigin::Root.into(),
|
||||
vec![old_fellows[0].clone()],
|
||||
vec![],
|
||||
vec![],
|
||||
Default::default(),
|
||||
)?;
|
||||
|
||||
// using `join_alliance` instead `force_set_members` to join alliance
|
||||
// to have deposit reserved and bench the worst case scenario.
|
||||
for fellow in old_fellows.iter().skip(1) {
|
||||
Alliance::<T, I>::join_alliance(
|
||||
SystemOrigin::Signed(fellow.clone()).into()
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
// elevating allies to have desired voting members count.
|
||||
for fellow in old_fellows.iter().skip(1) {
|
||||
Alliance::<T, I>::elevate_ally(
|
||||
T::MembershipManager::successful_origin(),
|
||||
T::Lookup::unlookup(fellow.clone())
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
for ally in old_allies.iter() {
|
||||
Alliance::<T, I>::join_alliance(
|
||||
SystemOrigin::Signed(ally.clone()).into()
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(Alliance::<T, I>::votable_members_count(), cc);
|
||||
assert_eq!(Alliance::<T, I>::ally_members_count(), m);
|
||||
}
|
||||
|
||||
// adding proposals to veto on the Alliance reset
|
||||
for i in 0..p {
|
||||
let threshold = cc;
|
||||
let bytes_in_storage = i + size_of::<Cid>() as u32 + 32;
|
||||
// proposals should be different so that different proposal hashes are generated
|
||||
let proposal: T::Proposal =
|
||||
AllianceCall::<T, I>::set_rule { rule: rule(vec![i as u8; i as usize]) }.into();
|
||||
Alliance::<T, I>::propose(
|
||||
SystemOrigin::Signed(proposer.clone()).into(),
|
||||
threshold,
|
||||
Box::new(proposal),
|
||||
bytes_in_storage,
|
||||
)?;
|
||||
}
|
||||
let mut proposals = T::ProposalProvider::proposals();
|
||||
if c != cc {
|
||||
// removing a helper founder from the alliance which should not be
|
||||
// included in the actual benchmark call.
|
||||
Alliance::<T, I>::give_retirement_notice(
|
||||
SystemOrigin::Signed(proposer.clone()).into()
|
||||
)?;
|
||||
System::<T>::set_block_number(
|
||||
System::<T>::block_number() + T::RetirementPeriod::get()
|
||||
);
|
||||
Alliance::<T, I>::retire(
|
||||
SystemOrigin::Signed(proposer.clone()).into()
|
||||
)?;
|
||||
// remove a helper founder from fellows list.
|
||||
old_fellows.remove(0);
|
||||
}
|
||||
}: _(SystemOrigin::Root, founders.clone(), fellows.clone(), allies.clone(), witness)
|
||||
verify {
|
||||
founders.sort();
|
||||
fellows.sort();
|
||||
allies.sort();
|
||||
if !witness.is_zero() {
|
||||
old_fellows.append(&mut old_allies);
|
||||
old_fellows.sort();
|
||||
proposals.sort();
|
||||
assert_prev_event::<T, I>(Event::AllianceDisbanded {
|
||||
members: old_fellows,
|
||||
proposals: proposals,
|
||||
}.into());
|
||||
}
|
||||
assert_last_event::<T, I>(Event::MembersInitialized {
|
||||
founders: founders.clone(),
|
||||
fellows: fellows.clone(),
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
//!
|
||||
//! #### Root Calls
|
||||
//!
|
||||
//! - `init_founders` - Initialize the founding members.
|
||||
//! - `force_set_members` - Set the members via chain governance.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
@@ -172,6 +172,8 @@ impl<AccountId> IdentityVerifier<AccountId> for () {
|
||||
|
||||
/// The provider of a collective action interface, for example an instance of `pallet-collective`.
|
||||
pub trait ProposalProvider<AccountId, Hash, Proposal> {
|
||||
/// Add a new proposal.
|
||||
/// Returns a proposal length and active proposals count if successful.
|
||||
fn propose_proposal(
|
||||
who: AccountId,
|
||||
threshold: u32,
|
||||
@@ -179,6 +181,8 @@ pub trait ProposalProvider<AccountId, Hash, Proposal> {
|
||||
length_bound: u32,
|
||||
) -> Result<(u32, u32), DispatchError>;
|
||||
|
||||
/// Add an aye or nay vote for the sender to the given proposal.
|
||||
/// Returns true if the sender votes first time if successful.
|
||||
fn vote_proposal(
|
||||
who: AccountId,
|
||||
proposal: Hash,
|
||||
@@ -186,8 +190,11 @@ pub trait ProposalProvider<AccountId, Hash, Proposal> {
|
||||
approve: bool,
|
||||
) -> Result<bool, DispatchError>;
|
||||
|
||||
/// Veto a proposal, closing and removing it from the system, regardless of its current state.
|
||||
/// Returns an active proposals count, which includes removed proposal.
|
||||
fn veto_proposal(proposal_hash: Hash) -> u32;
|
||||
|
||||
/// Close a proposal that is either approved, disapproved, or whose voting period has ended.
|
||||
fn close_proposal(
|
||||
proposal_hash: Hash,
|
||||
index: ProposalIndex,
|
||||
@@ -195,7 +202,16 @@ pub trait ProposalProvider<AccountId, Hash, Proposal> {
|
||||
length_bound: u32,
|
||||
) -> DispatchResultWithPostInfo;
|
||||
|
||||
/// Return a proposal of the given hash.
|
||||
fn proposal_of(proposal_hash: Hash) -> Option<Proposal>;
|
||||
|
||||
/// Return hashes of all active proposals.
|
||||
fn proposals() -> Vec<Hash>;
|
||||
|
||||
// Return count of all active proposals.
|
||||
//
|
||||
// Used to check witness data for an extrinsic.
|
||||
fn proposals_count() -> u32;
|
||||
}
|
||||
|
||||
/// The various roles that a member can hold.
|
||||
@@ -324,10 +340,10 @@ pub mod pallet {
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T, I = ()> {
|
||||
/// The founders/fellows/allies have already been initialized.
|
||||
AllianceAlreadyInitialized,
|
||||
/// The Alliance has not been initialized yet, therefore accounts cannot join it.
|
||||
AllianceNotYetInitialized,
|
||||
/// The Alliance has been initialized, therefore cannot be initialized again.
|
||||
AllianceAlreadyInitialized,
|
||||
/// Account is already a member.
|
||||
AlreadyMember,
|
||||
/// Account is not a member.
|
||||
@@ -367,12 +383,16 @@ pub mod pallet {
|
||||
TooManyMembers,
|
||||
/// Number of announcements exceeds `MaxAnnouncementsCount`.
|
||||
TooManyAnnouncements,
|
||||
/// Invalid witness data given.
|
||||
BadWitness,
|
||||
/// Account already gave retirement notice
|
||||
AlreadyRetiring,
|
||||
/// Account did not give a retirement notice required to retire.
|
||||
RetirementNoticeNotGiven,
|
||||
/// Retirement period has not passed.
|
||||
RetirementPeriodNotPassed,
|
||||
/// Founders must be provided to initialize the Alliance.
|
||||
FoundersMissing,
|
||||
}
|
||||
|
||||
#[pallet::event]
|
||||
@@ -408,6 +428,8 @@ pub mod pallet {
|
||||
UnscrupulousItemAdded { items: Vec<UnscrupulousItemOf<T, I>> },
|
||||
/// Accounts or websites have been removed from the list of unscrupulous items.
|
||||
UnscrupulousItemRemoved { items: Vec<UnscrupulousItemOf<T, I>> },
|
||||
/// Alliance disbanded.
|
||||
AllianceDisbanded { members: Vec<T::AccountId>, proposals: Vec<T::Hash> },
|
||||
}
|
||||
|
||||
#[pallet::genesis_config]
|
||||
@@ -451,15 +473,22 @@ pub mod pallet {
|
||||
!Pallet::<T, I>::has_member(MemberRole::Fellow),
|
||||
"Fellows are already initialized!"
|
||||
);
|
||||
assert!(
|
||||
!self.founders.is_empty(),
|
||||
"Founders must be provided to initialize the Alliance"
|
||||
);
|
||||
let members: BoundedVec<T::AccountId, T::MaxMembersCount> =
|
||||
self.fellows.clone().try_into().expect("Too many genesis fellows");
|
||||
Members::<T, I>::insert(MemberRole::Fellow, members);
|
||||
}
|
||||
if !self.allies.is_empty() {
|
||||
// Only allow Allies if the Alliance is "initialized".
|
||||
assert!(
|
||||
Pallet::<T, I>::is_initialized(),
|
||||
"Alliance must have Founders or Fellows to have Allies"
|
||||
!Pallet::<T, I>::has_member(MemberRole::Ally),
|
||||
"Allies are already initialized!"
|
||||
);
|
||||
assert!(
|
||||
!self.founders.is_empty(),
|
||||
"Founders must be provided to initialize the Alliance"
|
||||
);
|
||||
let members: BoundedVec<T::AccountId, T::MaxMembersCount> =
|
||||
self.allies.clone().try_into().expect("Too many genesis allies");
|
||||
@@ -619,24 +648,80 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
/// Initialize the founders, fellows, and allies.
|
||||
/// Founders must be provided to initialize the Alliance.
|
||||
///
|
||||
/// This should only be called once, and must be called by the Root origin.
|
||||
#[pallet::weight(T::WeightInfo::init_members(
|
||||
/// Provide witness data to disband current Alliance before initializing new.
|
||||
/// Alliance must be empty or disband first to initialize new.
|
||||
///
|
||||
/// Alliance is only disbanded if new member set is not provided.
|
||||
///
|
||||
/// Must be called by the Root origin.
|
||||
#[pallet::weight(T::WeightInfo::force_set_members(
|
||||
T::MaxFounders::get(),
|
||||
T::MaxFellows::get(),
|
||||
T::MaxAllies::get()
|
||||
T::MaxAllies::get(),
|
||||
witness.proposals,
|
||||
witness.voting_members,
|
||||
witness.ally_members,
|
||||
))]
|
||||
pub fn init_members(
|
||||
pub fn force_set_members(
|
||||
origin: OriginFor<T>,
|
||||
founders: Vec<T::AccountId>,
|
||||
fellows: Vec<T::AccountId>,
|
||||
allies: Vec<T::AccountId>,
|
||||
witness: ForceSetWitness,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
|
||||
// Cannot be called if the Alliance already has Founders or Fellows.
|
||||
// TODO: Remove check and allow Root to set members at any time.
|
||||
// https://github.com/paritytech/substrate/issues/11928
|
||||
if !witness.is_zero() {
|
||||
// Disband Alliance by removing all members and returning deposits.
|
||||
// Veto and remove all active proposals to avoid any unexpected behavior from
|
||||
// actionable items managed outside of the pallet. Items managed within the pallet,
|
||||
// like `UnscrupulousWebsites`, are left for the new Alliance to clean up or keep.
|
||||
|
||||
ensure!(
|
||||
T::ProposalProvider::proposals_count() <= witness.proposals,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
ensure!(
|
||||
Self::votable_members_count() <= witness.voting_members,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
ensure!(
|
||||
Self::ally_members_count() <= witness.ally_members,
|
||||
Error::<T, I>::BadWitness
|
||||
);
|
||||
|
||||
let mut proposals = T::ProposalProvider::proposals();
|
||||
for hash in proposals.iter() {
|
||||
T::ProposalProvider::veto_proposal(*hash);
|
||||
}
|
||||
|
||||
let mut members = Self::votable_members();
|
||||
T::MembershipChanged::change_members_sorted(&[], &members, &[]);
|
||||
|
||||
members.append(&mut Self::members_of(MemberRole::Ally));
|
||||
for member in members.iter() {
|
||||
if let Some(deposit) = DepositOf::<T, I>::take(&member) {
|
||||
let err_amount = T::Currency::unreserve(&member, deposit);
|
||||
debug_assert!(err_amount.is_zero());
|
||||
}
|
||||
}
|
||||
|
||||
Members::<T, I>::remove(&MemberRole::Founder);
|
||||
Members::<T, I>::remove(&MemberRole::Fellow);
|
||||
Members::<T, I>::remove(&MemberRole::Ally);
|
||||
|
||||
members.sort();
|
||||
proposals.sort();
|
||||
Self::deposit_event(Event::AllianceDisbanded { members, proposals });
|
||||
}
|
||||
|
||||
if founders.is_empty() {
|
||||
ensure!(fellows.is_empty() && allies.is_empty(), Error::<T, I>::FoundersMissing);
|
||||
// new members set not provided.
|
||||
return Ok(())
|
||||
}
|
||||
ensure!(!Self::is_initialized(), Error::<T, I>::AllianceAlreadyInitialized);
|
||||
|
||||
let mut founders: BoundedVec<T::AccountId, T::MaxMembersCount> =
|
||||
@@ -665,9 +750,11 @@ pub mod pallet {
|
||||
T::InitializeMembers::initialize_members(&voteable_members);
|
||||
|
||||
log::debug!(
|
||||
target: "runtime::alliance",
|
||||
target: LOG_TARGET,
|
||||
"Initialize alliance founders: {:?}, fellows: {:?}, allies: {:?}",
|
||||
founders, fellows, allies
|
||||
founders,
|
||||
fellows,
|
||||
allies
|
||||
);
|
||||
|
||||
Self::deposit_event(Event::MembersInitialized {
|
||||
@@ -913,7 +1000,9 @@ pub mod pallet {
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Check if the Alliance has been initialized.
|
||||
fn is_initialized() -> bool {
|
||||
Self::has_member(MemberRole::Founder) || Self::has_member(MemberRole::Fellow)
|
||||
Self::has_member(MemberRole::Founder) ||
|
||||
Self::has_member(MemberRole::Fellow) ||
|
||||
Self::has_member(MemberRole::Ally)
|
||||
}
|
||||
|
||||
/// Check if a given role has any members.
|
||||
@@ -957,13 +1046,36 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Self::is_founder(who) || Self::is_fellow(who)
|
||||
}
|
||||
|
||||
/// Count of ally members.
|
||||
fn ally_members_count() -> u32 {
|
||||
Members::<T, I>::decode_len(MemberRole::Ally).unwrap_or(0) as u32
|
||||
}
|
||||
|
||||
/// Count of all members who have voting rights.
|
||||
fn votable_members_count() -> u32 {
|
||||
Members::<T, I>::decode_len(MemberRole::Founder)
|
||||
.unwrap_or(0)
|
||||
.saturating_add(Members::<T, I>::decode_len(MemberRole::Fellow).unwrap_or(0)) as u32
|
||||
}
|
||||
|
||||
/// Get all members of a given role.
|
||||
fn members_of(role: MemberRole) -> Vec<T::AccountId> {
|
||||
Members::<T, I>::get(role).into_inner()
|
||||
}
|
||||
|
||||
/// Collect all members who have voting rights into one list.
|
||||
fn votable_members_sorted() -> Vec<T::AccountId> {
|
||||
let mut founders = Members::<T, I>::get(MemberRole::Founder).into_inner();
|
||||
let mut fellows = Members::<T, I>::get(MemberRole::Fellow).into_inner();
|
||||
fn votable_members() -> Vec<T::AccountId> {
|
||||
let mut founders = Self::members_of(MemberRole::Founder);
|
||||
let mut fellows = Self::members_of(MemberRole::Fellow);
|
||||
founders.append(&mut fellows);
|
||||
founders.sort();
|
||||
founders.into()
|
||||
founders
|
||||
}
|
||||
|
||||
/// Collect all members who have voting rights into one sorted list.
|
||||
fn votable_members_sorted() -> Vec<T::AccountId> {
|
||||
let mut members = Self::votable_members();
|
||||
members.sort();
|
||||
members
|
||||
}
|
||||
|
||||
/// Add a user to the sorted alliance member set.
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//! Test utilities
|
||||
|
||||
pub use sp_core::H256;
|
||||
use sp_runtime::traits::Hash;
|
||||
pub use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
@@ -196,6 +197,14 @@ impl ProposalProvider<u64, H256, Call> for AllianceProposalProvider {
|
||||
fn proposal_of(proposal_hash: H256) -> Option<Call> {
|
||||
AllianceMotion::proposal_of(proposal_hash)
|
||||
}
|
||||
|
||||
fn proposals() -> Vec<H256> {
|
||||
AllianceMotion::proposals().into_inner()
|
||||
}
|
||||
|
||||
fn proposals_count() -> u32 {
|
||||
pallet_collective::Proposals::<Test, AllianceCollective>::decode_len().unwrap_or(0) as u32
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -254,7 +263,17 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![(1, 50), (2, 50), (3, 50), (4, 50), (5, 30), (6, 50), (7, 50)],
|
||||
balances: vec![
|
||||
(1, 50),
|
||||
(2, 50),
|
||||
(3, 50),
|
||||
(4, 50),
|
||||
(5, 30),
|
||||
(6, 50),
|
||||
(7, 50),
|
||||
(8, 50),
|
||||
(9, 50),
|
||||
],
|
||||
}
|
||||
.assimilate_storage(&mut t)
|
||||
.unwrap();
|
||||
@@ -296,6 +315,10 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(5), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(Origin::signed(1), 0, 5, Judgement::KnownGood));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(6), Box::new(info.clone())));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(8), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(Origin::signed(1), 0, 8, Judgement::KnownGood));
|
||||
assert_ok!(Identity::set_identity(Origin::signed(9), Box::new(info.clone())));
|
||||
assert_ok!(Identity::provide_judgement(Origin::signed(1), 0, 9, Judgement::KnownGood));
|
||||
|
||||
// Joining before init should fail.
|
||||
assert_noop!(
|
||||
@@ -303,7 +326,13 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
Error::<Test, ()>::AllianceNotYetInitialized
|
||||
);
|
||||
|
||||
assert_ok!(Alliance::init_members(Origin::root(), vec![1, 2], vec![3], vec![]));
|
||||
assert_ok!(Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![1, 2],
|
||||
vec![3],
|
||||
vec![],
|
||||
Default::default()
|
||||
));
|
||||
|
||||
System::set_block_number(1);
|
||||
});
|
||||
@@ -323,10 +352,25 @@ pub fn test_cid() -> Cid {
|
||||
Cid::new_v0(&*result)
|
||||
}
|
||||
|
||||
pub fn make_proposal(value: u64) -> Call {
|
||||
Call::System(frame_system::Call::remark { remark: value.encode() })
|
||||
pub fn make_remark_proposal(value: u64) -> (Call, u32, H256) {
|
||||
make_proposal(Call::System(frame_system::Call::remark { remark: value.encode() }))
|
||||
}
|
||||
|
||||
pub fn make_set_rule_proposal(rule: Cid) -> Call {
|
||||
Call::Alliance(pallet_alliance::Call::set_rule { rule })
|
||||
pub fn make_set_rule_proposal(rule: Cid) -> (Call, u32, H256) {
|
||||
make_proposal(Call::Alliance(pallet_alliance::Call::set_rule { rule }))
|
||||
}
|
||||
|
||||
pub fn make_kick_member_proposal(who: u64) -> (Call, u32, H256) {
|
||||
make_proposal(Call::Alliance(pallet_alliance::Call::kick_member { who }))
|
||||
}
|
||||
|
||||
pub fn make_proposal(proposal: Call) -> (Call, u32, H256) {
|
||||
let len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let hash = BlakeTwo256::hash_of(&proposal);
|
||||
(proposal, len, hash)
|
||||
}
|
||||
|
||||
pub fn assert_prev_event(event: Event) {
|
||||
let events = System::events();
|
||||
assert_eq!(events.get(events.len() - 2).expect("events expected").event, event);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
|
||||
//! Tests for the alliance pallet.
|
||||
|
||||
use sp_runtime::traits::Hash;
|
||||
|
||||
use frame_support::{assert_noop, assert_ok, error::BadOrigin, Hashable};
|
||||
use frame_support::{assert_noop, assert_ok, error::BadOrigin};
|
||||
use frame_system::{EventRecord, Phase};
|
||||
|
||||
use super::*;
|
||||
@@ -27,12 +25,156 @@ use crate::mock::*;
|
||||
|
||||
type AllianceMotionEvent = pallet_collective::Event<Test, pallet_collective::Instance1>;
|
||||
|
||||
#[test]
|
||||
fn force_set_members_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// ensure alliance is set
|
||||
assert_eq!(Alliance::votable_members_sorted(), vec![1, 2, 3]);
|
||||
|
||||
// creating and proposing proposals
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
assert_ok!(Alliance::propose(Origin::signed(1), 3, Box::new(proposal), proposal_len));
|
||||
|
||||
let (k_proposal, k_proposal_len, k_hash) = make_kick_member_proposal(2);
|
||||
assert_ok!(Alliance::propose(Origin::signed(1), 3, Box::new(k_proposal), k_proposal_len));
|
||||
let mut proposals = vec![hash, k_hash];
|
||||
|
||||
// give a retirement notice to check later a retiring member not removed
|
||||
assert_ok!(Alliance::give_retirement_notice(Origin::signed(2)));
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
|
||||
// join alliance and reserve funds
|
||||
assert_eq!(Balances::free_balance(9), 40);
|
||||
assert_ok!(Alliance::join_alliance(Origin::signed(9)));
|
||||
assert_eq!(Alliance::deposit_of(9), Some(25));
|
||||
assert_eq!(Balances::free_balance(9), 15);
|
||||
assert!(Alliance::is_member_of(&9, MemberRole::Ally));
|
||||
|
||||
// ensure proposal is listed as active proposal
|
||||
assert_eq!(<Test as Config>::ProposalProvider::proposals(), proposals);
|
||||
assert_eq!(<Test as Config>::ProposalProvider::proposals_count(), 2);
|
||||
|
||||
// fails without root
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::signed(1),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
Default::default()
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
|
||||
// nothing to do, witness data is default, new members not provided.
|
||||
assert_ok!(Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
Default::default()
|
||||
));
|
||||
|
||||
// alliance must be reset first, no witness data.
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![8],
|
||||
vec![],
|
||||
vec![],
|
||||
Default::default()
|
||||
),
|
||||
Error::<Test, ()>::AllianceAlreadyInitialized,
|
||||
);
|
||||
|
||||
// wrong witness data checks
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
ForceSetWitness::new(1, 3, 1)
|
||||
),
|
||||
Error::<Test, ()>::BadWitness,
|
||||
);
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
ForceSetWitness::new(2, 1, 1)
|
||||
),
|
||||
Error::<Test, ()>::BadWitness,
|
||||
);
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
ForceSetWitness::new(1, 3, 0)
|
||||
),
|
||||
Error::<Test, ()>::BadWitness,
|
||||
);
|
||||
|
||||
// founders missing, other members given
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![],
|
||||
vec![4],
|
||||
vec![2],
|
||||
ForceSetWitness::new(2, 3, 1)
|
||||
),
|
||||
Error::<Test, ()>::FoundersMissing,
|
||||
);
|
||||
|
||||
// success call
|
||||
assert_ok!(Alliance::force_set_members(
|
||||
Origin::root(),
|
||||
vec![8, 5],
|
||||
vec![4],
|
||||
vec![2],
|
||||
ForceSetWitness::new(2, 3, 1)
|
||||
));
|
||||
|
||||
// assert new set of voting members
|
||||
assert_eq!(Alliance::votable_members_sorted(), vec![4, 5, 8]);
|
||||
// assert new ally member
|
||||
assert!(Alliance::is_ally(&2));
|
||||
// assert a retiring member from previous Alliance not removed
|
||||
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
|
||||
// assert old alliance disband.
|
||||
assert!(!Alliance::is_member(&1));
|
||||
assert!(!Alliance::is_member(&3));
|
||||
assert!(!Alliance::is_member(&9));
|
||||
// deposit unreserved
|
||||
assert_eq!(Balances::free_balance(9), 40);
|
||||
// all proposals are removed
|
||||
assert_eq!(<Test as Config>::ProposalProvider::proposals(), vec![]);
|
||||
assert_eq!(<Test as Config>::ProposalProvider::proposals_count(), 0);
|
||||
|
||||
// assert events
|
||||
proposals.sort();
|
||||
assert_prev_event(mock::Event::Alliance(crate::Event::AllianceDisbanded {
|
||||
members: vec![1, 3, 9],
|
||||
proposals,
|
||||
}));
|
||||
|
||||
System::assert_last_event(mock::Event::Alliance(crate::Event::MembersInitialized {
|
||||
founders: vec![5, 8],
|
||||
fellows: vec![4],
|
||||
allies: vec![2],
|
||||
}));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn propose_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let proposal = make_proposal(42);
|
||||
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
|
||||
// only votable member can propose proposal, 4 is ally not have vote rights
|
||||
assert_noop!(
|
||||
@@ -67,9 +209,7 @@ fn propose_works() {
|
||||
#[test]
|
||||
fn vote_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let proposal = make_proposal(42);
|
||||
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
assert_ok!(Alliance::propose(
|
||||
Origin::signed(1),
|
||||
3,
|
||||
@@ -103,9 +243,7 @@ fn vote_works() {
|
||||
#[test]
|
||||
fn veto_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let proposal = make_proposal(42);
|
||||
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let hash: H256 = proposal.blake2_256().into();
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
assert_ok!(Alliance::propose(
|
||||
Origin::signed(1),
|
||||
3,
|
||||
@@ -119,9 +257,7 @@ fn veto_works() {
|
||||
);
|
||||
|
||||
let cid = test_cid();
|
||||
let vetoable_proposal = make_set_rule_proposal(cid);
|
||||
let vetoable_proposal_len: u32 = vetoable_proposal.using_encoded(|p| p.len() as u32);
|
||||
let vetoable_hash: H256 = vetoable_proposal.blake2_256().into();
|
||||
let (vetoable_proposal, vetoable_proposal_len, vetoable_hash) = make_set_rule_proposal(cid);
|
||||
assert_ok!(Alliance::propose(
|
||||
Origin::signed(1),
|
||||
3,
|
||||
@@ -163,10 +299,8 @@ fn veto_works() {
|
||||
#[test]
|
||||
fn close_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let proposal = make_proposal(42);
|
||||
let proposal_len: u32 = proposal.using_encoded(|p| p.len() as u32);
|
||||
let (proposal, proposal_len, hash) = make_remark_proposal(42);
|
||||
let proposal_weight = proposal.get_dispatch_info().weight;
|
||||
let hash = BlakeTwo256::hash_of(&proposal);
|
||||
assert_ok!(Alliance::propose(
|
||||
Origin::signed(1),
|
||||
3,
|
||||
@@ -452,9 +586,18 @@ fn retire_works() {
|
||||
fn assert_powerless(user: Origin) {
|
||||
//vote / veto with a valid propsal
|
||||
let cid = test_cid();
|
||||
let proposal = make_proposal(42);
|
||||
let (proposal, _, _) = make_kick_member_proposal(42);
|
||||
|
||||
assert_noop!(Alliance::init_members(user.clone(), vec![], vec![], vec![]), BadOrigin);
|
||||
assert_noop!(
|
||||
Alliance::force_set_members(
|
||||
user.clone(),
|
||||
vec![],
|
||||
vec![],
|
||||
vec![],
|
||||
ForceSetWitness { voting_members: 3, ..Default::default() }
|
||||
),
|
||||
BadOrigin
|
||||
);
|
||||
|
||||
assert_noop!(Alliance::set_rule(user.clone(), cid.clone()), BadOrigin);
|
||||
|
||||
|
||||
@@ -93,3 +93,34 @@ impl Cid {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Witness data for the `force_set_members` call.
|
||||
/// Relevant only if executed on an initialized alliance to reset it.
|
||||
#[derive(
|
||||
Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo, Default,
|
||||
)]
|
||||
pub struct ForceSetWitness {
|
||||
/// Number of active proposals which will be vetoed and removed.
|
||||
#[codec(compact)]
|
||||
pub(super) proposals: u32,
|
||||
/// Total number of voting members in the current alliance.
|
||||
#[codec(compact)]
|
||||
pub(super) voting_members: u32,
|
||||
/// Total number of ally members in the current alliance.
|
||||
#[codec(compact)]
|
||||
pub(super) ally_members: u32,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
impl ForceSetWitness {
|
||||
// Creates new ForceSetWitness.
|
||||
pub(super) fn new(proposals: u32, voting_members: u32, ally_members: u32) -> Self {
|
||||
Self { proposals, voting_members, ally_members }
|
||||
}
|
||||
}
|
||||
|
||||
impl ForceSetWitness {
|
||||
pub(super) fn is_zero(self) -> bool {
|
||||
self == Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! DATE: 2022-09-01, 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
|
||||
|
||||
@@ -53,7 +53,7 @@ pub trait WeightInfo {
|
||||
fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight;
|
||||
fn close_disapproved(x: u32, y: u32, p: u32, ) -> Weight;
|
||||
fn close_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight;
|
||||
fn init_members(x: u32, y: u32, z: u32, ) -> Weight;
|
||||
fn force_set_members(x: u32, y: u32, z: u32, p: u32, c: u32, m: u32, ) -> Weight;
|
||||
fn set_rule() -> Weight;
|
||||
fn announce() -> Weight;
|
||||
fn remove_announcement() -> Weight;
|
||||
@@ -79,16 +79,14 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(22_575_000 as RefTimeWeight)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_ref_time(11_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight))
|
||||
// Standard Error: 23_000
|
||||
.saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(37_864_000 as RefTimeWeight)
|
||||
// Standard Error: 28_000
|
||||
.saturating_add(Weight::from_ref_time(69_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(90_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(66_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(216_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -96,12 +94,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// 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 {
|
||||
Weight::from_ref_time(45_486_000 as RefTimeWeight)
|
||||
// Standard Error: 29_000
|
||||
.saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn vote(_x: u32, y: u32, ) -> Weight {
|
||||
Weight::from_ref_time(46_813_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(128_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(125_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -111,9 +107,9 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: AllianceMotion Voting (r:0 w:1)
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn veto(p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(35_296_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(171_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
Weight::from_ref_time(35_316_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(172_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -126,13 +122,13 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(39_252_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(36_245_000 as RefTimeWeight)
|
||||
// Standard Error: 18_000
|
||||
.saturating_add(Weight::from_ref_time(75_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(336_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(109_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(170_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(178_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -145,12 +141,16 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(50_357_000 as RefTimeWeight)
|
||||
fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(48_088_000 as RefTimeWeight)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight))
|
||||
// Standard Error: 16_000
|
||||
.saturating_add(Weight::from_ref_time(194_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(103_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(204_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(201_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -164,11 +164,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(41_258_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(43_374_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(101_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(111_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(182_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -182,45 +182,65 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(40_490_000 as RefTimeWeight)
|
||||
// Standard Error: 16_000
|
||||
.saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(42_798_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(195_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Members (r:2 w:3)
|
||||
// Storage: AllianceMotion Members (r:1 w:1)
|
||||
/// The range of component `x` is `[2, 10]`.
|
||||
// Storage: AllianceMotion Proposals (r:1 w:1)
|
||||
// Storage: Alliance Members (r:3 w:3)
|
||||
// Storage: Alliance DepositOf (r:200 w:199)
|
||||
// Storage: System Account (r:199 w:199)
|
||||
// Storage: AllianceMotion Voting (r:0 w:100)
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
// Storage: AllianceMotion ProposalOf (r:0 w:100)
|
||||
/// The range of component `x` is `[1, 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 {
|
||||
Weight::from_ref_time(35_186_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(127_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight))
|
||||
/// The range of component `p` is `[0, 100]`.
|
||||
/// The range of component `c` is `[0, 100]`.
|
||||
/// The range of component `m` is `[0, 100]`.
|
||||
fn force_set_members(x: u32, y: u32, z: u32, p: u32, c: u32, m: u32, ) -> Weight {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
// Standard Error: 221_000
|
||||
.saturating_add(Weight::from_ref_time(1_294_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 23_000
|
||||
.saturating_add(Weight::from_ref_time(231_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(9_371_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(11_673_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(11_581_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight)))
|
||||
.saturating_add(T::DbWeight::get().reads((2 as RefTimeWeight).saturating_mul(m as RefTimeWeight)))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(p as RefTimeWeight)))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight)))
|
||||
.saturating_add(T::DbWeight::get().writes((2 as RefTimeWeight).saturating_mul(m as RefTimeWeight)))
|
||||
}
|
||||
// Storage: Alliance Rule (r:0 w:1)
|
||||
fn set_rule() -> Weight {
|
||||
Weight::from_ref_time(18_189_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(18_721_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Announcements (r:1 w:1)
|
||||
fn announce() -> Weight {
|
||||
Weight::from_ref_time(21_106_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(21_887_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Announcements (r:1 w:1)
|
||||
fn remove_announcement() -> Weight {
|
||||
Weight::from_ref_time(22_208_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(23_052_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -229,14 +249,14 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Alliance DepositOf (r:0 w:1)
|
||||
fn join_alliance() -> Weight {
|
||||
Weight::from_ref_time(53_771_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(54_504_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Members (r:4 w:1)
|
||||
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
|
||||
fn nominate_ally() -> Weight {
|
||||
Weight::from_ref_time(41_912_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(42_601_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -245,7 +265,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
fn elevate_ally() -> Weight {
|
||||
Weight::from_ref_time(36_811_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(37_704_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -255,7 +275,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
// Storage: Alliance RetiringMembers (r:0 w:1)
|
||||
fn give_retirement_notice() -> Weight {
|
||||
Weight::from_ref_time(41_079_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(40_859_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight))
|
||||
}
|
||||
@@ -264,7 +284,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Alliance DepositOf (r:1 w:1)
|
||||
// Storage: System Account (r:1 w:1)
|
||||
fn retire() -> Weight {
|
||||
Weight::from_ref_time(42_703_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(43_447_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -275,7 +295,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
fn kick_member() -> Weight {
|
||||
Weight::from_ref_time(61_370_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(61_718_000 as RefTimeWeight)
|
||||
.saturating_add(T::DbWeight::get().reads(6 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(5 as RefTimeWeight))
|
||||
}
|
||||
@@ -284,11 +304,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
Weight::from_ref_time(359_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(1_385_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(1_376_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(112_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
|
||||
}
|
||||
@@ -298,10 +318,10 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// The range of component `l` is `[1, 255]`.
|
||||
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
// Standard Error: 153_000
|
||||
.saturating_add(Weight::from_ref_time(21_484_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 59_000
|
||||
.saturating_add(Weight::from_ref_time(3_772_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
// Standard Error: 145_000
|
||||
.saturating_add(Weight::from_ref_time(20_932_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 56_000
|
||||
.saturating_add(Weight::from_ref_time(3_649_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as RefTimeWeight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as RefTimeWeight))
|
||||
}
|
||||
@@ -318,16 +338,14 @@ 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 {
|
||||
Weight::from_ref_time(22_575_000 as RefTimeWeight)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_ref_time(11_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight))
|
||||
// Standard Error: 23_000
|
||||
.saturating_add(Weight::from_ref_time(158_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn propose_proposed(_b: u32, x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(37_864_000 as RefTimeWeight)
|
||||
// Standard Error: 28_000
|
||||
.saturating_add(Weight::from_ref_time(69_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(90_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(66_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(216_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -335,12 +353,10 @@ 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 {
|
||||
Weight::from_ref_time(45_486_000 as RefTimeWeight)
|
||||
// Standard Error: 29_000
|
||||
.saturating_add(Weight::from_ref_time(78_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn vote(_x: u32, y: u32, ) -> Weight {
|
||||
Weight::from_ref_time(46_813_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(128_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(125_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -350,9 +366,9 @@ impl WeightInfo for () {
|
||||
// Storage: AllianceMotion Voting (r:0 w:1)
|
||||
/// The range of component `p` is `[1, 100]`.
|
||||
fn veto(p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(35_296_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(171_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
Weight::from_ref_time(35_316_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(172_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -365,13 +381,13 @@ 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 {
|
||||
Weight::from_ref_time(39_252_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(36_245_000 as RefTimeWeight)
|
||||
// Standard Error: 18_000
|
||||
.saturating_add(Weight::from_ref_time(75_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(336_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(107_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(109_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(170_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(178_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -384,12 +400,16 @@ 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 {
|
||||
Weight::from_ref_time(50_357_000 as RefTimeWeight)
|
||||
fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(48_088_000 as RefTimeWeight)
|
||||
// Standard Error: 0
|
||||
.saturating_add(Weight::from_ref_time(1_000 as RefTimeWeight).scalar_saturating_mul(b as RefTimeWeight))
|
||||
// Standard Error: 16_000
|
||||
.saturating_add(Weight::from_ref_time(194_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(103_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(204_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(201_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -403,11 +423,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 {
|
||||
Weight::from_ref_time(41_258_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(43_374_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(101_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(111_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(186_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(182_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
@@ -421,45 +441,65 @@ 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 {
|
||||
Weight::from_ref_time(40_490_000 as RefTimeWeight)
|
||||
// Standard Error: 16_000
|
||||
.saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
fn close_approved(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
|
||||
Weight::from_ref_time(42_798_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(93_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(87_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(195_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(192_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Members (r:2 w:3)
|
||||
// Storage: AllianceMotion Members (r:1 w:1)
|
||||
/// The range of component `x` is `[2, 10]`.
|
||||
// Storage: AllianceMotion Proposals (r:1 w:1)
|
||||
// Storage: Alliance Members (r:3 w:3)
|
||||
// Storage: Alliance DepositOf (r:200 w:199)
|
||||
// Storage: System Account (r:199 w:199)
|
||||
// Storage: AllianceMotion Voting (r:0 w:100)
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
// Storage: AllianceMotion ProposalOf (r:0 w:100)
|
||||
/// The range of component `x` is `[1, 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 {
|
||||
Weight::from_ref_time(35_186_000 as RefTimeWeight)
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(161_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(127_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight))
|
||||
/// The range of component `p` is `[0, 100]`.
|
||||
/// The range of component `c` is `[0, 100]`.
|
||||
/// The range of component `m` is `[0, 100]`.
|
||||
fn force_set_members(x: u32, y: u32, z: u32, p: u32, c: u32, m: u32, ) -> Weight {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
// Standard Error: 221_000
|
||||
.saturating_add(Weight::from_ref_time(1_294_000 as RefTimeWeight).scalar_saturating_mul(x as RefTimeWeight))
|
||||
// Standard Error: 23_000
|
||||
.saturating_add(Weight::from_ref_time(231_000 as RefTimeWeight).scalar_saturating_mul(y as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(115_000 as RefTimeWeight).scalar_saturating_mul(z as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(9_371_000 as RefTimeWeight).scalar_saturating_mul(p as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(11_673_000 as RefTimeWeight).scalar_saturating_mul(c as RefTimeWeight))
|
||||
// Standard Error: 21_000
|
||||
.saturating_add(Weight::from_ref_time(11_581_000 as RefTimeWeight).scalar_saturating_mul(m as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight)))
|
||||
.saturating_add(RocksDbWeight::get().reads((2 as RefTimeWeight).saturating_mul(m as RefTimeWeight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(p as RefTimeWeight)))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(c as RefTimeWeight)))
|
||||
.saturating_add(RocksDbWeight::get().writes((2 as RefTimeWeight).saturating_mul(m as RefTimeWeight)))
|
||||
}
|
||||
// Storage: Alliance Rule (r:0 w:1)
|
||||
fn set_rule() -> Weight {
|
||||
Weight::from_ref_time(18_189_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(18_721_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Announcements (r:1 w:1)
|
||||
fn announce() -> Weight {
|
||||
Weight::from_ref_time(21_106_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(21_887_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Announcements (r:1 w:1)
|
||||
fn remove_announcement() -> Weight {
|
||||
Weight::from_ref_time(22_208_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(23_052_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -468,14 +508,14 @@ impl WeightInfo for () {
|
||||
// Storage: System Account (r:1 w:1)
|
||||
// Storage: Alliance DepositOf (r:0 w:1)
|
||||
fn join_alliance() -> Weight {
|
||||
Weight::from_ref_time(53_771_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(54_504_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as RefTimeWeight))
|
||||
}
|
||||
// Storage: Alliance Members (r:4 w:1)
|
||||
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
|
||||
fn nominate_ally() -> Weight {
|
||||
Weight::from_ref_time(41_912_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(42_601_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as RefTimeWeight))
|
||||
}
|
||||
@@ -484,7 +524,7 @@ impl WeightInfo for () {
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
fn elevate_ally() -> Weight {
|
||||
Weight::from_ref_time(36_811_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(37_704_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -494,7 +534,7 @@ impl WeightInfo for () {
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
// Storage: Alliance RetiringMembers (r:0 w:1)
|
||||
fn give_retirement_notice() -> Weight {
|
||||
Weight::from_ref_time(41_079_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(40_859_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(5 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight))
|
||||
}
|
||||
@@ -503,7 +543,7 @@ impl WeightInfo for () {
|
||||
// Storage: Alliance DepositOf (r:1 w:1)
|
||||
// Storage: System Account (r:1 w:1)
|
||||
fn retire() -> Weight {
|
||||
Weight::from_ref_time(42_703_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(43_447_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(4 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as RefTimeWeight))
|
||||
}
|
||||
@@ -514,7 +554,7 @@ impl WeightInfo for () {
|
||||
// Storage: AllianceMotion Members (r:0 w:1)
|
||||
// Storage: AllianceMotion Prime (r:0 w:1)
|
||||
fn kick_member() -> Weight {
|
||||
Weight::from_ref_time(61_370_000 as RefTimeWeight)
|
||||
Weight::from_ref_time(61_718_000 as RefTimeWeight)
|
||||
.saturating_add(RocksDbWeight::get().reads(6 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(5 as RefTimeWeight))
|
||||
}
|
||||
@@ -523,11 +563,11 @@ impl WeightInfo for () {
|
||||
/// 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 {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
Weight::from_ref_time(359_000 as RefTimeWeight)
|
||||
// Standard Error: 2_000
|
||||
.saturating_add(Weight::from_ref_time(1_385_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(1_376_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 1_000
|
||||
.saturating_add(Weight::from_ref_time(119_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(Weight::from_ref_time(112_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight))
|
||||
}
|
||||
@@ -537,10 +577,10 @@ impl WeightInfo for () {
|
||||
/// The range of component `l` is `[1, 255]`.
|
||||
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight {
|
||||
Weight::from_ref_time(0 as RefTimeWeight)
|
||||
// Standard Error: 153_000
|
||||
.saturating_add(Weight::from_ref_time(21_484_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 59_000
|
||||
.saturating_add(Weight::from_ref_time(3_772_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
// Standard Error: 145_000
|
||||
.saturating_add(Weight::from_ref_time(20_932_000 as RefTimeWeight).scalar_saturating_mul(n as RefTimeWeight))
|
||||
// Standard Error: 56_000
|
||||
.saturating_add(Weight::from_ref_time(3_649_000 as RefTimeWeight).scalar_saturating_mul(l as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as RefTimeWeight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as RefTimeWeight))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user