Skip to content

[scanner] Block listener: subscribe_blocks + structured per-block logging #8

@obchain

Description

@obchain

Context

The bot's heartbeat. Subscribes to newHeads over WebSocket and routes each new block into the scanning pipeline. Structured logging makes it grep-able (chain=bsc block=N) and Prometheus-ready for later.

Scope

  • charon-scanner/src/listener.rs with a BlockListener task
  • subscribe_blocks() via alloy's pub-sub provider
  • Emits events into an mpsc channel consumed by the rest of the pipeline
  • Every received block logs structured fields: chain, block, timestamp
  • Code path is written for a single chain today but shaped so tokio::select! across multiple chains is a drop-in later

Acceptance criteria

  • Listener runs as a spawned tokio task without blocking main
  • Every new BSC block produces one structured log line
  • Logs are readable at INFO level, verbose at RUST_LOG=debug
  • Listener survives 5+ continuous minutes without crashing
  • Graceful error handling — reconnect attempt on WebSocket drop

References

  • PRD section 5c (Multi-Chain Listener Orchestration)

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)priority:p0-blockerBlocks the critical pathstatus:readyScoped and ready to pick uptype:featureNew capability or deliverable

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions