mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-07-12 21:22:46 +02:00
Merge bitcoin/bitcoin#31666: multi-peer orphan resolution followups
7426afbe62
[p2p] assign just 1 random announcer in AddChildrenToWorkSet (glozow)4c1fa6b28c
test fix: make peer who sends MSG_TX announcement non-wtxidrelay (glozow)2da46b88f0
pass P2PTxInvStore init args to P2PInterface init (glozow)e3bd51e4b5
[doc] how unique_parents can be empty (glozow)32eb6dc758
[refactor] assign local variable for wtxid (glozow)18820ccf6b
multi-announcer orphan handling test fixups (glozow)c4cc61db98
[fuzz] GetCandidatePeers (glozow)7704139cf0
[refactor] make GetCandidatePeers take uint256 and in-out vector (glozow)6e4d392a75
[refactor] rename to OrphanResolutionCandidate to MaybeAdd* (glozow)57221ad979
[refactor] move parent inv-adding to OrphanResolutionCandidate (glozow) Pull request description: Followup to #31397. Addressing (in order): https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1906077380 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1881060842 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1905994963 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1905999581 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1906001592 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1905989913 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1905920861 https://github.com/bitcoin/bitcoin/pull/31658#pullrequestreview-2551617694 https://github.com/bitcoin/bitcoin/pull/31397#discussion_r1917559601 ACKs for top commit: instagibbs: reACK7426afbe62
marcofleon: reACK7426afbe62
mzumsande: Code Review ACK7426afbe62
dergoegge: Code review ACK7426afbe62
Tree-SHA512: bca8f576873fdaa20b758e1ee9708ce94e618ff14726864b29b50f0f9a4db58136a286d2b654af569b09433a028901fe6bcdda68dcbfea71e2d1271934725503
This commit is contained in:
@ -66,8 +66,8 @@ def cleanup(func):
|
||||
|
||||
class PeerTxRelayer(P2PTxInvStore):
|
||||
"""A P2PTxInvStore that also remembers all of the getdata and tx messages it receives."""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
def __init__(self, wtxidrelay=True):
|
||||
super().__init__(wtxidrelay=wtxidrelay)
|
||||
self._tx_received = []
|
||||
self._getdata_received = []
|
||||
|
||||
@ -402,7 +402,7 @@ class OrphanHandlingTest(BitcoinTestFramework):
|
||||
node = self.nodes[0]
|
||||
peer1 = node.add_p2p_connection(PeerTxRelayer())
|
||||
peer2 = node.add_p2p_connection(PeerTxRelayer())
|
||||
peer3 = node.add_p2p_connection(PeerTxRelayer())
|
||||
peer3 = node.add_p2p_connection(PeerTxRelayer(wtxidrelay=False))
|
||||
|
||||
self.log.info("Test that an orphan with rejected parents, along with any descendants, cannot be retried with an alternate witness")
|
||||
parent_low_fee_nonsegwit = self.wallet_nonsegwit.create_self_transfer(fee_rate=0)
|
||||
@ -776,16 +776,18 @@ class OrphanHandlingTest(BitcoinTestFramework):
|
||||
assert tx_replacer_BC["txid"] in node.getrawmempool()
|
||||
node.sendrawtransaction(tx_replacer_C["hex"])
|
||||
assert tx_replacer_BC["txid"] not in node.getrawmempool()
|
||||
assert parent_peekaboo_AB["txid"] not in node.getrawmempool()
|
||||
assert tx_replacer_C["txid"] in node.getrawmempool()
|
||||
|
||||
# Second peer is an additional announcer for this orphan
|
||||
# Second peer is an additional announcer for this orphan, but its missing parents are different from when it was
|
||||
# previously announced.
|
||||
peer2 = node.add_p2p_connection(PeerTxRelayer())
|
||||
peer2.send_and_ping(msg_inv([orphan_inv]))
|
||||
assert_equal(len(node.getorphantxs(verbosity=2)[0]["from"]), 2)
|
||||
|
||||
# Disconnect peer1. peer2 should become the new candidate for orphan resolution.
|
||||
peer1.peer_disconnect()
|
||||
node.bumpmocktime(NONPREF_PEER_TX_DELAY + TXID_RELAY_DELAY)
|
||||
node.bumpmocktime(TXREQUEST_TIME_SKIP)
|
||||
self.wait_until(lambda: len(node.getorphantxs(verbosity=2)[0]["from"]) == 1)
|
||||
# Both parents should be requested, now that they are both missing.
|
||||
peer2.wait_for_parent_requests([int(parent_peekaboo_AB["txid"], 16), int(parent_missing["txid"], 16)])
|
||||
|
@ -928,8 +928,8 @@ class P2PDataStore(P2PInterface):
|
||||
|
||||
class P2PTxInvStore(P2PInterface):
|
||||
"""A P2PInterface which stores a count of how many times each txid has been announced."""
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.tx_invs_received = defaultdict(int)
|
||||
|
||||
def on_inv(self, message):
|
||||
|
Reference in New Issue
Block a user