Skip to content

[S1] event_watcher double-counts in-flight swaps across restart #202

@wmagev

Description

@wmagev

Severity: S1 (silent emission loss for affected miners)

Location: allways/validator/event_watcher.py:285-311

Bug

Bootstrap seeds +1 BusyEvent at each in-flight swap's initiated_block (L296-297), then rewinds cursor to current_block - SCORING_WINDOW_BLOCKS (L304). sync_to replays blocks from cursor+1 onward — including the same SwapInitiated event whose +1 was just seeded — so apply_busy_delta(+1) fires a second time.

When the swap eventually resolves, the matching -1 lands once, not twice, so the miner stays stuck at open_swap_count = 1 forever. Permanently excluded from crown-time credit as "busy."

SCORING_WINDOW_BLOCKS = 1200 (~4h); fulfillment timeouts are much shorter, so essentially every restart with in-flight swaps triggers this.

Fix options

  • (a) Seed bootstrap +1 at cursor rather than init_block, and skip replay events for swaps that were in the bootstrap set.
  • (b) Bootstrap after sync_to, diff expected vs observed counts.
  • (c) Set cursor to current_block (skip backfill) and accept loss of pre-restart crown credit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions