Subject: Re: [PATCH 0/5] Distributing substitutes over IPFS

From: Pierre Neidhardt <[email-masked]>
Date: Mon, 01 Jul 2019 23:36:34 +0200

Hi!

(Re-sending to debbugs, sorry for the double email :p)

A little update/recap after many months! :)

I talked with Héctor and some other people from IPFS + I reviewed Ludo's
patch so now I have a little better understanding of the current state
of affair.

- We could store the substitutes as tarballs on IPFS, but this has
  some possible downsides:

  - We would need to use IPFS' tar chunker to deduplicate the content of
    the tarball.  But the tar chunker is not well maintained currently,
    and it's not clear whether it's reproducible at the moment, so it
    would need some more work.

  - Tarballs might induce some performance cost.  Nix had attempted
    something similar in the past and this may have incurred a significant
    performance penalty, although this remains to be confirmed.
    Lewo?

- Ludo's patch stores all files on IPFS individually.  This way we don't
  need to touch the tar chunker, so it's less work :)
  This raises some other issues however:

  - Extra metadata:  IPFS stores files on UnixFSv1 which does not
    include the executable bit.

    - Right now we store a s-exp manifest with a list of files and a
      list of executable bits.  But maybe we don't have to roll out our own.

    - UnixFSv1 has some metadata field, but Héctor and Alex did not
      recommend using it (not sure why though).

    - We could use UnixFSv2 but it's not released yet and it's unclear when
      it's going to be released.  So we can't really count on it right now.

    - IPLD: As Héctor suggested in the previous email, we could leverage
      IPLD and generate a JSON object that references the files with
      their paths together with an "executable?" property.
      A problem would arise if this IPLD object grows over the 2M
      block-size limit because then we would have to shard it (something
      that UnixFS would do automatically for us).

  - Flat storage vs. tree storage: Right now we are storing the files
    separately, but this has some shortcomings, namely we need multiple
    "get" requests instead of just one, and that IPFS does
    not "know" that those files are related.  (We lose the web view of
    the tree, etc.)  Storing them as tree could be better.
    I don't understand if that would work with the "IPLD manifest"
    suggested above.  Héctor?

  - Pinning: Pinning all files separately incurs an overhead.  It's
    enough to just pin the IPLD object since it propagates recursively.
    When adding a tree, then it's no problem since pinning is only done once.

  - IPFS endpoint calls: instead of adding each file individually, it's
    possible to add them all in one go.  Can we add all files at once
    while using a flat storage? (I.e. not adding them all under a common
    root folder.)

To sum up, here is what remains to be done on the current patch:

- Add all files in one go without pinning them.
- Store as the file tree?  Can we still us the IPLD object to reference
  the files in the tree?  Else use the "raw-leaves" option to avoid
  wrapping small files in UnixFS blocks.
- Remove the Scheme manifest if IPLD can do.
- Generate the IPLD object and pin it.

Any corrections?
Thoughts?

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/