Repository navigation
fix(eip8037): place the system call state-gas margin in the reservoir - #3892
Merged
rakita merged 1 commit intoSep 3, 2026
Merged
Conversation
EIP-8037 puts the additional SSTORE_SET_BYTES * CPSB * SYSTEM_MAX_SSTORES_PER_CALL of a system call into state_gas_reservoir and the base 30M into gas_left; execution-specs builds the Amsterdam system transaction the same way. run_system_call went through tx_gas with a zero InitialAndFloorGas, which lifts the EIP-7825 cap and lands the whole 31,566,720 in gas_left with an empty reservoir, so GAS inside a system contract read 31,566,718 instead of 29,999,998 and every state-gas charge spilled into regular gas. Split SYSTEM_CALL_GAS_LIMIT into SYSTEM_CALL_REGULAR_GAS_LIMIT and SYSTEM_CALL_STATE_GAS_RESERVOIR, add Handler::system_call_gas that applies the split when EIP-8037 is enabled, and use it from both the plain and the inspected system call paths.
RealiCZ
force-pushed
the
cz/fix/eip8037-system-call-reservoir
branch
from
September 3, 2026 07:02
91a5e35 to
8ee288d
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
This was referenced Sep 17, 2026
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
EIP-8037 sizes the system call gas limit as
30_000_000 + STATE_BYTES_PER_STORAGE_SET × CPSB × SYSTEM_MAX_SSTORES_PER_CALLand specifies that "the additionalSTATE_BYTES_PER_STORAGE_SET × CPSB × SYSTEM_MAX_SSTORES_PER_CALLis placed instate_gas_reservoirwhile the rest of the system call's gas is placed ingas_left" (EIP-8037, "System contracts and system transactions").execution-specsdoes the same: the Amsterdam system transaction is built withexecution_gas_grant=SYSTEM_TRANSACTION_GAS(30M) andstate_gas_reservoir=StateGasCosts.STORAGE_SET * SYSTEM_MAX_SSTORES_PER_CALL(src/ethereum/forks/amsterdam/fork.py,process_system_transaction).#3672 adopted the new limit but kept building the system call gas through
tx_gaswith an all-zeroInitialAndFloorGas. That path lifts the EIP-7825 cap tou64::MAXfor system calls, so the whole 31,566,720 lands ingas_leftand the reservoir is 0. TheSYSTEM_CALL_GAS_LIMITdoc comment ("the base 30M regular-gas budget plus a state-gas reservoir") already describes the intended split.Observable differences against the spec today:
GASinside a system contract reports 31,566,718 instead of 29,999,998.state_gas_spilledgrows), so a revert inside the system call credits it back togas_leftinstead of the reservoir.The four mainnet system contracts (EIP-2935/4788/7002/7251) do not branch on
gasleft(), so this does not change their results; it changes what a system contract can observe and how state gas is settled on its failure paths.Changes
SYSTEM_CALL_GAS_LIMITis now expressed asSYSTEM_CALL_REGULAR_GAS_LIMIT(30M) +SYSTEM_CALL_STATE_GAS_RESERVOIR; both constants are public.Handler::system_call_gas(default method) builds the system callGasTracker: with EIP-8037 enabled, everything above the regular budget goes to the reservoir; without it the whole limit stays regular gas.run_system_callandinspect_run_system_calluse it instead oftx_gas.test_system_call_eip8037_state_gas_reservoir: a system contract runningGAS PUSH0 SSTORE STOPunderSpecId::AMSTERDAMstores29_999_998and the fresh-slot SSTORE is accounted asSSTORE_SET_BYTES × CPSBstate gas.No change for configurations without EIP-8037;
total_gas_spentof a system call is unchanged (it already subtracts the reservoir).Verification
cargo nextest run -p revm-handler -p revm-inspector: 48 passedcargo nextest run -p revm-ee-tests -E 'test(eip8037) | test(system_call)': 43 passedcargo clippy -p revm-handler -p revm-inspector --all-targets --all-features: clean;cargo fmt --all --check: clean;RUSTDOCFLAGS=-D warnings cargo doc -p revm-handler --no-deps: cleanmain(6014612) withleft: 31566718, right: 29999998and passes with this change.