Skip to content

Implement ADDRv2 support (part of BIP155)#19031

Closed
vasild wants to merge 2 commits intobitcoin:masterfrom
vasild:addrv2
Closed

Implement ADDRv2 support (part of BIP155)#19031
vasild wants to merge 2 commits intobitcoin:masterfrom
vasild:addrv2

Conversation

@vasild
Copy link
Contributor

@vasild vasild commented May 20, 2020

An implementation of BIP155 addrv2 messages. To ease review it is split in a few logical changes and submitted as separate, smaller, PRs.

The current one for review is: #19954

Preparation changes

Commits:

Change CNetAddr::ip to have flexible size

Commits:

Implement addrv2 (un)serializing

Add support to serialize CNetAddr and CAddress in ADDRv2 format. Invoke that from CAddrMan serialization methods. Commits:

Advertise support

Advertise ADDRv2 support to peers, handle incoming ADDRv2 messages and send to peers in that format if they have advertised support. Commits:

All the steps to get Tor v3 support are outlined in issue#18884 Tor v3 support, this PR is one of them.

This was referenced May 20, 2020
@dongcarl
Copy link
Contributor

Concept ACK 😄

Am I correct in saying that you've replaced NetworkID in my implementation with Bip155NetworkId? (totally fine btw, just wanted to make sure)

@laanwj
Copy link
Member

laanwj commented May 20, 2020

Concept ACK!

@vasild
Copy link
Contributor Author

vasild commented May 20, 2020

Am I correct in saying that you've replaced NetworkID in my implementation with Bip155NetworkId? (totally fine btw, just wanted to make sure)

Yes, thanks for asking!

Ideally we would have just one enum for network types, not two. That would contain the network ids from BIP155 + the other ones we have now - unroutable, internal/name, etc. But the problem is that lots of code relies on the values being sequential - there are loops from 0 to NET_MAX. I did not wanted to plant e.g. "unroutable" as 0x07 just after CJDNS or to change those loops and assumptions because it would bloat this PR too much.

So I introduced a second enum but made it private inside CNetAddr and named it BIP155... to denote that it contains just the networks mentioned in BIP155 and nothing else.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 20, 2020

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@naumenkogs
Copy link
Contributor

Concept ACK. WIll do a good review later.

@leto
Copy link
Contributor

leto commented Sep 11, 2020

utACK

It's important to support new Tor service version 3 and adding support for i2p and cjdns is really awesome 👍

@practicalswift
Copy link
Contributor

Concept ACK

@vasild
Copy link
Contributor Author

vasild commented Sep 18, 2020

Rebased on latest #19845

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK 99047b0771f8dfc85640c095b8a331f4746e63e3, tested on Linux Mint 20 (x86_64).

Compare RPC and GUI output:

$ src/bitcoin-cli -netinfo 2
Bitcoin Core v0.20.99.0-336ba7ca7 - 70016/Satoshi:0.20.99/

Peer connections sorted by direction and min ping
<-> relay   net mping   ping send recv  txn  blk uptime id address                                                        
out  full onion   271    313    2    1    0           6  6 mwmfluek4au6mxxpw6fy7sjhkm65bdfc7izc7lpz3trewfdghyrzsbid.onion 
out  full onion   272    272    1    8    0           7  2 rp7k2go3s5lyj3fnj6zn62ktarlrsft2ohlsxkyd7v3e3idqyptvread.onion 
out  full onion   281    281    2    2    0           6 11 mwg3wapk3trgyg3e.onion:8333                                    
out  full onion   311    337    8    8    0           6 10 jzovs6u3fjpdrtow.onion:8333                                    
out  full onion   337    404    1    1    3           6  5 lw6hmfiyqkneb7biux5maaxztcizqnryjtrytwtsynj6szfwuo7dykyd.onion 
out  full onion   346    410    1    7    1           7  1 h25e66x235hdrwgw.onion:8333                                    
out  full onion   361    416    1    2    0           6 12 3ibzyvezkciodlfj.onion:8333                                    
out  full onion   404    678    4    5    0    1      6  8 vuswbtydwykwd5faap72ayjrchxz3wzezsi5tobahjedhf2fbg3dj7qd.onion 
out  full onion   408    542    2    2    0           6  4 esorot4j7z32pr7fm62pjgqhm2g5a26aaucesohjcy3csjewgmrvvmyd.onion 
out block onion   473    473   67    9                5 15 uleur3cw27x53j64.onion:8333                                    
out  full onion   501    634    6    6    0           6  7 wizbit5555bsslwv4ctronnsgk5vh2w2pdx7v7eyuivlyuoteejk7lid.onion 
out  full onion   539    539    2    1    0           6  3 yp77p2jxvz5nzza5.onion:8333                                    
out  full onion   546    859    2    2    0           6  9 e6pa22pv6k66lb7w.onion:8333                                    
out  full onion   623    623    3    6    0           5 13 blbmcefvms57el3f.onion:8333                                    
out  full onion   639    691    3    2    0    6      7  0 kpgvmscirrdqpekbqjsvw5teanhatztpp2gl6eee4zkowvwfxwenqaid.onion 
out block onion   669   1196   59   59                5 16 4opclnv4bgcpyano.onion:8333                                    
out  full onion  1595   2047    2    1                5 14 djhudr2ovodzeyv7.onion:8333                                    
                   ms     ms  sec  sec  min  min    min

        ipv4    ipv6   onion   total  block-relay
in         0       0       0       0       0
out        0       0      17      17       2
total      0       0      17      17       2

Local addresses
i4ezhlel222uleirryjorb66b2wtn5ttbs6ixqciqebg2zqand6de4qd.onion  port  8333     score      

Screenshot from 2020-09-26 17-16-05

UPDATE: the column width in the GUI just need to be adjusted :)

@vasild
Copy link
Contributor Author

vasild commented Sep 28, 2020

Added more tests.

@vasild
Copy link
Contributor Author

vasild commented Sep 28, 2020

Rebased on latest #19845

@hebasto
Copy link
Member

hebasto commented Sep 29, 2020

Mind rebasing?

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

vasild and others added 2 commits September 29, 2020 10:30
Change the serialization of `CAddrMan` to serialize its addresses
in ADDRv2/BIP155 format by default. Introduce a new `CAddrMan` format
version (3).

Add support for ADDRv2 format in `CAddress` (un)serialization.

Co-authored-by: Carl Dong <[email protected]>
Introduce a new message `sendaddrv2` to signal support for ADDRv2.
Send the new message immediately after sending the `VERACK` message.

Add support for receiving and parsing ADDRv2 messages.

Send ADDRv2 messages (instead of ADDR) to a peer if he has
advertised support for it.

Co-authored-by: Carl Dong <[email protected]>
@vasild
Copy link
Contributor Author

vasild commented Sep 29, 2020

Rebased now that #19845 is merged.

@vasild
Copy link
Contributor Author

vasild commented Sep 29, 2020

Two more commits remain from this PR to be merged:

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

they are included in #19954.

Closing this as superseded by #19954.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.