Repository navigation
Description
Migrated from SergioDemianLerner/rustock#280 (issue by @SDL-A1, 2026-10-07).
Original: SergioDemianLerner/rustock#280
What
Violation::ParentMismatch appears in two arms of the same match in crates/sync/src/service.rs:
2103: Violation::ParentMismatch { at, .. } => {
2104: warn!("Canonical index does not link at #{at}; repairing lineage");
self.repair_canonical_gap(cursor.validated_head.number, at.saturating_sub(1));
}
...
// I1, I2, I3: the chain between the executed head and the head is not
// contiguous. Reported correctly and acted on never, so the node stood
// still -- execution asks for blocks across the break, fails, and
// retries from the same place.
2148: Violation::NoCanonicalEntry { at }
2149: | Violation::CanonicalHeaderMissing { at, .. }
2150: | Violation::ParentMismatch { at, .. } => {
2151: self.reseat_head_above_executed(at);
}Rust takes match arms in order, so the second ParentMismatch is dead. reseat_head_above_executed never runs for it. Clippy reports it as unreachable pattern at service.rs:2150:23.
How it got there
48f893d 2026-09-30 Restore the sync guards reverted with #215, re-reviewed (#220)
added the reseat arm, including ParentMismatch
8498a05 2026-10-05 Detect and repair a canonical index that does not link to itself (#263)
added the repair arm ABOVE it
So #263 took over ParentMismatch handling from #220 without removing the now-dead pattern. Nothing caught it because clippy has never run in CI.
Why it matters
The comment on the shadowed arm says these violations were "Reported correctly and acted on never, so the node stood still" -- reseating was the fix for that. For ParentMismatch, that fix is now unreachable, and the only response is repair_canonical_gap.
This is the code path behind the mainnet wedge at #9,296,505 that cost 33 hours.
The question
Is the current behaviour intended?
- If yes --
repair_canonical_gapsupersedes reseating, because repairing the index removes the need -- then the dead pattern should be deleted from the second arm and the comment updated, so the code stops implying both apply. - If no -- a
ParentMismatchthatrepair_canonical_gapdoes not resolve now leaves the node without the reseat that Restore the sync guards reverted with #215, re-reviewed #220 added for exactly that case -- then the arms need reordering or the repair arm needs to fall through to a reseat.
Deliberately not changed either way: deleting the dead pattern would silence clippy while preserving whichever behaviour is there, which is the wrong move if the answer is "no".
Related
- Fix what clippy's deny-level lints found, and the warnings that meant something #279 fixes the rest of clippy's deny-level and meaningful findings; this one is held out as a behavioural question.
Activity