Repository navigation
perf(anvil): prefetch system call slots on forks - #18360
Open
sembrestels wants to merge 1 commit into
Open
sembrestels wants to merge 1 commit into
sembrestels wants to merge 1 commit into
Conversation
The EIP-2935, EIP-4788 and EIP-7002/7251 system calls read slots that are new for each block, so on a fork each one was a cold storage round trip, made one after another. Fetch them all at once before the block executes. 20 evm_mine calls on a Gnosis fork: 16.3s on master, 5.9s with this change, with the same 60 upstream requests.
sembrestels
requested review from
0xrusowsky,
DaniPopes,
figtracer,
grandizzy,
mablr,
mattsse and
stevencartavia
as code owners
November 10, 2026 03:38
This branch has not been deployed
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.
Since #15975, every block anvil mines on a fork runs the EIP-2935, EIP-4788 and EIP-7002/7251 system calls. Their storage slots are new for each block, so on a fork each call makes a cold
eth_getStorageAtround trip, and the EVM makes them one after another: three round trips of latency per mined block before the first transaction runs. Before executing a block, anvil now computes the slots these calls will read from the block number and timestamp ((number - 1) % 8191for the block hash history,timestamp % 8191and+ 8191for the beacon roots, slots 0 to 3 of the request queues) and starts fetching them at once through the fork backend, the same wayfork_prefetchwarms a new fork block. The EVM's reads then join the requests in flight or hit the cache, so it gets the same values as before and sends no extra requests. Keys held locally are skipped, a key the calls end up not reading stays out of the disk cache, and a database without a fork does nothing.Results
Gnosis fork at block 49194000 through a logging proxy,
--no-storage-caching, profiling builds, three alternating runs each.evm_mineFor reference, v1.7.1 (before the system calls) takes 5.14 s for the 20 blocks with 20 requests, and 30.7–35.4 s for the test.