fix(engine): use caller's gas state on precompile cache hits#23328
Open
fix(engine): use caller's gas state on precompile cache hits#23328
Conversation
Cached precompile results stored the full GasTracker from the original execution, including reservoir and state_gas_spent. On cache hits, returning that stale tracker overwrote the caller's live gas state, corrupting EIP-8037 reservoir accounting. Build a fresh GasTracker from the caller's current gas_limit and reservoir on cache hits, replaying only the cached regular gas cost. Also preserve the reverted flag from cached output. Fixes the same bug in the precompile-cache example: store only output bytes, gas cost, and reverted flag; use map_cacheable_precompiles to skip identity and stateful precompiles. Co-Authored-By: rakita <13179220+rakita@users.noreply.github.com>
Contributor
|
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.
Cached precompile results stored the full
GasTrackerfrom the originalexecution, including
reservoirandstate_gas_spent. On cache hits, returningthat stale tracker overwrote the caller's live gas state — corrupting EIP-8037
reservoir accounting by restoring already-spent reservoir gas and zeroing
state_gas_spent.Builds a fresh
GasTrackerfrom the caller's currentgas_limitandreservoiron cache hits, replaying only the cached regular gas cost.Also preserves the
revertedflag from the cached output.Same fix applied to the precompile-cache example: caches only output
bytes, gas cost, and reverted flag; uses
map_cacheable_precompilesto skip identity and stateful precompiles.
Prompted by: Dragan