-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reject proposals early #668
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f48dbce
Reject proposals when they cannot pass.
Callum-A a46886e
lint
Callum-A f770502
Add flex tests
Callum-A 8cb9e80
Address feedback
Callum-A a231a2e
Update contracts/cw3-flex-multisig/src/contract.rs
Callum-A 4cc1159
Update contracts/cw3-fixed-multisig/src/state.rs
Callum-A 4a12462
Merge branch 'main' into main
Callum-A 8d0cf8d
Merge branch 'main' into main
ethanfrey 1b43acc
Address feedback
Callum-A 07d8530
Merge branch 'main' of https://github.com/Callum-A/cw-plus into main
Callum-A 3b326ee
Correct small error
Callum-A 7689360
Typo again
Callum-A 068d33f
Address feedback
Callum-A 92e01a4
Update comment. Circle CI
Callum-A File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,7 +81,6 @@ impl Proposal { | |
self.votes.yes >= votes_needed(opinions, threshold) | ||
} else { | ||
// If not expired, we must assume all non-votes will be cast against | ||
// vote_count | ||
let possible_opinions = self.total_weight - self.votes.abstain; | ||
self.votes.yes >= votes_needed(possible_opinions, threshold) | ||
} | ||
|
@@ -108,18 +107,16 @@ impl Proposal { | |
Decimal::one() - percentage_needed, | ||
) | ||
} | ||
Threshold::ThresholdQuorum { threshold, quorum } => { | ||
// we always require the quorum | ||
if self.votes.total() < votes_needed(self.total_weight, quorum) { | ||
return false; | ||
} | ||
Threshold::ThresholdQuorum { | ||
threshold, | ||
quorum: _, | ||
} => { | ||
if self.expires.is_expired(block) { | ||
// If expired, we compare vote_count against the total number of votes (minus abstain). | ||
let opinions = self.votes.total() - self.votes.abstain; | ||
self.votes.no > votes_needed(opinions, Decimal::one() - threshold) | ||
} else { | ||
// If not expired, we must assume all non-votes will be cast against | ||
// vote_count | ||
// If not expired, we must assume all non-votes will be cast for | ||
let possible_opinions = self.total_weight - self.votes.abstain; | ||
self.votes.no > votes_needed(possible_opinions, Decimal::one() - threshold) | ||
} | ||
|
@@ -464,12 +461,37 @@ mod test { | |
30, | ||
true | ||
)); | ||
// Under quorum means it cannot be rejected | ||
// (40% of 50 = 20), 13 votes casted | ||
|
||
// Under quorum and cannot reject as it is not expired | ||
assert!(!check_is_rejected( | ||
quorum.clone(), | ||
rejecting.clone(), | ||
50, | ||
false | ||
)); | ||
// Can reject when expired | ||
assert!(check_is_rejected( | ||
quorum.clone(), | ||
rejecting.clone(), | ||
50, | ||
true | ||
)); | ||
|
||
// Check edgecase where quorum is not met but we can reject | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯 |
||
// 35% vote no | ||
let quorum_edgecase = Threshold::ThresholdQuorum { | ||
threshold: Decimal::percent(67), | ||
quorum: Decimal::percent(40), | ||
}; | ||
assert!(check_is_rejected( | ||
quorum_edgecase, | ||
Votes { | ||
yes: 15, | ||
no: 35, | ||
abstain: 0, | ||
veto: 10 | ||
}, | ||
100, | ||
true | ||
)); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is proper place. Nice eye