ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.2k stars 3.03k forks source link

Leverage Content Path Affinity in routing #10251

Open lidel opened 11 months ago

lidel commented 11 months ago

Created as a follow-up for https://github.com/ipfs/kubo/pull/10249, https://github.com/ipfs/kubo/issues/9416, and a prerequisite for https://github.com/ipfs/kubo/issues/8676

Problem

Right now, we support three values in Reprovider.Strategy which tells reprovider what should be announced. Valid strategies are:

If the repository gets too big, all and pinned are too expensive and folks are forced to use roots which is codec-agnostic and will only announce the root block of UnixFS DAG.

But roots comes with a big downside:

⚠️ BE CAREFUL: node with roots strategy will not announce child blocks.

It makes sense only for use cases where the entire DAG is fetched in full, and a graceful resume does not have to be guaranteed: the lack of child announcements means an interrupted retrieval won't be able to find providers for the missing block in the middle of a file, unless the peer happens to already be connected to a provider and ask for child CID over bitswap.

This is not an inherent limitation of IPFS as a whole – it is only a limitation of how things are implemented in Kubo:

  1. /ipfs/cid/sub/dir/file is resolved first, into /ipfs/file-CID
  2. Retrieval of /ipfs/file-CID starts
  3. If interrupted and resumed at later time, blocks for /ipfs/cid, /ipfs/cid/sub, and /ipfs/cid/sub/dir are already cached in local store, so Kubo does no network lookup for provider of these. It will ask for providers of the first missing block within /ipfs/file-CID, and if these internal blocks are not announced (e.g. due to Reprovider.Strategy set to roots), Kubo won't be able to resume download.

Solution ideas

randalljyoung commented 11 months ago

Does IPFS have only a push-centric functionality (provides) does there exist a pull equivalent ( requests?) and if so, what happens when you request a block that a node hasn't provided?