net, rpc, test, bugfix: update GetNetworkName, GetNetworksInfo, regression tests #20120

pull jonatack wants to merge 3 commits into bitcoin:master from jonatack:fix-getnetworkinfo-empty-networks changing 3 files +33 −19
  1. jonatack commented at 10:42 am on October 11, 2020: member

    Following up on the BIP155 addrv2 changes, and starting with 7be6ff6 in #19845, RPC getnetworkinfo began returning networks with empty names.

     0  "networks": [
     1    {
     2      "name": "ipv4",
     3      "limited": false,
     4      "reachable": true,
     5      "proxy": "",
     6      "proxy_randomize_credentials": false
     7    },
     8    {
     9      "name": "ipv6",
    10      "limited": false,
    11      "reachable": true,
    12      "proxy": "",
    13      "proxy_randomize_credentials": false
    14    },
    15    {
    16      "name": "onion",
    17      "limited": false,
    18      "reachable": true,
    19      "proxy": "127.0.0.1:9050",
    20      "proxy_randomize_credentials": true
    21    },
    22    {
    23      "name": "",
    24      "limited": false,
    25      "reachable": true,
    26      "proxy": "",
    27      "proxy_randomize_credentials": false
    28    },
    29    {
    30      "name": "",
    31      "limited": false,
    32      "reachable": true,
    33      "proxy": "",
    34      "proxy_randomize_credentials": false
    35    }
    36  ],
    
     0  "networks": [
     1    {
     2      "name": "ipv4",
     3      "limited": false,
     4      "reachable": true,
     5      "proxy": "",
     6      "proxy_randomize_credentials": false
     7    },
     8    {
     9      "name": "ipv6",
    10      "limited": false,
    11      "reachable": true,
    12      "proxy": "",
    13      "proxy_randomize_credentials": false
    14    },
    15    {
    16      "name": "onion",
    17      "limited": false,
    18      "reachable": true,
    19      "proxy": "127.0.0.1:9050",
    20      "proxy_randomize_credentials": true
    21    }
    22  ],
    

    This patch:

    • updates GetNetworkName() to the current Network enum
    • updates getNetworksInfo() to ignore as-yet unsupported networks
    • adds regression tests
  2. fanquake added the label RPC/REST/ZMQ on Oct 11, 2020
  3. jonatack force-pushed on Oct 11, 2020
  4. DrahtBot commented at 8:26 pm on October 11, 2020: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #20254 (Add I2P support using statically configured destinations by vasild)

    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.

  5. promag commented at 0:27 am on October 12, 2020: member

    Concept ACK.

    How about:

    0--- a/src/netbase.cpp
    1+++ b/src/netbase.cpp
    2@@ -58,7 +58,7 @@ std::string GetNetworkName(enum Network net) {
    3     case NET_IPV4: return "ipv4";
    4     case NET_IPV6: return "ipv6";
    5     case NET_ONION: return "onion";
    6-    default: return "";
    7+    default: assert(false);
    8     }
    9 }
    

    This is the only place GetNetworkName is called.

  6. jonatack force-pushed on Oct 12, 2020
  7. jonatack commented at 7:57 am on October 12, 2020: member
    Thanks @promag. This aborts, but good idea–I’ve updated this patch to fix the issue at the netbase level as well. (I’m proposing calling GetNetworkName here as well for getpeerinfo.)
  8. jonatack renamed this:
    rpc, bugfix: filter networks with empty names from getnetworkinfo
    net, rpc, test, bugfix: update GetNetworkName, GetNetworksInfo, regression tests
    on Oct 12, 2020
  9. in test/functional/feature_proxy.py:225 in 2320bc09d8 outdated
    200 
    201         if self.have_ipv6:
    202             n3 = networks_dict(self.nodes[3].getnetworkinfo())
    203-            for net in ['ipv4','ipv6']:
    204+            assert_equal(NETWORKS, n3.keys())
    205+            for net in NETWORKS:
    


    vasild commented at 11:52 am on October 12, 2020:
    This used to run for just 'ipv4','ipv6' before and now will also run for 'onion' in addition. I guess it is ok as long as the test passes.

    jonatack commented at 12:11 pm on October 12, 2020:
    Thanks. Yes, that was my thinking: if it passes with the additional coverage, we’ll take it.
  10. vasild approved
  11. vasild commented at 11:52 am on October 12, 2020: member
    ACK 2320bc09d
  12. promag commented at 5:27 pm on October 12, 2020: member

    Code review ACK 2320bc09d829e6efe26cc07ef388599ffdc99b9e.

    Note that #20002 adds another call to GetNetworkName.

  13. fanquake deleted a comment on Oct 12, 2020
  14. hebasto commented at 8:53 am on October 14, 2020: member

    Concept ACK.

    Following up on the BIP155 addrv2 changes, and starting with #19991, RPC getnetworkinfo began returning networks with empty names.

    From the git log of the master branch it follows that behavior was changed in 7be6ff61875a8d5d2335bff5d1f16ba40557adb0 from #19845. @jonatack if you could confirm this, mind updating the OP?

  15. in src/netbase.cpp:68 in 49f7be8396 outdated
    63+    case NET_I2P: return "i2p";
    64+    case NET_CJDNS: return "cjdns";
    65+    case NET_INTERNAL: return "internal";
    66+    case NET_MAX: assert(false);
    67     }
    68+    assert(false);
    


    hebasto commented at 9:03 am on October 14, 2020:

    49f7be8396d85b1795c65ca5ebf6069c6c1e047e

    Mind following Developer Notes – C++ data structures:

    0    case NET_MAX: assert(false);
    1    } // no default case, so the compiler can warn about missing cases
    2    assert(false);
    

    ?


    hebasto commented at 9:23 am on October 14, 2020:
    ofc, it’s not a blocker :)

    jonatack commented at 9:24 am on October 14, 2020:
    Thanks for reviewing–I don’t mind, but I hesitate to invalidate 3 reviews for a non-essential code comment. Can add it in another PR.

    jonatack commented at 5:13 pm on October 15, 2020:
    Had to rebase, so updating with your feedback. Thanks!
  16. hebasto approved
  17. hebasto commented at 9:13 am on October 14, 2020: member
    ACK 2320bc09d829e6efe26cc07ef388599ffdc99b9e, tested on Linux Mint 20 (x86_64).
  18. jonatack commented at 9:56 am on October 14, 2020: member

    From the git log of the master branch it follows that behavior was changed in 7be6ff6 from #19845. @jonatack if you could confirm this, mind updating the OP?

    Updated, thanks. This makes sense. I likely tested incorrectly.

  19. jonatack force-pushed on Oct 15, 2020
  20. net: update GetNetworkName() with all enum Network cases ba8997fb2e
  21. rpc: update GetNetworksInfo() to not return unsupported networks 9a75e1e569
  22. test: add getnetworkinfo network name regression tests 7b5bd3102e
  23. jonatack force-pushed on Oct 15, 2020
  24. jonatack commented at 5:24 pm on October 15, 2020: member
    Rebased and updated per git range-diff 0d22482 2320bc0 7b5bd31 after merge of #20002.
  25. hebasto approved
  26. hebasto commented at 7:00 pm on October 15, 2020: member
    re-ACK 7b5bd3102e06f7ff34b5d0f1d45a005560f265a5
  27. laanwj added this to the milestone 0.21.0 on Oct 15, 2020
  28. luke-jr approved
  29. luke-jr commented at 6:29 pm on October 24, 2020: member
    utACK
  30. vasild approved
  31. vasild commented at 10:24 am on October 26, 2020: member
    ACK 7b5bd3102
  32. in test/functional/feature_proxy.py:48 in 7b5bd3102e
    42@@ -41,12 +43,16 @@
    43 from test_framework.netutil import test_ipv6_local
    44 
    45 RANGE_BEGIN = PORT_MIN + 2 * PORT_RANGE  # Start after p2p and rpc ports
    46-# From GetNetworkName() in netbase.cpp:
    47-NET_UNROUTABLE = ""
    48+
    49+# Networks returned by RPC getpeerinfo, defined in src/netbase.cpp::GetNetworkName()
    50+NET_UNROUTABLE = "unroutable"
    


    promag commented at 12:13 pm on November 7, 2020:
    This is not used?

    jonatack commented at 4:16 pm on November 9, 2020:
    It’s used below, line 171: self.network_test(node, addr, network=NET_UNROUTABLE)
  33. laanwj merged this on Nov 9, 2020
  34. laanwj closed this on Nov 9, 2020

  35. jonatack deleted the branch on Nov 9, 2020
  36. sidhujag referenced this in commit 55fb188668 on Nov 9, 2020
  37. random-zebra referenced this in commit b4751e10ce on Aug 11, 2021
  38. Fabcien referenced this in commit c50d2ac071 on Dec 22, 2021
  39. DeckerSU referenced this in commit c26f71f1ac on Feb 12, 2022
  40. 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: 2024-07-05 22:12 UTC

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