Skip to content

refactor: generalize chain_events into a reusable backfill+stream watcher #1092

Closed

Description

@yigitdot

Spun out of the #1089 review (maintainer note, summary item F).

The slash watcher (crates/node/src/slash_watcher.rs, #1032) is now the third hand-rolled resubscribe/backoff/backfill loop, after payment_settlement.rs (settlement) and the in-flight #1087 blacklist watcher. They already share backfill_windows + MAX_BACKFILL_BLOCK_SPAN, but each re-implements the same shape:

  • install a filter (optionally with indexed-topic constraints),
  • read head → windowed get_logs backfill over [cursor, head],
  • drain the live stream, skipping removed logs,
  • resubscribe with exponential backoff, carrying a cursor across cycles.

Proposal: generalize crates/node/src/chain_events.rs into a small backfill+stream watcher abstraction (filter builder + per-log callback + cursor/backoff policy) and migrate settlement, slash, and blacklist onto it, so the loops can't diverge (they already drift — e.g. the slash watcher's window span was briefly 9k vs the settlement 10k before being unified).

Non-blocking; the three copies are individually correct today.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions