Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
drop veto call
  • Loading branch information
muharem committed Nov 22, 2022
commit eed82830c336e720a2d9daf1984d951adbca2080
4 changes: 0 additions & 4 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions frame/alliance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ to update the Alliance's rule and make announcements.
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:
FoundingFellow, Fellow, or Ally. A member can also be kicked by the `MembershipManager` origin
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.
Expand All @@ -51,7 +49,6 @@ to update the Alliance's rule and make announcements.

- `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 @@ -65,5 +62,5 @@ to update the Alliance's rule and make announcements.

#### 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.
42 changes: 0 additions & 42 deletions frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,48 +210,6 @@ 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 fellows = (0 .. m).map(fellow::<T, I>).collect::<Vec<_>>();
let vetor = fellows[0].clone();

Alliance::<T, I>::init_members(
SystemOrigin::Root.into(),
fellows,
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 as a minimum so we always trigger a vote in the voting loop (`for j in ...`)
let m in 4 .. T::MaxFellows::get();
Expand Down
27 changes: 0 additions & 27 deletions frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
//!
//! - `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 Down Expand Up @@ -186,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,
Expand Down Expand Up @@ -354,8 +349,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`.
Expand Down Expand Up @@ -546,26 +539,6 @@ 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 Fellow.
#[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::has_voting_rights(&proposor), Error::<T, I>::NoVotingRights);

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.
///
/// Must be called by a Fellow.
Expand Down
8 changes: 0 additions & 8 deletions frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ impl ProposalProvider<AccountId, 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,
Expand Down Expand Up @@ -382,10 +378,6 @@ 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: AccountId) -> (RuntimeCall, u32, H256) {
make_proposal(RuntimeCall::Alliance(pallet_alliance::Call::kick_member { who }))
}
Expand Down
50 changes: 0 additions & 50 deletions frame/alliance/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,56 +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
));

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(|| {
Expand Down