Skip to content

[config] run_listen hard-codes chain key "bnb" — testnet profile panics at startup before read-only gate is reached #239

@obchain

Description

@obchain

PR: #51 (feat/23-testnet-config)
File: crates/charon-cli/src/main.rs, line 113
Refs #51

Problem

run_listen contains:

let bnb = config.chain.get("bnb").context("chain 'bnb' not configured — required for v0.1")?;

The testnet TOML must use a distinct chain key (e.g. bnb_testnet or chapel) to avoid collision with the mainnet [chain.bnb] section. The hard-coded "bnb" lookup returns None for any profile that uses a different key, and the ? propagates the error immediately — before the read-only gate (flashloan/liquidator presence check) is ever reached.

The PR description says the gate is added to the opportunity-processing arm, but the chain lookup is above that arm and is unconditional. Testnet profile cannot run in read-only mode because startup fails before the gate.

Impact

Any operator running charon --config config/testnet.toml listen receives:

Error: chain 'bnb' not configured — required for v0.1

and the bot exits. The entire testnet / Grafana demo path is broken.

Fix

Replace the hard-coded lookup with a resolution that works across config profiles:

  1. Add bot.chain field to BotConfig naming the active chain key (preferred).
  2. Accept a --chain flag in the Listen subcommand (mirrors TestConnection).
  3. Require exactly one chain entry and use .values().next() when the map has one entry.

Option 1 aligns best with the existing BotConfig pattern and requires no new CLI flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:rustRust crates (core / scanner / protocols / executor / cli)priority:p0-blockerBlocks the critical pathstatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions