-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
autorelay: curtail addrsplosion #598
Conversation
I think we might want to try parallel connects, as many of the relays in the discovered set (I have 183) appear to be dead. |
If not parallel connects, at least parallel |
Added a relay address set clean up phase to curtail addrsplosion. |
Maybe 15s to |
I will revert it to 30s. |
Reworked the relay selection logic to perform |
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.
Almost there. Please ping me on IRC/slack when you want me to review this again (trying to shorten my review cycles a bit..).
ma.ForEach(a, func(c ma.Component) bool { | ||
switch c.Protocol().Code { | ||
case ma.P_TCP, ma.P_UDP: | ||
port = int(binary.BigEndian.Uint16(c.RawValue())) |
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.
Ideally, this would only bother with the first port (although multiple ports isn't currently an issue except for relay addresses which we should be ignoring anyways).
p2p/host/relay/autorelay.go
Outdated
case qr := <-resultCh: | ||
rcount++ | ||
if qr.err == nil { | ||
pi := cleanupAddressSet(qr.pi) |
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.
Ah, you mean we won't advertise addresses like /ip4/.../tcp/ADDRSPLODE/p2p/QmRelay/p2p-circuit/p2p/QmMe
? Got it.
p2p/host/relay/autorelay.go
Outdated
case qr := <-resultCh: | ||
rcount++ | ||
if qr.err == nil { | ||
pi := cleanupAddressSet(qr.pi) |
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.
Although, if we're going through all this trouble for that, I really wish we could just wait for the relay to tell us its addresses.
Note: If we actually had a reserve, the relay would return the addresses it wants us to use in response to the reserve command.
(but oh well)
…ss set findRelays cleans up address sets now for addrsplosion, and this removes private addrs as well.
WRT #598 (comment) The bad peer addresses will already get put into the peerstore anyways so this patch won't actually help fix dialing relays. This patch will allow us to trim down the address list auto-relay users announce but a better solution might be to re-calculate In terms of this code, @vyzo and I discussed generalizing it and using it from within either the dialer and/or the peerstore. Specifically, we can use the addrsplosion detection logic to trim down the set of addresses we're dialing. However, the current heuristics around circuit and private addresses obviously won't generalize (although we should drop addresses of the form So, the question is, is merging this patch worth it? IMO, not really given that it doesn't affect dialing and there's an (IMO) better option on the advertising end. |
So the patch fixes two problems with the current code:
|
Wrt to moving forward, we can stop tracking the relay addrs discovered by |
I have updated the code to dynamically compute the relay address set on demand. |
- select 25 of 50 relays instead of 20 - increase connect timeout to 30s
I have significantly simplified the patch, removing the contentious parallel query selection logic. |
the presence of stashed query results from discovery in the peerstore _biases_ the selection towards fully DHT nodes, which penalizes dedicated relays.
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 correct.
Relays, as discovered in the DHT, are addrsploded. The current (pre-)computation of advertised relay addrs fails to account for this fact, resulting in the advertisement of many dead addresses. In addition, many relays discovered in the DHT are actually dead.
This patch adds logic to deal with the situation
findRelays
that deals with the case of no live relays in the discovered set.Note: the patch was originally much more extensive, adding a complex relay selection logic that tried to parallelize to deal with dead relays. That proved to be contentious, and biased against dedicated relays, so it has been reverted.