Skip to content

Commit b1291b2

Browse files
author
MarcoFalke
committed
Merge bitcoin#19963: Clarify blocksonly whitelistforcerelay test
e153448 Clarify blocksonly whitelistforcerelay test (t-bast) Pull request description: As discussed in bitcoin#19943, this test may be a bit misleading to newcomers. We underscore the fact that our peer needs to run a modified version of Bitcoin Core to actually relay transactions to a `blocksonly` node and benefit from the `whitelistforcerelay` parameter. ACKs for top commit: naumenkogs: ACK e153448 Tree-SHA512: cc3526ac26c40a2d878b0ad863008663040683fd21092fcdc93866c2b0a79db8c2d29767d1f70bf56195092fca2aa2961cdbee52b5f0b1ae757cece9cd206301
2 parents c7eb85d + e153448 commit b1291b2

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

test/functional/p2p_blocksonly.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,33 @@ def run_test(self):
5757
self.nodes[0].p2p.wait_for_tx(txid)
5858
assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
5959

60-
self.log.info('Check that txs from forcerelay peers are not rejected and relayed to others')
61-
self.log.info("Restarting node 0 with forcerelay permission and blocksonly")
62-
self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", "-whitelistforcerelay", "-blocksonly"])
60+
self.log.info('Check that txs from peers with relay-permission are not rejected and relayed to others')
61+
self.log.info("Restarting node 0 with relay permission and blocksonly")
62+
self.restart_node(0, ["-persistmempool=0", "-whitelist=relay@127.0.0.1", "-blocksonly"])
6363
assert_equal(self.nodes[0].getrawmempool(), [])
6464
first_peer = self.nodes[0].add_p2p_connection(P2PInterface())
6565
second_peer = self.nodes[0].add_p2p_connection(P2PInterface())
6666
peer_1_info = self.nodes[0].getpeerinfo()[0]
67-
assert_equal(peer_1_info['whitelisted'], True)
68-
assert_equal(peer_1_info['permissions'], ['noban', 'forcerelay', 'relay', 'mempool', 'download'])
67+
assert_equal(peer_1_info['permissions'], ['relay'])
6968
peer_2_info = self.nodes[0].getpeerinfo()[1]
70-
assert_equal(peer_2_info['whitelisted'], True)
71-
assert_equal(peer_2_info['permissions'], ['noban', 'forcerelay', 'relay', 'mempool', 'download'])
69+
assert_equal(peer_2_info['permissions'], ['relay'])
7270
assert_equal(self.nodes[0].testmempoolaccept([sigtx])[0]['allowed'], True)
7371
txid = self.nodes[0].testmempoolaccept([sigtx])[0]['txid']
7472

75-
self.log.info('Check that the tx from forcerelay first_peer is relayed to others (ie.second_peer)')
73+
self.log.info('Check that the tx from first_peer with relay-permission is relayed to others (ie.second_peer)')
7674
with self.nodes[0].assert_debug_log(["received getdata"]):
75+
# Note that normally, first_peer would never send us transactions since we're a blocksonly node.
76+
# By activating blocksonly, we explicitly tell our peers that they should not send us transactions,
77+
# and Bitcoin Core respects that choice and will not send transactions.
78+
# But if, for some reason, first_peer decides to relay transactions to us anyway, we should relay them to
79+
# second_peer since we gave relay permission to first_peer.
80+
# See https://github.com/bitcoin/bitcoin/issues/19943 for details.
7781
first_peer.send_message(msg_tx(FromHex(CTransaction(), sigtx)))
78-
self.log.info('Check that the forcerelay peer is still connected after sending the transaction')
82+
self.log.info('Check that the peer with relay-permission is still connected after sending the transaction')
7983
assert_equal(first_peer.is_connected, True)
8084
second_peer.wait_for_tx(txid)
8185
assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
82-
self.log.info("Forcerelay peer's transaction is accepted and relayed")
86+
self.log.info("Relay-permission peer's transaction is accepted and relayed")
8387

8488

8589
if __name__ == '__main__':

0 commit comments

Comments
 (0)