rpc: Make v2transport default for addnode RPC when enabled #29239

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202401_default_addnode_bip324 changing 2 files +7 −6
  1. sipa commented at 9:29 PM on January 11, 2024: member

    Since #29058, several types of manually configured connections will attempt v2 connections when -v2transport is enabled, except for the addnode RPC, as that one has an explicit argument to enable or disable.

    Make the default for that RPC match the -v2transport setting so the behavior matches that of other manual connections from a user perspective.

  2. DrahtBot commented at 9:29 PM on January 11, 2024: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK kristapsk, theStack, achow101
    Concept ACK fanquake
    Approach ACK jonatack

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. sipa renamed this:
    Make v2transaction default for addnode RPC when enabled
    Make v2transport default for addnode RPC when enabled
    on Jan 11, 2024
  4. sipa force-pushed on Jan 11, 2024
  5. sipa force-pushed on Jan 11, 2024
  6. in test/functional/test_framework/test_framework.py:610 in f4e0a1aad8 outdated
     601 | @@ -602,12 +602,7 @@ def connect_nodes(self, a, b, *, peer_advertises_v2=None, wait_for_connect: bool
     602 |          if peer_advertises_v2 is None:
     603 |              peer_advertises_v2 = from_connection.use_v2transport
     604 |  
     605 | -        if peer_advertises_v2:
     606 | -            from_connection.addnode(node=ip_port, command="onetry", v2transport=True)
     607 | -        else:
     608 | -            # skip the optional third argument (default false) for
     609 | -            # compatibility with older clients
     610 | -            from_connection.addnode(ip_port, "onetry")
    


    theStack commented at 12:47 AM on January 12, 2024:

    Isn't this still needed for tests with previous releases (earlier than v26.0), which only accept two arguments for addnode?


    sipa commented at 2:18 PM on January 12, 2024:

    Unsure how relevant that is, but I've changed it to drop the 3rd argument whenever it matches the node -v2transport setting (I think).

  7. theStack commented at 12:49 AM on January 12, 2024: contributor

    Concept ACK

  8. DrahtBot added the label CI failed on Jan 12, 2024
  9. in src/rpc/net.cpp:338 in f4e0a1aad8 outdated
     336 | -
     337 | -    if (use_v2transport && !(node.connman->GetLocalServices() & NODE_P2P_V2)) {
     338 | +    auto use_v2transport = self.MaybeArg<bool>(2);
     339 | +    bool node_v2transport = node.connman->GetLocalServices() & NODE_P2P_V2;
     340 | +    if (!use_v2transport.has_value()) use_v2transport = node_v2transport;
     341 | +    if (*use_v2transport && !node_v2transport) {
    


    maflcko commented at 7:17 AM on January 12, 2024:

    nit: Can be written shorter

        bool node_v2transport = node.connman->GetLocalServices() & NODE_P2P_V2;
        bool use_v2transport = self.MaybeArg<bool>(2).value_or(node_v2transport);
    
        if (use_v2transport && !node_v2transport) {
    

    sipa commented at 2:19 PM on January 12, 2024:

    Nice, done.

  10. maflcko approved
  11. maflcko commented at 7:17 AM on January 12, 2024: member

    Missing rpc: prefix in title?

  12. kristapsk commented at 7:25 AM on January 12, 2024: contributor

    Concept ACK

  13. fanquake renamed this:
    Make v2transport default for addnode RPC when enabled
    rpc: Make v2transport default for addnode RPC when enabled
    on Jan 12, 2024
  14. sipa force-pushed on Jan 12, 2024
  15. in src/rpc/net.cpp:335 in 6a3461dbc7 outdated
     331 | @@ -332,9 +332,10 @@ static RPCHelpMan addnode()
     332 |      CConnman& connman = EnsureConnman(node);
     333 |  
     334 |      const std::string node_arg{request.params[0].get_str()};
     335 | -    bool use_v2transport = self.Arg<bool>(2);
     336 | +    bool node_v2transport = node.connman->GetLocalServices() & NODE_P2P_V2;
    


    maflcko commented at 2:26 PM on January 12, 2024:
        bool node_v2transport = connman.GetLocalServices() & NODE_P2P_V2;
    

    nit, if you re-touch


    sipa commented at 2:39 PM on January 12, 2024:

    Done. I needed to re-touch anyway because apparently nool is not a C++ type.

  16. glozow added this to the milestone 27.0 on Jan 12, 2024
  17. Make v2transport default for addnode RPC when enabled 3ba815b42d
  18. sipa force-pushed on Jan 12, 2024
  19. kristapsk approved
  20. kristapsk commented at 5:21 PM on January 12, 2024: contributor

    ACK 3ba815b42db74804e341ce15f648c2b297af55ca

  21. DrahtBot requested review from theStack on Jan 12, 2024
  22. theStack approved
  23. theStack commented at 5:29 PM on January 12, 2024: contributor

    Code-review ACK 3ba815b42db74804e341ce15f648c2b297af55ca

  24. in src/rpc/net.cpp:339 in 3ba815b42d
     336 | +    bool node_v2transport = connman.GetLocalServices() & NODE_P2P_V2;
     337 | +    bool use_v2transport = self.MaybeArg<bool>(2).value_or(node_v2transport);
     338 |  
     339 | -    if (use_v2transport && !(node.connman->GetLocalServices() & NODE_P2P_V2)) {
     340 | +    if (use_v2transport && !node_v2transport) {
     341 |          throw JSONRPCError(RPC_INVALID_PARAMETER, "Error: v2transport requested but not enabled (see -v2transport)");
    


    jonatack commented at 5:51 PM on January 12, 2024:

    Test coverage for this conditional logic and error? Haven't looked deeply but didn't see it in #24748 @stratospher.


    maflcko commented at 10:32 AM on January 15, 2024:

    Missing test coverage seems unrelated to this pull? (This line and condition is not changed)

  25. in src/rpc/net.cpp:316 in 3ba815b42d
     312 | @@ -313,7 +313,7 @@ static RPCHelpMan addnode()
     313 |                  {
     314 |                      {"node", RPCArg::Type::STR, RPCArg::Optional::NO, "The address of the peer to connect to"},
     315 |                      {"command", RPCArg::Type::STR, RPCArg::Optional::NO, "'add' to add a node to the list, 'remove' to remove a node from the list, 'onetry' to try a connection to the node once"},
     316 | -                    {"v2transport", RPCArg::Type::BOOL, RPCArg::Default{false}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
     317 | +                    {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport"}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
    


    jonatack commented at 6:09 PM on January 12, 2024:

    Perhaps helpful to disambiguate the config option from this addnode option (beyond the - convention)

                        {"v2transport", RPCArg::Type::BOOL, RPCArg::DefaultHint{"set by -v2transport configuration option"}, "Attempt to connect using BIP324 v2 transport protocol (ignored for 'remove' command)"},
    

    jonatack commented at 6:15 PM on January 12, 2024:

    fwiw for the v2transport config option help

    current

      -v2transport
           Support v2 transport (default: 0)
    

    suggestion

      -v2transport
           Support BIP324 v2 transport (default: 0)
    

    or

      -v2transport
           Support BIP324 v2 transport protocol (default: 0)
    
  26. jonatack commented at 6:09 PM on January 12, 2024: member

    Approach ACK

  27. fanquake commented at 10:28 AM on January 15, 2024: member

    Concept ACK for 27.0.

  28. achow101 commented at 9:36 PM on January 16, 2024: member

    ACK 3ba815b42db74804e341ce15f648c2b297af55ca

  29. DrahtBot requested review from jonatack on Jan 16, 2024
  30. DrahtBot requested review from fanquake on Jan 16, 2024
  31. achow101 merged this on Jan 16, 2024
  32. achow101 closed this on Jan 16, 2024

  33. Retropex referenced this in commit 7caf2a8895 on Mar 28, 2024
  34. kwvg referenced this in commit 63a7054351 on Sep 17, 2024
  35. kwvg referenced this in commit 2d8a45bba0 on Sep 17, 2024
  36. kwvg referenced this in commit 194ed825a0 on Sep 17, 2024
  37. kwvg referenced this in commit 78c12224a3 on Oct 2, 2024
  38. kwvg referenced this in commit 3caaa7ae96 on Oct 9, 2024
  39. kwvg referenced this in commit f8b3594770 on Oct 14, 2024
  40. kwvg referenced this in commit c32892cb15 on Oct 15, 2024
  41. kwvg referenced this in commit 5dd60c4875 on Oct 15, 2024
  42. PastaPastaPasta referenced this in commit 5903fb7898 on Oct 16, 2024
  43. bitcoin locked this on Jan 15, 2025

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-19 09:13 UTC

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