Skip to content

Fix #167: Implement reveal quorum threshold for protocol v2 resolution - #177

Closed
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-167
Closed

Fix #167: Implement reveal quorum threshold for protocol v2 resolution#177
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-167

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #167 by introducing a configurable reveal quorum threshold (reveal_quorum_bps) to protocol v2 resolution. This prevents malicious asserters from manipulating outcomes via silent, unrevealed positions that inflate eligible weight W to block honest strict majorities while exploiting the optimistic timeout fallback.

Changes

  • Contracts (contracts/tholos-v2/src/lib.rs):
    • Added pub reveal_quorum_bps: u32 to PolicySnapshotV2.
    • Added constant MAX_REVEAL_QUORUM_BPS: u32 = 10_000.
    • Added error variants InvalidRevealQuorum = 37 and RevealQuorumNotMet = 38 to enum Error.
    • Updated initialize to validate reveal_quorum_bps <= MAX_REVEAL_QUORUM_BPS and store it in PolicySnapshotV2.
    • Updated close_reveal_if_ready to enforce revealed.saturating_mul(10_000) >= eligible.saturating_mul(quorum_bps) on deadline timeouts when neither side reaches strict majority. If quorum is not met, returns Err(Error::RevealQuorumNotMet).
    • Maintained immediate resolution for strict majorities (StrictMajorityFor / StrictMajorityAgainst) regardless of reveal quorum.
  • Testing (contracts/tholos-v2/src/test.rs):
    • Updated test fixtures to initialize with DEFAULT_REVEAL_QUORUM_BPS = 5_000 (50%).
    • Added unit tests for initialization bounds: test_initialize_rejects_reveal_quorum_over_max, test_initialize_accepts_reveal_quorum_at_max, test_initialize_accepts_reveal_quorum_at_zero.
    • Added unit test test_optimistic_timeout_fails_when_reveal_quorum_not_met verifying rejection with RevealQuorumNotMet when revealed turnout is below quorum.
    • Added unit test test_admin_cancel_recovers_funds_when_quorum_deadlocked verifying round cancellation and full principal refunds when quorum is deadlocked.
    • Added unit test test_strict_majority_resolves_even_if_below_reveal_quorum verifying strict majority resolves even if turnout is below quorum.
    • Added unit test test_zero_reveal_quorum_permits_optimistic_timeout_with_low_reveals verifying that reveal_quorum_bps == 0 preserves permissive timeout resolution.
    • Added property test prop_reveal_quorum_boundary exercising random quorums and position sizes across the quorum threshold.
    • Refreshed test snapshots for all 115 passing tests.
  • Documentation:
    • Added Part 4 ("Withheld-reveal manipulation and reveal-quorum analysis") to docs/src/V2_BOND_SIZING.md with mathematical analysis, proofs, and parameter selection guidance.
    • Documented reveal_quorum_bps, InvalidRevealQuorum, and RevealQuorumNotMet in docs/src/CONTRACT_V2.md.
    • Documented reveal quorum enforcement in docs/src/V2_RESOLUTION.md.

Verification

  • cargo test -p tholos-v2: 115 tests passed (including proptests).
  • cargo test --workspace: all tests passed across all crates.
  • cargo clippy --workspace --all-targets -- -D warnings: zero warnings.
  • cargo fmt --check: formatting clean.
  • cargo build -p tholos-v2 --target wasm32v1-none --release: compiled WASM cleanly.
  • cargo build -p tholos --target wasm32v1-none --release: compiled WASM cleanly.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

…rydocs#167)

- Add reveal_quorum_bps to PolicySnapshotV2 and enforce upper bound of 10,000 bps

- Enforce reveal quorum in close_reveal_if_ready on deadline timeout

- Add InvalidRevealQuorum and RevealQuorumNotMet error variants

- Add comprehensive unit tests, property tests, and snapshot tests

- Document withheld-reveal manipulation analysis and quorum sizing in V2_BOND_SIZING.md, CONTRACT_V2.md, and V2_RESOLUTION.md
@collinsezedike

Copy link
Copy Markdown
Collaborator

@s6pa1rta3n-lab Closing. #167 has no assignee. Comment on the issue and wait to be assigned before opening a PR.

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.

[Bug] Withheld-reveal registration can deny a genuine majority in tholos-v2

2 participants