-
Notifications
You must be signed in to change notification settings - Fork 22
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: generate sharded DAG index on client and invoke w index/add
#1451
Conversation
@@ -7,7 +7,7 @@ import varint from 'varint' | |||
*/ | |||
|
|||
/** Byte length of a CBOR encoded CAR header with zero roots. */ | |||
const NO_ROOTS_HEADER_LENGTH = 17 | |||
const NO_ROOTS_HEADER_LENGTH = 18 |
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.
🤦 FML this was wrong. Either it was wrong the whole time or @ipld/car
started encoding the header differently.
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.
nit: would be great to just export it from @ipld/car
@@ -19,7 +19,7 @@ export async function randomBytes(size) { | |||
} else { | |||
crypto.getRandomValues(chunk) | |||
} | |||
size -= bytes.length | |||
size -= chunk.length |
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.
FML we were creating random data in tests where the last 65,536 bytes were random but the rest was ZEROs.
for (const slice of slices.values()) { | ||
slice[0] += diff | ||
} | ||
controller.enqueue(await encodeCAR(blocks, slices, rootCID)) |
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.
Putting a root CID in the last CAR shard is a massive PITA. I wish we didn't do that.
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.
Wait, I thought we were putting it in the first shard.
Let's put it as a separate thing that is not in the set of shards. It would be easier to change that now.
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.
Yes I would like all shards to be rootless and track the DAG root in upload/add
and/or content claims.
f8fc6d5
to
6d691de
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.
See comments. I am not sure about the placement of the DAG block. Maybe better to change the index to keep it separate.
Review of test.index.js
was not done as I still need to understand how that code works.
|
||
// add the CAR shard itself to the slices | ||
meta.slices.set(meta.cid.multihash, [0, meta.size]) | ||
shardIndexes.push(meta.slices) |
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.
Check with ShardedDAGIndex
, but I thought this was supposed to be the first slice.
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.
They are sorted when encoded anyway so it doesn't matter where you put it?
{ message: 'failed index/add invocation' } | ||
) | ||
}) | ||
}) |
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.
Will any of these tests fail if the DAG block is in the wrong place or missing? If no, then that would be good. Or, change the index to put the DAGblock in a different place than the others.
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.
No, but there probably should be a test that asserts the additional slice that spans the whole blob is added...
@@ -7,7 +7,7 @@ import varint from 'varint' | |||
*/ | |||
|
|||
/** Byte length of a CBOR encoded CAR header with zero roots. */ | |||
const NO_ROOTS_HEADER_LENGTH = 17 | |||
const NO_ROOTS_HEADER_LENGTH = 18 |
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.
nit: would be great to just export it from @ipld/car
…m:web3-storage/w3up into feat/generate-sharded-dag-index-in-client
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.
LGTM
some suggestions for follow ups in review, + filecoin/offer
things I believe MUST be added
@@ -183,5 +195,24 @@ async function uploadBlockStream( | |||
if (!root) throw new Error('missing root CID') | |||
|
|||
await Upload.add(conf, root, shards, options) | |||
|
|||
const index = ShardedDAGIndex.create(root) |
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.
nit: should we have an option to not index? I mean, let's do this by default, but we wanted this to be optional, perhaps just an issue where user can tweak their indexing intentions would be good enough for now
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.
} | ||
|
||
// Store the index in the space | ||
const indexDigest = await Blob.add(conf, indexBytes.ok, options) |
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.
nit: this is great to store in the space, but we will need to look into deleting this on remove from space to not have its usage. Maybe we can just fill in issue now?
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.
Co-authored-by: Vasco Santos <[email protected]>
Co-authored-by: Vasco Santos <[email protected]>
…m:web3-storage/w3up into feat/generate-sharded-dag-index-in-client
🤖 I have created a release *beep* *boop* --- ## [15.0.0](upload-api-v14.0.0...upload-api-v15.0.0) (2024-05-15) ### ⚠ BREAKING CHANGES * delegated capabilities required to use `uploadFile`, `uploadDirectory` and `uploadCAR` have changed. In order to use these methods your agent will now need to be delegated `blob/add`, `index/add`, `filecoin/offer` and `upload/add` capabilities. Note: no code changes are required. ### Features * generate sharded DAG index on client and invoke w `index/add` ([#1451](#1451)) ([a6d9026](a6d9026)) --- 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* --- ## [19.0.0](access-v18.4.0...access-v19.0.0) (2024-05-15) ### ⚠ BREAKING CHANGES * delegated capabilities required to use `uploadFile`, `uploadDirectory` and `uploadCAR` have changed. In order to use these methods your agent will now need to be delegated `blob/add`, `index/add`, `filecoin/offer` and `upload/add` capabilities. Note: no code changes are required. ### Features * generate sharded DAG index on client and invoke w `index/add` ([#1451](#1451)) ([a6d9026](a6d9026)) --- 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* --- ## [15.0.0](upload-client-v14.1.1...upload-client-v15.0.0) (2024-05-15) ### ⚠ BREAKING CHANGES * delegated capabilities required to use `uploadFile`, `uploadDirectory` and `uploadCAR` have changed. In order to use these methods your agent will now need to be delegated `blob/add`, `index/add`, `filecoin/offer` and `upload/add` capabilities. Note: no code changes are required. ### Features * generate sharded DAG index on client and invoke w `index/add` ([#1451](#1451)) ([a6d9026](a6d9026)) --- 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: Alan Shaw <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [14.0.0](w3up-client-v13.1.1...w3up-client-v14.0.0) (2024-06-04) ### ⚠ BREAKING CHANGES * **upload-api:** integrate agent store for idempotence & invocation/receipt persistence ([#1444](#1444)) * delegated capabilities required to use `uploadFile`, `uploadDirectory` and `uploadCAR` have changed. In order to use these methods your agent will now need to be delegated `blob/add`, `index/add`, `filecoin/offer` and `upload/add` capabilities. Note: no code changes are required. ### Features * generate sharded DAG index on client and invoke w `index/add` ([#1451](#1451)) ([a6d9026](a6d9026)) * **upload-api:** integrate agent store for idempotence & invocation/receipt persistence ([#1444](#1444)) ([c9bf33e](c9bf33e)) ### Fixes * check for blob/accept receipts before blob/add is concluded ([#1459](#1459)) ([462518c](462518c)) * export blob client ([#1485](#1485)) ([7944077](7944077)) * rename blob and index client capabilities ([#1478](#1478)) ([17e3a31](17e3a31)) --- 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: Vasco Santos <[email protected]>
🤖 I have created a release *beep* *boop* --- ## 1.0.0 (2024-12-02) ### ⚠ BREAKING CHANGES * **upload-api:** integrate agent store for idempotence & invocation/receipt persistence ([storacha#1444](https://github.com/storacha/upload-service/issues/1444)) * delegated capabilities required to use `uploadFile`, `uploadDirectory` and `uploadCAR` have changed. In order to use these methods your agent will now need to be delegated `blob/add`, `index/add`, `filecoin/offer` and `upload/add` capabilities. Note: no code changes are required. * coupon ([storacha#1136](https://github.com/storacha/upload-service/issues/1136)) * tweak readmes to get release-please to bump major version ([storacha#1102](https://github.com/storacha/upload-service/issues/1102)) ### Features * add "plan/create-admin-session" capability ([storacha#1411](https://github.com/storacha/upload-service/issues/1411)) ([50eeeb5](50eeeb5)) * add `subscription/list` capability ([storacha#1088](https://github.com/storacha/upload-service/issues/1088)) ([471d7e5](471d7e5)) * add blob protocol to upload-client ([storacha#1425](https://github.com/storacha/upload-service/issues/1425)) ([49aef56](49aef56)) * add CLI ([#39](#39)) ([112720e](112720e)) * add usage/report capability ([storacha#1079](https://github.com/storacha/upload-service/issues/1079)) ([6418b4b](6418b4b)) * coupon ([storacha#1136](https://github.com/storacha/upload-service/issues/1136)) ([1b94f2d](1b94f2d)) * expose OwnedSpace and SharedSpace from access-client ([storacha#1244](https://github.com/storacha/upload-service/issues/1244)) ([8ec1b44](8ec1b44)) * generate sharded DAG index on client and invoke w `index/add` ([storacha#1451](https://github.com/storacha/upload-service/issues/1451)) ([a6d9026](a6d9026)) * Generate Space proofs on the fly, on `access/claim` ([storacha#1555](https://github.com/storacha/upload-service/issues/1555)) ([9e2b1d4](9e2b1d4)) * router ([#11](#11)) ([c810735](c810735)) * tweak readmes to get release-please to bump major version ([storacha#1102](https://github.com/storacha/upload-service/issues/1102)) ([a411255](a411255)) * two more interface tweaks ([storacha#1287](https://github.com/storacha/upload-service/issues/1287)) ([bc3c364](bc3c364)) * upgrade ucanto/transport to 9.1.0 in all packages to get more verbose errors from HTTP transport on non-ok response ([storacha#1312](https://github.com/storacha/upload-service/issues/1312)) ([d6978d7](d6978d7)) * **upload-api:** integrate agent store for idempotence & invocation/receipt persistence ([storacha#1444](https://github.com/storacha/upload-service/issues/1444)) ([c9bf33e](c9bf33e)) * w3up client login ([storacha#1120](https://github.com/storacha/upload-service/issues/1120)) ([8279bf6](8279bf6)) ### Fixes * access client should request blob namespace capabilities ([storacha#1378](https://github.com/storacha/upload-service/issues/1378)) ([fc5bb4a](fc5bb4a)) * access-client package.json uses https instead of git for one-webcrypto dep to help with yarn compat ([storacha#1157](https://github.com/storacha/upload-service/issues/1157)) ([e1d0798](e1d0798)) * don't error when we can't figure out a name for a space ([storacha#1177](https://github.com/storacha/upload-service/issues/1177)) ([a31f667](a31f667)) * fix export paths for JS files ([storacha#1089](https://github.com/storacha/upload-service/issues/1089)) ([1a5d1aa](1a5d1aa)) * fix IndexedDB reset function ([storacha#1199](https://github.com/storacha/upload-service/issues/1199)) ([48cf555](48cf555)) * floating promises and add no-floating-promises to eslint-config-w3up ([storacha#1198](https://github.com/storacha/upload-service/issues/1198)) ([1b8c5aa](1b8c5aa)) * issue where typedoc docs would only show full docs for w3up-client ([storacha#1141](https://github.com/storacha/upload-service/issues/1141)) ([0b8d3f3](0b8d3f3)) * migrate repo ([storacha#1389](https://github.com/storacha/upload-service/issues/1389)) ([475a287](475a287)) * package metadata ([storacha#1161](https://github.com/storacha/upload-service/issues/1161)) ([b8a1cc2](b8a1cc2)) * point `main` at files included in the package ([storacha#1241](https://github.com/storacha/upload-service/issues/1241)) ([c0b306d](c0b306d)) * repo URLs ([storacha#1550](https://github.com/storacha/upload-service/issues/1550)) ([e02ddf3](e02ddf3)) * support storing ArrayBuffers in conf ([storacha#1236](https://github.com/storacha/upload-service/issues/1236)) ([9b1aafb](9b1aafb)) * sync space names from proofs ([storacha#1193](https://github.com/storacha/upload-service/issues/1193)) ([f552036](f552036)) * upgrade @ucanto/validator with bugfix ([storacha#1151](https://github.com/storacha/upload-service/issues/1151)) ([d4e961b](d4e961b)) * upgrade type-fest in access ([storacha#1263](https://github.com/storacha/upload-service/issues/1263)) ([47a4589](47a4589)) * upgrade ucanto core ([storacha#1127](https://github.com/storacha/upload-service/issues/1127)) ([5ce4d22](5ce4d22)) * upgrade ucanto libs and format filecoin api ([storacha#1359](https://github.com/storacha/upload-service/issues/1359)) ([87ca098](87ca098)) * upload API test fixes ([6b0d72d](6b0d72d)) * use an ArrayBuffer for delegation bits in AgentData ([storacha#1219](https://github.com/storacha/upload-service/issues/1219)) ([bddf874](bddf874)) * use one-webcrypto from npm ([storacha#1525](https://github.com/storacha/upload-service/issues/1525)) ([9345c54](9345c54)) ### Other Changes * Add `pnpm dev` to watch-build all packages ([storacha#1533](https://github.com/storacha/upload-service/issues/1533)) ([07970ef](07970ef)) * **main:** release access 16.5.0 ([storacha#1086](https://github.com/storacha/upload-service/issues/1086)) ([cf81c3a](cf81c3a)) * **main:** release access 16.5.1 ([storacha#1090](https://github.com/storacha/upload-service/issues/1090)) ([cb46ee9](cb46ee9)) * **main:** release access 17.0.0 ([storacha#1103](https://github.com/storacha/upload-service/issues/1103)) ([5b34dfb](5b34dfb)) * **main:** release access 17.1.0 ([storacha#1122](https://github.com/storacha/upload-service/issues/1122)) ([3f302a3](3f302a3)) * **main:** release access 18.0.0 ([storacha#1132](https://github.com/storacha/upload-service/issues/1132)) ([aa4ba63](aa4ba63)) * **main:** release access 18.0.1 ([storacha#1142](https://github.com/storacha/upload-service/issues/1142)) ([3d7f118](3d7f118)) * **main:** release access 18.0.2 ([storacha#1158](https://github.com/storacha/upload-service/issues/1158)) ([1dd371b](1dd371b)) * **main:** release access 18.0.3 ([storacha#1166](https://github.com/storacha/upload-service/issues/1166)) ([dfbc3f1](dfbc3f1)) * **main:** release access 18.0.4 ([storacha#1200](https://github.com/storacha/upload-service/issues/1200)) ([f51b066](f51b066)) * **main:** release access 18.0.5 ([storacha#1203](https://github.com/storacha/upload-service/issues/1203)) ([89080ca](89080ca)) * **main:** release access 18.0.6 ([storacha#1233](https://github.com/storacha/upload-service/issues/1233)) ([ddb413f](ddb413f)) * **main:** release access 18.0.7 ([storacha#1237](https://github.com/storacha/upload-service/issues/1237)) ([bb5235f](bb5235f)) * **main:** release access 18.1.0 ([storacha#1243](https://github.com/storacha/upload-service/issues/1243)) ([4991f70](4991f70)) * **main:** release access 18.1.1 ([storacha#1265](https://github.com/storacha/upload-service/issues/1265)) ([3244a26](3244a26)) * **main:** release access 18.2.0 ([storacha#1288](https://github.com/storacha/upload-service/issues/1288)) ([787fca6](787fca6)) * **main:** release access 18.3.0 ([storacha#1319](https://github.com/storacha/upload-service/issues/1319)) ([5701761](5701761)) * **main:** release access 18.3.1 ([storacha#1381](https://github.com/storacha/upload-service/issues/1381)) ([086759d](086759d)) * **main:** release access 18.3.2 ([storacha#1396](https://github.com/storacha/upload-service/issues/1396)) ([bcc958f](bcc958f)) * **main:** release access 18.4.0 ([storacha#1446](https://github.com/storacha/upload-service/issues/1446)) ([af9f44e](af9f44e)) * **main:** release access 19.0.0 ([storacha#1462](https://github.com/storacha/upload-service/issues/1462)) ([b16a0bf](b16a0bf)) * **main:** release access 20.0.0 ([storacha#1473](https://github.com/storacha/upload-service/issues/1473)) ([be8247f](be8247f)) * **main:** release access 20.0.1 ([storacha#1529](https://github.com/storacha/upload-service/issues/1529)) ([a82c4fb](a82c4fb)) * **main:** release access 20.1.0 ([storacha#1541](https://github.com/storacha/upload-service/issues/1541)) ([89836c0](89836c0)) * package renames ([0f797ed](0f797ed)) --- 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>
This PR generates index data for blocks as CAR shards are constructed. Once all shards have been successfully sent, a sharded DAG index is encoded and stored (using
blob/add
) and thenindex/add
is invoked with the CID of the index as a parameter.