fix: resolve a per-chain RPC URL on a fork - #2977
Open
apexearth wants to merge 1 commit into
Open
Conversation
rpcUrlFor() returned LOCAL_PROVIDER_URL for every chain whenever FORK=true, so
a fork stack could only ever serve one chain. anvil serves a single chain id,
so a Sonic or Base action pointed at a mainnet fork fails in initNetwork():
the provider is constructed for the action's real chain id while the node
reports the fork's, and ethers throws
underlying network changed (network={chainId:146}, detected={chainId:1})
Now a per-chain LOCAL_PROVIDER_URL_<chainId> wins when set, falling back to
the shared LOCAL_PROVIDER_URL. Single-chain forks are unchanged, and the
non-fork path is untouched.
Surfaced by talos running one anvil per chain so mainnet, Base and Sonic
actions can all be exercised locally.
apexearth
requested review from
clement-ux,
naddison36,
shahthepro and
sparrowDom
as code owners
August 18, 2026 20:01
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.
rpcUrlFor()returnsLOCAL_PROVIDER_URLfor every chain wheneverFORK=true, so a fork stack can only ever serve one chain. anvil serves a single chain id, so a Sonic or Base action pointed at a mainnet fork fails ininitNetwork()— the provider is built for the action's real chain id while the node reports the fork's:A per-chain
LOCAL_PROVIDER_URL_<chainId>wins when set, falling back to the sharedLOCAL_PROVIDER_URL.anvil:8545anvil-sonic:8545anvil-base:8545anvil:8545anvil:8545anvil:8545MAINNET_PROVIDER_URLSONIC_PROVIDER_URLBASE_PROVIDER_URLSingle-chain forks behave exactly as before, and the non-fork path is untouched.
Why now
oplabs/talos#30 runs one anvil per chain (mainnet, Base, Sonic) so actions on all three can be exercised locally against an impersonated relayer. Companion PR in this repo: #2976 (nonce-queue recording on the impersonated branch).
Not verified
No typecheck — the worktree has no
node_modules. Resolution logic was checked against all three scenarios above by simulation, not by running the code.