Repository navigation
fix(dispute): add voting window deadline and quorum requirement to resolve_dispute (#58) - #66
Closed
produckq-boop wants to merge 1 commit into
Conversation
…solve_dispute (trustflow-protocol#58) - Add `dispute_deadline` to `DisputeRecord`, computed on `raise_dispute` from the admin-configurable `DataKey::DisputeVotingWindow` (default 34,560 ledgers = commit + reveal windows, bounded to 2..=90 days) so updating the global window never retroactively alters open disputes. - Add admin-configurable `DataKey::DisputeQuorum` (`set_dispute_quorum` / `get_dispute_quorum`, minimum and default = 2) so a single colluding juror can never settle a dispute early before the voting window closes. - Enforce a quorum-OR-deadline gate in `resolve_dispute`: revert before `commit_deadline`, and revert before `dispute_deadline` unless at least `DisputeQuorum` revealed votes have been cast; once `dispute_deadline` passes, settle sub-quorum disputes (>= 1 vote) via fallback plurality tally without thin-sample slashing (0 votes still return `NoVotesCast`). - Update `dispute_round` test helper to advance to `dispute_deadline` dynamically and add unit tests covering single-vote early-resolve rejection, early quorum resolution before deadline, post-deadline sub-quorum fallback settlement, and admin configuration bounds. Closes trustflow-protocol#58
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.
Closes #58
Summary
Adds an admin-configurable dispute voting window (
dispute_deadlineonDisputeRecord) and minimum juror vote quorum (DataKey::DisputeQuorum) toresolve_dispute.Previously,
resolve_disputedid not enforce a minimum vote quorum alongside a configurable dispute voting window, leaving early or low-turnout dispute resolution without quorum guarantees. This change enforces a quorum-OR-deadline gate after the commit phase closes: resolution beforedispute_deadlinerequires at leastDisputeQuorumrevealed votes, while post-deadline sub-quorum disputes settle via fallback plurality tally without slashing jurors on a thin sample.Changes
DisputeRecord::dispute_deadline:dispute_deadline: u32toDisputeRecord, computed and persisted inraise_disputefromDataKey::DisputeVotingWindow(default34,560ledgers =COMMIT_WINDOW_LEDGERS + REVEAL_WINDOW_LEDGERS, split evenly into commit and reveal phases).set_dispute_voting_window/get_dispute_voting_window(admin-authenticated, bounded to2..=PERSISTENT_BUMP_AMOUNT, returningTrustFlowError::InvalidVotingWindowoutside that range). Updating the window applies to newly raised disputes without shifting deadlines on already-open disputes.DataKey::DisputeQuorum):set_dispute_quorum/get_dispute_quorum(admin-authenticated, default2,MIN_DISPUTE_QUORUM = 2, returningTrustFlowError::InvalidQuorumfor< 2so single-vote early resolution cannot be re-enabled).resolve_dispute:now < dispute.commit_deadline) withTrustFlowError::RevealPhaseNotEnded.dispute.dispute_deadline, reject calls whenvoters.len() < quorum(RevealPhaseNotEnded), and allow early settlement (with normal majority/tie-break tally and minority slashing) oncevoters.len() >= quorum.dispute.dispute_deadline, settle sub-quorum disputes (1 <= voters.len() < quorum) using the revealed vote plurality tally (ties break in favour of the depositor) while skipping minority slashing so escrow funds cannot be stranded by low turnout and dissenting jurors are not penalized without quorum (0revealed votes still returnTrustFlowError::NoVotesCast).contracts/trustflow/src/lib.rs):dispute_roundhelper to advance ledgers dynamically usingdispute.commit_deadlineanddispute.dispute_deadline.dispute_deadline, post-deadline sub-quorum settlement without slashing, deadline snapshotting across window updates, and admin auth/bounds validation.Verification
Run from
contracts/:cargo fmt --all --checkcargo clippy --all-features --workspace --libcargo check --workspacecargo test --package trustflow(69 passed; 0 failed)cargo build --target wasm32-unknown-unknown --release --workspace