Skip to content

[backport] Complete the BIP155 implementation and upgrade to TORv3

Axel Gembe requested to merge ago/bitcoin-cash-node:backport_core_pr19954 into master

Summary

This is a backport of https://github.com/bitcoin/bitcoin/pull/19954

This also includes a partial backport of https://github.com/bitcoin/bitcoin/pull/20564

This PR contains the two remaining commits from #19031 to complete the BIP155 implementation:

net: CAddress & CAddrMan: (un)serialize as ADDRv2 net: advertise support for ADDRv2 via new message

plus one more commit:

tor: make a TORv3 hidden service instead of TORv2

Depends on !1475 (merged)

Test plan

  • ninja all check check-functional-extended
  • ./test/functional/test_runner.py --failfast -j $(nproc) $(echo {1..128} | sed 's/[^ ]*/p2p_addrv2_relay.py/g') to check for the fixed race condition in p2p_addrv2_relay
  • Install a Tor instance and set ControlPort 9051, CookieAuthentication 1, CookieAuthFileGroupReadable 1 and depending on distro DataDirectoryGroupReadable 1 in /etc/tor/torrc. Add your user to the tor group: gpasswd -a tor user. Restart tor. You might need to log out and log in again to get your login session to have the additional group, check with id.
  • bitcoind -datadir=<first datadir> -proxy=127.0.0.1:9050 -listen -debug=tor -debug=net to start the first instance. Check the log for tor: Got service ID v525rwi6aar2hpgmbryssymabh7ty4yzyjpym2pje5edhco23o6kofqd, advertising service v525rwi6aar2hpgmbryssymabh7ty4yzyjpym2pje5edhco23o6kofqd.onion:8333, this is your onion service address.
  • bitcoind -datadir=<second datadir> -proxy=127.0.0.1:9050 -onlynet=onion -debug=tor -addnode=v525rwi6aar2hpgmbryssymabh7ty4yzyjpym2pje5edhco23o6kofqd.onion:8333 -rpcport=8442 to start the second instance.
  • Check the logs to see if the second instance can connect to the first and they exchange sendaddrv2 after verack and then send addrv2.
  • Do the same with -useextversion=1.

Some more useful commands to test this:

bitcoin-cli getpeerinfo > peerinfo.json

# Check that sendaddrv2 has been sent to all our peers
test $(jq '. | length' peerinfo.json) -eq $(jq '[.[] | select(.bytessent_per_msg.sendaddrv2 > 0)] | length' peerinfo.json) || echo failed

# List peers that have advertised via sendaddrv2 to us
jq '.[] | select(.bytesrecv_per_msg.sendaddrv2 > 0)' peerinfo.json

# List peers that have sent addrv2 to us
jq '.[] | select(.bytesrecv_per_msg.addrv2 > 0)' peerinfo.json

# List peers that we sent addrv2 to
jq '.[] | select(.bytesrecv_per_msg.addrv2 > 0)' peerinfo.json

# List onion peers
jq '.[] | select(.addr | contains("onion"))' peerinfo.json
Edited by Axel Gembe

Merge request reports

Loading