Skip to content

Commit 05395ff

Browse files
committed
merge bitcoin#22817: Avoid race after connect_nodes
Due to stricter checks, we can no longer start masternodes in parallel, as entities used to process `to_connection` checks are reused before the previous check is completed, resulting in an exception. Since we're now validating the establishment of a two-way connection, we have to do it one at a time.
1 parent 5a0479f commit 05395ff

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

test/functional/test_framework/test_framework.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -695,18 +695,19 @@ def connect_nodes(self, a, b):
695695
if (a == b):
696696
return
697697

698-
def connect_nodes_helper(from_connection, node_num):
699-
ip_port = "127.0.0.1:" + str(p2p_port(node_num))
700-
from_connection.addnode(ip_port, "onetry")
701-
# poll until version handshake complete to avoid race conditions
702-
# with transaction relaying
703-
# See comments in net_processing:
704-
# * Must have a version message before anything else
705-
# * Must have a verack message before anything else
706-
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
707-
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
708-
709-
connect_nodes_helper(self.nodes[a], b)
698+
from_connection = self.nodes[a]
699+
to_connection = self.nodes[b]
700+
ip_port = "127.0.0.1:" + str(p2p_port(b))
701+
from_connection.addnode(ip_port, "onetry")
702+
# poll until version handshake complete to avoid race conditions
703+
# with transaction relaying
704+
# See comments in net_processing:
705+
# * Must have a version message before anything else
706+
# * Must have a verack message before anything else
707+
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
708+
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
709+
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
710+
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
710711

711712
def disconnect_nodes(self, a, b):
712713
# A node cannot disconnect from itself, bail out early

0 commit comments

Comments
 (0)