-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
blob/add
to upload-cliblob/add
to upload-client
d8e3391
to
28cbbac
Compare
bc77447
to
b6e213f
Compare
There was a problem hiding this 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 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 |
0a92134
to
aaf2a42
Compare
Something is eluding me as suddenly the CI decided to start firing prettier errors with no changes from my side 🤔 |
2dba4d4
to
3d28eb0
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
} | ||
blob: { | ||
add: ServiceMethod<BlobAdd, BlobAddSuccess, BlobAddFailure> | ||
remove: ServiceMethod<BlobRemove, BlobRemoveSuccess, BlobRemoveFailure> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
import * as Test from '../test.js' | ||
|
||
export const BlobClient = Test.withContext({ | ||
'should store a CAR file': async ( |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed
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>
}) | ||
} | ||
|
||
return multihash |
There was a problem hiding this comment.
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.
🤖 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>
🤖 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>
🤖 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>
🤖 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>
🤖 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>
🤖 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>
- 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>
Clsoes storacha/project-tracking#47
store/add
call withblob/add
on the upload-client;blob/remove
andblob/list
;