Skip to content

Conversation

@subwaycookiecrunch
Copy link
Contributor

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

Verified with a new regression test in repros.rs.

Copy link
Member

Choose a reason for hiding this comment

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

please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback

I agree that saturating_sub may mask incorrect gas accounting.
Would you prefer:

  • an explicit fork-check (Cancun vs Prague), or
  • guarding the subtraction with a conditional + debug assertion, or
  • returning early when gas < stipend inside pauseGasMetering?

Happy to rework this to preserve gas semantics while avoiding the panic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

gas underflow for delete operations on CANCUN

2 participants