Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

feat: initial implementation #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GATEWAY="http://localhost:9081"
USE_IPFS_PATH=true
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Deploy
on: [workflow_dispatch]
env:
AWS_REGION: us-west-2
LAMBDA: read-test
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Use Node.js Current
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Restore cached dependencies
uses: actions/cache@v2
with:
path: node_modules
key: node-modules-${{ hashFiles('package.json') }}
- name: Install dependencies
run: npm install
- name: Lint code
run: npm run lint
- name: Build
run: npm run build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Deploy
run: npm run deploy
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: ci
on:
push:
branches:
- master
pull_request:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- uses: bahmutov/npm-install@v1
- run: npm run test
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,25 @@
The `gateway-read-test-lambda` aims to track the IPFS gateway performance over time once writes happen in nft.storage, as well as alerting when availability issues happen.

It uses the [nft.storage gateway](https://github.com/nftstorage/nft.storage/tree/main/packages/gateway), which keeps a record of the performance of each backend gateway it uses, as well as which gateways had successfully retrieved a given [CID](https://docs.ipfs.io/concepts/content-addressing/#identifier-formats).

## Assumptions

For the gateway read test MVP there are a few assumptions in place and this lambda function will try to read a given CID from the gateway if:
- S3 Object Metadata has a "Complete" structure
- S3 Object has a DagPB encoded root with a known size __acceptable__ (100MB) and the S3 directory for that root CID already has all the expected chunks

Once we have the new CAR chunking in place where last sent CAR has the root, we will be able to simplify the lambda logic to only try to fetch from the gateway when that CAR is received. With this, the current assumptions can be dropped.

## AWS Setup

This project already comes with a script for build and deploy (which is also integrated with Github Actions). However it needs:
- Project creation in AWS
- It needs a role policy with S3 `s3:GetObject` and `s3:ListBucket` privilleges
- Secrets setup in Repo secrets for automatic deploy
- Environment variables setup

## What's next?

- CBOR
- Trigger an alert when data is not available from the nft.storage gateway within a reasonable timeframe.
- What to do with really large CAR files ?
8 changes: 8 additions & 0 deletions mocks/gateway.nft.storage/get_.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* https://github.com/sinedied/smoke#javascript-mocks
*/
module.exports = async () => {
return {
statusCode: 200
}
}
8 changes: 8 additions & 0 deletions mocks/gateway.nft.storage/get_ipfs#@cid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* https://github.com/sinedied/smoke#javascript-mocks
*/
module.exports = async () => {
return {
statusCode: 200
}
}
Loading