-
Notifications
You must be signed in to change notification settings - Fork 3
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
Allowing to unvote without having to switch to a new vote #218
Allowing to unvote without having to switch to a new vote #218
Conversation
4837a83
to
9a3ac9d
Compare
contracts/hydro/src/vote.rs
Outdated
|
||
let lock_entry = &lock_entries[&lock_id]; | ||
|
||
// If user didn't yet vote with the given lock in the given round and tranche, check |
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.
The comment seems outdated now. We don't have an explicit check anymore for whether the user has voted in the given round/tranche; if they already voted in this round, then implicitly their old VOTING_ALLOWED_ROUND was erased during process_unvotes
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. Since this is a bit of a bigger change that touches core logic, I want to get a second set of eyes on it, so not approving yet.
Thanks a ton for the contribution!
The merge conflicts with main are quite small (regenerating checksums/artifacts/schema and organizing changelog). I don't think I have permission to fix them (since the PR is from the moonkitt-lab hydro repo), could you take care of it? The only thing to pay attention to is that the merge automatically tried to put your changelog entry into 3.0.0 (it should stay in unreleased). Thanks! |
PR is fixed and should resolve conflicts. The changelog entry is kept in |
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.
Left a few minor comments, but otherwise looks great to me! Thanks for your contribution!
Will need to be rebased, has some merge conflicts with main.
contracts/hydro/src/vote.rs
Outdated
locks_voted.push(lock_id); | ||
} | ||
|
||
voted_proposals.push(proposal_id); |
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.
If all locks specified to vote for some proposal were skipped (for one reason or another), we would still insert that proposal ID here as voted. This seams to be the issue that existed before your PR. Can we fix this as well, by converting voted_proposals
into HashSet<u64>
and insert the proposal ID into it each time locks_voted.push(lock_id);
is executed? Since it will be a Set there will be no duplicates. And then just convert it into Vec<u64>
. WDYT?
contracts/hydro/src/score_keeper.rs
Outdated
update1 | ||
.validator_shares | ||
.entry(validator) | ||
.and_modify(|existing| *existing += shares) |
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.
Can we have this function filter-out 0 values for some validator from the resulting HashSet? E.g. if we have
updates1: (proposal1, validator1) -500
updates2: (proposal1, validator1) +500
This should result in no entry for (proposal1, validator1).
* Introduce compounder cap (#220) * introduce participant's cap * Introduce snapshot map for total voting power tracking and handle its population * Added round<->height tracking and implemented validation for users locking in extra_cap based on their voting power in previous round. * Introduced USER_LOCKS to be able to calculate users voting power at a given height * - Added test for compunders cap and fixed couple of minor bugs within the new code - validate_denom() modified to be able to execute for past rounds as well * fixing errors after merge from main * added tests for user lock snapshoting and heght<->round tracking * added transaction to remove the constants at a specified timestamps * implementation of migration * CR required changes * added SNAPSHOTS_ACTIVATION_HEIGHT * added migration tests * added changelogs, recompiled contracts and schemas * added util function for ICQ results mock * fixed interchain tests (#222) * borrow input Deps, Env and MessageInfo whenever possible (#224) * Allowing to unvote without having to switch to a new vote (#218) * Refactoring vote and adding unvote feature * Make clippy happy * Remove unnecessary unvoted_proposals in process_unvotes * Adding a test case for unvote * Update wasms * Improving readability by adding / restoring comments, renaming variables * Store vote and voting allowed round directly in process_votes * Adding new test: attempts to unvote non-existing or not-owned locks should fail * Adding changelog * Fix HydroBase.client.ts as generated by make schema * Addressing Dusan's comments * Hydro DAO DAO governance support (#226) * implement hydro DAO DAO governance support * added changelog * CR changes * Prepare release for v3.1.0 (#227) * Prepare v3.1.0 release * Regenerate schema * Regenerate client types * Change migration and version to v3.1.0 * Fix migration mod --------- Co-authored-by: arlai <[email protected]> Co-authored-by: Philip Offtermatt <[email protected]>
Description
Closes: #211
This PR introduces a new
Unvote
message allowing users to remove their votes from specific tranches by specifying lock IDs. Additionally, it includes a significant refactor of the voting system to optimize storage operations and improve code organization.Key Changes
Unvote
message type for explicit vote removalvote.rs
moduleImplementation Details
New Files
vote.rs
module containing:process_votes
: Handles new vote application, once any previous vote has been removedprocess_unvotes
: Manages vote removalvalidate_proposals_and_locks_for_voting
: Input validation prior to votingMajor Improvements
Optimized Vote Processing
Enhanced Storage Operations
add_many_validator_shares_to_proposal
function supporting both positive and negative changesSCALED_PROPOSAL_SHARES_MAP
andPROPOSAL_TOTAL_MAP
Code Organization
Minor Changes
While maintaining full functional compatibility, there are minor changes to the
Vote
message's response attributes: locks re-voting for the same proposal are now included in thelocks_skipped
attribute rather than thelocks_voted
attribute.Testing Notes
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
.changelog
make compile
and included content of the artifacts directory into the PRmake schema
and included generated files into the PR