Clarify blocksonly whitelistforcerelay test #19963

pull t-bast wants to merge 1 commits into bitcoin:master from t-bast:clarify-whitelist-force-relay-test changing 1 files +14 −10
  1. t-bast commented at 1:02 PM on September 16, 2020: member

    As discussed in #19943, this test may be a bit misleading to newcomers.

    We underscore the fact that our peer needs to run a modified version of Bitcoin Core to actually relay transactions to a blocksonly node and benefit from the whitelistforcerelay parameter.

  2. fanquake added the label Tests on Sep 16, 2020
  3. in test/functional/p2p_blocksonly.py:77 in e483b06187 outdated
      72 | @@ -74,6 +73,10 @@ def run_test(self):
      73 |  
      74 |          self.log.info('Check that the tx from forcerelay first_peer is relayed to others (ie.second_peer)')
      75 |          with self.nodes[0].assert_debug_log(["received getdata"]):
      76 | +            # NB: in practice, first_peer would never send us transactions since we're a blocksonly node.
      77 | +            # But if first_peer runs a modified version of Bitcoin Core to bypass relay checks and forward
    


    michaelfolkson commented at 1:23 PM on September 16, 2020:

    nit: s/forward/forwards


    t-bast commented at 3:43 PM on September 16, 2020:

    My thinking was that forward was going in pair with bypass (both infinitive), but I'm not a native speaker, I can definitely apply that.


    michaelfolkson commented at 3:50 PM on September 16, 2020:

    Yeah first_peer is running a modified version of Bitcoin Core to bypass relay checks. Once it has done that the first_peer forwards the transactions. But as I said I don't think we are fussy on grammar for comments on this project and I wouldn't want to put people like you off from adding comments in future! So feel free to leave it. We'll see if Gleb has more substantial suggestions.

  4. michaelfolkson commented at 1:36 PM on September 16, 2020: contributor

    Concept ACK. Thanks for opening this @t-bast.

    I think we are pretty lenient on style, grammar etc of comments on this project so feel free to ignore the nit. I personally like linking to the issue number (where the discussion is) too.

    Anything that needs adding to this comment @naumenkogs?

  5. naumenkogs commented at 7:14 AM on September 17, 2020: member
    1. What's "NB"?
    2. This part of the test is confusing in the first place: it should have nothing to do with "forcerelay". It's about "relay" permission. It works just because "forcerelay" enables "relay" permission automatically. Can you modify this chunk of the test to talk about "relay"?
    3. I would prefer to expand the following description: "first_peer would never send us transactions since we're a blocksonly node.". Say that we tell them we don't need transactions, so Bitcoin Core node would adhere to this suggestion and not send us transactions. And normally we'd disconnect them (unless we enabled "relay" permission, see next)
    4. Also expand this: "But if first_peer runs a modified version of Bitcoin Core to bypass relay checks" -> something along the lines "if, for some reason, first_peer decides to relay transactions to us, we should relay them forward per RELAY permission we assigned to first_peer".
  6. t-bast commented at 1:26 PM on September 17, 2020: member

    Done, let me know if that's better.

  7. in test/functional/p2p_blocksonly.py:59 in 7d5cf26e99 outdated
      55 | @@ -56,33 +56,35 @@ def run_test(self):
      56 |              self.nodes[0].p2p.wait_for_tx(txid)
      57 |              assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
      58 |  
      59 | -        self.log.info('Check that txs from forcerelay peers are not rejected and relayed to others')
      60 | -        self.log.info("Restarting node 0 with forcerelay permission and blocksonly")
      61 | -        self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", "-whitelistforcerelay", "-blocksonly"])
      62 | +        self.log.info('Check that txs from relay peers are not rejected and relayed to others')
    


    naumenkogs commented at 10:51 AM on September 18, 2020:

    "Forcerelay' clearly meant a peer with FORCERELAY permission. Now that you call it "relay", it's not clear it's about permissions, because we commonly use "relay" in many contexts. I would prefer "RELAY-whitelisted" or something like that hereinafter.


    t-bast commented at 11:14 AM on September 18, 2020:
  8. naumenkogs commented at 10:52 AM on September 18, 2020: member

    Still no idea what's "NB" :) Otherwise looks good if you see my new suggestion.

  9. t-bast commented at 11:15 AM on September 18, 2020: member

    Still no idea what's "NB" :)

    Heh, it's "Nota Bene", we probably use that latin abbreviation too often in France :)

  10. DrahtBot commented at 1:27 PM on September 19, 2020: 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:

    • #19770 (RPC: getpeerinfo: Deprecate "whitelisted" field (replaced by "permissions") by luke-jr)
    • #19315 ([tests] Allow outbound & block-relay-only connections in functional tests. by amitiuttarwar)

    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.

  11. in test/functional/p2p_blocksonly.py:62 in 3abe9f866c outdated
      55 | @@ -57,29 +56,35 @@ def run_test(self):
      56 |              self.nodes[0].p2p.wait_for_tx(txid)
      57 |              assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
      58 |  
      59 | -        self.log.info('Check that txs from forcerelay peers are not rejected and relayed to others')
      60 | -        self.log.info("Restarting node 0 with forcerelay permission and blocksonly")
      61 | -        self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", "-whitelistforcerelay", "-blocksonly"])
      62 | +        self.log.info('Check that txs from RELAY-whitelisted peers are not rejected and relayed to others')
      63 | +        self.log.info("Restarting node 0 with relay permission and blocksonly")
      64 | +        self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", "-whitelistrelay", "-blocksonly"])
    


    MarcoFalke commented at 7:16 AM on September 20, 2020:

    Can't this be written shorter as:

            self.restart_node(0, ["-persistmempool=0", "-whitelist=relay@127.0.0.1", "-blocksonly"])
    

    t-bast commented at 6:32 AM on September 21, 2020:

    I thought so too, but interestingly it doesn't work. When setting whitelist=relay@127.0.0.1 and doing a getpeerinfo, the permissions are correctly set to relay, but whitelisted is set to false...


    naumenkogs commented at 6:56 AM on September 21, 2020:

    whitelisted is there for backward compatibility only: // If this flag is present, the user probably expect that RPC and QT report it as whitelisted (backward compatibility).

    Your test should still work even after marco's suggestion? You just have to update the following stuff too: drop the legacy assert_equal(peer_1_info['whitelisted'], True) stuff


    naumenkogs commented at 6:57 AM on September 21, 2020:

    (I'm fine keeping it as is too)


    t-bast commented at 6:59 AM on September 21, 2020:

    Great, thanks for the explanation, the rest of the test indeed works fine once changed. I'll remove that check if that is a deprecated flag, it can be misleading for newcomers.


  12. in test/functional/p2p_blocksonly.py:59 in 3abe9f866c outdated
      55 | @@ -57,29 +56,35 @@ def run_test(self):
      56 |              self.nodes[0].p2p.wait_for_tx(txid)
      57 |              assert_equal(self.nodes[0].getmempoolinfo()['size'], 1)
      58 |  
      59 | -        self.log.info('Check that txs from forcerelay peers are not rejected and relayed to others')
      60 | -        self.log.info("Restarting node 0 with forcerelay permission and blocksonly")
      61 | -        self.restart_node(0, ["-persistmempool=0", "-whitelist=127.0.0.1", "-whitelistforcerelay", "-blocksonly"])
      62 | +        self.log.info('Check that txs from RELAY-whitelisted peers are not rejected and relayed to others')
    


    MarcoFalke commented at 7:17 AM on September 20, 2020:
            self.log.info('Check that txs from peers with relay-permission are not rejected and relayed to others')
    

    Would prefer to use lowercase (identical to the flag name for the whitelist setting)


    t-bast commented at 6:30 AM on September 21, 2020:

    Done


    naumenkogs commented at 6:31 AM on September 21, 2020:

    I agree with Marco even though it was my suggestion to use the uppercase. We definitely use lowercase for permissions, I was just referring to the enum, which has less prio in this case.

  13. in test/functional/p2p_blocksonly.py:12 in 3abe9f866c outdated
       8 | @@ -9,7 +9,6 @@
       9 |  from test_framework.test_framework import BitcoinTestFramework
      10 |  from test_framework.util import assert_equal
      11 |  
      12 | -
    


    MarcoFalke commented at 7:18 AM on September 20, 2020:

    I think pep-8 wants two lines here


    t-bast commented at 6:30 AM on September 21, 2020:

    Done

  14. MarcoFalke approved
  15. MarcoFalke commented at 7:18 AM on September 20, 2020: member

    ACK

    some style nits, which you are free to ignore

  16. naumenkogs commented at 6:31 AM on September 21, 2020: member

    We normally don't commit "fixup fixup" like that, so please squash into 1 commit after you address marco's comments :)

  17. t-bast force-pushed on Sep 21, 2020
  18. t-bast force-pushed on Sep 21, 2020
  19. in test/functional/p2p_blocksonly.py:79 in f59681ecc4 outdated
      82 |          with self.nodes[0].assert_debug_log(["received getdata"]):
      83 | +            # Note that normally, first_peer would never send us transactions since we're a blocksonly node.
      84 | +            # By activating blocksonly, we explicitly tell our peers that they should not send us transactions,
      85 | +            # and Bitcoin Core respects that choice and will not send transactions.
      86 | +            # But if, for some reason, first_peer decides to relay transactions to us anyway, we should relay them to
      87 | +            # second_peer since we gave RELAY permission to first_peer.
    


    naumenkogs commented at 7:28 AM on September 21, 2020:

    still uppercase :)



    naumenkogs commented at 8:01 AM on September 21, 2020:

    Ready to ack, please squash :)


    t-bast commented at 8:16 AM on September 21, 2020:

    Done!

  20. Clarify blocksonly whitelistforcerelay test
    As discussed in https://github.com/bitcoin/bitcoin/issues/19943, this
    test may be a bit misleading to newcomers.
    
    We underscore the fact that our peer needs to run a modified version of
    Bitcoin Core to actually relay transactions to a `blocksonly` node and
    benefit from the `whitelistforcerelay` parameter.
    e15344889a
  21. t-bast force-pushed on Sep 21, 2020
  22. naumenkogs commented at 9:16 AM on September 21, 2020: member

    ACK e15344889aac50aadee9211ac34e466867d5862b

  23. MarcoFalke merged this on Sep 22, 2020
  24. MarcoFalke closed this on Sep 22, 2020

  25. sidhujag referenced this in commit 748f7209a8 on Sep 23, 2020
  26. t-bast deleted the branch on Sep 23, 2020
  27. deadalnix referenced this in commit 4f440ba689 on Oct 11, 2021
  28. DrahtBot locked this on Feb 15, 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-29 03:14 UTC

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