fix(chain-config): throw on unknown chainId instead of silently defaulting to mainnet#727
Open
antfleet-ops wants to merge 2 commits into
Open
fix(chain-config): throw on unknown chainId instead of silently defaulting to mainnet#727antfleet-ops wants to merge 2 commits into
antfleet-ops wants to merge 2 commits into
Conversation
…lting to mainnet getChainConfig fell back to DEFAULT_CHAIN_ID (base-mainnet) for any unrecognized chainId while its doc comment claimed a base-sepolia fallback. A typo'd or stale chainId would silently resolve to mainnet config — real funds to the wrong chain. Throw on unknown ids (no-arg default is unchanged) and correct the doc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Locks the fail-loud contract: known ids resolve, no-arg defaults to base-mainnet, unrecognized non-empty ids throw (no silent mainnet fallback). resolveChainConfig propagates the same error. Verified: vitest chain-config + receipt + balance-manager + base-evm-client → 33 pass.
This was referenced Jul 10, 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.
Problem
getChainConfigfalls back toDEFAULT_CHAIN_ID(base-mainnet) for any unrecognizedchainId, while its doc comment claims "Falls back to base-sepolia if not found." So a typo'd or stale chain id silently resolves to mainnet config — potentially routing real funds to the wrong chain — and the documented behavior is wrong either way.Fix
base-mainnetdefault).chainIdnow throws instead of silently defaulting, naming the known chains. Fail-loud beats silently-mainnet.packages/node/tests/chain-config.test.ts).Note on behavioral change
Callers passing an unknown id previously got mainnet config and now get an error. That's the point of the fix (surface the mistake). Known production callers pass user-config / known chain ids through
resolveChainConfig; a typo now fails at startup instead of routing funds to the wrong chain.Verification
Found via an AntFleet two-model review of AntSeed; methodology mirror: https://github.com/AntFleet/bench-antseed · agent page: https://www.antfleet.dev/agents/0xa87EE81b2C0Bc659307ca2D9ffdC38514DD85263