Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[WIP] Feat/169 - Testnet implemented on hardhat node #195

Closed
wants to merge 11 commits into from
Closed
55 changes: 55 additions & 0 deletions docker-compose.dev-scratch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3'

services:
testnet-scratch:
ports:
- '5000:5000'
build:
context: ./packages/contracts/
dockerfile: ../../dockerfiles/Contract.dockerfile
environment:
BLOCKTIME: 10000
command: >
sh -c "npx hardhat node --hostname 0.0.0.0 --port 5000 &
sleep 5 &&
truffle migrate --network testnet &&
echo 'Finished Zkopru contract deployment.' &&
echo "Done" | nc -w0 coordinator 5354 &&
echo "Done" | nc -w0 wallet 5354 &&
tail -f /dev/null"
coordinator:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- '1234:1234'
- '8888:8888'
links:
- 'testnet-scratch:testnet'
depends_on:
- 'testnet-scratch'
environment:
TARGET_HOST: 'testnet'
PORT: 1234
command: >
bash -c "nc -l -p 5354 &&
bash wait_deploy_contracts.sh &&
gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json"
wallet:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- '4321:4321'
links:
- 'testnet-scratch:testnet'
- 'coordinator:coordinator'
depends_on:
- 'testnet-scratch'
environment:
TARGET_HOST: 'testnet'
PORT: 4321
command: >
bash -c "nc -l -p 5354 &&
bash wait_deploy_contracts.sh &&
gotty -w --port 4321 node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json"
43 changes: 23 additions & 20 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
version: "3"
version: '3'

services:
testnet:
ports:
- "5000:5000"
- '5000:5000'
build:
context: ./packages/contracts/
dockerfile: ../../dockerfiles/Contract.dockerfile
command: ganache-cli --db=/data -i 20200406 -p 5000 --gasLimit 12000000 --deterministic --host 0.0.0.0 --secure --blockTime 10
postgres:
ports:
- "5678:5432"
build:
context: ./
dockerfile: ./dockerfiles/Postgres.dockerfile
dockerfile: ../../dockerfiles/Contract.fork.dockerfile
environment:
POSTGRES_PASSWORD: helloworld
POSTGRES_URL: postgresql://postgres:helloworld@localhost:5432/zkopru
BLOCKTIME: 10000
command: >
sh -c "npx hardhat node --port 5000 &
tail -f /dev/null"
coordinator:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- "1234:1234"
- "8888:8888"
- '1234:1234'
- '8888:8888'
links:
- 'testnet:testnet'
depends_on:
- 'testnet'
- 'postgres'
environment:
TARGET_HOST: 'testnet'
PORT: 1234
POSTGRES_URL: postgresql://postgres:helloworld@postgres:5432/zkopru
command: >
bash -c "bash wait_deploy_contracts.sh &&
gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json"
wallet:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- "4321:4321"
- '4321:4321'
links:
- 'testnet:testnet'
- 'coordinator:coordinator'
depends_on:
- 'testnet'
- 'postgres'
environment:
TARGET_HOST: 'testnet'
PORT: 4321
SKIP_MIGRATE: 1
POSTGRES_URL: postgresql://postgres:helloworld@postgres:5432/zkopru
command: >
bash -c "bash wait_deploy_contracts.sh &&
gotty -w --port 4321 node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json"
51 changes: 19 additions & 32 deletions docker-compose.instant-block.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,44 @@
version: "3"
version: '3'

services:
testnet:
ports:
- "5000:5000"
- '5000:5000'
build:
context: ./packages/contracts/
dockerfile: ../../dockerfiles/Contract.dockerfile
command: ganache-cli --db=/data -i 20200406 -p 5000 --deterministic --host 0.0.0.0 --secure
postgres:
ports:
- "5678:5432"
build:
context: ./
dockerfile: ./dockerfiles/Postgres.dockerfile
environment:
POSTGRES_PASSWORD: helloworld
postgres-setup:
build:
context: ./
dockerfile: ./dockerfiles/PostgresSetup.dockerfile
depends_on:
- 'postgres'
links:
- 'postgres:postgres'
environment:
POSTGRES_URL: postgresql://postgres:helloworld@postgres:5432/zkopru
command: prisma migrate up --experimental --schema /proj/prisma/postgres-migrator.prisma --verbose
dockerfile: ../../dockerfiles/Contract.fork.dockerfile
command: >
sh -c "npx hardhat node --port 5000 &
tail -f /dev/null"
coordinator:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- "1234:1234"
- "8888:8888"
- '1234:1234'
- '8888:8888'
links:
- 'testnet:testnet'
- 'postgres:postgres'
depends_on:
- 'testnet'
- 'postgres-setup'
command: sh -c "sleep 5s && gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json"
environment:
TARGET_HOST: 'testnet'
command: >
bash -c "bash wait_deploy_contracts.sh &&
gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json"
wallet:
build:
context: ./
dockerfile: ./dockerfiles/Cli.dockerfile
ports:
- "4321:4321"
- '4321:4321'
links:
- 'testnet:testnet'
- 'postgres:postgres'
- 'coordinator:coordinator'
depends_on:
- 'testnet'
- 'postgres-setup'
command: sh -c "sleep 5s && gotty -w --port 4321 node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json"
environment:
TARGET_HOST: 'testnet'
command: >
bash -c "bash wait_deploy_contracts.sh &&
gotty -w --port 4321 node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json"
25 changes: 12 additions & 13 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
version: "3"
version: '3'

services:
testnet:
build:
context: ./packages/contracts/
dockerfile: ../../dockerfiles/Contract.dockerfile
dockerfile: ../../dockerfiles/Contract.fork.dockerfile
ports:
- "5000:5000"
command: ganache-cli --db=/data -i 20200406 -p 5000 --deterministic --host 0.0.0.0
- '5000:5000'
command: >
sh -c "npx hardhat node --port 5000 &
tail -f /dev/null"
coordinator:
build:
context: ./
dockerfile: ./dockerfiles/Coordinator.dockerfile
ports:
- "8888:8888"
- '8888:8888'
links:
- 'testnet:testnet'
depends_on:
- 'testnet'
- 'postgres'
command: 'node /proj/packages/coordinator/dist/cli.js --ws ws://testnet:5000 --config /proj/packages/coordinator/coordinator.json'
postgres:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: helloworld
ports:
- "5432:5432"
TARGET_HOST: 'testnet'
command: >
bash -c "nc -l -p 5354 &&
bash wait_deploy_contracts.sh &&
node /proj/packages/coordinator/dist/cli.js --ws ws://testnet:5000 --config /proj/packages/coordinator/coordinator.json"
6 changes: 2 additions & 4 deletions dockerfiles/Cli.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:14-stretch-slim
RUN apt update
RUN apt install -y git make musl-dev golang-go sqlite g++ tmux
RUN apt install -y git make musl-dev golang-go sqlite g++ tmux curl jq
RUN mkdir -p /usr/share/man/man1
RUN mkdir -p /usr/share/man/man7
RUN apt install -y postgresql-client netcat
Expand Down Expand Up @@ -62,7 +62,5 @@ RUN lerna clean -y --loglevel silent && lerna bootstrap
COPY ./packages/cli/coordinator.*.json /proj/packages/cli/
COPY ./packages/cli/wallet.*.json /proj/packages/cli/

COPY ./scripts/dev_start.sh /dev_start.sh
COPY ./scripts/wait_deploy_contracts.sh /proj/wait_deploy_contracts.sh
EXPOSE 8888
CMD ["/bin/sh", "/dev_start.sh"]
# CMD ["node", "/proj/packages/cli/dist/apps/coordinator/cli.js", "--ws ws://localhost:5000", "--config /proj/packages/cli/coordinator.json"]
14 changes: 7 additions & 7 deletions dockerfiles/Contract.dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM node:12-alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install -g truffle ganache-cli --unsafe-perm=true --allow-root \
python \
make \
g++ \
&& npm install -g truffle --unsafe-perm=true --allow-root \
&& apk del .gyp
RUN apk add git
WORKDIR /proj
Expand All @@ -12,9 +12,9 @@ RUN yarn install
COPY ./contracts /proj/contracts
COPY ./utils /proj/utils
COPY ./migrations /proj/migrations
COPY ./hardhat.config.js /proj/hardhat.config.js
COPY ./truffle-config.js /proj/truffle-config.js
RUN truffle compile
EXPOSE 5000
COPY ./keys /proj/keys
RUN ganache-cli --db=/data -i 20200406 -p 5000 --gasLimit 12000000 --deterministic --host 0.0.0.0 & sleep 5 && truffle migrate --network testnet
CMD ganache-cli --db=/data -b 5 -i 20200406 -p 5000 --gasLimit 12000000 --deterministic --host 0.0.0.0
CMD npx hardhat node --hostname 0.0.0.0 --port 5000
# In integration test blockTime is 5 sec.
19 changes: 19 additions & 0 deletions dockerfiles/Contract.fork.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:12-alpine
RUN apk add --no-cache --virtual .gyp \
python \
make \
g++ \
&& npm install -g truffle --unsafe-perm=true --allow-root \
&& apk del .gyp
RUN apk add git
WORKDIR /proj
COPY ./package.json /proj/package.json
RUN yarn install
COPY ./contracts /proj/contracts
COPY ./utils /proj/utils
COPY ./migrations /proj/migrations
COPY ./hardhat.config-fork.js /proj/hardhat.config.js
COPY ./truffle-config.js /proj/truffle-config.js
EXPOSE 5000
COPY ./keys /proj/keys
CMD npx hardhat node --hostname 0.0.0.0 --port 5000
20 changes: 0 additions & 20 deletions dockerfiles/Contract.integration.dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion dockerfiles/Postgres.dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions dockerfiles/PostgresSetup.dockerfile

This file was deleted.

7 changes: 1 addition & 6 deletions dockerfiles/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
version: "3.4"
version: '3.4'

services:
contracts:
image: zkoprunet/contracts:dev
build:
context: ../packages/contracts/
dockerfile: ../../dockerfiles/Contract.dockerfile
contracts-for-integration-test:
image: zkoprunet/contracts-integration-test:dev
build:
context: ../packages/contracts/
dockerfile: ../../dockerfiles/Contract.integration.dockerfile
circuits:
image: zkoprunet/circuits:dev
build:
Expand Down
Loading