Repository navigation
refactor(revme): separate bytecode from account in test state - #3803
Merged
Merged
Conversation
The EIP-8037 auth-refund bookkeeping read the authority's pre-transaction bytecode from the account's original info, which carries no code when the database serves bytecode separately from the account (code only via code_by_hash). A pre-existing delegation was then missed and the clearing refund under-counted. Derive the fact from the original code hash instead: an accepted authorization's code is guaranteed empty-or-delegation, so a non-empty hash is necessarily a delegation.
Seed statetest and blockchaintest pre-state with the bytecode stored separately from the account (contracts map keyed by code hash) instead of inlined in AccountInfo. Execution now has to fetch code through Database::code_by_hash, the way a node's state provider serves it, so the fixtures exercise every code-loading path and catch loads that forget to fetch bytecode. Post-state code validation in blockchaintest falls back to code_by_hash when the account carries only a hash, and the debug pre-state keeps the code inlined for readable output.
Merging this PR will not alter performance
Comparing Footnotes
|
Closed
RealiCZ
added a commit
to megaeth-labs/revm
that referenced
this pull request
Sep 16, 2026
…de from account in test state (bluealloy#3803)
43 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.
Motivation
A recent bug (delegate bytecode not loaded at first-frame creation, found as a glamsterdam-devnet-7 gas divergence) went unnoticed by the fixture suites because the revme test databases inline bytecode into
AccountInfo, soDatabase::basicalways returns code and paths that forget to fetch it throughcode_by_hashare masked. Real node providers (e.g. reth) serve code separately.Changes
code: Noneand the bytecode goes into the cache's contracts map keyed by code hash. Execution now has to fetch code throughDatabase::code_by_hash, so the standard fixtures exercise every code-loading path.code_by_hashwhen the final account carries only a code hash (untouched accounts no longer have code inline). The--print-env-on-errorpre-state dump keeps code inlined for readable output.delegated_before_txfromoriginal_info().code, which isNonewith a provider-style database, so clearing a pre-existing delegation under-counted the refund. It now derives the fact from the original code hash (sound because an accepted authorization's code is guaranteed empty-or-delegation).Testing
cargo nextest run --workspace, clippy all-features and fmt are clean.