-
Notifications
You must be signed in to change notification settings - Fork 38.8k
p2p: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified #20018
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
p2p: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified #20018
Conversation
|
Concept ACK. Perhaps we also want a warning that -seednode will be ignored in -connect mode? |
42c6b67 to
8208494
Compare
|
Thank you, @sipa. I've added a log warning as well as a test for it. |
8208494 to
8678a6f
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
robot-dreams
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 noticing this case and cleaning it up!
0bbc945 to
50abb30
Compare
|
Comments above have been addressed. This PR is ready for review. |
|
Thanks for addressing! One more question: if someone manually sets I'm asking since it looks like |
50abb30 to
a1467aa
Compare
|
Great question, @robot-dreams! With
Yes, I think it's worth adding a warning for the case: Rebased with master. |
a1467aa to
c9c6388
Compare
robot-dreams
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.
utACK c9c6388b7747032615cb550036d330fb12beedc7
Thanks for looking into the interactions so thoroughly!
c9c6388 to
a16825b
Compare
|
utACK a16825b42190a2780baeb7a262c9b6cda57a2755 |
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 Concept ACK
Could/should the warnings be placed in the -connect section of InitParameterInteraction() and logged at the top along with the other parameter interactions?
$ ./src/bitcoind -regtest -connect=fakeaddress1 -seednode=fakeaddress2
2020-10-04T12:22:30Z Bitcoin Core version v0.20.99.0-a16825b421-dirty (debug build)
2020-10-04T12:22:30Z InitParameterInteraction: parameter interaction: -connect set -> setting -dnsseed=0
2020-10-04T12:22:30Z InitParameterInteraction: parameter interaction: -connect set -> setting -listen=0
src/init.cpp
Outdated
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.
maybe s/in -connect mode/when -connect is used/
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.
Done
src/init.cpp
Outdated
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.
maybe s/in -connect mode when/when -connect is used and/
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.
Done
src/init.cpp
Outdated
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 could have gone inside the condition right above.
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.
The condition above is true when connect.size() == 0 (happens in the -noconnect -seednode=fakeaddress test case) and the new condition is not.
I could move the whole condition inside as-is, but wouldn't gain in clarity or brevity.
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.
I guess @naumenkogs meant this:
if (connect.size() != 1 || connect[0] != "0") {
connOptions.m_specified_outgoing = connect;
if (!connOptions.vSeedNodes.empty()) {
LogPrintf("-seednode is ignored when -connect is used\n");
}
}
src/init.cpp
Outdated
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.
But this is true even if no -connect is configured? Then the warning is confusing...
Perhaps move this into the block above (same suggestion there)?
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.
Warning says -dnsseed is ignored. But it will be shown even if a user haven't touched -dnsseed at all, just when they configured a -proxy. Feels like bad UX.
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.
Reg. the first comment: If the configuration is -dnsseed=1 -proxy=X, ThreadDNSAddressSeed will queue ADDR_FETCH connections and they will get processed because ThreadOpenConnections will invoke ProcessAddrFetch with some frequency. (This will no longer happen when using -connect=X -dnsseed=1 -proxy=X after this PR is merged)
Reg. the second comment: You're right. If the configuration is -connect=X -proxy=Y, the log would print and the user might be confused. I have updated the code to check explicitly that the user set the arg. I have also added a test case to confirm the same.
|
I find it hard to navigate this PR and make sense of everything. |
a16825b to
0b59d7b
Compare
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.
Thank you for thorough and educational reviews, @jonatack, @naumenkogs ! I have pushed up changes and rebased master since since I had to force push anyway.
src/init.cpp
Outdated
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.
The condition above is true when connect.size() == 0 (happens in the -noconnect -seednode=fakeaddress test case) and the new condition is not.
I could move the whole condition inside as-is, but wouldn't gain in clarity or brevity.
src/init.cpp
Outdated
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.
Done
src/init.cpp
Outdated
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.
Reg. the first comment: If the configuration is -dnsseed=1 -proxy=X, ThreadDNSAddressSeed will queue ADDR_FETCH connections and they will get processed because ThreadOpenConnections will invoke ProcessAddrFetch with some frequency. (This will no longer happen when using -connect=X -dnsseed=1 -proxy=X after this PR is merged)
Reg. the second comment: You're right. If the configuration is -connect=X -proxy=Y, the log would print and the user might be confused. I have updated the code to check explicitly that the user set the arg. I have also added a test case to confirm the same.
src/init.cpp
Outdated
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.
Done
@jonatack I'd actually have liked that too, but the place it is right now also checks for |
@naumenkogs I can definitely do that if it makes sense for commit atomicity. Since the actual change is only removing the |
4609c75 to
b485325
Compare
1ba1285 to
03c2bff
Compare
|
Rebased. Ready for further review. |
|
Are you still working on this? |
|
@achow101 yes |
|
Mind doing a rebase, otherwise it will be harder to review, given all the other related changes in the meantime |
|
@MarcoFalke working through bip324 PRs to bring them up to date with the released draft and I'll get to the rebases right after that. |
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
I agree that the call to ProcessAddrFetch() is unnecessary when -connect is used - I don't see a use case for harvesting addresses that you'll never use.
Automatic rebase on master seems to work fine without any silent conflicts.
In principle, we could disable various other unnecessary things related to addr relay in -connect mode (e.g. sending out GETADDR messages) in follow-ups, but this would mean making the existing code more complicated and I'm not convinced that's worth it.
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.
If
-proxyis set, or if a seed domain does not supportx9.domain(which tests forNODE_NETWORK | NODE_WITNESS),getaddrcalls are made to the dns seed itself as a peer. i.e.ADDR_FETCHconnections to an address likednsseed.emzy.de.
I used to think the same, but @sipa explained to me that this is not what's happening: We don't make a ADDR_FETCH connection to a node run by the DNS seed, in fact the DNS seed operator does not even need to run a reachable bitcoind node. Instead, we connect to the peer that the DNS seed currently resolves to - which is basically just a random node on the network not under the control of the DNS seed operator, and it changes every once in a while (~30minutes?) for a given DNS seed.
Since this is a common misconception, I think it would be good to describe it not just here in the test code, but also in net (If you'd prefer not to do it here, I could open a PR).
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.
Oh yeah, he mentioned this to me as well. Embarrassingly, I forgot to update this PR. Updated this comment, added a comment in net and updated a PR comment from me to @robot-dreams as well to reflect this.
03c2bff to
bcb9541
Compare
bcb9541 to
2555a39
Compare
Thanks, @mzumsande! Rebased.
See my OP in the PR. I thought about this, but then realized that this would mean the node we are I agree though, if we want to do that at all, we do it in a followup. |
|
Code Review ACK 2555a39
Oops, missed this. I agree, fingerprinting is another good reason. I think in practice we'd often trust the node we |
vasild
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 2555a39
|
cc @ryanofsky from a settings / init pov. |
|
ACK 2555a39 |
…if -connect is specified 2555a39 p2p: ProcessAddrFetch(-seednode) is unnecessary if -connect is specified (Dhruv Mehta) Pull request description: If the user runs: `bitcoind -connect=X -seednode=Y`, I _think_ it is safe to ignore `-seednode`. A more populated `addrman` (via `getaddr` calls to peers in `-seednode`) is not useful in this configuration: `addrman` entries are used to initiate new outbound connections when slots are open, or to open feeler connections and keep `addrman` from getting stale. This is all done in a part of `ThreadOpenConnections` (below [this line](https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1803)) which is never executed when `-connect` is supplied. With `-connect`, `ThreadOpenConnections` will run [this loop](https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1785) and exit thread execution when interrupted. Reviewers may also find it relevant that when `-connect` is used, we [soft disable](https://github.com/bitcoin/bitcoin/blob/master/src/init.cpp#L800) `-dnsseed` in init.cpp perhaps for the same reason i.e. seeding is not useful with `-connect`. Running `ProcessAddrFetch` does not seem to have downside except developer confusion AFAICT. I was confused by this and felt it might affect other new bitcoiners too. If there is strong preference to not remove the line, I'd also be happy to just leave a comment there mentioning `ADDR_FETCH`/`-seednode` is irrelevant when used with `-connect`. If this change is accepted, the node will still make `getaddr` calls to peers in `-connect` and expand `addrman`. However, disabling those `getaddr` calls would leak information about the node's configuration. ACKs for top commit: mzumsande: Code Review ACK 2555a39 achow101: ACK 2555a39 vasild: ACK 2555a39 Tree-SHA512: 9187a0cff58db8edeca7e15379b1c121e7ebe8c38fb82f69e3dae8846ee94c92a329d79025e0f023c7579b2d86e7dbf756e4e30e90a72236bfcd2c00714180b3
If the user runs:
bitcoind -connect=X -seednode=Y, I think it is safe to ignore-seednode. A more populatedaddrman(viagetaddrcalls to peers in-seednode) is not useful in this configuration:addrmanentries are used to initiate new outbound connections when slots are open, or to open feeler connections and keepaddrmanfrom getting stale. This is all done in a part ofThreadOpenConnections(below this line) which is never executed when-connectis supplied. With-connect,ThreadOpenConnectionswill run this loop and exit thread execution when interrupted.Reviewers may also find it relevant that when
-connectis used, we soft disable-dnsseedin init.cpp perhaps for the same reason i.e. seeding is not useful with-connect.Running
ProcessAddrFetchdoes not seem to have downside except developer confusion AFAICT. I was confused by this and felt it might affect other new bitcoiners too. If there is strong preference to not remove the line, I'd also be happy to just leave a comment there mentioningADDR_FETCH/-seednodeis irrelevant when used with-connect.If this change is accepted, the node will still make
getaddrcalls to peers in-connectand expandaddrman. However, disabling thosegetaddrcalls would leak information about the node's configuration.