-
Notifications
You must be signed in to change notification settings - Fork 38.7k
[test, init] DNS seed querying logic #22098
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
Conversation
5664a2f to
75ee018
Compare
lsilva01
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.
Tested ACK 75ee018 on Ubuntu 20.04.
willcl-ark
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.
This looks like a good change which clears up the behaviour of some contradictory flag combinations and more thoroughly tests the dns fallback behaviour. tACK each commit in the series.
Logic added in ea0ad08 is exercised by the new test test/functional/p2p_dns_seeds.py
|
Thanks for adding tests for this functionality. This goes as far as can be reasonably expected without emulating a DNS server in the tests 😅 Code review ACK 75ee018 |
mzumsande
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.
Concept ACK. Some non-critical suggestions below, although maybe it's worthwile speeding the test up a bit.
jnewbery
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 75ee018
Thanks for adding these tests!
6108630 to
a8834fa
Compare
|
thank you for the reviews @lsilva01, @willcl-ark, @laanwj, @mzumsande & @jnewbery! I've incorporated all the review comments (diff). I also changed the regtest dns seed to be |
|
Code review ACK a8834fa |
kristapsk
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 a8834fa0513d6bfcd4dfc759bbb841c02fcf8517
|
Code Review ACK a8834fa0513d6bfcd4dfc759bbb841c02fcf8517 |
practicalswift
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.
Concept ACK
Thanks for improving testing!
I left some review comments on small changes that could further reduce the risk of accidental external communication :)
|
This probably needs a rebase / exception added for the new test after #22490 was merged. |
This commit introduces a DNS seed to the regest chain params in order to add coverage to the DNS querying logic. The first test checks that we do not query DNS seeds if we are able to succesfully connect to 2 outbound connections. Since we participate in ADDR relay with those connections, including sending a GETADDR message during the VERSION handshake, querying the DNS seeds is unnecessary. Co-authored-by: Martin Zumsande <[email protected]>
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]>
…nd -forcednsseed -dnsseed determines whether we run ThreadDNSAddressSeed and potentially query the DNS seeds for addresses. -forcednsseed tells the node to force querying the DNS seeds even if we have sufficient addresses or current connections. This commit disallows starting up with explicitly conflicting parameters.
Test that passing conflicting parameters for the two causes a startup error. This logic also impacts -connect, which soft sets -dnsseed, so add a test for that too.
When starting up with a populated addrman, ThreadDNSAddressSeed adds a delay during which time the node may be able to connect to some peers. This commit tests the delay changes based on the number of addresses in the addrman.
a8834fa to
82b6f89
Compare
|
thanks for the reviews @kristapsk & @practicalswift! & for the re-reviews @jnewbery & @mzumsande @practicalswift @mzumsande
I locally rebased & confirmed that the tests still pass, but opted not to push the rebase here to make it easier to re-review. But lmk if you think it would be better to rebase & set |
Excellent! It is outside of the scope of this PR but I think it would make sense to err on the safe side and specify all seed domain names with an ending dot to make them unambiguous. In other words … vSeeds.emplace_back("seed.bitcoin.sipa.be."); // Pieter Wuille, only supports x1, x5, x9, and xd… instead of the current … vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xdThe former is guaranteed to be interpreted as The case I'm thinking about is if Looking up In other words I haven't tried it myself but if I'm thinking correctly here then adding I guess an alternative way to fix this could be to add the ending dot (if missing) when building the host string: diff --git a/src/net.cpp b/src/net.cpp
index 073643fb7..c68c497ea 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1714,7 +1714,7 @@ void CConnman::ThreadDNSAddressSeed()
std::vector<CNetAddr> vIPs;
std::vector<CAddress> vAdd;
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
- std::string host = strprintf("x%x.%s", requiredServiceBits, seed);
+ std::string host = strprintf("x%x.%s.", requiredServiceBits, seed);
CNetAddr resolveSource;
if (!resolveSource.SetInternal(host)) {
continue;Some background context from https://bugzilla.mozilla.org/show_bug.cgi?id=134402: |
|
all review comments have been addressed.
@practicalswift, very interesting! thanks for digging in & sharing your findings! I'll have to learn more myself but this seems like a good idea. Shall we open an issue? |
|
ACK 82b6f89
not necessary, I didn't realize that it would work, but your explanation makes sense. |
Feel free to open an issue if you feel for it: I'm afraid I won't be able to find time to work on this any time soon, but I'd be glad to help out with review :) An
|
A simpler way that should reproduce the issue without having to make any changes to If my thinking is correct that should make the DNS seeding queries return |
|
reACK 82b6f89 |
|
The DNS querying logic and related config options certainly are somewhat convoluted / confusing. This is not helped by the fact that certain options (soft)-set other options, or sometimes behave un-intuitively. I think there is definitely scope to improve this code further going forward. |
|
cc @ajtowns |
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
This PR adds a DNS seed to the regtest chain params to enable testing the DNS seed querying logic of
CConnman::ThreadDNSAddressSeedand 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
-dnsseedand-forcednsseed.The tests include:
-connect,-dnsseedand-forcednsseed-forcednsseedHuge props to mzumsande for identifying the timing technique for testing successful connections before running
ThreadDNSAddressSeed🙌🏽