Skip to content

[PR #32] No block gap detection after reconnect — blocks during backoff silently lost #94

@obchain

Description

@obchain

PR: #32 feat/07-block-listener
File: crates/charon-scanner/src/listener.rs — BlockListener::run_once and run

Problem

BlockListener tracks no last_seen_block. After reconnect (up to 30s backoff), listener resumes from next block node pushes, no backfill of blocks produced during disconnect window.

BSC 3s block time × up to 30s backoff = up to ~10 blocks skipped silently per reconnect event. Each skipped block is a window where undercollateralised position could have been liquidated by competitor while Charon was blind.

Impact

Silent missed liquidation opportunities proportional to reconnect frequency × backoff duration. No metric, no log, no error surfaces the gap.

Fix

  1. Store last_seen_block: Option<u64> on BlockListener.
  2. On re-entry to run_once, after subscription established, call provider.get_block_number() to read current_head.
  3. If last_seen_block < current_head - 1, iterate eth_getBlockByNumber from last_seen_block + 1 to current_head - 1 inclusive, emit synthetic ChainEvent::NewBlock entries.
  4. Emit warn! with gap size for operator tuning.

May defer to follow-up issue but must be tracked. Current PR silently accepts data loss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer:rustRust crates (core / scanner / protocols / executor / cli)pr-reviewFindings from PR review processpriority:p1-coreCore MVP scopetype:featureNew capability or deliverable

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions