fix(v2): enforce MAX_ANTI_SNIPE_HARD_MAX_SECS upper bound on initialize - #116
fix(v2): enforce MAX_ANTI_SNIPE_HARD_MAX_SECS upper bound on initialize#116Santia2004 wants to merge 6 commits into
Conversation
collinsezedike
left a comment
There was a problem hiding this comment.
One thing outside this PR's diff, not blocking on its own but worth catching now: docs/src/CONTRACT_V2.md's InvalidAntiSnipeParams row and the initialize section only document the two existing relative-bound rejection rules. Please add a line for the new anti_snipe_hard_max_secs > MAX_ANTI_SNIPE_HARD_MAX_SECS case this PR introduces.
| let disputer = f.funded_address(); | ||
| let voter = f.funded_address(); | ||
| f.mint(&voter, DEFAULT_MINT); | ||
| f.mint(&voter, DEFAULTMINT); |
There was a problem hiding this comment.
Typo: DEFAULTMINT should be DEFAULT_MINT. This breaks compilation of the whole test suite, cargo check --tests fails with cannot find value DEFAULTMINT in this scope, so nothing in this crate can currently pass CI.
| } | ||
|
|
||
| // --------------------------------------------------------------------------- | ||
| // Property-based tests for settlement's pro-rata forfeiture splitting and |
There was a problem hiding this comment.
This PR strips 53 lines of explanatory doc comments from the proptest_settlement module (added in a prior merged PR) that have nothing to do with the anti-snipe fix here, looks like an accidental revert from branching off an older base or a merge conflict resolved the wrong way. Please restore them, they explain the rationale for run_scenario, expected_pool, is_recipient, and both proptest! cases.
|
Hi @collinsezedike, thank you for the feedback!
|
|
Hey @Santia2004, the |
…estore proptest comments
|
Hi @collinsyzedike, both items are now addressed in commit 8b3b488:
Thanks! |
collinsezedike
left a comment
There was a problem hiding this comment.
Both items from the last round are confirmed fixed, the proptest comments are restored verbatim and the docs update is accurate. One new thing, subtle but real.
|
|
||
| const MAX_REGISTRATION_DURATION_SECS: u64 = 7 * 24 * 60 * 60; | ||
| const MAX_REVEAL_DURATION_SECS: u64 = 7 * 24 * 60 * 60; | ||
| pub const MAX_ANTI_SNIPE_HARD_MAX_SECS: u64 = 30 * 24 * 60 * 60; // 30 days |
There was a problem hiding this comment.
This is set to exactly 30 days, the same as INSTANCE_BUMP_AMOUNT's persistent-storage TTL bump, zero margin. The comment right below this line says the bound "must leave real margin within the 30-day persistent-storage TTL bump ... for finalize to actually get called before the assertion's ledger entry risks archival", and this constant sits exactly at that edge rather than safely under it. An admin setting anti_snipe_hard_max_secs to the new max, with no intervening register() calls to bump TTL, risks the assertion's persistent entries being archived right around when resolve_outcome needs to read them. Worth trimming this below 30 days, e.g. 29 * 24 * 60 * 60, to actually satisfy the margin the comment describes.
…tent storage TTL margin
|
Hi @collinsyzedike, adjusted Thanks! |
collinsezedike
left a comment
There was a problem hiding this comment.
The 29-day trim is correct, compiles clean and actually leaves the margin the comment asks for. One leftover from that same fix.
| | `InvalidRegistrationDuration` | `registration_duration_secs` is zero or exceeds 7 days. | | ||
| | `InvalidRevealDuration` | `reveal_duration_secs` is zero or exceeds 7 days. | | ||
| | `InvalidAntiSnipeParams` | `anti_snipe_extension_secs` exceeds `anti_snipe_hard_max_secs`, or `anti_snipe_hard_max_secs` is shorter than `registration_duration_secs`. | | ||
| | `InvalidAntiSnipeParams` | `anti_snipe_extension_secs` exceeds `anti_snipe_hard_max_secs`, `anti_snipe_hard_max_secs` is shorter than `registration_duration_secs`, or `anti_snipe_hard_max_secs` exceeds `MAX_ANTI_SNIPE_HARD_MAX_SECS` (30 days). | |
There was a problem hiding this comment.
Still says "(30 days)" here, but MAX_ANTI_SNIPE_HARD_MAX_SECS is now 29 days after this PR's own last commit. Please update this to match.
|
Hi @collinsyzedike, updated the remaining Thanks! |
Closes #114
Summary
MAX_ANTI_SNIPE_HARD_MAX_SECSconstant (30 * 24 * 60 * 60, 30 days) to prevent setting an unbounded or excessively largeanti_snipe_hard_max_secsat initialization that could lead to arithmetic overflow during dispute resolution.initialize()fortholos-v2, returningError::InvalidAntiSnipeParamsifanti_snipe_hard_max_secs > MAX_ANTI_SNIPE_HARD_MAX_SECS.test.rsto verify rejection of values aboveMAX_ANTI_SNIPE_HARD_MAX_SECSas well as acceptance at the exact bound.Test plan
test_initialize_rejects_anti_snipe_hard_max_over_maxcovering rejection of out-of-bound values.test_initialize_accepts_anti_snipe_hard_max_at_maxensuring valid boundary values initialize cleanly.anti_snipe_hard_max_secs >= registration_duration_secsandanti_snipe_extension_secs <= anti_snipe_hard_max_secs).