Skip to content

Commit

Permalink
Merge pull request #286 from EYBlockchain/swati/multiple-user-test
Browse files Browse the repository at this point in the history
Multiple Zapp Test
  • Loading branch information
SwatiEY authored Jul 1, 2024
2 parents bf5cb4b + 4211824 commit c94ac06
Show file tree
Hide file tree
Showing 18 changed files with 646 additions and 22 deletions.
5 changes: 5 additions & 0 deletions src/boilerplate/common/api.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import express from 'express';
import router from "./api_routes.mjs"; // import the routes
import Web3 from './common/web3.mjs'
ENCRYPTEDLISTENER_IMPORT

const app = express();

Expand All @@ -18,7 +20,10 @@ function gracefulshutdown() {
process.on("SIGTERM", gracefulshutdown);
process.on("SIGINT", gracefulshutdown);

const web3 = Web3.connection()
ENCRYPTEDLISTENER_CALL


const listener = app.listen(process.env.PORT || 3000, () => {
console.log('Your app is listening on port ' + listener.address().port)
})
37 changes: 37 additions & 0 deletions src/boilerplate/common/bin/startup-double
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
set -e

docker-compose -f docker-compose.zapp-double.yml down -v

echo "Starting ganache..."

docker compose -f docker-compose.zapp-double.yml up -d ganache $BUILD_ARG

echo "Waiting for 30 seconds before starting the deployer..."
sleep 30

echo "Starting deployer and zokrates..."
CONSTRUCTOR_CALL

docker-compose -f docker-compose.zapp-double.yml up -d deployer $BUILD_ARG

docker compose -f docker-compose.zapp-double.yml up -d zokrates zokrates2 $BUILD_ARG
echo "Waiting for 20 seconds before starting timber..."
sleep 20

echo "Starting timber..."
docker compose -f docker-compose.zapp-double.yml up -d timber timber2 $BUILD_ARG

echo "Waiting for 2 seconds before starting Zapp orchestrators..."
sleep 2

echo "Starting Zapp ..."
docker compose -f docker-compose.zapp-double.yml up -d zapp zapp2 --build --wait
echo "Waiting for 2 seconds before running the tests..."
sleep 2
echo "All services have been started."
echo "----------------------------------------------------"
echo " Run these commands in two terminal to get the logs"
echo "docker compose -f docker-compose.zapp-double.yml logs -f -n 1000 zapp zokrates timber"
echo "docker compose -f docker-compose.zapp-double.yml logs -f -n 1000 zapp2 zokrates2 timber2"
echo "-----------------------------------------------------"
10 changes: 8 additions & 2 deletions src/boilerplate/common/boilerplate-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ FROM node:18.19

WORKDIR /app


COPY ./package.json ./package-lock.json ./
RUN npm ci
RUN npm i
COPY circuits ./circuits
COPY config ./config
COPY orchestration ./orchestration
COPY proving-files ./proving-files

EXPOSE 3000

CMD ["node", "orchestration/api.mjs"]
272 changes: 272 additions & 0 deletions src/boilerplate/common/boilerplate-docker-compose.zapp-double.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
version: '3.5'

services:
zapp:
ports:
- '3000:3000'
build:
context: .
dockerfile: Dockerfile
depends_on:
- zokrates
- timber
- ganache
- zapp-mongo
volumes:
- ./build:/app/build
- ./contracts/:/app/contracts/
- ./migrations/:/app/migrations/
- ./truffle-config.js:/app/truffle-config.js
- ./circuits/:/app/circuits:delegated
- ./orchestration/:/app/orchestration:delegated
- ./test/:/app/test:delegated
- ./config/:/app/config:delegated
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
RPC_URL: ws://ganache:8545
DEFAULT_ACCOUNT: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
KEY: '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
LOG_LEVEL: info
MONGO_HOST: mongodb://zapp-mongo
MONGO_PORT: 27019
MONGO_NAME: zapp_db
MONGO_USERNAME: admin
MONGO_PASSWORD: admin
networks:
- zapp_network

zapp2:
ports:
- '3001:3000'
build:
context: .
dockerfile: Dockerfile
depends_on:
- zokrates
- timber
- ganache
- zapp-mongo
volumes:
- ./build:/app/build
- ./contracts/:/app/contracts/
- ./migrations/:/app/migrations/
- ./truffle-config.js:/app/truffle-config.js
- ./circuits/:/app/circuits:delegated
- ./orchestration/:/app/orchestration:delegated
- ./test/:/app/test:delegated
- ./config/:/app/config:delegated
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
RPC_URL: ws://ganache:8545
DEFAULT_ACCOUNT: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
KEY: '0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1'
LOG_LEVEL: info
MONGO_HOST: mongodb://zapp-mongo
MONGO_PORT: 27019
MONGO_NAME: zapp_db
MONGO_USERNAME: admin
MONGO_PASSWORD: admin
networks:
- zapp_network

zokrates:
image: ghcr.io/eyblockchain/zokrates-worker-updated:latest
# the following image is for arm64 architecture. Uncomment the following lines and comment the above line if you are using ARM
# image: ghcr.io/eyblockchain/zokrates-worker-starlight:v0.2
# platform: linux/arm64/v8
volumes:
- ./circuits/:/app/circuits:delegated
- ./proving-files/:/app/output:delegated
- ./orchestration/common/write-vk.mjs:/app/write-vk.mjs
- ./orchestration/common/db/:/app/orchestration/common/db:delegated
environment:
PROVING_SCHEME: 'g16'
ports:
- '8080:80'
networks:
- zapp_network

zokrates2:
image: ghcr.io/eyblockchain/zokrates-worker-updated:latest
# the following image is for arm64 architecture. Uncomment the following lines and comment the above line if you are using ARM
# image: ghcr.io/eyblockchain/zokrates-worker-starlight:v0.2
# platform: linux/arm64/v8
volumes:
- ./circuits/:/app/circuits:delegated
- ./proving-files/:/app/output:delegated
- ./orchestration/common/write-vk.mjs:/app/write-vk.mjs
- ./orchestration/common/db/:/app/orchestration/common/db:delegated
environment:
PROVING_SCHEME: 'g16'
ports:
- '8081:80'
networks:
- zapp_network

timber:
build:
context: https://github.com/EYBlockchain/timber.git#starlight/testnet:merkle-tree
dockerfile: Dockerfile
restart: on-failure
depends_on:
- timber-mongo
- ganache
volumes:
- ./config/:/app/config
- ./contracts/:/app/contracts:consistent
- ./build/:/app/build:consistent
ports:
- '9000:80'
environment:
HASH_TYPE: 'mimc'
LOG_LEVEL: 'silly'
UNIQUE_LEAVES: 'true'
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
RPC_URL: ws://ganache:8545
DEFAULT_ACCOUNT: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
KEY: '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
CONTRACT_LOCATION: 'default'
MONGO_HOST: mongodb://timber-mongo
MONGO_PORT: 27017
MONGO_NAME: merkle_tree
MONGO_USERNAME: admin
MONGO_PASSWORD: admin
networks:
- zapp_network

timber2:
build:
context: https://github.com/EYBlockchain/timber.git#starlight/testnet:merkle-tree
dockerfile: Dockerfile
restart: on-failure
depends_on:
- timber-mongo
- ganache
volumes:
- ./config/:/app/config
- ./contracts/:/app/contracts:consistent
- ./build/:/app/build:consistent
ports:
- '9001:80'
environment:
HASH_TYPE: 'mimc'
LOG_LEVEL: 'silly'
UNIQUE_LEAVES: 'true'
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
RPC_URL: ws://ganache:8545
DEFAULT_ACCOUNT: '0xFFcf8FDEE72ac11b5c542428B35EEF5769C409f0'
KEY: '0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1'
CONTRACT_LOCATION: 'default'
MONGO_HOST: mongodb://timber-mongo
MONGO_PORT: 27017
MONGO_NAME: merkle_tree
MONGO_USERNAME: admin
MONGO_PASSWORD: admin
networks:
- zapp_network

#The database storing the merkle tree
timber-mongo:
build:
context: .
dockerfile: Dockerfile.mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
- MONGO_INITDB_DATABASE=merkle_tree
ports:
- "2022:27017"
volumes:
- timber-mongo-volume:/data/db
- ./config:/app/config/
networks:
- zapp_network

timber-mongo2:
build:
context: .
dockerfile: Dockerfile.mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
- MONGO_INITDB_DATABASE=merkle_tree
ports:
- "2023:27017"
volumes:
- timber-mongo-volume2:/data/db
networks:
- zapp_network

#The database storing commitments
zapp-mongo:
build:
context: .
dockerfile: Dockerfile.mongo
ports:
- "2020:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
- MONGO_INITDB_DATABASE=zapp_db
volumes:
- zapp-commitment-volume:/data/db
networks:
- zapp_network

zapp-mongo2:
build:
context: .
dockerfile: Dockerfile.mongo
ports:
- "2021:27017"
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_ROOT_PASSWORD=admin
- MONGO_INITDB_DATABASE=zapp_db
volumes:
- zapp-commitment-volume2:/data/db
networks:
- zapp_network


ganache:
image: trufflesuite/ganache:v7.4.4
command: --accounts=10 --gasLimit=100000000 --deterministic -i 1337
ports:
- '8545:8545'
networks:
- zapp_network

deployer:
build:
context: .
dockerfile: Dockerfile.deployer
depends_on:
- ganache
volumes:
- ./build:/app/build
- ./contracts/:/app/contracts/
- ./migrations/:/app/migrations/
- ./truffle-config.js:/app/truffle-config.js
- ./orchestration/:/app/orchestration:delegated
environment:
BLOCKCHAIN_HOST: ws://ganache
BLOCKCHAIN_PORT: 8545
RPC_URL: ws://ganache:8545
DEFAULT_ACCOUNT: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
KEY: '0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
networks:
- zapp_network

volumes:
timber-mongo-volume: {}
timber-mongo-volume2: {}
zapp-commitment-volume: {}
zapp-commitment-volume2: {}
networks:
zapp_network:
name: zapp_network
14 changes: 7 additions & 7 deletions src/boilerplate/common/boilerplate-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"scripts": {
"test": "./bin/startup && docker-compose -f docker-compose.zapp.yml run zapp npx mocha --exit --require @babel/register 'orchestration/test.mjs'",
"retest": "docker-compose -f docker-compose.zapp.yml run zapp npx mocha --exit --require @babel/register 'orchestration/test.mjs'",
"start": "./bin/startup && docker-compose -f docker-compose.zapp.yml run --name apiservice -p 3000:3000 zapp node orchestration/api.mjs",
"start": "./bin/startup",
"restart": "docker rm apiservice && docker-compose -f docker-compose.zapp.yml run --name apiservice -p 3000:3000 zapp node orchestration/api.mjs",
"apitest": "./bin/setup && ./bin/startup && docker-compose -f docker-compose.zapp.yml run --name apiservice -d -p 3000:3000 zapp node orchestration/api.mjs"
},
Expand All @@ -21,13 +21,13 @@
"author": "starlight",
"license": "CC0-1.0",
"dependencies": {
"@babel/register": "^7.11.5",
"@babel/register": "^7.23.7",
"@truffle/contract": "^4.2.21",
"@truffle/hdwallet-provider": "^1.4.0",
"@openzeppelin/contracts": "4.9.0",
"axios": "^0.19.2",
"axios": "1.7.2",
"config": "^3.3.1",
"express":"4.18.2",
"express":"4.19.2",
"enquirer": "^2.3.6",
"general-number": "^1.0.1",
"lodash.clonedeep": "^4.5.0",
Expand All @@ -37,14 +37,14 @@
"web3": "1.8.2",
"typescript": "^4.9.5",
"winston": "^3.3.3",
"yargs": "^15.4.1",
"yargs": "17.7.2",
"zkp-utils": "^1.0.8"
},
"devDependencies": {
"cod-scripts": "^6.0.0",
"eslint": "^7.19.0",
"husky": "^4.2.5",
"mocha": "^8.2.1",
"husky": "9.0.11",
"mocha": "10.4.0",
"prettier": "^2.2.1",
"prettier-plugin-solidity": "^1.0.0-alpha.54"
}
Expand Down
Loading

0 comments on commit c94ac06

Please sign in to comment.