Vasco Santos
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # CAR Aggregation Protocol ![status:wip](https://img.shields.io/badge/status-wip-orange.svg?style=flat-square) ## Editors - [Vasco Santos], [Protocol Labs] - [Irakli Gozalishvili], [Protocol Labs] - [Alan Shaw], [Protocol Labs] ## Authors - [Vasco Santos], [Protocol Labs] - [Irakli Gozalishvili], [Protocol Labs] - [Alan Shaw], [Protocol Labs] # Abstract This spec describes a [UCAN] protocol allowing an implementer to receive an aggregate of CAR files for inclusion in a Filecoin deal. ## Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119](https://datatracker.ietf.org/doc/html/rfc2119). # Terminology ## Roles There are several roles in the authorization flow: | Name | Description | | ----------- | ----------- | | Storefront | [Principal] identified by [`did:web`] identifier, representing a storage aggregator like w3up | | Authority | [Principal] that represents service provider that executes invoked capabilities | | Verifier | Component of the [authority] that performs UCAN validation | ### Storefront A _Storefront_ is a type of [principal] identified by a [`did:web`] identifier. A Storefront facilitates data storage services to applications and users, getting the requested data stored into Filecoin deals asynchronously. ### Authority _Authority_ is a [principal] that executes invoked capabilities. ### Verifier A Component of the [authority] that performs UCAN validation # Protocol ## Overview A Storefront is the entry point for user/application data into web3. It will act on behalf of users to move data around into different storage points. One of the key storage presences may be Filecoin Storage Providers. ### Authorization Broker MUST have an authorization mechanism for allowed Storefront principals (e.g. web3.storage). Either by out-of-bound exchange of information or through a well defined API. In other words, broker can authorize invocations from `did:web:web3.storage` by validating signature from did. This way, it allows web3.storage to rotate keys and/or re-delegate access without having to coordinate with the broker. ### Storefront offers broker an aggregate When a Storefront has enough content to fulfill an aggregate (each broker MAY have different requirements), a Filecoin deal for an aggregate MAY be requested by an `aggregate/offer` invocation. Deal negotiations with Filecoin Storage Providers SHOULD be handled out off band. Broker MUST acknowledge a request by issuing a signed receipt. ```mermaid sequenceDiagram participant Storefront as 🌐<br/><br/>did:web:web3.storage participant Authority as 🌐<br/><br/>did:web:spade.storage Storefront->>Authority: invoke `aggregate/offer` Note left of Authority: Request offer to be queued Authority-->>Storefront: receipt issued ``` ### Broker queues the offer Once broker successfully gets an offer, the offer gets queued for review. A receipt is created to proof the transition of `aggregate/offer` state from `null` into `queued`. It is worth mentioning that if an offer is from an aggregate that is already `queued` or `complete` it is ignored. This receipt MUST have link to a followup task (using `.fx.join` field) that either succeeds (if aggregate was accepted) or fails (if aggregated was determined to be invalid) so that it's receipt COULD be looked up using it. > Note: Aggregator MAY have several intermediate steps and states it transitions though, however those intentionally are not captured by this protocol, because storefront will take no action until success / failure condition is met. ### Broker reviews and handles the offer When a broker dequeues the offer from the queue, its details are retrieved from the provided source URL. With the offer details, the broker will interact with available Filecoin Storage Providers, in order to establish a previously determined (out of band) number of deals. Depending on storage providers availability, as well as the content present in the offer, the aggregate MAY be handled or not. A receipt is created to proof the transition of `aggregate/offer` state from `queued` into `accepted` or `denied`. ```mermaid sequenceDiagram participant Storefront as 🌐<br/><br/>did:web:web3.storage participant Authority as 🌐<br/><br/>did:web:spade.storage Note right of Storefront: Review and handle offer async Authority-->>Storefront: receipt issued ``` Once offer gets into `accepted` state, broker takes care of renewing deals. ### Storefront can query state of the aggregate deals Storefront users MAY want to check details about deals from the content they previously stored. These deals will change over time as they get renewed. Therefore, Storefront should invoke `aggregate/get` capability to gather information about given aggregate identifier. ```mermaid sequenceDiagram participant Storefront as 🌐<br/><br/>did:web:web3.storage participant Authority as 🌐<br/><br/>did:web:spade.storage Storefront->>Authority: invoke `aggregate/get` ``` ## Capabilities This section describes the capabilities that form the w3 aggregation protocol, along with the details relevant for invoking capabilities with a service provider. In this document, we will be looking at `spade.storage` as an implementer of the `aggregate/*` and `offer/*` protocol. ### `aggregate/offer` A Storefront principal can invoke a capabilty to submit an aggregate ready for offers. ```iplsch type AggregateOffer union { Aggregate "aggregate/offer" } representation inline { discriminantKey "can" } type Offers [Offer] type Offer struct { with StorefrontDID offer &Offers } type Proof &Any type Archive &Any type URL string type struct OfferDetails { size Int archive Archive src [URL] proof Proof } ``` > `did:web:web3.storage` invokes capability from `did:web:spade.storage` ```json { "iss": "did:web:web3.storage", "aud": "did:web:spade.storage", "att": [{ "on": "did:web:spade.storage", "call": "aggregate/offer", "input": { "offers": { "/": "bafy...many-offers" } /* dag-cbor CID */ } }], "prf": [], "sig": "..." } /* decoded offers block */ [ { "link": { "/": "bafy...offer" }, /* CAR CID */ "size": 110101, "proof": { "/": "bafy...offer" }, /* COMMP CID */ "src": ["https://w3s.link/ipfs/bafy...offer"] } ] ``` Invoking `aggregate/offer` capability submits an offer to a broker service to arrange a Filecoin deals. The `nb.offer` representing a "Ferry" aggregate offer that is ready for a Filecoin deal. The `link` field is the DAG-CBOR CID that refers to a "Ferry" offer. It encodes a dag-cbor block with an array of entries representing all the CAR files to include in the aggregated deal. Its format is: The `src` field of each piece MUST be set to a (alphabetically sorted) list of URLs from which it can be fetched. The `size` field of each piece MUST be set to the byte size of the combined CAR files. Broker MUST issue a signed receipt to acknowledge the received request. Issued receipt MUST contain an [effect](https://github.com/ucan-wg/invocation/#7-effect) with a subsequent task (`.fx.join` field) that is run when submitted aggregate is processed and either succeeds (implying that aggregate was accepted and deals will be arranged) or fail (with `error` describing a problem with an aggregate). ```json { "ran": "bafy...invocation", "out": { "ok": { "status": "queued" } }, "fx": { "join": { "/": "bafy...dequeue" } }, "meta": {}, "iss": "did:web:spade.storage", "prf": [] } ``` See [`offer/arrange`](#offerarrange) section to see the subsequent task. ### `aggregate/get` A Storefront principal can invoke a capability to get state of a previously accepted offer. > `did:web:web3.storage` invokes capability from `did:web:spade.storage` ```json { "iss": "did:web:web3.storage", "aud": "did:web:spade.storage", "att": [{ "with": "did:web:web3.storage", "can": "aggregate/get", "nb": { "link": "bafy...offer", } }], "prf": [], "sig": "..." } ``` Once this invocation is executed, a receipt is generated with the resulting aggregate information: ```json { "ran": "bafy...get", "out": { "ok": { "deals": { "111": { "storageProvider": "f07...", "status": "Active", "pieceCid": "bag...", "dataCid": "bafy...", "dataModelSelector": "Links/...", "activation": "2023-04-13T01:58:00+00:00", "expiration": "2024-09-05T01:58:00+00:00", "created": "2023-04-11T17:57:30.522198+00:00", "updated": "2024-04-12T03:42:26.928993+00:00" } } }, }, "fx": { "fork": [] }, "meta": {}, "iss": "did:web:spade.storage", "prf": [] } ``` ### `offer/arrange` When a broker receives an `aggregate/offer` invocation from a Storefront Principal, an [Effect](https://github.com/ucan-wg/invocation/#7-effect) for this submission is created with join task to be performed asynchronously. ```json { "iss": "did:web:spade.storage", "aud": "did:web:web3.storage", "att": [{ "with": "did:web:spade.storage", "can": "offer/arrange", "nb": { "link": "bafy...offer", } }], "prf": [], "sig": "..." } ``` Once this invocation is executed, a receipt is generated with the status of the task updated. Accepted aggregate receipt will provide aggregate offer operation info: ```json { "ran": "bafy...arrange", "out": { "ok": { "link": "bafy...offer" } }, "fx": { "fork": [] }, "meta": {}, "iss": "did:web:spade.storage", "prf": [] } ``` If offered aggregate is invalid, details on failing commPs are also reported: ```json { "ran": "bafy...invocation", "out": { "error": { "link": "bafy...offer", "cause": [{ "commP": "commP", "reason": "reasonCode", }], }, }, "fx": { "fork": [] }, "meta": {}, "iss": "did:web:spade.storage", "prf": [] } ``` ### Schema ```ipldsch type Aggregate union { | Link "queued" | Link "status" | Link "rejected" } representation keyed type AggregateCapability enum { AggregateOffer "aggregate/offer" AggregateGet "aggregate/get" } representation inline { discriminantKey "can" } type AggregateGet struct { with StorefrontDID nb SucceedAggregateRef } type SucceedAggregateRef struct { link &AggregateCBOR } type AggregateRef struct { link &AggregateCBOR } type AggregateOffer struct { with StorefrontDID nb AggregateOfferDetail } type AggregateOfferDetail struct { offer: Offer } type Offer { link &AggregateCBOR src [URL] size number } type StorefrontDID string type URL string type AggregateCBOR any type OfferCapability union { OfferArrange "offer/arrange" } representation inline { discriminantKey "can" } type OfferArrange struct { with BrokerDID nb AggregateRef } type BrokerDID string ``` [`did:web`]: https://w3c-ccg.github.io/did-method-web/ [UCAN]: https://github.com/ucan-wg/spec/ [principal]: https://github.com/ucan-wg/spec/#321-principals [authority]:#authority [Protocol Labs]:https://protocol.ai/ [Vasco Santos]:https://github.com/vasco-santos [Irakli Gozalishvili]:https://github.com/Gozala [Alan Shaw]:https://github.com/alanshaw

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully