Skip to content

fix(v2): require minimum resolution bond on registration top-ups - #160

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

fix(v2): require minimum resolution bond on registration top-ups#160
s6pa1rta3n-lab wants to merge 1 commit into
drydocs:mainfrom
s6pa1rta3n-lab:fix-issue-155

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Closes #155

This PR addresses an economic vulnerability where callers could submit cheap dust top-ups (e.g. 1 unit) during the anti-snipe extension window to repeatedly extend the registration deadline up to the hard deadline at minimal cost.

Root Cause & Changes

Previously, register only checked policy.min_resolution_bond on first-time registrations in the match &existing { None => ... } branch. Top-up deposits had no minimum amount constraint, allowing 1-unit top-ups to qualify as late deposits and extend registration_deadline.

  • Enforce Minimum Bond on All Deposits (contracts/tholos-v2/src/lib.rs):
    • Moved the amount < assertion.policy.min_resolution_bond check to the top of register, returning Error::BelowMinimumResolutionBond before any storage reads/mutations or deadline extension evaluations.
    • Simplified the match &existing branch since initial and top-up deposits are both validated upfront.
    • Updated docstrings on Error::BelowMinimumResolutionBond and TholosV2::register.
  • Test Suite Updates (contracts/tholos-v2/src/test.rs):
    • Updated test_register_top_up_aggregates and test_register_top_up_with_different_commitment_fails to use valid top-up amounts (>= DEFAULT_BOND).
    • Updated test_strict_majority_boundary_requires_more_than_half to register with 101 (>= DEFAULT_BOND 100) to test odd eligible totals without relying on sub-minimum top-ups.
    • Added test_register_top_up_below_minimum_fails asserting top-ups below min_resolution_bond fail with BelowMinimumResolutionBond.
    • Added test_register_dust_top_up_cannot_extend_deadline asserting dust top-ups fail and cannot extend the anti-snipe deadline.
  • Documentation (docs/src/CONTRACT_V2.md):
    • Updated the error table description for BelowMinimumResolutionBond.
    • Updated the register function specification to state that all deposits must meet policy.min_resolution_bond.

Verification

  • cargo fmt --check passes.
  • cargo clippy --workspace --all-targets --locked -- -D warnings passes with 0 warnings.
  • cargo test --workspace --locked passes (all 178 unit and proptest tests across all workspace crates).
  • cargo build --workspace --lib --target wasm32v1-none --release --locked compiles cleanly.

Payout Routing

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

@collinsezedike

Copy link
Copy Markdown
Collaborator

@s6pa1rta3n-lab Closing. #155 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.

[Chore] Anti-snipe extension griefable via cheap repeated top-ups

2 participants