mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
validation: have LoadBlockIndex account for snapshot use
Ensure that blocks past the snapshot base block (i.e. the end of the assumed-valid region of the chain) are not included in setBlockIndexCandidates for the background validation chainstate. These blocks, while fully validated and lacking the BLOCK_ASSUMED_VALID flag, *rely* on blocks which are assumed-valid, and so shouldn't be added to the IBD chainstate. Co-authored-by: Russ Yanofsky <russ@yanofsky.org>
This commit is contained in:
@@ -427,20 +427,16 @@ public:
|
||||
|
||||
std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main);
|
||||
|
||||
bool LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
bool LoadBlockIndexDB(ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
/**
|
||||
* Load the blocktree off disk and into memory. Populate certain metadata
|
||||
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
|
||||
* collections like setDirtyBlockIndex.
|
||||
*
|
||||
* @param[out] block_index_candidates Fill this set with any valid blocks for
|
||||
* which we've downloaded all transactions.
|
||||
*/
|
||||
bool LoadBlockIndex(
|
||||
const Consensus::Params& consensus_params,
|
||||
std::set<CBlockIndex*, CBlockIndexWorkComparator>& block_index_candidates)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
/** Clear all data members. */
|
||||
void Unload() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
@@ -626,6 +622,10 @@ public:
|
||||
*/
|
||||
const std::optional<uint256> m_from_snapshot_blockhash;
|
||||
|
||||
//! Return true if this chainstate relies on blocks that are assumed-valid. In
|
||||
//! practice this means it was created based on a UTXO snapshot.
|
||||
bool reliesOnAssumedValid() { return m_from_snapshot_blockhash.has_value(); }
|
||||
|
||||
/**
|
||||
* The set of all CBlockIndex entries with either BLOCK_VALID_TRANSACTIONS (for
|
||||
* itself and all ancestors) *or* BLOCK_ASSUMED_VALID (if using background
|
||||
|
||||
Reference in New Issue
Block a user