-
Notifications
You must be signed in to change notification settings - Fork 38.8k
[net] Minor improvements to addr caching #25096
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
…ddr cache randomizer
|
Concept ACK |
1968c8a to
4df29c9
Compare
|
Concept ACK |
4df29c9 to
224d765
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
|
Concept ACK |
224d765 to
f5e1269
Compare
|
utACK f5e1269fbeaaf37fdb3945381231d5ff9834e42e |
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.
Code Review ACK f5e1269fbeaaf37fdb3945381231d5ff9834e42e
If it was somehow possible for inbound peers to make us generate additional bind addresses, this could be abused to make us create a lot of caches, but I don't think this is possible in any way.
f5e1269 to
292828c
Compare
|
Thanks @mzumsande for the review, I took both of your suggestions. |
|
utACK 292828c |
|
Code Review ACK 292828c |
|
utACK 292828c |
| def set_test_params(self): | ||
| self.num_nodes = 1 | ||
| # Start onion ports after p2p and rpc ports. | ||
| port = PORT_MIN + 2 * PORT_RANGE |
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.
pretty sure the tests only pass by accident? Locally they fail for me:
./test/functional/test_runner.py p2p_getaddr_caching feature_proxy feature_bind_extra p2p_add_connections
p2p_add_connections.py | ✓ Passed | 7 s
feature_bind_extra.py | ✖ Failed | 1 s
feature_proxy.py | ✖ Failed | 1 s
p2p_getaddr_caching.py | ✖ Failed | 20 s
The basic idea is that all port ranges for all tests are fully assigned once the test_runner starts. Using the same range for different tests is asking for collisions.
One option to fix this would be to start a third range for "other" ports or just use one of the 12 ports assigned to each test (initially intended to be used by the test nodes itself).
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.
Oops sorry about that, will have a PR up shortly...
…getaddr_caching.py ea54ba2 [test] Fix port collisions caused by p2p_getaddr_caching.py (dergoegge) f9682e7 [test_framework] Set PortSeed.n directly after initialising params (dergoegge) Pull request description: This PR fixes the issue mentioned [here](bitcoin/bitcoin#25096 (comment)), to avoid port collisions between nodes spun up by the test framework. Top commit has no ACKs. Tree-SHA512: ec9159f0af90db636f7889d664c24e1430cf2bcb3c02a9ab2dcfe531b2a4d18f6e3a0f8ba73071bdf2f7db518df9d5d86a9cd06695e67644d20fe4515fac32b7
fa7a711 test: Fix out-of-range port collisions (MacroFake) Pull request description: Otherwise the test will fail if two tests running in parallel use the same port. See bitcoin/bitcoin#25096 (comment) and bitcoin/bitcoin#25312 ACKs for top commit: dergoegge: ACK fa7a711 - This gets rid of some rather arbitrary choices for ports in some of our functional tests that can cause port collisions across test runs, resulting in intermittent failures. Tree-SHA512: ac73da8a498230b992ab12e1ee3c4ff3d868cd63c00d2c71537d156cb7c8f8be8598ec574646b17c5a44ae3ac5bb54bf29d300f054a36cec6f6ce8054a0da0a4
292828c [test] Test addr cache for multiple onion binds (dergoegge) 3382905 [net] Seed addr cache randomizer with port from binding address (dergoegge) f10e80b [net] Use ConnectedThroughNetwork() instead of GetNetwork() to seed addr cache randomizer (dergoegge) Pull request description: The addr cache id randomizer is currently supposed to be seeded with the network of the inbound connection and the local socket (only the address is used not the port): https://github.com/bitcoin/bitcoin/blob/a8098f2cef53ec003edae91100afce564e9c6f23/src/net.cpp#L2800-L2804 For inbound onion connections `CNode::addr.GetNetwork()` returns `NET_UNROUTABLE` and `CNode::addrBind` is set to `127.0.0.1:<onion bind port>`. This results in the same addr cache for all inbound connections on 127.0.0.1 binds. To avoid the same addr cache across all onion and other 127.0.0.1 binds, we should seed the addr cache randomizer with the correct network for inbound onion connections (using `CNode::ConnectedThroughNetwork()`) as well as the port of `CNode::addrBind`. ACKs for top commit: sipa: utACK 292828c mzumsande: Code Review ACK 292828c naumenkogs: utACK 292828c Tree-SHA512: d0be13bab6bc121c2926d4b168687f6c2ed4ce0c9dd19be71eb4886adeba8afc3daacdc4e232a0ba3b03a89d69b618abc5595b69abd1ad0c476d825bc6ea1f9f
…caching.py ea54ba2 [test] Fix port collisions caused by p2p_getaddr_caching.py (dergoegge) f9682e7 [test_framework] Set PortSeed.n directly after initialising params (dergoegge) Pull request description: This PR fixes the issue mentioned [here](bitcoin#25096 (comment)), to avoid port collisions between nodes spun up by the test framework. Top commit has no ACKs. Tree-SHA512: ec9159f0af90db636f7889d664c24e1430cf2bcb3c02a9ab2dcfe531b2a4d18f6e3a0f8ba73071bdf2f7db518df9d5d86a9cd06695e67644d20fe4515fac32b7
The addr cache id randomizer is currently supposed to be seeded with the network of the inbound connection and the local socket (only the address is used not the port):
bitcoin/src/net.cpp
Lines 2800 to 2804 in a8098f2
For inbound onion connections
CNode::addr.GetNetwork()returnsNET_UNROUTABLEandCNode::addrBindis set to127.0.0.1:<onion bind port>. This results in the same addr cache for all inbound connections on 127.0.0.1 binds.To avoid the same addr cache across all onion and other 127.0.0.1 binds, we should seed the addr cache randomizer with the correct network for inbound onion connections (using
CNode::ConnectedThroughNetwork()) as well as the port ofCNode::addrBind.