Repository navigation
feat(precompile): track spilled state gas in PrecompileOutput - #3820
Merged
Merged
Conversation
Add `state_gas_spilled` to `PrecompileOutput` and forward it into the
frame's gas tracker, so a revert or halt credits the spilled portion back
to regular gas instead of the reservoir (EIP-8037).
Add `PrecompileOutput::{from_gas_tracker, set_gas, to_gas_tracker}` and
`Gas::from_tracker` to convert between a precompile's gas accounting and a
`GasTracker`, and use them to simplify
`precompile_output_to_interpreter_result`.
Merging this PR will degrade performance by 3.5%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | blake2/2_rounds |
3.2 µs | 3.3 µs | -3.5% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/precompile-spilled-state-gas (279fc0e) with main (bc8ab33)
Footnotes
-
1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩
Closed
This was referenced Jul 23, 2026
RealiCZ
added a commit
to megaeth-labs/revm
that referenced
this pull request
Sep 16, 2026
…state gas in PrecompileOutput (bluealloy#3820)
3 tasks done
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.
PrecompileOutputcarriedstate_gas_usedandreservoir, but not the spilled portion of the state gas (EIP-8037'sstate_gas_from_gas_left). The reconstructed frame gas therefore always hadstate_gas_spilled == 0, so:handle_reservoir_remaining_gas).Changes
PrecompileOutput::state_gas_spilled— new field, forwarded into the frame'sGasbyprecompile_output_to_interpreter_result.PrecompileOutput::{from_gas_tracker, set_gas, to_gas_tracker}— convert between a precompile's gas accounting and aGasTracker.Gas::from_tracker(GasTracker)— lift externally-tracked gas into a frame's gas; pairs with the existingtracker()/tracker_mut().precompile_output_to_interpreter_resultsimplified on top of those: the status maps to anInstructionResultin one flat match, the overspend check becomesgas_used > gas_limit(exactly whenrecord_regular_costused to fail), and the gas comes straight fromto_gas_tracker. Behavior unchanged.Breaking
Adding a public field breaks external code that builds
PrecompileOutputwith struct-literal syntax; thenew/halt/revertconstructors are unaffected. No in-tree precompile setsstate_gas_usedyet.Testing
precompile_output_propagates_spilled_state_gas,precompile_output_overspend_is_oog,gas_tracker_round_trip,to_gas_tracker_saturates_on_overspend.cargo nextest run --workspace: 393 passed../scripts/run-tests.sh: 61,606 passed, 0 failed. fmt + clippy (--all-targets --all-features) clean.