-
Notifications
You must be signed in to change notification settings - Fork 38.6k
net: ignore block-relay-only peers when skipping DNS seed #22013
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
net: ignore block-relay-only peers when skipping DNS seed #22013
Conversation
|
utACK fe3d17d
Lines 468 to 485 in eb4df9a
|
|
Oh good catch. Concept ACK |
|
ACK fe3d17d, this impacts the very common case where we stop/start a node, persisting anchors & have a non-empty addrman (although, to be clear, wouldn't be particularly problematic in the common cases where the addrman has valid addresses) I tried to figure out if I could write a functional test to cover this code path, but seems like a no go- I can add outbound-block-relay only connections & then shut down the node to persist them to anchors, but they can't reconnect before hitting |
|
ACK fe3d17d
I think the main issue is that this code is inside of a loop over the DNS seeds, and regtest doesn't have any. If there was a unreachable dummy dns seed for regtest, this could be tested: |
|
Concept ACK Change in fe3d17d makes sense however I was not able to reproduce the issue by compiling master branch. Not sure if I am testing it correctly.
|
|
@prayank23 In order to hit this on testnet, you need to have a non-empty addrman, but with no valid addresses - the following should work if you start with empty peers.dat and two good anchors: In the second run, you'll have two block-only peers but will never query a DNS seeds on master - whereas on this branch you will. |
yup, this was the approach I took- added dummy seeds to regtest chain params & from the test made sure addrman has addresses & was asserting against log messages. the step I haven't been able to figure out is adding the connections during the sleep, with the test framework timing playing nicely with bitcoind timing. the branch is a bit of a mess, but lmk if you'd like me to clean it up and share- very possible I'm missing a viable solution! |
|
@mzumsande these manual test instructions are quite useful; I might test it next week. @amitiuttarwar maybe mention those in the PR description, so it's a bit easier to find with |
|
@amitiuttarwar See mzumsande@237d754 for what I did to test this PR. But I have no idea if adding dummy seeds to regtest is viable or breaks anything... |
|
Thanks @mzumsande I was able to reproduce the issue.
Things that I tried in INVALID ADDRESS:
debug.log (DNS seeding was skipped because of peer=1 which is a block-relay-only connection) Logs had lot of connections attempts for invalid peer: bitcoin.conf |
|
I retarted bitcoind few times to see if something changes. It recovered, used DNS seed and had outbound full relay connections. |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK fe3d17d
ghost
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tACK fe3d17d
|
opened #22098 based on the convo here. huge props @mzumsande for figuring out the technique for timing around DNS logic with block-relay-only vs full-outbound connections 👏 the second commit on that PR 3548b571521b3f0693bbba39677344a626a406c5 fails prior to these changes. |
When a node is able to properly shutdown, it will persist its block-relay-only connections to the addrman. On startup, it will attempt to reconnect to these anchors. Since block-relay-only connections do not participate in ADDR relay, succesful connections are insufficient to skip querying the DNS seeds. This test fails prior to the changes in bitcoin#22013. Co-authored-by: Martin Zumsande <[email protected]>
Github-Pull: bitcoin#22013 Rebased-From: fe3d17d
When a node is able to properly shutdown, it will persist its block-relay-only connections to the addrman. On startup, it will attempt to reconnect to these anchors. Since block-relay-only connections do not participate in ADDR relay, succesful connections are insufficient to skip querying the DNS seeds. This test fails prior to the changes in bitcoin#22013. Co-authored-by: Martin Zumsande <[email protected]>
82b6f89 [style] Small style improvements to DNS parameters (Amiti Uttarwar) 4c89e24 [test] Test the delay before querying DNS seeds (Amiti Uttarwar) 6395c8e [test] Test the interactions between -forcednsseed and -dnsseed (Amiti Uttarwar) 6f6b7df [init] Disallow starting up with conflicting paramters for -dnsseed and -forcednsseed (Amiti Uttarwar) 26d0ffe [test] Test -forcednsseed causes querying DNS seeds (Amiti Uttarwar) 3585145 [test] Test the interactions between -connect and -dnsseed (Amiti Uttarwar) 75c05af [test] Test logic to query DNS seeds with block-relay-only connections (Amiti Uttarwar) 9c08719 [test] Introduce test logic to query DNS seeds (Amiti Uttarwar) Pull request description: This PR adds a DNS seed to the regtest chain params to enable testing the DNS seed querying logic of `CConnman::ThreadDNSAddressSeed` and relevant startup parameters. Adds coverage for the changes in #22013 (and then some). The main behavioral change to bitcoind is that this PR disallows starting up with conflicting parameters for `-dnsseed` and `-forcednsseed`. The tests include: * parameter interactions of different combinations of `-connect`, `-dnsseed` and `-forcednsseed` * the delay before querying DNS seeds depending on how many addresses are in the addrman * the behavior of `-forcednsseed` * skipping DNS querying if we have outbound full relay connections & not block-relay-only connections Huge props to mzumsande for identifying the timing technique for testing successful connections before running `ThreadDNSAddressSeed` 🙌🏽 ACKs for top commit: mzumsande: ACK 82b6f89 jnewbery: reACK 82b6f89 Tree-SHA512: 9f0c29bfbf99426727e79c0a25606ae09deab91a92e3c5cee7f84c3ca7503a8ac9ab85a85c51841d40b164ef8c991326070f0b2f41d075fb7985df26f6e95d6d
82b6f89 [style] Small style improvements to DNS parameters (Amiti Uttarwar) 4c89e24 [test] Test the delay before querying DNS seeds (Amiti Uttarwar) 6395c8e [test] Test the interactions between -forcednsseed and -dnsseed (Amiti Uttarwar) 6f6b7df [init] Disallow starting up with conflicting paramters for -dnsseed and -forcednsseed (Amiti Uttarwar) 26d0ffe [test] Test -forcednsseed causes querying DNS seeds (Amiti Uttarwar) 3585145 [test] Test the interactions between -connect and -dnsseed (Amiti Uttarwar) 75c05af [test] Test logic to query DNS seeds with block-relay-only connections (Amiti Uttarwar) 9c08719 [test] Introduce test logic to query DNS seeds (Amiti Uttarwar) Pull request description: This PR adds a DNS seed to the regtest chain params to enable testing the DNS seed querying logic of `CConnman::ThreadDNSAddressSeed` and relevant startup parameters. Adds coverage for the changes in bitcoin#22013 (and then some). The main behavioral change to bitcoind is that this PR disallows starting up with conflicting parameters for `-dnsseed` and `-forcednsseed`. The tests include: * parameter interactions of different combinations of `-connect`, `-dnsseed` and `-forcednsseed` * the delay before querying DNS seeds depending on how many addresses are in the addrman * the behavior of `-forcednsseed` * skipping DNS querying if we have outbound full relay connections & not block-relay-only connections Huge props to mzumsande for identifying the timing technique for testing successful connections before running `ThreadDNSAddressSeed` 🙌🏽 ACKs for top commit: mzumsande: ACK 82b6f89 jnewbery: reACK 82b6f89 Tree-SHA512: 9f0c29bfbf99426727e79c0a25606ae09deab91a92e3c5cee7f84c3ca7503a8ac9ab85a85c51841d40b164ef8c991326070f0b2f41d075fb7985df26f6e95d6d
Since #17428 bitcoind will attempt to reconnect to two block-relay-only anchors before doing any other outbound connections. When determining whether to use DNS seeds, it will currently see these two peers and decide "we're connected to the p2p network, so no need to lookup DNS" -- but block-relay-only peers don't do address relay, so if your address book is full of invalid addresses (apart from your anchors) this behaviour will prevent you from recovering from that situation.
This patch changes it so that it only skips use of DNS seeds when there are two full-outbound peers, not just block-relay-only peers.