Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Feb 3, 2024
1 parent 4a77d03 commit c55ff3f
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions .github/workflows/finalize-round.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ on:
subgraph_name:
description: 'Clrfund subgraph name'
required: true
default: 'yuetloo/clrfund-dev'
default: 'clrfund/clrfund-testnet'

env:
NODE_VERSION: 18.x
NETWORK: "arbitrum-goerli"
NETWORK: "arbitrum-sepolia"
COORDINATOR_ETH_PK: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_WALLET_PRIVATE_KEY }}
COORDINATOR_PK: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_MACI_PRIVATE_KEY }}
JSONRPC_HTTP_URL: ${{ secrets.JSONRPC_HTTP_URL }}
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY_ARBITRUM }}
ETHERSCAN_URL: "https://api-goerli.arbiscan.io"
CIRCUIT_TYPE: micro
ZKEYS_DOWNLOAD_SCRIPT: "download-6-8-2-3.sh"

Expand All @@ -35,43 +32,50 @@ jobs:
run: |
sudo apt update
sudo apt-get install build-essential libgmp-dev libsodium-dev nlohmann-json3-dev nasm g++ curl
- name: Install rust toolchain
uses: actions-rs/toolchain@v1
- name: Checkout rapidsnark source code
uses: actions/checkout@v3
with:
toolchain: stable
- name: Install zkutil
repository: clrfund/rapidsnark
path: rapidsnark
- name: Install rapidsnark
run: |
cargo install zkutil --version 0.3.2
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:
ref: ${{ github.event.inputs.branch_name }}
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="https://api.thegraph.com/subgraphs/name/${{ github.event.inputs.subgraph_name }}"
echo $SUBGRAPH_URL
export NODE_CONFIG=$(node -e "const snarkParamsPath=process.env.GITHUB_WORKSPACE + '/params'; console.log(JSON.stringify({ snarkParamsPath }));")
export ROUND=$(curl -X POST -d '{"query":"{fundingRoundFactories {id currentRound {id maci}}}"}' $SUBGRPAH_URL)
export FACTORY_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.fundingRoundFactories[0].id)')
export ROUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.fundingRoundFactories[0].currentRound.id)')
export MACI_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.fundingRoundFactories[0].currentRound.maci)')
export TX_URL="${ETHERSCAN_URL}/api?module=account&action=txlistinternal&address=${MACI_ADDRESS}&startblock=0&page=10&offset=1&sort=asc&apikey=${ETHERSCAN_API_KEY}"
export TXLIST=$(curl $TX_URL)
export MACI_START_BLOCK=$(node -e 'console.log(JSON.parse(process.env.TXLIST).result[0].blockNumber)')
echo "MACI_START_BLOCK:" $MACI_START_BLOCK
export ROUND=$(curl -X POST -d '{"query":"{clrFund {id currentRound {id maci}}}"}' $SUBGRPAH_URL)
export CLRFUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFund[0].id)')
export ROUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFund[0].currentRound.id)')
export MACI_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFund[0].currentRound.maci)')
export MACI_TX_HASH=$(node -e 'console.log(JSON.parse(process.env.ROUND).data.clrFund[0].currentRound.maciTxHash)')
# tally and finalize
cd contracts
yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${NETWORK}"
cd monorepo/contracts
yarn hardhat clr-tally --clrfund "${CLRFUND_ADDRESS}" --network "${NETWORK}" \
--directory ~/params --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=@"tally.json"'
JSONRPC_HTTP_URL=${{env.JSONRPC_HTTP_URL}} yarn hardhat run --network "${NETWORK}" scripts/finalize.ts
--form 'file=@"./proof_output/tally.json"'
yarn hardhat --network "${NETWORK}" clr-finalize --clrfund "${CLRFUND_ADDRESS}"

0 comments on commit c55ff3f

Please sign in to comment.