Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2054,12 +2054,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)
Expand Down
14 changes: 14 additions & 0 deletions test/functional/p2p_ibd_txrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from decimal import Decimal
import time

from test_framework.blocktools import create_block, create_coinbase
from test_framework.messages import (
CInv,
COIN,
Expand Down Expand Up @@ -48,6 +49,12 @@ def run_test(self):
self.wait_until(lambda: all(peer['minfeefilter'] == MAX_FEE_FILTER for peer in node.getpeerinfo()))

self.nodes[0].setmocktime(int(time.time()))
self.log.info("Mine one old block so we stay in IBD, then remember its coinbase wtxid")
block = create_block(int(self.nodes[0].getbestblockhash(), 16), create_coinbase(1), int(time.time()) - 2 * 24 * 60 * 60)
block.solve()
self.nodes[0].submitblock(block.serialize().hex())
assert self.nodes[0].getblockchaininfo()['initialblockdownload']
ibd_wtxid = int(self.nodes[0].getblock(f"{block.hash_int:064x}", 2)["tx"][0]["hash"], 16)

self.log.info("Check that nodes don't send getdatas for transactions while still in IBD")
peer_inver = self.nodes[0].add_p2p_connection(P2PDataStore())
Expand Down Expand Up @@ -82,6 +89,13 @@ def run_test(self):
assert not node.getblockchaininfo()['initialblockdownload']
self.wait_until(lambda: all(peer['minfeefilter'] == NORMAL_FEE_FILTER for peer in node.getpeerinfo()))

self.log.info("Check that txs confirmed during IBD are not in the recently-confirmed filter once out of ibd")
peer_inver = self.nodes[0].add_p2p_connection(P2PDataStore())
peer_inver.send_and_ping(msg_inv([CInv(t=MSG_WTX, h=ibd_wtxid)]))
self.nodes[0].bumpmocktime(NONPREF_PEER_TX_DELAY)
peer_inver.wait_for_getdata([ibd_wtxid])
self.nodes[0].disconnect_p2ps()

self.log.info("Check that nodes process the same transaction, even when unsolicited, when no longer in IBD")
peer_txer = self.nodes[0].add_p2p_connection(P2PInterface())
with self.nodes[0].assert_debug_log(expected_msgs=["was not accepted"]):
Expand Down