Repository navigation
fix(dispute): enforce voting window deadline and configurable minimum quorum in resolve_dispute (#58) - #63
Closed
huangji6693-max wants to merge 1 commit into
Conversation
… quorum in resolve_dispute (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.
Summary
Enforces a dispute voting-window deadline (
dispute_deadline) and configurable minimum juror quorum (DataKey::DisputeQuorum, default3) inresolve_disputeso a single juror cannot prematurely resolve a dispute before other honest jurors have had a chance to vote.Closes #58
Changes
dispute_deadline: u32toDisputeRecord, set inraise_disputewhen a dispute is opened.DataKey::DisputeQuorum(DEFAULT_DISPUTE_QUORUM = 3) initialized ininitialize, with admin-onlyset_dispute_quorum(env, caller, quorum)(TrustFlowError::InvalidQuorumon0) andget_dispute_quorum(env)entrypoints.resolve_disputeto use a quorum-OR-deadline gate after the commit window closes:dispute_deadline,resolve_disputerequires at leastDisputeQuorumrevealed votes (voters.len() >= quorum), rejecting early single-vote resolution attempts withTrustFlowError::RevealPhaseNotEnded.dispute_deadlinehas passed,resolve_disputeallows sub-quorum resolution (tallying cast revealed votes with ties favouring the depositor) so escrow funds cannot be permanently stranded by low juror turnout, while still rejecting zero-vote disputes withTrustFlowError::NoVotesCast.test_resolve_dispute_single_vote_before_deadline_failstest_resolve_dispute_after_quorum_reached_before_deadline_succeedstest_resolve_dispute_after_deadline_with_sub_quorum_votes_succeedstest_set_and_get_dispute_quorum_admin_only_and_validationVerification
[MEASURED]cargo test --package trustflow:68 passed; 0 failed[MEASURED]cargo fmt --all --check&cargo clippy --all-features --workspace --lib: passed