Skip to content

Follow mode's only peer-relative check is a block count, and it has silently rescued four separate bugs #117

Open

Description

@SDL-A1

Migrated from SergioDemianLerner/rustock#117 (issue by @SDL-A1, 2026-09-25).
Original: SergioDemianLerner/rustock#117

check_follow_gap is the only check in follow mode that compares this
node against its peers, and it fires on a block count:

if metadata.best_number > our_height + LONG_SYNC_LIMIT {   // 24
    info!("Fell behind by {} blocks, switching to skeleton sync", …);

Everything else follow mode does is internal — the downloaded head against
the executed head, the buffer against the executed head, the canonical index
against the head. All of those are differences of this node's own numbers,
and a wedged node can have all of them read zero.

So when follow mode breaks, the node stands still until the network's own
progress
carries it 25 blocks ahead, at which point skeleton sync takes over
and fixes in seconds what follow mode could not fix at all.

It has now done this four times, for four different reasons

date actual bug how it escaped fixed by
2026-09-24 04:10 orphaned executed head, 3-deep retreat too shallow 25-block threshold #99
2026-09-24 15:41 headers held, bodies never re-requested 25-block threshold #108
2026-09-24 18:57 executed head on the losing side of a tip sibling fork did not escape — stopped by hand at 16 behind, 12 min in #112
2026-09-24 23:30 (the #112 wedge, on restart) 25-block threshold — 551 behind after downtime —

The fourth is the one that prompted this. The node was restarted onto the
#112 fix specifically to watch that fix clear the wedge. It never got the
chance: 4.5 hours of downtime left it 551 blocks behind, check_follow_gap
went straight to skeleton sync, and the bulk path cleared the wedge in 24
seconds (Processed 551 blocks). The I5 repair fired zero times on that
recovery.

That is the problem stated precisely. The threshold is good enough at
masking bugs that it can mask the evidence for whether a fix works.

It is not the threshold's fault

LONG_SYNC_LIMIT = 24 matches rskj's longSyncLimit and is the right value
for what it is for — deciding between chasing individual headers and
requesting a height range. BLIND_RETREAT_DEPTH is deliberately derived from
it (LONG_SYNC_LIMIT + 1) for a good documented reason: a range request is
the only mechanism that re-fetches a height whose block the node already
holds.

The complaint is not the number. It is that a mode-selection heuristic is
carrying the node's liveness
, and nothing says so.

What to add

A time-based peer-relative check in follow mode. Φ already computes
exactly the right quantity — the watchdog logs behind N every tick — but Φ
feeds the escalation ladder, whose first two rungs are three minutes apart and
whose first rung was itself a no-op until #112. The signal exists; nothing
acts on it quickly.

Concretely:

  1. If a peer's tip has been above ours for more than ~90 seconds and our
    executed head has not moved, switch to skeleton sync
    regardless of the
    gap. Three RSK block times is unambiguous; the current rule needs twelve.
  2. Log it distinctly (Follow mode made no progress for Ns against peer tip #N; switching to skeleton sync) so this escape route is visible in the
    log rather than looking like an ordinary "fell behind".
  3. Keep the count-based rule. It is right for the case it was written for and
    costs nothing.

The harder question underneath

Every one of the four was a different bug, and the threshold rescued three
of them without anyone noticing. Bugs that are silently recovered from are
bugs that do not get fixed — and #112 sat undiagnosed for the twelve minutes
it took to notice the node was not moving.

Worth considering alongside the fix: when the time-based rule fires, that is
prima facie evidence follow mode has a defect. It should be loud, and
probably counted — a node that takes this escape route once a week is fine; a
node that takes it hourly has a bug nobody has looked at yet.

Prior art in this repo

The 2026-09-24 15:41 incident doc already reached this conclusion and it was
not acted on:

check_follow_gap triggers on a block count, not on time. Thirteen
minutes of no progress is a stronger signal than "25 blocks behind", and the
Φ watchdog already computes it.

Filing it properly so it stops being a footnote in incident write-ups.

Tests

  • Follow mode with a peer tip one block ahead and execution frozen switches to
    skeleton sync on the time rule, not after 25 blocks.
  • A node that is simply slower than the network — progressing, but behind —
    does not trip it.
  • The count rule still fires on its own for a node that falls behind quickly
    while healthy.

Related: #99, #108, #112. Incident records in
/root/doc/incident-2026-09-24-*.md.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions