mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-20 19:04:49 +02:00
Merge bitcoin/bitcoin#32950: validation: remove BLOCK_FAILED_CHILD
fb3e1bf9c9test: check LoadBlockIndex correctly recomputes invalidity flags (stratospher)29740c06acvalidation: remove BLOCK_FAILED_MASK (stratospher)b5b2956bdavalidation: reset BLOCK_FAILED_CHILD to BLOCK_FAILED_VALID when loading from disk (stratospher)37bc207852validation: stop using BLOCK_FAILED_CHILD (stratospher)120c631e16refactor: use clearer variables in InvalidateBlock() (stratospher)18f11695c7validation: don't update BLOCK_FAILED_VALID to BLOCK_FAILED_CHILD in InvalidateBlock (stratospher) Pull request description: Fixes https://github.com/bitcoin/bitcoin/issues/32173 even though we have a distinction between `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` in the codebase, we don't use it for anything. Whenever we check for BlockStatus, we use `BLOCK_FAILED_MASK` which encompasses both of them. Since there is no functional difference between `BLOCK_FAILED_VALID` and `BLOCK_FAILED_CHILD` and it's added code complexity to correctly categorise them (ex: https://github.com/bitcoin/bitcoin/pull/31405#discussion_r1914366243, https://github.com/bitcoin/bitcoin/pull/16856#issuecomment-565506585), we could just remove it. Looking for conceptual feedback on whether it's better to improve handling of `BLOCK_FAILED_CHILD` in the codebase or remove `BLOCK_FAILED_CHILD`. Of less relevance, but it would also fix a `reconsiderblock` crash that could happen in the situation mentioned in https://github.com/bitcoin/bitcoin/issues/32173#issuecomment-2767030982 Similar attempt in the past in https://github.com/bitcoin/bitcoin/pull/16856#issuecomment-568073859 ACKs for top commit: stickies-v: re-ACKfb3e1bf9c9alexanderwiederin: ACKfb3e1bf9c9mzumsande: re-ACKfb3e1bf9c9Tree-SHA512: e97b739885c40a8c021966438e9767cc02bc183056236d6a8c64f6819347ae70c0fbcd71cc2528917560d9f4fd56aed45faf1b6c75d98de7b08b621693a97fbc
This commit is contained in:
@@ -487,10 +487,18 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
|
||||
pindex->m_chain_tx_count = pindex->nTx;
|
||||
}
|
||||
}
|
||||
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
|
||||
pindex->nStatus |= BLOCK_FAILED_CHILD;
|
||||
|
||||
if (pindex->nStatus & BLOCK_FAILED_CHILD) {
|
||||
// BLOCK_FAILED_CHILD is deprecated, but may still exist on disk. Replace it with BLOCK_FAILED_VALID.
|
||||
pindex->nStatus = (pindex->nStatus & ~BLOCK_FAILED_CHILD) | BLOCK_FAILED_VALID;
|
||||
m_dirty_blockindex.insert(pindex);
|
||||
}
|
||||
if (!(pindex->nStatus & BLOCK_FAILED_VALID) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_VALID)) {
|
||||
// All descendants of invalid blocks are invalid too.
|
||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||
m_dirty_blockindex.insert(pindex);
|
||||
}
|
||||
|
||||
if (pindex->pprev) {
|
||||
pindex->BuildSkip();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user