seeder: Add support for `addrv2` message + TorV3 addresses
This MR depends on !1489 (merged).
Summary
As a follow-up to !1457 (merged), the seeder also needs updating. This is part of on-going work highlighted in #362 (closed).
Core hasn't updated their seeder yet to work with the new addrv2
messages, so no backports are available from Core for this. This code is original BCHN work.
The changes involve having the seeder also send out sendaddrv2
messages before verack
, and then having it understand how to parse addrv2
messages. We also needed to upgrade the DB format that the seeder uses to serialize in the new "V2" address format (otherwise we wouldn't be able to store the new TorV3 addresses to disk!). Thus, this seeder version will write out dnsseed.dat
files in a slightly new, incompatible format. We had to bump the file format nVersion
from 0
to 1
for this. This program can still read the old version 0
files just fine, but if an old nVersion=0
seeder tries to read our new nVersion=1
files, it will likely terminate with an unhandled stream exception.
Also in this MR:
- Make the seeder useragent reflect the BCHN version it was compiled against e.g. :
/bitcoin-cash-seeder:24.0.1/
rather than the static string:/bitcoin-cash-seeder:0.15.0/
, which never got updated since we forked from Core! - Various small fixups such as not using bare literals for things like
NetMsgType
andINIT_PROTO_VERSION
, but rather use the app-wide constants for these. - Fixed a bug in a commented-out log line.
- Updated the seeder tests
Test Plan
ninja bitcoin-seeder check-bitcoin-seeder
Optional: Also perhaps run a seeder and add some debug prints to various places in bitcoin.cpp
in the seeder to verify it is receiving addrv2 messages properly. Maybe you will need to connect to bch.loping.net:8333
in order to really do this (since it's the only node right now known to send out addrv2 messages on demand). I have done this as part of my developer testing and confirmed it always works, but it may not be a bad idea for an intrepid reviewer to do this as well as a sanity check.