Compare commits

55 changed files with 15202 additions and 68 deletions
@@ -86,11 +86,6 @@ runs:
- name: Load cache and build
working-directory: ${{ steps.find-workdir.outputs.WORK_DIR }}
env:
AWS_BUCKET: ${{ inputs.s3-cache-bucket }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ inputs.s3-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.s3-secret-access-key }}
run: npm run cache -- load
shell: bash
@@ -78,11 +78,6 @@ runs:
- name: Load cache and build
working-directory: ${{ steps.find-workdir.outputs.WORK_DIR }}
env:
AWS_BUCKET: ${{ inputs.s3-cache-bucket }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ inputs.s3-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.s3-secret-access-key }}
run: npm run cache -- load
shell: bash
@@ -78,11 +78,6 @@ runs:
- name: Load cache and build
working-directory: ${{ steps.find-workdir.outputs.WORK_DIR }}
env:
AWS_BUCKET: ${{ inputs.s3-cache-bucket }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ inputs.s3-access-key-id }}
AWS_SECRET_ACCESS_KEY: ${{ inputs.s3-secret-access-key }}
run: npm run cache -- load
shell: bash
+3 -3
View File
@@ -28,7 +28,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/run-interop-hole-punch-test
with:
s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }}
s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }}
s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }}
s3-cache-bucket: libp2p-by-tf-aws-bootstrap
s3-access-key-id: ${{ vars.S3_AWS_ACCESS_KEY_ID }}
s3-secret-access-key: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }}
worker-count: 16
+4 -4
View File
@@ -18,12 +18,12 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/run-transport-interop-test
with:
s3-cache-bucket: ${{ vars.S3_LIBP2P_BUILD_CACHE_BUCKET_NAME }}
s3-access-key-id: ${{ vars.S3_LIBP2P_BUILD_CACHE_AWS_ACCESS_KEY_ID }}
s3-secret-access-key: ${{ secrets.S3_LIBP2P_BUILD_CACHE_AWS_SECRET_ACCESS_KEY }}
s3-cache-bucket: libp2p-by-tf-aws-bootstrap
s3-access-key-id: ${{ vars.S3_AWS_ACCESS_KEY_ID }}
s3-secret-access-key: ${{ secrets.S3_AWS_SECRET_ACCESS_KEY }}
worker-count: 16
build-without-secrets:
runs-on: ['self-hosted', 'linux', 'x64', '4xlarge'] # https://github.com/pl-strflt/tf-aws-gh-runner/blob/main/runners.tf
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Purposely not using secrets to replicate how forks will behave.
+1 -1
View File
@@ -1,6 +1,6 @@
# Interoperability/end to end test-plans & performance benchmarking for libp2p
[![Interop Dashboard](https://github.com/vacp2p/libp2p-test-plans/workflows/libp2p%20transport%20interop%20test/badge.svg?branch=master)](https://github.com/vacp2p/libp2p-test-plans/actions/runs/10508587062/attempts/1#summary-29112802717)
[![Interop Dashboard](https://github.com/status-im/libp2p-test-plans/workflows/libp2p%20transport%20interop%20test/badge.svg?branch=master)](https://github.com/status-im/libp2p-test-plans/actions/runs/7043365318/attempts/1#summary-19169013615)
[![Made by Protocol Labs](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai)
-5
View File
@@ -1,5 +0,0 @@
{
"opRetro": {
"projectId": "0x966804cb492e1a4bde5d781a676a44a23d69aa5dd2562fa7a4f95bb606021c8b"
}
}
+16 -20
View File
@@ -1,9 +1,8 @@
const AWS_BUCKET = process.env.AWS_BUCKET;
const AWS_BUCKET = process.env.AWS_BUCKET || 'libp2p-by-tf-aws-bootstrap';
const scriptDir = __dirname;
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as child_process from 'child_process';
import ignore, { Ignore } from 'ignore'
@@ -77,14 +76,10 @@ async function loadCacheOrBuild(dir: string, ig: Ignore) {
if (mode == Mode.PushCache) {
console.log("Pushing cache")
try {
if (!AWS_BUCKET) {
throw new Error("AWS_BUCKET not set")
}
try {
child_process.execSync(`aws s3 ls s3://${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`)
const res = await fetch(`https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`, {method: "HEAD"})
if (res.ok) {
console.log("Cache already exists")
} catch (e) {
console.log("Cache doesn't exist", e)
} else {
// Read image id from image.json
const imageID = JSON.parse(fs.readFileSync(path.join(dir, 'image.json')).toString()).imageID;
console.log(`Pushing cache for ${dir}: ${imageID}`)
@@ -101,17 +96,18 @@ async function loadCacheOrBuild(dir: string, ig: Ignore) {
console.log("Loading cache")
let cacheHit = false
try {
if (!AWS_BUCKET) {
throw new Error("AWS_BUCKET not set")
}
const cachePath = fs.mkdtempSync(path.join(os.tmpdir(), 'cache'))
const archivePath = path.join(cachePath, 'archive.tar.gz')
const dockerLoadedMsg = child_process.execSync(`aws s3 cp s3://${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz ${archivePath} && docker image load -i ${archivePath}`).toString();
const loadedImageId = dockerLoadedMsg.match(/Loaded image( ID)?: (.*)/)[2];
if (loadedImageId) {
console.log(`Cache hit for ${loadedImageId}`);
fs.writeFileSync(path.join(dir, 'image.json'), JSON.stringify({imageID: loadedImageId}) + "\n");
cacheHit = true
// Check if the cache exists
const res = await fetch(`https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`, {method: "HEAD"})
if (res.ok) {
const dockerLoadedMsg = child_process.execSync(`curl https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz | docker image load`).toString();
const loadedImageId = dockerLoadedMsg.match(/Loaded image( ID)?: (.*)/)[2];
if (loadedImageId) {
console.log(`Cache hit for ${loadedImageId}`);
fs.writeFileSync(path.join(dir, 'image.json'), JSON.stringify({imageID: loadedImageId}) + "\n");
cacheHit = true
}
} else {
console.log("Cache not found")
}
} catch (e) {
console.log("Cache not found:", e)
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-1-9",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^1.9.2"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-0",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.0.1"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-1",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.1.2"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-2",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.2.1"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-3",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.3.1"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-4",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.4.0"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-5",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.5.0"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-6",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.6.1"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+12
View File
@@ -0,0 +1,12 @@
DOCKER_IMAGE := node:20-alpine
DOCKER_RUN := docker run --rm -v "$(shell pwd)":/usr/src/myapp -w /usr/src/myapp $(DOCKER_IMAGE)
all: perf
perf:
$(DOCKER_RUN) npm ci
clean:
rm -rf node_modules
.PHONY: all clean perf
+108
View File
@@ -0,0 +1,108 @@
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { tcp } from '@libp2p/tcp'
import { multiaddr } from '@multiformats/multiaddr'
import { createLibp2p } from 'libp2p'
import { perf } from '@libp2p/perf'
import { parseArgs } from 'node:util'
const argv = parseArgs({
options: {
'run-server': {
type: 'string',
default: 'false'
},
'server-address': {
type: 'string'
},
transport: {
type: 'string',
default: 'tcp'
},
'upload-bytes': {
type: 'string',
default: '0'
},
'download-bytes': {
type: 'string',
default: '0'
}
}
})
/**
* @param {boolean} runServer
* @param {string} serverIpAddress
* @param {string} transport
* @param {number} uploadBytes
* @param {number} downloadBytes
*/
export async function main (runServer, serverIpAddress, transport, uploadBytes, downloadBytes) {
const { host, port } = splitHostPort(serverIpAddress)
const config = {
transports: [
tcp()
],
streamMuxers: [
yamux()
],
connectionEncryption: [
noise()
],
connectionManager: {
minConnections: 0
},
services: {
perf: perf()
}
}
if (runServer) {
Object.assign(config, {
addresses: {
listen: [
// #TODO: right now we only support tcp
`/ip4/${host}/tcp/${port}`
]
}
})
}
const node = await createLibp2p(config)
await node.start()
if (!runServer) {
for await (const output of node.services.perf.measurePerformance(multiaddr(`/ip4/${host}/tcp/${port}`), uploadBytes, downloadBytes)) {
// eslint-disable-next-line no-console
console.log(JSON.stringify(output))
}
await node.stop()
}
}
/**
* @param {string} address
* @returns { host: string, port?: string }
*/
function splitHostPort (address) {
try {
const parts = address.split(':')
const host = parts[0]
const port = parts[1]
return {
host,
port
}
} catch (error) {
throw Error('Invalid server address')
}
}
main(argv.values['run-server'] === 'true', argv.values['server-address'], argv.values.transport, Number(argv.values['upload-bytes']), Number(argv.values['download-bytes'])).catch((err) => {
// eslint-disable-next-line no-console
console.error(err)
process.exit(1)
})
File diff suppressed because it is too large Load Diff
+13
View File
@@ -0,0 +1,13 @@
{
"name": "@libp2p/perf-js-libp2p-2-7",
"private": true,
"main": "index.js",
"type": "module",
"dependencies": {
"@chainsafe/libp2p-noise": "^14.0.0",
"@chainsafe/libp2p-yamux": "^6.0.1",
"@libp2p/perf": "^3.0.4",
"@libp2p/tcp": "^9.0.4",
"libp2p": "^2.7.0"
}
}
+45
View File
@@ -0,0 +1,45 @@
#!/bin/bash
# In case this script is `kill`ed, `kill` its child process, namely the `node`
# process below.
cleanup() {
kill $node_pid
}
trap cleanup EXIT TERM
# Find the path to the Node.js executable
node_path=$(which node)
run_server=false
server_address=""
upload_bytes=0
download_bytes=0
transport=""
# Parse named parameters manually
for ((i = 1; i <= $#; i++)); do
if [ "${!i}" == "--server-address" ]; then
server_address="${@:i+1:1}"
fi
if [ "${!i}" == "--upload-bytes" ]; then
upload_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--download-bytes" ]; then
download_bytes="${@:i+1:1}"
fi
if [ "${!i}" == "--transport" ]; then
transport="${@:i+1:1}"
fi
if [ "${!i}" == "--run-server" ]; then
run_server=true
fi
done
# Run perf
node $(dirname "$0")/index.js --run-server=$run_server --server-address=$server_address --upload-bytes=$upload_bytes --download-bytes=$download_bytes --transport=$transport &
node_pid=$!
# Wait for `node_pid` to finish, or for it to be `kill`ed by the above
# `cleanup`.
wait $node_pid
+63
View File
@@ -66,5 +66,68 @@
"transportStacks": [
"tcp"
]
},
{
"id": "v1.9",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.0",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.1",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.2",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.3",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.4",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.5",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.6",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
},
{
"id": "v2.7",
"implementation": "js-libp2p",
"transportStacks": [
"tcp"
]
}
]
+16 -20
View File
@@ -1,9 +1,8 @@
const AWS_BUCKET = process.env.AWS_BUCKET;
const AWS_BUCKET = process.env.AWS_BUCKET || 'libp2p-by-tf-aws-bootstrap';
const scriptDir = __dirname;
import * as crypto from 'crypto';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import * as child_process from 'child_process';
import ignore, { Ignore } from 'ignore'
@@ -66,14 +65,10 @@ switch (modeStr) {
if (mode == Mode.PushCache) {
console.log("Pushing cache")
try {
if (!AWS_BUCKET) {
throw new Error("AWS_BUCKET not set")
}
try {
child_process.execSync(`aws s3 ls s3://${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`)
const res = await fetch(`https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`, { method: "HEAD" })
if (res.ok) {
console.log("Cache already exists")
} catch (e) {
console.log("Cache doesn't exist", e)
} else {
// Read image id from image.json
const imageID = JSON.parse(fs.readFileSync(path.join(implFolder, 'image.json')).toString()).imageID;
console.log(`Pushing cache for ${impl}: ${imageID}`)
@@ -90,17 +85,18 @@ switch (modeStr) {
console.log("Loading cache")
let cacheHit = false
try {
if (!AWS_BUCKET) {
throw new Error("AWS_BUCKET not set")
}
const cachePath = fs.mkdtempSync(path.join(os.tmpdir(), 'cache'))
const archivePath = path.join(cachePath, 'archive.tar.gz')
const dockerLoadedMsg = child_process.execSync(`aws s3 cp s3://${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz ${archivePath} && docker image load -i ${archivePath}`).toString();
const loadedImageId = dockerLoadedMsg.match(/Loaded image( ID)?: (.*)/)[2];
if (loadedImageId) {
console.log(`Cache hit for ${loadedImageId}`);
fs.writeFileSync(path.join(implFolder, 'image.json'), JSON.stringify({ imageID: loadedImageId }) + "\n");
cacheHit = true
// Check if the cache exists
const res = await fetch(`https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz`, { method: "HEAD" })
if (res.ok) {
const dockerLoadedMsg = child_process.execSync(`curl https://s3.amazonaws.com/${AWS_BUCKET}/imageCache/${cacheKey}-${arch}.tar.gz | docker image load`).toString();
const loadedImageId = dockerLoadedMsg.match(/Loaded image( ID)?: (.*)/)[2];
if (loadedImageId) {
console.log(`Cache hit for ${loadedImageId}`);
fs.writeFileSync(path.join(implFolder, 'image.json'), JSON.stringify({ imageID: loadedImageId }) + "\n");
cacheHit = true
}
} else {
console.log("Cache not found")
}
} catch (e) {
console.log("Cache not found:", e)