-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: roundabout gets raw cids as blobs (#359)
Part of storacha/project-tracking#49 Note that currently Roundabout is used in production traffic for SPs to download Piece bytes, and is planned to be used by w3filecoin storefront to validate a Piece CID. ## SP reads 1. SPs request comes with a PieceCID, where we get equivalency claim for this Piece to some content. 2. In current world (`store/*` protocol), it will in most cases be a CAR CID that we can get from R2 `carpark-prod-0` as `carCid/carCid.car`. However, `store/add` does not really require this to be a CAR, so it could end up being other CIDs that are still stored with same key format in R2 bucket. 3. With new world (`blob/*` protocol), it will be a RAW CID that we can get from R2 `carpark-prod-0` as `b58btc(multihash)/b58btc(multihash).blob`. ## w3filecoin reads 1. `filecoin/offer` is performed with a given content CID 2. In current client world, a `CarCID` is provided on `filecoin/offer`. This CID is used to get bytes for the content, in order to derive Piece for validation. In addition, equivalency claim is issued with `CarCID` 3. With new world, we aim to have `filecoin/offer` to rely on RAW CIDs, which will be used for both reading content and issuing equivalency claims. ## This PR We need a transition period where we support both worlds. This PR enables roundabout to attempt to distinguish between a Blob and a CAR when it gets a retrieval request. If the CID requested is a CAR (or a Piece that equals a CAR), we can assume the old path and key format immediately. On the other hand, if CID requested is RAW, we may need to give back a Blob object or a "CAR" like stored object. For the transition period, this PR proposed that if we have a RAW content to locate, we MUST do a HEAD request to see if a Blob exists, and if so redirect to presigned URL for it. Otherwise, we need to fallback into old key formats. As an alternative, we could make the decision to make `store/add` handler not accept anymore non CAR CIDs, even though we would lose the ability to retrieve old things from Roundabout (which may be fine as well 🤔 ). Please note that this is still not hooked with content claims to figure out which bucket to use, and still relies on assumption of CF R2 `carpark-prod-0`. Just uses equivalency claims to map PieceCID to ContentCID
- Loading branch information
1 parent
5779161
commit cdb7c65
Showing
7 changed files
with
147 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import * as Raw from 'multiformats/codecs/raw' | ||
|
||
export const RAW_CODE = Raw.code | ||
|
||
/** https://github.com/multiformats/multicodec/blob/master/table.csv#L140 */ | ||
export const CAR_CODE = 0x02_02 | ||
|
||
/** https://github.com/multiformats/multicodec/blob/master/table.csv#L520 */ | ||
export const PIECE_V1_CODE = 0xf1_01 | ||
|
||
/** https://github.com/multiformats/multicodec/blob/master/table.csv#L151 */ | ||
export const PIECE_V1_MULTIHASH = 0x10_12 | ||
|
||
/** https://github.com/multiformats/multicodec/pull/331/files */ | ||
export const PIECE_V2_MULTIHASH = 0x10_11 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters