Skip to content

Commit af54459

Browse files
committed
validation: remove BLOCK_FAILED_CHILD
even though we have a distinction between BLOCK_FAILED_VALID and BLOCK_FAILED_CHILD in the codebase, we don't use it for anything. since there's no functional difference between them and it's unnecessary code complexity to categorise them correctly, just mark as BLOCK_FAILED_VALID instead.
1 parent 5738d3e commit af54459

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

src/chain.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ enum BlockStatus : uint32_t {
123123
BLOCK_HAVE_MASK = BLOCK_HAVE_DATA | BLOCK_HAVE_UNDO,
124124

125125
BLOCK_FAILED_VALID = 32, //!< stage after last reached validness failed
126-
BLOCK_FAILED_CHILD = 64, //!< descends from failed block
127-
BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD,
126+
BLOCK_FAILED_MASK = BLOCK_FAILED_VALID,
128127

129128
BLOCK_OPT_WITNESS = 128, //!< block data in blk*.dat was received with a witness-enforcing client
130129

src/node/blockstorage.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
462462
}
463463
}
464464
if (!(pindex->nStatus & BLOCK_FAILED_MASK) && pindex->pprev && (pindex->pprev->nStatus & BLOCK_FAILED_MASK)) {
465-
pindex->nStatus |= BLOCK_FAILED_CHILD;
465+
pindex->nStatus |= BLOCK_FAILED_VALID;
466466
m_dirty_blockindex.insert(pindex);
467467
}
468468
if (pindex->pprev) {

src/test/fuzz/chain.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ FUZZ_TARGET(chain)
5050
BlockStatus::BLOCK_HAVE_UNDO,
5151
BlockStatus::BLOCK_HAVE_MASK,
5252
BlockStatus::BLOCK_FAILED_VALID,
53-
BlockStatus::BLOCK_FAILED_CHILD,
5453
BlockStatus::BLOCK_FAILED_MASK,
5554
BlockStatus::BLOCK_OPT_WITNESS,
5655
});

src/validation.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ CBlockIndex* Chainstate::FindMostWorkChain()
33063306
// Remove the entire chain from the set.
33073307
while (pindexTest != pindexFailed) {
33083308
if (fFailedChain) {
3309-
pindexFailed->nStatus |= BLOCK_FAILED_CHILD;
3309+
pindexFailed->nStatus |= BLOCK_FAILED_VALID;
33103310
m_blockman.m_dirty_blockindex.insert(pindexFailed);
33113311
} else if (fMissingData) {
33123312
// If we're missing data, then add back to m_blocks_unlinked,
@@ -3817,7 +3817,7 @@ void Chainstate::SetBlockFailureFlags(CBlockIndex* invalid_block)
38173817

38183818
for (auto& [_, block_index] : m_blockman.m_block_index) {
38193819
if (block_index.GetAncestor(invalid_block->nHeight) == invalid_block && !(block_index.nStatus & BLOCK_FAILED_MASK)) {
3820-
block_index.nStatus |= BLOCK_FAILED_CHILD;
3820+
block_index.nStatus |= BLOCK_FAILED_VALID;
38213821
}
38223822
}
38233823
}
@@ -4366,10 +4366,10 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
43664366
* B1 - C1 - D1 - E1
43674367
*
43684368
* In the case that we attempted to reorg from E1 to F2, only to find
4369-
* C2 to be invalid, we would mark D2, E2, and F2 as BLOCK_FAILED_CHILD
4369+
* C2 to be invalid, we would mark D2, E2, and F2 as BLOCK_FAILED_VALID
43704370
* but NOT D3 (it was not in any of our candidate sets at the time).
43714371
*
4372-
* In any case D3 will also be marked as BLOCK_FAILED_CHILD at restart
4372+
* In any case D3 will also be marked as BLOCK_FAILED_VALID at restart
43734373
* in LoadBlockIndex.
43744374
*/
43754375
if (!pindexPrev->IsValid(BLOCK_VALID_SCRIPTS)) {
@@ -4382,7 +4382,7 @@ bool ChainstateManager::AcceptBlockHeader(const CBlockHeader& block, BlockValida
43824382
assert(failedit->nStatus & BLOCK_FAILED_VALID);
43834383
CBlockIndex* invalid_walk = pindexPrev;
43844384
while (invalid_walk != failedit) {
4385-
invalid_walk->nStatus |= BLOCK_FAILED_CHILD;
4385+
invalid_walk->nStatus |= BLOCK_FAILED_VALID;
43864386
m_blockman.m_dirty_blockindex.insert(invalid_walk);
43874387
invalid_walk = invalid_walk->pprev;
43884388
}

0 commit comments

Comments
 (0)