Merge cc68a3b9dd into merged_master (Bitcoin PR bitcoin/bitcoin#28589)

This commit is contained in:
Byron Hambly 2025-08-06 15:10:12 +02:00
commit 02fdfc4263
No known key found for this signature in database
GPG key ID: DE8F6EA20A661697
2 changed files with 24 additions and 3 deletions

View file

@ -142,7 +142,10 @@ class AssumeutxoTest(BitcoinTestFramework):
f"-stopatheight={PAUSE_HEIGHT}", *self.extra_args[1]])
# Finally connect the nodes and let them sync.
self.connect_nodes(0, 1)
#
# Set `wait_for_connect=False` to avoid a race between performing connection
# assertions and the -stopatheight tripping.
self.connect_nodes(0, 1, wait_for_connect=False)
n1.wait_until_stopped(timeout=5)
@ -156,7 +159,15 @@ class AssumeutxoTest(BitcoinTestFramework):
self.connect_nodes(0, 1)
self.log.info(f"Ensuring snapshot chain syncs to tip. ({FINAL_HEIGHT})")
wait_until_helper(lambda: n1.getchainstates()['snapshot']['blocks'] == FINAL_HEIGHT)
def check_for_final_height():
chainstates = n1.getchainstates()
# The background validation may have completed before we run our first
# check, so accept a final blockheight from either chainstate type.
cs = chainstates.get('snapshot') or chainstates.get('normal')
return cs['blocks'] == FINAL_HEIGHT
wait_until_helper(check_for_final_height)
self.sync_blocks(nodes=(n0, n1))
self.log.info("Ensuring background validation completes")

View file

@ -591,7 +591,14 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
def wait_for_node_exit(self, i, timeout):
self.nodes[i].process.wait(timeout)
def connect_nodes(self, a, b, *, peer_advertises_v2=None):
def connect_nodes(self, a, b, *, peer_advertises_v2=None, wait_for_connect: bool = True):
"""
Kwargs:
wait_for_connect: if True, block until the nodes are verified as connected. You might
want to disable this when using -stopatheight with one of the connected nodes,
since there will be a race between the actual connection and performing
the assertions before one node shuts down.
"""
from_connection = self.nodes[a]
to_connection = self.nodes[b]
from_num_peers = 1 + len(from_connection.getpeerinfo())
@ -608,6 +615,9 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
# compatibility with older clients
from_connection.addnode(ip_port, "onetry")
if not wait_for_connect:
return
# poll until version handshake complete to avoid race conditions
# with transaction relaying
# See comments in net_processing: