Restore test case for p2p transaction blinding #19649

pull instagibbs wants to merge 2 commits into bitcoin:master from instagibbs:p2p_segwit_reject changing 1 files +11 −1
  1. instagibbs commented at 1:03 am on August 3, 2020: member
    Introduced in ca10a03addf70421893791c2c499e82fc494d60b then erroneously removed in 8d8099e97ab8af2126f6fbd223fbd82c52f2e85e. The restored line is how we are checking that the node will still re-request a specific txid given a witness-related failure.
  2. fanquake added the label Tests on Aug 3, 2020
  3. Restore test case for p2p transaction blinding
    Introduced in ca10a03addf70421893791c2c499e82fc494d60b then erroneously removed in
    8d8099e97ab8af2126f6fbd223fbd82c52f2e85e. The restored line is how we are
    checking that the node will still re-request a specific txid given a witness-related failure.
    0fea6ede1b
  4. instagibbs force-pushed on Aug 3, 2020
  5. ajtowns commented at 1:54 am on August 3, 2020: member

    ACK 0fea6ede1b46f5137e8ea0fbacce169d97e4a5ee

    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:

     0--- a/test/functional/p2p_segwit.py
     1+++ b/test/functional/p2p_segwit.py
     2@@ -174,6 +174,9 @@ class TestP2PConn(P2PInterface):
     3         self.last_wtxidrelay.append(message)
     4 
     5     def announce_tx_and_wait_for_getdata(self, tx, timeout=60, success=True, use_wtxid=False):
     6+        if success:
     7+            # sanity check
     8+            assert (self.wtxidrelay and use_wtxid) or (not self.wtxidrelay and not use_wtxid)
     9         with mininode_lock:
    10             self.last_message.pop("getdata", None)
    11         if use_wtxid:
    12@@ -259,6 +262,8 @@ class SegWitTest(BitcoinTestFramework):
    13         self.old_node = self.nodes[0].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK)
    14         # self.std_node is for testing node1 (fRequireStandard=true)
    15         self.std_node = self.nodes[1].add_p2p_connection(TestP2PConn(), services=NODE_NETWORK | NODE_WITNESS)
    16+        # self.std_wtx_node is for testing node1 with wtxid relay
    17+        self.std_wtx_node = self.nodes[1].add_p2p_connection(TestP2PConn(wtxidrelay=True), services=NODE_NETWORK | NODE_WITNESS)
    18 
    19         assert self.test_node.nServices & NODE_WITNESS != 0
    20 
    21@@ -1320,10 +1325,13 @@ class SegWitTest(BitcoinTestFramework):
    22         tx3.rehash()
    23 
    24         # Node will not be blinded to the transaction, requesting it any number of times
    25-        # since it is being announced via txid relay.
    26+        # if it is being announced via txid relay.
    27+        # Node will be blinded to the transaction via wtxid, however.
    28         self.std_node.announce_tx_and_wait_for_getdata(tx3)
    29+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True)
    30         test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'tx-size')
    31         self.std_node.announce_tx_and_wait_for_getdata(tx3)
    32+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True, success=False)
    33 
    34         # Remove witness stuffing, instead add extra witness push on stack
    35         tx3.vout[0] = CTxOut(tx2.vout[0].nValue - 1000, CScript([OP_TRUE, OP_DROP] * 15 + [OP_TRUE]))
    
  6. Test that wtxid relay peers add wtxid to reject filter
    h/t Anthony Towns
    566aada386
  7. instagibbs commented at 3:38 am on August 3, 2020: member
    @ajtowns looks good, may as well get this in now, confirmed it’s not already(intentionally) tested for
  8. instagibbs commented at 7:09 pm on August 3, 2020: member
    @sdaftuar you may be interested
  9. laanwj commented at 1:47 pm on August 5, 2020: member
    Concept ACK, thanks for paying attention here.
  10. fjahr commented at 2:51 pm on August 6, 2020: member
    tACK 566aada386e181c2ff40ef18ee660a819f485415
  11. laanwj merged this on Aug 9, 2020
  12. laanwj closed this on Aug 9, 2020

  13. sidhujag referenced this in commit 8d30d93ed3 on Aug 9, 2020
  14. in test/functional/p2p_segwit.py:1334 in 566aada386
    1330+        # Node will be blinded to the transaction via wtxid, however.
    1331         self.std_node.announce_tx_and_wait_for_getdata(tx3)
    1332+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True)
    1333         test_transaction_acceptance(self.nodes[1], self.std_node, tx3, True, False, 'tx-size')
    1334+        self.std_node.announce_tx_and_wait_for_getdata(tx3)
    1335+        self.std_wtx_node.announce_tx_and_wait_for_getdata(tx3, use_wtxid=True, success=False)
    


    jnewbery commented at 8:19 am on April 29, 2021:

    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

  15. DrahtBot locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me