Skip to content

Conversation

@instagibbs
Copy link
Member

Introduced in ca10a03 then erroneously removed in 8d8099e. The restored line is how we are
checking that the node will still re-request a specific txid given a witness-related failure.

@fanquake fanquake added the Tests label Aug 3, 2020
Introduced in ca10a03 then erroneously removed in
8d8099e. The restored line is how we are
checking that the node will still re-request a specific txid given a witness-related failure.
@ajtowns
Copy link
Contributor

ajtowns commented Aug 3, 2020

ACK 0fea6ed

However, while we're at it, maybe also check that announcing the stuffed tx3 via wtxid does blind the node to the wtxid? I don't think test_wtxid_relay does that already, and it should be easy to do it here:

--- a/test/functional/p2p_segwit.py
+++ b/test/functional/p2p_segwit.py
@@ -174,6 +174,9 @@ class TestP2PConn(P2PInterface):
         self.last_wtxidrelay.append(message)
 
     def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtxid=False):
+        if success:
+            # sanity check
+            assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
         with mininode_lock:
             self.last_message.pop("getdata", None)
         if use_wtxid:
@@ -259,6 +262,8 @@ class SegWitTest(BitcoinTestFramework):
         self.old_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
         # self.std_node is for testing node1 (fRequireStandard=true)
         self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK | NODE_WITNESS)
+        # self.std_wtx_node is for testing node1 with wtxid relay
+        self.std_wtx_node = self.nodes[1].add_p2p_connection(TestP2PConn(wtxidrelay=True), services=NODE_NETWORK | NODE_WITNESS)
 
         assert self.test_node.nServices & NODE_WITNESS != 0
 
@@ -1320,10 +1325,13 @@ class SegWitTest(BitcoinTestFramework):
         tx3.rehash()
 
         # Node will not be blinded to the transaction, requesting it any number of times
-        # since it is being announced via txid relay.
+        # if it is being announced via txid relay.
+        # Node will be blinded to the transaction via wtxid, however.
         self.std_node.announce_tx_and_wait_for_getdata(tx3)
+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True)
         test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'tx-size')
         self.std_node.announce_tx_and_wait_for_getdata(tx3)
+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True, success=False)
 
         # Remove witness stuffing, instead add extra witness push on stack
         tx3.vout[0] = CTxOut(tx2.vout[0].nValue - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))

@instagibbs
Copy link
Member Author

@ajtowns looks good, may as well get this in now, confirmed it's not already(intentionally) tested for

@instagibbs
Copy link
Member Author

@sdaftuar you may be interested

@laanwj
Copy link
Member

laanwj commented Aug 5, 2020

Concept ACK, thanks for paying attention here.

@fjahr
Copy link
Contributor

fjahr commented Aug 6, 2020

tACK 566aada

@laanwj laanwj merged commit 214e665 into bitcoin:master Aug 9, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Aug 9, 2020
566aada Test that wtxid relay peers add wtxid to reject filter (Gregory Sanders)
0fea6ed Restore test case for p2p transaction blinding (Gregory Sanders)

Pull request description:

  Introduced in ca10a03 then erroneously removed in 8d8099e. The restored line is how we are
  checking that the node will still re-request a specific txid given a witness-related failure.

ACKs for top commit:
  fjahr:
    tACK 566aada

Tree-SHA512: be2b75b5eddb88019b79cc798f9922ca7347ccbb2210b8d4eae93fdde62e2cbb614b5247cb2fbd7ee3577dbe053875a9b62c5747aace8617f12790b8fccdeab4
self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True)
test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'tx-size')
self.std_node.announce_tx_and_wait_for_getdata(tx3)
self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True, success=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This results in a sleep(60) since the timeout defaults to 60. We don't need to wait that long to verify that the inv doesn't result in a getdata.

Fixed in #21804

@bitcoin bitcoin locked as resolved and limited conversation to collaborators Aug 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants