namada
namada copied to clipboard
Improve governance voting logic
Describe your changes
Closes #2523.
Summary of changes w.r.t the delegation validators and governance voting:
- client:
- if voter is validator, client will return error if validator is inactive or jailed in the current epoch
- if delegator, client just ensures it has delegations. Does not filter based on the bond validator's state
- wasm tx:
- fetches the delegation validators in the current epoch, passes them into
vote_proposal
, which writes a vote key to storage for each. Does not filter based on the bond validator's state
- fetches the delegation validators in the current epoch, passes them into
- gov VP:
is_valid_vote_key
does not filter based on the bond validator's state.
Almost no filtering is done in when a vote tx is submitted and vote keys are written into a storage for a proposal. This is because the state of a validator at the tally epoch, which is the voting end epoch, cannot necessarily be known at the epoch of vote submission. We should allow, for example, a delegator to submit a vote for a bond to an inactive validator, which may be active by the time the tally epoch comes around.
Ultimately in compute_proposal_votes
, a vote will only be counted if the validator is active at the end epoch - in consensus, below-capacity, or below-threshold. We rely on this step to do the proper filtering.
Filtering is performed, however, by preventing a delegator with no delegations from submitting a valid vote tx and by preventing a validator that is currently jailed or inactive from submitting a valid vote tx.
Indicate on which release or other PRs this topic is based on
v0.34.0
Checklist before merging to draft
- [x] I have added a changelog
- [x] Git history is in acceptable state
There's a failing unit test and I left a minor comment. Overall it looks good to me but I'd like a second opinion from @brentstone especially for the query and sdk files
Codecov Report
Attention: Patch coverage is 59.83607%
with 49 lines
in your changes are missing coverage. Please review.
Project coverage is 59.46%. Comparing base (
9d4de02
) to head (48aba22
). Report is 2 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #3120 +/- ##
==========================================
+ Coverage 59.40% 59.46% +0.05%
==========================================
Files 298 298
Lines 92326 92332 +6
==========================================
+ Hits 54849 54904 +55
+ Misses 37477 37428 -49
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@Fraccaman @grarco I fixed up the logic in here and also summarized the changes in the PR description. Lmk your thoughts