Skip to content

[scanner] ChainProvider: alloy WebSocket connect + latest-block health check #7

@obchain

Description

@obchain

Context

All on-chain reads flow through a single ChainProvider abstraction. For v0.1 this manages a WebSocket connection to BNB Chain; the type is designed so multi-chain support in later milestones is a config change, not a rewrite.

Scope

  • charon-scanner/src/provider.rs with a ChainProvider struct wrapping an alloy provider
  • Constructor takes &ChainConfig from charon-core
  • test_connection() -> Result<u64> — fetches and returns the latest block number
  • WebSocket connection via ProviderBuilder::new().on_ws(WsConnect::new(url))
  • Connection errors surface with chain name + URL in the error context (no panics / no unwraps)

Acceptance criteria

  • ChainProvider::new(config) connects over WebSocket
  • test_connection() returns the latest block number on a running BSC node
  • Connection failure produces a clean error chain with context
  • Required alloy feature flags (pubsub, ws, etc.) added to charon-scanner/Cargo.toml

References

  • PRD section 5b (Alloy Provider & WebSocket Connections)

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