Skip to content

Commit 4c0ef27

Browse files
committed
validation: hacky way for no BLOCK_FAILED_CHILD
1 parent 00b9e70 commit 4c0ef27

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

src/chain.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +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
126+
BLOCK_FAILED_CHILD = BLOCK_FAILED_VALID, //!< descends from failed block
127127
BLOCK_FAILED_MASK = BLOCK_FAILED_VALID | BLOCK_FAILED_CHILD,
128128

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

src/validation.cpp

+19-15
Original file line numberDiff line numberDiff line change
@@ -5400,22 +5400,26 @@ void ChainstateManager::CheckBlockIndex()
54005400
if (pindexFirstInvalid == nullptr) {
54015401
// Checks for not-invalid blocks.
54025402
printf("pindexFirstInvalid == nullptr : %s\n", pindex->ToString().c_str());
5403-
if (ActiveChain().Contains(pindex)) {
5404-
printf("failed mask not set in main chain\n");
5405-
assert((pindex->nStatus & BLOCK_FAILED_MASK) == 0); // The failed mask cannot be set for blocks without invalid parents.
5406-
}
5407-
}
5408-
else if (pindexFirstInvalid != pindex) {
5409-
// pindexFirstInvalid -> ...... -> pindex
5410-
// we check that descendants are BLOCK_FAILED_CHILD and not BLOCK_FAILED_VALID
5411-
printf("pindexFirstInvalid != pindex : %s\n", pindex->ToString().c_str());
5412-
assert((pindex->nStatus & BLOCK_FAILED_VALID) == 0);
5413-
assert(pindex->nStatus & BLOCK_FAILED_CHILD);
5403+
assert((pindex->nStatus & BLOCK_FAILED_MASK) == 0); // The failed mask cannot be set for blocks without invalid parents.
5404+
// if (ActiveChain().Contains(pindex)) {
5405+
// printf("failed mask not set in main chain\n");
5406+
// assert((pindex->nStatus & BLOCK_FAILED_MASK) == 0); // The failed mask cannot be set for blocks without invalid parents.
5407+
// }
54145408
} else {
5415-
printf("pindexFirstInvalid == pindex : %s\n", pindex->ToString().c_str());
5416-
assert(pindex->nStatus & BLOCK_FAILED_VALID);
5417-
assert((pindex->nStatus & BLOCK_FAILED_CHILD) == 0);
5418-
}
5409+
printf("pindexFirstInvalid != nullptr : %s\n", pindex->ToString().c_str());
5410+
assert(pindex->nStatus & BLOCK_FAILED_MASK);
5411+
}
5412+
// else if (pindexFirstInvalid != pindex) {
5413+
// // pindexFirstInvalid -> ...... -> pindex
5414+
// // we check that descendants are BLOCK_FAILED_CHILD and not BLOCK_FAILED_VALID
5415+
// printf("pindexFirstInvalid != pindex : %s\n", pindex->ToString().c_str());
5416+
// assert((pindex->nStatus & BLOCK_FAILED_VALID) == 0);
5417+
// assert(pindex->nStatus & BLOCK_FAILED_CHILD);
5418+
// } else {
5419+
// printf("pindexFirstInvalid == pindex : %s\n", pindex->ToString().c_str());
5420+
// assert(pindex->nStatus & BLOCK_FAILED_VALID);
5421+
// assert((pindex->nStatus & BLOCK_FAILED_CHILD) == 0);
5422+
// }
54195423
// Make sure m_chain_tx_count sum is correctly computed.
54205424
if (!pindex->pprev) {
54215425
// If no previous block, nTx and m_chain_tx_count must be the same.

0 commit comments

Comments
 (0)