You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Repair the holes in the segbuild segments (missing pegout-index nodes) #397
A segbuild segment holds the trie nodes its build touched, not the whole state at its heights. Re-executing newer code against one therefore hits nodes the segment never captured, and TrieStore::get returns None for them — indistinguishable from a key genuinely absent from the state.
This cost a night of work and produced a false consensus-divergence report against #374. Full write-up: docs/trie-segments-design.md §6.9d.
Measured size of the problem
Replaying 201 blocks of segment 093-8920462-9017691 with the 131 GB trie behind it:
reads 334793 from segment, 5 from fallback, 0 absent in both
(0.0015% needed the fallback)
Five nodes out of 334,798 — and those five turned a correct execution into a phantom peg-in refund and a wrong state root. The segments are 99.9985% complete and that remainder is total in consequence.
The gaps are RSKIP379 pegout-index entries: earlier code wrote them when it created each pegout, in whichever segment covered that height, and never read them again. A later segment's build therefore never captured them.
What to do
The repair list is produced by the full re-execution: /home/paseo/reexec/segment-gaps.txt, as block → segment → node-key. Affected blocks found so far include #8,922,011, #9,021,501 and #9,041,704 — the third discovered only because the gap log records block numbers.
Repair is cheap relative to a rebuild: read each missing key from the 131 GB trie at /mnt/import/rustock-trie and write it into the segment that lacked it. No re-execution needed, since the nodes are content-addressed.
Depends on #(reader-abort issue), which is what stops this class of defect recurring rather than just fixing today's instance.
Done. Correcting the numbers first, because this issue understated the job by three orders of magnitude.
What the full re-execution actually found
I filed this from a single 201-block sample that needed 5 fallback reads. Across the whole Unitrie era it was:
7,638,848 blocks re-executed, every state root matching
segment gaps: 568,032 reads served by the fallback, 0 absent in both
568,032 reads, not 5 — but concentrated in only 19 distinct blocks across 10 segments. So the gaps were whole subtrees around a few Bridge-touching blocks, not scattered leaves. The affected blocks:
All 19 would have produced wrong state roots on a segment-only replay. Two of them (#8,922,011 and #9,021,501) are the ones that produced the false divergence report against #374; #9,041,704 and the other sixteen were only found because the gap log records block numbers as well as keys.
The repair
crates/cli/examples/repair_segments.rs (new). For each affected segment it re-executes that segment's affected blocks with the 131 GB archival trie behind it, and writes every node the segment could not serve straight into the segment. Then it re-executes the same blocks segment-only, with a store that returns None on a miss and counts it, so a half-repaired segment fails rather than passing quietly.
Re-execution rather than copying the recorded keys, for two reasons: the gap file is capped (50,000 of 568,032), and inserting a node whose children are still missing only moves the failure one level down. Re-execution finds exactly what the walk needs, transitively.
Done on writable copies, then swapped in by the repository owner, with each original kept as sealed.pre-repair.
segment
blocks
nodes inserted
080-7608260-7720969
1
11,102
093-8920462-9017691
3
8,518
094-9017692-9133347
4
8,115
011-3252956-3283388
1
7,706
002-1852707-2116423
1
7,677
088-8367629-8504184
4
5,235
012-3283389-3314242
1
3,725
010-3206874-3252955
1
3,090
055-5849091-5895185
1
1,531
072-7028548-7072424
2
10
19
56,709
Verified against the live store after the swap, read-only, no fallback:
all 10: verify OK (0 reads still missing)
0 nodes inserted
Took about three minutes. 072 needing 10 nodes against 080's 11,102 shows the spread is two orders of magnitude.
What this does not fix
It repairs the gaps this replay exercised. Nothing stops different code reading a node no build ever captured, and the failure stays silent and asymmetric — it will always look like a regression in whatever is newest.
#398 is the one that closes the class, and it should not be considered addressed by this.
Closing. Measurements in docs/trie-segments-design.md §6.9d.
Activity
SDL-A1 commentedon Nov 20, 2026
Done. Correcting the numbers first, because this issue understated the job by three orders of magnitude.
What the full re-execution actually found
I filed this from a single 201-block sample that needed 5 fallback reads. Across the whole Unitrie era it was:
568,032 reads, not 5 — but concentrated in only 19 distinct blocks across 10 segments. So the gaps were whole subtrees around a few Bridge-touching blocks, not scattered leaves. The affected blocks:
All 19 would have produced wrong state roots on a segment-only replay. Two of them (#8,922,011 and #9,021,501) are the ones that produced the false divergence report against #374; #9,041,704 and the other sixteen were only found because the gap log records block numbers as well as keys.
The repair
crates/cli/examples/repair_segments.rs(new). For each affected segment it re-executes that segment's affected blocks with the 131 GB archival trie behind it, and writes every node the segment could not serve straight into the segment. Then it re-executes the same blocks segment-only, with a store that returnsNoneon a miss and counts it, so a half-repaired segment fails rather than passing quietly.Re-execution rather than copying the recorded keys, for two reasons: the gap file is capped (50,000 of 568,032), and inserting a node whose children are still missing only moves the failure one level down. Re-execution finds exactly what the walk needs, transitively.
Done on writable copies, then swapped in by the repository owner, with each original kept as
sealed.pre-repair.Verified against the live store after the swap, read-only, no fallback:
Took about three minutes.
072needing 10 nodes against080's 11,102 shows the spread is two orders of magnitude.What this does not fix
It repairs the gaps this replay exercised. Nothing stops different code reading a node no build ever captured, and the failure stays silent and asymmetric — it will always look like a regression in whatever is newest.
#398 is the one that closes the class, and it should not be considered addressed by this.
Closing. Measurements in
docs/trie-segments-design.md§6.9d.