Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -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))
5 changes: 5 additions & 0 deletions crates/core/src/dec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
if scale > POS_DECIMAL_PRECISION {
Expand Down
42 changes: 21 additions & 21 deletions crates/governance/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -142,19 +142,19 @@ impl TallyResult {
total_voting_power: VotePower,
) -> Result<Self, arith::Error> {
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(
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -1167,7 +1167,7 @@ mod test {
let proposal_result = compute_proposal_result(
proposal_votes.clone(),
token::Amount::from(200),
TallyType::TwoThirds,
TallyType::TwoFifths,
)
.unwrap();

Expand Down