-
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
feat: upgrade storefront api with filecoin offer from bucket event instead of directly compute #343
Conversation
bbda033
to
1f3b1f3
Compare
a18f008
to
31a834f
Compare
31a834f
to
e9c6d1c
Compare
e9c6d1c
to
f85dccb
Compare
@@ -140,7 +140,7 @@ export const createSQS = async (opts = {}) => { | |||
const port = opts.port || 9324 | |||
|
|||
const queue = await pRetry(() => | |||
new Container('softwaremill/elasticmq') | |||
new Container('softwaremill/elasticmq:1.5.4') |
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 like latest queue docker image is bad 😱
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 was failing with a random error, fixed it for now to previous version
f85dccb
to
0ab61f5
Compare
0ab61f5
to
4b7fe90
Compare
4b7fe90
to
6343e78
Compare
6343e78
to
01724a5
Compare
01724a5
to
45776db
Compare
45776db
to
e40cd0f
Compare
e40cd0f
to
e33fa3e
Compare
e33fa3e
to
0906e7a
Compare
0906e7a
to
cb735d2
Compare
View stack outputs
|
|
||
const { ok, error } = await storefrontEvents.handlePieceInsertToEquivalencyClaim(context, record) |
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.
we now use the API 🎉
const context = { | ||
pieceStore: createPieceTable(AWS_REGION, pieceTableName) | ||
pieceStore: createPieceTable(AWS_REGION, pieceTableName), | ||
dataStore: composeDataStoresWithOrderedStream( |
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.
we want to read from S3 first, fallback to R2 if not there (prep for new world)
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 would read more naturally if it was something like
cons s3 = createDataStore(AWS_REGION, s3BucketName)
const r2 = createDataStore(R2_REGION, r2BucketName, {
endpoint: r2BucketEndpoint,
credentials: {
accessKeyId: r2BucketAccessKeyId,
secretAccessKey: r2BucketSecretAccessKey,
},
})
const store = S3.or(r2)
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.
good call, we actually already use this pattern on upload-api
https://github.com/web3-storage/w3infra/blob/main/upload-api/functions/ucan-invocation-router.js#L185C52-L186C1 and that is why I kept. But probably we could get more declarative on a follow up
// Only used for testing storing a CAR | ||
// until we hook up claims to look for data | ||
put: async (bytes) => { | ||
const hash = await sha256.digest(bytes) | ||
const root = CID.create(1, raw.code, hash) | ||
|
||
const { writer, out } = CarWriter.create(root) | ||
writer.put({ cid: root, bytes }) | ||
writer.close() | ||
|
||
const chunks = [] | ||
for await (const chunk of out) { | ||
chunks.push(chunk) | ||
} | ||
const blob = new Blob(chunks) | ||
const cid = await CAR.codec.link(new Uint8Array(await blob.arrayBuffer())) | ||
|
||
const putCmd = new PutObjectCommand({ | ||
Bucket: bucketName, | ||
Key: `${cid.toString()}/${cid.toString()}.car`, | ||
Body: bytes |
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.
we only need this for the tests, so that we can put something on the store. Maybe I should change the API to have an augmented store just on the tests interface, but not the actual service store. WDYT?
@@ -140,7 +140,7 @@ export const createSQS = async (opts = {}) => { | |||
const port = opts.port || 9324 | |||
|
|||
const queue = await pRetry(() => | |||
new Container('softwaremill/elasticmq') | |||
new Container('softwaremill/elasticmq:1.5.4') |
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 was failing with a random error, fixed it for now to previous version
@@ -13,7 +13,7 @@ | |||
"lint": "tsc && eslint '**/*.js'", | |||
"clean": "rm -rf dist node_modules package-lock.json ./*/{.cache,dist,node_modules}", | |||
"test": "npm test -w billing -w upload-api -w carpark -w replicator -w satnav -w roundabout -w filecoin", | |||
"test-integration": "ava --verbose --serial --timeout=600s test/*.test.js", | |||
"test-integration": "ava --verbose --serial --timeout=660s test/*.test.js", |
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.
not sure if needed, but now tests look a bit slower with extra queue
if (result === undefined) { | ||
throw new Error('no result received') | ||
} | ||
return result |
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: result should probably aggregate errors as opposed to just returning the last error.
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.
true, given this is a temporary thing I am tempted to keep it, given otherwise would be difficult to align the types
const context = { | ||
pieceStore: createPieceTable(AWS_REGION, pieceTableName) | ||
pieceStore: createPieceTable(AWS_REGION, pieceTableName), | ||
dataStore: composeDataStoresWithOrderedStream( |
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 would read more naturally if it was something like
cons s3 = createDataStore(AWS_REGION, s3BucketName)
const r2 = createDataStore(R2_REGION, r2BucketName, {
endpoint: r2BucketEndpoint,
credentials: {
accessKeyId: r2BucketAccessKeyId,
secretAccessKey: r2BucketSecretAccessKey,
},
})
const store = S3.or(r2)
This is not needed since #1332 got released and used in w3infra storacha/w3infra#343 and has been deployed in production without issues for the last few weeks BREAKING CHANGE: not possible to skip submit queue on storefront service anymore
This PR intends to upgrade storefront package. This enables
filecoin/offer
invocations lead to messages to the submit queue, where message consumer will compute Piece for the content. The main goal of this is to have the client to compute Filecoin Pieces and offer them, instead of pieces being directly computed from bucket event and written into the DB (skipping the submit validation).Note that:
filecoin/offer
so that we can keep old clients running wherefilecoin/offer
is not invoked. This of course means that we may need to run Piece computation twice for the old path. However, looking at our AWS bill, we paid 200 USD in February for lambda execution of whole w3infra. This assumes then that we will not incur a lot of additional cost while making migration much simplerNeeds: