Skip to content

fix(chain-config): throw on unknown chainId instead of silently defaulting to mainnet#727

Open
antfleet-ops wants to merge 2 commits into
AntSeed:mainfrom
antfleet-ops:fix/chain-config-unknown-chainid
Open

fix(chain-config): throw on unknown chainId instead of silently defaulting to mainnet#727
antfleet-ops wants to merge 2 commits into
AntSeed:mainfrom
antfleet-ops:fix/chain-config-unknown-chainid

Conversation

@antfleet-ops

@antfleet-ops antfleet-ops commented Jul 10, 2026

Copy link
Copy Markdown

Problem

getChainConfig falls back to DEFAULT_CHAIN_ID (base-mainnet) for any unrecognized chainId, 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

  • No-arg call is unchanged (still returns the base-mainnet default).
  • An unrecognized chainId now throws instead of silently defaulting, naming the known chains. Fail-loud beats silently-mainnet.
  • Doc comment corrected to describe the real behavior.
  • Unit tests lock the contract (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

pnpm --filter=@antseed/node exec vitest run tests/chain-config.test.ts tests/receipt.test.ts tests/balance-manager.test.ts tests/base-evm-client.test.ts
# → 33 pass

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

…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>
@antfleet-ops antfleet-ops marked this pull request as draft July 10, 2026 08:24
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant