p2p: remove tor v2 support #22050

pull jonatack wants to merge 13 commits into bitcoin:master from jonatack:torv2-remove-support changing 9 files +61 −1156
  1. jonatack commented at 9:48 pm on May 24, 2021: member

    image

    This patch removes support in Bitcoin Core for Tor v2 onions, which are already removed from the release of Tor 0.4.6.

    • no longer serialize/deserialize and relay Tor v2 addresses
    • ignore incoming Tor v2 addresses
    • remove Tor v2 addresses from the addrman and peers.dat on node launch
    • update generate-seeds.py to ignore Tor v2 addresses
    • remove Tor v2 hard-coded seeds

    Tested with tor-0.4.6.1-alpha (no v2 support) and 0.4.5.7 (v2 support). With the latest Tor (no v2 support), this removes all the warnings like those reported with current master in #21351

    0<bitcoind debug log>
    1Socks5() connect to […].onion:8333 failed: general failure
    2
    3<tor log>
    4Invalid hostname [scrubbed]; rejecting
    

    and the addrman no longer has Tor v2 addresses on launching bitcoind.

     0$ ./src/bitcoin-cli -addrinfo
     1{
     2  "addresses_known": {
     3    "ipv4": 44483,
     4    "ipv6": 8467,
     5    "torv2": 0,
     6    "torv3": 2296,
     7    "i2p": 6,
     8    "total": 55252
     9  }
    10}
    

    After recompiling back to current master and restarting with either of the two Tor versions (0.4.5.7 or 0.4.6.1), -addrinfo initially returns 0 Tor v2 addresses and then begins finding them again.

    Ran nodes on this patch over the past week on mainnet/testnet/signet/regtest after building with DEBUG_ADDRMAN.

    Verified that this patch bootstraps an onlynet=onion node from the Tor v3 hardcoded fixed seeds on mainnet and testnet and connects to blocks and v3 onion peers: rm ~/.bitcoin/testnet3/peers.dat ; ./src/bitcoind -testnet -dnsseed=0 -onlynet=onion

    Screenshot from 2021-05-28 00-26-17

    Tested using addnode, getaddednodeinfo,addpeeraddress, disconnectnode and -addrinfo that a currently valid, connectable Tor v2 peer can no longer be added:

    Screenshot from 2021-05-30 11-32-05

    Thanks to Vasil Dimov, Carl Dong, and Wladimir J. van der Laan for their work on BIP155 and Tor v3 that got us here.

  2. jonatack commented at 10:01 pm on May 24, 2021: member
  3. DrahtBot added the label P2P on May 24, 2021
  4. DrahtBot added the label Scripts and tools on May 24, 2021
  5. theStack commented at 11:05 pm on May 24, 2021: member
    Concept ACK
  6. jonatack force-pushed on May 24, 2021
  7. Rspigler commented at 2:12 am on May 25, 2021: contributor
    Concept ACK
  8. jonatack marked this as a draft on May 25, 2021
  9. dunxen commented at 6:53 am on May 25, 2021: contributor
    Concept ACK. (Thank you for your service, tor v2)
  10. 0xB10C commented at 7:08 am on May 25, 2021: member
    Concept ACK
  11. laanwj added this to the milestone 22.0 on May 25, 2021
  12. laanwj commented at 2:53 pm on May 25, 2021: member
    Concept ACK, adding 22.0 label Going to test this.
  13. DrahtBot commented at 5:46 pm on May 25, 2021: member

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

    Conflicts

    No conflicts as of last run.

  14. jonatack force-pushed on May 26, 2021
  15. test: update feature_proxy to torv3 0f1c58ae87
  16. p2p: remove torv2/ADDR_TORV2_SIZE from SetTor() f8e94002fc
  17. in contrib/seeds/nodes_main.txt:653 in 7cfec99a26 outdated
    649@@ -650,518 +650,6 @@
    650 [2a0f:df00:0:254::46]:8333
    651 [2c0f:f598:5:1:1001::1]:8333
    652 [2c0f:fce8:0:400:b7c::1]:8333
    653-226eupdnaouu4h2v.onion:8333
    


    laanwj commented at 11:23 am on May 27, 2021:
    Please also run cd contrib/seeds && python3 generate-seeds.py . > ../../src/chainparamsseeds.h to update chainparamsseeds.h (in the same commit?).

    jonatack commented at 9:43 pm on May 27, 2021:
    Thanks! Done.
  18. jonatack force-pushed on May 27, 2021
  19. p2p: drop onions from IsAddrV1Compatible(), no longer relay torv2 c56a1c9b18
  20. fuzz: rename CNetAddr/CService deserialize targets
    as the changes that follow are incompatible with the inputs.
    eba9a94b9f
  21. p2p: remove torv2 from SetNetFromBIP155Network() 7d1769bc45
  22. jonatack force-pushed on May 27, 2021
  23. jonatack commented at 8:18 am on May 28, 2021: member
    This seems to be ready. Updated the PR description. Will propose release documentation in a follow-up.
  24. jonatack marked this as ready for review on May 28, 2021
  25. willcl-ark commented at 8:01 pm on May 28, 2021: member

    Light tested ACK, rebased on top of master @ 123b401e0acf3b26f149711bdf06d7f6eced1968

    Used Tor version 0.4.5.7. with manually configured hidden service and a bitcoin.conf with

    0listenonion=1
    1onlynet=onion
    2proxy=127.0.0.1:9050
    
    • Node has not picked up any Tor V2 addresses since startup and has a healthy number of V3 addresses in a short period of time:
    • Tested bootstrapping without peers.dat and that picked up over 1000 V3 peers in just a few minutes.

    • Adding a V2 address check back into src/test/net_test.cpp resulted in expected test failure:

    test/net_tests.cpp(614): error: in "net_tests/cnetaddr_unserialize_v2": check addr.IsValid() has failed

  26. willcl-ark approved
  27. in contrib/seeds/generate-seeds.py:50 in 5715134414 outdated
    45@@ -46,9 +46,7 @@ def name_to_bip155(addr):
    46     '''Convert address string to BIP155 (networkID, addr) tuple.'''
    47     if addr.endswith('.onion'):
    48         vchAddr = b32decode(addr[0:-6], True)
    49-        if len(vchAddr) == 10:
    50-            return (BIP155Network.TORV2, vchAddr)
    


    benthecarman commented at 8:39 pm on May 28, 2021:
    I think an error message specific for v2 not being supported would be better than the defualt error message

    laanwj commented at 9:25 pm on May 28, 2021:
    I guess makeseeds.py is still producing these? It should probably ignore Torv2’s from the DNS seeder (all of them, at the moment sipa/bitcoin-seeder#92) completely.

    jonatack commented at 10:04 am on May 29, 2021:
    Thanks, updated generate-seeds.py to ignore torv2 rather than raise.
  28. jonatack force-pushed on May 29, 2021
  29. jonatack commented at 10:10 am on May 29, 2021: member

    Changed generate-seeds.py to ignore torv2 addresses rather than raise. (Edit: I don’t know if using None or an optional type would be preferred to -1 or more pythonic, happy to update if so.)

     0diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py
     1index aaccefcf6f..ae97240203 100755
     2--- a/contrib/seeds/generate-seeds.py
     3+++ b/contrib/seeds/generate-seeds.py
     4@@ -47,8 +47,10 @@ def name_to_bip155(addr):
     5     if addr.endswith('.onion'):
     6         vchAddr = b32decode(addr[0:-6], True)
     7         if len(vchAddr) == 35:
     8-            assert(vchAddr[34] == 3)
     9+            assert vchAddr[34] == 3
    10             return (BIP155Network.TORV3, vchAddr[:32])
    11+        elif len(vchAddr) == 10:
    12+            return (BIP155Network.TORV2, vchAddr)
    13         else:
    14             raise ValueError('Invalid onion %s' % vchAddr)
    15     elif addr.endswith('.b32.i2p'):
    16@@ -98,7 +100,10 @@ def parse_spec(s):
    17 
    18     host = name_to_bip155(host)
    19 
    20-    return host + (port, )
    21+    if host[0] == BIP155Network.TORV2:
    22+        return -1  # TORV2 is no longer supported, so we ignore it
    23+    else:
    24+        return host + (port, )
    25 
    26 def ser_compact_size(l):
    27     r = b""
    28@@ -134,6 +139,8 @@ def process_nodes(g, f, structname):
    29             continue
    30 
    31         spec = parse_spec(line)
    32+        if spec == -1:  # ignore this entry (e.g. no longer supported addresses like TORV2)
    33+            continue
    34         blob = bip155_serialize(spec)
    35         hoststr = ','.join(('0x%02x' % b) for b in blob)
    36         g.write(f'    {hoststr},\n')
    
  30. benthecarman commented at 10:20 am on May 29, 2021: contributor
    utACK ef34bda6c52d7a59be9cd3451bc3536430410e36
  31. jonatack commented at 6:38 pm on May 29, 2021: member

    Tested using addnode, getaddednodeinfo,addpeeraddress, disconnectnode and -addrinfo that a currently valid, connectable Tor v2 peer can no longer be added:

    Screenshot from 2021-05-30 11-32-05

  32. dunxen commented at 6:47 pm on May 29, 2021: contributor

    tACK ef34bda

    • Using Tor v0.4.4.6.
    • Node originally had established connections with Tor v2 peers, now does not connect to v2 peers on patch.
    • After a short while, with onlynet=onion, node is connected to 8+ Tor v3 peers exclusively.

    No Tor v2 addresses known

    0{
    1  "addresses_known": {
    2    "ipv4": 309,
    3    "ipv6": 33,
    4    "torv2": 0,
    5    "torv3": 3563,
    6    "i2p": 0,
    7    "total": 3905
    8  }
    9}
    
    • Cannot add v2 address or connect to v2 address with addnode.
  33. Rspigler commented at 0:45 am on May 30, 2021: contributor
    Could we add a more detailed error message for someone who misses or doesn’t read the release docs?
  34. Zero-1729 commented at 3:13 am on May 30, 2021: contributor

    tACK ef34bda6c52d7a59be9cd3451bc3536430410e36

    Using Tor v0.4.5.8 on MacOS 11.3.1 (20E241)

    Note: Tor v2 seed (bk7yp6epnmcllq72.onion) used is from this article.

    Started bitcoind with -onlynet=onion -listenonion=1 -proxy=127.0.0.1:9050

    Before (on master be1c512437f7aa8215d2e05eda5cc8b58c3d3937):

    • Establishes connection with Tor v2 peers.
     0$ bitcoin-cli -addrinfo
     1{
     2  "addresses_known": {
     3    "ipv4": 272,
     4    "ipv6": 0,
     5    "torv2": 2598,
     6    "torv3": 345,
     7    "i2p": 0,
     8    "total": 3215
     9  }
    10}
    
    • Successfully adds Tor v2 peer bk7yp6epnmcllq72.onion with addpeeraddress.

    After (on torv2-remove-support ef34bda6c52d7a59be9cd3451bc3536430410e36):

    • No longer connects to Tor v2 peers.
    0{
    1  "addresses_known": {
    2    "ipv4": 271,
    3    "ipv6": 0,
    4    "torv2": 0,
    5    "torv3": 352,
    6    "i2p": 0,
    7    "total": 623
    8  }
    9}
    
    • Establishing manual connection with bk7yp6epnmcllq72.onion (Tor v2) using addpeeraddress fails.
    • Adding bk7yp6epnmcllq72.onion via addnode also doesn’t work.
    $ bitcoin-cli addpeeraddress bk7yp6epnmcllq72.onion 8333  
    {
        "success": false
    }
    $ bitcoin-cli addnode bk7yp6epnmcllq72.onion onetry   
    $ bitcoin-cli disconnectnode bk7yp6epnmcllq72.onion
    error code: -29
    error message:
    Node not found in connected nodes
    

    Can verify connections to Tor v2 peers no longer established, including when using addnode & addpeeraddress after patch (ef34bda6c52d7a59be9cd3451bc3536430410e36) 👍

  35. jonatack commented at 10:04 am on May 30, 2021: member

    Updated #22050 (comment) to also mention getaddednodeinfo.

    Could we add a more detailed error message for someone who misses or doesn’t read the release docs?

    Good question. Are you thinking of addpeeraddress or addnode? The former is a hidden test/debug RPC. The latter can be a valuable anti-Eclipse measure to help ensure a node has at least one honest peer, but it is presumably used by informed users.

    I was kind of hoping that updating doc/tor.md and adding an announcement toward the top of the release notes (both in a follow-up), along with communication on twitter and the fediverse (and by the Tor Project, who propose to communicate together for the transition) and maybe resources like the ML and Bitcoin Optech would be enough.

    This is a one-off event and soon the Tor v2 network will no longer be operating at all; according to the Tor AMA event last Friday, the v2 net is already less robust than the v3 one. This should soon be visible in the metrics at https://metrics.torproject.org/versions.html.

  36. Rspigler commented at 10:24 pm on May 30, 2021: contributor

    I was kind of hoping that updating doc/tor.md and adding an announcement toward the top of the release notes (both in a follow-up), along with communication on twitter and the fediverse (and by the Tor Project, who propose to communicate together for the transition) and maybe resources like the ML and Bitcoin Optech would be enough.

    Good point, I think if we do all that, it should be enough

  37. in contrib/seeds/generate-seeds.py:104 in ef34bda6c5 outdated
     99@@ -100,7 +100,10 @@ def parse_spec(s):
    100 
    101     host = name_to_bip155(host)
    102 
    103-    return host + (port, )
    104+    if host[0] == BIP155Network.TORV2:
    105+        return -1  # TORV2 is no longer supported, so we ignore it
    


    kiminuo commented at 9:21 am on June 1, 2021:
    Would it be possibly better to return None here?

    jonatack commented at 9:51 am on June 1, 2021:
    Yes, I asked this in #22050 (comment), happy to update if reviewers think it’s worth changing.

    kiminuo commented at 4:31 pm on June 1, 2021:
    Ah, sorry. None +1 from me :)

    jonatack commented at 8:16 pm on June 1, 2021:
    Ok, I have a couple minor refactorings ready that aren’t essential to removing tor v2 support and propose to insert this change into that commit, unless I need to update this patch for another reason.

    jonatack commented at 11:30 am on June 3, 2021:
    done
  38. in contrib/seeds/generate-seeds.py:53 in ef34bda6c5 outdated
    52-            assert(vchAddr[34] == 3)
    53+        if len(vchAddr) == 35:
    54+            assert vchAddr[34] == 3
    55             return (BIP155Network.TORV3, vchAddr[:32])
    56+        elif len(vchAddr) == 10:
    57+            return (BIP155Network.TORV2, vchAddr)
    


    kiminuo commented at 9:24 am on June 1, 2021:
    This re-ordering change looks unnecessary now. The diff would be smaller when you revert this 4 line change. :-)

    jonatack commented at 9:51 am on June 1, 2021:
    Most frequent path first.
  39. in src/netaddress.h:337 in ef34bda6c5 outdated
    329@@ -334,31 +330,22 @@ class CNetAddr
    330                 memcpy(arr, IPV4_IN_IPV6_PREFIX.data(), prefix_size);
    331                 memcpy(arr + prefix_size, m_addr.data(), m_addr.size());
    332                 return;
    333-            case NET_ONION:
    


    kiminuo commented at 9:37 am on June 1, 2021:

    L301 mentions that GetBIP155Network() Must not be called for IsInternal() objects.

    Would it make sense to add a note after L301 about Tor v2 not being supported anymore? The reason why it may make sense is simply because BIP155 is written with Tor v2 in mind (and that won’t change, or will it?) and the function name is GetBIP155Network. So we are about to deviate from BIP155. For a good reason but still.


    jonatack commented at 9:53 am on June 1, 2021:
    I’m not sure if you’re confusing “addrv2” and “torv2”. What comment would you suggest?

    kiminuo commented at 6:22 pm on June 1, 2021:

    The idea was to change:

    0/**
    1 * Get the BIP155 network id of this address.
    2 * Must not be called for IsInternal() objects.
    3 * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id
    4 */
    5BIP155Network GetBIP155Network() const;
    

    to something like

    0/**
    1 * Get the BIP155 network id of this address.
    2 * Must not be called for IsInternal() objects.
    3 * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id except [BIP155Network::]TORV2 which is no longer supported
    4 */
    5BIP155Network GetBIP155Network() const;
    

    but it’s probably an overkill.


    jonatack commented at 8:19 pm on June 1, 2021:
    SGTM, will add to the follow-up refactoring commit unless this patch needs a more substantial update.

    jonatack commented at 11:35 am on June 3, 2021:

    Updated

    0-         * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id
    1+         * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id, except TORV2 which is no longer supported.
    
  40. kiminuo commented at 9:46 am on June 1, 2021: contributor
    @jonatack $ ./src/bitcoin-cli -addrinfo reports torv2 entry as mentioned in OP. The plan is to remove this later, I guess, right?
  41. jonatack commented at 9:56 am on June 1, 2021: member

    @jonatack $ ./src/bitcoin-cli -addrinfo reports torv2 entry as mentioned in OP. The plan is to remove this later, I guess, right?

    Indeed yes, the reason for -addrinfo returning torv2 and torv3 is for this transition period so the user can see if their node knows enough torv3 peers. When torv2 peers are gone, we can simplify -addrinfo to return only “onion” instead.

  42. reemuru commented at 7:50 pm on June 1, 2021: none

    tACK ef34bda. Run on mainnet, Fedora 34 stable.

    0[user@fedora bitcoin]$ tor --version
    1Jun 01 14:44:30.057 [warn] Tor was compiled with zstd 1.4.9, but is running with zstd 1.5.0. For safety, we'll avoid using advanced zstd functionality.
    2Tor version 0.4.5.8.
    
    [user@fedora ~]$ bitcoin/src/bitcoin-cli -addrinfo
    {
      "addresses_known": {
        "ipv4": 39776,
        "ipv6": 7431,
        "torv2": 17,
        "torv3": 8,
        "i2p": 0,
        "total": 47232
      }
    }
    
    [user@fedora ~]$ bitcoin/src/bitcoin-cli -addrinfo
    {
      "addresses_known": {
      "ipv4": 39729,
      "ipv6": 7425,
      "torv2": 0,
      "torv3": 416,
      "i2p": 0,
      "total": 47570
      }
    }
    
  43. reemuru approved
  44. MarcoFalke requested review from laanwj on Jun 2, 2021
  45. MarcoFalke commented at 5:02 am on June 2, 2021: member
  46. in contrib/seeds/generate-seeds.py:142 in ef34bda6c5 outdated
    138@@ -136,6 +139,8 @@ def process_nodes(g, f, structname):
    139             continue
    140 
    141         spec = parse_spec(line)
    142+        if spec == -1:  # ignore this entry (e.g. no longer supported addresses like TORV2)
    


    laanwj commented at 7:18 am on June 3, 2021:
    I would prefer using the sentinel value None instead of -1 then check with spec is None (just a small nit though, no need to change if no other changes are necessary).

    jonatack commented at 11:29 am on June 3, 2021:
    done
  47. in src/netaddress.cpp:163 in ef34bda6c5 outdated
    144@@ -160,10 +145,6 @@ void CNetAddr::SetLegacyIPv6(Span<const uint8_t> ipv6)
    145         // IPv4-in-IPv6
    146         m_net = NET_IPV4;
    147         skip = sizeof(IPV4_IN_IPV6_PREFIX);
    148-    } else if (HasPrefix(ipv6, TORV2_IN_IPV6_PREFIX)) {
    


    laanwj commented at 7:19 am on June 3, 2021:
    Don’t we need some kind of check here to be able to filter out (ignore) torv2-in-ipv6 in old style addr messages?

    jonatack commented at 10:53 am on June 3, 2021:

    Yes, I thought they would be invalid (so ignored) without the removed code, but it may be better to be explicit about it with something like:

    0    } else if (HasPrefix(ipv6, TORV2_IN_IPV6_PREFIX)) {
    1        // TORv2-in-IPv6 (unsupported). Unserialize as !IsValid(), thus ignoring them.
    2        // Mimic a default-constructed CNetAddr object which is !IsValid() and thus
    3        // will not be gossiped, but continue reading next addresses from the stream.
    4        m_net = NET_IPV6;
    5        m_addr.assign(ADDR_IPV6_SIZE, 0x0);
    6        return;
    

    jonatack commented at 11:36 am on June 3, 2021:
    done
  48. p2p: remove BIP155Network::TORV2 from GetBIP155Network() 1d631e956f
  49. p2p: ignore torv2-in-ipv6 addresses in SetLegacyIPv6() 4192a74413
  50. p2p: remove pre-addrv2 onions from SerializeV1Array() cff5ec477a
  51. p2p: remove torv2 in SetIP() and ADDR_TORV2_SIZE constant 3d39042144
  52. p2p: remove torv2 from CNetAddr::ToStringIP() 5f9d3c09b4
  53. p2p, refactor: extract OnionToString() from CNetAddr::ToStringIp() 8be56f0f8e
  54. jonatack force-pushed on Jun 3, 2021
  55. jonatack commented at 11:51 am on June 3, 2021: member

    Changed the torv2-in-ipv6 case to deserialize explicitly to an invalid address which will be ignored, changed the ignore value in generate-seeds.py from -1 to None, extracted the onion-to-string code to a helper, and updated a Doxygen comment.

     0diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py
     1index ae97240203..0ce868bfcc 100755
     2--- a/contrib/seeds/generate-seeds.py
     3+++ b/contrib/seeds/generate-seeds.py
     4@@ -101,7 +101,7 @@ def parse_spec(s):
     5     host = name_to_bip155(host)
     6 
     7     if host[0] == BIP155Network.TORV2:
     8-        return -1  # TORV2 is no longer supported, so we ignore it
     9+        return None  # TORV2 is no longer supported, so we ignore it
    10     else:
    11         return host + (port, )
    12 
    13@@ -139,7 +139,7 @@ def process_nodes(g, f, structname):
    14             continue
    15 
    16         spec = parse_spec(line)
    17-        if spec == -1:  # ignore this entry (e.g. no longer supported addresses like TORV2)
    18+        if spec is None:  # ignore this entry (e.g. no longer supported addresses like TORV2)
    19             continue
    20         blob = bip155_serialize(spec)
    21         hoststr = ','.join(('0x%02x' % b) for b in blob)
    22diff --git a/src/netaddress.cpp b/src/netaddress.cpp
    23index e46f9c2568..0ae8dd0698 100644
    24--- a/src/netaddress.cpp
    25+++ b/src/netaddress.cpp
    26@@ -145,6 +145,13 @@ void CNetAddr::SetLegacyIPv6(Span<const uint8_t> ipv6)
    27         // IPv4-in-IPv6
    28         m_net = NET_IPV4;
    29         skip = sizeof(IPV4_IN_IPV6_PREFIX);
    30+    } else if (HasPrefix(ipv6, TORV2_IN_IPV6_PREFIX)) {
    31+        // TORv2-in-IPv6 (unsupported). Unserialize as !IsValid(), thus ignoring them.
    32+        // Mimic a default-constructed CNetAddr object which is !IsValid() and thus
    33+        // will not be gossiped, but continue reading next addresses from the stream.
    34+        m_net = NET_IPV6;
    35+        m_addr.assign(ADDR_IPV6_SIZE, 0x0);
    36+        return;
    37     } else if (HasPrefix(ipv6, INTERNAL_IN_IPV6_PREFIX)) {
    38         // Internal-in-IPv6
    39         m_net = NET_INTERNAL;
    40@@ -587,31 +594,26 @@ static std::string IPv6ToString(Span<const uint8_t> a, uint32_t scope_id)
    41     return r;
    42 }
    43 
    44+static std::string OnionToString(const Span<const uint8_t>& addr)
    45+{
    46+    uint8_t checksum[torv3::CHECKSUM_LEN];
    47+    torv3::Checksum(addr, checksum);
    48+    // TORv3 onion_address = base32(PUBKEY | CHECKSUM | VERSION) + ".onion"
    49+    prevector<torv3::TOTAL_LEN, uint8_t> address{addr.begin(), addr.end()};
    50+    address.insert(address.end(), checksum, checksum + torv3::CHECKSUM_LEN);
    51+    address.insert(address.end(), torv3::VERSION, torv3::VERSION + sizeof(torv3::VERSION));
    52+    return EncodeBase32(address) + ".onion";
    53+}
    54+
    55 std::string CNetAddr::ToStringIP() const
    56 {
    57     switch (m_net) {
    58     case NET_IPV4:
    59         return IPv4ToString(m_addr);
    60-    case NET_IPV6: {
    61+    case NET_IPV6:
    62         return IPv6ToString(m_addr, m_scope_id);
    63-    }
    64     case NET_ONION:
    65-        switch (m_addr.size()) {
    66-        case ADDR_TORV3_SIZE: {
    67-
    68-            uint8_t checksum[torv3::CHECKSUM_LEN];
    69-            torv3::Checksum(m_addr, checksum);
    70-
    71-            // TORv3 onion_address = base32(PUBKEY | CHECKSUM | VERSION) + ".onion"
    72-            prevector<torv3::TOTAL_LEN, uint8_t> address{m_addr.begin(), m_addr.end()};
    73-            address.insert(address.end(), checksum, checksum + torv3::CHECKSUM_LEN);
    74-            address.insert(address.end(), torv3::VERSION, torv3::VERSION + sizeof(torv3::VERSION));
    75-
    76-            return EncodeBase32(address) + ".onion";
    77-        }
    78-        default:
    79-            assert(false);
    80-        }
    81+        return OnionToString(m_addr);
    82     case NET_I2P:
    83         return EncodeBase32(m_addr, false /* don't pad with = */) + ".b32.i2p";
    84     case NET_CJDNS:
    85diff --git a/src/netaddress.h b/src/netaddress.h
    86index d539bd51ff..0d04ab88fb 100644
    87--- a/src/netaddress.h
    88+++ b/src/netaddress.h
    89@@ -299,7 +299,7 @@ class CNetAddr
    90         /**
    91          * Get the BIP155 network id of this address.
    92          * Must not be called for IsInternal() objects.
    93-         * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id
    94+         * [@returns](/bitcoin-bitcoin/contributor/returns/) BIP155 network id, except TORV2 which is no longer supported.
    95          */
    96         BIP155Network GetBIP155Network() const;
    
  56. contrib: update generate-seeds.py to ignore torv2 addresses 5f7e086dac
  57. contrib: remove torv2 seed nodes 5d82a57db4
  58. jonatack force-pushed on Jun 3, 2021
  59. laanwj commented at 1:00 pm on June 3, 2021: member
    Changes look good to me now. Code review ACK 5d82a57db4f67506a4e80d186ba76f3a8665e147 Tested ACK of an earlier commit, which I tested for a while on one of my nodes. I noticed no difference in behavior except for no longer connecting to Tor v2 nodes.
  60. laanwj merged this on Jun 3, 2021
  61. laanwj closed this on Jun 3, 2021

  62. jonatack deleted the branch on Jun 3, 2021
  63. sidhujag referenced this in commit 31269453d9 on Jun 3, 2021
  64. in src/netaddress.cpp:82 in 5d82a57db4
    70-            m_net = NET_ONION;
    71-            return true;
    72-        }
    73-        throw std::ios_base::failure(
    74-            strprintf("BIP155 TORv2 address with length %u (should be %u)", address_size,
    75-                      ADDR_TORV2_SIZE));
    


    vasild commented at 9:31 am on June 4, 2021:

    (can be ignored)

    This change in CNetAddr::SetNetFromBIP155Network() will now accept and ignore a Tor v2 addresses with bogus length, e.g. 13. whereas we know it should be exactly 10. The comment near the bottom of this function: // Don't throw on addresses with unknown network ids (maybe from the future). is somewhat incorrect now.


    jonatack commented at 10:25 am on June 19, 2021:
    Thanks, I’ll have a look.
  65. vasild commented at 11:08 am on June 7, 2021: member

    ACK 5d82a57db4f67506a4e80d186ba76f3a8665e147

    Some followups in #22179.

  66. laanwj referenced this in commit 4bff49bbb1 on Jun 12, 2021
  67. laanwj referenced this in commit 0de84b7328 on Sep 16, 2021
  68. gwillen referenced this in commit 97ea1dabe4 on Jun 1, 2022
  69. DrahtBot locked this on Aug 18, 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-10-04 19:12 UTC

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