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
DisputableVoting: Optimize quiet ending #1234
Conversation
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.
I have 2 general comments:
- Going from Absent to whatever else (Y or N) is not considered a flip, right? Just to clarify.
- Seeing the complexity, I’m even more convinced that I would do only one extension ;-P
Some other comments inline.
} else { | ||
// First, we make sure the extension is persisted, if are voting within the extension and it was not considered yet, we store it. | ||
// Note that we are trusting `_canVote`, if we reached this point, it means the vote's flip was already confirmed. | ||
if (getTimestamp64() >= _finalVoteEndDate(vote_)) { |
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.
This is definitely quite counter-intuitive! haha (but looks fine to me)
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.
I see, honestly I couldn't come up with a clearer but similarly optimized as this one to compute multiple extensions
}) | ||
}) | ||
}) | ||
}) |
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.
Nice tests!!
@bingen thx a lot for the review! let me know your thoughts :D |
… into improve_quiet_ending
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.
Looks good to me. Great improvement overall!!
@@ -256,10 +256,10 @@ contract DisputableVoting is IForwarder, DisputableAragonApp { | |||
* @param _supports Whether voter supports the vote | |||
*/ | |||
function vote(uint256 _voteId, bool _supports) external { | |||
Vote storage vote_ = _getVote(_voteId); | |||
require(_canVote(vote_, msg.sender), ERROR_CANNOT_VOTE); | |||
Vote storage _vote = _getVote(_voteId); |
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.
I meant only for function params, but this looks fine to me too.
* DisputableVoting: Improve quiet ending * DisputableVoting: Make `wasFlipped` implementation clearer * DisputableVoting: Use `_` prefix instead of suffix for vote storage variables * DisputableVoting: Fix linter * DisputableVoting: Use `_` prefix only for args
This PR introduces an improvement to the quiet ending feature. The main purpose is to compare the result at the beginning and at the end of the quiet ending period, and extend it only if it differs.