Skip to content
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

Question about addr handling #1012

Closed
amitiuttarwar opened this issue Apr 19, 2021 · 2 comments
Closed

Question about addr handling #1012

amitiuttarwar opened this issue Apr 19, 2021 · 2 comments

Comments

@amitiuttarwar
Copy link

Hi! I'm proposing some changes to addr handling in Bitcoin Core, and trying to ensure there will not be negative consequences for other clients on the network. For more information about the changes, please see my mailing list post. The crux is that, if the changes are accepted, bitcoin core would stop sending addr messages to peers who don't "indicate interest" aka initiate an addr-related message (addr, addrv2, getaddr, or sendaddrv2).

I'd like to ensure that bcoin clients will initiate an addr related message to outbound peers. I've looked in the code and believe the software plays nice, and am looking for a +1 from someone more familiar with this project.

My understanding of the bcoin code is that upon opening a connection, the node will advertise its own address & usually send a getaddr message, based on the functionality in handleOpen. If this understanding is accurate, there should be no compatibility issues with my proposed changes. Does this seem right?

Thanks in advance!
Amiti

@pinheadmz
Copy link
Member

Thanks so much for reaching out Amiti! Yes I believe your analysis is correct, bcoin sends getaddr packets when it connects to peers. If it is configured to accept incoming connections (listen: true) it will also send an addr with its own public host address. Just to be totally certain, I built your bitcoin branch from commit amitiuttarwar/bitcoin@0c194ffafd and connected in local regtest to bcoin master at commit f1abba5

Bitcoin Core log messages:

2021-04-20T14:58:37Z Added connection peer=1
2021-04-20T14:58:37Z connection from 127.0.0.1:52291 accepted
2021-04-20T14:58:37Z received: version (99 bytes) peer=1
2021-04-20T14:58:37Z sending version (102 bytes) peer=1
2021-04-20T14:58:37Z send version message: version 70016, blocks=200, us=[::]:0, peer=1
2021-04-20T14:58:37Z sending verack (0 bytes) peer=1
2021-04-20T14:58:37Z receive version message: /bcoin:2.1.2/: version 70015, blocks=200, us=127.0.0.1:18444, peer=1
2021-04-20T14:58:37Z received: verack (0 bytes) peer=1
2021-04-20T14:58:37Z sending sendheaders (0 bytes) peer=1
2021-04-20T14:58:37Z sending sendcmpct (9 bytes) peer=1
2021-04-20T14:58:37Z sending sendcmpct (9 bytes) peer=1
2021-04-20T14:58:37Z sending ping (8 bytes) peer=1
2021-04-20T14:58:37Z sending feefilter (8 bytes) peer=1
2021-04-20T14:58:37Z received: addr (31 bytes) peer=1
2021-04-20T14:58:37Z received: sendcmpct (9 bytes) peer=1
2021-04-20T14:58:37Z received: getaddr (0 bytes) peer=1
2021-04-20T14:58:37Z received: pong (8 bytes) peer=1
2021-04-20T14:58:37Z received: getblocks (645 bytes) peer=1
2021-04-20T14:58:37Z getblocks -1 to end limit 500 from peer=1
...
2021-04-20T14:58:39Z sending addr (31 bytes) peer=0

bcoin log messages:

[info] (net) Adding loader peer (127.0.0.1:18444).
[info] (net) Connected to 127.0.0.1:18444.
[info] (net) Received version (127.0.0.1:18444): version=70016 height=200 services=10000001001 agent=/Satoshi:0.21.0/
[debug] (node) Added time data: samples=1, offset=0 (0 minutes).
[debug] (peer) Received verack (127.0.0.1:18444).
[debug] (peer) Version handshake complete (127.0.0.1:18444).
[info] (peer) Initializing witness compact blocks (127.0.0.1:18444).
[info] (peer) Peer initialized compact blocks (mode=0, version=2) (127.0.0.1:18444).
[debug] (peer) Peer sent a duplicate sendcmpct (127.0.0.1:18444).
[spam] (peer) Serving 1 headers to 127.0.0.1:18444.
[debug] (peer) Sending getblocks (hash=02cfe6bd0f8cfe53b0ed70757f716f6018f0cd9d158a476ccc6ef4ca1a291d8c, stop=null).
...
[info] (net) Received 1 addrs (hosts=4, peers=2) (127.0.0.1:18444).

@amitiuttarwar
Copy link
Author

awesome!! thank you for this thorough confirmation :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants