diff --git a/src/validation.cpp b/src/validation.cpp index 6e6de0ea6e4..52c636c8151 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5305,6 +5305,7 @@ void ChainstateManager::CheckBlockIndex() // are not yet validated. CChain best_hdr_chain; assert(m_best_header); + assert(!(m_best_header->nStatus & BLOCK_FAILED_MASK)); best_hdr_chain.SetTip(*m_best_header); std::multimap forward; @@ -5418,6 +5419,8 @@ void ChainstateManager::CheckBlockIndex() if (pindexFirstInvalid == nullptr) { // Checks for not-invalid blocks. assert((pindex->nStatus & BLOCK_FAILED_MASK) == 0); // The failed mask cannot be set for blocks without invalid parents. + } else { + assert(pindex->nStatus & BLOCK_FAILED_MASK); // Invalid blocks and their descendants must be marked as invalid } // Make sure m_chain_tx_count sum is correctly computed. if (!pindex->pprev) { @@ -5431,6 +5434,8 @@ void ChainstateManager::CheckBlockIndex() // block, and must be set if it is. assert((pindex->m_chain_tx_count != 0) == (pindex == snap_base)); } + // There should be no block with more work than m_best_header, unless it's known to be invalid + assert((pindex->nStatus & BLOCK_FAILED_MASK) || pindex->nChainWork <= m_best_header->nChainWork); // Chainstate-specific checks on setBlockIndexCandidates for (auto c : GetAll()) {