Skip to content

Sync stalls when a same-height sibling reorg leaves the executed head on the losing fork #112

Closed

Description

@SDL-A1

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

Observed live on mainnet 2026-09-24 18:57 UTC. The node stalled for 12 minutes
and was stopped at 16 blocks behind. Full write-up:
/root/doc/incident-2026-09-24-sibling-reorg-stall.md.

What happens

Two siblings at #9,268,363 — same parent, same timestamp, same difficulty:

#9268362  0xbcafa50b…                     (canonical, executed)
   ├─ #9268363  0x4f0221e3…   ← executed head
   └─ #9268363  0xc667a642…   ← became canonical at 18:57:16

handle_headers_response switched KEY_HEAD and the canonical index to the
winning sibling. The executed head stayed on the loser, and nothing ever
re-executed the winner. Nothing was stored at #9,268,364 either: the node had
stopped moving forward entirely.

Why no guard caught it

Every guard that would notice measures a difference of block numbers, and
that difference is zero in this state:

guard compares value
"downloaded but not executed" exec_head.number + 1 ..= head.number empty range
leave_follow_if_backlog downloaded head vs executed head, by number 0
fill_follow_body_gap (#108) canonical blocks above the executed head none
orphan_retreat_target (#99) executed head has no descendant stored above it nothing above either sibling
check_follow_gap our height vs peers the only one that fires — at 25

Coherence violation I5 reported the real condition correctly every 35
seconds for eleven minutes and nothing consumed it. The invariant checker is
a reporter, not an actuator.

The fix

orphan_retreat_target already does the right thing — retreat the executed
head below the fork and let the range re-download. It is wired to the wrong
trigger. It should also fire on the I5 condition itself:

the executed head is not the canonical block at its own height

which is a strictly more general statement of "we executed the wrong chain",
covers this case, and is already computed every tick.

Two things to get right:

  1. Do not thrash. A sibling reorg can flip back. Require I5 to hold for
    more than one tick, or require the new canonical block's body to be
    present, before retreating.
  2. RetreatAndReverify { blocks: 1 } ran and did nothing. Watchdog
    escalation 1 fired at 19:00:48 with exactly the retreat that should have
    fixed this — one block back to Segmented-trie tooling, and a whole-chain replay that found a Bridge consensus bug #9,268,362, re-execute onto the new
    canonical child — and the executed head did not move. That is a second bug
    and possibly the cheaper fix. Worth checking first.

Tests

  • A same-height sibling reorg at the tip: the executed head follows the
    canonical switch within a bounded number of ticks.
  • The retreat does not thrash when siblings alternate across ticks.
  • A deeper reorg (2–3 blocks) still retreats to the common ancestor.
  • I5 clears after the recovery, and Coherence restored is logged.

Context

This is the third stall in one day whose only real escape route was
check_follow_gap at 25 blocks behind (#99 and #108 were the other two).
Three different bugs, one accidental rescue mechanism. The 25-block threshold
is doing work it was not designed for.

🤖 Generated with Claude Code

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