Skip to content

Commit 01a9b8f

Browse files
committed
validation: set BLOCK_ASSUMED_VALID during snapshot load
Mark the block index entries that are beneath the snapshot base block as assumed-valid. Subsequent commits will make use of this flag in other parts of the system.
1 parent 42b2520 commit 01a9b8f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/validation.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5007,11 +5007,25 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
50075007
// Fake nChainTx so that GuessVerificationProgress reports accurately
50085008
index->nChainTx = index->pprev ? index->pprev->nChainTx + index->nTx : 1;
50095009

5010+
// Mark unvalidated block index entries beneath the snapshot base block as assumed-valid.
5011+
if (!index->IsValid(BLOCK_VALID_SCRIPTS)) {
5012+
// This flag will be removed once the block is fully validated by a
5013+
// background chainstate.
5014+
index->nStatus |= BLOCK_ASSUMED_VALID;
5015+
}
5016+
50105017
// Fake BLOCK_OPT_WITNESS so that CChainState::NeedsRedownload()
50115018
// won't ask to rewind the entire assumed-valid chain on startup.
50125019
if (index->pprev && DeploymentActiveAt(*index, ::Params().GetConsensus(), Consensus::DEPLOYMENT_SEGWIT)) {
50135020
index->nStatus |= BLOCK_OPT_WITNESS;
50145021
}
5022+
5023+
setDirtyBlockIndex.insert(index);
5024+
// Changes to the block index will be flushed to disk after this call
5025+
// returns in `ActivateSnapshot()`, when `MaybeRebalanceCaches()` is
5026+
// called, since we've added a snapshot chainstate and therefore will
5027+
// have to downsize the IBD chainstate, which will result in a call to
5028+
// `FlushStateToDisk(ALWAYS)`.
50155029
}
50165030

50175031
assert(index);

0 commit comments

Comments
 (0)