Skip to content

Finalize a test round #82

Finalize a test round

Finalize a test round #82

Workflow file for this run

name: Finalize a test round
on:
workflow_dispatch:
inputs:
subgraph_url:
description: 'Clrfund subgraph url'
required: true
default: 'https://api.studio.thegraph.com/query/66324/clrfund-dev/version/latest'
network:
description: 'Network'
required: true
default: 'optimism-sepolia'
env:
NODE_VERSION: 20.x
COORDINATOR_MACISK: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_MACI_PRIVATE_KEY }}
WALLET_PRIVATE_KEY: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_WALLET_PRIVATE_KEY }}
CIRCUIT_TYPE: micro
ZKEYS_DOWNLOAD_SCRIPT: "download-6-8-2-3.sh"
jobs:
finalize:
runs-on: ubuntu-22.04
steps:
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install g++ library dependencies
run: |
sudo apt update
sudo apt-get install build-essential libgmp-dev libsodium-dev nlohmann-json3-dev nasm g++ curl
- name: Checkout rapidsnark source code
uses: actions/checkout@v3
with:
repository: clrfund/rapidsnark
path: rapidsnark
- name: Install rapidsnark
run: |
cd $GITHUB_WORKSPACE/rapidsnark
npm install
git submodule init
git submodule update
./build_gmp.sh host
mkdir build_prover && cd build_prover
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j4 && make install
- name: Checkout source code
uses: actions/checkout@v3
with:
path: monorepo
- name: Download batch 64 params
run: |
ls -la $GITHUB_WORKSPACE
$GITHUB_WORKSPACE/monorepo/.github/scripts/${ZKEYS_DOWNLOAD_SCRIPT}
- name: Build
run: |
cd monorepo
# use https to avoid error: unable to connect to github.com
git config --global url."https://".insteadOf git://
yarn && yarn build
- name: Run finalize scripts
run: |
export SUBGRPAH_URL=${{ github.event.inputs.subgraph_url }}
export NETWORK=${{ github.event.inputs.network }}
export ROUND=$(curl -X POST -d '{"query":"{clrFunds {id currentRound {id maci maciTxHash}}}"}' $SUBGRPAH_URL)
export CLRFUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFunds[0].id)')
export ROUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFunds[0].currentRound.id)')
export MACI_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFunds[0].currentRound.maci)')
export MACI_TX_HASH=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFunds[0].currentRound.maciTxHash)')
export RAPID_SNARK="$GITHUB_WORKSPACE/rapidsnark/package/bin/prover"
export CIRCUIT_DIRECTORY=$GITHUB_WORKSPACE/params
# tally and finalize
cd monorepo/contracts
mkdir -p proof_output
yarn hardhat clr-tally --clrfund "${CLRFUND_ADDRESS}" --network "${NETWORK}" \
--rapidsnark ${RAPID_SNARK} \
--circuit-directory ${CIRCUIT_DIRECTORY} \
--maci-tx-hash "${MACI_TX_HASH}" --output-dir "./proof_output"
curl --location --request POST 'https://api.pinata.cloud/pinning/pinFileToIPFS' \
--header "Authorization: Bearer ${{ secrets.PINATA_JWT }}" \
--form 'file=@"./proof_output/tally.json"'
yarn hardhat --network "${NETWORK}" clr-finalize --clrfund "${CLRFUND_ADDRESS}"