This is part of the assumeutxo project (parent PR: #15606)
Half of the replacement for #24232. The original PR grew larger than expected throughout the review process.
This change adds the ability to initialize a snapshot-based chainstate during init if one is detected on disk. This is of course unused as of now (aside from in unittests) given that we haven’t yet enabled actually loading snapshots.
Don’t be scared! There are some big move-only commits in here.
Accompanying changes include:
- moving the snapshot coinsdb directory from being called
chainstate_[base blockhash]
tochainstate_snapshot
, since we only support one snapshot in use at a time. This simplifies some logic, but it necessitates writing that base blockhash out to a file within the coinsdb dir. See discussion here. - adding a simple fix in
FlushBlockFile()
that avoids a crash when attemping to flush to disk beforeLoadBlockIndexDB()
is called, which happens when callingMaybeRebalanceCaches()
during multiple chainstate init. - improving the unittest to allow testing with on-disk chainstates - necessary to test a simulated restart and re-initialization.