Skip to content

fix: return ArithmeticOverflow instead of panicking on i128 overflow - #429

Merged
chonilius merged 1 commit into
MergeFi:mainfrom
Lets-work-0012:fix/checked-arithmetic-overflow
Sep 29, 2026
Merged

chonilius merged 1 commit into
MergeFi:mainfrom
Lets-work-0012:fix/checked-arithmetic-overflow

Conversation

@Akatenvictor

Copy link
Copy Markdown

Release profile sets overflow-checks=true + panic=abort, so any unchecked i128 op (pool.balance += amount, total_deposited += amount, totalfee_bps, distributablebps, allocated += share, remainingamount, deadline + GRACE_PERIOD, balance_after - balance_before) aborts the whole transaction. Convert every reachable site in escrow, milestones, maintenance-pool, and common::compute_split to checked_/saturating_* ops returning a new ArithmeticOverflow error (SplitError::Overflow in common, mapped per-contract), so overflows are graceful errors that leave state untouched rather than aborts.

Summary

Related issues

Closes #7
Closes #9
Closes #18
Closes #27

Changes

Test plan

  • Existing tests pass (make test)
  • New tests added for changed behaviour
  • Manually verified against a local node / testnet where applicable

Checklist

  • Branch is up to date with main
  • No debug / dead code left in
  • cargo fmt and cargo clippy are clean

Release profile sets overflow-checks=true + panic=abort, so any
unchecked i128 op (pool.balance += amount, total_deposited += amount,
total*fee_bps, distributable*bps, allocated += share, remaining*amount,
deadline + GRACE_PERIOD, balance_after - balance_before) aborts the
whole transaction. Convert every reachable site in escrow, milestones,
maintenance-pool, and common::compute_split to checked_*/saturating_*
ops returning a new ArithmeticOverflow error (SplitError::Overflow in
common, mapped per-contract), so overflows are graceful errors that
leave state untouched rather than aborts.
@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Akatenvictor 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! 🚀

Learn more about application limits

@chonilius
chonilius merged commit f370f66 into MergeFi:main Sep 29, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants