HomePhabricator

init: add utxo snapshot detection, allow on-disk coins and block tree dbs in…

Description

init: add utxo snapshot detection, allow on-disk coins and block tree dbs in tests

Summary:

init: add utxo snapshot detection

Add functionality for activating a snapshot-based chainstate if one is
detected on-disk.

Also cautiously initialize chainstate cache usages so that we don't
somehow blow past our cache allowances during initialization, then
rebalance at the end of init.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>

https://github.com/bitcoin/bitcoin/pull/25667/commits/252abd1e8bc5cdf4368ad55e827a873240535b28

blockmanager: avoid undefined behavior during FlushBlockFile

If we call FlushBlockFile() without having intitialized the block index
with LoadBlockIndexDB(), we may be indexing into an empty vector.

Specifically this is an issue when we call MaybeRebalanceCaches() during
chainstate init before the block index has been loaded, which calls
FlushBlockFile().

Also add an assert to avoid undefined behavior.

Co-authored-by: Russell Yanofsky <russ@yanofsky.org>

https://github.com/bitcoin/bitcoin/pull/25667/commits/8153bd9247dad3982d54488bcdb3960470315290

This is a partial backport of core#25667
Depends on D14650

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14651

Details

Provenance
James O'Beirne <james.obeirne@pm.me>Authored on Apr 20 2022, 21:40
PiRKCommitted on Oct 26 2023, 11:31
PiRKPushed on Oct 26 2023, 11:31
Reviewer
Restricted Project
Differential Revision
D14651: init: add utxo snapshot detection, allow on-disk coins and block tree dbs in tests
Parents
rABCdabda24d1975: validation: rename snapshot chainstate dir
Branches
Unknown
Tags
Unknown