Skip to content

Commit

Permalink
feat: add the EIPFS infra for the blob protocol (#361)
Browse files Browse the repository at this point in the history
- adds the EIPFS multihashes queue;
- adds the EIPFS blocks CAR positions table.
  • Loading branch information
joaosa authored Apr 29, 2024
1 parent cdb7c65 commit bb21369
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

EIPFS_INDEXER_SQS_ARN = 'arn:aws:sqs:us-west-2:505595374361:staging-ep-indexer-topic'
EIPFS_INDEXER_SQS_URL = 'https://sqs.us-west-2.amazonaws.com/505595374361/staging-ep-indexer-topic'
EIPFS_MULTIHASHES_SQS_ARN = 'arn:aws:sqs:us-west-2:505595374361:staging-ep-multihashes-topic'
EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN = 'arn:aws:dynamodb:us-west-2:505595374361:table/staging-ep-v1-blocks-cars-position'

PROVIDERS = ''
UPLOAD_API_DID = ''
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ AWS ARN for Elastic IPFS SQS indexer used to request Elastic IPFS to index given

AWS URL for Elastic IPFS SQS indexer used to request Elastic IPFS to index given CAR files.

#### `EIPFS_MULTIHASHES_SQS_ARN`

AWS ARN for Elastic IPFS SQS multihashes used to enqueue multihashes for indexed CAR files.

#### `EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN`

AWS ARN for Elastic IPFS DynamoDB table used to store blocks and positions for indexed CAR files.

#### `POSTMARK_TOKEN`

Postmark API token, which is used by the email verification system to send emails.
Expand Down
2 changes: 2 additions & 0 deletions stacks/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ export function getEnv() {
AGGREGATOR_URL: mustGetEnv('AGGREGATOR_URL'),
CONTENT_CLAIMS_DID: mustGetEnv('CONTENT_CLAIMS_DID'),
CONTENT_CLAIMS_URL: mustGetEnv('CONTENT_CLAIMS_URL'),
EIPFS_MULTIHASHES_SQS_ARN: mustGetEnv('EIPFS_MULTIHASHES_SQS_ARN'),
EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN: mustGetEnv('EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN'),
// Not required
STOREFRONT_PROOF: process.env.STOREFRONT_PROOF ?? '',
CONTENT_CLAIMS_PROOF: process.env.CONTENT_CLAIMS_PROOF ?? '',
Expand Down
33 changes: 31 additions & 2 deletions stacks/upload-api-stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import {
Config,
Function,
Queue,
Table,
use
} from 'sst/constructs'
import * as sqs from 'aws-cdk-lib/aws-sqs'
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb'

import { StartingPosition } from 'aws-cdk-lib/aws-lambda'
import { UploadDbStack } from './upload-db-stack.js'
import { BillingDbStack } from './billing-db-stack.js'
Expand All @@ -18,7 +22,7 @@ import { getCustomDomain, getApiPackageJson, getGitInfo, setupSentry, getEnv, ge
* @param {import('sst/constructs').StackContext} properties
*/
export function UploadApiStack({ stack, app }) {
const { AGGREGATOR_DID } = getEnv()
const { AGGREGATOR_DID, EIPFS_MULTIHASHES_SQS_ARN, EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN } = getEnv()

// Setup app monitoring with Sentry
setupSentry(app, stack)
Expand All @@ -30,6 +34,28 @@ export function UploadApiStack({ stack, app }) {
const { customerTable, spaceDiffTable, spaceSnapshotTable, stripeSecretKey } = use(BillingDbStack)
const { pieceOfferQueue, filecoinSubmitQueue } = use(FilecoinStack)

// Blob protocol
// Elastic IPFS event for multihashes
const multihashesQueue = new Queue(stack, 'multihashes-topic-queue', {
cdk: {
queue: sqs.Queue.fromQueueArn(
stack,
'multihashes-topic',
EIPFS_MULTIHASHES_SQS_ARN
),
},
})

const blocksCarPositionTable = new Table(stack, 'blocks-car-position-table', {
cdk: {
table: dynamodb.Table.fromTableArn(
stack,
'blocks-car-position',
EIPFS_BLOCKS_CAR_POSITION_TABLE_ARN
),
},
})

// Setup API
const customDomain = getCustomDomain(stack.stage, process.env.HOSTED_ZONE)
const pkg = getApiPackageJson()
Expand Down Expand Up @@ -62,7 +88,8 @@ export function UploadApiStack({ stack, app }) {
workflowBucket,
ucanStream,
pieceOfferQueue,
filecoinSubmitQueue
filecoinSubmitQueue,
multihashesQueue,
],
environment: {
DID: process.env.UPLOAD_API_DID ?? '',
Expand All @@ -89,6 +116,8 @@ export function UploadApiStack({ stack, app }) {
PIECE_TABLE_NAME: pieceTable.tableName,
PIECE_OFFER_QUEUE_URL: pieceOfferQueue.queueUrl,
FILECOIN_SUBMIT_QUEUE_URL: filecoinSubmitQueue.queueUrl,
MULTIHASHES_QUEUE_URL: multihashesQueue.queueUrl,
BLOCKS_CAR_POSITION_TABLE_NAME: blocksCarPositionTable.tableName,
NAME: pkg.name,
VERSION: pkg.version,
COMMIT: git.commmit,
Expand Down

0 comments on commit bb21369

Please sign in to comment.