Skip to content

fix: bridge-fee arithmetic overflow remediation#347

Merged
gboigwe merged 1 commit intoThinkLikeAFounder:mainfrom
Dopezapha:fix/cross-chain-bridge-fee-overflow
Mar 28, 2026
Merged

fix: bridge-fee arithmetic overflow remediation#347
gboigwe merged 1 commit intoThinkLikeAFounder:mainfrom
Dopezapha:fix/cross-chain-bridge-fee-overflow

Conversation

@Dopezapha
Copy link
Copy Markdown
Contributor

@Dopezapha Dopezapha commented Mar 28, 2026

Closes #306

  • Description:
    This PR addresses a critical arithmetic safety issue in the cross-chain token bridge (token-bridge contract) where bridge fee calculations used unchecked multiplication.

    Key Changes:

    1. Safety Hardening: The bridge fee calculation in deposit_for_bridge now uses checked_mul. This prevents potential intermediate result overflows when handling extremely large transfer amounts
    2. Explicit Failure (Production Grade): Implemented an explicit .expect() to ensure the contract halts safely with a descriptive error message if an overflow is reached, rather than silently wrapping to an incorrect value.
    3. Comprehensive Testing: Added specific test scenarios to the bridge's local test suite that trigger the overflow case and confirm correct normal operation.

@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 28, 2026

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

@gboigwe gboigwe merged commit 2cdc8c6 into ThinkLikeAFounder:main Mar 28, 2026
1 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

Development

Successfully merging this pull request may close these issues.

[BUG] cross-chain-bridge: fee calculation uses unchecked multiplication — potential i128 overflow

2 participants