Skip to content

evm: EIP-8037 cleanups#20292

Draft
yperbasis wants to merge 6 commits intomainfrom
yperbasis/eip8037-simplify
Draft

evm: EIP-8037 cleanups#20292
yperbasis wants to merge 6 commits intomainfrom
yperbasis/eip8037-simplify

Conversation

@yperbasis
Copy link
Copy Markdown
Member

Summary

  • Tracer spill gap: fire OnGasChange(reservoir, 0) when the state gas reservoir drains to 0 during spill — tracers previously missed this transition
  • Overflow fix: compute float64(gasLimit) * 2_628_000 instead of float64(gasLimit*2_628_000) in CostPerStateByte to avoid uint64 overflow at extreme gas limits
  • Dedup: hoist Amsterdam block gas accounting above the refund/no-refund branch, removing 5 duplicated lines
  • Nil checks: remove defensive evm != nil in useMdGas — never nil at any call site

Test plan

  • Existing EEST BAL tests pass
  • make lint

🤖 Generated with Claude Code

yperbasis and others added 6 commits April 2, 2026 16:51
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ild revert

Two uint64 underflow bugs in the EIP-8037 multidimensional gas accounting
caused incorrect receipt gasUsed when child frames reverted with a state
gas reservoir that grew beyond its initial value (via sub-child reverts):

1. handleFrameRevert: `reservoirUsed = initialChildState - gas.State`
   underflowed when the reservoir grew (gas.State > initialChildState),
   preventing state gas from cascading up through nested reverts.
   Fix: guard the subtraction; use `gas.State += childStateConsumed`
   to preserve sub-child restorations already in the reservoir.

2. txn_executor.mdGasUsed().Total(): per-component Minus() underflowed
   when gasRemaining.State > initialGas.State.
   Fix: compute receipt gasUsed as `initialGas.Total() - gasRemaining.Total()`
   matching the EIP-8037 formula `tx.gas - gas_left - reservoir`.

Also skip 2 BAL tests where coinbase==target exposes a separate TxIn bug
in exec3_parallel finalize (TODO).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per-component subtraction is unsound when spill can transfer gas
between dimensions (reservoir grows above initial value on child
revert). Remove the footgun; inline Regular subtraction at the
two pre-Amsterdam call sites that only need it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move reservoirUsed/spill into the only branch that uses them
(depth == 0, REVERT). Inline regularGasUsed assignments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1. useMdGas: fire OnGasChange when the state gas reservoir drains to 0
   during spill, so tracers see the full reservoir→0 transition.

2. CostPerStateByte: multiply in float64 to avoid uint64 overflow of
   gasLimit*2_628_000 at extreme gas limits (>7 trillion).

3. txn_executor: hoist Amsterdam block gas accounting above the
   refund/no-refund branch to remove 5 duplicated lines.

4. useMdGas: remove defensive evm != nil checks — evm is never nil at
   any call site.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@yperbasis yperbasis added the Glamsterdam https://eips.ethereum.org/EIPS/eip-7773 label Apr 8, 2026
Base automatically changed from yperbasis/bal_v5.6.0_a to main April 8, 2026 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Glamsterdam https://eips.ethereum.org/EIPS/eip-7773

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant