From 01021bb1dfc8d3b2b6cb17b744e396df89afe81a Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Wed, 13 Dec 2023 23:36:28 +0000 Subject: [PATCH] ci(ceremony): setup nightly workflow to test ceremony artifacts --- .github/scripts/ceremony-param-tests.sh | 57 ++++++++++++++++++ .../scripts/download-ceremony-artifacts.sh | 17 ++++++ .github/workflows/nightly-ceremony.yml | 59 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100755 .github/scripts/ceremony-param-tests.sh create mode 100755 .github/scripts/download-ceremony-artifacts.sh create mode 100644 .github/workflows/nightly-ceremony.yml diff --git a/.github/scripts/ceremony-param-tests.sh b/.github/scripts/ceremony-param-tests.sh new file mode 100755 index 0000000000..b20deb230e --- /dev/null +++ b/.github/scripts/ceremony-param-tests.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e + +cd "$(dirname "$0")" +cd ../../cli + +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployVkRegistry +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js setVerifyingKeys \ + --state-tree-depth 6 \ + --int-state-tree-depth 2 \ + --msg-tree-depth 8 \ + --vote-option-tree-depth 3 \ + --msg-batch-depth 2 \ + --process-messages-zkey ./zkeys/ProcessMessages_6-8-2-3_final.zkey \ + --tally-votes-zkey ./zkeys/TallyVotes_6-2-3_final.zkey +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js create -s 6 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployPoll \ + -pk macipk.c974f4f168b79727ac98bfd53a65ea0b4e45dc2552fe73df9f8b51ebb0930330 \ + -t 30 -g 25 -mv 25 -i 2 -m 8 -b 2 -v 3 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js signup \ + --pubkey macipk.3e7bb2d7f0a1b7e980f1b6f363d1e3b7a12b9ae354c2cd60a9cfa9fd12917391 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \ + --pubkey macipk.3e7bb2d7f0a1b7e980f1b6f363d1e3b7a12b9ae354c2cd60a9cfa9fd12917391 \ + --privkey macisk.fd7aa614ec4a82716ffc219c24fd7e7b52a2b63b5afb17e81c22fe21515539c \ + --state-index 1 \ + --vote-option-index 0 \ + --new-vote-weight 9 \ + --nonce 1 \ + --poll-id 0 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \ + --pubkey macipk.d5788ea6ccf1ec295df99aaef859031fe7bd359e7e03acb80eb6e8a192f2ce19 \ + --privkey macisk.fd7aa614ec4a82716ffc219c24fd7e7b52a2b63b5afb17e81c22fe21515539c \ + --state-index 1 \ + --vote-option-index 1 \ + --new-vote-weight 9 \ + --nonce 2 \ + --poll-id 0 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js timeTravel -s 100 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeSignups --poll-id 0 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeMessages --poll-id 0 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js genProofs \ + --privkey macisk.49953af3585856f539d194b46c82f4ed54ec508fb9b882940cbe68bbc57e59e \ + --poll-id 0 \ + --rapidsnark ~/rapidsnark/build/prover \ + --process-zkey ./zkeys/ProcessMessages_6-8-2-3_final.zkey \ + --tally-zkey ./zkeys/TallyVotes_6-2-3_final.zkey \ + --tally-file tally.json \ + --output proofs/ \ + --process-witnessgen ./zkeys/TallyVotes_6-2-3 \ + --tally-witnessgen ./zkeys/ProcessMessages_6-8-2-3 +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js proveOnChain \ + --poll-id 0 \ + --proof-dir proofs/ +HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js verify \ + --poll-id 0 \ + --tally-file tally.json diff --git a/.github/scripts/download-ceremony-artifacts.sh b/.github/scripts/download-ceremony-artifacts.sh new file mode 100755 index 0000000000..0226279345 --- /dev/null +++ b/.github/scripts/download-ceremony-artifacts.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -e + +cd "$(dirname "$0")" +cd .. +mkdir -p ../cli/zkeys + +URL=https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.2.0/maci_keys_6-8-2-3_ceremony.tar.gz +DIR_NAME="maci_keys.tar.gz" +OUT_DIR=../cli/ + +echo "downloading $URL" +curl $URL -o "$OUT_DIR/$DIR_NAME" +tar -xvf "$OUT_DIR/$DIR_NAME" -C "$OUT_DIR" + + diff --git a/.github/workflows/nightly-ceremony.yml b/.github/workflows/nightly-ceremony.yml new file mode 100644 index 0000000000..b36158dfa4 --- /dev/null +++ b/.github/workflows/nightly-ceremony.yml @@ -0,0 +1,59 @@ +name: Nightly Ceremony + +on: + push: + pull_request: + +jobs: + test-with-ceremony-keys: + strategy: + fail-fast: false + + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + ref: dev + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install --yes \ + build-essential \ + libgmp-dev \ + libsodium-dev \ + nasm \ + nlohmann-json3-dev + + - name: Initialize Project + run: | + npm install + npm run bootstrap + npm run build + + - name: Compile contracts with ceremony params and run hardhat fork + run: | + cd contracts + npm run compileSol 6 + npm run hardhat & + + - name: Download rapidsnark (1c137) + run: | + mkdir -p ~/rapidsnark/build + wget -qO ~/rapidsnark/build/prover https://maci-devops-zkeys.s3.ap-northeast-2.amazonaws.com/rapidsnark-linux-amd64-1c137 + chmod +x ~/rapidsnark/build/prover + + - name: Download ceremony artifacts + run: ./.github/scripts/download-ceremony-artifacts.sh + + - name: Run tests + run: ./.github/scripts/ceremony-param-tests.sh + + - name: Stop Hardhat + run: kill $(lsof -t -i:8545)