feat: validate amount/duration upper bounds in create_commitment#544
Merged
1nonlypiece merged 2 commits intoMay 29, 2026
Merged
Conversation
…ontracts-log-context-propagation feat: propagate logging context and add input validation for escrow contract
…reate-commitment-upper-bounds feat: validate amount/duration upper bounds in create_commitment
|
@egwujiohaifesinachiperpetual-max is attempting to deploy a commit to the 1nonly's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #469
This PR #469
addresses security and correctness in the
escrowsmart contract by adding input validation and overflow prevention for commitment parameters.🛡️ Security & Correctness Enhancements
CommitmentLimits:MAX_AMOUNT:1_000_000_000_000(1T tokens)MAX_DURATION_DAYS:365(1 year)MAX_PENALTY_BPS:10_000(100% basis points early-exit limit)now + duration * SECONDS_PER_DAY) with safechecked_addandchecked_multo eliminate integer overflow attacks.InvalidAmountorInvalidDurationif upper bounds or maturity calculations fail validation.🧪 Robust Test Coverage
create_rejects_overflow_duration: Safely triggers maturity multiplication overflows to assert error handling.create_rejects_excessive_amount: Asserts values aboveMAX_AMOUNTfail.create_rejects_excessive_duration: Asserts durations aboveMAX_DURATION_DAYSfail.📚 Documentation
contracts/README.mdto document the constants and error conditions.Verification & Build Results
A standalone MinGW/GNU toolchain was configured to successfully compile the smart contract and execute all tests locally: