Allow Alliance Fellows to Give Up Voting Rights (#12730)

* allow fellows to abdicate voting rights

* rename founders to founding fellows, give equal power

* Drop FoundingFellow role and veto call (#12762)

* drop FoundingFellow role

* drop veto call

* Storage migration to remove founder role (#12766)

* storage migration to remove founder role

* skip migration if no members

* truncate the final fellows set if overflows

* change log - action order

* MemberAbdicated -> FellowAbdicated

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
This commit is contained in:
joe petrowski
2022-11-25 15:52:26 +01:00
committed by GitHub
parent 7ed2bc7258
commit bcea0d7e7f
10 changed files with 614 additions and 775 deletions
-4
View File
@@ -97,10 +97,6 @@ impl ProposalProvider<AccountId, Hash, RuntimeCall> for AllianceProposalProvider
AllianceMotion::do_vote(who, proposal, index, approve)
}
fn veto_proposal(proposal_hash: Hash) -> u32 {
AllianceMotion::do_disapprove_proposal(proposal_hash)
}
fn close_proposal(
proposal_hash: Hash,
proposal_index: ProposalIndex,
+1 -3
View File
@@ -1574,8 +1574,7 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
}
parameter_types! {
pub const MaxFounders: u32 = 10;
pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFounders::get();
pub const MaxFellows: u32 = AllianceMaxMembers::get();
pub const MaxAllies: u32 = 100;
pub const AllyDeposit: Balance = 10 * DOLLARS;
pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS);
@@ -1606,7 +1605,6 @@ impl pallet_alliance::Config for Runtime {
type IdentityVerifier = ();
type ProposalProvider = AllianceProposalProvider;
type MaxProposals = AllianceMaxProposals;
type MaxFounders = MaxFounders;
type MaxFellows = MaxFellows;
type MaxAllies = MaxAllies;
type MaxUnscrupulousItems = ConstU32<100>;
+15 -19
View File
@@ -1,7 +1,7 @@
# Alliance Pallet
The Alliance Pallet provides a collective that curates a list of accounts and URLs, deemed by
the voting members to be unscrupulous actors. The alliance
the voting members to be unscrupulous actors. The Alliance
- provides a set of ethics against bad behavior, and
- provides recognition and influence for those teams that contribute something back to the
@@ -19,19 +19,17 @@ to update the Alliance's rule and make announcements.
### Terminology
- Rule: The IPFS CID (hash) of the Alliance rules for the community to read and the Alliance
members to enforce. Similar to a Code of Conduct.
members to enforce. Similar to a Charter or Code of Conduct.
- Announcement: An IPFS CID of some content that the Alliance want to announce.
- Member: An account that is already in the group of the Alliance, including three types:
Founder, Fellow, or Ally. A member can also be kicked by the `MembershipManager` origin or
retire by itself.
- Founder: An account who is initiated by Root with normal voting rights for basic motions and
special veto rights for rule change and Ally elevation motions.
- Fellow: An account who is elevated from Ally by Founders and other Fellows.
- Ally: An account who would like to join the alliance. To become a voting member, Fellow or
Founder, it will need approval from the `MembershipManager` origin. Any account can join as an
Ally either by placing a deposit or by nomination from a voting member.
- Unscrupulous List: A list of bad websites and addresses, items can be added or removed by
Founders and Fellows.
Fellow, or Ally. A member can also be kicked by the `MembershipManager` origin
or retire by itself.
- Fellow: An account who is elevated from Ally by other Fellows.
- Ally: An account who would like to join the Alliance. To become a voting member (Fellow), it
will need approval from the `MembershipManager` origin. Any account can join as an Ally either
by placing a deposit or by nomination from a voting member.
- Unscrupulous List: A list of bad websites and addresses; items can be added or removed by
voting members.
## Interface
@@ -43,10 +41,11 @@ to update the Alliance's rule and make announcements.
#### For Members (All)
- `give_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)
#### For Voting Members
- `propose` - Propose a motion.
- `vote` - Vote on a motion.
@@ -59,12 +58,9 @@ to update the Alliance's rule and make announcements.
- `add_unscrupulous_items` - Add some items, either accounts or websites, to the list of
unscrupulous items.
- `remove_unscrupulous_items` - Remove some items from the list of unscrupulous items.
#### For Members (Only Founders)
- `veto` - Veto on a motion about `set_rule` and `elevate_ally`.
- `abdicate_fellow_status` - Abdicate one's voting rights, demoting themself to Ally.
#### Root Calls
- `init_members` - Initialize the Alliance, onboard founders, fellows, and allies.
- `init_members` - Initialize the Alliance, onboard fellows and allies.
- `disband` - Disband the Alliance, remove all active members and unreserve deposits.
+55 -137
View File
@@ -61,10 +61,6 @@ fn funded_account<T: Config<I>, I: 'static>(name: &'static str, index: u32) -> T
account
}
fn founder<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
funded_account::<T, I>("founder", index)
}
fn fellow<T: Config<I>, I: 'static>(index: u32) -> T::AccountId {
funded_account::<T, I>("fellow", index)
}
@@ -82,10 +78,6 @@ fn generate_unscrupulous_account<T: Config<I>, I: 'static>(index: u32) -> T::Acc
}
fn set_members<T: Config<I>, I: 'static>() {
let founders: BoundedVec<_, T::MaxMembersCount> =
BoundedVec::try_from(vec![founder::<T, I>(1), founder::<T, I>(2)]).unwrap();
Members::<T, I>::insert(MemberRole::Founder, founders.clone());
let fellows: BoundedVec<_, T::MaxMembersCount> =
BoundedVec::try_from(vec![fellow::<T, I>(1), fellow::<T, I>(2)]).unwrap();
fellows.iter().for_each(|who| {
@@ -102,29 +94,24 @@ fn set_members<T: Config<I>, I: 'static>() {
});
Members::<T, I>::insert(MemberRole::Ally, allies);
T::InitializeMembers::initialize_members(&[founders.as_slice(), fellows.as_slice()].concat());
T::InitializeMembers::initialize_members(&[fellows.as_slice()].concat());
}
benchmarks_instance_pallet! {
// This tests when proposal is created and queued as "proposed"
propose_proposed {
let b in 1 .. MAX_BYTES;
let x in 2 .. T::MaxFounders::get();
let y in 0 .. T::MaxFellows::get();
let m in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();
let m = x + y;
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let proposer = founders[0].clone();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let proposer = fellows[0].clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -154,28 +141,21 @@ benchmarks_instance_pallet! {
}
vote {
// We choose 5 (3 founders + 2 fellows) as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let x in 3 .. T::MaxFounders::get();
let y in 2 .. T::MaxFellows::get();
let m = x + y;
// We choose 5 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 5 .. T::MaxFellows::get();
let p = T::MaxProposals::get();
let b = MAX_BYTES;
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let proposer = founders[0].clone();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let proposer = fellows[0].clone();
let mut members = Vec::with_capacity(founders.len() + fellows.len());
members.extend(founders.clone());
members.extend(fellows.clone());
let members = fellows.clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -230,71 +210,21 @@ benchmarks_instance_pallet! {
verify {
}
veto {
let p in 1 .. T::MaxProposals::get();
let m = 3;
let b = MAX_BYTES;
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
// Construct `members`.
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![],
)?;
// Threshold is one less than total members so that two nays will disapprove the vote
let threshold = m - 1;
// Add proposals
let mut last_hash = T::Hash::default();
for i in 0 .. p {
// 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; b as usize])
}.into();
Alliance::<T, I>::propose(
SystemOrigin::Signed(vetor.clone()).into(),
threshold,
Box::new(proposal.clone()),
bytes_in_storage,
)?;
last_hash = T::Hashing::hash_of(&proposal);
}
}: _(SystemOrigin::Signed(vetor), last_hash.clone())
verify {
// The proposal is removed
assert_eq!(T::ProposalProvider::proposal_of(last_hash), None);
}
close_early_disapproved {
// We choose 4 (2 founders + 2 fellows) as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let x in 2 .. T::MaxFounders::get();
let y in 2 .. T::MaxFellows::get();
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();
let m = x + y;
let bytes = 100;
let bytes_in_storage = bytes + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let mut members = Vec::with_capacity(founders.len() + fellows.len());
members.extend(founders.clone());
members.extend(fellows.clone());
let members = fellows.clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -361,25 +291,19 @@ benchmarks_instance_pallet! {
close_early_approved {
let b in 1 .. MAX_BYTES;
// We choose 4 (2 founders + 2 fellows) as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let x in 2 .. T::MaxFounders::get();
let y in 2 .. T::MaxFellows::get();
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();
let m = x + y;
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let mut members = Vec::with_capacity(founders.len() + fellows.len());
members.extend(founders.clone());
members.extend(fellows.clone());
let members = fellows.clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -450,27 +374,20 @@ benchmarks_instance_pallet! {
}
close_disapproved {
// We choose 2 (2 founders / 2 fellows) as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let x in 2 .. T::MaxFounders::get();
let y in 2 .. T::MaxFellows::get();
// We choose 4 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();
let m = x + y;
let bytes = 100;
let bytes_in_storage = bytes + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let mut members = Vec::with_capacity(founders.len() + fellows.len());
members.extend(founders.clone());
members.extend(fellows.clone());
let members = fellows.clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -528,25 +445,19 @@ benchmarks_instance_pallet! {
close_approved {
let b in 1 .. MAX_BYTES;
// We choose 4 (2 founders + 2 fellows) as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let x in 2 .. T::MaxFounders::get();
let y in 2 .. T::MaxFellows::get();
// We choose 4 fellows as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 5 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();
let m = x + y;
let bytes_in_storage = b + size_of::<Cid>() as u32 + 32;
// Construct `members`.
let founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let mut members = Vec::with_capacity(founders.len() + fellows.len());
members.extend(founders.clone());
members.extend(fellows.clone());
let members = fellows.clone();
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
founders,
fellows,
vec![],
)?;
@@ -605,54 +516,48 @@ benchmarks_instance_pallet! {
}
init_members {
// at least 1 founders
let x in 1 .. T::MaxFounders::get();
let y in 0 .. T::MaxFellows::get();
// at least 1 fellow
let m in 1 .. T::MaxFellows::get();
let z in 0 .. T::MaxAllies::get();
let mut founders = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let mut fellows = (0 .. y).map(fellow::<T, I>).collect::<Vec<_>>();
let mut fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let mut allies = (0 .. z).map(ally::<T, I>).collect::<Vec<_>>();
}: _(SystemOrigin::Root, founders.clone(), fellows.clone(), allies.clone())
}: _(SystemOrigin::Root, fellows.clone(), allies.clone())
verify {
founders.sort();
fellows.sort();
allies.sort();
assert_last_event::<T, I>(Event::MembersInitialized {
founders: founders.clone(),
fellows: fellows.clone(),
allies: allies.clone(),
}.into());
assert_eq!(Alliance::<T, I>::members(MemberRole::Founder), founders);
assert_eq!(Alliance::<T, I>::members(MemberRole::Fellow), fellows);
assert_eq!(Alliance::<T, I>::members(MemberRole::Ally), allies);
}
disband {
// at least 1 founders
let x in 1 .. T::MaxFounders::get() + T::MaxFellows::get();
let x in 1 .. T::MaxFellows::get();
let y in 0 .. T::MaxAllies::get();
let z in 0 .. T::MaxMembersCount::get() / 2;
let voting_members = (0 .. x).map(founder::<T, I>).collect::<Vec<_>>();
let fellows = (0 .. x).map(fellow::<T, I>).collect::<Vec<_>>();
let allies = (0 .. y).map(ally::<T, I>).collect::<Vec<_>>();
let witness = DisbandWitness{
voting_members: x,
fellow_members: x,
ally_members: y,
};
// setting the Alliance to disband on the benchmark call
Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
voting_members.clone(),
vec![],
fellows.clone(),
allies.clone(),
)?;
// reserve deposits
let deposit = T::AllyDeposit::get();
for member in voting_members.iter().chain(allies.iter()).take(z as usize) {
for member in fellows.iter().chain(allies.iter()).take(z as usize) {
T::Currency::reserve(&member, deposit)?;
<DepositOf<T, I>>::insert(&member, deposit);
}
@@ -662,7 +567,7 @@ benchmarks_instance_pallet! {
}: _(SystemOrigin::Root, witness)
verify {
assert_last_event::<T, I>(Event::AllianceDisbanded {
voting_members: x,
fellow_members: x,
ally_members: y,
unreserved: cmp::min(z, x + y),
}.into());
@@ -732,22 +637,22 @@ benchmarks_instance_pallet! {
nominate_ally {
set_members::<T, I>();
let founder1 = founder::<T, I>(1);
assert!(Alliance::<T, I>::is_member_of(&founder1, MemberRole::Founder));
let fellow1 = fellow::<T, I>(1);
assert!(Alliance::<T, I>::is_member_of(&fellow1, MemberRole::Fellow));
let outsider = outsider::<T, I>(1);
assert!(!Alliance::<T, I>::is_member(&outsider));
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
let outsider_lookup = T::Lookup::unlookup(outsider.clone());
}: _(SystemOrigin::Signed(founder1.clone()), outsider_lookup)
}: _(SystemOrigin::Signed(fellow1.clone()), outsider_lookup)
verify {
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
assert_eq!(DepositOf::<T, I>::get(&outsider), None); // without a deposit
assert!(!Alliance::<T, I>::has_voting_rights(&outsider)); // allies don't have voting rights
assert_last_event::<T, I>(Event::NewAllyJoined {
ally: outsider,
nominator: Some(founder1),
nominator: Some(fellow1),
reserved: None
}.into());
}
@@ -764,7 +669,7 @@ benchmarks_instance_pallet! {
}: { call.dispatch_bypass_filter(origin)? }
verify {
assert!(!Alliance::<T, I>::is_ally(&ally1));
assert!(Alliance::<T, I>::is_fellow(&ally1));
assert!(Alliance::<T, I>::has_voting_rights(&ally1));
assert_last_event::<T, I>(Event::AllyElevated { ally: ally1 }.into());
}
@@ -772,7 +677,7 @@ benchmarks_instance_pallet! {
set_members::<T, I>();
let fellow2 = fellow::<T, I>(2);
assert!(Alliance::<T, I>::is_fellow(&fellow2));
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
}: _(SystemOrigin::Signed(fellow2.clone()))
verify {
assert!(Alliance::<T, I>::is_member_of(&fellow2, MemberRole::Retiring));
@@ -790,7 +695,7 @@ benchmarks_instance_pallet! {
set_members::<T, I>();
let fellow2 = fellow::<T, I>(2);
assert!(Alliance::<T, I>::is_fellow(&fellow2));
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
assert_eq!(
Alliance::<T, I>::give_retirement_notice(
@@ -885,5 +790,18 @@ benchmarks_instance_pallet! {
assert_last_event::<T, I>(Event::UnscrupulousItemRemoved { items: unscrupulous_list }.into());
}
abdicate_fellow_status {
set_members::<T, I>();
let fellow2 = fellow::<T, I>(2);
assert!(Alliance::<T, I>::has_voting_rights(&fellow2));
}: _(SystemOrigin::Signed(fellow2.clone()))
verify {
assert!(Alliance::<T, I>::is_member_of(&fellow2, MemberRole::Ally));
assert_last_event::<T, I>(
Event::FellowAbdicated {fellow: fellow2}.into()
);
}
impl_benchmark_test_suite!(Alliance, crate::mock::new_bench_ext(), crate::mock::Test);
}
+91 -178
View File
@@ -18,7 +18,7 @@
//! # Alliance Pallet
//!
//! The Alliance Pallet provides a collective that curates a list of accounts and URLs, deemed by
//! the voting members to be unscrupulous actors. The alliance
//! the voting members to be unscrupulous actors. The Alliance
//!
//! - provides a set of ethics against bad behavior, and
//! - provides recognition and influence for those teams that contribute something back to the
@@ -36,19 +36,16 @@
//! ### Terminology
//!
//! - Rule: The IPFS CID (hash) of the Alliance rules for the community to read and the Alliance
//! members to enforce. Similar to a Code of Conduct.
//! members to enforce. Similar to a Charter or Code of Conduct.
//! - Announcement: An IPFS CID of some content that the Alliance want to announce.
//! - Member: An account that is already in the group of the Alliance, including three types:
//! Founder, Fellow, or Ally. A member can also be kicked by the `MembershipManager` origin or
//! retire by itself.
//! - Founder: An account who is initiated by Root with normal voting rights for basic motions and
//! special veto rights for rule change and Ally elevation motions.
//! - Fellow: An account who is elevated from Ally by Founders and other Fellows.
//! - Ally: An account who would like to join the alliance. To become a voting member, Fellow or
//! Founder, it will need approval from the `MembershipManager` origin. Any account can join as an
//! Ally either by placing a deposit or by nomination from a voting member.
//! - Unscrupulous List: A list of bad websites and addresses, items can be added or removed by
//! Founders and Fellows.
//! - Member: An account that is already in the group of the Alliance, including two types: Fellow,
//! or Ally. A member can also be kicked by the `MembershipManager` origin or retire by itself.
//! - Fellow: An account who is elevated from Ally by other Fellows.
//! - Ally: An account who would like to join the Alliance. To become a voting member (Fellow), it
//! will need approval from the `MembershipManager` origin. Any account can join as an Ally either
//! by placing a deposit or by nomination from a voting member.
//! - Unscrupulous List: A list of bad websites and addresses; items can be added or removed by
//! voting members.
//!
//! ## Interface
//!
@@ -64,7 +61,7 @@
//! pass in order to retire.
//! - `retire` - Retire from the Alliance and release the caller's deposit.
//!
//! #### For Members (Founders/Fellows)
//! #### For Voting Members
//!
//! - `propose` - Propose a motion.
//! - `vote` - Vote on a motion.
@@ -77,14 +74,11 @@
//! - `add_unscrupulous_items` - Add some items, either accounts or websites, to the list of
//! unscrupulous items.
//! - `remove_unscrupulous_items` - Remove some items from the list of unscrupulous items.
//!
//! #### For Members (Only Founders)
//!
//! - `veto` - Veto on a motion about `set_rule` and `elevate_ally`.
//! - `abdicate_fellow_status` - Abdicate one's voting rights, demoting themself to Ally.
//!
//! #### Root Calls
//!
//! - `init_members` - Initialize the Alliance, onboard founders, fellows, and allies.
//! - `init_members` - Initialize the Alliance, onboard fellows and allies.
//! - `disband` - Disband the Alliance, remove all active members and unreserve deposits.
#![cfg_attr(not(feature = "std"), no_std)]
@@ -191,10 +185,6 @@ 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,
@@ -210,7 +200,6 @@ pub trait ProposalProvider<AccountId, Hash, Proposal> {
/// The various roles that a member can hold.
#[derive(Copy, Clone, PartialEq, Eq, RuntimeDebug, Encode, Decode, TypeInfo, MaxEncodedLen)]
pub enum MemberRole {
Founder,
Fellow,
Ally,
Retiring,
@@ -282,21 +271,14 @@ pub mod pallet {
/// Maximum number of proposals allowed to be active in parallel.
type MaxProposals: Get<ProposalIndex>;
/// The maximum number of founders supported by the pallet. Used for weight estimation.
///
/// NOTE:
/// + Benchmarks will need to be re-run and weights adjusted if this changes.
/// + This pallet assumes that dependencies keep to the limit without enforcing it.
type MaxFounders: Get<u32>;
/// The maximum number of fellows supported by the pallet. Used for weight estimation.
/// The maximum number of Fellows supported by the pallet. Used for weight estimation.
///
/// NOTE:
/// + Benchmarks will need to be re-run and weights adjusted if this changes.
/// + This pallet assumes that dependencies keep to the limit without enforcing it.
type MaxFellows: Get<u32>;
/// The maximum number of allies supported by the pallet. Used for weight estimation.
/// The maximum number of Allies supported by the pallet. Used for weight estimation.
///
/// NOTE:
/// + Benchmarks will need to be re-run and weights adjusted if this changes.
@@ -319,8 +301,7 @@ pub mod pallet {
#[pallet::constant]
type MaxAnnouncementsCount: Get<u32>;
/// The maximum number of members per member role. Should not exceed the sum of
/// `MaxFounders` and `MaxFellows`.
/// The maximum number of members per member role.
#[pallet::constant]
type MaxMembersCount: Get<u32>;
@@ -344,8 +325,6 @@ pub mod pallet {
NotMember,
/// Account is not an ally.
NotAlly,
/// Account is not a founder.
NotFounder,
/// Account does not have voting rights.
NoVotingRights,
/// Account is already an elevated (fellow) member.
@@ -369,8 +348,6 @@ pub mod pallet {
WithoutGoodIdentityJudgement,
/// The proposal hash is not found.
MissingProposalHash,
/// The proposal is not vetoable.
NotVetoableProposal,
/// The announcement is not found.
MissingAnnouncement,
/// Number of members exceeds `MaxMembersCount`.
@@ -385,8 +362,8 @@ pub mod pallet {
RetirementNoticeNotGiven,
/// Retirement period has not passed.
RetirementPeriodNotPassed,
/// Founders must be provided to initialize the Alliance.
FoundersMissing,
/// Fellows must be provided to initialize the Alliance.
FellowsMissing,
}
#[pallet::event]
@@ -398,12 +375,8 @@ pub mod pallet {
Announced { announcement: Cid },
/// An on-chain announcement has been removed.
AnnouncementRemoved { announcement: Cid },
/// Some accounts have been initialized as members (founders/fellows/allies).
MembersInitialized {
founders: Vec<T::AccountId>,
fellows: Vec<T::AccountId>,
allies: Vec<T::AccountId>,
},
/// Some accounts have been initialized as members (fellows/allies).
MembersInitialized { fellows: Vec<T::AccountId>, allies: Vec<T::AccountId> },
/// An account has been added as an Ally and reserved its deposit.
NewAllyJoined {
ally: T::AccountId,
@@ -423,12 +396,13 @@ pub mod pallet {
/// Accounts or websites have been removed from the list of unscrupulous items.
UnscrupulousItemRemoved { items: Vec<UnscrupulousItemOf<T, I>> },
/// Alliance disbanded. Includes number deleted members and unreserved deposits.
AllianceDisbanded { voting_members: u32, ally_members: u32, unreserved: u32 },
AllianceDisbanded { fellow_members: u32, ally_members: u32, unreserved: u32 },
/// A Fellow abdicated their voting rights. They are now an Ally.
FellowAbdicated { fellow: T::AccountId },
}
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
pub founders: Vec<T::AccountId>,
pub fellows: Vec<T::AccountId>,
pub allies: Vec<T::AccountId>,
pub phantom: PhantomData<(T, I)>,
@@ -437,40 +411,22 @@ pub mod pallet {
#[cfg(feature = "std")]
impl<T: Config<I>, I: 'static> Default for GenesisConfig<T, I> {
fn default() -> Self {
Self {
founders: Vec::new(),
fellows: Vec::new(),
allies: Vec::new(),
phantom: Default::default(),
}
Self { fellows: Vec::new(), allies: Vec::new(), phantom: Default::default() }
}
}
#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
fn build(&self) {
for m in self.founders.iter().chain(self.fellows.iter()).chain(self.allies.iter()) {
for m in self.fellows.iter().chain(self.allies.iter()) {
assert!(Pallet::<T, I>::has_identity(m).is_ok(), "Member does not set identity!");
}
if !self.founders.is_empty() {
assert!(
!Pallet::<T, I>::has_member(MemberRole::Founder),
"Founders are already initialized!"
);
let members: BoundedVec<T::AccountId, T::MaxMembersCount> =
self.founders.clone().try_into().expect("Too many genesis founders");
Members::<T, I>::insert(MemberRole::Founder, members);
}
if !self.fellows.is_empty() {
assert!(
!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);
@@ -481,24 +437,20 @@ pub mod pallet {
"Allies are already initialized!"
);
assert!(
!self.founders.is_empty(),
"Founders must be provided to initialize the Alliance"
!self.fellows.is_empty(),
"Fellows must be provided to initialize the Alliance"
);
let members: BoundedVec<T::AccountId, T::MaxMembersCount> =
self.allies.clone().try_into().expect("Too many genesis allies");
Members::<T, I>::insert(MemberRole::Ally, members);
}
T::InitializeMembers::initialize_members(
&[self.founders.as_slice(), self.fellows.as_slice()].concat(),
)
T::InitializeMembers::initialize_members(self.fellows.as_slice())
}
}
/// The IPFS CID of the alliance rule.
/// Founders and fellows can propose a new rule with a super-majority.
///
/// Any founder has a special one-vote veto right to the rule setting.
/// Fellows can propose a new rule with a super-majority.
#[pallet::storage]
#[pallet::getter(fn rule)]
pub type Rule<T: Config<I>, I: 'static = ()> = StorageValue<_, Cid, OptionQuery>;
@@ -550,11 +502,10 @@ pub mod pallet {
impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Add a new proposal to be voted on.
///
/// Requires the sender to be a founder or fellow.
/// Must be called by a Fellow.
#[pallet::weight(T::WeightInfo::propose_proposed(
*length_bound, // B
T::MaxFounders::get(), // X
T::MaxFellows::get(), // Y
T::MaxFellows::get(), // M
T::MaxProposals::get(), // P2
))]
pub fn propose(
@@ -572,8 +523,8 @@ pub mod pallet {
/// Add an aye or nay vote for the sender to the given proposal.
///
/// Requires the sender to be a founder or fellow.
#[pallet::weight(T::WeightInfo::vote(T::MaxFounders::get(), T::MaxFellows::get()))]
/// Must be called by a Fellow.
#[pallet::weight(T::WeightInfo::vote(T::MaxFellows::get()))]
pub fn vote(
origin: OriginFor<T>,
proposal: T::Hash,
@@ -587,39 +538,18 @@ pub mod pallet {
Ok(())
}
/// Veto a proposal about `set_rule` and `elevate_ally`, close, and remove it from the
/// system, regardless of its current state.
///
/// Must be called by a founder.
#[pallet::weight(T::WeightInfo::veto(T::MaxProposals::get()))]
pub fn veto(origin: OriginFor<T>, proposal_hash: T::Hash) -> DispatchResult {
let proposor = ensure_signed(origin)?;
ensure!(Self::is_founder(&proposor), Error::<T, I>::NotFounder);
let proposal = T::ProposalProvider::proposal_of(proposal_hash)
.ok_or(Error::<T, I>::MissingProposalHash)?;
match proposal.is_sub_type() {
Some(Call::set_rule { .. }) | Some(Call::elevate_ally { .. }) => {
T::ProposalProvider::veto_proposal(proposal_hash);
Ok(())
},
_ => Err(Error::<T, I>::NotVetoableProposal.into()),
}
}
/// Close a vote that is either approved, disapproved, or whose voting period has ended.
///
/// Requires the sender to be a founder or fellow.
/// Must be called by a Fellow.
#[pallet::weight({
let b = *length_bound;
let x = T::MaxFounders::get();
let y = T::MaxFellows::get();
let m = T::MaxFellows::get();
let p1 = *proposal_weight_bound;
let p2 = T::MaxProposals::get();
T::WeightInfo::close_early_approved(b, x, y, p2)
.max(T::WeightInfo::close_early_disapproved(x, y, p2))
.max(T::WeightInfo::close_approved(b, x, y, p2))
.max(T::WeightInfo::close_disapproved(x, y, p2))
T::WeightInfo::close_early_approved(b, m, p2)
.max(T::WeightInfo::close_early_disapproved(m, p2))
.max(T::WeightInfo::close_approved(b, m, p2))
.max(T::WeightInfo::close_disapproved(m, p2))
.saturating_add(p1.into())
})]
#[allow(deprecated)]
@@ -638,62 +568,52 @@ pub mod pallet {
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
}
/// Initialize the Alliance, onboard founders, fellows, and allies.
/// Initialize the Alliance, onboard fellows and allies.
///
/// The Alliance must be empty, and the call must provide some founding members.
///
/// Founders must be not empty.
/// The Alliance must be empty.
/// Must be called by the Root origin.
#[pallet::weight(T::WeightInfo::init_members(
founders.len() as u32,
fellows.len() as u32,
allies.len() as u32,
))]
pub fn init_members(
origin: OriginFor<T>,
founders: Vec<T::AccountId>,
fellows: Vec<T::AccountId>,
allies: Vec<T::AccountId>,
) -> DispatchResult {
ensure_root(origin)?;
ensure!(!founders.is_empty(), Error::<T, I>::FoundersMissing);
ensure!(!fellows.is_empty(), Error::<T, I>::FellowsMissing);
ensure!(!Self::is_initialized(), Error::<T, I>::AllianceAlreadyInitialized);
let mut founders: BoundedVec<T::AccountId, T::MaxMembersCount> =
founders.try_into().map_err(|_| Error::<T, I>::TooManyMembers)?;
let mut fellows: BoundedVec<T::AccountId, T::MaxMembersCount> =
fellows.try_into().map_err(|_| Error::<T, I>::TooManyMembers)?;
let mut allies: BoundedVec<T::AccountId, T::MaxMembersCount> =
allies.try_into().map_err(|_| Error::<T, I>::TooManyMembers)?;
for member in founders.iter().chain(fellows.iter()).chain(allies.iter()) {
for member in fellows.iter().chain(allies.iter()) {
Self::has_identity(member)?;
}
founders.sort();
Members::<T, I>::insert(&MemberRole::Founder, founders.clone());
fellows.sort();
Members::<T, I>::insert(&MemberRole::Fellow, fellows.clone());
allies.sort();
Members::<T, I>::insert(&MemberRole::Ally, allies.clone());
let mut voteable_members = Vec::with_capacity(founders.len() + fellows.len());
voteable_members.extend(founders.clone());
voteable_members.extend(fellows.clone());
let mut voteable_members = fellows.clone();
voteable_members.sort();
T::InitializeMembers::initialize_members(&voteable_members);
log::debug!(
target: LOG_TARGET,
"Initialize alliance founders: {:?}, fellows: {:?}, allies: {:?}",
founders,
"Initialize alliance fellows: {:?}, allies: {:?}",
fellows,
allies
);
Self::deposit_event(Event::MembersInitialized {
founders: founders.into(),
fellows: fellows.into(),
allies: allies.into(),
});
@@ -704,9 +624,9 @@ pub mod pallet {
///
/// Witness data must be set.
#[pallet::weight(T::WeightInfo::disband(
witness.voting_members,
witness.fellow_members,
witness.ally_members,
witness.voting_members.saturating_add(witness.ally_members),
witness.fellow_members.saturating_add(witness.ally_members),
))]
pub fn disband(
origin: OriginFor<T>,
@@ -716,7 +636,7 @@ pub mod pallet {
ensure!(!witness.is_zero(), Error::<T, I>::BadWitness);
ensure!(
Self::voting_members_count() <= witness.voting_members,
Self::voting_members_count() <= witness.fellow_members,
Error::<T, I>::BadWitness
);
ensure!(Self::ally_members_count() <= witness.ally_members, Error::<T, I>::BadWitness);
@@ -735,12 +655,11 @@ pub mod pallet {
}
}
Members::<T, I>::remove(&MemberRole::Founder);
Members::<T, I>::remove(&MemberRole::Fellow);
Members::<T, I>::remove(&MemberRole::Ally);
Self::deposit_event(Event::AllianceDisbanded {
voting_members: voting_members.len() as u32,
fellow_members: voting_members.len() as u32,
ally_members: ally_members.len() as u32,
unreserved: unreserve_count,
});
@@ -831,8 +750,8 @@ pub mod pallet {
Ok(())
}
/// A founder or fellow can nominate someone to join the alliance as an Ally.
/// There is no deposit required to the nominator or nominee.
/// A Fellow can nominate someone to join the alliance as an Ally. There is no deposit
/// required from the nominator or nominee.
#[pallet::weight(T::WeightInfo::nominate_ally())]
pub fn nominate_ally(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
let nominator = ensure_signed(origin)?;
@@ -856,7 +775,7 @@ pub mod pallet {
Ok(())
}
/// Elevate an ally to fellow.
/// Elevate an Ally to Fellow.
#[pallet::weight(T::WeightInfo::elevate_ally())]
pub fn elevate_ally(origin: OriginFor<T>, ally: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
@@ -891,8 +810,10 @@ pub mod pallet {
Ok(())
}
/// 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.
/// As a member, retire from the Alliance and unreserve the deposit.
///
/// This can only be done once you have called `give_retirement_notice` and the
/// `RetirementPeriod` has passed.
#[pallet::weight(T::WeightInfo::retire())]
pub fn retire(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
@@ -914,7 +835,7 @@ pub mod pallet {
Ok(())
}
/// Kick a member from the alliance and slash its deposit.
/// Kick a member from the Alliance and slash its deposit.
#[pallet::weight(T::WeightInfo::kick_member())]
pub fn kick_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
@@ -960,7 +881,7 @@ pub mod pallet {
Ok(())
}
/// Deem an item no longer unscrupulous.
/// Deem some items no longer unscrupulous.
#[pallet::weight(<T as Config<I>>::WeightInfo::remove_unscrupulous_items(
items.len() as u32, T::MaxWebsiteUrlLength::get()
))]
@@ -985,17 +906,16 @@ pub mod pallet {
/// Close a vote that is either approved, disapproved, or whose voting period has ended.
///
/// Requires the sender to be a founder or fellow.
/// Must be called by a Fellow.
#[pallet::weight({
let b = *length_bound;
let x = T::MaxFounders::get();
let y = T::MaxFellows::get();
let m = T::MaxFellows::get();
let p1 = *proposal_weight_bound;
let p2 = T::MaxProposals::get();
T::WeightInfo::close_early_approved(b, x, y, p2)
.max(T::WeightInfo::close_early_disapproved(x, y, p2))
.max(T::WeightInfo::close_approved(b, x, y, p2))
.max(T::WeightInfo::close_disapproved(x, y, p2))
T::WeightInfo::close_early_approved(b, m, p2)
.max(T::WeightInfo::close_early_disapproved(m, p2))
.max(T::WeightInfo::close_approved(b, m, p2))
.max(T::WeightInfo::close_disapproved(m, p2))
.saturating_add(p1)
})]
pub fn close(
@@ -1010,15 +930,30 @@ pub mod pallet {
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
}
/// Abdicate one's position as a voting member and just be an Ally. May be used by Fellows
/// who do not want to leave the Alliance but do not have the capacity to participate
/// operationally for some time.
#[pallet::weight(T::WeightInfo::abdicate_fellow_status())]
pub fn abdicate_fellow_status(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let role = Self::member_role_of(&who).ok_or(Error::<T, I>::NotMember)?;
// Not applicable to members who are retiring or who are already Allies.
ensure!(Self::has_voting_rights(&who), Error::<T, I>::NoVotingRights);
Self::remove_member(&who, role)?;
Self::add_member(&who, MemberRole::Ally)?;
Self::deposit_event(Event::FellowAbdicated { fellow: who });
Ok(())
}
}
}
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::Ally)
Self::has_member(MemberRole::Fellow) || Self::has_member(MemberRole::Ally)
}
/// Check if a given role has any members.
@@ -1042,24 +977,14 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Members::<T, I>::get(role).contains(&who)
}
/// Check if an account is a founder.
fn is_founder(who: &T::AccountId) -> bool {
Self::is_member_of(who, MemberRole::Founder)
}
/// Check if an account is a fellow.
fn is_fellow(who: &T::AccountId) -> bool {
Self::is_member_of(who, MemberRole::Fellow)
}
/// Check if an account is an ally.
/// Check if an account is an Ally.
fn is_ally(who: &T::AccountId) -> bool {
Self::is_member_of(who, MemberRole::Ally)
}
/// Check if a member has voting rights.
fn has_voting_rights(who: &T::AccountId) -> bool {
Self::is_founder(who) || Self::is_fellow(who)
Self::is_member_of(who, MemberRole::Fellow)
}
/// Count of ally members.
@@ -1069,9 +994,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Count of all members who have voting rights.
fn voting_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
Members::<T, I>::decode_len(MemberRole::Fellow).unwrap_or(0) as u32
}
/// Get all members of a given role.
@@ -1081,17 +1004,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Collect all members who have voting rights into one list.
fn voting_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
}
/// Collect all members who have voting rights into one sorted list.
fn voting_members_sorted() -> Vec<T::AccountId> {
let mut members = Self::voting_members();
members.sort();
members
Self::members_of(MemberRole::Fellow)
}
/// Add a user to the sorted alliance member set.
@@ -1104,8 +1017,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Ok(())
})?;
if role == MemberRole::Founder || role == MemberRole::Fellow {
let members = Self::voting_members_sorted();
if role == MemberRole::Fellow {
let members = Self::voting_members();
T::MembershipChanged::change_members_sorted(&[who.clone()], &[], &members[..]);
}
Ok(())
@@ -1119,8 +1032,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Ok(())
})?;
if matches!(role, MemberRole::Founder | MemberRole::Fellow) {
let members = Self::voting_members_sorted();
if role == MemberRole::Fellow {
let members = Self::voting_members();
T::MembershipChanged::change_members_sorted(&[], &[who.clone()], &members[..]);
}
Ok(())
+101 -1
View File
@@ -20,7 +20,7 @@ use frame_support::{pallet_prelude::*, storage::migration, traits::OnRuntimeUpgr
use log;
/// The current storage version.
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2);
/// Wrapper for all migrations of this pallet.
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
@@ -31,6 +31,10 @@ pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
weight = weight.saturating_add(v0_to_v1::migrate::<T, I>());
}
if onchain_version < 2 {
weight = weight.saturating_add(v1_to_v2::migrate::<T, I>());
}
STORAGE_VERSION.put::<Pallet<T, I>>();
weight = weight.saturating_add(T::DbWeight::get().writes(1));
@@ -77,3 +81,99 @@ mod v0_to_v1 {
T::DbWeight::get().writes(res.unique.into())
}
}
/// v1_to_v2: `Members` storage map collapses `Founder` and `Fellow` keys into one `Fellow`.
/// Total number of `Founder`s and `Fellow`s must not be higher than `T::MaxMembersCount`.
pub(crate) mod v1_to_v2 {
use super::*;
use crate::{MemberRole, Members};
/// V1 Role set.
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, TypeInfo, MaxEncodedLen)]
pub enum MemberRoleV1 {
Founder,
Fellow,
Ally,
Retiring,
}
pub fn migrate<T: Config<I>, I: 'static>() -> Weight {
log::info!(target: LOG_TARGET, "Running migration v1_to_v2: `Members` storage map collapses `Founder` and `Fellow` keys into one `Fellow`.");
// fetch into the scope all members.
let founders_vec = take_members::<T, I>(MemberRoleV1::Founder).into_inner();
let mut fellows_vec = take_members::<T, I>(MemberRoleV1::Fellow).into_inner();
let allies = take_members::<T, I>(MemberRoleV1::Ally);
let retiring = take_members::<T, I>(MemberRoleV1::Retiring);
if founders_vec
.len()
.saturating_add(fellows_vec.len())
.saturating_add(allies.len())
.saturating_add(retiring.len()) ==
0
{
return T::DbWeight::get().reads(4)
}
log::info!(
target: LOG_TARGET,
"Members storage v1 contains, '{}' founders, '{}' fellows, '{}' allies, '{}' retiring members.",
founders_vec.len(),
fellows_vec.len(),
allies.len(),
retiring.len(),
);
// merge founders with fellows and sort.
fellows_vec.extend(founders_vec);
fellows_vec.sort();
if fellows_vec.len() as u32 > T::MaxMembersCount::get() {
log::error!(
target: LOG_TARGET,
"Merged list of founders and fellows do not fit into `T::MaxMembersCount` bound. Truncating the merged set into max members count."
);
fellows_vec.truncate(T::MaxMembersCount::get() as usize);
}
let fellows: BoundedVec<T::AccountId, T::MaxMembersCount> =
fellows_vec.try_into().unwrap_or_default();
// insert members with new storage map key.
Members::<T, I>::insert(&MemberRole::Fellow, fellows.clone());
Members::<T, I>::insert(&MemberRole::Ally, allies.clone());
Members::<T, I>::insert(&MemberRole::Retiring, retiring.clone());
log::info!(
target: LOG_TARGET,
"Members storage updated with, '{}' fellows, '{}' allies, '{}' retiring members.",
fellows.len(),
allies.len(),
retiring.len(),
);
T::DbWeight::get().reads_writes(4, 4)
}
fn take_members<T: Config<I>, I: 'static>(
role: MemberRoleV1,
) -> BoundedVec<T::AccountId, T::MaxMembersCount> {
migration::take_storage_item::<
MemberRoleV1,
BoundedVec<T::AccountId, T::MaxMembersCount>,
Twox64Concat,
>(<Pallet<T, I>>::name().as_bytes(), b"Members", role)
.unwrap_or_default()
}
}
#[cfg(test)]
mod test {
use super::*;
use crate::{mock::*, MemberRole};
#[test]
fn migration_v1_to_v2_works() {
new_test_ext().execute_with(|| {
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(4)));
assert_eq!(Alliance::members(MemberRole::Ally), vec![4]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
v1_to_v2::migrate::<Test, ()>();
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3, 4]);
assert_eq!(Alliance::members(MemberRole::Ally), vec![]);
assert_eq!(Alliance::members(MemberRole::Retiring), vec![]);
});
}
}
+22 -28
View File
@@ -39,6 +39,7 @@ pub use crate as pallet_alliance;
use super::*;
type BlockNumber = u64;
type AccountId = u64;
parameter_types! {
pub const BlockHashCount: BlockNumber = 250;
@@ -53,7 +54,7 @@ impl frame_system::Config for Test {
type BlockNumber = BlockNumber;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type RuntimeEvent = RuntimeEvent;
@@ -61,7 +62,7 @@ impl frame_system::Config for Test {
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type AccountData = pallet_balances::AccountData<AccountId>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
@@ -120,8 +121,8 @@ ord_parameter_types! {
pub const Four: u64 = 4;
pub const Five: u64 = 5;
}
type EnsureOneOrRoot = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<One, u64>>;
type EnsureTwoOrRoot = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<Two, u64>>;
type EnsureOneOrRoot = EitherOfDiverse<EnsureRoot<AccountId>, EnsureSignedBy<One, AccountId>>;
type EnsureTwoOrRoot = EitherOfDiverse<EnsureRoot<AccountId>, EnsureSignedBy<Two, AccountId>>;
impl pallet_identity::Config for Test {
type RuntimeEvent = RuntimeEvent;
@@ -139,12 +140,12 @@ impl pallet_identity::Config for Test {
}
pub struct AllianceIdentityVerifier;
impl IdentityVerifier<u64> for AllianceIdentityVerifier {
fn has_identity(who: &u64, fields: u64) -> bool {
impl IdentityVerifier<AccountId> for AllianceIdentityVerifier {
fn has_identity(who: &AccountId, fields: u64) -> bool {
Identity::has_identity(who, fields)
}
fn has_good_judgement(who: &u64) -> bool {
fn has_good_judgement(who: &AccountId) -> bool {
if let Some(judgements) =
Identity::identity(who).map(|registration| registration.judgements)
{
@@ -156,15 +157,15 @@ impl IdentityVerifier<u64> for AllianceIdentityVerifier {
}
}
fn super_account_id(who: &u64) -> Option<u64> {
fn super_account_id(who: &AccountId) -> Option<AccountId> {
Identity::super_of(who).map(|parent| parent.0)
}
}
pub struct AllianceProposalProvider;
impl ProposalProvider<u64, H256, RuntimeCall> for AllianceProposalProvider {
impl ProposalProvider<AccountId, H256, RuntimeCall> for AllianceProposalProvider {
fn propose_proposal(
who: u64,
who: AccountId,
threshold: u32,
proposal: Box<RuntimeCall>,
length_bound: u32,
@@ -173,7 +174,7 @@ impl ProposalProvider<u64, H256, RuntimeCall> for AllianceProposalProvider {
}
fn vote_proposal(
who: u64,
who: AccountId,
proposal: H256,
index: ProposalIndex,
approve: bool,
@@ -181,10 +182,6 @@ impl ProposalProvider<u64, H256, RuntimeCall> for AllianceProposalProvider {
AllianceMotion::do_vote(who, proposal, index, approve)
}
fn veto_proposal(proposal_hash: H256) -> u32 {
AllianceMotion::do_disapprove_proposal(proposal_hash)
}
fn close_proposal(
proposal_hash: H256,
proposal_index: ProposalIndex,
@@ -200,8 +197,7 @@ impl ProposalProvider<u64, H256, RuntimeCall> for AllianceProposalProvider {
}
parameter_types! {
pub const MaxFounders: u32 = 10;
pub const MaxFellows: u32 = MaxMembers::get() - MaxFounders::get();
pub const MaxFellows: u32 = MaxMembers::get();
pub const MaxAllies: u32 = 100;
pub const AllyDeposit: u64 = 25;
pub const RetirementPeriod: BlockNumber = MOTION_DURATION_IN_BLOCKS + 1;
@@ -209,9 +205,9 @@ parameter_types! {
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Proposal = RuntimeCall;
type AdminOrigin = EnsureSignedBy<One, u64>;
type MembershipManager = EnsureSignedBy<Two, u64>;
type AnnouncementOrigin = EnsureSignedBy<Three, u64>;
type AdminOrigin = EnsureSignedBy<One, AccountId>;
type MembershipManager = EnsureSignedBy<Two, AccountId>;
type AnnouncementOrigin = EnsureSignedBy<Three, AccountId>;
type Currency = Balances;
type Slashed = ();
type InitializeMembers = AllianceMotion;
@@ -222,7 +218,6 @@ impl Config for Test {
type IdentityVerifier = ();
type ProposalProvider = AllianceProposalProvider;
type MaxProposals = MaxProposals;
type MaxFounders = MaxFounders;
type MaxFellows = MaxFellows;
type MaxAllies = MaxAllies;
type MaxUnscrupulousItems = ConstU32<100>;
@@ -272,7 +267,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
GenesisBuild::<Test>::assimilate_storage(
&pallet_alliance::GenesisConfig {
founders: vec![],
fellows: vec![],
allies: vec![],
phantom: Default::default(),
@@ -360,7 +354,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
Error::<Test, ()>::AllianceNotYetInitialized
);
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![1, 2], vec![3], vec![]));
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![1, 2, 3], vec![]));
System::set_block_number(1);
});
@@ -384,11 +378,7 @@ pub fn make_remark_proposal(value: u64) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::System(frame_system::Call::remark { remark: value.encode() }))
}
pub fn make_set_rule_proposal(rule: Cid) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::set_rule { rule }))
}
pub fn make_kick_member_proposal(who: u64) -> (RuntimeCall, u32, H256) {
pub fn make_kick_member_proposal(who: AccountId) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who }))
}
@@ -397,3 +387,7 @@ pub fn make_proposal(proposal: RuntimeCall) -> (RuntimeCall, u32, H256) {
let hash = BlakeTwo256::hash_of(&proposal);
(proposal, len, hash)
}
pub fn is_fellow(who: &AccountId) -> bool {
Alliance::is_member_of(who, MemberRole::Fellow)
}
+65 -109
View File
@@ -25,12 +25,45 @@ use crate::mock::*;
type AllianceMotionEvent = pallet_collective::Event<Test, pallet_collective::Instance1>;
fn assert_powerless(user: RuntimeOrigin, user_is_member: bool) {
//vote / veto with a valid propsal
let cid = test_cid();
let (proposal, _, _) = make_kick_member_proposal(42);
assert_noop!(Alliance::init_members(user.clone(), vec![], vec![],), BadOrigin);
assert_noop!(
Alliance::disband(user.clone(), DisbandWitness { fellow_members: 3, ..Default::default() }),
BadOrigin
);
assert_noop!(Alliance::set_rule(user.clone(), cid.clone()), BadOrigin);
assert_noop!(Alliance::retire(user.clone()), Error::<Test, ()>::RetirementNoticeNotGiven);
// Allies should be able to give retirement notice.
if !user_is_member {
assert_noop!(Alliance::give_retirement_notice(user.clone()), Error::<Test, ()>::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::<Test, ()>::NoVotingRights);
assert_noop!(
Alliance::propose(user.clone(), 5, Box::new(proposal), 1000),
Error::<Test, ()>::NoVotingRights
);
}
#[test]
fn init_members_works() {
new_test_ext().execute_with(|| {
// alliance must be reset first, no witness data
assert_noop!(
Alliance::init_members(RuntimeOrigin::root(), vec![8], vec![], vec![],),
Alliance::init_members(RuntimeOrigin::root(), vec![8], vec![],),
Error::<Test, ()>::AllianceAlreadyInitialized,
);
@@ -42,33 +75,28 @@ fn init_members_works() {
assert_ok!(Alliance::disband(RuntimeOrigin::root(), DisbandWitness::new(2, 0)));
// fails without root
assert_noop!(
Alliance::init_members(RuntimeOrigin::signed(1), vec![], vec![], vec![]),
BadOrigin
);
assert_noop!(Alliance::init_members(RuntimeOrigin::signed(1), vec![], vec![]), BadOrigin);
// founders missing, other members given
// fellows missing, other members given
assert_noop!(
Alliance::init_members(RuntimeOrigin::root(), vec![], vec![4], vec![2],),
Error::<Test, ()>::FoundersMissing,
Alliance::init_members(RuntimeOrigin::root(), vec![], vec![2],),
Error::<Test, ()>::FellowsMissing,
);
// success call
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![8, 5], vec![4], vec![2],));
assert_ok!(Alliance::init_members(RuntimeOrigin::root(), vec![8, 5], vec![2],));
// assert new set of voting members
assert_eq!(Alliance::voting_members_sorted(), vec![4, 5, 8]);
assert_eq!(Alliance::voting_members(), vec![5, 8]);
// assert new members member
assert!(Alliance::is_founder(&8));
assert!(Alliance::is_founder(&5));
assert!(Alliance::is_fellow(&4));
assert!(is_fellow(&8));
assert!(is_fellow(&5));
assert!(Alliance::is_ally(&2));
// assert a retiring member from previous Alliance not removed
assert!(Alliance::is_member_of(&2, MemberRole::Retiring));
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MembersInitialized {
founders: vec![5, 8],
fellows: vec![4],
fellows: vec![5, 8],
allies: vec![2],
}));
})
@@ -78,7 +106,7 @@ fn init_members_works() {
fn disband_works() {
new_test_ext().execute_with(|| {
// ensure alliance is set
assert_eq!(Alliance::voting_members_sorted(), vec![1, 2, 3]);
assert_eq!(Alliance::voting_members(), vec![1, 2, 3]);
// give a retirement notice to check later a retiring member not removed
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(2)));
@@ -121,7 +149,7 @@ fn disband_works() {
assert_eq!(Balances::free_balance(9), 40);
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::AllianceDisbanded {
voting_members: 2,
fellow_members: 2,
ally_members: 1,
unreserved: 1,
}));
@@ -208,62 +236,6 @@ fn vote_works() {
});
}
#[test]
fn veto_works() {
new_test_ext().execute_with(|| {
let (proposal, proposal_len, hash) = make_remark_proposal(42);
assert_ok!(Alliance::propose(
RuntimeOrigin::signed(1),
3,
Box::new(proposal.clone()),
proposal_len
));
// only set_rule/elevate_ally can be veto
assert_noop!(
Alliance::veto(RuntimeOrigin::signed(1), hash),
Error::<Test, ()>::NotVetoableProposal
);
let cid = test_cid();
let (vetoable_proposal, vetoable_proposal_len, vetoable_hash) = make_set_rule_proposal(cid);
assert_ok!(Alliance::propose(
RuntimeOrigin::signed(1),
3,
Box::new(vetoable_proposal.clone()),
vetoable_proposal_len
));
// only founder have veto rights, 3 is fellow
assert_noop!(
Alliance::veto(RuntimeOrigin::signed(3), vetoable_hash),
Error::<Test, ()>::NotFounder
);
assert_ok!(Alliance::veto(RuntimeOrigin::signed(2), vetoable_hash));
let record = |event| EventRecord { phase: Phase::Initialization, event, topics: vec![] };
assert_eq!(
System::events(),
vec![
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 0,
proposal_hash: hash,
threshold: 3
})),
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Proposed {
account: 1,
proposal_index: 1,
proposal_hash: vetoable_hash,
threshold: 3
})),
record(mock::RuntimeEvent::AllianceMotion(AllianceMotionEvent::Disapproved {
proposal_hash: vetoable_hash
})),
]
);
})
}
#[test]
fn close_works() {
new_test_ext().execute_with(|| {
@@ -447,7 +419,7 @@ fn nominate_ally_works() {
Error::<Test, ()>::AlreadyMember
);
// only voting member(founder/fellow) have nominate right
// only voting members (Fellows) have nominate right
assert_noop!(
Alliance::nominate_ally(RuntimeOrigin::signed(5), 4),
Error::<Test, ()>::NoVotingRights
@@ -503,11 +475,11 @@ fn elevate_ally_works() {
assert_ok!(Alliance::join_alliance(RuntimeOrigin::signed(4)));
assert_eq!(Alliance::members(MemberRole::Ally), vec![4]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
assert_ok!(Alliance::elevate_ally(RuntimeOrigin::signed(2), 4));
assert_eq!(Alliance::members(MemberRole::Ally), Vec::<u64>::new());
assert_eq!(Alliance::members(MemberRole::Fellow), vec![3, 4]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3, 4]);
});
}
@@ -519,9 +491,9 @@ fn give_retirement_notice_work() {
Error::<Test, ()>::NotMember
);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(3)));
assert_eq!(Alliance::members(MemberRole::Fellow), Vec::<u64>::new());
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2]);
assert_eq!(Alliance::members(MemberRole::Retiring), vec![3]);
System::assert_last_event(mock::RuntimeEvent::Alliance(
crate::Event::MemberRetirementPeriodStarted { member: (3) },
@@ -547,7 +519,7 @@ fn retire_works() {
Error::<Test, ()>::RetirementNoticeNotGiven
);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![3]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
assert_ok!(Alliance::give_retirement_notice(RuntimeOrigin::signed(3)));
assert_noop!(
Alliance::retire(RuntimeOrigin::signed(3)),
@@ -555,7 +527,7 @@ fn retire_works() {
);
System::set_block_number(System::block_number() + RetirementPeriod::get());
assert_ok!(Alliance::retire(RuntimeOrigin::signed(3)));
assert_eq!(Alliance::members(MemberRole::Fellow), Vec::<u64>::new());
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2]);
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberRetired {
member: (3),
unreserved: None,
@@ -564,38 +536,22 @@ fn retire_works() {
// Move time on:
System::set_block_number(System::block_number() + RetirementPeriod::get());
assert_powerless(RuntimeOrigin::signed(3));
assert_powerless(RuntimeOrigin::signed(3), false);
});
}
fn assert_powerless(user: RuntimeOrigin) {
//vote / veto with a valid propsal
let cid = test_cid();
let (proposal, _, _) = make_kick_member_proposal(42);
#[test]
fn abdicate_works() {
new_test_ext().execute_with(|| {
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
assert_ok!(Alliance::abdicate_fellow_status(RuntimeOrigin::signed(3)));
assert_noop!(Alliance::init_members(user.clone(), vec![], vec![], vec![],), BadOrigin);
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::FellowAbdicated {
fellow: (3),
}));
assert_noop!(
Alliance::disband(user.clone(), DisbandWitness { voting_members: 3, ..Default::default() }),
BadOrigin
);
assert_noop!(Alliance::set_rule(user.clone(), cid.clone()), BadOrigin);
assert_noop!(Alliance::retire(user.clone()), Error::<Test, ()>::RetirementNoticeNotGiven);
assert_noop!(Alliance::give_retirement_notice(user.clone()), Error::<Test, ()>::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::<Test, ()>::NoVotingRights);
assert_noop!(
Alliance::propose(user.clone(), 5, Box::new(proposal), 1000),
Error::<Test, ()>::NoVotingRights
);
assert_powerless(RuntimeOrigin::signed(3), true);
});
}
#[test]
@@ -609,9 +565,9 @@ fn kick_member_works() {
);
<DepositOf<Test, ()>>::insert(2, 25);
assert_eq!(Alliance::members(MemberRole::Founder), vec![1, 2]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 2, 3]);
assert_ok!(Alliance::kick_member(RuntimeOrigin::signed(2), 2));
assert_eq!(Alliance::members(MemberRole::Founder), vec![1]);
assert_eq!(Alliance::members(MemberRole::Fellow), vec![1, 3]);
assert_eq!(<DepositOf<Test, ()>>::get(2), None);
System::assert_last_event(mock::RuntimeEvent::Alliance(crate::Event::MemberKicked {
member: (2),
+4 -4
View File
@@ -99,9 +99,9 @@ impl Cid {
Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo, Default,
)]
pub struct DisbandWitness {
/// Total number of voting members in the current Alliance.
/// Total number of fellow members in the current Alliance.
#[codec(compact)]
pub(super) voting_members: u32,
pub(super) fellow_members: u32,
/// Total number of ally members in the current Alliance.
#[codec(compact)]
pub(super) ally_members: u32,
@@ -110,8 +110,8 @@ pub struct DisbandWitness {
#[cfg(test)]
impl DisbandWitness {
// Creates new DisbandWitness.
pub(super) fn new(voting_members: u32, ally_members: u32) -> Self {
Self { voting_members, ally_members }
pub(super) fn new(fellow_members: u32, ally_members: u32) -> Self {
Self { fellow_members, ally_members }
}
}
+260 -292
View File
@@ -1,41 +1,22 @@
// This file is part of Substrate.
// Copyright (C) 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.
//! Autogenerated weights for pallet_alliance
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-11-07, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `bm2`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
//! DATE: 2022-11-22, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! HOSTNAME: `cob`, CPU: `<UNKNOWN>`
//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/substrate
// ./target/release/substrate
// benchmark
// pallet
// --chain=dev
// --steps=50
// --repeat=20
// --pallet=pallet_alliance
// --pallet=pallet-alliance
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=./frame/alliance/src/weights.rs
// --header=./HEADER-APACHE2
// --output=./frame/alliance/src/._weights.rs
// --template=./.maintain/frame-weight-template.hbs
#![cfg_attr(rustfmt, rustfmt_skip)]
@@ -47,14 +28,14 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_alliance.
pub trait WeightInfo {
fn propose_proposed(b: u32, x: u32, y: u32, p: u32, ) -> Weight;
fn vote(x: u32, y: u32, ) -> Weight;
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight;
fn vote(m: u32, ) -> Weight;
fn veto(p: u32, ) -> Weight;
fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight;
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 close_early_disapproved(m: u32, p: u32, ) -> Weight;
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight;
fn close_disapproved(m: u32, p: u32, ) -> Weight;
fn close_approved(b: u32, m: u32, p: u32, ) -> Weight;
fn init_members(m: u32, z: u32, ) -> Weight;
fn disband(x: u32, y: u32, z: u32, ) -> Weight;
fn set_rule() -> Weight;
fn announce() -> Weight;
@@ -67,6 +48,7 @@ pub trait WeightInfo {
fn kick_member() -> Weight;
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight;
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight;
fn abdicate_fellow_status() -> Weight;
}
/// Weights for pallet_alliance using the Substrate node and recommended hardware.
@@ -78,31 +60,29 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: AllianceMotion ProposalCount (r:1 w:1)
// Storage: AllianceMotion Voting (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 `[0, 90]`.
/// The range of component `m` is `[2, 100]`.
/// The range of component `p` is `[1, 100]`.
fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 43_720 nanoseconds.
Weight::from_ref_time(44_766_307 as u64)
// Standard Error: 2_522
.saturating_add(Weight::from_ref_time(54_721 as u64).saturating_mul(y as u64))
// Standard Error: 2_301
.saturating_add(Weight::from_ref_time(173_300 as u64).saturating_mul(p as u64))
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(24_357_172 as u64)
// Standard Error: 428
.saturating_add(Weight::from_ref_time(233 as u64).saturating_mul(b as u64))
// Standard Error: 4_474
.saturating_add(Weight::from_ref_time(48_024 as u64).saturating_mul(m as u64))
// Standard Error: 4_418
.saturating_add(Weight::from_ref_time(97_604 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
// Storage: Alliance Members (r:2 w:0)
// Storage: Alliance Members (r:1 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 {
// Minimum execution time: 46_984 nanoseconds.
Weight::from_ref_time(46_837_255 as u64)
// Standard Error: 32_860
.saturating_add(Weight::from_ref_time(273_691 as u64).saturating_mul(x as u64))
// Standard Error: 2_781
.saturating_add(Weight::from_ref_time(126_964 as u64).saturating_mul(y as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
/// The range of component `m` is `[5, 100]`.
fn vote(m: u32, ) -> Weight {
// Minimum execution time: 24_000 nanoseconds.
Weight::from_ref_time(26_617_201 as u64)
// Standard Error: 4_280
.saturating_add(Weight::from_ref_time(43_152 as u64).saturating_mul(m as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:1 w:0)
@@ -111,10 +91,10 @@ 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 {
// Minimum execution time: 34_734 nanoseconds.
Weight::from_ref_time(37_652_708 as u64)
// Standard Error: 1_270
.saturating_add(Weight::from_ref_time(183_078 as u64).saturating_mul(p as u64))
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(26_045_752 as u64)
// Standard Error: 2_154
.saturating_add(Weight::from_ref_time(61_220 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
@@ -123,18 +103,15 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: AllianceMotion Members (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 `m` is `[4, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 50_147 nanoseconds.
Weight::from_ref_time(42_719_616 as u64)
// Standard Error: 19_981
.saturating_add(Weight::from_ref_time(188_796 as u64).saturating_mul(x as u64))
// Standard Error: 1_947
.saturating_add(Weight::from_ref_time(95_998 as u64).saturating_mul(y as u64))
// Standard Error: 1_739
.saturating_add(Weight::from_ref_time(177_837 as u64).saturating_mul(p as u64))
fn close_early_disapproved(m: u32, p: u32, ) -> Weight {
// Minimum execution time: 30_000 nanoseconds.
Weight::from_ref_time(25_697_866 as u64)
// Standard Error: 3_827
.saturating_add(Weight::from_ref_time(48_360 as u64).saturating_mul(m as u64))
// Standard Error: 3_731
.saturating_add(Weight::from_ref_time(116_922 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
@@ -144,20 +121,17 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: AllianceMotion ProposalOf (r:1 w:1)
// Storage: AllianceMotion Proposals (r:1 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 `m` is `[4, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 59_495 nanoseconds.
Weight::from_ref_time(53_137_721 as u64)
// Standard Error: 138
.saturating_add(Weight::from_ref_time(1_979 as u64).saturating_mul(b as u64))
// Standard Error: 16_388
.saturating_add(Weight::from_ref_time(8_198 as u64).saturating_mul(x as u64))
// Standard Error: 1_599
.saturating_add(Weight::from_ref_time(86_577 as u64).saturating_mul(y as u64))
// Standard Error: 1_428
.saturating_add(Weight::from_ref_time(215_905 as u64).saturating_mul(p as u64))
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 34_000 nanoseconds.
Weight::from_ref_time(30_725_464 as u64)
// Standard Error: 370
.saturating_add(Weight::from_ref_time(2_367 as u64).saturating_mul(b as u64))
// Standard Error: 3_920
.saturating_add(Weight::from_ref_time(40_710 as u64).saturating_mul(m as u64))
// Standard Error: 3_822
.saturating_add(Weight::from_ref_time(111_866 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
@@ -167,16 +141,15 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// 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 `m` is `[2, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 52_405 nanoseconds.
Weight::from_ref_time(44_494_732 as u64)
// Standard Error: 1_759
.saturating_add(Weight::from_ref_time(118_517 as u64).saturating_mul(y as u64))
// Standard Error: 1_572
.saturating_add(Weight::from_ref_time(198_256 as u64).saturating_mul(p as u64))
fn close_disapproved(m: u32, p: u32, ) -> Weight {
// Minimum execution time: 31_000 nanoseconds.
Weight::from_ref_time(29_444_599 as u64)
// Standard Error: 4_043
.saturating_add(Weight::from_ref_time(48_928 as u64).saturating_mul(m as u64))
// Standard Error: 3_994
.saturating_add(Weight::from_ref_time(76_527 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
@@ -187,39 +160,33 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: AllianceMotion Proposals (r:1 w:1)
// 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 `m` is `[5, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 52_737 nanoseconds.
Weight::from_ref_time(45_874_458 as u64)
// Standard Error: 140
.saturating_add(Weight::from_ref_time(601 as u64).saturating_mul(b as u64))
// Standard Error: 1_623
.saturating_add(Weight::from_ref_time(88_372 as u64).saturating_mul(y as u64))
// Standard Error: 1_449
.saturating_add(Weight::from_ref_time(197_595 as u64).saturating_mul(p as u64))
fn close_approved(_b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(32_315_075 as u64)
// Standard Error: 4_502
.saturating_add(Weight::from_ref_time(43_205 as u64).saturating_mul(m as u64))
// Standard Error: 4_340
.saturating_add(Weight::from_ref_time(101_872 as u64).saturating_mul(p as u64))
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:3 w:3)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Members (r:1 w:1)
/// The range of component `x` is `[1, 10]`.
/// The range of component `y` is `[0, 90]`.
/// The range of component `m` is `[1, 100]`.
/// The range of component `z` is `[0, 100]`.
fn init_members(x: u32, y: u32, z: u32, ) -> Weight {
// Minimum execution time: 48_821 nanoseconds.
Weight::from_ref_time(32_972_152 as u64)
// Standard Error: 17_618
.saturating_add(Weight::from_ref_time(230_451 as u64).saturating_mul(x as u64))
// Standard Error: 1_865
.saturating_add(Weight::from_ref_time(172_532 as u64).saturating_mul(y as u64))
// Standard Error: 1_682
.saturating_add(Weight::from_ref_time(145_258 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
fn init_members(m: u32, z: u32, ) -> Weight {
// Minimum execution time: 22_000 nanoseconds.
Weight::from_ref_time(13_523_882 as u64)
// Standard Error: 1_823
.saturating_add(Weight::from_ref_time(91_625 as u64).saturating_mul(m as u64))
// Standard Error: 1_802
.saturating_add(Weight::from_ref_time(98_184 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:3 w:3)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: Alliance DepositOf (r:101 w:50)
// Storage: System Account (r:50 w:50)
@@ -229,67 +196,67 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// The range of component `y` is `[0, 100]`.
/// The range of component `z` is `[0, 50]`.
fn disband(x: u32, y: u32, z: u32, ) -> Weight {
// Minimum execution time: 256_235 nanoseconds.
Weight::from_ref_time(258_695_000 as u64)
// Standard Error: 19_643
.saturating_add(Weight::from_ref_time(436_821 as u64).saturating_mul(x as u64))
// Standard Error: 19_549
.saturating_add(Weight::from_ref_time(496_858 as u64).saturating_mul(y as u64))
// Standard Error: 39_062
.saturating_add(Weight::from_ref_time(9_169_692 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(4 as u64))
// Minimum execution time: 145_000 nanoseconds.
Weight::from_ref_time(147_000_000 as u64)
// Standard Error: 13_290
.saturating_add(Weight::from_ref_time(304_371 as u64).saturating_mul(x as u64))
// Standard Error: 13_226
.saturating_add(Weight::from_ref_time(330_798 as u64).saturating_mul(y as u64))
// Standard Error: 26_428
.saturating_add(Weight::from_ref_time(7_207_748 as u64).saturating_mul(z as u64))
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(y as u64)))
.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(z as u64)))
.saturating_add(T::DbWeight::get().writes(5 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(z as u64)))
}
// Storage: Alliance Rule (r:0 w:1)
fn set_rule() -> Weight {
// Minimum execution time: 19_205 nanoseconds.
Weight::from_ref_time(19_502_000 as u64)
// Minimum execution time: 11_000 nanoseconds.
Weight::from_ref_time(12_000_000 as u64)
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Alliance Announcements (r:1 w:1)
fn announce() -> Weight {
// Minimum execution time: 22_562 nanoseconds.
Weight::from_ref_time(22_842_000 as u64)
// Minimum execution time: 13_000 nanoseconds.
Weight::from_ref_time(14_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Alliance Announcements (r:1 w:1)
fn remove_announcement() -> Weight {
// Minimum execution time: 23_773 nanoseconds.
Weight::from_ref_time(24_212_000 as u64)
// Minimum execution time: 14_000 nanoseconds.
Weight::from_ref_time(14_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:4 w:1)
// Storage: Alliance Members (r:3 w:1)
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: Alliance DepositOf (r:0 w:1)
fn join_alliance() -> Weight {
// Minimum execution time: 57_709 nanoseconds.
Weight::from_ref_time(59_155_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
// Minimum execution time: 39_000 nanoseconds.
Weight::from_ref_time(41_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:4 w:1)
// Storage: Alliance Members (r:3 w:1)
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
fn nominate_ally() -> Weight {
// Minimum execution time: 44_576 nanoseconds.
Weight::from_ref_time(45_162_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:3 w:2)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: AllianceMotion Members (r:0 w:1)
// Storage: AllianceMotion Prime (r:0 w:1)
fn elevate_ally() -> Weight {
// Minimum execution time: 38_913 nanoseconds.
Weight::from_ref_time(39_637_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(24_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(3 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
// Storage: Alliance Members (r:4 w:2)
@@ -298,8 +265,8 @@ 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 {
// Minimum execution time: 42_947 nanoseconds.
Weight::from_ref_time(43_414_000 as u64)
// Minimum execution time: 31_000 nanoseconds.
Weight::from_ref_time(32_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(5 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
@@ -308,8 +275,8 @@ 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 {
// Minimum execution time: 46_281 nanoseconds.
Weight::from_ref_time(46_703_000 as u64)
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
@@ -320,8 +287,8 @@ 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 {
// Minimum execution time: 65_274 nanoseconds.
Weight::from_ref_time(65_762_000 as u64)
// Minimum execution time: 45_000 nanoseconds.
Weight::from_ref_time(47_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(6 as u64))
.saturating_add(T::DbWeight::get().writes(5 as u64))
}
@@ -330,12 +297,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
/// The range of component `n` is `[0, 100]`.
/// The range of component `l` is `[0, 255]`.
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight {
// Minimum execution time: 17_396 nanoseconds.
Weight::from_ref_time(17_638_000 as u64)
// Standard Error: 2_602
.saturating_add(Weight::from_ref_time(1_286_177 as u64).saturating_mul(n as u64))
// Standard Error: 1_019
.saturating_add(Weight::from_ref_time(70_947 as u64).saturating_mul(l as u64))
// Minimum execution time: 9_000 nanoseconds.
Weight::from_ref_time(9_512_816 as u64)
// Standard Error: 2_976
.saturating_add(Weight::from_ref_time(560_175 as u64).saturating_mul(n as u64))
// Standard Error: 1_169
.saturating_add(Weight::from_ref_time(24_530 as u64).saturating_mul(l as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
@@ -343,16 +310,24 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
// Storage: Alliance UnscrupulousWebsites (r:1 w:1)
/// The range of component `n` is `[0, 100]`.
/// The range of component `l` is `[0, 255]`.
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight {
// Minimum execution time: 17_446 nanoseconds.
Weight::from_ref_time(17_725_000 as u64)
// Standard Error: 163_579
.saturating_add(Weight::from_ref_time(12_823_232 as u64).saturating_mul(n as u64))
// Standard Error: 64_064
.saturating_add(Weight::from_ref_time(496_642 as u64).saturating_mul(l as u64))
fn remove_unscrupulous_items(n: u32, _l: u32, ) -> Weight {
// Minimum execution time: 10_000 nanoseconds.
Weight::from_ref_time(10_000_000 as u64)
// Standard Error: 94_049
.saturating_add(Weight::from_ref_time(10_887_604 as u64).saturating_mul(n as u64))
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(2 as u64))
}
// Storage: Alliance Members (r:3 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: AllianceMotion Members (r:0 w:1)
// Storage: AllianceMotion Prime (r:0 w:1)
fn abdicate_fellow_status() -> Weight {
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(T::DbWeight::get().reads(4 as u64))
.saturating_add(T::DbWeight::get().writes(4 as u64))
}
}
// For backwards compatibility and tests
@@ -363,31 +338,29 @@ impl WeightInfo for () {
// Storage: AllianceMotion ProposalCount (r:1 w:1)
// Storage: AllianceMotion Voting (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 `[0, 90]`.
/// The range of component `m` is `[2, 100]`.
/// The range of component `p` is `[1, 100]`.
fn propose_proposed(_b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 43_720 nanoseconds.
Weight::from_ref_time(44_766_307 as u64)
// Standard Error: 2_522
.saturating_add(Weight::from_ref_time(54_721 as u64).saturating_mul(y as u64))
// Standard Error: 2_301
.saturating_add(Weight::from_ref_time(173_300 as u64).saturating_mul(p as u64))
fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(24_357_172 as u64)
// Standard Error: 428
.saturating_add(Weight::from_ref_time(233 as u64).saturating_mul(b as u64))
// Standard Error: 4_474
.saturating_add(Weight::from_ref_time(48_024 as u64).saturating_mul(m as u64))
// Standard Error: 4_418
.saturating_add(Weight::from_ref_time(97_604 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
// Storage: Alliance Members (r:2 w:0)
// Storage: Alliance Members (r:1 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 {
// Minimum execution time: 46_984 nanoseconds.
Weight::from_ref_time(46_837_255 as u64)
// Standard Error: 32_860
.saturating_add(Weight::from_ref_time(273_691 as u64).saturating_mul(x as u64))
// Standard Error: 2_781
.saturating_add(Weight::from_ref_time(126_964 as u64).saturating_mul(y as u64))
.saturating_add(RocksDbWeight::get().reads(3 as u64))
/// The range of component `m` is `[5, 100]`.
fn vote(m: u32, ) -> Weight {
// Minimum execution time: 24_000 nanoseconds.
Weight::from_ref_time(26_617_201 as u64)
// Standard Error: 4_280
.saturating_add(Weight::from_ref_time(43_152 as u64).saturating_mul(m as u64))
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:1 w:0)
@@ -396,10 +369,10 @@ impl WeightInfo for () {
// Storage: AllianceMotion Voting (r:0 w:1)
/// The range of component `p` is `[1, 100]`.
fn veto(p: u32, ) -> Weight {
// Minimum execution time: 34_734 nanoseconds.
Weight::from_ref_time(37_652_708 as u64)
// Standard Error: 1_270
.saturating_add(Weight::from_ref_time(183_078 as u64).saturating_mul(p as u64))
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(26_045_752 as u64)
// Standard Error: 2_154
.saturating_add(Weight::from_ref_time(61_220 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(3 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
@@ -408,18 +381,15 @@ impl WeightInfo for () {
// Storage: AllianceMotion Members (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 `m` is `[4, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_early_disapproved(x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 50_147 nanoseconds.
Weight::from_ref_time(42_719_616 as u64)
// Standard Error: 19_981
.saturating_add(Weight::from_ref_time(188_796 as u64).saturating_mul(x as u64))
// Standard Error: 1_947
.saturating_add(Weight::from_ref_time(95_998 as u64).saturating_mul(y as u64))
// Standard Error: 1_739
.saturating_add(Weight::from_ref_time(177_837 as u64).saturating_mul(p as u64))
fn close_early_disapproved(m: u32, p: u32, ) -> Weight {
// Minimum execution time: 30_000 nanoseconds.
Weight::from_ref_time(25_697_866 as u64)
// Standard Error: 3_827
.saturating_add(Weight::from_ref_time(48_360 as u64).saturating_mul(m as u64))
// Standard Error: 3_731
.saturating_add(Weight::from_ref_time(116_922 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
@@ -429,20 +399,17 @@ impl WeightInfo for () {
// Storage: AllianceMotion ProposalOf (r:1 w:1)
// Storage: AllianceMotion Proposals (r:1 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 `m` is `[4, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_early_approved(b: u32, x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 59_495 nanoseconds.
Weight::from_ref_time(53_137_721 as u64)
// Standard Error: 138
.saturating_add(Weight::from_ref_time(1_979 as u64).saturating_mul(b as u64))
// Standard Error: 16_388
.saturating_add(Weight::from_ref_time(8_198 as u64).saturating_mul(x as u64))
// Standard Error: 1_599
.saturating_add(Weight::from_ref_time(86_577 as u64).saturating_mul(y as u64))
// Standard Error: 1_428
.saturating_add(Weight::from_ref_time(215_905 as u64).saturating_mul(p as u64))
fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 34_000 nanoseconds.
Weight::from_ref_time(30_725_464 as u64)
// Standard Error: 370
.saturating_add(Weight::from_ref_time(2_367 as u64).saturating_mul(b as u64))
// Standard Error: 3_920
.saturating_add(Weight::from_ref_time(40_710 as u64).saturating_mul(m as u64))
// Standard Error: 3_822
.saturating_add(Weight::from_ref_time(111_866 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
@@ -452,16 +419,15 @@ impl WeightInfo for () {
// 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 `m` is `[2, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_disapproved(_x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 52_405 nanoseconds.
Weight::from_ref_time(44_494_732 as u64)
// Standard Error: 1_759
.saturating_add(Weight::from_ref_time(118_517 as u64).saturating_mul(y as u64))
// Standard Error: 1_572
.saturating_add(Weight::from_ref_time(198_256 as u64).saturating_mul(p as u64))
fn close_disapproved(m: u32, p: u32, ) -> Weight {
// Minimum execution time: 31_000 nanoseconds.
Weight::from_ref_time(29_444_599 as u64)
// Standard Error: 4_043
.saturating_add(Weight::from_ref_time(48_928 as u64).saturating_mul(m as u64))
// Standard Error: 3_994
.saturating_add(Weight::from_ref_time(76_527 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
@@ -472,39 +438,33 @@ impl WeightInfo for () {
// Storage: AllianceMotion Proposals (r:1 w:1)
// 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 `m` is `[5, 100]`.
/// The range of component `p` is `[1, 100]`.
fn close_approved(b: u32, _x: u32, y: u32, p: u32, ) -> Weight {
// Minimum execution time: 52_737 nanoseconds.
Weight::from_ref_time(45_874_458 as u64)
// Standard Error: 140
.saturating_add(Weight::from_ref_time(601 as u64).saturating_mul(b as u64))
// Standard Error: 1_623
.saturating_add(Weight::from_ref_time(88_372 as u64).saturating_mul(y as u64))
// Standard Error: 1_449
.saturating_add(Weight::from_ref_time(197_595 as u64).saturating_mul(p as u64))
fn close_approved(_b: u32, m: u32, p: u32, ) -> Weight {
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(32_315_075 as u64)
// Standard Error: 4_502
.saturating_add(Weight::from_ref_time(43_205 as u64).saturating_mul(m as u64))
// Standard Error: 4_340
.saturating_add(Weight::from_ref_time(101_872 as u64).saturating_mul(p as u64))
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:3 w:3)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Members (r:1 w:1)
/// The range of component `x` is `[1, 10]`.
/// The range of component `y` is `[0, 90]`.
/// The range of component `m` is `[1, 100]`.
/// The range of component `z` is `[0, 100]`.
fn init_members(x: u32, y: u32, z: u32, ) -> Weight {
// Minimum execution time: 48_821 nanoseconds.
Weight::from_ref_time(32_972_152 as u64)
// Standard Error: 17_618
.saturating_add(Weight::from_ref_time(230_451 as u64).saturating_mul(x as u64))
// Standard Error: 1_865
.saturating_add(Weight::from_ref_time(172_532 as u64).saturating_mul(y as u64))
// Standard Error: 1_682
.saturating_add(Weight::from_ref_time(145_258 as u64).saturating_mul(z as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
fn init_members(m: u32, z: u32, ) -> Weight {
// Minimum execution time: 22_000 nanoseconds.
Weight::from_ref_time(13_523_882 as u64)
// Standard Error: 1_823
.saturating_add(Weight::from_ref_time(91_625 as u64).saturating_mul(m as u64))
// Standard Error: 1_802
.saturating_add(Weight::from_ref_time(98_184 as u64).saturating_mul(z as u64))
.saturating_add(RocksDbWeight::get().reads(3 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:3 w:3)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: Alliance DepositOf (r:101 w:50)
// Storage: System Account (r:50 w:50)
@@ -514,67 +474,67 @@ impl WeightInfo for () {
/// The range of component `y` is `[0, 100]`.
/// The range of component `z` is `[0, 50]`.
fn disband(x: u32, y: u32, z: u32, ) -> Weight {
// Minimum execution time: 256_235 nanoseconds.
Weight::from_ref_time(258_695_000 as u64)
// Standard Error: 19_643
.saturating_add(Weight::from_ref_time(436_821 as u64).saturating_mul(x as u64))
// Standard Error: 19_549
.saturating_add(Weight::from_ref_time(496_858 as u64).saturating_mul(y as u64))
// Standard Error: 39_062
.saturating_add(Weight::from_ref_time(9_169_692 as u64).saturating_mul(z as u64))
.saturating_add(RocksDbWeight::get().reads(4 as u64))
// Minimum execution time: 145_000 nanoseconds.
Weight::from_ref_time(147_000_000 as u64)
// Standard Error: 13_290
.saturating_add(Weight::from_ref_time(304_371 as u64).saturating_mul(x as u64))
// Standard Error: 13_226
.saturating_add(Weight::from_ref_time(330_798 as u64).saturating_mul(y as u64))
// Standard Error: 26_428
.saturating_add(Weight::from_ref_time(7_207_748 as u64).saturating_mul(z as u64))
.saturating_add(RocksDbWeight::get().reads(3 as u64))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64)))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(y as u64)))
.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(z as u64)))
.saturating_add(RocksDbWeight::get().writes(5 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(z as u64)))
}
// Storage: Alliance Rule (r:0 w:1)
fn set_rule() -> Weight {
// Minimum execution time: 19_205 nanoseconds.
Weight::from_ref_time(19_502_000 as u64)
// Minimum execution time: 11_000 nanoseconds.
Weight::from_ref_time(12_000_000 as u64)
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: Alliance Announcements (r:1 w:1)
fn announce() -> Weight {
// Minimum execution time: 22_562 nanoseconds.
Weight::from_ref_time(22_842_000 as u64)
// Minimum execution time: 13_000 nanoseconds.
Weight::from_ref_time(14_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: Alliance Announcements (r:1 w:1)
fn remove_announcement() -> Weight {
// Minimum execution time: 23_773 nanoseconds.
Weight::from_ref_time(24_212_000 as u64)
// Minimum execution time: 14_000 nanoseconds.
Weight::from_ref_time(14_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(1 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:4 w:1)
// Storage: Alliance Members (r:3 w:1)
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
// Storage: System Account (r:1 w:1)
// Storage: Alliance DepositOf (r:0 w:1)
fn join_alliance() -> Weight {
// Minimum execution time: 57_709 nanoseconds.
Weight::from_ref_time(59_155_000 as u64)
.saturating_add(RocksDbWeight::get().reads(6 as u64))
// Minimum execution time: 39_000 nanoseconds.
Weight::from_ref_time(41_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(3 as u64))
}
// Storage: Alliance Members (r:4 w:1)
// Storage: Alliance Members (r:3 w:1)
// Storage: Alliance UnscrupulousAccounts (r:1 w:0)
fn nominate_ally() -> Weight {
// Minimum execution time: 44_576 nanoseconds.
Weight::from_ref_time(45_162_000 as u64)
.saturating_add(RocksDbWeight::get().reads(5 as u64))
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(1 as u64))
}
// Storage: Alliance Members (r:3 w:2)
// Storage: Alliance Members (r:2 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: AllianceMotion Members (r:0 w:1)
// Storage: AllianceMotion Prime (r:0 w:1)
fn elevate_ally() -> Weight {
// Minimum execution time: 38_913 nanoseconds.
Weight::from_ref_time(39_637_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
// Minimum execution time: 23_000 nanoseconds.
Weight::from_ref_time(24_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(3 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
// Storage: Alliance Members (r:4 w:2)
@@ -583,8 +543,8 @@ impl WeightInfo for () {
// Storage: AllianceMotion Prime (r:0 w:1)
// Storage: Alliance RetiringMembers (r:0 w:1)
fn give_retirement_notice() -> Weight {
// Minimum execution time: 42_947 nanoseconds.
Weight::from_ref_time(43_414_000 as u64)
// Minimum execution time: 31_000 nanoseconds.
Weight::from_ref_time(32_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(5 as u64))
.saturating_add(RocksDbWeight::get().writes(5 as u64))
}
@@ -593,8 +553,8 @@ impl WeightInfo for () {
// Storage: Alliance DepositOf (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn retire() -> Weight {
// Minimum execution time: 46_281 nanoseconds.
Weight::from_ref_time(46_703_000 as u64)
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
@@ -605,8 +565,8 @@ impl WeightInfo for () {
// Storage: AllianceMotion Members (r:0 w:1)
// Storage: AllianceMotion Prime (r:0 w:1)
fn kick_member() -> Weight {
// Minimum execution time: 65_274 nanoseconds.
Weight::from_ref_time(65_762_000 as u64)
// Minimum execution time: 45_000 nanoseconds.
Weight::from_ref_time(47_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(6 as u64))
.saturating_add(RocksDbWeight::get().writes(5 as u64))
}
@@ -615,12 +575,12 @@ impl WeightInfo for () {
/// The range of component `n` is `[0, 100]`.
/// The range of component `l` is `[0, 255]`.
fn add_unscrupulous_items(n: u32, l: u32, ) -> Weight {
// Minimum execution time: 17_396 nanoseconds.
Weight::from_ref_time(17_638_000 as u64)
// Standard Error: 2_602
.saturating_add(Weight::from_ref_time(1_286_177 as u64).saturating_mul(n as u64))
// Standard Error: 1_019
.saturating_add(Weight::from_ref_time(70_947 as u64).saturating_mul(l as u64))
// Minimum execution time: 9_000 nanoseconds.
Weight::from_ref_time(9_512_816 as u64)
// Standard Error: 2_976
.saturating_add(Weight::from_ref_time(560_175 as u64).saturating_mul(n as u64))
// Standard Error: 1_169
.saturating_add(Weight::from_ref_time(24_530 as u64).saturating_mul(l as u64))
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
}
@@ -628,14 +588,22 @@ impl WeightInfo for () {
// Storage: Alliance UnscrupulousWebsites (r:1 w:1)
/// The range of component `n` is `[0, 100]`.
/// The range of component `l` is `[0, 255]`.
fn remove_unscrupulous_items(n: u32, l: u32, ) -> Weight {
// Minimum execution time: 17_446 nanoseconds.
Weight::from_ref_time(17_725_000 as u64)
// Standard Error: 163_579
.saturating_add(Weight::from_ref_time(12_823_232 as u64).saturating_mul(n as u64))
// Standard Error: 64_064
.saturating_add(Weight::from_ref_time(496_642 as u64).saturating_mul(l as u64))
fn remove_unscrupulous_items(n: u32, _l: u32, ) -> Weight {
// Minimum execution time: 10_000 nanoseconds.
Weight::from_ref_time(10_000_000 as u64)
// Standard Error: 94_049
.saturating_add(Weight::from_ref_time(10_887_604 as u64).saturating_mul(n as u64))
.saturating_add(RocksDbWeight::get().reads(2 as u64))
.saturating_add(RocksDbWeight::get().writes(2 as u64))
}
// Storage: Alliance Members (r:3 w:2)
// Storage: AllianceMotion Proposals (r:1 w:0)
// Storage: AllianceMotion Members (r:0 w:1)
// Storage: AllianceMotion Prime (r:0 w:1)
fn abdicate_fellow_status() -> Weight {
// Minimum execution time: 29_000 nanoseconds.
Weight::from_ref_time(30_000_000 as u64)
.saturating_add(RocksDbWeight::get().reads(4 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
}