Skip to content

Commit ccea14d

Browse files
committed
ipip(1337): add skip-leaves IPIP
1 parent 24861cd commit ccea14d

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-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-1337.md

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: "IPIP-1337: Ipfs"
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: 1337
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 contains the unixfs proofs.
25+
26+
Usefull for features like webseeds [#444](https://github.com/ipfs/specs/issues/444).
27+
28+
## Detailed design
29+
30+
The `skip-leaves` CAR Content-Type parameter on :cite[trustless-gateway]
31+
allows clients to download an entity except blocks with the multicodec
32+
`raw` (`0x55`).
33+
34+
- When set to `y`, the parameter instructs the gateway not to transmit
35+
blocks tagged with the `raw` multicodec.
36+
- If set to `n`, or left unspecified, the gateway MUST transmit `raw`
37+
multicodec blocks.
38+
39+
Importantly, unless explicitly specified as `y`, the default operational
40+
mode of the gateway MUST assume the value of `skip-leaves` to be `n`.
41+
42+
## Design rationale
43+
44+
### User Benefit
45+
46+
Implementing the `skip-leaves` parameter offers several benefits to users:
47+
48+
1. **Verification Flexibility:** Clients can verify out-of-band (OOB) received
49+
files in their deserialized form without necessitating the transmission of
50+
raw blocks from the gateway.
51+
2. **Incremental Download:** Clients can incrementally download files in
52+
deserialized forms from non-IPFS servers. Allowing applications to share
53+
distribution for IPFS and non IPFS clients.
54+
3. **Efficient Block Discovery:** With the `skip-leaves` option enabled,
55+
clients can quickly discover numerous candidate blocks without being
56+
bottlenecked by the gateway's transmission of raw blocks.
57+
58+
### Compatibility
59+
60+
Setting the default value of the `skip-leaves` parameter to `n` ensures
61+
backward compatibility with existing clients and systems that are unaware
62+
of this new flag.
63+
64+
### Prevention of Amplification Attacks and Efficient Server Operation
65+
66+
By utilizing the `raw` (`0x55`) codec servers can trivially determine whether
67+
to fetch or skip a block without having to learn any new information.
68+
Altho more limited and not able to handle unixfs file using dag-pb for their
69+
leaves, it allows both the client and server to trivially verify a block
70+
must not be fetched. Preventing issues of Amplification where a server could
71+
need to fetch multiple orders more data than the client when executing the request.
72+
73+
### Alternatives
74+
75+
An alternative approach would be to request blocks individually.
76+
However it adds extra round trips and more per HTTP request overhead
77+
and thus is undesireable.
78+
79+
## Security
80+
81+
None.
82+
83+
## Test fixtures
84+
85+
TODO
86+
87+
### Copyright
88+
89+
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

0 commit comments

Comments
 (0)