diff --git a/docker-compose.dev-scratch.yml b/docker-compose.dev-scratch.yml new file mode 100644 index 000000000..981dcafd9 --- /dev/null +++ b/docker-compose.dev-scratch.yml @@ -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" diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index a573b0e67..00e588e5e 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -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" diff --git a/docker-compose.instant-block.yml b/docker-compose.instant-block.yml index eb995a3b8..923e01d3e 100644 --- a/docker-compose.instant-block.yml +++ b/docker-compose.instant-block.yml @@ -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" \ No newline at end of file + 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" diff --git a/docker-compose.yml b/docker-compose.yml index dbb6c7424..3c403335b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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" \ No newline at end of file + 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" diff --git a/dockerfiles/Cli.dockerfile b/dockerfiles/Cli.dockerfile index 5a401e67c..caf27a279 100644 --- a/dockerfiles/Cli.dockerfile +++ b/dockerfiles/Cli.dockerfile @@ -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 @@ -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"] diff --git a/dockerfiles/Contract.dockerfile b/dockerfiles/Contract.dockerfile index 234bf65ca..8631e28c0 100644 --- a/dockerfiles/Contract.dockerfile +++ b/dockerfiles/Contract.dockerfile @@ -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 @@ -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. \ No newline at end of file diff --git a/dockerfiles/Contract.fork.dockerfile b/dockerfiles/Contract.fork.dockerfile new file mode 100644 index 000000000..ad24fb8aa --- /dev/null +++ b/dockerfiles/Contract.fork.dockerfile @@ -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 \ No newline at end of file diff --git a/dockerfiles/Contract.integration.dockerfile b/dockerfiles/Contract.integration.dockerfile deleted file mode 100644 index 7e1b96224..000000000 --- a/dockerfiles/Contract.integration.dockerfile +++ /dev/null @@ -1,20 +0,0 @@ -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 \ - && 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 ./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 integrationtest -CMD ganache-cli --db=/data -i 20200406 -p 5000 --gasLimit 12000000 --deterministic --host 0.0.0.0 diff --git a/dockerfiles/Postgres.dockerfile b/dockerfiles/Postgres.dockerfile deleted file mode 100644 index d3f2fcb60..000000000 --- a/dockerfiles/Postgres.dockerfile +++ /dev/null @@ -1 +0,0 @@ -FROM postgres diff --git a/dockerfiles/PostgresSetup.dockerfile b/dockerfiles/PostgresSetup.dockerfile deleted file mode 100644 index cd3158f8e..000000000 --- a/dockerfiles/PostgresSetup.dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM node:14-alpine - -WORKDIR /proj diff --git a/dockerfiles/docker-compose.yml b/dockerfiles/docker-compose.yml index 64c1c2203..55ccfc69e 100644 --- a/dockerfiles/docker-compose.yml +++ b/dockerfiles/docker-compose.yml @@ -1,4 +1,4 @@ -version: "3.4" +version: '3.4' services: contracts: @@ -6,11 +6,6 @@ services: 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: diff --git a/dockerfiles/templates/coordinator.yaml b/dockerfiles/templates/coordinator.yaml new file mode 100644 index 000000000..6b94bfdfa --- /dev/null +++ b/dockerfiles/templates/coordinator.yaml @@ -0,0 +1,65 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: coordinator + name: coordinator +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: coordinator + strategy: {} + template: + metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: coordinator + spec: + containers: + - args: + - sh + - -c + - sleep 5s && gotty -w --port 1234 node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json + image: zkopru/coordinator + name: coordinator + ports: + - containerPort: 1234 + - containerPort: 8888 + resources: {} + imagePullPolicy: Never + restartPolicy: Always +status: {} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: coordinator + name: coordinator +spec: + type: NodePort + ports: + - name: "1234" + port: 1234 + targetPort: 1234 + nodePort: 31234 + - name: "8888" + port: 8888 + targetPort: 8888 + nodePort: 31238 + selector: + io.kompose.service: coordinator +status: + loadBalancer: {} diff --git a/dockerfiles/templates/testnet.yaml b/dockerfiles/templates/testnet.yaml new file mode 100644 index 000000000..cbd0157bf --- /dev/null +++ b/dockerfiles/templates/testnet.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: testnet + name: testnet +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: testnet + strategy: {} + template: + metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: testnet + spec: + containers: + - args: + - ganache-cli + - --db=/data + - -i + - "20200406" + - -p + - "5000" + - --deterministic + - --host + - 0.0.0.0 + - --secure + image: zkopru/testnet + name: testnet + imagePullPolicy: Never + ports: + - containerPort: 5000 + resources: {} +status: {} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: testnet + name: testnet +spec: + ports: + - name: "5000" + port: 5000 + targetPort: 5000 + selector: + io.kompose.service: testnet +status: + loadBalancer: {} diff --git a/dockerfiles/templates/wallet.yaml b/dockerfiles/templates/wallet.yaml new file mode 100644 index 000000000..e42c8ffe2 --- /dev/null +++ b/dockerfiles/templates/wallet.yaml @@ -0,0 +1,61 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: wallet + name: wallet +spec: + replicas: 1 + selector: + matchLabels: + io.kompose.service: wallet + strategy: {} + template: + metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: wallet + spec: + containers: + - args: + - sh + - -c + - sleep 5s && gotty -w --port 4321 node /proj/packages/cli/dist/apps/wallet/cli.js --config /proj/packages/cli/wallet.dev.json + image: zkopru/wallet + name: wallet + ports: + - containerPort: 4321 + resources: {} + imagePullPolicy: Never + restartPolicy: Always +status: {} +--- +apiVersion: v1 +kind: Service +metadata: + annotations: + kompose.cmd: kompose -f docker-compose.instant-block.yml convert + kompose.version: 1.22.0 (955b78124) + creationTimestamp: null + labels: + io.kompose.service: wallet + name: wallet +spec: + type: NodePort + ports: + - name: "4321" + port: 4321 + targetPort: 4321 + nodePort: 32134 + selector: + io.kompose.service: wallet +status: + loadBalancer: {} + diff --git a/packages/cli/coordinator.auto.json b/packages/cli/coordinator.auto.json index cc007ae63..953988708 100644 --- a/packages/cli/coordinator.auto.json +++ b/packages/cli/coordinator.auto.json @@ -1 +1,37 @@ -{"_":[],"bootstrap":true,"b":true, "n": true, "ws":"ws://testnet:5000","websocket":"ws://testnet:5000", "postgres": "postgresql://postgres:helloworld@postgres:5432/zkopru", "address":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","a":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","db":"db","maxBytes":131072,"max-bytes":131072,"priceMultiplier":48,"price-multiplier":48,"port":7777,"$0":"zkopru-coordinator","keystore":{"version":3,"id":"5c1043d1-c95d-49b3-ad52-e67e377ee64f","address":"90f8bf6a479f320ead074411a4b0e7944ea8c9c1","crypto":{"ciphertext":"5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b","cipherparams":{"iv":"9454222d759f0c0cf340725a76156f24"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2","n":8192,"r":8,"p":1},"mac":"fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c"}},"password":"helloworld"} +{ + "_": [], + "bootstrap": true, + "b": true, + "n": true, + "ws": "ws://testnet:5000", + "websocket": "ws://testnet:5000", + "address": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "a": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "db": "db", + "maxBytes": 131072, + "max-bytes": 131072, + "priceMultiplier": 48, + "price-multiplier": 48, + "port": 7777, + "$0": "zkopru-coordinator", + "keystore": { + "version": 3, + "id": "5c1043d1-c95d-49b3-ad52-e67e377ee64f", + "address": "90f8bf6a479f320ead074411a4b0e7944ea8c9c1", + "crypto": { + "ciphertext": "5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b", + "cipherparams": { "iv": "9454222d759f0c0cf340725a76156f24" }, + "cipher": "aes-128-ctr", + "kdf": "scrypt", + "kdfparams": { + "dklen": 32, + "salt": "a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2", + "n": 8192, + "r": 8, + "p": 1 + }, + "mac": "fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c" + } + }, + "password": "helloworld" +} diff --git a/packages/cli/coordinator.dev.json b/packages/cli/coordinator.dev.json index 6dc0d2519..c43d47f64 100644 --- a/packages/cli/coordinator.dev.json +++ b/packages/cli/coordinator.dev.json @@ -1 +1,36 @@ -{"_":[],"bootstrap":true,"b":true, "ws":"ws://testnet:5000","websocket":"ws://testnet:5000", "postgres": "postgresql://postgres:helloworld@postgres:5432/zkopru", "address":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","a":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","db":"db","maxBytes":131072,"max-bytes":131072,"priceMultiplier":48,"price-multiplier":48,"port":8888,"$0":"zkopru-coordinator","keystore":{"version":3,"id":"5c1043d1-c95d-49b3-ad52-e67e377ee64f","address":"90f8bf6a479f320ead074411a4b0e7944ea8c9c1","crypto":{"ciphertext":"5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b","cipherparams":{"iv":"9454222d759f0c0cf340725a76156f24"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2","n":8192,"r":8,"p":1},"mac":"fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c"}},"password":"helloworld"} +{ + "_": [], + "bootstrap": true, + "b": true, + "ws": "ws://testnet:5000", + "websocket": "ws://testnet:5000", + "address": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "a": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "db": "db", + "maxBytes": 131072, + "max-bytes": 131072, + "priceMultiplier": 48, + "price-multiplier": 48, + "port": 8888, + "$0": "zkopru-coordinator", + "keystore": { + "version": 3, + "id": "5c1043d1-c95d-49b3-ad52-e67e377ee64f", + "address": "90f8bf6a479f320ead074411a4b0e7944ea8c9c1", + "crypto": { + "ciphertext": "5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b", + "cipherparams": { "iv": "9454222d759f0c0cf340725a76156f24" }, + "cipher": "aes-128-ctr", + "kdf": "scrypt", + "kdfparams": { + "dklen": 32, + "salt": "a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2", + "n": 8192, + "r": 8, + "p": 1 + }, + "mac": "fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c" + } + }, + "password": "helloworld" +} diff --git a/packages/cli/coordinator.json b/packages/cli/coordinator.json index eb7a11da0..63b4f9c90 100644 --- a/packages/cli/coordinator.json +++ b/packages/cli/coordinator.json @@ -1 +1,36 @@ -{"_":[],"bootstrap":true,"b":true,"ws":"ws://localhost:5000","websocket":"ws://localhost:5000","address":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","a":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","db":"db","maxBytes":131072,"max-bytes":131072,"priceMultiplier":48,"price-multiplier":48,"port":8888,"$0":"zkopru-coordinator","keystore":{"version":3,"id":"5c1043d1-c95d-49b3-ad52-e67e377ee64f","address":"90f8bf6a479f320ead074411a4b0e7944ea8c9c1","crypto":{"ciphertext":"5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b","cipherparams":{"iv":"9454222d759f0c0cf340725a76156f24"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2","n":8192,"r":8,"p":1},"mac":"fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c"}},"password":"helloworld"} +{ + "_": [], + "bootstrap": true, + "b": true, + "ws": "ws://localhost:5000", + "websocket": "ws://localhost:5000", + "address": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "a": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "db": "db", + "maxBytes": 131072, + "max-bytes": 131072, + "priceMultiplier": 48, + "price-multiplier": 48, + "port": 8888, + "$0": "zkopru-coordinator", + "keystore": { + "version": 3, + "id": "5c1043d1-c95d-49b3-ad52-e67e377ee64f", + "address": "90f8bf6a479f320ead074411a4b0e7944ea8c9c1", + "crypto": { + "ciphertext": "5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b", + "cipherparams": { "iv": "9454222d759f0c0cf340725a76156f24" }, + "cipher": "aes-128-ctr", + "kdf": "scrypt", + "kdfparams": { + "dklen": 32, + "salt": "a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2", + "n": 8192, + "r": 8, + "p": 1 + }, + "mac": "fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c" + } + }, + "password": "helloworld" +} diff --git a/packages/cli/coordinator.playground.json b/packages/cli/coordinator.playground.json index 88c9b7cc2..f67d071cc 100644 --- a/packages/cli/coordinator.playground.json +++ b/packages/cli/coordinator.playground.json @@ -1 +1,37 @@ -{"_":[],"bootstrap":true,"b":true, "ws":"ws://localhost:5000","websocket":"ws://localhost:5000", "sqlite": "/proj/zkopru/packages/cli/zkopru-coordinator.db", "address":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","a":"0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF","db":"db","maxBytes":131072,"max-bytes":131072,"priceMultiplier":48,"price-multiplier":48,"port":8888,"$0":"zkopru-coordinator","keystore":{"version":3,"id":"5c1043d1-c95d-49b3-ad52-e67e377ee64f","address":"90f8bf6a479f320ead074411a4b0e7944ea8c9c1","crypto":{"ciphertext":"5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b","cipherparams":{"iv":"9454222d759f0c0cf340725a76156f24"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2","n":8192,"r":8,"p":1},"mac":"fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c"}},"password":"helloworld"} +{ + "_": [], + "bootstrap": true, + "b": true, + "ws": "ws://localhost:5000", + "websocket": "ws://localhost:5000", + "sqlite": "/proj/zkopru/packages/cli/zkopru-coordinator.db", + "address": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "a": "0x970e8f18ebfEa0B08810f33a5A40438b9530FBCF", + "db": "db", + "maxBytes": 131072, + "max-bytes": 131072, + "priceMultiplier": 48, + "price-multiplier": 48, + "port": 8888, + "$0": "zkopru-coordinator", + "keystore": { + "version": 3, + "id": "5c1043d1-c95d-49b3-ad52-e67e377ee64f", + "address": "90f8bf6a479f320ead074411a4b0e7944ea8c9c1", + "crypto": { + "ciphertext": "5d334c6d4b80d89725a3fbd4d8e6cb5a51285d5100ae98cbe5e4ad5d83d83d5b", + "cipherparams": { "iv": "9454222d759f0c0cf340725a76156f24" }, + "cipher": "aes-128-ctr", + "kdf": "scrypt", + "kdfparams": { + "dklen": 32, + "salt": "a760a305564c7d0b8d6ff835579a4aa50241ba1baa87965bae795a9594c40ab2", + "n": 8192, + "r": 8, + "p": 1 + }, + "mac": "fe55615bb0216bda70d9bd5d547e0f465bc863342357c9de01ce4f8c2f35583c" + } + }, + "password": "helloworld" +} diff --git a/packages/contracts/hardhat.config-fork.js b/packages/contracts/hardhat.config-fork.js new file mode 100644 index 000000000..fe8d53395 --- /dev/null +++ b/packages/contracts/hardhat.config-fork.js @@ -0,0 +1,25 @@ +/** + * @type import('hardhat/config').HardhatUserConfig + */ +module.exports = { + solidity: "0.7.4", + networks: { + hardhat: { + chainId: 20200406, + blockGasLimit: 12000000, + forking: { + url: "https://zkopru-testnet.sifnoc.net", + blockNumber: 95 // Migration step 19 complete as 'testnet' network. + }, + mining: { + auto: process.env.BLOCKTIME ? false : true, + interval: process.env.BLOCKTIME + }, + accounts: { + mnemonic: + "myth like bonus scare over problem client lizard pioneer submit female collect", + count: 10 + } + } + } +}; diff --git a/packages/contracts/hardhat.config.js b/packages/contracts/hardhat.config.js new file mode 100644 index 000000000..f9490ca45 --- /dev/null +++ b/packages/contracts/hardhat.config.js @@ -0,0 +1,21 @@ +/** + * @type import('hardhat/config').HardhatUserConfig + */ +module.exports = { + solidity: "0.7.4", + networks: { + hardhat: { + chainId: 20200406, + blockGasLimit: 12000000, + mining: { + auto: process.env.BLOCKTIME ? false : true, + interval: process.env.BLOCKTIME + }, + accounts: { + mnemonic: + "myth like bonus scare over problem client lizard pioneer submit female collect", + count: 10 + } + } + } +}; diff --git a/packages/contracts/package.json b/packages/contracts/package.json index d22770470..278e03eae 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -19,6 +19,7 @@ "@openzeppelin/contracts": "3.4.1", "bn.js": "^5.2.0", "ganache-time-traveler": "^1.0.15", + "hardhat": "^2.1.2", "soltypes": "^1.3.5", "web3": "^1.2.6", "web3-core": "^1.2.6", diff --git a/packages/contracts/truffle-config.js b/packages/contracts/truffle-config.js index 2ef1cbfb8..10f8cde77 100644 --- a/packages/contracts/truffle-config.js +++ b/packages/contracts/truffle-config.js @@ -49,11 +49,6 @@ module.exports = { port: 8549, // Standard Ethereum port (default: none) network_id: "*" // Any network (default: none) }, - integrationtest: { - host: "127.0.0.1", - port: 5000, - network_id: "20200406" - }, testnet: { host: "127.0.0.1", port: 5000, diff --git a/scripts/dev_start.sh b/scripts/dev_start.sh deleted file mode 100644 index d152acc57..000000000 --- a/scripts/dev_start.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -while ! nc -z postgres 5432; do sleep 1; done; - -if [ -z $SKIP_MIGRATE ] -then - yes | prisma migrate up --experimental --schema /proj/packages/prisma/prisma/postgres-migrator.prisma --verbose -fi - -exec gotty -w --port $PORT node /proj/packages/cli/dist/apps/coordinator/cli.js --config /proj/packages/cli/coordinator.dev.json diff --git a/scripts/run_testnet_minikube.sh b/scripts/run_testnet_minikube.sh new file mode 100644 index 000000000..6d6f2ad91 --- /dev/null +++ b/scripts/run_testnet_minikube.sh @@ -0,0 +1,16 @@ +#!/bin/bash +eval $(minikube -p minikube docker-env) + +# Create Image in Local +docker-compose -f docker-compose.instant-block.yml build + +# Change docker image names for kubernetes +docker image tag zkopru_testnet:latest zkopru/testnet:latest +docker image tag zkopru_coordinator:latest zkopru/coordinator:latest +docker image tag zkopru_wallet:latest zkopru/wallet:latest + +# Run kubenetes pods +minikube kubectl -- apply -f ./dockerfiles/templates/testnet.yaml +minikube kubectl -- apply -f ./dockerfiles/templates/coordinator.yaml +minikube kubectl -- apply -f ./dockerfiles/templates/wallet.yaml + diff --git a/scripts/wait_deploy_contracts.sh b/scripts/wait_deploy_contracts.sh new file mode 100644 index 000000000..1e0bfd1ca --- /dev/null +++ b/scripts/wait_deploy_contracts.sh @@ -0,0 +1,17 @@ +#!/bin/bash +target_contract=$(cat /proj/packages/cli/coordinator.dev.json | jq .address) + +function get_code_length() { + response_length=$(curl -s -H "Content-Type: application/json" -X POST --data '{"id":1337,"jsonrpc":"2.0","method":"eth_getCode","params":['$target_contract']}' http://$TARGET_HOST:5000 | jq .result | wc -m) +} + +while true; do + get_code_length + if [[ $response_length -gt 40000 ]]; then + echo "Zkopru contract deployed, Ready to run" + break + else + echo "Wait for finish deploying Zkopru contract" + sleep 1 + fi +done