Skip to content

fix(anvil): respect genesis number in RPC lookups - #17731

Merged
mablr merged 2 commits into
masterfrom
steven/anvil-genesis-lookups
Oct 22, 2026
Merged

mablr merged 2 commits into
masterfrom
steven/anvil-genesis-lookups

Conversation

@stevencartavia

Copy link
Copy Markdown
Member

Fixes #17725.

When anvil starts with a non-zero genesis block (--number N), several RPC methods still treated block 0 as the start of the chain and looked up blocks below N that don't exist. The most visible effect was that a plain cast send failed on a fresh node, because eth_feeHistory errored during fee estimation.

eth_feeHistory now limits its range to the blocks that exist, as it already does with genesis 0. eth_getTransactionBySenderAndNonce starts its search at the block after genesis. anvil_rollback and anvil_reorg now reject a depth that would go below genesis with the usual invalid-params error, instead of a generic "Resource not found". Two neighboring spots get the same treatment: ots_getContractCreator no longer scans heights below genesis, and debug_executionWitness reports the configured genesis as having no parent state. Fork mode is unchanged, since blocks before the fork are already served by the fork provider.

With a non-zero genesis block (--number N), eth_feeHistory,
eth_getTransactionBySenderAndNonce, anvil_rollback and anvil_reorg looked
up blocks below genesis, which made plain cast send fail on a fresh node.
Bound these lookups by the genesis number outside fork mode, and do the
same for ots_getContractCreator and debug_executionWitness.
mattsse
mattsse previously approved these changes Oct 22, 2026

@mattsse mattsse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

mablr
mablr previously approved these changes Oct 22, 2026
Retain both the genesis fee-history regression and the Amsterdam state gas reservoir test added at the same location.
@mablr
mablr dismissed stale reviews from mattsse and themself via 91bb591 October 22, 2026 09:25
@mablr
mablr enabled auto-merge (squash) October 22, 2026 09:27

@mattsse mattsse left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mablr
mablr merged commit 0b40734 into master Oct 22, 2026
23 of 24 checks passed
@mablr
mablr deleted the steven/anvil-genesis-lookups branch October 22, 2026 09:33
@github-project-automation github-project-automation Bot moved this to Done in Foundry Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug(anvil): RPC lookups assume genesis is block 0 with --number

3 participants