IPFS seems to (also) store Provider Records in far distant nodes. Why?

This is a conceptual question around IPFS protocol. I’ve read the DHT document from ipfs.tech and a high-level run-down of what I got from it is as follows:

(1) the hash of the record key we’re looking for indicates which nodes are likely to store a provider record for that data and

(2) a peer can traverse the peer graph efficiently (due to the skiplist-like routing table and the peer ordering with sha256(peerID) taken as integer) and therefore ask the right nodes for the provider records.

This makes sense as long as hash(record key) is stored at around nodes with hash(peerID) being close to hash(record key). Please correct if my understanding so far is inaccurate.

Now the provider record PUT procedure in the ipfs.tech doc is:

Provider PUT

  1. Do a standard lookup for the K closest peers to SHA256(H)
  2. Put the provider record at those K closest peers, and also store it ourselves.
  3. Currently, you are only allowed to put a provider record for yourself. Alice cannot advertise that Bob has content.

Why would would the node store the provider record itself - the original node that’s doing this may be far distance to the nodes where the data should be? Shouldn’t just the nodes whose hash(peerID) is in proximity of the data hash store the provider record? How are other nodes supposed to benefit from the fact that some random node in the network also has a provider record for that data hash?

Except the increased load on the DHT, there is no downside to storing the provider record in more places. It’s just less and less likely that it will be usefull.

If you are far-away it’s very unlikely that someone will ask you, however because the network is not that big (a few tens of thousands of nodes) and you often store far more blocks than this (hundred of thousands to hundred of millions for usual workloads), it do happen that someone will connect to you, do a DHT request asking you about a block you host, even tho you are not close to that block in key space.

It’s just that by luck you got selected in the skip list.

1 Like