blockstorage: segment normal/assumedvalid blockfiles
Summary:
When using an assumedvalid (snapshot) chainstate along with a background
chainstate, we are syncing two very different regions of the chain
simultaneously. If we use the same blockfile space for both of these
syncs, wildly different height blocks will be stored alongside one
another, making pruning ineffective.
This change implements a separate blockfile cursor for the assumedvalid
chainstate when one is in use.
This is a partial backport of core#27596 and core#28562
https://github.com/bitcoin/bitcoin/pull/27596/commits/7fcd21544a333ffdf1910b65c573579860be6a36
https://github.com/bitcoin/bitcoin/pull/28562/commits/82e48d20f1243fb7733e872a29661b151ab5d523
https://github.com/bitcoin/bitcoin/pull/28562/commits/a47fbe7d49e8921214ac159c558ff4ca19f98dce (partial)
Depends on D17895
Test Plan:
ninja all check-all
Run a full IBD with assumeutxo and pruning.
Delete the datadir, build on master, run a few minutes of regular IBD to create an index. Fast-forward to this diff, re-compile and restart the node to check it can still load an existing datadir, check that the IBD resumes normally where we left them previously, without need to reindex. Stop and restart a second time. Stop and go back to master, re-compile, and check that the node still starts without any issue and without requiring a reindex.
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D17896