Skip to content

Client deployment to use with the sdk #698

New issue

Have a question about this project? Sign up for a free account to open an issue and contact its maintainers and the community.

By clicking “Sign up for ”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on ? Sign in to your account

Merged
merged 22 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 17 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
1 change: 0 additions & 1 deletion apps/challenger/src/app.mjs
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
/* ignore unused exports */

import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
Expand Down
1 change: 0 additions & 1 deletion apps/proposer/src/app.mjs
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
/* ignore unused exports */

import express from 'express';
import bodyParser from 'body-parser';
import config from 'config';
Expand Down
1 change: 0 additions & 1 deletion apps/synchronizer/src/app.mjs
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
/* ignore unused exports */

import express from 'express';
import bodyParser from 'body-parser';
import config from 'config';
Expand Down
13 changes: 13 additions & 0 deletions common-files/package-lock.json

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

3 changes: 2 additions & 1 deletion common-files/package.json
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@
"dependencies": {
"config": "^3.3.7",
"winston": "^3.6.0",
"ws": "^8.5.0"
"ws": "^8.5.0",
"axios": "^0.21.4"
}
}
21 changes: 21 additions & 0 deletions common-files/utils/httputils.mjs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
/* ignore unused exports */
import axios from 'axios';
import fs from 'fs';
import * as stream from 'stream';
import { promisify } from 'util';

const finished = promisify(stream.finished);

const downloadFile = async (fileUrl, outputLocationPath) => {
const writer = fs.createWriteStream(outputLocationPath);
return axios({
method: 'get',
url: fileUrl,
responseType: 'stream',
}).then(response => {
response.data.pipe(writer);
return finished(writer); // this is a Promise
});
};

export default downloadFile;
16 changes: 12 additions & 4 deletions config/default.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,6 +126,10 @@ module.exports = {
MPC_PARAMS_URL:
'https://nightfallv3-proving-files.s3.eu-west-1.amazonaws.com/phase2/mpc_params',
},
DEPLOYMENT_FILES_URL: {
DEFAULT_CIRCUIT_FILES_URL: 'https://nightfallv3-proving-files.s3.eu-west-1.amazonaws.com',
DEFAULT_CONTRACT_FILES_URL: 'https://nightfallv3-proving-files.s3.eu-west-1.amazonaws.com',
},
ENVIRONMENTS: {
mainnet: {
name: 'Mainnet',
Expand DownExpand Up@@ -168,9 +172,13 @@ module.exports = {
: 'http://localhost:8092',
adversarialOptimistApiUrl: 'http://localhost:8088',
adversarialOptimistWsUrl: 'ws://localhost:8089',
web3WsUrl: process.env.BLOCKCHAIN_WS_HOST
? `ws://${process.env.BLOCKCHAIN_WS_HOST}:${process.env.BLOCKCHAIN_PORT}`
: 'ws://localhost:8546',
web3WsUrl:
// eslint-disable-next-line no-nested-ternary
process.env.BLOCKCHAIN_WS_HOST && process.env.BLOCKCHAIN_PORT
? `ws://${process.env.BLOCKCHAIN_WS_HOST}:${process.env.BLOCKCHAIN_PORT}`
: process.env.BLOCKCHAIN_WS_HOST
? `wss://${process.env.BLOCKCHAIN_WS_HOST}`
: 'ws://localhost:8546',
},
aws: {
name: 'AWS',
Expand All@@ -188,7 +196,7 @@ module.exports = {
tokenTypeERC721: 'ERC721',
tokenTypeERC1155: 'ERC1155',
},
transferValue: 10,
transferValue: process.env.TRANSFER_VALUE || 10,
// this is the etherum private key for accounts[0]
privateKey: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
gas: 10000000,
Expand Down
37 changes: 37 additions & 0 deletions docker-compose.client.dev.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
version: '3.5'
# Use this script for running up nightfall_3 client in 'developer' mode with local
# bindings. See the readme for more information.
services:
client1:
build:
dockerfile: client.Dockerfile
context: .
volumes:
- type: bind
source: ./nightfall-client/src
target: /app/src
- type: bind
source: ./common-files
target: /common-files
- type: bind
source: ./config/default.js
target: /app/config/default.js

worker:
build:
dockerfile: worker.Dockerfile
context: .
volumes:
- type: bind
source: ./nightfall-deployer/circuits
target: /app/circuits/
- type: bind
source: ./zokrates-worker/src
target: /app/src/
- type: bind
source: ./config/default.js
target: /app/config/default.js
ports:
# to use with postman and etc
- 8091:80
entrypoint: ['npm', 'run', 'start']
72 changes: 72 additions & 0 deletions docker-compose.client.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
version: '3.5'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some requirements on the docker-compose version required to be installed. Can you clarify?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I choose the same version and format of the docker-compose files of the root folder for other purposes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What i meant is that there should be a requirements section in the README where we explain what sw is needed to run this. For example, we need nodeJS v xxx, docker-compose v.xxx,... Again, this README needs to be enough for a user to spin a client without the need to go to the main README. All information required should be here.

# Use this script for running up nightfall_3 client in 'developer' mode with local
# bindings. See the readme for more information.
services:
client1:
image: ghcr.io/eyblockchain/nightfall3-client:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you should change the image name.... its strange that its called eyblockchain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this applies to all images that we are building now in the Dockerfiles in the root folder and not only this PR.
So we have to do it in all images I think.

  • ghcr.io/eyblockchain/nightfall3-deployer:latest
  • ghcr.io/eyblockchain/nightfall3-worker:latest
  • ghcr.io/eyblockchain/nightfall3-client:latest
  • ghcr.io/eyblockchain/nightfall3-optimist:latest
  • ghcr.io/eyblockchain/nightfall3-proposer:latest
  • ghcr.io/eyblockchain/nightfall3-user-local:latest

volumes:
- type: volume
source: build
target: /app/build
- type: volume
source: mongodb1
target: /app/mongodb
networks:
- nightfall_network
ports:
- 27017:27017
- 8080:80
depends_on:
- worker
- rabbitmq1
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: admin
LOG_LEVEL: debug
ZOKRATES_WORKER_HOST: worker
RABBITMQ_HOST: amqp://rabbitmq1
RABBITMQ_PORT: 5672
ENABLE_QUEUE: 1
USE_STUBS: 'false' # make sure this flag is the same as in deployer service
BLOCKCHAIN_URL: ${BLOCKCHAIN_URL}
USE_EXTERNAL_NODE: 'true'
AUTOSTART_RETRIES: 600
ETH_NETWORK: ${ETH_NETWORK}
CONTRACT_FILES_URL: ${CONTRACT_FILES_URL}
command: ['npm', 'run', 'dev']

worker:
image: ghcr.io/eyblockchain/nightfall3-worker:latest
volumes:
- type: volume
source: proving_files
target: /app/output/
networks:
- nightfall_network
environment:
LOG_LEVEL: info
MPC: 'true'
ETH_NETWORK: ${ETH_NETWORK}
CIRCUIT_FILES_URL: ${CIRCUIT_FILES_URL}

rabbitmq1:
image: rabbitmq
ports:
- '15674:15674'
- '5672:5672'
networks:
- nightfall_network

volumes:
mongodb1:
proving_files:
build:

networks:
nightfall_network:
driver: bridge
ipam:
driver: default
config:
- subnet: 172.16.238.0/24
gateway: 172.16.238.1
10 changes: 5 additions & 5 deletions docker-compose.ropsten.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,13 +3,13 @@ services:
client1:
environment:
BLOCKCHAIN_URL: $ROPSTEN_NODE
USE_ROPSTEN_NODE: 'true'
USE_EXTERNAL_NODE: 'true'
AUTOSTART_RETRIES: 600

client2:
environment:
BLOCKCHAIN_URL: $ROPSTEN_NODE
USE_ROPSTEN_NODE: 'true'
USE_EXTERNAL_NODE: 'true'
AUTOSTART_RETRIES: 600

deployer:
Expand All@@ -18,18 +18,18 @@ services:
# startup routines will wait for a blockchain client to be reachable on this network
ETH_NETWORK: ropsten
BLOCKCHAIN_URL: $ROPSTEN_NODE
USE_ROPSTEN_NODE: 'true'
USE_EXTERNAL_NODE: 'true'
FROM_ADDRESS: ${FROM_ADDRESS:-0x29100E7E3dA6654BF63d9E7804ADe518aCc5AaA5}
ETH_PRIVATE_KEY: $ETH_PRIVATE_KEY

optimist1:
environment:
BLOCKCHAIN_URL: $ROPSTEN_NODE
USE_ROPSTEN_NODE: 'true'
USE_EXTERNAL_NODE: 'true'
AUTOSTART_RETRIES: 600

optimist2:
environment:
BLOCKCHAIN_URL: $ROPSTEN_NODE
USE_ROPSTEN_NODE: 'true'
USE_EXTERNAL_NODE: 'true'
AUTOSTART_RETRIES: 600
2 changes: 2 additions & 0 deletions nightfall-client/.gitignore
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,3 +102,5 @@ dist

# TernJS port file
.tern-port

client.env
Loading