-
Notifications
You must be signed in to change notification settings - Fork 75
implementation plan for peer & content routing with signed address records #78
Comments
Thanks @yusefnapora for the context dump, this is really helpful. Below are some of my thoughts on our use of Go interfaces generally and with the DHT/ContentRouting specifically that hopefully are useful (but idk you tell me 😄):
|
These are great points, thanks @aschmahmann! As someone that's coming more or less straight from Java to Go, the interface thing has definitely been tripping me up. I think that defining and using an interface instead of the I also found this blog post about go interfaces that's pretty good. In the Upgrading Interfaces section they recommend defining a new interface with methods you want to add instead of adding methods to an existing one. Then the caller has to do a type assertion to see if the new interface is supported. I could potentially make it so that the Peerstore changes in #73 are non-breaking changes by adopting that pattern. I'm intrigued by the idea of moving go-libp2p away from "global" interfaces... one of the things that's been tricky for me as I'm learning how to navigate go-libp2p is that it's not obvious where the implementations for a given interface live and where all the consumers are. That's partly because things are spread out into a lot of repos, but moving towards defining interfaces at the point of use would probably help. Sounds like a pretty big refactor, but definitely worth thinking about 🤔 |
just had a sync call with @raulk, where we talked over this issue and realized that we may not need interface changes here. Instead, we can isolate the signed vs unsigned record exchange within the DHT implementation, and callers will still use the existing If a consumer of those interfaces really cares about only having signed addresses, they should be able to enable a "strict mode" flag, which will prevent the DHT from returning unsigned addrs. I'm going to close this issue, since it looks like we won't need to change the -core interfaces or peer.AddrInfo. I'll open a new planning issue soon in the -kad-dht repo to track the actual implementation changes needed. Thanks again for the input @aschmahmann :) |
I've been trying to figure out how to integrate the signed routing records (or maybe signed address records? names are hard) into the DHT and other peer routing systems in go-libp2p. This issue is just a place to think out loud about it and get feedback from other people before I start diving in too deep.
In my opinion so far, it looks like the simplest way to go would be to add another field (containing the signed record) to the peer.AddrInfo struct, since it's used in all the places where we'd like to add signed addresses - mostly the PeerRouting and ContentRouting interfaces, but also in the kad-dht internals.
Extending the
AddrInfo
struct with a new field would mean that we wouldn't need to define newSignedPeerRouting
andSignedContentRouting
interfaces; we could just use the existing interfaces and have the implementations include the signed address records if they were able to find them, and leave the fieldnil
if they can't. Callers who care about signed addresses could use the new field,and callers who don't could ignore it.
This seems like it would make updating the DHT much simpler than defining new interfaces that are essentially copies of
PeerRouting
andContentRouting
but with a different return type. For example, this gnarly findProvidersAsync implementation could just be tweaked to include signed records in the results, rather than having to duplicate the whole method to return signed records instead ofAddrInfo
s.However, it turns out that adding a field to a struct is a breaking change, since people might be embedding your struct in their own types and you can't guarantee that the new field won't collide with one of theirs. Since we're making other breaking changes to the
Peerstore
interface (in #73) to add signed records in the first place, maybe this isn't a huge deal if we communicate it clearly.The bigger question is whether we really do want separate interfaces for finding signed peer addresses for design / architecture reasons. Maybe conflating the two is a bad idea, and they are different enough to warrant separate interfaces. In my mind they seem really related - when I call
FindPeer
, I just want to know the best way to connect to the target peer, and it seems like that should include the signed addresses if possible.One argument for making them separate is that I might only want signed addresses, and I don't want calls to
FindProvidersAsync
to give me a bunch of useless unsigned results.Another reason is that
peer.AddrInfo
seems to be used in a lot of places, and shoving a field in there because it's convenient for this one use case might be rude 😄So, if we're not extending
peer.AddrInfo
, it seems like we want to define something like this:Where
SignedRoutingState
is the address record defined in #73, which contains the original signed envelope along with an "unpacked" address list.Anyway, that's where my head is at. What do people think?
The text was updated successfully, but these errors were encountered: