Skip to content

store: resume scripthash postings after a pass-1 restart - #873

Merged
reardencode merged 7 commits into
masterfrom
ibd/end-of-sync
Oct 2, 2026
Merged

reardencode merged 7 commits into
masterfrom
ibd/end-of-sync

Conversation

@rearden-grok

@rearden-grok rearden-grok Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #867.

A restart during scripthash postings collect treated the pass-1 MPHF as a durable head, entered tip follow, and opened Electrum on an index that has no multi-script history. Pack-complete shards now carry scripthash.head/NN.packed (or scripthash.head.packed when there is one shard). Pass 1 does not write that mark. Open loads sorted main only when the MPHF and the mark both exist, and a restart after DONE.keys resumes pass 2. A finished unmarked head, with no unsorted extract in progress, is soft-migrated. Schema stays 26.

Electrum stays down while --sh-index is on and the inclusion floor is behind the tip. The same process binds it once write-behind covers the tip. With --sh-index off, Electrum and Esplora still listen (the behavior from #862); address methods fail closed.

A tip append that lands on ingest while the shard is unsealed used to hide the packed chain after pass 2. Packing the shard soft-clears ingest keys that packed main now owns.

Tests

end_of_ibd_follow: one miner, one --sh-index syncer. IBD leaves initial block download, Electrum history matches, the next block tip-follows, and a restart does not rewrite the pack mark. A cancelled mid-IBD resume finishes the same tip. With the miner down after catch-up, the syncer stays out of IBD. A partial datadir whose miner is down does not open Electrum; the miner coming back finishes that datadir.

end_of_ibd_sh_interrupt: catch-up with --sh-index off, freeze after pass 1 (DONE.keys, no DONE.post). Resume serves the full Electrum history on the first answer. A block mined after the freeze is in that history. A copy whose include_hwm already names that later block, with the create sitting on the unsealed head, still serves the same history.

end_of_ibd_work_fork: retargeting plus min-difficulty makes one chain taller and weaker. The syncer adopts the heavier tip, keeps it across a reopen, and follows the next heavy block while the tall chain is still ahead.

Reopen treated a pass-1 MPHF as a sealed durable head, so restart
skipped pass 2 and multi-script history never landed. The pack commit
is now scripthash.head/NN.packed. Open loads a shard only when that
mark exists. A finished unmarked head with no extract in progress is
soft-migrated. Schema refuse still uses index occupancy.
A durable head whose include_hwm lagged the tip was marked ready at tip
entry, and a cancel before any extract file named scripthash.cold_progress.
Electrum stays down until sh_is_tip_ready, then this process binds it once
write-behind catches up. The cancel line names cold_progress or
scripthash.unsorted only when that path is on disk.
The syncer catches a miner, serves Electrum history, tip-follows, and
restarts on write-behind without rewriting the pack mark. A cancelled
IBD resumes to the same tip. With the miner down, a partial datadir
stays short of that tip and does not open Electrum; the miner coming
back lets it finish.
A tip append while pass 1 is unsealed lands on ingest and hides the
packed multi-script chain. Packing the shard soft-clears those keys.
The end-of-IBD journey freezes after DONE.keys and checks Electrum
history across that resume, a later block, and the lying include_hwm.
Regtest retargeting plus min-difficulty makes one miner taller and
weaker. The syncer adopts the heavier tip, keeps it across a reopen,
and follows the next heavy block.
#862 binds Electrum when --sh-index is off. The pass-1 freeze
chapter only needs that catch-up to reach the miner tip before
the datadir is copied.
The tip-follow bind still called the seven-argument helper. #866
added the per-connection subscription cap, so that call did not compile.
Comment thread crates/rbitcoin-test/tests/end_of_ibd.rs Dismissed
@reardencode
reardencode merged commit c8e2d74 into master Oct 2, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SH index silently incomplete after a restart during "scripthash postings collect"

2 participants