-
Notifications
You must be signed in to change notification settings - Fork 225
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
Add provider record addresses to peerstore #870
Conversation
fixes issue #868
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.
LGTM
What is the point of this ? I mean the fact we are even passing the addresses in the add endpoint seems wrong and I doubt we do. |
The idea is to avoid the second lookup for network addresses after you've found the provider record. The routed host will still do the lookup for new addresses if it cannot connect to the peer. Up until now we relied on identify to keep the addresses around. IIRC @cortze's RFM showed improvement potential if we kept them around longer. I don't think at all that this is a bug or anything. This is just caching. |
@dennis-tra what does the add provider endpoint has to do with that ? When I add a provider the remote peer already know my addresses since I'm connected to it. |
Ok so, the provider store does indeed not store the addreses
I did checked that some addresses are sent over the wire and yes some are:
However this code is at least buggy because it fails to run the addresses through the address filter (using |
The add provider endpoint explicitly allows the client to associate addresses with the record.
I agree that, as things currently are, it probably doesn’t matter if we take the addresses from the identify exchange or from the wire message. They probably contain the same set of addresses. That’s not the point though. The thing that we want to address here is the TTL associated with the multiaddresses of that peer. However, I still think it’s better to take the explicitly passed multiaddresses from the request.
Not sure if I’m missing something but that is what we’re doing isn’t it? We’re storing the multihash -> PeerID mapping in a datastore and another mapping from PeerID to multiaddresses in the peerstore. We’re not storing any duplicate multiaddresses. When a peer requests a record we look up the peer IDs in the datastore and then the multiaddresses in the peerstore. We serve both information to the client. However, we stop serving multiaddresses after 30 min because the TTL is not properly updated. We want to continue serving the multiaddresses for much longer. This PR attempted to fix that. |
Yeah I wrote that before tracing the code. Still over the wire we send theses duplicates which is an ineficient use of resources.
We don't need to send the addresses over kad-dht to update the TTL. IMO This fix just makes thing worst because it incentivize clients to do the wrong thing and waste bandwidth, before it was a bug and we did nothing with theses addresses now you turned it in a feature ✨. // PseudoCode-Ish
addrs := dht.pstore.Addrs(p)
if f := dht.addrsFilter; f != nil {
addrs = dht.addrsFilter(addrs)
}
pstore.AddAddrs(p, addrs, dht.providerTTL) They both achieve the same thing except this allows us to stop sending maddrs along side add provider. Edit: the pseudo code that fetch run through the filter and add the addresses back-in is better IMO, because it only increase the cache on the addresses we want to cache. |
if len(pi.Addrs) < 1 {
logger.Debugw("no valid addresses for provider", "from", p)
continue
} I actually this is on purpose 🤦, forget what I said. Edit: new issue here #871 |
fixes #868