From 18a9b27dd68dc9044a82fba0802b8cb5c68d10ce Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 22 Mar 2021 23:53:56 +0100 Subject: [PATCH 1/2] p2p: Don't send FEEFILTER in blocksonly mode It is unnecessary to send FEEFILTER messages when we don't accept transactions from our peers. --- src/net_processing.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index e561f02c4a..d327a69a93 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4689,7 +4689,10 @@ bool PeerManagerImpl::SendMessages(CNode* pto) // // Message: feefilter // - if (pto->m_tx_relay != nullptr && pto->GetCommonVersion() >= FEEFILTER_VERSION && gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) && + if (pto->m_tx_relay != nullptr && + !m_ignore_incoming_txs && + pto->GetCommonVersion() >= FEEFILTER_VERSION && + gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) && !pto->HasPermission(PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us ) { CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK(); From beead33a21483c4901e76799ba5c8f7d6fdfffe9 Mon Sep 17 00:00:00 2001 From: glozow Date: Wed, 24 Mar 2021 11:40:04 -0700 Subject: [PATCH 2/2] [test] no send feefilters when txrelay is turned off --- test/functional/p2p_feefilter.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/functional/p2p_feefilter.py b/test/functional/p2p_feefilter.py index a2a122b352..52dc4de3bd 100755 --- a/test/functional/p2p_feefilter.py +++ b/test/functional/p2p_feefilter.py @@ -61,6 +61,7 @@ class FeeFilterTest(BitcoinTestFramework): def run_test(self): self.test_feefilter_forcerelay() self.test_feefilter() + self.test_feefilter_blocksonly() def test_feefilter_forcerelay(self): self.log.info('Check that peers without forcerelay permission (default) get a feefilter message') @@ -119,6 +120,19 @@ class FeeFilterTest(BitcoinTestFramework): conn.wait_for_invs_to_match(txids) conn.clear_invs() + def test_feefilter_blocksonly(self): + """Test that we don't send fee filters to block-relay-only peers and when we're in blocksonly mode.""" + self.log.info("Check that we don't send fee filters to block-relay-only peers.") + feefilter_peer = self.nodes[0].add_outbound_p2p_connection(FeefilterConn(), p2p_idx=0, connection_type="block-relay-only") + feefilter_peer.sync_with_ping() + feefilter_peer.assert_feefilter_received(False) + + self.log.info("Check that we don't send fee filters when in blocksonly mode.") + self.restart_node(0, ["-blocksonly"]) + feefilter_peer = self.nodes[0].add_p2p_connection(FeefilterConn()) + feefilter_peer.sync_with_ping() + feefilter_peer.assert_feefilter_received(False) + if __name__ == '__main__': FeeFilterTest().main()