Skip to content

Comments

fix(forge): prevent gas underflow in delete operations on Cancun#13157

Merged
grandizzy merged 1 commit intomasterfrom
fix/gas-underflow-cancun-clean
Jan 20, 2026
Merged

fix(forge): prevent gas underflow in delete operations on Cancun#13157
grandizzy merged 1 commit intomasterfrom
fix/gas-underflow-cancun-clean

Conversation

@gakonst
Copy link
Member

@gakonst gakonst commented Jan 20, 2026

Fixes a gas underflow issue that occurs when using delete operations within a pauseGasMetering block on the Cancun EVM version.

In Cancun, the reported gas usage can drop below the stipend due to the absence of the EIP-7702 gas floor (unlike in Prague). This previously triggered a wrapping subtraction panic in the test runner's gas calculation.

This PR replaces the wrapping subtraction with a saturating subtraction to correctly handle this scenario, ensuring that gas usage is reported as 0 rather than underflowing to a large integer.

Fixes #12803


This is a clean version of #12861 without the unrelated CI changes.

Co-authored-by: subwaycookiecrunch 185599332+subwaycookiecrunch@users.noreply.github.com

Fixes a gas underflow issue that occurs when using `delete` operations within a `pauseGasMetering` block on the Cancun EVM version.

In Cancun, the reported gas usage can drop below the stipend due to the absence of the EIP-7702 gas floor (unlike in Prague). This previously triggered a wrapping subtraction panic in the test runner's gas calculation.

This PR replaces the wrapping subtraction with a saturating subtraction to correctly handle this scenario, ensuring that gas usage is reported as 0 rather than underflowing to a large integer.

Fixes #12803

Co-authored-by: subwaycookiecrunch <lucid7006@gmail.com>
@gakonst gakonst force-pushed the fix/gas-underflow-cancun-clean branch from 74faa99 to da1a53a Compare January 20, 2026 13:55
@zerosnacks zerosnacks self-assigned this Jan 20, 2026
@zerosnacks zerosnacks moved this to Ready For Review in Foundry Jan 20, 2026
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense

@grandizzy grandizzy added this pull request to the merge queue Jan 20, 2026
Merged via the queue into master with commit e03e3ff Jan 20, 2026
16 checks passed
@grandizzy grandizzy deleted the fix/gas-underflow-cancun-clean branch January 20, 2026 14:30
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(forge): gas underflow for delete operations on Cancun

3 participants