Skip to content

Commit c0fe763

Browse files
committed
consensus: Fix rare fork possibility.
1 parent 6bd792e commit c0fe763

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

doc/release-notes-particl.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
12
22.0.3
23
==============
34

45
- wallet: Stake thread is awoken when the chain leaves IBD state.
6+
- consensus: Fix rare fork possibility.
7+
- A block index is added for an invalid block, to prevent nodes trying
8+
to redownload the same block from peers.
9+
The failed block index is added to m_failed_blocks, but wasn't being
10+
removed when the block index is removed to prevent DoS issues.
511

612

713
22.0.2

src/validation.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4507,7 +4507,9 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
45074507
// we don't need to iterate over the failed blocks list.
45084508
for (const CBlockIndex* failedit : m_failed_blocks) {
45094509
if (pindexPrev->GetAncestor(failedit->nHeight) == failedit) {
4510-
//assert(failedit->nStatus & BLOCK_FAILED_VALID);
4510+
if (!(failedit->nStatus & BLOCK_FAILED_VALID)) {
4511+
LogPrintf("ERROR: Valid block in m_failed_blocks!\n");
4512+
}
45114513
CBlockIndex* invalid_walk = pindexPrev;
45124514
if (failedit->nStatus & BLOCK_FAILED_VALID)
45134515
while (invalid_walk != failedit) {
@@ -6652,6 +6654,7 @@ bool RemoveUnreceivedHeader(ChainstateManager &chainman, const uint256 &hash) EX
66526654
for (auto &entry : remove_headers) {
66536655
LogPrint(BCLog::NET, "Removing loose header %s.\n", entry->second->GetBlockHash().ToString());
66546656
setDirtyBlockIndex.erase(entry->second);
6657+
chainman.m_blockman.m_failed_blocks.erase(entry->second);
66556658

66566659
if (pindexBestHeader == entry->second) {
66576660
pindexBestHeader = chainman.ActiveChain().Tip();

0 commit comments

Comments
 (0)