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

store access-api delegation bytes in R2 not D1 #571

Closed
Tracked by #475
gobengo opened this issue Mar 20, 2023 · 1 comment
Closed
Tracked by #475

store access-api delegation bytes in R2 not D1 #571

gobengo opened this issue Mar 20, 2023 · 1 comment
Assignees
Milestone

Comments

@gobengo
Copy link
Contributor

gobengo commented Mar 20, 2023

Motivation:

Solutions Considered

  • move delegation bytes out of D1 and into a non-d1 cloudflare data store
    • pros
      • cheap to try to remove the biggest data from d1 - bytes
      • changes max amount of delegations stored from O(100MB/(avgByteLength * n)) to O(100Mb/n)
    • cons
      • reading delegations will be slower. Before the read just had to query D1, but now it will query D1 for delegation CIDs, and then read the bytes for those CIDs from R2
      • migrating this data will be more complicated. When it's in d1, we can use d1 migrations and sql to manage data migrations like e.g. adding a delegations expiry index. If the underlying delegation bytes are not in D1, we will need to make our own data migration system that spans the data stores we do use.
      • non-bytes data will still be in D1 and subject to size limitation
  • avoid using d1 entirely
    • this may make sense in the long run, e.g. using a datastore with a much bigger size limit, but I don't think we can do this quickly today without looking beyond cloudflare's data storage products (e.g. to AWS like DyanmoDB or Aurora)
    • pros
      • avoid D1 and its limits entirely
    • cons
      • would involve modifying models/DBs/functionality in access-api other than just delegations
      • complexity of using cloudflare workers with non-cloudflare data store
        • e.g. what would localdev use?
  • store delegation bytes using web3.storage store/add protocol
    • insufficient because the delegations may be non-public, but all things stored in web3.storage are retrievable by CID alone

data store needs for delegation bytes

  • stored delegations are non-public and we only serve them to authorized invocations e.g. access/claim invocations
  • want read-after-write strong consistency
    • e.g. for access/delegate + immediate access/claim
  • keys will be CIDs
  • value never needs to be mutated once written
  • deletes of delegation CIDs can be processed eventually

should we store bytes in cloudflare KV or R2?

tl;dr - looks like R2 provides what's needed at the lowest cost

@gobengo
Copy link
Contributor Author

gobengo commented Mar 20, 2023

(via @Gozala)
Long term: consider whether r2 key format should be similar to elastic ipfs s3 key format
{car.cid}/{root.cid}.{fileExtension}

gobengo added a commit that referenced this issue Mar 23, 2023
Motivation:
* first PR on #571

todo
* [x] initial `DbDelegationsStorageWithR2` that passes tests as a
`DelegationsStorage`
* [x] rm unused access-ws package
#596
* [x] access-api should use `DbDelegationsStorageWithR2` and not
`DbDelegationsStorage` (without r2) and still pass tests
#599

informed by review
* [x] add r2 bucket name binding to wrangler.toml for staging,
production
#578 (comment)

unblocks:
* `DbDelegationsStorageWithR2` supports deletes
* we don't need this to support current `DelegationsStorage`, but
probably will before long, but doesn't need to block this PR
* optimization where r2 stores all the CIDs with varying multibases but
for the same hash only once
* safe to remove `DbDelegationsStorage`, `DelegationsV2Row`,
`DelegationsV2Tables`

---------

Co-authored-by: Irakli Gozalishvili <[email protected]>
@gobengo gobengo closed this as completed Mar 24, 2023
gobengo added a commit that referenced this issue Apr 11, 2023
Motivation:
* first PR on #571

todo
* [x] initial `DbDelegationsStorageWithR2` that passes tests as a
`DelegationsStorage`
* [x] rm unused access-ws package
#596
* [x] access-api should use `DbDelegationsStorageWithR2` and not
`DbDelegationsStorage` (without r2) and still pass tests
#599

informed by review
* [x] add r2 bucket name binding to wrangler.toml for staging,
production
#578 (comment)

unblocks:
* `DbDelegationsStorageWithR2` supports deletes
* we don't need this to support current `DelegationsStorage`, but
probably will before long, but doesn't need to block this PR
* optimization where r2 stores all the CIDs with varying multibases but
for the same hash only once
* safe to remove `DbDelegationsStorage`, `DelegationsV2Row`,
`DelegationsV2Tables`

---------

Co-authored-by: Irakli Gozalishvili <[email protected]>
Peeja pushed a commit to storacha/upload-service that referenced this issue Jan 17, 2025
🤖 I have created a release *beep* *boop*
---


##
[5.0.0](storacha/w3ui@vue-uploads-list-v4.0.1...vue-uploads-list-v5.0.0)
(2023-11-21)


### ⚠ BREAKING CHANGES

* pin solid and vue upload packages
([storacha#589](storacha/w3ui#589))

### Features

* add support for getting an account's plan
([storacha#564](storacha/w3ui#564))
([11023a4](storacha/w3ui@11023a4))
* pin solid and vue upload packages
([storacha#589](storacha/w3ui#589))
([2f7707f](storacha/w3ui@2f7707f))
* re-export Service from `react-keyring`
([storacha#577](storacha/w3ui#577))
([308816d](storacha/w3ui@308816d))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Travis Vachon <[email protected]>
Peeja pushed a commit to storacha/upload-service that referenced this issue Jan 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[5.0.0](storacha/w3ui@vue-uploads-list-v4.0.1...vue-uploads-list-v5.0.0)
(2023-11-21)


### ⚠ BREAKING CHANGES

* pin solid and vue upload packages
([storacha#589](storacha/w3ui#589))

### Features

* add support for getting an account's plan
([storacha#564](storacha/w3ui#564))
([9565452](storacha/w3ui@9565452))
* pin solid and vue upload packages
([storacha#589](storacha/w3ui#589))
([aeeedc5](storacha/w3ui@aeeedc5))
* re-export Service from `react-keyring`
([storacha#577](storacha/w3ui#577))
([94e8b96](storacha/w3ui@94e8b96))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Travis Vachon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants