If both options “onion” and “proxy” are unset, no outbound Onion connections should be made #22647

issue ghost openend this issue on August 6, 2021
  1. ghost commented at 9:33 am on August 6, 2021: none

    bitcoind 22.0rc2

    Having the following bitcoin.conf

     0upnp=0
     1debug=i2p
     2shrinkdebugfile=1
     3onlynet=i2p
     4listen=1
     5timeout=20000
     6server=1
     7maxtxfee=0.001
     8i2psam=127.0.0.1:7656
     9addnode=72l3ucjkuscrbiiepoehuwqgknyzgo7zuix5ty4puwrkyhtmnsga.b32.i2p:0
    10addnode=c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p:0
    11addnode=gehtac45oaghz54ypyopim64mql7oad2bqclla74l6tfeolzmodq.b32.i2p:0
    12addnode=h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0
    13addnode=hnbbyjpxx54623l555sta7pocy3se4sdgmuebi5k6reesz5rjp6q.b32.i2p:0
    14addnode=pjs7or2ctvteeo5tu4bwyrtydeuhqhvdprtujn4daxr75jpebjxa.b32.i2p:0
    15addnode=wwbw7nqr3ahkqv62cuqfwgtneekvvpnuc4i4f6yo7tpoqjswvcwa.b32.i2p:0
    16addnode=zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:0
    

    Makes bitcoind connect outgoing to Onion network. bitcoind --help says for option onlynet: “if it is used with non-onion networks and the -onion or -proxy option is set, then outbound onion connections will still be made; use -noonion or -onion=0 to disable outbound onion connections in this case.”

    But as you can see, neither onion nor proxy is set. proxy defaults to “disabled” (=0 ?), and onion defaults to value of proxy, so if proxy is unset=disabled, onion should be disabled(=0), too. There should be no need for setting onion=0 in this case.

    The above sentence would be clearer like so: “use -noonion or -onion=0 to disable outbound onion connections if proxy is set”

    Expected behavior

    No outgoing connections to Onion network, only to I2P network.

    Actual behavior

    Outgoing connections to both Onion and I2P network.

    To reproduce

    Use above bitcoin.conf.

    System information

    Debian Buster amd_64

  2. unknown added the label Bug on Aug 6, 2021
  3. jonatack commented at 9:51 am on August 6, 2021: member
    Opened a draft at #22648 and will look into addressing your comments.
  4. vasild commented at 1:18 pm on August 6, 2021: member

    This looks like a bug or at least some serious violation of the Principle of least astonishment.

    I wonder how did bitcoind find the Tor socks5 proxy if none of -proxy or -onion is specified? Can you post the full debug.log and the output of bitcoin-cli getnetworkinfo. I could not reproduce it.

  5. ghost commented at 1:46 pm on August 6, 2021: none

    debug.log. The last line was the first outbound connection, which was of type Onion.

      02021-08-06T13:27:10Z Bitcoin Core version v22.0.0-g873fbc745d037ad43570f81e58334c397bc95477 (release build)
      12021-08-06T13:27:10Z Qt 5.12.11 (static), plugin=xcb (static)
      22021-08-06T13:27:10Z Static plugins:
      32021-08-06T13:27:10Z  QXcbIntegrationPlugin, version 330752
      42021-08-06T13:27:10Z Style: fusion / QFusionStyle
      52021-08-06T13:27:10Z System: Debian GNU/Linux 10 (buster), x86_64-little_endian-lp64
      62021-08-06T13:27:10Z Screen: Virtual-1 1600x900, pixel ratio=1.0
      72021-08-06T13:27:10Z Assuming ancestors of block 00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad have valid signatures.
      82021-08-06T13:27:10Z Setting nMinimumChainWork=00000000000000000000000000000000000000001fa4663bbbe19f82de910280
      92021-08-06T13:27:10Z Using the 'sse4(1way),sse41(4way)' SHA256 implementation
     102021-08-06T13:27:10Z Using RdSeed as additional entropy source
     112021-08-06T13:27:10Z Using RdRand as an additional entropy source
     122021-08-06T13:27:10Z Default data directory /home/user/.bitcoin
     132021-08-06T13:27:10Z Using data directory /home/user/.bitcoin
     142021-08-06T13:27:10Z Config file: /home/user/.bitcoin/bitcoin.conf
     152021-08-06T13:27:10Z Config file arg: addnode="72l3ucjkuscrbiiepoehuwqgknyzgo7zuix5ty4puwrkyhtmnsga.b32.i2p:0"
     162021-08-06T13:27:10Z Config file arg: addnode="c4gfnttsuwqomiygupdqqqyy5y5emnk5c73hrfvatri67prd7vyq.b32.i2p:0"
     172021-08-06T13:27:10Z Config file arg: addnode="gehtac45oaghz54ypyopim64mql7oad2bqclla74l6tfeolzmodq.b32.i2p:0"
     182021-08-06T13:27:10Z Config file arg: addnode="h3r6bkn46qxftwja53pxiykntegfyfjqtnzbm6iv6r5mungmqgmq.b32.i2p:0"
     192021-08-06T13:27:10Z Config file arg: addnode="hnbbyjpxx54623l555sta7pocy3se4sdgmuebi5k6reesz5rjp6q.b32.i2p:0"
     202021-08-06T13:27:10Z Config file arg: addnode="pjs7or2ctvteeo5tu4bwyrtydeuhqhvdprtujn4daxr75jpebjxa.b32.i2p:0"
     212021-08-06T13:27:10Z Config file arg: addnode="wwbw7nqr3ahkqv62cuqfwgtneekvvpnuc4i4f6yo7tpoqjswvcwa.b32.i2p:0"
     222021-08-06T13:27:10Z Config file arg: addnode="zsxwyo6qcn3chqzwxnseusqgsnuw3maqnztkiypyfxtya4snkoka.b32.i2p:0"
     232021-08-06T13:27:10Z Config file arg: debug="i2p"
     242021-08-06T13:27:10Z Config file arg: i2psam="127.0.0.1:7656"
     252021-08-06T13:27:10Z Config file arg: listen="1"
     262021-08-06T13:27:10Z Config file arg: maxtxfee="0.001"
     272021-08-06T13:27:10Z Config file arg: onlynet="i2p"
     282021-08-06T13:27:10Z Config file arg: server="1"
     292021-08-06T13:27:10Z Config file arg: shrinkdebugfile="1"
     302021-08-06T13:27:10Z Config file arg: timeout="20000"
     312021-08-06T13:27:10Z Config file arg: upnp="0"
     322021-08-06T13:27:10Z Using at most 125 automatic connections (1024 file descriptors available)
     332021-08-06T13:27:10Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
     342021-08-06T13:27:10Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
     352021-08-06T13:27:10Z Script verification uses 1 additional threads
     362021-08-06T13:27:10Z scheduler thread start
     372021-08-06T13:27:10Z HTTP: creating work queue of depth 16
     382021-08-06T13:27:10Z Using random cookie authentication.
     392021-08-06T13:27:10Z Generated RPC authentication cookie /home/user/.bitcoin/.cookie
     402021-08-06T13:27:10Z HTTP: starting 4 worker threads
     412021-08-06T13:27:10Z Using wallet directory /home/user/.bitcoin
     422021-08-06T13:27:10Z init message: Überprüfe Wallet(s)...
     432021-08-06T13:27:10Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
     442021-08-06T13:27:10Z Using wallet /home/user/.bitcoin/wallet.dat
     452021-08-06T13:27:10Z BerkeleyEnvironment::Open: LogDir=/home/user/.bitcoin/database ErrorFile=/home/user/.bitcoin/db.log
     462021-08-06T13:27:10Z init message: Lade Bannliste
     472021-08-06T13:27:10Z SetNetworkActive: true
     482021-08-06T13:27:10Z Using /16 prefix for IP bucketing
     492021-08-06T13:27:10Z Cache configuration:
     502021-08-06T13:27:10Z * Using 2.0 MiB for block index database
     512021-08-06T13:27:10Z * Using 8.0 MiB for chain state database
     522021-08-06T13:27:10Z * Using 290.0 MiB for in-memory UTXO set (plus up to 286.1 MiB of unused mempool space)
     532021-08-06T13:27:10Z init message: Lade Block-Index...
     542021-08-06T13:27:10Z Switching active chainstate to Chainstate [ibd] @ height -1 (null)
     552021-08-06T13:27:10Z Opening LevelDB in /home/user/.bitcoin/blocks/index
     562021-08-06T13:27:10Z Opened LevelDB successfully
     572021-08-06T13:27:10Z Using obfuscation key for /home/user/.bitcoin/blocks/index: 0000000000000000
     582021-08-06T13:27:16Z LoadBlockIndexDB: last block file = 2679
     592021-08-06T13:27:16Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=126, size=115009652, heights=694332...694480, time=2021-08-05...2021-08-06)
     602021-08-06T13:27:16Z Checking all blk files are present...
     612021-08-06T13:27:16Z Opening LevelDB in /home/user/.bitcoin/chainstate
     622021-08-06T13:27:17Z Opened LevelDB successfully
     632021-08-06T13:27:17Z Using obfuscation key for /home/user/.bitcoin/chainstate: 0000000000000000
     642021-08-06T13:27:17Z Loaded best chain: hashBestChain=00000000000000000003bfbfaf2b79a93047a1d82b00ca70a727135956e3f11b height=694480 date=2021-08-06T13:21:10Z progress=0.999999
     652021-08-06T13:27:17Z init message: Überprüfe Blöcke...
     662021-08-06T13:27:17Z Verifying last 6 blocks at level 3
     672021-08-06T13:27:17Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
     682021-08-06T13:27:18Z No coin database inconsistencies in last 6 blocks (6887 transactions)
     692021-08-06T13:27:18Z  block index            7426ms
     702021-08-06T13:27:18Z init message: Lade Wallet...
     712021-08-06T13:27:18Z BerkeleyEnvironment::Open: LogDir=/home/user/.bitcoin/database ErrorFile=/home/user/.bitcoin/db.log
     722021-08-06T13:27:18Z [default wallet] Wallet File Version = 169900
     732021-08-06T13:27:18Z [default wallet] Keys: 0 plaintext, 4012 encrypted, 4012 w/ metadata, 4012 total. Unknown wallet records: 0
     742021-08-06T13:27:18Z [default wallet] Wallet completed loading in              53ms
     752021-08-06T13:27:18Z [default wallet] setKeyPool.size() = 1999
     762021-08-06T13:27:18Z [default wallet] mapWallet.size() = 9
     772021-08-06T13:27:18Z [default wallet] m_address_book.size() = 11
     782021-08-06T13:27:18Z block tree size = 694695
     792021-08-06T13:27:18Z nBestHeight = 694480
     802021-08-06T13:27:18Z loadblk thread start
     812021-08-06T13:27:18Z torcontrol thread start
     822021-08-06T13:27:18Z Bound to 127.0.0.1:8334
     832021-08-06T13:27:18Z Bound to [::]:8333
     842021-08-06T13:27:18Z Bound to 0.0.0.0:8333
     852021-08-06T13:27:18Z init message: Lade P2P-Adressen...
     862021-08-06T13:27:18Z Leaving InitialBlockDownload (latching to false)
     872021-08-06T13:27:18Z tor: Got service ID ........................................................, advertising service .........................................................onion:8333
     882021-08-06T13:27:18Z AddLocal(.........................................................onion:8333,4)
     892021-08-06T13:27:18Z Loaded 57329 addresses from peers.dat  343ms
     902021-08-06T13:27:18Z Loaded 0 addresses from "anchors.dat"
     912021-08-06T13:27:18Z 0 block-relay-only anchors will be tried for connections.
     922021-08-06T13:27:18Z init message: Starte Netzwerk-Threads...
     932021-08-06T13:27:18Z init message: Laden abgeschlossen
     942021-08-06T13:27:18Z i2paccept thread start
     952021-08-06T13:27:18Z I2P: Creating SAM session with 127.0.0.1:7656
     962021-08-06T13:27:18Z opencon thread start
     972021-08-06T13:27:18Z dnsseed thread start
     982021-08-06T13:27:18Z Waiting 300 seconds before querying DNS seeds.
     992021-08-06T13:27:18Z addcon thread start
    1002021-08-06T13:27:18Z net thread start
    1012021-08-06T13:27:18Z msghand thread start
    1022021-08-06T13:27:18Z GUI: Platform customization: "other"
    1032021-08-06T13:27:19Z Imported mempool transactions from disk: 1080 succeeded, 0 failed, 0 expired, 0 already there, 0 waiting for initial broadcast
    1042021-08-06T13:27:19Z loadblk thread exit
    1052021-08-06T13:27:21Z New outbound peer connected: version: 70016, blocks=694480, peer=0 (outbound-full-relay)
    

    Output of bitcoin-cli getnetworkinfo

     0{
     1  "version": 220000,
     2  "subversion": "/Satoshi:22.0.0/",
     3  "protocolversion": 70016,
     4  "localservices": "0000000000000409",
     5  "localservicesnames": [
     6    "NETWORK",
     7    "WITNESS",
     8    "NETWORK_LIMITED"
     9  ],
    10  "localrelay": true,
    11  "timeoffset": -3,
    12  "networkactive": true,
    13  "connections": 15,
    14  "connections_in": 0,
    15  "connections_out": 15,
    16  "networks": [
    17    {
    18      "name": "ipv4",
    19      "limited": true,
    20      "reachable": false,
    21      "proxy": "",
    22      "proxy_randomize_credentials": false
    23    },
    24    {
    25      "name": "ipv6",
    26      "limited": true,
    27      "reachable": false,
    28      "proxy": "",
    29      "proxy_randomize_credentials": false
    30    },
    31    {
    32      "name": "onion",
    33      "limited": false,
    34      "reachable": true,
    35      "proxy": "127.0.0.1:9050",
    36      "proxy_randomize_credentials": true
    37    },
    38    {
    39      "name": "i2p",
    40      "limited": false,
    41      "reachable": true,
    42      "proxy": "127.0.0.1:7656",
    43      "proxy_randomize_credentials": false
    44    }
    45  ],
    46  "relayfee": 0.00001000,
    47  "incrementalfee": 0.00001000,
    48  "localaddresses": [
    49    {
    50      "address": "....................................onion",
    51      "port": 8333,
    52      "score": 4
    53    },
    54    {
    55      "address": ".....................................b32.i2p",
    56      "port": 0,
    57      "score": 4
    58    }
    59  ],
    60  "warnings": ""
    61}
    
  6. jonatack commented at 1:50 pm on August 6, 2021: member

    I’ve reproduced the issue with the 22.0rc2 binary (debian), the above config, i2pd 2.38.0 and tor 0.4.6 on mainnet.

     0  "networks": [
     1    {
     2      "name": "ipv4",
     3      "limited": true,
     4      "reachable": false,
     5      "proxy": "",
     6      "proxy_randomize_credentials": false
     7    },
     8    {
     9      "name": "ipv6",
    10      "limited": true,
    11      "reachable": false,
    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": "i2p",
    24      "limited": false,
    25      "reachable": true,
    26      "proxy": "127.0.0.1:7656",
    27      "proxy_randomize_credentials": false
    28    }
    29  ],
    30  "relayfee": 0.00001000,
    31  "incrementalfee": 0.00001000,
    32  "localaddresses": [
    33    {
    34      "address": "xyz.onion",
    35      "port": 8333,
    36      "score": 4
    37    },
    38    {
    39      "address": "aw4zvb3rab7tbtfip2q2fre5eahgvthzu5hhq5rpd6llvgkvlyta.b32.i2p",
    40      "port": 0,
    41      "score": 4
    42    }
    43  ],
    
  7. ghost commented at 1:54 pm on August 6, 2021: none

    With added debug=tor there are those additional log lines:

     02021-08-06T13:49:46Z Leaving InitialBlockDownload (latching to false)
     12021-08-06T13:49:46Z torcontrol thread start
     22021-08-06T13:49:46Z tor: Reading cached private key from /home/user/.bitcoin/onion_v3_private_key
     32021-08-06T13:49:46Z tor: Successfully connected!
     42021-08-06T13:49:46Z tor: Connected to Tor version 0.3.5.15
     52021-08-06T13:49:46Z tor: Supported authentication method: COOKIE
     62021-08-06T13:49:46Z tor: Supported authentication method: HASHEDPASSWORD
     72021-08-06T13:49:46Z tor: Supported authentication method: SAFECOOKIE
     82021-08-06T13:49:46Z tor: Using SAFECOOKIE authentication, reading cookie authentication from /run/tor/control.authcookie
     92021-08-06T13:49:46Z tor: SAFECOOKIE authentication challenge successful
    102021-08-06T13:49:46Z tor: AUTHCHALLENGE ServerHash ........................... ServerNonce ...............................
    112021-08-06T13:49:46Z tor: Authentication successful
    122021-08-06T13:49:46Z tor: ADD_ONION successful
    132021-08-06T13:49:46Z tor: Got service ID ..................., advertising service ....................................onion:8333
    142021-08-06T13:49:46Z tor: Cached service private key to /home/user/.bitcoin/onion_v3_private_key
    152021-08-06T13:49:46Z AddLocal(...............................onion:8333,4)
    
  8. jonatack commented at 2:06 pm on August 6, 2021: member

    Current solution is to add onion=0: this blocks outbound onion connections, I2P outbound connections only.

     0  "networks": [
     1    {
     2      "name": "ipv4",
     3      "limited": true,
     4      "reachable": false,
     5      "proxy": "",
     6      "proxy_randomize_credentials": false
     7    },
     8    {
     9      "name": "ipv6",
    10      "limited": true,
    11      "reachable": false,
    12      "proxy": "",
    13      "proxy_randomize_credentials": false
    14    },
    15    {
    16      "name": "onion",
    17      "limited": true,
    18      "reachable": false,
    19      "proxy": "",
    20      "proxy_randomize_credentials": false
    21    },
    22    {
    23      "name": "i2p",
    24      "limited": false,
    25      "reachable": true,
    26      "proxy": "127.0.0.1:7656",
    27      "proxy_randomize_credentials": false
    28    }
    29  ],
    30  "relayfee": 0.00001000,
    31  "incrementalfee": 0.00001000,
    32  "localaddresses": [
    33    {
    34      "address": "aw4zvb3rab7tbtfip2q2fre5eahgvthzu5hhq5rpd6llvgkvlyta.b32.i2p",
    35      "port": 0,
    36      "score": 4
    37    }
    38  ],
    39  "warnings": ""
    
  9. vasild referenced this in commit 4f4c7d8b11 on Aug 6, 2021
  10. vasild commented at 3:20 pm on August 6, 2021: member

    Thanks for the debug info!

    I wonder how did bitcoind find the Tor socks5 proxy if none of -proxy or -onion is specified?

    It just defaults to 127.0.0.1:9050, disrespecting -onlynet:

    https://github.com/bitcoin/bitcoin/blob/d67330d11245b11fbdd5e2dd5343ee451186931e/src/torcontrol.cpp#L378-L383

    Fixed in https://github.com/bitcoin/bitcoin/pull/22651

  11. ghost commented at 8:06 pm on August 6, 2021: none

    Current solution is to add onion=0: this blocks outbound onion connections, I2P outbound connections only.

    Do you really in fact get I2P outbound connections with onion=0 and onlynet=i2p ? I did not on a 3h test, see my addition to comment in #22634 (comment)

    Edit: I2P only now works for me. Maybe it was a problem of too few nodes or bootstrap issue before. Now I have 10 outbound and even one inbound I2P connection right after startup. I could now also remove the I2P addnode lines from bitcoin.conf, and get I2P connections after restart, I guess the I2P peers are used now from the peer cache.

  12. jonatack commented at 8:32 pm on August 6, 2021: member

    Yes.

    Also, i2pd 2.23.0 (an old version currently still shipped with Debian stable), while a bit funky at first, worked for me across more than a dozen restarts and configurations today to test your reports. I’m running a production node with it now to test it over more time.

  13. jonatack commented at 8:39 pm on August 6, 2021: member

    Also:

    I see many log lines Error connecting to xxx.b32.i2p:0: Unexpected reply to “NAMING LOOKUP NAME=xxx.b32.i2p”: “NAMING REPLY RESULT=INVALID_KEY NAME=xxx.b32.i2p”

    With i2pd 2.23, this is one of the errors when a peer isn’t online. It’s normal when some of the addnode peers in your conf file aren’t up.

  14. Rspigler commented at 9:33 pm on August 6, 2021: contributor

    Are there possible tests that could be added to catch errors like this?

    Edit: I have now seen the discussion on 22651, sorry!

  15. ghost commented at 10:27 pm on August 6, 2021: none
    @jonatak On a second I2P-only test, I get now I2P connections, so pure I2P now works for me too, very nice.
  16. vasild referenced this in commit c591379eb0 on Aug 11, 2021
  17. fanquake deleted a comment on Aug 12, 2021
  18. vasild referenced this in commit 394af8183b on Aug 19, 2021
  19. vasild referenced this in commit 7b821b9d4c on Aug 30, 2021
  20. vasild referenced this in commit 5384c98993 on Aug 30, 2021
  21. vasild referenced this in commit 0ea0de6438 on Sep 1, 2021
  22. vasild referenced this in commit 46a9a797f1 on Sep 3, 2021
  23. luke-jr referenced this in commit 93c87541f6 on Oct 10, 2021
  24. vasild referenced this in commit 8dea7fcf72 on Nov 8, 2021
  25. vasild referenced this in commit e53a8505db on Nov 24, 2021
  26. luke-jr referenced this in commit 06fc482a73 on Dec 14, 2021
  27. laanwj closed this on Mar 1, 2022

  28. laanwj referenced this in commit 848b11615b on Mar 1, 2022
  29. janus referenced this in commit 11617f9a40 on Jul 3, 2022
  30. backpacker69 referenced this in commit 3c6d35919d on Jan 18, 2023
  31. DrahtBot locked this on Mar 1, 2023

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-12-19 00:12 UTC

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