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
fix: resolve DNS/hostnames for signer node_host config #4475
Conversation
Changes work as expected in local e2e testing using hostnames
|
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.
Not NACKing this outright since it might be workable pending some deeper digging, but a decisive advantage of keeping SocketAddr
over String
for node hosts is that a DNS resolution won't stall the calling thread. Right now, DNS resolution in Rust is synchronous -- the implementation of ToSocketAddrs
for (&str, u16)
and friends does a blocking call to gethostbyname(3)
. This can lead to inexplicable delays every time you try to send data to a host named by a DNS hostname instead of an IP address.
Most systems that use DNS avoid this through caching, but I don't know what Rust does here. Does the ToSocketAddrs
implementation cache DNS names? If so, for how long? Can the policy be changed by the operator? Where is the policy that enforces this -- for example, is it the host's libc
config? Should we cache DNS names? (the Stacks node does this directly by running ToSocketAddrs
calls in a separate thread, for example).
@jcnelson this is fixing the issue with using DNS at all. Whatever dns caching or similar optimizations should be in a different issue. |
Rust just uses getaddrinfo in libc -- this seems like actually the "right" thing. Caching is controlled by the OS in this case, and adding a cache on top of that removes that control. |
Also, if the provided address can be parsed as an IPv4 or IPv6 address - no DNS resolution takes place From https://doc.rust-lang.org/src/std/net/socket_addr.rs.html#251-268
|
Okay, these two facts are what I needed to be certain of. Approving... |
I am seeing a lot of build errors mostly due to clones. As soon as those are addressed, will approve. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #4475 +/- ##
===========================================
- Coverage 82.92% 60.03% -22.90%
===========================================
Files 453 453
Lines 325610 325579 -31
Branches 318 318
===========================================
- Hits 270010 195447 -74563
- Misses 55592 130124 +74532
Partials 8 8
... and 291 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
Fixes #4466