Skip to content

bug(anvil): rollback leaves inferred Monad hardfork stale #16144

Description

@haythemsellami

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions