Skip to content

fix(dispute): enforce voting window deadline and configurable minimum quorum in resolve_dispute (#58) - #63

Closed
huangji6693-max wants to merge 1 commit into
trustflow-protocol:mainfrom
huangji6693-max:fix/dispute-voting-window-quorum-58
Closed

huangji6693-max wants to merge 1 commit into
trustflow-protocol:mainfrom
huangji6693-max:fix/dispute-voting-window-quorum-58

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Enforces a dispute voting-window deadline (dispute_deadline) and configurable minimum juror quorum (DataKey::DisputeQuorum, default 3) in resolve_dispute so a single juror cannot prematurely resolve a dispute before other honest jurors have had a chance to vote.

Closes #58

Changes

  • Added dispute_deadline: u32 to DisputeRecord, set in raise_dispute when a dispute is opened.
  • Added DataKey::DisputeQuorum (DEFAULT_DISPUTE_QUORUM = 3) initialized in initialize, with admin-only set_dispute_quorum(env, caller, quorum) (TrustFlowError::InvalidQuorum on 0) and get_dispute_quorum(env) entrypoints.
  • Updated resolve_dispute to use a quorum-OR-deadline gate after the commit window closes:
    • Before dispute_deadline, resolve_dispute requires at least DisputeQuorum revealed votes (voters.len() >= quorum), rejecting early single-vote resolution attempts with TrustFlowError::RevealPhaseNotEnded.
    • Once dispute_deadline has passed, resolve_dispute allows 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 with TrustFlowError::NoVotesCast.
  • Added unit tests covering:
    • test_resolve_dispute_single_vote_before_deadline_fails
    • test_resolve_dispute_after_quorum_reached_before_deadline_succeeds
    • test_resolve_dispute_after_deadline_with_sub_quorum_votes_succeeds
    • test_set_and_get_dispute_quorum_admin_only_and_validation

Verification

  • [MEASURED] cargo test --package trustflow: 68 passed; 0 failed
  • [MEASURED] cargo fmt --all --check & cargo clippy --all-features --workspace --lib: passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add dispute voting window and quorum requirement to resolve_dispute

2 participants