Skip to content

Commit 2aed101

Browse files
authored
Merge pull request #392 from JohnnyLawDGB/fix/dandelion-stempool-ancestor-leak
fix: purge confirmed txs from Dandelion stempool on block connect
2 parents eb07fb7 + 13f98b4 commit 2aed101

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/validation.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3350,9 +3350,10 @@ bool Chainstate::DisconnectTip(BlockValidationState& state, DisconnectedBlockTra
33503350

33513351
if (disconnectpool && m_mempool) {
33523352
// Save transactions to re-add to mempool at end of reorg. If any entries are evicted for
3353-
// exceeding memory limits, remove them and their descendants from the mempool.
3353+
// exceeding memory limits, remove them and their descendants from the mempool and stempool.
33543354
for (auto&& evicted_tx : disconnectpool->AddTransactionsFromBlock(block.vtx)) {
33553355
m_mempool->removeRecursive(*evicted_tx, MemPoolRemovalReason::REORG);
3356+
if (m_stempool) m_stempool->removeRecursive(*evicted_tx, MemPoolRemovalReason::REORG);
33563357
}
33573358
}
33583359

@@ -3483,6 +3484,13 @@ bool Chainstate::ConnectTip(BlockValidationState& state, CBlockIndex* pindexNew,
34833484
m_mempool->removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
34843485
disconnectpool.removeForBlock(blockConnecting.vtx);
34853486
}
3487+
// CRITICAL FIX: Also remove confirmed transactions from the Dandelion stempool.
3488+
// Without this, confirmed txs remain as phantom ancestors in the stempool,
3489+
// inflating ancestor counts until new stempool txs hit the 25-ancestor limit
3490+
// and get rejected with "too-long-mempool-chain".
3491+
if (m_stempool) {
3492+
m_stempool->removeForBlock(blockConnecting.vtx, pindexNew->nHeight);
3493+
}
34863494
// Update m_chain & related variables.
34873495
m_chain.SetTip(*pindexNew);
34883496
UpdateTip(pindexNew);

0 commit comments

Comments
 (0)