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

feat: add blob protocol to upload-client #1425

Merged
merged 43 commits into from
May 13, 2024
Merged

feat: add blob protocol to upload-client #1425

merged 43 commits into from
May 13, 2024

Conversation

joaosa
Copy link
Contributor

@joaosa joaosa commented Apr 30, 2024

Clsoes storacha/project-tracking#47

  • Replaces the store/add call with blob/add on the upload-client;
  • Add blob/remove and blob/list;
  • Ports store-related tests to create a blob protocol counterpart;
  • Fixes associated tests.

@joaosa joaosa changed the title feat: add blob/add to upload-cli feat: add blob/add to upload-client Apr 30, 2024
@joaosa joaosa force-pushed the feat/blob-add-cli branch 3 times, most recently from d8e3391 to 28cbbac Compare April 30, 2024 18:40
@joaosa joaosa marked this pull request as draft April 30, 2024 18:49
@joaosa joaosa force-pushed the feat/blob-add-cli branch 2 times, most recently from bc77447 to b6e213f Compare May 2, 2024 15:44
Copy link
Contributor

@Gozala Gozala left a comment

Choose a reason for hiding this comment

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

Added a comment

@joaosa joaosa marked this pull request as ready for review May 6, 2024 19:25
@joaosa joaosa requested a review from alanshaw May 6, 2024 19:25
@Gozala
Copy link
Contributor

Gozala commented May 6, 2024

@joaosa I suspect that w3up-client tests are failing because the upload-api in-memory service isn't wired with new capabilities, I'm not exactly sure why though

Actually looks like failing tests also use mocks as opposed to actual upload-api service hence the problem https://github.com/w3s-project/w3up/blob/21065624c20108b208dc106193a60d307fd7391b/packages/w3up-client/test/client.test.js#L37-L88

@joaosa joaosa force-pushed the feat/blob-add-cli branch 5 times, most recently from 0a92134 to aaf2a42 Compare May 6, 2024 23:01
@joaosa
Copy link
Contributor Author

joaosa commented May 6, 2024

Something is eluding me as suddenly the CI decided to start firing prettier errors with no changes from my side 🤔

@joaosa joaosa force-pushed the feat/blob-add-cli branch 9 times, most recently from 2dba4d4 to 3d28eb0 Compare May 7, 2024 19:06
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Looks great, I've left some minor feedback but this should be good to merge after it's addressed IMO.

🚀

@@ -161,6 +161,11 @@ async function allocate({ context, blob, space, cause }) {

// 3. if not already allocated (or expired) execute `blob/allocate`
if (!blobAllocateReceipt) {
// Create allocation task and save it
const saveTask = await context.tasksStorage.put(task)
Copy link
Member

Choose a reason for hiding this comment

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

Ok I think this is the quirk that @Gozala is going to fix today 🤞. I think it's ok to do here, but not necessary in production.

The code that stores invocations and receipts runs in w3infra. So this should be done automatically for you in allocate.execute(...) below.

In the tests here, there's no code that does this automatically, which is why in tests you see this: https://github.com/w3s-project/w3up/blob/f8132ca1fced72a4addc7e9f0a2162e823c1ea5f/packages/upload-api/test/helpers/blob.js#L113-L115

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually part of @Gozala's PR into my branch, but good to get more context 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I have added this before I realized what was going on, I have branch that I'm actively trying to finish that should fix this and will remove these lines also.

packages/upload-client/src/blob.js Outdated Show resolved Hide resolved
packages/upload-client/src/blob.js Outdated Show resolved Hide resolved
packages/upload-client/src/blob.js Outdated Show resolved Hide resolved
packages/upload-client/src/blob.js Outdated Show resolved Hide resolved
packages/upload-client/src/blob.js Outdated Show resolved Hide resolved
}
blob: {
add: ServiceMethod<BlobAdd, BlobAddSuccess, BlobAddFailure>
remove: ServiceMethod<BlobRemove, BlobRemoveSuccess, BlobRemoveFailure>
Copy link
Member

Choose a reason for hiding this comment

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

Argh, I completely forgot, we're also going to need blob/get for the console. Could you send a follow up PR to add? So sorry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't really see this capability in the spec. How should we go about this?

Copy link
Member

@alanshaw alanshaw May 13, 2024

Choose a reason for hiding this comment

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

Ah yes it'll need a specs PR also.

Essentially the same as store/get - it allows the caller to get the size of the blob (and potentially other stuff in the future). The allocations storage already has a method, you just need to create a handler, call it and return it: https://github.com/w3s-project/w3up/blob/9982d12b0a1f9a6da3f0d4264b9a35348e189dfb/packages/upload-api/src/types/blob.ts#L20-L23

it('stores a DAG with the service', async () => {
const space = await Signer.generate()
const agent = await Signer.generate()
const car = await randomCAR(128)
Copy link
Member

Choose a reason for hiding this comment

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

I'd use just random bytes here - there's no need to associate this with CARs. Same for all of these tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

packages/w3up-client/src/capability/store.js Outdated Show resolved Hide resolved
import * as Test from '../test.js'

export const BlobClient = Test.withContext({
'should store a CAR file': async (
Copy link
Member

Choose a reason for hiding this comment

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

Again, just reference blobs here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

joaosa and others added 7 commits May 10, 2024 15:38
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
@joaosa joaosa requested a review from alanshaw May 10, 2024 15:25
})
}

return multihash
Copy link
Contributor

Choose a reason for hiding this comment

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

I would expect blob/add not to return until task corresponding to result.out.ok.site is done, which I realize from the current state of the backend implementation have no good way of doing. Never the less I'll try to make a PR that will add missing pieces. I don't think we should block this in the meantime.

@joaosa joaosa merged commit 49aef56 into main May 13, 2024
14 checks passed
@joaosa joaosa deleted the feat/blob-add-cli branch May 13, 2024 15:17
travis pushed a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[17.1.0](capabilities-v17.0.0...capabilities-v17.1.0)
(2024-05-14)


### Features

* add "plan/create-admin-session" capability
([#1411](#1411))
([50eeeb5](50eeeb5))
* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))

---
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>
travis added a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[18.4.0](access-v18.3.2...access-v18.4.0)
(2024-05-14)


### Features

* add "plan/create-admin-session" capability
([#1411](#1411))
([50eeeb5](50eeeb5))
* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))

---
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 <travis.vachon@protocol.ai>
travis added a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[14.1.0](upload-client-v14.0.0...upload-client-v14.1.0)
(2024-05-14)


### Features

* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))


### Fixes

* cid for filecoin offer must be raw
([#1450](#1450))
([c3dd7b5](c3dd7b5))


### Other Changes

* appease linter
([782c6d0](782c6d0))

---
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 <travis.vachon@protocol.ai>
travis added a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[13.1.0](w3up-client-v13.0.1...w3up-client-v13.1.0)
(2024-05-14)


### Features

* add "plan/create-admin-session" capability
([#1411](#1411))
([50eeeb5](50eeeb5))
* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))


### Fixes

* test against actual api
([#1438](#1438))
([f8132ca](f8132ca))

---
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 <travis.vachon@protocol.ai>
travis added a commit that referenced this pull request May 14, 2024
🤖 I have created a release *beep* *boop*
---


##
[14.0.0](upload-api-v13.0.2...upload-api-v14.0.0)
(2024-05-14)


### ⚠ BREAKING CHANGES

* deprecate issuer
([#1344](#1344))

### Features

* add "plan/create-admin-session" capability
([#1411](#1411))
([50eeeb5](50eeeb5))
* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))
* deprecate issuer
([#1344](#1344))
([afbbde3](afbbde3))
* move blob index logic from upload-api to blob-index lib
([#1434](#1434))
([797f628](797f628))
* remove issuer row
([#1345](#1345))
([cf5b0db](cf5b0db))


### Fixes

* `encodeURIComponent` on bucket origin
([#1448](#1448))
([5618644](5618644))
* add format specifier to blob location claim URL
([#1445](#1445))
([9982d12](9982d12))
* test against actual api
([#1438](#1438))
([f8132ca](f8132ca))

---
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 <travis.vachon@protocol.ai>
vasco-santos pushed a commit that referenced this pull request May 23, 2024
🤖 I have created a release *beep* *boop*
---


##
[7.0.0](filecoin-api-v6.0.1...filecoin-api-v7.0.0)
(2024-05-23)


### ⚠ BREAKING CHANGES

* **upload-api:** integrate agent store for idempotence &
invocation/receipt persistence
([#1444](#1444))

### Features

* add blob protocol to upload-client
([#1425](#1425))
([49aef56](49aef56))
* **upload-api:** integrate agent store for idempotence &
invocation/receipt persistence
([#1444](#1444))
([c9bf33e](c9bf33e))


### Fixes

* check service did in w3filecoin
([#1476](#1476))
([11b00bf](11b00bf))


### Other Changes

* appease linter
([782c6d0](782c6d0))

---
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>
vasco-santos added a commit that referenced this pull request Jun 4, 2024
- Verifies that `blob/accept` has succeeded before concluding `blob/add`
as per
#1425 (comment). A
location commitment is returned instead of the blob multihash.

---------

Co-authored-by: Vasco Santos <santos.vasco10@gmail.com>
Co-authored-by: Alan Shaw <alan.shaw@protocol.ai>
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

Successfully merging this pull request may close these issues.

3 participants