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
Remove special cases for Peer and Provider records #584
Comments
|
can you expand a bit on on the proposed updated record interface? e.g. how would merge indicate two records couldn't be merged? The optimizations possible with findPeer seem like they may warrant remaining special cased. it looks like the proposal is to keep the FIND_NODE records as they exist now, which sounds right. |
They can always be merged, but maybe there's a better word to use here. The question being asked of the interface is "given that I've received record A, what do I do with this record B I've just received?". In the case of provider records, we return A + B (i.e. emit B since A has already been sent), while in the case of IPNS and peer records we return Best(A, B) (i.e. emit B if B is better than A, and not thing otherwise).
These are going to have to change in some form anyway as a result of signed peer records #558. I think we may have to experiment a bit to see if we can remove the FindPeer special casing without taking any non-trivial performance hits. If we can get away with it I think it would be great since I'd prefer to think of any "special-casing" like we should be extending the interface. For example, if someone wanted to build a DHT with a new type of peer record (e.g. different signature scheme) it'd be nice if they could benefit from the same optimizations we're using for the "default" FindPeer. |
aschmahmann commentedApr 13, 2020
•
edited
Proposal
a.
Merge(rec1, rec2)so that we can support record types that are mergeable (e.g. provider records) and not just sortable (e.g. IPNS records)b.
Verify(key, rec)which we already havec. We could optionally make both of these functions take some external "state" if we wanted to insist that the above were pure functions, which is not the case with the existing Record interface
a.
CustomKadID(key string) kad.ID, so that if it makes sense that/a/QmABCwould be nearQmABCin Kad space that we can represent thatb.
RecordID intwe should allow representing record namespaces on the wire using a (var)int instead of a string to save some bytes. There's no reason to expect contention over the slots since they should be defined per DHT prefix (e.g./ipfs), and that spec would be where the standardization of the record IDs happenADD_PROVIDERandGET_PROVIDERSMessage Types and instead perform those operations via the/providernamespace of PUT/GET VALUE/p2pnamespace of PUT/GET VALUE for finding and advertising peers. Use a CustomKadID for peer records that puts/p2p/QmABCnearSHA256(QmABC)(this will make it behave similarly to how it does today)Background
We currently have a few message types that do approximately the same thing:
Generic Puts + Gets
PutValue(key, value): puts an arbitrary piece of data that must follow the rules defined by the key's prefix
Get/SearchValue(key): gets an arbitrary piece of data returning the "best" version of the data found using the rules defined by the key's prefix
Message Types Used:
FIND_NODEandPUT_VALUEfor PutValue andGET_VALUEfor Get/SearchValueWhat can you do with the records? The Record interface allows for user defined types that verify and order records (e.g. the
/ipnsprefix is associated with a particular record format, a way to verify that an IPNS record is valid and a way to determine which of two records is better).Provider Records
Provide(cid): Puts a provider record (a piece of data signifying that a peer cares about some information)
FindProviders(cid): Gets a set of provider record corresponding to the cid (or really multihash #422 )
Message Types Used:
FIND_NODEandADD_PROVIDERfor Provide andGET_PROVIDERSfor FindProvidersWhat can you do with the records? Everything here is implicit, we learn about peer's the have expressed interest in some topic (e.g. having the data identified by a multihash) and then decide what to do about it (e.g. connect to them and start using some other protocol). Despite provider records not being signed we'd still like the network to only advertise that someone is interested in being contacted if they have expressed interest, therefore DHT servers only accept provider records coming directly from the source (as can be verified by their crypto handshake).
Peer Records
This one is a little funky and still needs a specification libp2p/go-libp2p#784. The main reason it's strange is because there are a number of optimizations that can be done for peers that are members of the DHT (whether clients or servers) that cannot be performed for others.
FindPeer(peerID): Get a peer's multiaddresses from the DHT
PutPeer(peerID): This function does not exist, but rather is implicitly done by forming connections to other peers
Message Types Used:
FIND_NODEand implicitly the Identify protocolWhat can you do with the records? These operate similarly to provider records, you find out about the addresses for a peer that you have an interest in. Like provider records servers are supposed to ensure that only real addresses that they have received from the peers are conveyed in queries.
Why Now?
Well a few of the "quirks" of our DHT message types have finally caught up with us. In particular, we want to:
a. Dial peers more reliably, especially peers that are not DHT servers, but are advertising their addresses in the DHT
b. Trust DHT servers a little less (attack omitted, but you can guess
c. Enable third parties to advertise peer records in the DHT
d. Give less trust to third parties that fetch peer records from the DHT
a. Find content more reliably, since we can prioritize which providers to utilize first
b. Enable third parties to advertise provider records in the DHT
c. Give less trust to third parties that fetch provider records from the DHT
d. Enable record rebalancing Correctly Implement Kademlia Rebalancing #354 (more important for provider records then peer records, but useful there too)
e. Having an actual record format will also enable embedding extra information in the record going forward (e.g. in the case of IPFS, do I have all of a DAG under some CID or just some of it)
f. Trust DHT servers a little less
Given that 1,2 and 3 will require rewriting our message types anyway this seems like an opportune time to tackle this as well. As an added bonus this will give us an opportunity to take another stab at what the ContentRouting and PeerRouting interfaces could look like in a very low stakes environment (since we'll end up wrapping the DHT in something that exports the existing Routing interface)
@jacobheun @Stebalien @aarshkshah1992
The text was updated successfully, but these errors were encountered: