Description
Migrated from SergioDemianLerner/rustock#99 (pull request by @SDL-A1, 2026-09-24).
Merged: yes. The commits are already in this repository's history.
Original: SergioDemianLerner/rustock#99
Fixes the twelve-minute mainnet stall of 2026-09-24 (#9,266,649–#9,266,652). Timeline and evidence: /root/doc/incident-2026-09-24-orphan-retreat-stall.md.
What happened
A three-deep tip reorg orphaned the executed head. The retreat went to the orphaned head's own parent — which was on the abandoned branch too. So the retreat re-canonicalised a losing block, and the node sat in follow mode waiting for a child no peer would ever produce.
The Φ watchdog fired and escalated three times over those twelve minutes without repairing anything. What rescued it was an accident of scale: the network's own progress carried the node 25 blocks behind, which switched it to skeleton sync, whose bulk-execution path has a parent check of its own and fixed it in twenty seconds.
The hazard was half-known — the comment directly below the retreat says "Targeting the orphan's own parent here was the 2026-09-23 bug… execution stays stranded." That was fixed for execution; the head retreat still did it.
The fork point is not computable at that moment
This is the part worth reading, because it is not obvious and it changed the shape of the fix.
The retreat runs only when Validated::prove on the replacement branch failed, and prove fails for exactly one reason: a header missing while walking that branch down. Locating the fork means walking the same segment, from the same tip, toward the same meeting point — so it meets the same gap. The two succeed and fail together. And when they succeed, the caller adopts the replacement instead of retreating at all.
So the retreat covers distance rather than locating the fork:
- Depth =
LONG_SYNC_LIMIT + 1= 25 — derived, not guessed. That is the follow/skeleton boundary. Below it the node bridges gaps by chasing individual missing parents; above it skeleton sync requests by height range, which is the only mechanism that re-fetches a height whose block the node already holds — exactly a blind retreat's situation. It is also, precisely, what rescued the live node. - Bounded by state, so the head never retreats below a block execution could resume from.
- The exact fork point is reached one round later for free: the re-download puts the replacement branch in the store,
provesucceeds, adoption un-canonicalises our losing blocks, andchoose_resume_pointwalks execution back to the last block both chains share.
Both orphan paths share this now; the second had its own inlined single-step retreat with the same bug.
Tests
rollback::fork_point computes the true fork with both branches fully known — the knowledge the node does not have when it retreats — and exists as the oracle:
a_blind_retreat_never_stops_above_the_forkchecks the retreat against it at every depth up to the bound.retreating_to_the_parent_stops_above_the_fork_whenever_it_is_deeperstates the old rule's failure as a test rather than a paragraph.test_reconcile_retreats_below_a_three_deep_forkreplays the incident end to end. Restoring the single-step retreat fails it with "stopped at Fix the race that made the pipeline halt test flaky #32, which is still on the branch the network abandoned".
test_reconcile_when_the_forks_parent_was_never_downloaded asserted a one-block retreat — the bug written down as a requirement. It now asserts the intent its own comment states: at or below the last block both chains share.
Whole workspace: 1,501 tests, 0 failures.
Still open (in the incident doc)
- The Φ watchdog escalates without repairing — the natural place to trigger a deeper retreat if one is ever needed again.
extends_usmasks the problem after a retreat, which is why the one-block-per-round design never iterated. This steps over that rather than fixing it.- Routine tip reorgs now retreat 25 blocks, not one, because their replacement branch is equally absent — a few seconds of re-execution every few minutes. If that price is too high, the lever is to escalate depth from the watchdog instead of paying it every time.
🤖 Generated with Claude Code
Activity