Skip to content

safe commit - #1024

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Glam26:overflow-safe
Jul 30, 2026
Merged

safe commit#1024
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Glam26:overflow-safe

Conversation

@Glam26

@Glam26 Glam26 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary
Here's what was changed for the GrantFox FWC26 campaign (Closes #917):
contracts/settlement/src/lib.rs

  • Replaced daily.amount = daily.amount.saturating_add(amount) with daily.amount = daily.amount.checked_add(amount).ok_or(SettlementError::DailyWithdrawCapExceeded)? in withdraw_developer_balance
  • This was the only remaining non-checked arithmetic in the settlement contract. Previously, if the daily withdrawal accumulator overflowed i128 , it would silently saturate to i128::MAX . Now it fails loudly with DailyWithdrawCapExceeded .
    contracts/settlement/src/test_overflow_safe_math.rs
  • Added poke_withdrawal_today helper to seed the daily withdrawal state in tests
  • Added withdraw_daily_amount_overflow_raises_error test: seeds the daily accumulator at i128::MAX - 1 , sets cap to 0 (unlimited), then withdraws 1 micro-unit — verifies the overflow is caught
    API/Visible changes
    None. The function signatures, event schemas, and error codes remain unchanged. The DailyWithdrawCapExceeded error (code 13) was already documented and is now reused for this overflow case. This is a strict safety improvement — silent data corruption is replaced with a deterministic revert.
    Pre-existing issue
    The Cargo.lock has merge conflicts and duplicate entries that prevent compilation, but these are pre-existing and unrelated to this change.

closes #857

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Glam26 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

@greatest0fallt1me
greatest0fallt1me merged commit a2be792 into CalloraOrg:main Jul 30, 2026
6 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

Development

Successfully merging this pull request may close these issues.

Add overflow-safe math sweep in settlement [b#092] Add overflow-safe math sweep in settlement [b#032]

3 participants