Repository navigation
feat(evm): warn when an explicit network mismatches a fork - #18037
Merged
Merged
Conversation
An explicitly selected network skips the fork family check, so forking a chain of another family ran it under the selected EVM's rules without any message. Fork creation now warns once per source chain, naming the fork's family and the selected one. An inferred network still fails on the mismatch. Closes #17994. Amp-Thread-ID: https://ampcode.com/threads/T-bf11c0cd-86c4-4af5-8630-39d2c08bb15c Co-authored-by: Gustavo Figueiredo <me@figtracer.com>
figtracer
requested review from
0xrusowsky,
DaniPopes,
grandizzy,
mablr,
mattsse and
stevencartavia
as code owners
November 2, 2026 12:04
1 of 3 tasks
Amp-Thread-ID: https://ampcode.com/threads/T-bf11c0cd-86c4-4af5-8630-39d2c08bb15c Co-authored-by: Gustavo Figueiredo <me@figtracer.com>
An endpoint without Anvil metadata takes an explicitly selected network as its profile, so the warning compared the selection with itself and never fired for ordinary RPCs. Such endpoints now belong to the family of their recognized chain ID. Warnings are deduplicated per chain and family pair instead of per chain, and messages name the full execution profile, so Celo is no longer reported as ethereum. Amp-Thread-ID: https://ampcode.com/threads/T-01a19b5e-2472-7381-b12e-4dcf9808d2d4 Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com>
mattsse
requested changes
Nov 2, 2026
mattsse
left a comment
Member
There was a problem hiding this comment.
One regression in the new chain-ID fallback; details inline.
Amp-Thread-ID: https://ampcode.com/threads/T-01a19b5e-2472-7381-b12e-4dcf9808d2d4 Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com>
mattsse
previously requested changes
Nov 2, 2026
mattsse
left a comment
Member
There was a problem hiding this comment.
The reported endpoint-family regression remains reproducible on this head.
Chain-ID inference was gated on a missing Anvil instance ID, but `instance_id` is also absent when `anvil_nodeInfo` answers and only `anvil_metadata` is unavailable. An Anvil serving Monad on chain 1 behind such a proxy was then treated as Ethereum, failing an inferred fork and warning falsely under an explicit `--network monad`. Fork contexts require a recognized hardfork, so gate the inference on the reported hardfork, which is present exactly when node info answered. Amp-Thread-ID: https://ampcode.com/threads/T-01a19cae-ed5a-734d-8257-843655c9235a Co-authored-by: Mablr <59505383+mablr@users.noreply.github.com>
mablr
approved these changes
Nov 2, 2026
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.
When the network is selected explicitly (
--network,-n, ornetworkinfoundry.toml),create_forkskips the family check that fails an inferred network, which is intended since one EVM runs per process. The result was that-n monadwith a fork of an Ethereum chain, or-n ethereumwith a Monad fork, ran the fork under the selected EVM's rules with no message at all. Forge test and script fork creation, from the CLI or cheatcodes, now prints a warning such asfork of chain 31337 belongs to `ethereum`, but the selected network is `monad`, so the fork runs with `monad` ruleswhenever the selected EVM cannot serve the fork's family. Anvil endpoints report their own family; any other endpoint belongs to the family of its recognized chain ID, since it would otherwise inherit the selected network. The check uses the samesupports_fork_sourcerule as the inferred-network error, so pairs that are supported by design (Ethereum or Tempo execution over OP Stack state) stay quiet. The warning names the chain ID rather than the endpoint, because RPC URLs often carry API keys, and is printed once per source chain and family pair so a suite that callsvm.createSelectForkin every test does not repeat it.The book line in
config/networks.mdxthat says the selected profile must be compatible with the fork source still needs the qualification the issue asks for; that change belongs in foundry-rs/book.Closes #17994.