namada icon indicating copy to clipboard operation
namada copied to clipboard

Improve governance voting logic

Open Fraccaman opened this issue 10 months ago • 3 comments

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
  • 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

Fraccaman avatar Apr 24 '24 09:04 Fraccaman

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

grarco avatar Apr 29 '24 13:04 grarco

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.

Files Patch % Lines
crates/sdk/src/tx.rs 0.00% 25 Missing :warning:
crates/proof_of_stake/src/storage.rs 0.00% 11 Missing :warning:
...rates/apps/src/lib/node/ledger/shell/governance.rs 0.00% 8 Missing :warning:
crates/sdk/src/queries/vp/pos.rs 0.00% 3 Missing :warning:
crates/light_sdk/src/transaction/governance.rs 0.00% 2 Missing :warning:
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.

codecov[bot] avatar Apr 30 '24 03:04 codecov[bot]

@Fraccaman @grarco I fixed up the logic in here and also summarized the changes in the PR description. Lmk your thoughts

brentstone avatar Apr 30 '24 03:04 brentstone