Skip to content

[executor] BSC baseFeePerGas null: no fallback to eth_gasPrice in fetch_params #180

@obchain

Description

@obchain

Summary

GasOracle::fetch_params reads baseFeePerGas from the latest block header. BSC mainnet has emitted this field since the London-equivalent hard fork (Nov 2021, block ~13,082,000). However several failure modes produce a null value:

  • Private or load-balanced RPC nodes that strip EIP-1559 fields from eth_getBlockByNumber responses
  • A BSC reorg that serves a block header before the executor has fully consumed it
  • RPC libraries that deserialise missing optional fields as None rather than propagating an error

If baseFeePerGas is None, the current implementation will propagate an error that stalls the gas oracle. Since the gas oracle is called before every liquidation, a single malformed block response causes all opportunities to be silently dropped until the next successful fetch. There is no fallback to eth_gasPrice (type-0 pricing) and no metric emitted.

File

crates/charon-executor/src/gas.rsfetch_params()

Risk

Silent opportunity loss. A persistent RPC issue that omits EIP-1559 fields halts the bot with no clear error metric — only a log line.

Fix

Add a fallback:

let base_fee = block.header.base_fee_per_gas
    .ok_or(GasError::MissingBaseFee)
    .or_else(|_| {
        warn!("baseFeePerGas absent from block, falling back to eth_gasPrice");
        provider.get_gas_price().await.map_err(GasError::Provider)
    })?;

Refs #43

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority: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