core/vm: fix EIP-8037 CALL state gas ordering#33972
Open
qu0b wants to merge 2 commits intoethereum:bal-devnet-3from
Open
core/vm: fix EIP-8037 CALL state gas ordering#33972qu0b wants to merge 2 commits intoethereum:bal-devnet-3from
qu0b wants to merge 2 commits intoethereum:bal-devnet-3from
Conversation
Charge new-account state gas BEFORE the 63/64 child gas allocation rather than after. When state gas spills from an empty reservoir to regular gas, it must reduce the gas available for callGasTemp. Otherwise the spillover exceeds the 1/64 remainder after child gas allocation, causing Underflow → OOG on CALLs that should succeed. This matches nethermind's implementation which calls ConsumeNewAccountCreation() before the 63/64 calculation (EvmInstructions.Call.cs:187-213). Verified: geth+besu in sync through 159 blocks with spamoor load, geth+nethermind in sync through 50+ post-Amsterdam blocks. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When CREATE init code produces valid code but UseGas fails for code storage, TotalStateGasCharged was incremented by the full code storage state gas (potentially millions) without consuming any actual gas. This inflated TSC propagated up through RefundGas and caused blockGasUsed() to underflow (execRegularUsed = totalExecUsed - TSC wraps uint64), resulting in incorrect gas pool accounting and state root mismatches when validating blocks from other clients. The fix removes the TSC increment when UseGas fails for code storage. Since the contract creation failed and state was reverted, the state gas demand didn't materialize and shouldn't be tracked. Also removes the ErrCodeStoreOutOfGas case from isCodeValidation since TSC is no longer inflated in that code path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Underflow → OOGon CALLs that should succeedDetails
In
makeCallVariantGasCall(operations_acl.go), the EIP-8037 state gas for new account creation was returned in theGasCostsstruct and charged by the interpreter'sUseGas/SubaftercallGas()had already computed the 63/64 child gas allocation using the full (pre-state-gas)contract.Gas.RegularGas.When the state gas reservoir is empty (common case — reservoir only has gas when
tx.gasLimitexceedsTX_MAX_GAS_LIMIT - intrinsic), state gas spills to regular gas. The spill amount (131,488) far exceeds the 1/64 retained gas (~15,600 at 1M gas), causing an underflow/OOG.The fix charges state gas directly before
callGas()so the 63/64 calculation uses the reduced regular gas. This matches nethermind's implementation (EvmInstructions.Call.cs:187-213) and besu's approach.Test plan
ConsumeNewAccountCreationat line 189,callGasat line 212)🤖 Generated with Claude Code