Skip to content

fix(cli): refuse ambiguous EVM network selection (devnet manifest vs mainnet default)#156

Closed
Nic-dorman wants to merge 1 commit into
fix/cli-audit-thinningfrom
fix/v2-471-explicit-evm-network
Closed

fix(cli): refuse ambiguous EVM network selection (devnet manifest vs mainnet default)#156
Nic-dorman wants to merge 1 commit into
fix/cli-audit-thinningfrom
fix/v2-471-explicit-evm-network

Conversation

@Nic-dorman

@Nic-dorman Nic-dorman commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the silent-payment-failure trap around --evm-network and completes audit finding #5 (EVM resolution belongs in ant-core). Stacked on #155 (base branch refactor/v2-189-cli-thinning) — merge that first, then retarget/merge this; CI runs once this retargets to main.

The trap: --evm-network defaulted to arbitrum-one unconditionally, so --devnet-manifest with a custom EVM block but without --evm-network local silently paid against the hardcoded mainnet vault address on the manifest's chain. On Sepolia that address is an EOA: the tx "succeeds" as a no-op, gas is spent, the ANT allowance goes to a useless spender, and every subsequent chunk PUT fails median-payment verification — looking like a payment-protocol bug rather than a flag bug.

Changes:

  • String→EvmNetwork resolution (including manifest evm-block parsing for local) moves to ant_core::config::resolve_evm_network with typed errors (EvmNetworkAmbiguous, UnsupportedEvmNetwork, EvmManifestRequired, InvalidEvmManifest), so every frontend shares one implementation. (EvmNetwork and DevnetManifest are foreign re-exports, so the resolver is a free function in ant_core::config next to resolve_bootstrap_peers rather than an inherent method.)
  • No break for mainnet users: the default stays arbitrum-oneexcept when a devnet manifest carrying an evm block is loaded. That one combination (the only path where the trap fires) now errors and asks for an explicit choice: local to use the manifest's EVM config, or a preset to override it.
  • Selecting a preset while the manifest carries an EVM block prints a warning that the manifest's EVM config is ignored (the one remaining discard path, now loud).
  • ant-cli drops its direct reqwest dependency — the moved URL parse was the last use.

Testing

  • 7 unit tests on resolve_evm_network (mainnet default with no manifest / manifest-without-evm, ambiguous error when manifest has an evm block, preset mapping, local happy path with URL/address round-trip, missing manifest/evm block, unknown name, bad manifest values); full workspace suite passes; clippy/fmt clean.
  • CLI smoke: no flag + no manifest → mainnet address printed; no flag + manifest-with-evm → clear ambiguity error; preset + manifest-with-evm → warning on stderr, result on stdout; local + manifest → resolves; mainnet → unsupported error; local without manifest → manifest-required error.

🤖 Generated with Claude Code

…nt-core (V2-743, V2-471)

--evm-network defaulted to arbitrum-one, so a user passing
--devnet-manifest with a custom EVM block (but not --evm-network local)
silently paid against the mainnet vault address on the manifest's chain:
the tx 'succeeds' as a no-op against an EOA, gas is spent, ANT allowance
goes to a useless spender, and every chunk PUT then fails median-payment
verification. The failure reads like a payment-protocol bug, not a flag
bug (V2-471).

- string->EvmNetwork resolution (incl. manifest evm-block parsing for
  'local') moves to ant_core::config::resolve_evm_network with typed
  errors, per the V2-189 audit (finding #5) — frontends share one
  implementation
- no default network: payment ops without --evm-network now fail with
  a clear 'choose arbitrum-one | arbitrum-sepolia | local' error before
  any tokens move (per the fix proposed on V2-471; magic
  manifest-overrides-preset precedence deliberately rejected there)
- selecting a preset while the manifest carries an EVM block warns that
  the manifest's EVM config is ignored
- ant-cli drops its direct reqwest dependency (last use was the moved
  URL parse)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Nic-dorman Nic-dorman changed the title Require explicit --evm-network; move EVM resolution into ant-core (V2-743 + V2-471) Refuse ambiguous EVM selection (manifest vs default); move EVM resolution into ant-core (V2-743 + V2-471) Jul 23, 2026
@Nic-dorman Nic-dorman changed the title Refuse ambiguous EVM selection (manifest vs default); move EVM resolution into ant-core (V2-743 + V2-471) fix(cli): refuse ambiguous EVM network selection (devnet manifest vs mainnet default) Jul 23, 2026
@Nic-dorman Nic-dorman closed this Jul 23, 2026
@Nic-dorman

Copy link
Copy Markdown
Contributor Author

Superseded by #158 (stacked on #157) — same branch-rename closure as #155.

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