Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Allow Alliance Fellows to Give Up Voting Rights #12730

Merged
merged 6 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,8 +1574,8 @@ impl pallet_collective::Config<AllianceCollective> for Runtime {
}

parameter_types! {
pub const MaxFounders: u32 = 10;
pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFounders::get();
pub const MaxFoundingFellows: u32 = 10;
pub const MaxFellows: u32 = AllianceMaxMembers::get() - MaxFoundingFellows::get();
pub const MaxAllies: u32 = 100;
pub const AllyDeposit: Balance = 10 * DOLLARS;
pub const RetirementPeriod: BlockNumber = ALLIANCE_MOTION_DURATION_IN_BLOCKS + (1 * DAYS);
Expand Down Expand Up @@ -1606,7 +1606,7 @@ impl pallet_alliance::Config for Runtime {
type IdentityVerifier = ();
type ProposalProvider = AllianceProposalProvider;
type MaxProposals = AllianceMaxProposals;
type MaxFounders = MaxFounders;
type MaxFoundingFellows = MaxFoundingFellows;
type MaxFellows = MaxFellows;
type MaxAllies = MaxAllies;
type MaxUnscrupulousItems = ConstU32<100>;
Expand Down
35 changes: 17 additions & 18 deletions frame/alliance/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -19,19 +19,19 @@ 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.
FoundingFellow, 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.
- FoundingFellow: Operationally equivalent to a Fellow, but set by Root in the initialization of
the Alliance.
- 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

Expand All @@ -43,13 +43,15 @@ 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.
- `veto` - Veto on a motion about `set_rule` and `elevate_ally`.
- `close` - Close a motion with enough votes or that has expired.
- `set_rule` - Initialize or update the Alliance's rule by IPFS CID.
- `announce` - Make announcement by IPFS CID.
Expand All @@ -59,10 +61,7 @@ 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

Expand Down
41 changes: 27 additions & 14 deletions frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ 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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we set only two members for each role here.
for a worst case benches we will need to init Max* members for every role.
But this does not concern this PR

Members::<T, I>::insert(MemberRole::Founder, founders.clone());
Members::<T, I>::insert(MemberRole::FoundingFellow, founders.clone());

let fellows: BoundedVec<_, T::MaxMembersCount> =
BoundedVec::try_from(vec![fellow::<T, I>(1), fellow::<T, I>(2)]).unwrap();
Expand All @@ -109,7 +109,7 @@ 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 x in 2 .. T::MaxFoundingFellows::get();
let y in 0 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();

Expand Down Expand Up @@ -155,7 +155,7 @@ 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 x in 3 .. T::MaxFoundingFellows::get();
let y in 2 .. T::MaxFellows::get();

let m = x + y;
Expand Down Expand Up @@ -275,7 +275,7 @@ benchmarks_instance_pallet! {

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 x in 2 .. T::MaxFoundingFellows::get();
let y in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();

Expand Down Expand Up @@ -362,7 +362,7 @@ 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 x in 2 .. T::MaxFoundingFellows::get();
let y in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();

Expand Down Expand Up @@ -451,7 +451,7 @@ 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 x in 2 .. T::MaxFoundingFellows::get();
let y in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();

Expand Down Expand Up @@ -529,7 +529,7 @@ 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 x in 2 .. T::MaxFoundingFellows::get();
let y in 2 .. T::MaxFellows::get();
let p in 1 .. T::MaxProposals::get();

Expand Down Expand Up @@ -606,7 +606,7 @@ benchmarks_instance_pallet! {

init_members {
// at least 1 founders
let x in 1 .. T::MaxFounders::get();
let x in 1 .. T::MaxFoundingFellows::get();
let y in 0 .. T::MaxFellows::get();
let z in 0 .. T::MaxAllies::get();

Expand All @@ -624,14 +624,14 @@ benchmarks_instance_pallet! {
fellows: fellows.clone(),
allies: allies.clone(),
}.into());
assert_eq!(Alliance::<T, I>::members(MemberRole::Founder), founders);
assert_eq!(Alliance::<T, I>::members(MemberRole::FoundingFellow), 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::MaxFoundingFellows::get() + T::MaxFellows::get();
let y in 0 .. T::MaxAllies::get();
let z in 0 .. T::MaxMembersCount::get() / 2;

Expand Down Expand Up @@ -733,7 +733,7 @@ benchmarks_instance_pallet! {
set_members::<T, I>();

let founder1 = founder::<T, I>(1);
assert!(Alliance::<T, I>::is_member_of(&founder1, MemberRole::Founder));
assert!(Alliance::<T, I>::is_member_of(&founder1, MemberRole::FoundingFellow));

let outsider = outsider::<T, I>(1);
assert!(!Alliance::<T, I>::is_member(&outsider));
Expand Down Expand Up @@ -764,15 +764,15 @@ 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());
}

give_retirement_notice {
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));
Expand All @@ -790,7 +790,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(
Expand Down Expand Up @@ -885,5 +885,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::MemberAbdicated {member: fellow2}.into()
);
}

impl_benchmark_test_suite!(Alliance, crate::mock::new_bench_ext(), crate::mock::Test);
}
Loading