fix(contracts): check virtual offset additions - #609
Conversation
Return ContractError::Overflow when pricing offset additions exceed i128 instead of panicking. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@samlogy1 is attempting to deploy a commit to the Collins' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@samlogy1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
collinsezedike
left a comment
There was a problem hiding this comment.
@samlogy1 the fix itself is correct, both additions now go through checked_add before the multiply/divide, matching the issue's proposed solution exactly. Two things needed before this can merge:
- No test covers the overflow path this fix adds. Add one that drives
total_shares/total_assetstoward the limit where the addition would overflow and assertsContractError::Overflowis returned. PR #605 in this repo is a good model for how to trigger an overflow in a test. - The PR body is still the unfilled template:
## Summaryhas no bullet, both## Test planboxes are unchecked, and there's a danglingCloses #with no number at the end on top of thecloses #569already at the top. Please fill it in perCONTRIBUTING.md's PR body format.
collinsezedike
left a comment
There was a problem hiding this comment.
Walking back the approval — CONTRIBUTING.md line 345 requires the PR template be filled out fully before review, and the Test plan checkboxes were still empty. I filled in the Summary section myself since it was just describing the diff, but the Test plan is your confirmation that you ran the commands locally, not something I can fill in for you. Please check those boxes once you've actually run pnpm lint && pnpm typecheck && pnpm test, or update them to reflect what you verified.
The code change itself is still correct and unchanged from my last review.
closes #569
Return ContractError::Overflow when pricing offset additions exceed i128 instead of panicking.
Summary
+ OFFSETadditions indeposit's share-pricing calculation withchecked_add, returningContractError::Overflowon overflow instead of panicking, consistent with the surroundingchecked_mul/checked_divchain in the same function.Test plan
pnpm lint && pnpm typecheck && pnpm testpass locallycargo test -p vault: 59 passed, 0 failed