foundry-rs / foundry-rs/foundry

bug(anvil): rollback leaves inferred Monad hardfork stale

Open
#16,144 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
18h 20m
Merged PRs (30d)
510

Description

### Component

Anvil

### Affected version

The Monad integration proposed in #15343 at `40f293806e535762cabe33c70aa465c8e7b47918`.

### Description

Anvil can promote an inferred Monad execution profile while replaying a transaction-hash fork across a hardfork boundary, but `anvil_rollback` and reorg handling do not rewind that profile with the canonical head.

The replay path updates the live EVM spec and gas parameters, execution and blob fee rules, the backend hardfork, and the fork configuration's hardfork. Rollback currently restores the block environment and state but leaves those protocol-profile fields unchanged. Reorg handling uses the same rollback path.

As a result, replaying a MonadNine block and rolling back to a pre-activation MonadEight block can leave subsequent local execution using MonadNine rules. This can affect reserve-precompile availability, MIP gas pricing, fee behavior, and reported node information.

### Reproduction

1. Start an inferred Monad fork at the parent of a MonadNine activation block.
2. Replay a transaction by hash from a block at or after the activation timestamp.
3. Confirm that the live profile advances to MonadNine.
4. Call `anvil_rollback` with depth one, or trigger a reorg whose common ancestor is the pre-activation block.
5. Inspect the reported hardfork or execute a MonadNine-specific operation such as the reserve precompile.

The block number and timestamp rewind, but the execution profile remains MonadNine.

### Expected behavior

An inferred protocol profile should follow the retained canonical head in both directions. Rolling back across the boundary should atomically restore MonadEight execution.

An explicitly configured hardfork must remain fixed and should not be changed by rollback.

### Suggested fix

When rollback publishes the common block, derive its inferred Monad replay profile from retained block metadata, the fork-base identity, or the source-chain timestamp schedule. Republish the configuration and gas parameters, backend and fork hardforks, execution and blob fee rules, and coherent next-block fee state as one transition.

Add boundary tests for both rollback and reorg, plus an explicit-hardfork control proving an explicitly selected MonadNine profile remains fixed.

Contributor guide

Open the contributing guide

Research direction

Start with Anvil's transaction-hash replay path and the rollback and reorg handling described in the issue, then run the MonadEight/MonadNine reproduction. Trace which execution-profile, hardfork, fee, and fork-configuration values change during replay and are restored during rollback. Done means boundary tests cover rollback and reorg, while an explicitly configured MonadNine profile remains fixed.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
blockchain, cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.