Skip to content

Emitter silently replaces the caller’s genesis on a network mismatch #2290

Description

@noahjoeris

Describe the bug

When Emitter cannot find any caller-provided checkpoint on the RPC node, it silently replaces its checkpoint chain with the node's genesis and continues emitting blocks. This happens with an ordinary wrong-network configuration, such as mainnet checkpoints connected to a regtest node.

The emitted checkpoints no longer connect to the supplied chain, contrary to BlockEvent::checkpoint's documented guarantee. LocalChain::apply_update rejects them, but the emitter has already switched its internal chain without reporting the mismatch.

This issue was found by AI.

To Reproduce

  1. Run a regtest Bitcoin Core node with at least one mined block.
  2. Create a LocalChain from mainnet genesis and pass its tip to Emitter::new with that node's RPC client, start_height = 1, and NO_EXPECTED_MEMPOOL_TXS.
  3. Call next_block(). It returns a regtest block instead of reporting the network mismatch. Its checkpoint chain ends at regtest genesis, and connected_to() points to that genesis.
  4. Apply the emitted checkpoint to the original LocalChain; it returns CannotConnectError at height 0.

Confirmed with an RPC stub returning -5 for the caller's genesis and serving a chain rooted at a different genesis.

Expected behavior

An endpoint on a different network should not silently replace the caller's chain root or produce events that violate the documented connection guarantee.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions