Skip to content

Commit

Permalink
feat: support [email protected]
Browse files Browse the repository at this point in the history
The IPFS Cluster v1 release has much improved perf, and some breaking API changes.

In this PR we upgrade the ipfs-cluster client and local test environment to work with the v1 cluster API.

When this PR is merged to main, the staging API credentials must be updated.

The production release of this PR needs to be coordinated with the upgrade of the ipfs-cluster binaries on the prod cluster.

There will be a second PR to update the pins cron, which should be merged to main once the prod cluster is upgraded.

see: #1184

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <[email protected]>
  • Loading branch information
olizilla committed Apr 7, 2022
1 parent 07c4315 commit d7899a0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
18 changes: 14 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@ipld/dag-pb": "^2.0.2",
"@magic-ext/oauth": "^0.8.0",
"@magic-sdk/admin": "^1.3.0",
"@nftstorage/ipfs-cluster": "^4.0.0",
"@nftstorage/ipfs-cluster": "^5.0.0",
"@web3-storage/db": "^4.0.0",
"@web3-storage/multipart-parser": "^1.0.0",
"cborg": "^1.6.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/api/test/car.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import { sha256, sha512 } from 'multiformats/hashes/sha2'
import * as pb from '@ipld/dag-pb'
import { CarWriter } from '@ipld/car'
import fetch, { Blob } from '@web-std/fetch'
import { Cluster } from '@nftstorage/ipfs-cluster'
import { endpoint, clusterApi, clusterApiAuthHeader } from './scripts/constants.js'
import { createCar } from './scripts/car.js'
import { MAX_BLOCK_SIZE } from '../src/constants.js'
import { getTestJWT } from './scripts/helpers.js'
import { PIN_OK_STATUS } from '../src/utils/pin.js'

// Cluster client needs global fetch
Object.assign(global, { fetch })

describe('POST /car', () => {
it('should add posted CARs to Cluster', async () => {
const name = 'car'
Expand Down Expand Up @@ -44,13 +48,12 @@ describe('POST /car', () => {
const status = await statusRes.json()
const pinInfo = status.pins.find(pin => PIN_OK_STATUS.includes(pin.status))
assert(pinInfo, `status is one of ${PIN_OK_STATUS}`)

const clusterPeersRes = await fetch(new URL('peers', clusterApi), {
const cluster = new Cluster(clusterApi, {
headers: {
Authorization: clusterApiAuthHeader
}
})
const clusterPeers = await clusterPeersRes.json()
const clusterPeers = await cluster.peerList()
// assert that peerId from the status belongs to one of the cluster ipfs nodes.
assert(clusterPeers.some(peer => peer.ipfs.id === pinInfo.peerId))
})
Expand Down
3 changes: 2 additions & 1 deletion packages/api/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ bindings = [{ name = "NAME_ROOM", class_name = "NameRoom0" }]
account_id = "fffa4b4363a7e5250af8357087263b3a" # Protocol Labs CF account
zone_id = "7eee3323c1b35b6650568604c65f441e" # web3.storage zone
route = "https://api-staging.web3.storage/*"
vars = { CLUSTER_API_URL = "https://web3.storage.ipfscluster.io/api/", ENV = "staging", PG_REST_URL = "https://web3-storage-pgrest-staging.herokuapp.com", GATEWAY_URL = "https://ipfs.io" }
# nft.storage.ipfscluster.io is the staging cluster
vars = { CLUSTER_API_URL = "https://nft.storage.ipfscluster.io/api/", ENV = "staging", PG_REST_URL = "https://web3-storage-pgrest-staging.herokuapp.com", GATEWAY_URL = "https://ipfs.io" }

[env.staging.durable_objects]
bindings = [{ name = "NAME_ROOM", class_name = "NameRoom0" }]
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/docker/cluster/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ services:

cluster0:
container_name: cluster0
image: ipfs/ipfs-cluster:v0.14.5
image: ipfs/ipfs-cluster:v1.0.0-rc3
depends_on:
- ipfs0
environment:
Expand Down

0 comments on commit d7899a0

Please sign in to comment.