Skip to content

node: WatcherConfig::confirmations is wired but never engaged — a reorg guard the code advertises and never applies #1227

Closed

Description

@thiras

What

WatcherConfig::confirmations exists, is documented, and has a unit test — but every one of the six watcher construction sites passes 0, so scan_upper_bound(head, 0) always returns head and the guard never does anything.

payment_settlement.rs        confirmations: 0
slash_watcher.rs             confirmations: 0
reputation_indexer.rs        confirmations: 0
blacklist_watcher.rs         confirmations: 0
capacity_bond_registry.rs    confirmations: 0
chain_origin_directory.rs    confirmations: 0

The field's own doc claims a property the code does not deliver:

Confirmation lag: the scan upper bound is head - confirmations, so the live tail never emits logs from the unstable chain tip.

It does emit from the tip. scan_upper_bound_lags_by_confirmations passes because it tests the pure function directly, not any live configuration — so the test provides false assurance that the guard is active.

Additionally, capacity_bond_registry passes reorg_margin: 0 and is non-persisting, so that watcher has no reorg protection of any kind: it scans to head, never rewinds, never persists.

Why it matters

Not that this is necessarily wrong — on Arbitrum, with a single sequencer, reorgs past the confirmed head aren't a practical concern, which is presumably why every site passes 0. The problem is that the code claims a guard it doesn't apply, so a future reader (or a future L1/L2 deployment) will believe the live tail is confirmation-lagged when it isn't.

Options

  1. Delete it — drop the field, its doc, and the test; document in chain_events that the design deliberately scans to head and why Arbitrum makes that safe.
  2. Wire it — give it a real non-zero default (or a config knob) and let the doc become true.

(1) is probably right for the current single-chain target, but it's a decision that should be made explicitly rather than left as a dormant field.

Found while doing #1110. Not introduced by it — pre-existing since #1106.

Metadata

Metadata

Assignees

Labels

prio:mediumrust

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions