p2p: Use legacy relaying to download blocks in blocks-only mode #22340

pull dergoegge wants to merge 5 commits into bitcoin:master from dergoegge:nocmpct_blocksonly changing 3 files +142 −1
  1. dergoegge commented at 1:49 PM on June 25, 2021: member

    A blocks-only node does not participate in transaction relay to reduce its own bandwidth usage and therefore does not have a mempool. The use of compact blocks is not beneficial to such a node since it will always have to download full blocks.

    In both high- and low-bandwidth relaying the cmpctblock message is sent. This represent a bandwidth overhead for blocks-only nodes because the cmpctblock message is several times larger in the average case than the equivalent headers or inv announcement.

    compact blocks

    Example: A block with 2000 txs results in a cmpctblock with 2000*6 bytes in short ids. This is several times larger than the equivalent 82 bytes for a headers message or 37 bytes for an inv.

    Approach

    This PR makes blocks-only nodes always use the legacy relaying to download new blocks. It does so by making blocks-only nodes never initiate a high-bandwidth block relay connection by disabling the sending of sendcmpct(1). Additionally a blocks-only node will never request a compact block using getdata(CMPCT).

    A blocks-only node will continue to serve compact blocks to its peers in both high- and low-bandwidth mode.

  2. DrahtBot added the label P2P on Jun 25, 2021
  3. dergoegge commented at 3:12 PM on June 26, 2021: member

    Over the last 24h i ran a blocks-only node that saw 106 blocks and downloaded 3.8MB in cmpctblock messages. Thats an average of 12KB bytes per cmpctblock message received from three high-bandwidth peers. Only 26KB would have been downloaded if headers messages would have been used instead. Assuming an average block size of 1.38MB the cmpctblock messages represented 2.5% of downloaded block data.

  4. fanquake commented at 2:46 AM on July 1, 2021: member
  5. ajtowns commented at 5:20 AM on July 2, 2021: member

    Seems workable? Compact blocks should be seeing:

    • 12kB for short tx ids per cmpctblock message announcing a new block (for each high bw peer per block)
    • 2kB per getblocktxn message asking for the tx data (per block)
    • ~0 overhead for blocktxn message providing the block txns

    Which should be ~38kB per block or about 5MB per day/144 blocks. Legacy block relay should just be:

    • ~0 overhead for headers message
    • ~0 overhead for GETDATA MSG_BLOCK request
    • ~0 ovehead for BLOCK message

    So this makes sense to me.

  6. in src/net_processing.cpp:862 in e5993385d5 outdated
     857 | @@ -857,10 +858,13 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
     858 |                  });
     859 |                  lNodesAnnouncingHeaderAndIDs.pop_front();
     860 |              }
     861 | -            m_connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
     862 | -            // save BIP152 bandwidth state: we select peer to be high-bandwidth
     863 | -            pfrom->m_bip152_highbandwidth_to = true;
     864 | -            lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
     865 | +
     866 | +            if (!m_ignore_incoming_txs) {
    


    jnewbery commented at 9:23 AM on July 2, 2021:

    I think you can just exit this function immediately if !m_ignore_incoming_txs:

     void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
     {
         AssertLockHeld(cs_main);
    +
    +    // Never request high-bandwidth mode from peers if we're blocks-only. Our
    +    // mempool will not contain the transactions necessary to reconstruct the
    +    // compact block.
    +    if (m_ignore_incoming_txs) return;
    +
         CNodeState* nodestate = State(nodeid);
         if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) {
             // Never ask from peers who can't provide witnesses.
    @@ -859,12 +865,10 @@ void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
                     lNodesAnnouncingHeaderAndIDs.pop_front();
                 }
     
    -            if (!m_ignore_incoming_txs) {
    -                m_connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
    -                // save BIP152 bandwidth state: we select peer to be high-bandwidth
    -                pfrom->m_bip152_highbandwidth_to = true;
    -                lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
    -            }
    +            m_connman.PushMessage(pfrom, CNetMsgMaker(pfrom->GetCommonVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/true, nCMPCTBLOCKVersion));
    +            // save BIP152 bandwidth state: we select peer to be high-bandwidth
    +            pfrom->m_bip152_highbandwidth_to = true;
    +            lNodesAnnouncingHeaderAndIDs.push_back(pfrom->GetId());
                 return true;
             });
         }
    
  7. in src/net_processing.cpp:2107 in e5993385d5 outdated
    2103 | @@ -2100,7 +2104,7 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
    2104 |                              pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
    2105 |                  }
    2106 |                  if (vGetData.size() > 0) {
    2107 | -                    if (nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
    2108 | +                    if (!m_ignore_incoming_txs && nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
    


    jnewbery commented at 9:25 AM on July 2, 2021:

    Can I convince you to make this conditional a bit more readable:

    -                    if (!m_ignore_incoming_txs && nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
    +                    if (!m_ignore_incoming_txs
    +                        && nodestate->fSupportsDesiredCmpctVersion
    +                        && vGetData.size() == 1
    +                        && mapBlocksInFlight.size() == 1
    +                        && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
    
  8. jnewbery commented at 9:27 AM on July 2, 2021: member

    Concept ACK. Requesting HB mode or sending GETDATA(MSG_CMPCT_BLOCK) is wasteful (for both sender and reciever) if the node can't reconstruct compact blocks.

  9. dergoegge force-pushed on Jul 2, 2021
  10. jnewbery commented at 12:58 PM on July 2, 2021: member

    utACK 6dfee13f650521f7542df0926aff01af9ac6a328

  11. MarcoFalke renamed this:
    Use legacy relaying to download blocks in blocks-only mode
    p2p: Use legacy relaying to download blocks in blocks-only mode
    on Jul 2, 2021
  12. naumenkogs commented at 11:57 AM on July 7, 2021: member

    Is this true for transactions received via sendrawtransaction? What if some node, for whatever reason, receives all transactions, while having blocks-only mode? For them, compact blocks are going to be beneficial, but this PR will disable it?

  13. dergoegge commented at 6:14 PM on July 8, 2021: member

    For them, compact blocks are going to be beneficial, but this PR will disable it? @naumenkogs yes this PR would disable compact blocks even if txs were received through sendrawtransaction and i think overall that's ok since that seems like an edge case to me. I would presume most blocks-only nodes don't submit enough txs through sendrawtransaction for this to matter, especially not continuously so that most blocks contain many of those txs. Or if a node is broadcasting that many txs it might not care about the additional bandwidth?

    [1] Technically it would be possible for a blocks-only node to ask for compact blocks if its mempool size (significantly) exceeds the overhead of compact blocks. [2] A config option enabling compact blocks for those individual blocks-only nodes that heavily use sendrawtransaction could also help.

    Do you think adding [1] or [2] to this PR would be worth it?

  14. naumenkogs commented at 5:46 AM on July 9, 2021: member

    I think [2] is better than [1].

    Whether we want to add a new config option for this use case or just implement what you suggested originally — my personal choice would be to ask for thoughts at the #bitcoin-core-dev meeting.

  15. jnewbery commented at 8:36 AM on July 9, 2021: member

    yes this PR would disable compact blocks even if txs were received through sendrawtransaction and i think overall that's ok since that seems like an edge case to me.

    I agree that this seems like an edge case that wouldn't actually be used. Compact blocks exist to improve propagation speed/efficiency when a node is participating in tx relay. I'd prefer not to add a configuration option that we don't expect to be used, or to increase the complexity of this PR.

  16. naumenkogs commented at 8:55 AM on July 9, 2021: member

    I agree that this seems like an edge case that wouldn't actually be used. Compact blocks exist to improve propagation speed/efficiency when a node is participating in tx relay. I'd prefer not to add a configuration option that we don't expect to be used, or to increase the complexity of this PR.

    To be clear, my worry is that some miners use the following setting: A node in blocks-only mode with low-latency requirements (hence mining) is constantly fed with transactions via sendrawtransaction, for whatever reason (e.g., they consider p2p tx relay insecure and disable it).

    I don't have any evidence of someone using this, just wanted to point out we are going to break this use case here, so I thought asking around makes sense.

  17. sipa commented at 3:59 PM on July 19, 2021: member

    @naumenkogs That seems very unlikely to me.

  18. DrahtBot commented at 1:16 AM on July 23, 2021: member

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20799 (net processing: Only support version 2 compact blocks by jnewbery)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  19. in src/net_processing.cpp:890 in 6dfee13f65 outdated
     830 | @@ -831,6 +831,12 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
     831 |  void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
     832 |  {
     833 |      AssertLockHeld(cs_main);
     834 | +
     835 | +    // Never request high-bandwidth mode from peers if we're blocks-only. Our
     836 | +    // mempool will not contain the transactions necessary to reconstruct the
     837 | +    // compact block.
    


    rajarshimaitra commented at 1:52 PM on August 4, 2021:

    Maybe its better to add here that we are also not sending getdata(CMPCT) in case of block-only?

    My initial confusion was what about the low-band with case, and I missed the getdata(CMPCT) part in the code.

    It would help clarify the doc a little better.


    jnewbery commented at 9:53 AM on August 5, 2021:

    This isn't the right place for that documentation. This function is for sending sendcmpct(hb=true) to the three peers that sent us blocks most recently.


    rajarshimaitra commented at 4:42 PM on August 6, 2021:

    Thanks @jnewbery, that makes sense.

  20. theStack commented at 2:23 PM on August 4, 2021: member

    Concept ACK

  21. in src/net_processing.cpp:884 in 6dfee13f65 outdated
     830 | @@ -831,6 +831,12 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
     831 |  void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
    


    rajarshimaitra commented at 2:54 PM on August 4, 2021:

    Is there any reason why we use MaybeSetPeerAsAnnouncingHeaderAndIDs instead of MaybeSetPeerAsAnncouncingCompactBlocks? Are they different things?


    dergoegge commented at 12:36 PM on August 6, 2021:

    In BIP 152 the structure that is used for the cmcptblock message is called HeaderAndShortIDs. I am assuming that this were the name came from. The function was introduced in the initial compact block PR: https://github.com/bitcoin/bitcoin/pull/8068


    rajarshimaitra commented at 4:46 PM on August 6, 2021:

    Hmm, I guess it comes from there. Still a little hard to guess, as the name seems quite generic (Headers and IDs). It also doesn't have any doc comment above it indicate it's related to compact blocks. Could help with some pointers.


    jnewbery commented at 6:12 PM on August 6, 2021:

    I agree that headers-and-ids is not very helpful here (and in a few other places in the code). Maybe it could be updated in a different PR.

  22. willcl-ark commented at 4:39 PM on August 4, 2021: member

    utACK.

    Perhaps a new test case in p2p_compactblocks.py or p2p_compactblocks_hb.py might be a good addition here, or in a follow-up? This changes behaviour but doesn't fail any tests.

  23. LarryRuane commented at 6:06 PM on August 4, 2021: contributor

    utACK 6dfee13f650521f7542df0926aff01af9ac6a328 but (as others have said) a test would be nice

  24. rajarshimaitra commented at 6:07 PM on August 4, 2021: contributor

    Concept ACK.

    As others have mentioned a functional test covering this behaviour would be nice.

    I just have the following nits.

  25. theStack commented at 8:16 PM on August 6, 2021: member

    utACK 6dfee13f650521f7542df0926aff01af9ac6a328

  26. dergoegge force-pushed on Aug 8, 2021
  27. in test/functional/p2p_compactblocks_blocksonly.py:52 in 217a80d915 outdated
      47 | +        # Generate some blocks so all nodes are out of IBD.
      48 | +        self.nodes[2].generate(10)
      49 | +        self.sync_blocks()
      50 | +
      51 | +        self.disconnect_nodes(0, 2)
      52 | +        self.disconnect_nodes(1, 2)
    


    jnewbery commented at 1:59 PM on August 9, 2021:

    If you use the cached chain, all the nodes will already be out of IBD:

    diff --git a/test/functional/p2p_compactblocks_blocksonly.py b/test/functional/p2p_compactblocks_blocksonly.py
    index b97fdfdb14..bf486d8eda 100755
    --- a/test/functional/p2p_compactblocks_blocksonly.py
    +++ b/test/functional/p2p_compactblocks_blocksonly.py
    @@ -25,7 +25,6 @@ from test_framework.messages import (
     
     class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
         def set_test_params(self):
    -        self.setup_clean_chain = True
             self.num_nodes = 3
             self.extra_args = [["-blocksonly"], [], []]
     
    @@ -41,15 +40,9 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
             return block
     
         def run_test(self):
    -        self.connect_nodes(0, 2)
    -        self.connect_nodes(1, 2)
    -
    -        # Generate some blocks so all nodes are out of IBD.
    -        self.nodes[2].generate(10)
    -        self.sync_blocks()
    -
    -        self.disconnect_nodes(0, 2)
    -        self.disconnect_nodes(1, 2)
    +        # Nodes will only request hb compact blocks mode when they're out of IBD
    +        for i in range(3):
    +            assert not self.nodes[i].getblockchaininfo()['initialblockdownload']
     
             p2p_conn_node0 = self.nodes[0].add_p2p_connection(P2PInterface())
             p2p_conn_node1 = self.nodes[1].add_p2p_connection(P2PInterface())
    
    
  28. in test/functional/p2p_compactblocks_blocksonly.py:35 in 217a80d915 outdated
      31 | +
      32 | +    def setup_network(self):
      33 | +        self.setup_nodes()
      34 | +        self.sync_all()
      35 | +
      36 | +    def build_block_on_tip(self):
    


    jnewbery commented at 3:39 PM on August 9, 2021:

    Alternatively, just generate the block on the node:

    diff --git a/test/functional/p2p_compactblocks_blocksonly.py b/test/functional/p2p_compactblocks_blocksonly.py
    index b97fdfdb14..b55dddc01a 100755
    --- a/test/functional/p2p_compactblocks_blocksonly.py
    +++ b/test/functional/p2p_compactblocks_blocksonly.py
    @@ -7,17 +7,14 @@
     from test_framework.test_framework import BitcoinTestFramework
     from test_framework.p2p import P2PInterface
     from test_framework.util import assert_equal
    -from test_framework.blocktools import (
    -    NORMAL_GBT_REQUEST_PARAMS,
    -    add_witness_commitment,
    -    create_block,
    -)
     from test_framework.messages import (
         MSG_BLOCK,
         MSG_WITNESS_FLAG,
         MSG_CMPCT_BLOCK,
    +    CBlock,
         CInv,
         CBlockHeader,
    +    from_hex,
         msg_block,
         msg_sendcmpct,
         msg_headers,
    @@ -34,10 +31,10 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
             self.sync_all()
     
         def build_block_on_tip(self):
    -        block = create_block(tmpl=self.nodes[2].getblocktemplate(NORMAL_GBT_REQUEST_PARAMS))
    -        add_witness_commitment(block)
    -        block.solve()
    -        self.nodes[2].submitblock(block.serialize().hex())
    +        blockhash = self.nodes[2].generate(1)[0]
    +        block_hex = self.nodes[2].getblock(blockhash=blockhash, verbosity=0)
    +        block = from_hex(CBlock(), block_hex)
    +        block.rehash()
             return block
     
         def run_test(self):
    
  29. in test/functional/p2p_compactblocks_blocksonly.py:7 in 217a80d915 outdated
       0 | @@ -0,0 +1,100 @@
       1 | +#!/usr/bin/env python3
       2 | +# Copyright (c) 2019-2020 The Bitcoin Core developers
       3 | +# Distributed under the MIT software license, see the accompanying
       4 | +# file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5 | +"""Test p2p blocksonly mode & compact block relay"""
       6 | +
       7 | +from test_framework.test_framework import BitcoinTestFramework
    


    jnewbery commented at 3:40 PM on August 9, 2021:

    Please sort imports :slightly_smiling_face:

  30. in test/functional/p2p_compactblocks_blocksonly.py:83 in 217a80d915 outdated
      78 | +
      79 | +        # A normal node participating in transaction relay should request high
      80 | +        # bandwidth mode upon receiving a new valid block at the tip.
      81 | +        p2p_conn_node1.send_and_ping(msg_block(block0))
      82 | +        assert_equal(int(self.nodes[1].getbestblockhash(), 16), block0.sha256)
      83 | +        assert_equal(p2p_conn_node1.message_count['sendcmpct'], 3)
    


    jnewbery commented at 3:47 PM on August 9, 2021:

    This assumes that the node will send sendcmpct synchronously and before responding to the ping above. That's true right now, since MaybeSetPeerAsAnnouncingHeaderAndIDs is called in the synchronous BlockChecked() validation interface callback, but that may change in the future. (I'd like to change this to remove the synchronous BlockChecked callback).

    A less racy way to do this would be to use wait_until() so that the test doesn't immediately fail if the sendcmpct message isn't received before the pong.

  31. in test/functional/p2p_compactblocks_blocksonly.py:68 in 217a80d915 outdated
      63 | +        #                              node2
      64 | +        #
      65 | +        # node2 produces blocks which get passed to node0 and node1
      66 | +        # through the respective p2p connections.
      67 | +
      68 | +        self.log.info("Part 1: Test that blocksonly nodes do not request high bandwidth mode.")
    


    jnewbery commented at 3:52 PM on August 9, 2021:

    No need for "Part 1" or "Part 2" in these logs (tests have a habit of being rearranged, so these logs will fall out of date)

  32. jnewbery commented at 3:53 PM on August 9, 2021: member

    A few small suggestions on the new test.

  33. dergoegge force-pushed on Aug 9, 2021
  34. dergoegge commented at 8:45 PM on August 9, 2021: member

    Thanks for the review @jnewbery! I took all your suggestions.

    I also added two new test cases: One to test that on regular low bandwidth connections (no blocksonly nodes involved) getdata(CMPCT) is still sent. 8b1b308555382ea1b7390615371ecaa066c4af3b And one to test that blocksonly nodes still serve compact blocks in hb and lb mode. 8c4159aeccdad58a71ff61b3e21b26a4f24a6029

  35. in test/functional/p2p_compactblocks_blocksonly.py:68 in 8c4159aecc outdated
      63 | +        #   p2p_conn_blocksonly ---> node0
      64 | +        #   p2p_conn_high_bw    ---> node1
      65 | +        #   p2p_conn_low_bw     ---> node3
      66 | +        #   node2 (no connections)
      67 | +        #
      68 | +        # node2 produces blocks which get passed to the reset of the nodes
    


    jnewbery commented at 2:09 PM on August 10, 2021:
            # node2 produces blocks which get passed to the rest of the nodes
    
  36. in test/functional/p2p_compactblocks_blocksonly.py:44 in 8c4159aecc outdated
      39 | +        return block
      40 | +
      41 | +    def run_test(self):
      42 | +        # Nodes will only request hb compact blocks mode when they're out of IBD
      43 | +        for i in range(3):
      44 | +            assert not self.nodes[i].getblockchaininfo()['initialblockdownload']
    


    jnewbery commented at 2:18 PM on August 10, 2021:

    Should be 4 now that there are 4 nodes? Or maybe even better:

            for node in self.nodes:
                assert not node.getblockchaininfo()['initialblockdownload']
    
  37. in test/functional/p2p_compactblocks_blocksonly.py:54 in 8c4159aecc outdated
      49 | +        assert_equal(p2p_conn_blocksonly.message_count['sendcmpct'], 2)
      50 | +        assert_equal(p2p_conn_high_bw.message_count['sendcmpct'], 2)
      51 | +        assert_equal(p2p_conn_low_bw.message_count['sendcmpct'], 2)
      52 | +        p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=False, version=2))
      53 | +        p2p_conn_high_bw.send_and_ping(msg_sendcmpct(announce=False, version=2))
      54 | +        p2p_conn_low_bw.send_and_ping(msg_sendcmpct(announce=False, version=2))
    


    jnewbery commented at 2:49 PM on August 10, 2021:
            for conn in [p2p_conn_blocksonly, p2p_conn_high_bw, p2p_conn_low_bw]:
                assert_equal(conn.message_count['sendcmpct'], 2)
                conn.send_and_ping(msg_sendcmpct(announce=False, version=2))
    
  38. in test/functional/p2p_compactblocks_blocksonly.py:116 in 8c4159aecc outdated
     111 | +
     112 | +        self.log.info("Test that blocksonly nodes still serve compact blocks.")
     113 | +
     114 | +        def test_for_cmpctblock(block):
     115 | +            def test():
     116 | +                sha256 = p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash()
    


    jnewbery commented at 2:52 PM on August 10, 2021:

    If you separate the test for existence of the cmpctblock message from the test of its hash, you don't need the sync_send_with_ping() call:

                    if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
                        return False
                    sha256 = p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash()
    

    I'd also suggest using a lambda so that you don't need to have a named function returning the inner function, and also parametrizing the connection. Full diff:

             self.log.info("Test that blocksonly nodes still serve compact blocks.")
     
    -        def test_for_cmpctblock(block):
    -            def test():
    -                sha256 = p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash()
    -                return sha256 == block.sha256
    -            return test
    +        def test_for_cmpctblock(conn, block):
    +            if 'cmpctblock' not in conn.last_message:
    +                return False
    +            return conn.last_message['cmpctblock'].header_and_shortids.header.rehash() == block.sha256
     
             p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
    -        p2p_conn_blocksonly.sync_send_with_ping()
    -        p2p_conn_blocksonly.wait_until(test_for_cmpctblock(block0))
    +        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(p2p_conn_blocksonly, block0))
     
             # Request high bandwidth mode from node0
             p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=True, version=2))
    @@ -127,7 +123,7 @@ class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
             block2 = self.build_block_on_tip()
             self.nodes[0].submitblock(block1.serialize().hex())
             self.nodes[0].submitblock(block2.serialize().hex())
    -        p2p_conn_blocksonly.wait_until(test_for_cmpctblock(block2))
    +        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(p2p_conn_blocksonly, block2))
    
  39. jnewbery commented at 2:55 PM on August 10, 2021: member

    utACK 8c4159aeccdad58a71ff61b3e21b26a4f24a6029

    Thanks for being so responsive to review. I have a few more comments for your consideration inline. Nothing blocking.

  40. jonatack commented at 5:13 PM on August 10, 2021: member

    Started looking at this PR. Rebased to current master, debug build is clean, <strike>but the new test times out for me locally on every run (out of five).</strike>

    <details><summary>test output</summary><p>

    $ test/functional/p2p_compactblocks_blocksonly.py 
    2021-08-10T15:36:10.388000Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_ypwy_8d2
    2021-08-10T15:36:11.582000Z TestFramework (INFO): Test that blocksonly nodes do not request high bandwidth mode.
    2021-08-10T15:37:11.677000Z TestFramework.utils (ERROR): wait_until() failed. Predicate: ''''
            def test_function():
                if check_connected:
                    assert self.is_connected
                return test_function_in()
    '''
    2021-08-10T15:37:11.677000Z TestFramework (ERROR): Assertion failed
    Traceback (most recent call last):
      File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/test_framework.py", line 131, in main
        self.run_test()
      File "/home/jon/projects/bitcoin/bitcoin/test/functional/p2p_compactblocks_blocksonly.py", line 79, in run_test
        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['sendcmpct'] == 2)
      File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/p2p.py", line 451, in wait_until
        wait_until_helper(test_function, timeout=timeout, lock=p2p_lock, timeout_factor=self.timeout_factor)
      File "/home/jon/projects/bitcoin/bitcoin/test/functional/test_framework/util.py", line 256, in wait_until_helper
        raise AssertionError("Predicate {} not true after {} seconds".format(predicate_source, timeout))
    AssertionError: Predicate ''''
            def test_function():
                if check_connected:
                    assert self.is_connected
                return test_function_in()
    ''' not true after 60.0 seconds
    2021-08-10T15:37:11.729000Z TestFramework (INFO): Stopping nodes
    2021-08-10T15:37:11.891000Z TestFramework (WARNING): Not cleaning up dir /tmp/bitcoin_func_test_ypwy_8d2
    2021-08-10T15:37:11.892000Z TestFramework (ERROR): Test failed. Test logging available at /tmp/bitcoin_func_test_ypwy_8d2/test_framework.log
    2021-08-10T15:37:11.894000Z TestFramework (ERROR): 
    2021-08-10T15:37:11.896000Z TestFramework (ERROR): Hint: Call /home/jon/projects/bitcoin/bitcoin/test/functional/combine_logs.py '/tmp/bitcoin_func_test_ypwy_8d2' to consolidate all logs
    2021-08-10T15:37:11.896000Z TestFramework (ERROR): 
    2021-08-10T15:37:11.897000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
    2021-08-10T15:37:11.897000Z TestFramework (ERROR): https://github.com/bitcoin/bitcoin/issues
    2021-08-10T15:37:11.897000Z TestFramework (ERROR): 
    

    </p></details>

  41. amitiuttarwar commented at 8:01 PM on August 10, 2021: contributor

    @jonatack that's odd. I tried rebasing on master & the tests are passing 🤔

    And based on the logs you posted, I don't see why rebasing would cause a difference. The test file introduced is new, and I don't believe anything has changed recently around compact block p2p messages. Do you have any more info you can offer?

  42. jonatack commented at 8:13 PM on August 10, 2021: member

    It's late but I'll try again tomorrow (and do a review, looks like an interesting PR). I rebased and did a debug build with clang 13 on debian before running the test. Maybe it was spurious.

  43. jonatack commented at 9:06 PM on August 10, 2021: member

    Ok, the test runs fine. Here is what happened: I forgot about the footgun on master that currently doesn't build when DEBUG_ADDRMAN is defined. I built with my bash alias that does a debug build with that, the build failed, I didn't notice, and so I was running the test on the wrong build. I just verified that the failure I reported occurs on master. Apologies for the noise! Will review tomorrow.

  44. dergoegge force-pushed on Aug 10, 2021
  45. dergoegge commented at 9:30 PM on August 10, 2021: member

    @jnewbery great suggestions! Incorporated them all again.

    nocmpct_blocksonly_0 -> nocmpct_blocksonly_1

    <details> <summary>git range-diff nocmpct_blocksonly_0...nocmpct_blocksonly_1</summary>

    1:  5a29943a9 ! 1:  e58cfb118 [test] Test that blocksonly nodes do not request high bandwidth mode.
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +
         +    def run_test(self):
         +        # Nodes will only request hb compact blocks mode when they're out of IBD
        -+        for i in range(3):
        -+            assert not self.nodes[i].getblockchaininfo()['initialblockdownload']
        ++        for node in self.nodes:
        ++            assert not node.getblockchaininfo()['initialblockdownload']
         +
         +        p2p_conn_blocksonly = self.nodes[0].add_p2p_connection(P2PInterface())
         +        p2p_conn_high_bw = self.nodes[1].add_p2p_connection(P2PInterface())
        -+        assert_equal(p2p_conn_blocksonly.message_count['sendcmpct'], 2)
        -+        assert_equal(p2p_conn_high_bw.message_count['sendcmpct'], 2)
        -+        p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=False, version=2))
        -+        p2p_conn_high_bw.send_and_ping(msg_sendcmpct(announce=False, version=2))
        ++        for conn in [p2p_conn_blocksonly, p2p_conn_high_bw]:
        ++            assert_equal(conn.message_count['sendcmpct'], 2)
        ++            conn.send_and_ping(msg_sendcmpct(announce=False, version=2))
         +
         +        # Nodes:
         +        #   0 -> blocksonly
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +        #   p2p_conn_high_bw    ---> node1
         +        #   node2 (no connections)
         +        #
        -+        # node2 produces blocks which get passed to the reset of the nodes
        ++        # node2 produces blocks which get passed to the rest of the nodes
         +        # through the respective p2p connections.
         +
         +        self.log.info("Test that blocksonly nodes do not request high bandwidth mode.")
    2:  beeea3fbc = 2:  c99978d94 [test] Test that blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
    3:  8b1b30855 ! 3:  770c5f1a4 [test] Test that getdata(CMPCT) is still sent on regular low bandwdith connections.
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
    
                  p2p_conn_blocksonly = self.nodes[0].add_p2p_connection(P2PInterface())
                  p2p_conn_high_bw = self.nodes[1].add_p2p_connection(P2PInterface())
        +-        for conn in [p2p_conn_blocksonly, p2p_conn_high_bw]:
         +        p2p_conn_low_bw = self.nodes[3].add_p2p_connection(P2PInterface())
        -         assert_equal(p2p_conn_blocksonly.message_count['sendcmpct'], 2)
        -         assert_equal(p2p_conn_high_bw.message_count['sendcmpct'], 2)
        -+        assert_equal(p2p_conn_low_bw.message_count['sendcmpct'], 2)
        -         p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=False, version=2))
        -         p2p_conn_high_bw.send_and_ping(msg_sendcmpct(announce=False, version=2))
        -+        p2p_conn_low_bw.send_and_ping(msg_sendcmpct(announce=False, version=2))
        ++        for conn in [p2p_conn_blocksonly, p2p_conn_high_bw, p2p_conn_low_bw]:
        +             assert_equal(conn.message_count['sendcmpct'], 2)
        +             conn.send_and_ping(msg_sendcmpct(announce=False, version=2))
    
        -         # Nodes:
        +@@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
                  #   0 -> blocksonly
                  #   1 -> high bandwidth
                  #   2 -> miner
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        #   p2p_conn_low_bw     ---> node3
                  #   node2 (no connections)
                  #
        -         # node2 produces blocks which get passed to the reset of the nodes
        +         # node2 produces blocks which get passed to the rest of the nodes
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
                  p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
                  assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
    4:  8c4159aec ! 4:  e21f2e4f0 [test] Test that blocksonly nodes still serve compact blocks.
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        self.log.info("Test that blocksonly nodes still serve compact blocks.")
         +
         +        def test_for_cmpctblock(block):
        -+            def test():
        -+                sha256 = p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash()
        -+                return sha256 == block.sha256
        -+            return test
        ++            if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
        ++                return False
        ++            return p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash() == block.sha256
         +
         +        p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
        -+        p2p_conn_blocksonly.sync_send_with_ping()
        -+        p2p_conn_blocksonly.wait_until(test_for_cmpctblock(block0))
        ++        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block0))
         +
         +        # Request high bandwidth mode from node0
         +        p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=True, version=2))
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        block2 = self.build_block_on_tip()
         +        self.nodes[0].submitblock(block1.serialize().hex())
         +        self.nodes[0].submitblock(block2.serialize().hex())
        -+        p2p_conn_blocksonly.wait_until(test_for_cmpctblock(block2))
        ++        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block2))
         +
          if __name__ == '__main__':
              P2PCompactBlocksBlocksOnly().main()
    

    </details>

  46. jnewbery commented at 9:46 AM on August 11, 2021: member

    utACK e21f2e4f04c5f15eccac529c6e8c59aba5283351

  47. in test/functional/p2p_compactblocks_blocksonly.py:2 in e21f2e4f04 outdated
       0 | @@ -0,0 +1,128 @@
       1 | +#!/usr/bin/env python3
       2 | +# Copyright (c) 2019-2020 The Bitcoin Core developers
    


    jonatack commented at 3:44 PM on August 11, 2021:

    e58cfb11875728d90716577f34482ddddb898cdb pico-nit, unless this test has been under development since 2019 (maybe it has!)

    # Copyright (c) 2021-2021 The Bitcoin Core developers
    

    (yes, there is an automated update script run occasionally but IDK if it's smart enough to set the start year)

  48. in test/functional/p2p_compactblocks_blocksonly.py:27 in e21f2e4f04 outdated
      23 | +
      24 | +
      25 | +class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
      26 | +    def set_test_params(self):
      27 | +        self.num_nodes = 4
      28 | +        self.extra_args = [["-blocksonly"], [], [], []]
    


    jonatack commented at 3:50 PM on August 11, 2021:

    e58cfb11 suggestion stolen from review of #22651, feel free to ignore

    -        self.num_nodes = 4
             self.extra_args = [["-blocksonly"], [], [], []]
    +        self.num_nodes = len(self.extra_args)
    

    jnewbery commented at 1:35 PM on August 16, 2021:

    I don't think this is an improvement. Yes, it means that you don't need to change this line if the number of nodes in the test changes, but on the other hand I think it's very useful for people reading the code to be able to see at a glance how many nodes are used in the test. Making this a len(list_of_some_length) makes it less readable.


    jonatack commented at 1:42 PM on August 16, 2021:

    That's fair.

  49. in test/functional/p2p_compactblocks_blocksonly.py:65 in e21f2e4f04 outdated
      60 | +        #   p2p_conn_blocksonly ---> node0
      61 | +        #   p2p_conn_high_bw    ---> node1
      62 | +        #   p2p_conn_low_bw     ---> node3
      63 | +        #   node2 (no connections)
      64 | +        #
      65 | +        # node2 produces blocks which get passed to the rest of the nodes
    


    jonatack commented at 4:01 PM on August 11, 2021:

    e58cfb11875728d90716577f34482ddddb898cdb

            # node2 produces blocks that are passed to the rest of the nodes
    
  50. in test/functional/p2p_compactblocks_blocksonly.py:68 in e21f2e4f04 outdated
      63 | +        #   node2 (no connections)
      64 | +        #
      65 | +        # node2 produces blocks which get passed to the rest of the nodes
      66 | +        # through the respective p2p connections.
      67 | +
      68 | +        self.log.info("Test that blocksonly nodes do not request high bandwidth mode.")
    


    jonatack commented at 4:10 PM on August 11, 2021:
            self.log.info("Test -blocksonly nodes do not select peers for BIP152 high bandwidth mode")
    
  51. in test/functional/p2p_compactblocks_blocksonly.py:91 in e21f2e4f04 outdated
      86 | +        # Don't send a block from the p2p_conn_low_bw so the bitcoind node
      87 | +        # doesn't select it for high bw relay.
      88 | +        self.nodes[3].submitblock(block0.serialize().hex())
      89 | +
      90 | +        self.log.info("Test that blocksonly nodes send getdata(BLOCK) instead"
      91 | +                      "of getdata(CMPCT) in low bandwidth mode.")
    


    jonatack commented at 4:11 PM on August 11, 2021:

    c99978d9 missing space "insteadof" + other suggestions while here

    -        self.log.info("Test that blocksonly nodes send getdata(BLOCK) instead"
    -                      "of getdata(CMPCT) in low bandwidth mode.")
    +        self.log.info("Test -blocksonly nodes send getdata(BLOCK) instead"
    +                      " of getdata(CMPCT) in BIP152 low bandwidth mode")
    
  52. in test/functional/p2p_compactblocks_blocksonly.py:103 in e21f2e4f04 outdated
      98 | +
      99 | +        p2p_conn_high_bw.send_message(msg_headers(headers=[CBlockHeader(block1)]))
     100 | +        p2p_conn_high_bw.sync_send_with_ping()
     101 | +        assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
     102 | +
     103 | +        self.log.info("Test that getdata(CMPCT) is still sent on regular low bandwdith connections.")
    


    jonatack commented at 4:12 PM on August 11, 2021:

    770c5f1a s/bandwdith/bandwidth/ + minor suggestions while here

            self.log.info("Test getdata(CMPCT) is still sent on BIP152 low bandwidth connections")
    
  53. in test/functional/p2p_compactblocks_blocksonly.py:109 in e21f2e4f04 outdated
     104 | +
     105 | +        p2p_conn_low_bw.send_and_ping(msg_headers(headers=[CBlockHeader(block1)]))
     106 | +        p2p_conn_low_bw.sync_with_ping()
     107 | +        assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
     108 | +
     109 | +        self.log.info("Test that blocksonly nodes still serve compact blocks.")
    


    jonatack commented at 4:12 PM on August 11, 2021:
            self.log.info("Test -blocksonly nodes still serve compact blocks")
    
  54. in test/functional/p2p_compactblocks_blocksonly.py:102 in e21f2e4f04 outdated
      96 | +        p2p_conn_blocksonly.sync_send_with_ping()
      97 | +        assert_equal(p2p_conn_blocksonly.last_message['getdata'].inv, [CInv(MSG_BLOCK | MSG_WITNESS_FLAG, block1.sha256)])
      98 | +
      99 | +        p2p_conn_high_bw.send_message(msg_headers(headers=[CBlockHeader(block1)]))
     100 | +        p2p_conn_high_bw.sync_send_with_ping()
     101 | +        assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
    


    jonatack commented at 4:20 PM on August 11, 2021:

    c99978d added the low bandwidth node as a sanity check

    +
    +        p2p_conn_low_bw.send_message(msg_headers(headers=[CBlockHeader(block1)]))
    +        p2p_conn_low_bw.sync_send_with_ping()
    +        assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
    
  55. in test/functional/p2p_compactblocks_blocksonly.py:86 in e21f2e4f04 outdated
      81 | +        p2p_conn_high_bw.send_and_ping(msg_block(block0))
      82 | +        assert_equal(int(self.nodes[1].getbestblockhash(), 16), block0.sha256)
      83 | +        p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
      84 | +        assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
      85 | +
      86 | +        # Don't send a block from the p2p_conn_low_bw so the bitcoind node
    


    jonatack commented at 5:17 PM on August 11, 2021:

    770c5f1a "bitcoind node"...which one?

  56. in test/functional/p2p_compactblocks_blocksonly.py:86 in e21f2e4f04 outdated
      80 | +        # bandwidth mode upon receiving a new valid block at the tip.
      81 | +        p2p_conn_high_bw.send_and_ping(msg_block(block0))
      82 | +        assert_equal(int(self.nodes[1].getbestblockhash(), 16), block0.sha256)
      83 | +        p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
      84 | +        assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
      85 | +
    


    jonatack commented at 5:20 PM on August 11, 2021:

    e58cfb11 added the low bandwidth node as a sanity check

    +
    +        p2p_conn_low_bw.send_and_ping(msg_block(block0))
    +        assert_equal(int(self.nodes[1].getbestblockhash(), 16), block0.sha256)
    +        p2p_conn_low_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
    +        assert_equal(p2p_conn_low_bw.last_message['sendcmpct'].announce, True)
    
  57. in test/functional/p2p_compactblocks_blocksonly.py:119 in e21f2e4f04 outdated
     114 | +            return p2p_conn_blocksonly.last_message['cmpctblock'].header_and_shortids.header.rehash() == block.sha256
     115 | +
     116 | +        p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
     117 | +        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block0))
     118 | +
     119 | +        # Request high bandwidth mode from node0
    


    jonatack commented at 5:24 PM on August 11, 2021:

    e21f2e4

            # Request high bandwidth mode from the -blocksonly node
    
  58. in test/functional/p2p_compactblocks_blocksonly.py:80 in e21f2e4f04 outdated
      75 | +        assert_equal(int(self.nodes[0].getbestblockhash(), 16), block0.sha256)
      76 | +        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['sendcmpct'] == 2)
      77 | +        assert_equal(p2p_conn_blocksonly.last_message['sendcmpct'].announce, False)
      78 | +
      79 | +        # A normal node participating in transaction relay should request high
      80 | +        # bandwidth mode upon receiving a new valid block at the tip.
    


    jonatack commented at 5:37 PM on August 11, 2021:

    e58cfb11875728d90716577f34482ddddb898cdb in general, ISTM mentioning BIP152 makes "high/low bandwidth mode" more clear

    -        # A normal node participating in transaction relay should request high
    -        # bandwidth mode upon receiving a new valid block at the tip.
    +        # A normal node participating in transaction relay should request BIP152
    +        # high bandwidth mode upon receiving a new valid block at the tip.
    
  59. in test/functional/p2p_compactblocks_blocksonly.py:72 in e21f2e4f04 outdated
      67 | +
      68 | +        self.log.info("Test that blocksonly nodes do not request high bandwidth mode.")
      69 | +
      70 | +        block0 = self.build_block_on_tip()
      71 | +
      72 | +        # A blocksonly node should not request high bandwidth mode upon
    


    jonatack commented at 5:38 PM on August 11, 2021:

    e58cfb11875728d90716577f34482ddddb898cdb (micro-nit in general): blocksonly -> -blocksonly (or) blocks-only, the former might make clear for newer people that it is a config option and the latter describes the state clearly

  60. in src/net_processing.cpp:888 in e21f2e4f04 outdated
     830 | @@ -831,6 +831,12 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
     831 |  void PeerManagerImpl::MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid)
     832 |  {
     833 |      AssertLockHeld(cs_main);
     834 | +
     835 | +    // Never request high-bandwidth mode from peers if we're blocks-only. Our
    


    jonatack commented at 5:52 PM on August 11, 2021:

    6dfee13 in general, ISTM that mentioning BIP152 makes "high/low bandwidth mode" more clear, especially for newer people

        // Never request BIP152 high-bandwidth mode from peers if we're blocks-only. Our
    

    dergoegge commented at 5:03 PM on August 13, 2021:

    will do this in a follow up PR.

  61. in src/net_processing.cpp:2174 in e21f2e4f04 outdated
    2121 | @@ -2116,7 +2122,11 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
    2122 |                              pindexLast->GetBlockHash().ToString(), pindexLast->nHeight);
    2123 |                  }
    2124 |                  if (vGetData.size() > 0) {
    2125 | -                    if (nodestate->fSupportsDesiredCmpctVersion && vGetData.size() == 1 && mapBlocksInFlight.size() == 1 && pindexLast->pprev->IsValid(BLOCK_VALID_CHAIN)) {
    2126 | +                    if (!m_ignore_incoming_txs &&
    


    jonatack commented at 5:53 PM on August 11, 2021:

    6dfee13f650521f7542df0926aff01af9ac6a328 Perhaps add a comment here as well (feel free to ignore).


    dergoegge commented at 5:03 PM on August 13, 2021:

    will do this in a follow up PR.

  62. jonatack commented at 6:01 PM on August 11, 2021: member

    Code review ACK e21f2e4f04c5f15eccac529c6e8c59aba5283351 modulo some minor fixups

    Thanks for adding the tests! Verified that they fail as expected on master :)

    Consider documenting this change in behavior with a release note?

    Feel free to ignore the non-fixup suggestions below. Happy to re-ACK if you update.

  63. jonatack commented at 9:09 AM on August 12, 2021: member

    Consider also updating doc/reduce-traffic.md regarding the effects of setting -blocksonly (maybe also in the Memory Pool section of doc/reduce-memory.md).

  64. dergoegge force-pushed on Aug 13, 2021
  65. dergoegge commented at 4:56 PM on August 13, 2021: member

    @jonatack Thanks for the review! I took most of your suggestions.

    I did not modify 6dfee13f650521f7542df0926aff01af9ac6a328 because i don't want to invalidate the utACKs that this commit has already gotten. I will make a follow up PR for those suggestions as well as the other doc changes (Release note, doc/reduce-traffic.md).

    nocmpct_blocksonly_1 -> nocmpct_blocksonly_2

    <details> <summary>git range-diff nocmpct_blocksonly_1...nocmpct_blocksonly_2</summary>

    1:  e58cfb118 ! 1:  1bd2f889c [test] Test that blocksonly nodes do not request high bandwidth mode.
        @@ Metadata
         Author: Niklas Gögge <n.goeggi@gmail.com>
         
          ## Commit message ##
        -    [test] Test that blocksonly nodes do not request high bandwidth mode.
        +    [test] Test that -blocksonly nodes do not request high bandwidth mode.
         
             Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
         
          ## test/functional/p2p_compactblocks_blocksonly.py (new) ##
         @@
         +#!/usr/bin/env python3
        -+# Copyright (c) 2019-2020 The Bitcoin Core developers
        ++# Copyright (c) 2021-2021 The Bitcoin Core developers
         +# Distributed under the MIT software license, see the accompanying
         +# file COPYING or http://www.opensource.org/licenses/mit-license.php.
         +"""Test that a node in blocksonly mode does not request compact blocks."""
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +
         +class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
         +    def set_test_params(self):
        -+        self.num_nodes = 3
         +        self.extra_args = [["-blocksonly"], [], []]
        ++        self.num_nodes = len(self.extra_args)
         +
         +    def setup_network(self):
         +        self.setup_nodes()
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +        #   p2p_conn_high_bw    ---> node1
         +        #   node2 (no connections)
         +        #
        -+        # node2 produces blocks which get passed to the rest of the nodes
        ++        # node2 produces blocks that are passed to the rest of the nodes
         +        # through the respective p2p connections.
         +
        -+        self.log.info("Test that blocksonly nodes do not request high bandwidth mode.")
        ++        self.log.info("Test that -blocksonly nodes do not select peers for BIP 152 high bandwidth mode.")
         +
         +        block0 = self.build_block_on_tip()
         +
        -+        # A blocksonly node should not request high bandwidth mode upon
        ++        # A -blocksonly node should not request BIP152 high bandwidth mode upon
         +        # receiving a new valid block at the tip.
         +        p2p_conn_blocksonly.send_and_ping(msg_block(block0))
         +        assert_equal(int(self.nodes[0].getbestblockhash(), 16), block0.sha256)
         +        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['sendcmpct'] == 2)
         +        assert_equal(p2p_conn_blocksonly.last_message['sendcmpct'].announce, False)
         +
        -+        # A normal node participating in transaction relay should request high
        -+        # bandwidth mode upon receiving a new valid block at the tip.
        ++        # A normal node participating in transaction relay should request BIP152
        ++        # high bandwidth mode upon receiving a new valid block at the tip.
         +        p2p_conn_high_bw.send_and_ping(msg_block(block0))
         +        assert_equal(int(self.nodes[1].getbestblockhash(), 16), block0.sha256)
         +        p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
    2:  c99978d94 ! 2:  abe3c5cf7 [test] Test that blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
        @@ Metadata
         Author: Niklas Gögge <n.goeggi@gmail.com>
         
          ## Commit message ##
        -    [test] Test that blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
        +    [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
         
             Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
         
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
                  p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
                  assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
          
        -+        self.log.info("Test that blocksonly nodes send getdata(BLOCK) instead"
        -+                      "of getdata(CMPCT) in low bandwidth mode.")
        ++        self.log.info("Test that -blocksonly nodes send getdata(BLOCK) instead"
        ++                      " of getdata(CMPCT) in BIP152 low bandwidth mode.")
         +
         +        block1 = self.build_block_on_tip()
         +
    3:  770c5f1a4 ! 3:  c652e187e [test] Test that getdata(CMPCT) is still sent on regular low bandwdith connections.
        @@ Metadata
         Author: Niklas Gögge <n.goeggi@gmail.com>
         
          ## Commit message ##
        -    [test] Test that getdata(CMPCT) is still sent on regular low bandwdith connections.
        +    [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
         
             Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
         
        @@ test/functional/p2p_compactblocks_blocksonly.py: from test_framework.util import
          
          class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
              def set_test_params(self):
        --        self.num_nodes = 3
         -        self.extra_args = [["-blocksonly"], [], []]
        -+        self.num_nodes = 4
         +        self.extra_args = [["-blocksonly"], [], [], []]
        +         self.num_nodes = len(self.extra_args)
          
              def setup_network(self):
        -         self.setup_nodes()
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
          
                  p2p_conn_blocksonly = self.nodes[0].add_p2p_connection(P2PInterface())
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        #   p2p_conn_low_bw     ---> node3
                  #   node2 (no connections)
                  #
        -         # node2 produces blocks which get passed to the rest of the nodes
        +         # node2 produces blocks that are passed to the rest of the nodes
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
                  p2p_conn_high_bw.wait_until(lambda: p2p_conn_high_bw.message_count['sendcmpct'] == 3)
                  assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
          
        -+        # Don't send a block from the p2p_conn_low_bw so the bitcoind node
        -+        # doesn't select it for high bw relay.
        ++        # Don't send a block from the p2p_conn_low_bw so the low bandwidth node
        ++        # doesn't select it for BIP152 high bandwidth relay.
         +        self.nodes[3].submitblock(block0.serialize().hex())
         +
        -         self.log.info("Test that blocksonly nodes send getdata(BLOCK) instead"
        -                       "of getdata(CMPCT) in low bandwidth mode.")
        +         self.log.info("Test that -blocksonly nodes send getdata(BLOCK) instead"
        +                       " of getdata(CMPCT) in BIP152 low bandwidth mode.")
          
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
                  p2p_conn_high_bw.sync_send_with_ping()
                  assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
          
        -+        self.log.info("Test that getdata(CMPCT) is still sent on regular low bandwdith connections.")
        ++        self.log.info("Test that getdata(CMPCT) is still sent on BIP152 low bandwidth connections"
        ++                      " when no -blocksonly nodes are involved.")
         +
         +        p2p_conn_low_bw.send_and_ping(msg_headers(headers=[CBlockHeader(block1)]))
         +        p2p_conn_low_bw.sync_with_ping()
    4:  e21f2e4f0 ! 4:  ae54485c4 [test] Test that blocksonly nodes still serve compact blocks.
        @@ Metadata
         Author: Niklas Gögge <n.goeggi@gmail.com>
         
          ## Commit message ##
        -    [test] Test that blocksonly nodes still serve compact blocks.
        +    [test] Test that -blocksonly nodes still serve compact blocks.
         
          ## test/functional/p2p_compactblocks_blocksonly.py ##
         @@ test/functional/p2p_compactblocks_blocksonly.py: from test_framework.messages import (
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
                  p2p_conn_low_bw.sync_with_ping()
                  assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
          
        -+        self.log.info("Test that blocksonly nodes still serve compact blocks.")
        ++        self.log.info("Test that -blocksonly nodes still serve compact blocks.")
         +
         +        def test_for_cmpctblock(block):
         +            if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        p2p_conn_blocksonly.send_message(msg_getdata([CInv(MSG_CMPCT_BLOCK, block0.sha256)]))
         +        p2p_conn_blocksonly.wait_until(lambda: test_for_cmpctblock(block0))
         +
        -+        # Request high bandwidth mode from node0
        ++        # Request BIP152 high bandwidth mode from the -blocksonly node.
         +        p2p_conn_blocksonly.send_and_ping(msg_sendcmpct(announce=True, version=2))
         +
         +        block2 = self.build_block_on_tip()
    

    </details>

  66. in test/functional/p2p_compactblocks_blocksonly.py:68 in ae54485c40 outdated
      63 | +        #   node2 (no connections)
      64 | +        #
      65 | +        # node2 produces blocks that are passed to the rest of the nodes
      66 | +        # through the respective p2p connections.
      67 | +
      68 | +        self.log.info("Test that -blocksonly nodes do not select peers for BIP 152 high bandwidth mode.")
    


    jonatack commented at 9:47 AM on August 16, 2021:

    (micro style nits only if you retouch now or later, feel free to ignore)

    • s/BIP 152/BIP152/ on this one line (as elsewhere)
    • in general the test logging doesn't use EOL full stops/periods
    • in general s/Test that/Test/ in the test logging, as all the that's are needlessly verbose and add horizontal space (just my opinion though)

    dergoegge commented at 11:30 AM on September 4, 2021:

    I disagree on the third point because omitting the that does not sound like correct english to me. (i am not a native english speaker so i might be totally wrong) Also a lot of the other tests also have the that so i kept it here.

  67. jonatack commented at 10:05 AM on August 16, 2021: member

    Code review re-ACK ae54485c406bcf88c94450ffceabf709d5a18379 per git diff e21f2e4 ae54485, only changes since last review are minor (mostly documentation) improvements in the functional test; rebased to master, debug build clean, ran test a few times, including with vagrind

    test/functional/p2p_compactblocks_blocksonly.py --valgrind failed for me locally on the first run (AssertionError: [node 0] Unable to connect to bitcoind after 60s) during test setup, but succeeded on the second and third runs.

    Thanks for updating!

  68. jonatack commented at 10:43 AM on August 16, 2021: member

    I did not modify 6dfee13 because i don't want to invalidate the utACKs that this commit has already gotten

    Your mileage may vary. In review feedback a year ago it was suggested to me to not worry too much about invalidating ACKs and I ended up "invalidating" 7 ACKs on that pull, which was subsequently merged. Since then I no longer worry about it and AFAICT doing so doesn't seem to have slowed anything down. (Sharing a thought in general, not for this case!)

  69. jnewbery commented at 1:38 PM on August 16, 2021: member

    ACK ae54485c406bcf88c94450ffceabf709d5a18379

  70. in test/functional/p2p_compactblocks_blocksonly.py:33 in ae54485c40 outdated
      27 | +        self.extra_args = [["-blocksonly"], [], [], []]
      28 | +        self.num_nodes = len(self.extra_args)
      29 | +
      30 | +    def setup_network(self):
      31 | +        self.setup_nodes()
      32 | +        self.sync_all()
    


    rajarshimaitra commented at 5:55 AM on August 17, 2021:
            self.setup_nodes()
            # Start network with everyone disconnected
            self.sync_all()
    

    Not required, as its evident by definition. But wouldn't hurt having commented to specify we want an unconnected network topology. Also done in p2p_comapctblocks_hb.py.

  71. in test/functional/p2p_compactblocks_blocksonly.py:76 in ae54485c40 outdated
      71 | +
      72 | +        # A -blocksonly node should not request BIP152 high bandwidth mode upon
      73 | +        # receiving a new valid block at the tip.
      74 | +        p2p_conn_blocksonly.send_and_ping(msg_block(block0))
      75 | +        assert_equal(int(self.nodes[0].getbestblockhash(), 16), block0.sha256)
      76 | +        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['sendcmpct'] == 2)
    


    rajarshimaitra commented at 6:46 AM on August 17, 2021:

    It seems message_count['sendcmpct'] is already at 2 before reaching here. So the code isn't waiting for anything. Maybe we should wait for some other things that changes after previous step? Like block count or inv count?


    dergoegge commented at 11:30 AM on September 4, 2021:

    Changed it to wait for the expected block count and after that assert that the sendcmpct count is still 2.

  72. rajarshimaitra commented at 6:49 AM on August 17, 2021: contributor

    tACK https://github.com/bitcoin/bitcoin/pull/22340/commits/ae54485c406bcf88c94450ffceabf709d5a18379

    Stepped through the test, verified expected behaviors.

    Below are few comments inline, nothing blocking.

    Aside

    Taking this opportunity to mention some generic approaches I took for functional test reviews. Could be helpful for new review club folks:

    • Start python debugging and step through the *.py file.
    • The output will show at the start of the test, the temp directory where regtest nodes are created. - You can talk to them while you pause the python file, with bitcoin-cli -datadir=/tmp-filepath/node0/ <command>.
    • You can tail -f their debug.log and only activate the required logging(net, rpc, etc depending on the test you are trying) using bitcoin-cli, to see communications happening in each nodes. Verify they are occurring as expected.
    • If you want to print something from src/*.cpp, use LogPrintf() to print in the debug.log file, that you were already tailing.
    • Use python debug console to work with the python objects, call functions, see object attributes are updated as expected.
    • Try to identify edge cases by changing test variables and observing failures.
  73. dergoegge force-pushed on Sep 4, 2021
  74. dergoegge commented at 11:35 AM on September 4, 2021: member

    Thanks @rajarshimaitra and @jonatack for the reviews and advice!

    nocmpct_blocksonly_2 -> nocmpct_blocksonly_3

    <details> <summary>git range-diff nocmpct_blocksonly_2...nocmpct_blocksonly_3</summary>

    1:  1bd2f889c ! 1:  ac90610e1 [test] Test that -blocksonly nodes do not request high bandwidth mode.
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +
         +    def setup_network(self):
         +        self.setup_nodes()
        ++        # Start network with everyone disconnected
         +        self.sync_all()
         +
         +    def build_block_on_tip(self):
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +        # node2 produces blocks that are passed to the rest of the nodes
         +        # through the respective p2p connections.
         +
        -+        self.log.info("Test that -blocksonly nodes do not select peers for BIP 152 high bandwidth mode.")
        ++        self.log.info("Test that -blocksonly nodes do not select peers for BIP152 high bandwidth mode")
         +
         +        block0 = self.build_block_on_tip()
         +
         +        # A -blocksonly node should not request BIP152 high bandwidth mode upon
         +        # receiving a new valid block at the tip.
        -+        p2p_conn_blocksonly.send_and_ping(msg_block(block0))
        ++        p2p_conn_blocksonly.send_message(msg_block(block0))
        ++        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['block'] == 1)
         +        assert_equal(int(self.nodes[0].getbestblockhash(), 16), block0.sha256)
        -+        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['sendcmpct'] == 2)
        ++        assert_equal(p2p_conn_blocksonly.message_count['sendcmpct'], 2)
         +        assert_equal(p2p_conn_blocksonly.last_message['sendcmpct'].announce, False)
         +
         +        # A normal node participating in transaction relay should request BIP152
    2:  abe3c5cf7 ! 2:  90776a869 [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
                  assert_equal(p2p_conn_high_bw.last_message['sendcmpct'].announce, True)
          
         +        self.log.info("Test that -blocksonly nodes send getdata(BLOCK) instead"
        -+                      " of getdata(CMPCT) in BIP152 low bandwidth mode.")
        ++                      " of getdata(CMPCT) in BIP152 low bandwidth mode")
         +
         +        block1 = self.build_block_on_tip()
         +
    3:  c652e187e ! 3:  e38eb9288 [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
         +        self.nodes[3].submitblock(block0.serialize().hex())
         +
                  self.log.info("Test that -blocksonly nodes send getdata(BLOCK) instead"
        -                       " of getdata(CMPCT) in BIP152 low bandwidth mode.")
        +                       " of getdata(CMPCT) in BIP152 low bandwidth mode")
          
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
                  p2p_conn_high_bw.sync_send_with_ping()
                  assert_equal(p2p_conn_high_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
          
         +        self.log.info("Test that getdata(CMPCT) is still sent on BIP152 low bandwidth connections"
        -+                      " when no -blocksonly nodes are involved.")
        ++                      " when no -blocksonly nodes are involved")
         +
         +        p2p_conn_low_bw.send_and_ping(msg_headers(headers=[CBlockHeader(block1)]))
         +        p2p_conn_low_bw.sync_with_ping()
    4:  ae54485c4 ! 4:  f30eb1fe4 [test] Test that -blocksonly nodes still serve compact blocks.
        @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnl
                  p2p_conn_low_bw.sync_with_ping()
                  assert_equal(p2p_conn_low_bw.last_message['getdata'].inv, [CInv(MSG_CMPCT_BLOCK, block1.sha256)])
          
        -+        self.log.info("Test that -blocksonly nodes still serve compact blocks.")
        ++        self.log.info("Test that -blocksonly nodes still serve compact blocks")
         +
         +        def test_for_cmpctblock(block):
         +            if 'cmpctblock' not in p2p_conn_blocksonly.last_message:
    

    </details>

  75. naumenkogs commented at 7:15 AM on September 22, 2021: member

    ACK f30eb1fe4a62fd9c927ba57b2a549678bde3f3c7

  76. in test/functional/p2p_compactblocks_blocksonly.py:28 in f30eb1fe4a outdated
      23 | +
      24 | +
      25 | +class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
      26 | +    def set_test_params(self):
      27 | +        self.extra_args = [["-blocksonly"], [], [], []]
      28 | +        self.num_nodes = len(self.extra_args)
    


    jnewbery commented at 8:18 AM on September 22, 2021:

    I think this would be clearer if it was explicit about the number of nodes:

            self.num_nodes = 3
    

    Checking the number of test nodes is one of the first things I do when reading a functional test. It should be immediately obvious what the topology of the test is.

  77. in test/functional/p2p_compactblocks_blocksonly.py:76 in f30eb1fe4a outdated
      71 | +        block0 = self.build_block_on_tip()
      72 | +
      73 | +        # A -blocksonly node should not request BIP152 high bandwidth mode upon
      74 | +        # receiving a new valid block at the tip.
      75 | +        p2p_conn_blocksonly.send_message(msg_block(block0))
      76 | +        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['block'] == 1)
    


    jnewbery commented at 8:23 AM on September 22, 2021:

    This seems wrong. The message_count property is counting how many message of each type has been received from the bitcoind node since the start of the test. Here, you're sending a block message, and then waiting for the count of received block messages to be 1.

    I think here it'd be better to send_and_ping() the block message as you were before, and then use RPC to verify that the chain tip is as expected.


    dergoegge commented at 8:24 PM on September 22, 2021:

    You are right, thanks for catching this!

  78. dergoegge force-pushed on Sep 22, 2021
  79. dergoegge commented at 8:24 PM on September 22, 2021: member

    nocmpct_blocksonly_3 -> nocmpct_blocksonly_4

    <details> <summary>git range-diff nocmpct_blocksonly_3...nocmpct_blocksonly_4</summary>

    1:  ac90610e1 ! 1:  df6794e80 [test] Test that -blocksonly nodes do not request high bandwidth mode.
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
         +    def set_test_params(self):
         +        self.extra_args = [["-blocksonly"], [], []]
        -+        self.num_nodes = len(self.extra_args)
        ++        self.num_nodes = 3
         +
         +    def setup_network(self):
         +        self.setup_nodes()
        @@ test/functional/p2p_compactblocks_blocksonly.py (new)
         +
         +        # A -blocksonly node should not request BIP152 high bandwidth mode upon
         +        # receiving a new valid block at the tip.
        -+        p2p_conn_blocksonly.send_message(msg_block(block0))
        -+        p2p_conn_blocksonly.wait_until(lambda: p2p_conn_blocksonly.message_count['block'] == 1)
        ++        p2p_conn_blocksonly.send_and_ping(msg_block(block0))
         +        assert_equal(int(self.nodes[0].getbestblockhash(), 16), block0.sha256)
         +        assert_equal(p2p_conn_blocksonly.message_count['sendcmpct'], 2)
         +        assert_equal(p2p_conn_blocksonly.last_message['sendcmpct'].announce, False)
    2:  90776a869 = 2:  548115650 [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
    3:  e38eb9288 ! 3:  01db031b5 [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
        @@ test/functional/p2p_compactblocks_blocksonly.py: from test_framework.util import
          class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
              def set_test_params(self):
         -        self.extra_args = [["-blocksonly"], [], []]
        +-        self.num_nodes = 3
         +        self.extra_args = [["-blocksonly"], [], [], []]
        -         self.num_nodes = len(self.extra_args)
        ++        self.num_nodes = 4
    
              def setup_network(self):
        +         self.setup_nodes()
         @@ test/functional/p2p_compactblocks_blocksonly.py: class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
    
                  p2p_conn_blocksonly = self.nodes[0].add_p2p_connection(P2PInterface())
    4:  f30eb1fe4 = 4:  c24c52d51 [test] Test that -blocksonly nodes still serve compact blocks.
    

    </details>

  80. jnewbery commented at 10:13 AM on September 23, 2021: member

    Code review ACK c24c52d51cc8faaa79dc554c64ca6d1ee231f112

  81. naumenkogs commented at 12:00 PM on September 24, 2021: member

    ACK c24c52d

  82. [net processing] Dont request compact blocks in blocks-only mode 0dc8bf5b92
  83. [test] Test that -blocksonly nodes do not request high bandwidth mode.
    Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
    5bf6587457
  84. [test] Test that -blocksonly nodes do not send getdata(CMPCT) on a low bandwidth connection.
    Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
    5e231c116b
  85. [test] Test that getdata(CMPCT) is still sent on regular low bandwidth connections.
    Co-authored-by: Amiti Uttarwar <amiti@uttarwar.org>
    a79ad65fc2
  86. [test] Test that -blocksonly nodes still serve compact blocks. 18c5b23a0f
  87. dergoegge force-pushed on Sep 28, 2021
  88. dergoegge commented at 8:55 AM on September 29, 2021: member

    Rebased on latest master. @jnewbery @theStack @jonatack @naumenkogs @rajarshimaitra I would appreciate it if you folks could have another look and re-ACK since i think this is pretty close to being ready :)

  89. naumenkogs commented at 10:52 AM on September 29, 2021: member

    ACK 18c5b23a0f7adf9a08bcaa967ed800badf62d90a

  90. jnewbery commented at 4:18 PM on September 29, 2021: member

    reACK 18c5b23a0f

    Did the rebase myself and verified the same result.

  91. theStack approved
  92. theStack commented at 9:58 PM on September 30, 2021: member

    re-ACK 18c5b23a0f7adf9a08bcaa967ed800badf62d90a 🥛

    After my previous ACK (on a single commit with the changes in net_processing), the PR has been rebased and tests have been added. Those LGTM, the only place I found confusing is the assertion checking that the number of received sendcmpct messages on a peer from node after handshake is 2 initially, and not 1. I had to dig in the code to find out why:

    https://github.com/bitcoin/bitcoin/blob/571bb94dfb5047c9be8fcbae5dae71de7256b86c/src/net_processing.cpp#L2721-L2730

    Not a big deal, but if a follow-up PR is planned, probably a small comment could be added to the test explaining why 2 messages are expected (sendcmpct(0, 2) and sendcmpct(0, 1)).

  93. MarcoFalke referenced this in commit 4e1de1fc59 on Oct 1, 2021
  94. fanquake commented at 6:45 AM on October 1, 2021: member

    This has been merged.

  95. fanquake closed this on Oct 1, 2021

  96. sidhujag referenced this in commit 7bf329558f on Oct 1, 2021
  97. DrahtBot locked this on Oct 30, 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: 2026-04-24 09:15 UTC

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