-
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
Design blueprint for signed peer records #761
Comments
Sweet, let me just echo back a couple points to make sure I get the implications. Record generation & dissemination
Peerstore
DHT
About this point:
Is it necessary to make any assumptions here? It seems like |
Ideally yes, but I don't want to overcomplicate your work. If it's simple, go for it.
We should register both protocols by default (
Yes, that would be ideal. The caveat is that current master is racy when it comes to identify:
The PR here: libp2p/go-libp2p-kad-dht#365 I would be ecstatic if you cherry-pick those changes into master (as well as the corresponding ones in the stabilize branch of go-libp2p), so we can bring this feature in and rely on it: |
It looks like the reason that
The AutoRelay and observed address changes we could issue events for, but it looks like the
So some kind of polling seems necessary to track changing NAT mappings that are outside of our control. We could potentially move the polling into the |
I've been working on making the cab, ok := someHost.Peerstore().(peerstore.CertifiedAddrBook)
// ok is always false After some poking around, I realized that this is because the type peerstore struct {
pstore.Metrics
pstore.KeyBook
pstore.AddrBook
pstore.ProtoBook
pstore.PeerMetadata
} Even if the You can make it work by adding the func NewPeerstore(kb pstore.KeyBook, ab pstore.AddrBook, pb pstore.ProtoBook, md pstore.PeerMetadata) pstore.Peerstore {
cab := ab.(pstore.CertifiedAddrBook)
return &peerstore{
KeyBook: kb,
AddrBook: ab,
CertifiedAddrBook: cab,
ProtoBook: pb,
PeerMetadata: md,
Metrics: NewMetrics(),
}
} This will fail if I think we might as well just make the breaking API change and add the methods to |
Thinking some more about the DHT changes. Is it a problem that the DHT can be configured with arbitrary protocol ID strings? I dug around a bit and found at least one project (0x-mesh) that's using a custom protocol ID for their DHT, which it seems like we encourage by letting people pass in their own ID strings in a config option. If we're making signed record support conditional on a specific protocol ID string, that will only work if people are using our default protocol IDs. Instead of checking against a fixed string, we could potentially add another option, e.g. That seems a bit awkward, but it would let us enable capabilities for a particular protocol ID without having to hard-code the exact ID string, and it would let downstream users customize their protocol IDs and still opt-in to the new capabilities. The other alternative that I can think of is to not make the behavior conditional on the protocol ID, and instead advertise signed record support in the DHT protobuf message. I've been thinking about how that could work and it isn't too terrible, but there are some edge cases to consider. For now I'm going to stick with defining a new protocol ID and ignore the custom protocol problem, but I'll try not to box myself in too much. |
@raulk I've been thinking some more about the proposal to have separate routing tables, either completely split between Either way seems like it will lead to "lenient mode" peers having an artificially restricted view of the network. With separate routing tables, two lenient peers interacting with each other will never share contact info for any "old-school" v1.0 peers, even though both of them are capable of interacting with the older peers. This could easily break the lookup path and lead to surprising results. For example, let's say that I'm a lenient peer and the content I want is stored only on an old-school Even if lenient peers query the closest peers in both routing tables, it's still problematic. Some of the peers in the Maybe this could work as an alternative:
I think this results in:
Does that make sense? |
I realized a lot of my worries above might be unfounded. I was thinking that lenient peers would always do a protocol negotiation dance where they'd first try I think that would allow separate routing tables to work without the weird lookup problems I was worried about. That said, I'd still prefer to have a single table if we can make it work, just from an implementation standpoint. There are a lot of places in the code where we assume a single table, and we'd be adding a decent amount of overhead by having to periodically random-walk over both. Edit after some digging: it looks like dialing a specific protocol will take some non-trivial modifications to the |
This issue outlines the design blueprint to implement Signed Peer Records, to serve a guidance for the implementation efforts underway.
Record crafting and dissemination:
LocalAddressesUpdated
event on the eventbus when we detect changes in our local address set.host.Addrs()
, rebuilds the record, and emits a new eventLocalPeerRecordUpdated
, with a reference (pointer) or inline record.Stateful()
option, which delivers the last seen message to any new subscribers.IDService
.IDService()
accessor is not available onhost.Host
, it's a construct ofBasicHost
.Peer record tracking:
CertifiedAddrBook
with a method to ingest signed peer records with a TTL, and a method to fetch the raw bytes. On ingest, it overwrites all addresses with the incoming ones.Integration with the DHT:
dht/1.1
indicates that peer supports signed peer records.Strict
orLenient
.Strict
, local peer only registersdht/1.1
protocol and therefore only interfaces with peers supporting signed peer records.Lenient
, local peer registers bothdht/1.0
anddht/1.1
protocols, the latter taking precedence over the former in protocol negotiation.dht/1.1
, when responding to routing queries, we use theCertifiedAddrBook
interface. (we must abort initialisation if the injectedPeerstore
does not implement that interface)dht/1.0
includesdht/1.1
members, but not viceversa. This solution assumes thatdht/1.1
peers also supportdht/1.0
. That will be true for a transition period. In the future, we'll deprecatedht/1.0
.The text was updated successfully, but these errors were encountered: