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
    # api.nft.storage onboarding to w3filecoin ## Background `api.nft.storage` relies on dagcargo to track insertions on its postgres DB, in order to get uploaded CAR files to land into Filecoin SPs. `api.web3.storage` was sunset on the 9th of January in favour of new w3up, which relies on a brand new Filecoin pipeline called w3filecoin. Currently w3filecoin is triggered by a S3 Object Write bucket event in `carpark-prod-0`. However, we are currently working on decoupling the pipeline [web3-storage/w3up#1299](https://github.com/web3-storage/w3up/issues/1299) from this event into client triggering `filecoin/offer`. ## nft.storage a user of w3filecoin nft.storage direction is to not be migrated as a "tenant" of web3.storage. Therefore, the easiest path to get nft.storage to move from dagcargo to w3filecoin is to have nft.storage to be an independent user of w3filecoin aggregation pipeline. This way, nft.storage acts as a different Storefront without actually implementing the whole protocol for the Storefront. It will simply invoke `piece/offer` from Aggregator. This puts web3.storage without any responsability to in the future deal with renewals for nft.storage data. nft.storage performing `filecoin/submit` would put Storefront (w3up) in the middle, which is likely not desirable. ## nft.storage triggers w3filecoin options There are a few alternatives to have this integration: - trigger w3filecoin from S3 bucket `dotstorage-prod-1` write event - run a CRON job to query new uploads - trigger w3filecoin from `api.nft.storage` worker ### trigger w3filecoin from S3 bucket event This essentially mimics what we have today in place with w3up + w3filecoin. A Bucket event is triggered on write, running a lambda function that reads the bytes from S3 bucket, computes a PieceCID for them, writes equal claim and triggers the Filecoin pipeline via `piece/offer`. The main differences to current system would be: - hook up a lambda with `dotstorage-prod-1` instead of `carpark-prod-0` - use a nft.storage issuer instead of web3.storage issuer to differentiate offered pieces - trigger Filecoin pipeline via `piece/offer` instead of `filecoin/submit` #### Advantages - easy to implement - handles uniqueness out of the box #### Disadvantages - will flood R2 bucket with Head requests - workaround for main potencial issue with this solution is write cases where `api.nft.storage` failed uploading because it could not write to R2 (e.g. a rate limit issue) and S3 bucket event would still be triggered. This could cause SP to not be able to read the data. An alternative here would be to do a HEAD request to CF `carpark-prod-0` bucket before moving forward with the rest. This would cause a big spike on class A ops in R2 bucket ### run a CRON job to query new uploads This solution would go more towards what dagcargo partially does today. Run queries over the DB to get to know new uploads, and send them over for aggregation. New uploads discovered should be put into a queue to run similar lambda function to the S3 bucket event, but without need to perform HEAD request to R2, as it is guaranteed to have succeeded. A store MUST exist to both track a pointer to where we were before in the CRON #### Advantages - handles uniqueness out of the box if we just track `content` table insertions. But Aggregator will also dedupe by `piece/group` #### Disadvantages - more complex and expensive to run - may need more monitoring ### trigger w3filecoin from `api.nft.storage` worker We can compute the PieceCID of the data while running the worker with the user request. Note that running Piece computation in the 30s of the worker runtime may be problematic for arbitrary piece sizes, but a maximum of 100mb chunks is fine. My tests showed around 10s to compute 100mb chunk (while also needing to read from R2). Once we compute PieceCID, an equal claim can be issued and the Piece can be offered to the `w3filecoin` right away using `piece/offer`. #### Advantages - easy to implement - lower costs to run #### Disadvantages - no uniqueness on requests to aggregator. But Aggregator will also dedupe by `piece/group` ## Design proposal For the nft.storage write side of things, based on the `nft.storage triggers w3filecoin options` section, it looks like the best solution will be to trigger the w3filecoin pipeline directly from `api.nft.storage` worker, when user is uploading the data. On the read side, status/check API will need to be updated to not be fully backed by dagcargo DB to get information about deals. We currently perform 2 queries to get the information of an upload, first get the upload and then get the "deals" for it. Therefore, we can check the insertion date, and with that decide if we check in dagcargo DB, or if we will get that information from w3filecoin, relying on deal tracker. Regarding w3filecoin pipeline there are two main issues that need to be solved to accomplish this: - w3up providers support - https://github.com/web3-storage/w3filecoin-infra/issues/49 - aggregate grouping by storefront requester - create separate aggregate offers for web3.storage and nft.storage, so that each product can have their own wallet, and test it goes all the way to Dealer Finally, within Spade integration context we will need to flush out how to distinct aggregates offered from each product: - w3filecoin Dealer currently writes offers to a bucket with a `"collection":"did:web:web3.storage"` property in the JSON. If we can make use of collections to set the nft.storage collection it would be great. - otherwise, Dealer can also look into having a second bucket with offers from nft.storage. This solution is less optimal as it would make w3filecoin not generic on who issued aggregation as the collection, as it would need to provision buckets for each new client. ## Assumptions - api.nft.storage continues to write to `carpark-prod-0` in Cloudflare and roundabout reads from there by default, or at least fallsback to it - otherwise, SPs won't be able to read pieces to build the aggregate for commitment - api.nft.storage still has access to dagcargo DB ## Tasks P0 - [x] Make PieceCid computation possible in CF workers [fr32-sha2-256-trunc254-padded-binary-tree-multihash#33](https://github.com/web3-storage/fr32-sha2-256-trunc254-padded-binary-tree-multihash/pull/33) - [ ] Write inclusion claims - https://github.com/web3-storage/w3up/issues/1275 - [ ] Run PieceCid computation within api.nft.storage Cloudflare Worker - [ ] Offer Piece for aggregation using `piece/offer` and submit equal claim - [ ] Change status API to (uploads inserted after change date) check deal/info instead - filecoin/info - [ ] needs to rely on equal claims and inclusion claims P1 - [ ] Make aggregator distinct offered pieces by issuer https://github.com/web3-storage/w3filecoin-infra/issues/49 - [ ] Connect with Spade team on how to achieve multi-wallet design - either distinct bucket, or did offered? ## Open Questions - @dchoi What will we do with renewals for nft.storage? - @dchoi Must MVP include separation of aggregates built for each product? - @riba would you keep dagcargo DB for now as read only so that we can read the state? or will we need to get a dump of any sort?

    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