Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPIP-402: Partial CAR Support on Trustless Gateways #402

Merged
merged 21 commits into from
Jul 27, 2023

Conversation

hannahhoward
Copy link
Contributor

@hannahhoward hannahhoward commented Apr 17, 2023

Goals

Improve the capabilities of a trustless HTTP gateway by adding additional capabilities to requests for CAR files.

The goal is to enable a client capable of translating/decoding CAR files to make a single request to a trustless gateway that in most case allows them to render the same output generated via a request to a trusted gateway. (or if not in a single request, as few requests as possible)

Additions That Are Non-Breaking

Adds two query parameters, car-scope dag-scope=block|entity|all and bytes entity-bytes=from:to, specific to CAR file requests only, that allow a more precise specification of the type of DAG to download at the terminus of a content path (CID+path). The default values for these parameters match current behavior, such that if they are not specified, the return CAR file matches currently specified behavior.

Breaking changes

In order to serve requests for content paths other than just a CID root in a trustless manner, we are requiring gateways to return intermediate blocks from the CID root to the path terminus as part of the returned CAR file. This was not previously well specified, but most major HTTP Gateway implementations are currently only returning blocks starting at the end of the content path and will need to add intermediate blocks.

closes #348 cc ipfs/in-web-browsers#128

Add specification for queries for verifiable CAR requests
@hannahhoward hannahhoward changed the title Improving Trustless Gateways: Paths and Query Parameters for CAR files IPIP-402: Improving Trustless Gateways Via Paths and Query Parameters for CAR files Apr 17, 2023
@hacdias hacdias self-requested a review April 17, 2023 15:55
@alanshaw alanshaw self-requested a review April 17, 2023 16:02
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for opening this @hannahhoward!

I don't think this is a breaking change, since by default, the change is to return MORE blocks, than requested.
There may be perf. penalty due to unexpected blocks, but there should not be any breakage.

Initial thoughts in comments inline.

Once we are happy with the API, the next steps will be:

src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
@lidel lidel changed the title IPIP-402: Improving Trustless Gateways Via Paths and Query Parameters for CAR files IPIP-402: Partial CAR Support on Trustless Gateways Apr 21, 2023
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/trustless-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/trustless-gateway.md Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/path-gateway.md Show resolved Hide resolved
src/http-gateways/path-gateway.md Outdated Show resolved Hide resolved
src/http-gateways/trustless-gateway.md Outdated Show resolved Hide resolved
@BigLep
Copy link
Contributor

BigLep commented Apr 25, 2023

Related tracking items that would be good to add here:

  • dag.house work
  • Lassie work
  • Boxo work
  • ipfs/gateway-conformance work

Co-authored-by: Henrique Dias <hacdias@gmail.com>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
@willscott
Copy link
Contributor

I think my main feedback would be to add more features to what can be detected.

are you specifically interested in feature detection of what codecs are supported by the gateway, or rather if the gateway is able to support e.g. the car scope's being introduced here?

@John-LittleBearLabs
Copy link
Contributor

@willscott

feature detection of what codecs are supported by the gateway, or rather if the gateway is able to support e.g. the car scope's being introduced here?

Both. Codecs, multibases, hash algos, any parameter one might add to a gateway request, etc.. Really any feature that a conceivable MVP gateway might not support and still be considered roughly compliant and still a gateway some client might want to use for other requests.

I brought up "?format=raw" because I use that a lot currently (one could argue whether that's a good idea, but... if I reached for it someone else will at some point too) and a fair number of gateways currently don't support it.

Perhaps the bigger pain point has been the IPNS records, which are obviously a new feature and thus haven't been widely deployed for that reason. But one could also imagine an upstart gateway implementation not wanting to support it on day 1 either.

I don't think we need to be too careful about putting too many things in OPTIONS - it's not something a client would likely ask very frequently, each included feature is a handful of bytes so it's not much of a network traffic problem, and the gateway likely already has the full response in memory anyhow (since it's not dependent on who is asking, nor is it changing) so it's not exactly a DOS problem.

olizilla added a commit to storacha/dagula that referenced this pull request May 1, 2023
add getPath method as a generator that returns blocks for the targeted
dag and all blocks traversed while resolving a cid+path string

supports carScope to specify what blocks to return for the resolved dag
- `'all'`: return the entire dag starting at path. (default)
- `'block'`: return the block identified by the path.
- `'file'`: Mimic gateway semantics: Return All blocks for a multi-block
file or just enough blocks to enumerate a dir/map but not the dir
contents.

see: storacha/freeway#33
see: storacha/freeway#34
see: ipfs/specs#402

TODO:
- [x] find out how to identify the boundaries of a unixfs hamt 

...unixfs-exporter seems to define it as "not having an empty or null
Link.Name after the first 2 chars are stripped, which seems loose...
what happens if the actual dir listing has 2 char long link names? see:
https://github.com/ipfs/js-ipfs-unixfs/blob/e853049bd63d6773442e1540ae49b6a443ca8672/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/hamt-sharded-directory.ts#L20-L42

License: MIT

---------

Signed-off-by: Oli Evans <oli@protocol.ai>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
@lidel lidel force-pushed the feat/improving-trustless-gateways branch from 608e7b7 to e1af6e4 Compare July 3, 2023 23:39
lidel added 2 commits July 4, 2023 20:39
This backports CIDs and CARs from gateway conformance to the IPIP-402,
and provides some basic hints on how each fixture should be used.
@@ -235,9 +230,14 @@ single request.

## Test fixtures
Copy link
Member

@lidel lidel Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ A detailed list of compliance checks for dag-scope and entity-bytes can be found in gateway-conformance v0.2.0 → trustless_gateway_car_test.go. I've made another pass and double-checked them + pushed 4ebbb96 which adds CIDs, CARs, and short summary of each fixture to this IPIP.

This should be enough as a go-to resource for people who want to test with some reference data, or understand what the compliance tests do and where to find them.

@BigLep
Copy link
Contributor

BigLep commented Jul 6, 2023

2023-07-06 Kubo maintainer conversation: we need to ensure a conformance test involving inline CIDs.

lidel added a commit that referenced this pull request Jul 6, 2023
This change incorporates feedback from Adin, Rod and Juan:

- bytes: #402 (review)
- car-scope: #402 (comment)

I really hope these names will be good enough, but I am running on
artisan, recycled electrons so can do this all day :-)
lidel added a commit that referenced this pull request Jul 6, 2023
We have no spec for signaling this, we may add it as opt-in later
#402 (comment)
#402 (comment)
lidel added a commit that referenced this pull request Jul 6, 2023
lidel added a commit that referenced this pull request Jul 6, 2023
lidel added a commit that referenced this pull request Jul 6, 2023
Discussions in #402
illustrated deeper problem with CAR determinism, and
we made a decision to remove its aspects from IPIP-402.

Ref.
#402 (comment)
lidel added a commit that referenced this pull request Jul 6, 2023
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have conformance tests, reference implementation is in boxo/gateway and shipped with Kubo 0.21 and the same API been used in Rhea/Saturn for a while.

Thank you to everyone involved, especially asking questions and pointing gaps – it all made the specification better, and also produced IPIP-412: ordered cars and IPIP-425: signaling features where we continue some of the work that started here.

I believe this is ready for being rattified.
Will flag this during IPFS-Implementers-Sync-2023-07-20.

@lidel lidel dismissed stale reviews from aschmahmann and alanshaw July 27, 2023 13:59

feedback addressed

@lidel
Copy link
Member

lidel commented Jul 27, 2023

There were no ratification concerns during IPFS Implementers sync, nor during the week after it.
Merging to unblock IPIP-412 which is built on top of this one.

For future reference:

Thank you to everyone involved in this one ❤️

@lidel lidel merged commit 1b9a954 into main Jul 27, 2023
2 checks passed
@lidel lidel deleted the feat/improving-trustless-gateways branch July 27, 2023 14:16
@BigLep BigLep mentioned this pull request Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ratified
Archived in project
Development

Successfully merging this pull request may close these issues.

Create IPIP with Gateway spec for partial CAR exports