Skip to content

Commit 4399dc8

Browse files
author
MarcoFalke
committed
Merge #21509: p2p: Don't send FEEFILTER in blocksonly mode.
beead33 [test] no send feefilters when txrelay is turned off (glozow) 18a9b27 p2p: Don't send FEEFILTER in blocksonly mode (Martin Zumsande) Pull request description: The purpose of FEEFILTER messages (BIP 133) is to inform our peers that we do not want transactions below a specified fee rate. In blocksonly mode, we do not want our peer to send us any transactions at all (and will disconnect if a peer still sends a transaction INV or TX).  Therefore, I don't think that it makes sense to send FEEFILTER messages every 10 minutes on average in blocksonly mode - this PR disables it. Note that on block-relay-only connections, FEEFILTER is already disabled, just not in blocksonly mode. ACKs for top commit: glozow: re ACK beead33 🙂 thanks for adding the test! amitiuttarwar: reACK beead33 MarcoFalke: review ACK beead33 jnewbery: reACK beead33 Tree-SHA512: e748cd52fe23d647fa49008b020389956ac508e16ce9fd108d8afb773bff95788298ae229162bd70215d7246fc25c796484966dc05890b0b4ef601f9cd35628b
2 parents cf11f9c + beead33 commit 4399dc8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/net_processing.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4689,7 +4689,10 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
46894689
//
46904690
// Message: feefilter
46914691
//
4692-
if (pto->m_tx_relay != nullptr && pto->GetCommonVersion() >= FEEFILTER_VERSION && gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
4692+
if (pto->m_tx_relay != nullptr &&
4693+
!m_ignore_incoming_txs &&
4694+
pto->GetCommonVersion() >= FEEFILTER_VERSION &&
4695+
gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
46934696
!pto->HasPermission(PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us
46944697
) {
46954698
CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();

test/functional/p2p_feefilter.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def set_test_params(self):
6161
def run_test(self):
6262
self.test_feefilter_forcerelay()
6363
self.test_feefilter()
64+
self.test_feefilter_blocksonly()
6465

6566
def test_feefilter_forcerelay(self):
6667
self.log.info('Check that peers without forcerelay permission (default) get a feefilter message')
@@ -119,6 +120,19 @@ def test_feefilter(self):
119120
conn.wait_for_invs_to_match(txids)
120121
conn.clear_invs()
121122

123+
def test_feefilter_blocksonly(self):
124+
"""Test that we don't send fee filters to block-relay-only peers and when we're in blocksonly mode."""
125+
self.log.info("Check that we don't send fee filters to block-relay-only peers.")
126+
feefilter_peer = self.nodes[0].add_outbound_p2p_connection(FeefilterConn(), p2p_idx=0, connection_type="block-relay-only")
127+
feefilter_peer.sync_with_ping()
128+
feefilter_peer.assert_feefilter_received(False)
129+
130+
self.log.info("Check that we don't send fee filters when in blocksonly mode.")
131+
self.restart_node(0, ["-blocksonly"])
132+
feefilter_peer = self.nodes[0].add_p2p_connection(FeefilterConn())
133+
feefilter_peer.sync_with_ping()
134+
feefilter_peer.assert_feefilter_received(False)
135+
122136

123137
if __name__ == '__main__':
124138
FeeFilterTest().main()

0 commit comments

Comments
 (0)