Merge 5c5f88b80ad783f66cd0fe314bf657e128ddfa80 into 5f4422d68dc3530c353af1f87499de1c864b60ad

This commit is contained in:
Martin Zumsande 2025-03-17 03:54:40 +01:00 committed by GitHub
commit 7643e9b9cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 15 deletions

View File

@ -177,9 +177,7 @@ public:
//! Verification status of this block. See enum BlockStatus //! Verification status of this block. See enum BlockStatus
//! //!
//! Note: this value is modified to show BLOCK_OPT_WITNESS during UTXO snapshot //! Note: this value is modified to show BLOCK_OPT_WITNESS during UTXO snapshot load.
//! load to avoid a spurious startup failure requiring -reindex.
//! @sa NeedsRedownload
//! @sa ActivateSnapshot //! @sa ActivateSnapshot
uint32_t nStatus GUARDED_BY(::cs_main){0}; uint32_t nStatus GUARDED_BY(::cs_main){0};

View File

@ -2457,7 +2457,7 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state,
// may have let in a block that violates the rule prior to updating the // may have let in a block that violates the rule prior to updating the
// software, and we would NOT be enforcing the rule here. Fully solving // software, and we would NOT be enforcing the rule here. Fully solving
// upgrade from one software version to the next after a consensus rule // upgrade from one software version to the next after a consensus rule
// change is potentially tricky and issue-specific (see NeedsRedownload() // change is potentially tricky and issue-specific (see historical versions of NeedsRedownload()
// for one approach that was used for BIP 141 deployment). // for one approach that was used for BIP 141 deployment).
// Also, currently the rule against blocks more than 2 hours in the future // Also, currently the rule against blocks more than 2 hours in the future
// is enforced in ContextualCheckBlockHeader(); we wouldn't want to // is enforced in ContextualCheckBlockHeader(); we wouldn't want to
@ -4977,16 +4977,12 @@ bool Chainstate::NeedsRedownload() const
AssertLockHeld(cs_main); AssertLockHeld(cs_main);
// At and above m_params.SegwitHeight, segwit consensus rules must be validated // At and above m_params.SegwitHeight, segwit consensus rules must be validated
CBlockIndex* block{m_chain.Tip()}; int segwit_height{m_chainman.GetConsensus().DeploymentHeight(Consensus::DEPLOYMENT_SEGWIT)};
CBlockIndex* block{m_chain[segwit_height]};
while (block != nullptr && DeploymentActiveAt(*block, m_chainman, Consensus::DEPLOYMENT_SEGWIT)) { if (block && !(block->nStatus & BLOCK_OPT_WITNESS)) {
if (!(block->nStatus & BLOCK_OPT_WITNESS)) { // block is insufficiently validated for a segwit client
// block is insufficiently validated for a segwit client return true;
return true;
}
block = block->pprev;
} }
return false; return false;
} }
@ -6056,8 +6052,8 @@ util::Result<void> ChainstateManager::PopulateAndValidateSnapshot(
for (int i = AFTER_GENESIS_START; i <= snapshot_chainstate.m_chain.Height(); ++i) { for (int i = AFTER_GENESIS_START; i <= snapshot_chainstate.m_chain.Height(); ++i) {
index = snapshot_chainstate.m_chain[i]; index = snapshot_chainstate.m_chain[i];
// Fake BLOCK_OPT_WITNESS so that Chainstate::NeedsRedownload() // Set BLOCK_OPT_WITNESS, which would normally be done in ReceivedBlockTransactions
// won't ask for -reindex on startup. // if we had downloaded the block.
if (DeploymentActiveAt(*index, *this, Consensus::DEPLOYMENT_SEGWIT)) { if (DeploymentActiveAt(*index, *this, Consensus::DEPLOYMENT_SEGWIT)) {
index->nStatus |= BLOCK_OPT_WITNESS; index->nStatus |= BLOCK_OPT_WITNESS;
} }