Skip to content

Commit f1033ee

Browse files
committed
ipip-404: descope car roots and determinism
Discussions in #402 illustrated deeper problem with CAR determinism, and we made a decision to remove its aspects from IPIP-402. Ref. #402 (comment)
1 parent 8b198d2 commit f1033ee

File tree

2 files changed

+78
-17
lines changed

2 files changed

+78
-17
lines changed

src/http-gateways/trustless-gateway.md

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >
44
Trustless Gateways are a minimal subset of Path Gateways that allow light IPFS
55
clients to retrieve data behind a CID and verify its integrity without delegating any
66
trust to the gateway itself.
7-
date: 2023-04-17
7+
date: 2023-06-20
88
maturity: reliable
99
editors:
1010
- name: Marcin Rataj
@@ -153,18 +153,9 @@ The Body hash MUST match the Multihash from the requested CID.
153153

154154
### CAR Response
155155

156-
A CAR stream
157-
([application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car))
158-
for the requested content type, path and optional `dag-scope` and `entity-bytes` URL parameters.
159-
160-
:::note
161-
162-
By default, block order in CAR response is not deterministic, blocks can
163-
be returned in different order, depending on implementation choices (traversal,
164-
speed at which blocks arrive from the network, etc). An opt-in ordered CAR
165-
responses MAY be introduced in a future, see [IPIP-412](https://github.com/ipfs/specs/pull/412).
166-
167-
:::
156+
A CAR stream for the requested
157+
[application/vnd.ipld.car](https://www.iana.org/assignments/media-types/application/vnd.ipld.car)
158+
content type, path and optional `dag-scope` and `entity-bytes` URL parameters.
168159

169160
#### CAR version
170161

@@ -174,9 +165,40 @@ field MUST match the `version` parameter returned in `Content-Type` header.
174165

175166
#### CAR roots
176167

177-
If the response uses version 1 or 2 of the CAR spec, the
168+
The behavior associated with the
178169
[`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
179-
MAY contain the CID of the terminus of the content path.
170+
is not currently specified.
171+
172+
Clients MAY ignore it.
173+
174+
:::issue
175+
176+
As of 2023-06-20, the behavior of the `roots` CAR field remains an [unresolved item within the CARv1 specification](https://web.archive.org/web/20230328013837/https://ipld.io/specs/transport/car/carv1/#unresolved-items).
177+
178+
:::
179+
180+
#### CAR determinism
181+
182+
The default CAR header and block order in a CAR response is not specified and is non-deterministic.
183+
184+
Clients MUST NOT assume that CAR responses are deterministic (byte-for-byte identical) across different gateways.
185+
186+
Clients MUST NOT assume that CAR includes CIDs and their blocks in the same order across different gateways.
187+
188+
:::issue
189+
190+
In controlled environments, clients MAY choose to rely on undocumented CAR determinism,
191+
subject to the agreement of the following conditions between the client and the
192+
gateway:
193+
- CAR version
194+
- content of [`CarV1Header.roots`](https://ipld.io/specs/transport/car/carv1/#header) field
195+
- order of blocks
196+
- status of duplicate blocks
197+
198+
In the future, there may be an introduction of a convention to indicate aspects
199+
of determinism in CAR responses. Please refer to
200+
[IPIP-412](https://github.com/ipfs/specs/pull/412) for potential developments
201+
in this area.
202+
203+
:::
180204

181-
If implementation prefers to avoid buffering blocks, and return them as soon as
182-
possible, the field MAY be left empty.

src/ipips/ipip-0402.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,45 @@ mention feature detection via OPTIONS -- a separate IPIP?
143143
OR suggest executing test request and client-side detection the first time a gateway is used.
144144
-->
145145

146+
#### CAR roots and determinism
147+
148+
As of 2023-06-20, the behavior of the `roots` CAR field remains an [unresolved item within the CARv1 specification](https://web.archive.org/web/20230328013837/https://ipld.io/specs/transport/car/carv1/#unresolved-items):
149+
150+
> Regarding the roots property of the Header block:
151+
>
152+
> - The current Go implementation assumes at least one CID when creating a CAR
153+
> - The current Go implementation requires at least one CID when reading a CAR
154+
> - The current JavaScript implementation allows for zero or more roots
155+
> - Current usage of the CAR format in Filecoin requires exactly one CID
156+
>
157+
> [..]
158+
>
159+
> It is unresolved how the roots array should be constrained. It is recommended
160+
> that only a single root CID be used in this version of the CAR format.
161+
>
162+
> A work-around for use-cases where the inclusion of a root CID is difficult
163+
> but needing to be safely within the "at least one" recommendation is to use
164+
> an empty CID: `\x01\x55\x00\x00` (zero-length "identity" multihash with "raw"
165+
> codec). Since current implementations for this version of the CAR
166+
> specification don't check for the existence of root CIDs
167+
> (see [Root CID block existence](https://web.archive.org/web/20230328013837/https://ipld.io/specs/transport/car/carv1/#root-cid-block-existence)),
168+
> this will be safe as far as CAR implementations are concerned. However, there
169+
> is no guarantee that applications that use CAR files will correctly consume
170+
> (ignore) this empty root CID.
171+
172+
Due to the inconsistent and non-deterministic nature of CAR implementations,
173+
the gateway specification faces limitations in providing specific
174+
recommendations. Nevertheless, it is crucial for implementations to refrain
175+
from making implicit assumptions based on the legacy behavior of individual CAR
176+
implementations.
177+
178+
Due to this, gateway specification changes introduced in this IPIP clarify that:
179+
- The CAR `roots` behavior is out of scope and flags that clients MAY ignore it.
180+
- CAR determinism is not present by default, responses may differ across
181+
requests and gateways.
182+
- Opt-in determinism is possible, but standarized signaling mechanism does not
183+
exist until we have IPIP-412 or similar.
184+
146185
### Security
147186

148187
This IPIP allows clients to narrow down the amount of data returned as a CAR,

0 commit comments

Comments
 (0)