Skip to content

Commit ba3faaf

Browse files
MacroFakevijaydasmp
MacroFake
authored andcommitted
Merge bitcoin#25683: refactor: log nEvicted message in LimitOrphans then return void
b4b657b refactor: log `nEvicted` message in `LimitOrphans` then return void (chinggg) Pull request description: Fix https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=49347 LimitOrphans() can log expired tx and it should log evicted tx as well instead of returning the `nEvicted` number for caller to print the message. Since `LimitOrphans()` now returns void, the redundant assertion check in fuzz test is also removed. Top commit has no ACKs. Tree-SHA512: 18c41702321b0e59812590cd389f3163831d431f4ebdc3b3e1e0698496a6bdbac52288f28f779237a58813c6717da1a35e8933d509822978ff726c1b13cfc778
1 parent 46bbddd commit ba3faaf

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,10 +4543,7 @@ void PeerManagerImpl::ProcessMessage(
45434543

45444544
// DoS prevention: do not allow m_orphans to grow unbounded (see CVE-2012-3789)
45454545
unsigned int nMaxOrphanTxSize = (unsigned int)std::max((int64_t)0, gArgs.GetIntArg("-maxorphantxsize", DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE)) * 1000000;
4546-
unsigned int nEvicted = m_orphanage.LimitOrphans(nMaxOrphanTxSize);
4547-
if (nEvicted > 0) {
4548-
LogPrint(BCLog::MEMPOOL, "orphanage overflow, removed %u tx\n", nEvicted);
4549-
}
4546+
m_orphanage.LimitOrphans(nMaxOrphanTxSize);
45504547
} else {
45514548
LogPrint(BCLog::MEMPOOL, "not keeping orphan with rejected parents %s\n",tx.GetHash().ToString());
45524549
// We will continue to reject this tx since it has rejected

src/txorphanage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void TxOrphanage::EraseForPeer(NodeId peer)
109109
if (nErased > 0) LogPrint(BCLog::MEMPOOL, "Erased %d orphan tx from peer=%d\n", nErased, peer);
110110
}
111111

112-
unsigned int TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
112+
void TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
113113
{
114114
AssertLockHeld(g_cs_orphans);
115115

@@ -142,7 +142,7 @@ unsigned int TxOrphanage::LimitOrphans(unsigned int max_orphans_size)
142142
EraseTx(m_orphan_list[randompos]->first);
143143
++nEvicted;
144144
}
145-
return nEvicted;
145+
if (nEvicted > 0) LogPrint(BCLog::MEMPOOL, "orphanage overflow, removed %u tx\n", nEvicted);
146146
}
147147

148148
void TxOrphanage::AddChildrenToWorkSet(const CTransaction& tx, std::set<uint256>& orphan_work_set) const

src/txorphanage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class TxOrphanage {
4444
void EraseForBlock(const CBlock& block) LOCKS_EXCLUDED(::g_cs_orphans);
4545

4646
/** Limit the orphanage to the given maximum */
47-
unsigned int LimitOrphans(unsigned int max_orphans_size) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
47+
void LimitOrphans(unsigned int max_orphans_size) EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans);
4848

4949
/** Add any orphans that list a particular tx as a parent into a peer's work set
5050
* (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool) */

0 commit comments

Comments
 (0)