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.
This commit is contained in:
Kittywhiskers Van Gogh 2024-09-22 13:58:07 +00:00
parent 5a0479fe53
commit 05395ff37b
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -695,8 +695,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
if (a == b): if (a == b):
return return
def connect_nodes_helper(from_connection, node_num): from_connection = self.nodes[a]
ip_port = "127.0.0.1:" + str(p2p_port(node_num)) to_connection = self.nodes[b]
ip_port = "127.0.0.1:" + str(p2p_port(b))
from_connection.addnode(ip_port, "onetry") from_connection.addnode(ip_port, "onetry")
# poll until version handshake complete to avoid race conditions # poll until version handshake complete to avoid race conditions
# with transaction relaying # with transaction relaying
@ -704,9 +705,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# * Must have a version message before anything else # * Must have a version message before anything else
# * Must have a verack message before anything else # * Must have a verack message before anything else
wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo())) wait_until_helper(lambda: all(peer['version'] != 0 for peer in from_connection.getpeerinfo()))
wait_until_helper(lambda: all(peer['version'] != 0 for peer in to_connection.getpeerinfo()))
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo())) wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in from_connection.getpeerinfo()))
wait_until_helper(lambda: all(peer['bytesrecv_per_msg'].pop('verack', 0) == 24 for peer in to_connection.getpeerinfo()))
connect_nodes_helper(self.nodes[a], b)
def disconnect_nodes(self, a, b): def disconnect_nodes(self, a, b):
# A node cannot disconnect from itself, bail out early # A node cannot disconnect from itself, bail out early