Skip to content

fix(precompiles): cap minted balances below U256::MAX - #428

Merged
tac0turtle merged 2 commits into
mainfrom
fix/mint-balance-cap
Oct 27, 2026
Merged

tac0turtle merged 2 commits into
mainfrom
fix/mint-balance-cap

Conversation

@damiannolan

Copy link
Copy Markdown
Contributor

Description

add_balance only rejected a mint that overflowed U256, letting a balance climb arbitrarily close to U256::MAX. Near that ceiling, later credits (transfers, fee reimbursements, base-fee redirect) saturate and silently drop value. Cap the resulting balance at u128::MAX, the bound revm already assumes for the native token, leaving ample headroom below U256::MAX.

Adds a regression test for the cap.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Refactoring

Related Issues

Fixes #(issue)

Checklist

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Testing

Additional Notes

add_balance only rejected a mint that overflowed U256, letting a balance
climb arbitrarily close to U256::MAX. Near that ceiling, later credits
(transfers, fee reimbursements, base-fee redirect) saturate and silently
drop value. Cap the resulting balance at u128::MAX, the bound revm already
assumes for the native token, leaving ample headroom below U256::MAX.

Adds a regression test for the cap.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 808cc9f7-3890-48e3-9095-8bc4febec1df
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@damiannolan
damiannolan marked this pull request as ready for review October 27, 2026 11:40
@damiannolan
damiannolan requested a review from a team as a code owner October 27, 2026 11:40
@tac0turtle
tac0turtle merged commit cdad941 into main Oct 27, 2026
16 checks passed
@tac0turtle
tac0turtle deleted the fix/mint-balance-cap branch October 27, 2026 14:05
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.

2 participants