feat: governance vote salt + quorum decay (#712)#759
Merged
greatest0fallt1me merged 1 commit intoJun 29, 2026
Merged
Conversation
Implement commit-reveal vote salt and quorum decay for governance proposals. Changes: - governance.rs: add commit_vote() / reveal_vote() with sha256 commitment verification, VoteCommitment storage key, and NoCommitment / InvalidReveal / CommitmentExists error variants; quorum decay was already present - events.rs: add GovernanceVoteCommittedEvent struct and emit_governance_vote_committed() helper - governance_tests.rs: add 8 focused salt tests covering the full commit-reveal lifecycle, wrong-salt rejection, duplicate-commit guard, double-reveal guard, and post-deadline rejection - docs/contracts/GOVERNANCE.md: full rewrite covering vote salt API, quorum decay formula, delegation rules, event table, error reference, and regression coverage index - contracts/predictify-hybrid/README.md: add Governance section with quick-reference snippets; retire placeholder future-enhancement entry
|
@almuslavish Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #712. Implements commit-reveal vote salt (prevents precomputation / front-running) and quorum decay (effective quorum decreases linearly toward a configurable floor after a proposal's deadline) for the
predictify-hybridgovernance module.Changes
src/governance.rsBytes/BytesNimports.StorageKey::VoteCommitment(Symbol, Address)— stores per-voter commitments.GovernanceErrorvariants:NoCommitment,InvalidReveal,CommitmentExists.commit_vote(env, voter, proposal_id, commitment)— storessha256(salt ++ support_byte)during the open voting window; guards against duplicate commits and mixing with direct votes.reveal_vote(env, voter, proposal_id, salt, support)— recomputes the hash, verifies against stored commitment, tallies vote with delegation weight, removes commitment to prevent double-reveal.compute_effective_quorum,set_quorum_decay,get_quorum_decay) was already implemented; no changes required.src/events.rsGovernanceVoteCommittedEventstruct (#[contracttype]).EventEmitter::emit_governance_vote_committed— publishes under topicgov_cmit.src/governance_tests.rsBytes/BytesNimports.commit_vote,reveal_vote, andmake_commitmenthelpers toGovernanceFixture.vote_salt_commit_reveal_full_lifecyclevote_salt_wrong_reveal_rejectedvote_salt_duplicate_commit_rejectedvote_salt_reveal_without_commit_rejectedvote_salt_commit_rejected_after_voting_endsvote_salt_reveal_rejected_after_voting_endsvote_salt_double_reveal_rejectedvote_salt_direct_vote_then_commit_rejectedvote_salt_commit_not_found_wrong_proposalDocs
docs/contracts/GOVERNANCE.md— full rewrite: vote salt API, quorum decay formula/config table, delegation rules, event table, complete error reference, regression coverage index.contracts/predictify-hybrid/README.md— added Governance section with quick-reference snippets; replaced placeholder future-enhancement entry.Security Properties
sha256(salt ++ support_byte); direction hidden until revealVotekey guards both direct and commit-reveal pathsCommitmentExistserror prevents replacement after commitmentsaturating_mul/saturating_subthroughout; floor enforcedvoter.require_auth()orcaller.require_auth()Acceptance Criteria
cargo test -p predictify-hybrid)require_authon every state-changing entrypointunwrap()in production paths)///rustdoc on all public items