Merge bitcoin/bitcoin#22121: doc: Various validation doc fixups

fa4245d884 doc: Various validation doc fixups (MarcoFalke)

Pull request description:

ACKs for top commit:
  michaelfolkson:
    Re-ACK fa4245d884
  jnewbery:
    ACK fa4245d884

Tree-SHA512: fa1086b09941247a4ffcbc1d7d27dc77a17a3ae093a5146dbb703db9ff4ba5d73ea77bd5b7747af79ea8a7dfe2c4c56a7e19ac5aac3417090e9ae127836022ae
This commit is contained in:
fanquake committed 2021-06-04 20:42:28 +08:00
commit 346e52afd6
3 files changed
+12 -15

No files matched your search

+1 -1
View File
@@ -182,7 +182,7 @@ public:
//! //!
//! 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 to avoid the block index being spuriously rewound. //! load to avoid the block index being spuriously rewound.
//! @sa RewindBlockIndex //! @sa NeedsRedownload
//! @sa ActivateSnapshot //! @sa ActivateSnapshot
uint32_t nStatus{0}; uint32_t nStatus{0};
+10 -13
View File
@@ -1401,8 +1401,9 @@ void CChainState::InvalidChainFound(CBlockIndex* pindexNew)
} }
// Same as InvalidChainFound, above, except not called directly from InvalidateBlock, // Same as InvalidChainFound, above, except not called directly from InvalidateBlock,
// which does its own setBlockIndexCandidates manageent. // which does its own setBlockIndexCandidates management.
void CChainState::InvalidBlockFound(CBlockIndex *pindex, const BlockValidationState &state) { void CChainState::InvalidBlockFound(CBlockIndex* pindex, const BlockValidationState& state)
{
if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) { if (state.GetResult() != BlockValidationResult::BLOCK_MUTATED) {
pindex->nStatus |= BLOCK_FAILED_VALID; pindex->nStatus |= BLOCK_FAILED_VALID;
m_blockman.m_failed_blocks.insert(pindex); m_blockman.m_failed_blocks.insert(pindex);
@@ -1819,8 +1820,8 @@ bool CChainState::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 RewindBlockIndex() // change is potentially tricky and issue-specific (see NeedsRedownload()
// for one general 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
// re-enforce that rule here (at least until we make it impossible for // re-enforce that rule here (at least until we make it impossible for
@@ -5082,24 +5083,20 @@ bool ChainstateManager::PopulateAndValidateSnapshot(
LOCK(::cs_main); LOCK(::cs_main);
// Fake various pieces of CBlockIndex state: // Fake various pieces of CBlockIndex state:
//
// - nChainTx: so that we accurately report IBD-to-tip progress
// - nTx: so that LoadBlockIndex() loads assumed-valid CBlockIndex entries
// (among other things)
// - nStatus & BLOCK_OPT_WITNESS: so that RewindBlockIndex() doesn't zealously
// unwind the assumed-valid chain.
//
CBlockIndex* index = nullptr; CBlockIndex* index = nullptr;
for (int i = 0; i <= snapshot_chainstate.m_chain.Height(); ++i) { for (int i = 0; i <= snapshot_chainstate.m_chain.Height(); ++i) {
index = snapshot_chainstate.m_chain[i]; index = snapshot_chainstate.m_chain[i];
// Fake nTx so that LoadBlockIndex() loads assumed-valid CBlockIndex
// entries (among other things)
if (!index->nTx) { if (!index->nTx) {
index->nTx = 1; index->nTx = 1;
} }
// Fake nChainTx so that GuessVerificationProgress reports accurately
index->nChainTx = index->pprev ? index->pprev->nChainTx + index->nTx : 1; index->nChainTx = index->pprev ? index->pprev->nChainTx + index->nTx : 1;
// We need to fake this flag so that CChainState::RewindBlockIndex() // Fake BLOCK_OPT_WITNESS so that CChainState::NeedsRedownload()
// won't try to rewind the entire assumed-valid chain on startup. // won't ask to rewind the entire assumed-valid chain on startup.
if (index->pprev && ::IsWitnessEnabled(index->pprev, ::Params().GetConsensus())) { if (index->pprev && ::IsWitnessEnabled(index->pprev, ::Params().GetConsensus())) {
index->nStatus |= BLOCK_OPT_WITNESS; index->nStatus |= BLOCK_OPT_WITNESS;
} }
+1 -1
View File
@@ -555,7 +555,7 @@ enum class CoinsCacheSizeState
* *
* Anything that is contingent on the current tip of the chain is stored here, * Anything that is contingent on the current tip of the chain is stored here,
* whereas block information and metadata independent of the current tip is * whereas block information and metadata independent of the current tip is
* kept in `BlockMetadataManager`. * kept in `BlockManager`.
*/ */
class CChainState class CChainState
{ {