fix(v2): require minimum resolution bond on registration top-ups - #160
Closed
s6pa1rta3n-lab wants to merge 1 commit into
Closed
fix(v2): require minimum resolution bond on registration top-ups#160s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
Collaborator
|
@s6pa1rta3n-lab Closing. #155 has no assignee. Comment on the issue and wait to be assigned before opening a PR. |
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
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,
registeronly checkedpolicy.min_resolution_bondon first-time registrations in thematch &existing { None => ... }branch. Top-up deposits had no minimum amount constraint, allowing 1-unit top-ups to qualify as late deposits and extendregistration_deadline.contracts/tholos-v2/src/lib.rs):amount < assertion.policy.min_resolution_bondcheck to the top ofregister, returningError::BelowMinimumResolutionBondbefore any storage reads/mutations or deadline extension evaluations.match &existingbranch since initial and top-up deposits are both validated upfront.Error::BelowMinimumResolutionBondandTholosV2::register.contracts/tholos-v2/src/test.rs):test_register_top_up_aggregatesandtest_register_top_up_with_different_commitment_failsto use valid top-up amounts (>= DEFAULT_BOND).test_strict_majority_boundary_requires_more_than_halfto register with101(>= DEFAULT_BOND 100) to test odd eligible totals without relying on sub-minimum top-ups.test_register_top_up_below_minimum_failsasserting top-ups belowmin_resolution_bondfail withBelowMinimumResolutionBond.test_register_dust_top_up_cannot_extend_deadlineasserting dust top-ups fail and cannot extend the anti-snipe deadline.docs/src/CONTRACT_V2.md):BelowMinimumResolutionBond.registerfunction specification to state that all deposits must meetpolicy.min_resolution_bond.Verification
cargo fmt --checkpasses.cargo clippy --workspace --all-targets --locked -- -D warningspasses with 0 warnings.cargo test --workspace --lockedpasses (all 178 unit and proptest tests across all workspace crates).cargo build --workspace --lib --target wasm32v1-none --release --lockedcompiles cleanly.Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC