-
Notifications
You must be signed in to change notification settings - Fork 976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
addrv2 BIP155 support #101
base: master
Are you sure you want to change the base?
Conversation
By making IMPLEMENT_SERIALIZE generate a function declaration where the implementation code is directly the function body, the compiler will be able to preserve the line location of each statement which is useful for setting breakpoints in a debugger.
nVersion is a special contextual parameter which value should be preserved for the upcoming serialization invocations. For example: using READWRITE() passes nVersion implicitly. TLDR: If nVersion is unintentionally changed, the next Serialize call will have a bad protocol version.
These look like useful functions but they aren't used anywhere. Deleting dead code is less effort than fixing it.
Some helpers for serialization: - READWRITEAS() macro. Same as READWRITE() but with type casting. - COMPACTSIZE() macro. For serializing CompactSize. - extending FLATDATA() to accept vectors in addition to arrays.
We need it to encode onion v3 addresses.
Convert CNetAddr to be addrv2 native. CNetAddr used to store a static array of 16 bytes, now it stores a network id and a dynamically sized bytes vector.
Handle both addr and addrv2 serializations for CNetAddr and its derived classes.
In BIP155 the services field is serialized as CompactSize.
In CAddress we serialize services as CompactSize while services is a bit field and not a size.
Implement SetSpecial() and ToString() for onion and i2p addresses.
Use TorToString() and I2PToString() where appropriate.
Simplify GetNetwork using the networkId field.
Send sendaddrv2 to nodes with version 70016 or more recent. Decode addrv2 messages upon reception.
This is optional, but it is suitable to announce a minimum version of 70016 since we support addrv2.
The I2P protocol SAM v3.1 which is supported by bitcoin core does not use ports hence its value is zero. Read more at https://github.com/bitcoin/bitcoin/blob/master/doc/i2p.md#ports-in-i2p-and-bitcoin-core
To make sure all address types are preserved when serializing to the database, we use addrv2.
This is to accommodate for I2P seeds which have port zero.
onion v2 is no longer supported.
Concept ACK |
@sipa is this good? |
Oh wow, I completely missed this, sorry! I will review in the next few days. |
@siltribera I'm sorry for the slow response here. I finally had a look at the code. I'm not sure I like how much the new code diverges further from the Bitcoin Core codebase. I think it'd be better to just bring the network code up-to-date with the Bitcoin Core source code, which has all of these things (access to proxies, various networks, BIP155 serialization, ...) already implemented, rather than reimplement everything from scratch. That'll make it easier to port future changes to the seeder as well. |
Seems to work, after a bit of simple merges with master. Can always revert it later when updating the network code? |
This is BIP155 addrv2 support for TOR, I2P and CJDNS.
Resolves #92.
Included in this pull request is the complete implementation of BIP155.
Serialization to disk always uses addrv2 format (in order to save TOR and I2P addresses in the database); Serialization on the network only uses the addrv2 format when serializing an addrv2 message; For all other cases, the old address format is used (particularly when serializing the version message and the old addr message).
Commits were kept small and descriptive to convey information from the original developer to the potential code reviewer.
Two optional commits were left out of this pull request for submission in a follow up. This is an enhancement to the proxy implementation which adds HTTP proxy support (useful with I2P) and command line flags for setting a proxy for I2P and CJDNS. As this is an enhacement, it was postponed to keep this pull request small. If you wish to check it out you may find it here.
The crawler does attempt to communicate with TOR, I2P and CJDNS nodes to collect peer addresses from them, possibly through a proxy if supplied in the command line.
This implementation was carefully tested prior to submission for each of TOR, I2P and CJDNS nodes.