Merge bitcoin/bitcoin#34054: net processing: Add ibd check before processing block for txdownloadman

e5f0613503 net processing: Check if we are in ibd before processing block for txdownloadman (sedited)
ce8b692897 Add functional test exercising tx downloadman recently confirmed filter (Lőrinc)

Pull request description:

  Calculating the rolling bloom filters for the txorphanage takes some CPU time from the scheduler thread. This can be observed for example in [this flamegraph](https://bitcoin-dev-tools.github.io/benchcoin/results/pr-172/20066462508/mainnet-default-instrumented-base-flamegraph.svg?x=920203898521&y=780), where handling the filter takes about 2.6% of total time (and most of the scheduler thread's time).

  During ibd the entries in the tx download bloom filter are just continuously rolled over and aren't consumed, since no mempool entries are created by incoming transactions from peers during ibd. The mempool does accept transactions via RPC, or the wallet at the time, however these don't interact with the orphanage and the txdownloadman, because adding anything to those is guarded by IsInitialBlockDownload() checks as well.

  We're usually latching ibd to false a few blocks before catching up to the tip, so this should also not significantly degrade the performance of the filter once fully caught up.

ACKs for top commit:
  l0rinc:
    ACK e5f0613503
  instagibbs:
    ACK e5f0613503
  fjahr:
    Code review ACK e5f0613503

Tree-SHA512: d667e677f5723c438cdf5b34f0f9c1ade7cc1b2e98530c23f14384514daa38217c4e7c3b756194b6831b590a487449c4514b52bf0fb461ae8083061722824270
This commit is contained in:
merge-script
2026-02-26 10:33:29 +00:00
2 changed files with 19 additions and 5 deletions

View File

@@ -2084,12 +2084,12 @@ void PeerManagerImpl::BlockConnected(
}
// The following task can be skipped since we don't maintain a mempool for
// the historical chainstate.
if (role.historical) {
return;
// the historical chainstate, or during ibd since we don't receive incoming
// transactions from peers into the mempool.
if (!role.historical && !m_chainman.IsInitialBlockDownload()) {
LOCK(m_tx_download_mutex);
m_txdownloadman.BlockConnected(pblock);
}
LOCK(m_tx_download_mutex);
m_txdownloadman.BlockConnected(pblock);
}
void PeerManagerImpl::BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex)