|
| 1 | +--- |
| 2 | +title: "IPIP-0445: trustless gateway skip-leaves option" |
| 3 | +date: 2023-10-09 |
| 4 | +ipip: open |
| 5 | +editors: |
| 6 | + - name: Hugo VALTIER |
| 7 | + github: Jorropo |
| 8 | + url: https://jorropo.net/ |
| 9 | + affiliation: |
| 10 | + name: Protocol Labs |
| 11 | + url: https://protocol.ai/ |
| 12 | +relatedIssues: |
| 13 | + - https://github.com/ipfs/specs/issues/444 |
| 14 | +order: 445 |
| 15 | +tags: ['ipips'] |
| 16 | +--- |
| 17 | + |
| 18 | +## Summary |
| 19 | + |
| 20 | +Introduce `skip-leaves` flag for the :cite[trustless-gateway]. |
| 21 | + |
| 22 | +## Motivation |
| 23 | + |
| 24 | +Allow clients to read a stream which only contain proofs in a bottom heavy |
| 25 | +graph using `raw` codec for it's leaves. |
| 26 | + |
| 27 | +Usefull with unixfs for features like webseeds [#444](https://github.com/ipfs/specs/issues/444). |
| 28 | + |
| 29 | +## Detailed design |
| 30 | + |
| 31 | +The `skip-leaves` CAR Content-Type parameter on :cite[trustless-gateway] |
| 32 | +allows clients to download an entity except blocks with the multicodec |
| 33 | +`raw` (`0x55`). |
| 34 | + |
| 35 | +- When set to `y`, the parameter instructs the gateway not to transmit |
| 36 | + blocks tagged with the `raw` multicodec. |
| 37 | +- If set to `n`, or left unspecified, the gateway MUST transmit `raw` |
| 38 | + multicodec blocks. |
| 39 | + |
| 40 | +Importantly, unless explicitly specified as `y`, the default operational |
| 41 | +mode of the gateway MUST assume the value of `skip-leaves` to be `n`. |
| 42 | + |
| 43 | +## Design rationale |
| 44 | + |
| 45 | +### User Benefit |
| 46 | + |
| 47 | +Implementing the `skip-leaves` parameter offers several benefits to users: |
| 48 | + |
| 49 | +1. **Verification Flexibility:** Clients can verify out-of-band (OOB) received |
| 50 | + files in their deserialized form without necessitating the transmission of |
| 51 | + raw blocks from the gateway. |
| 52 | +2. **Incremental Download:** Clients can incrementally download files in |
| 53 | + deserialized forms from non-IPFS servers. Allowing applications to share |
| 54 | + distribution for IPFS and non IPFS clients. |
| 55 | +3. **Efficient Block Discovery:** With the `skip-leaves` option enabled, |
| 56 | + clients can quickly discover numerous candidate blocks without being |
| 57 | + bottlenecked by the gateway's transmission of raw blocks. |
| 58 | + |
| 59 | +### Compatibility |
| 60 | + |
| 61 | +Setting the default value of the `skip-leaves` parameter to `n` ensures |
| 62 | +backward compatibility with existing clients and systems that are unaware |
| 63 | +of this new flag. |
| 64 | + |
| 65 | +### Prevention of Amplification Attacks and Efficient Server Operation |
| 66 | + |
| 67 | +By utilizing the `raw` (`0x55`) codec servers can trivially determine whether |
| 68 | +to fetch or skip a block without having to learn any new information. |
| 69 | +Although more limited and not able to handle unixfs file using dag-pb for their |
| 70 | +leaves, it allows both the client and server to trivially verify a block |
| 71 | +must not be fetched. Preventing issues of Amplification where a server could |
| 72 | +need to fetch multiple orders more data than the client when executing the |
| 73 | +request. |
| 74 | + |
| 75 | +### Why not `dag-scope=skip-leaves` ? |
| 76 | + |
| 77 | +The `dag-scope` parameter determines the overall range of blocks to retrieve, |
| 78 | +while `skip-leaves` selectively filters specific blocks within that range. |
| 79 | +Combining them under one parameter would restrict their combined utility. |
| 80 | + |
| 81 | +For example: |
| 82 | +- A client is streaming a video from a webseed and the user seeked through the |
| 83 | + video, then the client would send `dag-scope=entity&entity-bytes=42:1337` |
| 84 | + with `skip-leaves=y` to download the proofs for the required section of the |
| 85 | + video. |
| 86 | +- A client is verifying an OOB transfered directory, then `dag-scope=all` with |
| 87 | + `skip-leaves=y` makes sense. |
| 88 | + |
| 89 | +### Alternatives |
| 90 | + |
| 91 | +An alternative approach would be to request blocks individually. |
| 92 | +However it adds extra round trips and more per HTTP request overhead |
| 93 | +and thus is undesireable. |
| 94 | + |
| 95 | +## Security |
| 96 | + |
| 97 | +None. |
| 98 | + |
| 99 | +## Test fixtures |
| 100 | + |
| 101 | +TODO |
| 102 | + |
| 103 | +### Copyright |
| 104 | + |
| 105 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments