-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: upgrade filecoin api with content store to rely on roundabout #360
fix: upgrade filecoin api with content store to rely on roundabout #360
Conversation
View stack outputs
|
2e5bb6a
to
3253ccd
Compare
3253ccd
to
1f45386
Compare
Filecoin api exported tests still using CARs instead of Blobs, which means storacha/w3infra#360 need to have TestContentStore to use CARs to make these tests work https://github.com/w3s-project/w3infra/pull/360/files#diff-cd843762832d0767495ff56f3f8692a15262dce245db89690794a1316868e25aR99 But, we want to use Blobs already, so let's make the tests also want Blobs across Filecoin pipeline :) note that in practise both Blobs and CARs work, but for testing we are only writing one of them and is a CAR today https://github.com/w3s-project/w3up/blob/main/packages/filecoin-api/test/events/storefront.js#L42
1f45386
to
ef018d1
Compare
ef018d1
to
7164afa
Compare
7164afa
to
0907272
Compare
0907272
to
f335473
Compare
f335473
to
16c788c
Compare
@@ -41,6 +41,7 @@ export default { | |||
|
|||
app.stack(BusStack) | |||
app.stack(UploadDbStack) | |||
app.stack(RoundaboutStack) |
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.
FilecoinStack now requires Roundabout endpoint deployed
16c788c
to
5f05460
Compare
// create URL for the link to be fetched | ||
const getUrl = new URL(`/${cid.toString()}`, storeHttpEndpoint) | ||
|
||
// Retry a few times as it looks like R2 sometimes takes a bit to make it available |
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.
context: This was difficult to find. It was making integration tests sometimes fail before I added the retry as R2 would give 404...
res = await pRetry((async () => { | ||
const fetchRes = await fetch(getUrl, { | ||
// Follow potential redirects | ||
redirect: 'follow', |
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 the default no?
filecoin/store/content.js
Outdated
}) | ||
if (fetchRes.status === 404) { | ||
throw new RecordNotFound(`blob ${cid.toString()} not found in store`) | ||
} else if (fetchRes.status > 299 || !fetchRes.body) { |
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.
} else if (fetchRes.status > 299 || !fetchRes.body) { | |
} else if (!fetchRes.ok || !fetchRes.body) { |
filecoin/store/content.js
Outdated
} | ||
|
||
// To satisfy typescript | ||
if (!res.body) { |
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.
Return fetchRes.body
above where you have already checked it is not null and then you don't need this check.
Today Storefront relies directly on a bucket (in S3) to read bytes to derive PieceCID for validation. With blob protocol, we are moving to write to R2 only 🙌🏼 therefore, we aim to make filecoin Storefront able to read from anywhere, but also not increase the infra costs with this change.
This PR changes Storefront to rely on Roundabout to read Blob bytes to derive Piece CID from anywhere instead of
contentStore
being directly hooked to a bucket. See usageRelying on Roundabout introduces a layer of indirection, but in current implementation where this validation runs in AWS and content will likely be read from CF, makes it cost optimal to read from Roundabout.
Closes storacha/w3up#1349