From 3421d01e66f692452520a0b8a132ded4d92e3c14 Mon Sep 17 00:00:00 2001 From: brentstone Date: Mon, 26 Aug 2024 21:04:32 -0700 Subject: [PATCH 1/2] change quorum to 40% for default proposals --- crates/core/src/dec.rs | 5 ++++ crates/governance/src/utils.rs | 42 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/crates/core/src/dec.rs b/crates/core/src/dec.rs index 35d7b80116b..b14b5ce2ba7 100644 --- a/crates/core/src/dec.rs +++ b/crates/core/src/dec.rs @@ -149,6 +149,11 @@ impl Dec { Self::two().checked_div(3).expect("Cannot fail") } + /// The representation of 2 / 5 + pub fn two_fifths() -> Self { + Dec::new(4, 1).expect("Cannot fail") + } + /// Create a new [`Dec`] using a mantissa and a scale. pub fn new(mantissa: i128, scale: u8) -> Option { if scale > POS_DECIMAL_PRECISION { diff --git a/crates/governance/src/utils.rs b/crates/governance/src/utils.rs index d93ec8b23d5..65c39e87b46 100644 --- a/crates/governance/src/utils.rs +++ b/crates/governance/src/utils.rs @@ -71,7 +71,7 @@ impl Vote { pub enum TallyType { /// The `yay` votes are at least 2/3 of the non-abstain votes, and 2/3 of /// the total voting power has voted - TwoThirds, + TwoFifths, /// There are more `yay` votes than `nay` votes, and at least 1/3 of the /// total voting power has voted OneHalfOverOneThird, @@ -84,8 +84,8 @@ impl TallyType { /// The type of tally used for each proposal type pub fn from(proposal_type: ProposalType, is_steward: bool) -> Self { match (proposal_type, is_steward) { - (ProposalType::Default, _) => TallyType::TwoThirds, - (ProposalType::DefaultWithWasm(_), _) => TallyType::TwoThirds, + (ProposalType::Default, _) => TallyType::TwoFifths, + (ProposalType::DefaultWithWasm(_), _) => TallyType::TwoFifths, (ProposalType::PGFSteward(_), _) => TallyType::OneHalfOverOneThird, (ProposalType::PGFPayment(_), true) => { TallyType::LessOneHalfOverOneThirdNay @@ -142,19 +142,19 @@ impl TallyResult { total_voting_power: VotePower, ) -> Result { let passed = match tally_type { - TallyType::TwoThirds => { - let at_least_two_third_voted = Self::get_total_voted_power( + TallyType::TwoFifths => { + let at_least_two_fifths_voted = Self::get_total_voted_power( yay_voting_power, nay_voting_power, abstain_voting_power, )? >= total_voting_power - .mul_ceil(Dec::two_thirds())?; + .mul_ceil(Dec::two_fifths())?; // yay >= 2/3 * (yay + nay) ---> yay >= 2 * nay let at_least_two_third_voted_yay = yay_voting_power >= checked!(nay_voting_power + nay_voting_power)?; - at_least_two_third_voted && at_least_two_third_voted_yay + at_least_two_fifths_voted && at_least_two_third_voted_yay } TallyType::OneHalfOverOneThird => { let at_least_one_third_voted = Self::get_total_voted_power( @@ -246,7 +246,7 @@ impl ProposalResult { impl Display for ProposalResult { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let threshold = match self.tally_type { - TallyType::TwoThirds => { + TallyType::TwoFifths => { self.total_voting_power.mul_ceil(Dec::two_thirds()) } TallyType::LessOneHalfOverOneThirdNay => Ok(token::Amount::zero()), @@ -462,7 +462,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -500,7 +500,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -549,7 +549,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -598,7 +598,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -659,7 +659,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -727,7 +727,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -786,7 +786,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -843,7 +843,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -916,7 +916,7 @@ mod test { for tally_type in [ TallyType::OneHalfOverOneThird, TallyType::LessOneHalfOverOneThirdNay, - TallyType::TwoThirds, + TallyType::TwoFifths, ] { let proposal_result = compute_proposal_result( proposal_votes.clone(), @@ -989,7 +989,7 @@ mod test { let proposal_result = compute_proposal_result( proposal_votes.clone(), validator_voting_power.add(validator_voting_power_two), - TallyType::TwoThirds, + TallyType::TwoFifths, ) .unwrap(); @@ -1058,7 +1058,7 @@ mod test { let proposal_result = compute_proposal_result( proposal_votes.clone(), validator_voting_power.add(validator_voting_power_two), - TallyType::TwoThirds, + TallyType::TwoFifths, ) .unwrap(); @@ -1114,7 +1114,7 @@ mod test { let proposal_result = compute_proposal_result( proposal_votes.clone(), delegator_voting_power_two.add(delegator_voting_power), - TallyType::TwoThirds, + TallyType::TwoFifths, ) .unwrap(); @@ -1167,7 +1167,7 @@ mod test { let proposal_result = compute_proposal_result( proposal_votes.clone(), token::Amount::from(200), - TallyType::TwoThirds, + TallyType::TwoFifths, ) .unwrap(); From d52f49a42ec7e13b34176e3b1a99240950f77f88 Mon Sep 17 00:00:00 2001 From: brentstone Date: Mon, 26 Aug 2024 22:26:20 -0700 Subject: [PATCH 2/2] changelog: add #3703 --- .../unreleased/improvements/3703-change-default-gov-quorum.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/3703-change-default-gov-quorum.md diff --git a/.changelog/unreleased/improvements/3703-change-default-gov-quorum.md b/.changelog/unreleased/improvements/3703-change-default-gov-quorum.md new file mode 100644 index 00000000000..b29f7bde135 --- /dev/null +++ b/.changelog/unreleased/improvements/3703-change-default-gov-quorum.md @@ -0,0 +1,2 @@ +- Change the quorum for voting on a default governance proposal from 2/3 to 40%. + ([\#3703](https://github.com/anoma/namada/pull/3703)) \ No newline at end of file