Skip to content

Commit e7027d1

Browse files
committed
ipip(0445): add skip-leaves
1 parent 24861cd commit e7027d1

File tree

2 files changed

+126
-1
lines changed

2 files changed

+126
-1
lines changed

src/http-gateways/trustless-gateway.md

+21-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ The Body hash MUST match the Multihash from the requested CID.
214214

215215
A CAR stream for the requested
216216
[application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car)
217-
content type (with optional `order` and `dups` params), path and optional
217+
content type (with optional `order`, `dups` and `skip-leaves` params), path and optional
218218
`dag-scope` and `entity-bytes` URL parameters.
219219

220220
## CAR version
@@ -301,6 +301,26 @@ of their presence in the DAG or the value assigned to the "dups" parameter, as
301301
the raw data is already present in the parent block that links to the identity
302302
CID.
303303

304+
## CAR `skip-leaves` (content type parameter)
305+
306+
The `skip-leaves` parameter specifies whether blocks with the multicodec `raw`
307+
`0x55` must be sent.
308+
309+
It accepts two values:
310+
- `y`: Blocks with `raw` multicodec MUST NOT be sent.
311+
- `n`, or unspecified: Blocks with `raw` multicodec MUST be sent.
312+
313+
A gateway MUST NOT assume this field is `y` if unspecified.
314+
When not specified it always MUST be understood as `n`.
315+
316+
:::note Notes for implementers
317+
318+
A request which is rooted at a `raw` block and has `skip-leaves=y` does not
319+
make sense and SHOULD NOT be sent by clients, it is fair for servers to
320+
error in this situation.
321+
322+
:::
323+
304324
## CAR format parameters and determinism
305325

306326
The default header and block order in a CAR format is not specified by IPLD specifications.

src/ipips/ipip-0445.md

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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

Comments
 (0)