Skip to content

Commit

Permalink
merge with feat/maci-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Feb 6, 2024
2 parents a0654f9 + 892c3f5 commit 2f3b060
Show file tree
Hide file tree
Showing 119 changed files with 3,156 additions and 4,116 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/cancel-round.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ name: Cancel current round
on: workflow_dispatch

env:
NODE_VERSION: 18.x
SUBGRPAH_URL: "https://api.thegraph.com/subgraphs/name/clrfund/clrfund-arbitrum-goerli"
NODE_VERSION: 20.x
SUBGRPAH_URL: "https://api.thegraph.com/subgraphs/name/clrfund/clrfund-testnet"
WALLET_PRIVATE_KEY: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_WALLET_PRIVATE_KEY }}
NETWORK: "arbitrum-sepolia"

jobs:
cancel-round:
Expand All @@ -25,6 +26,6 @@ jobs:
- name: Run the cancel round script
run: |
cd contracts
export FACTORY=$(curl -X POST -d '{"query":"{fundingRoundFactories {id}}"}' $SUBGRPAH_URL)
export FACTORY_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.FACTORY).data.fundingRoundFactories[0].id)')
yarn hardhat cancel-round --factory ${FACTORY_ADDRESS} --network arbitrum-goerli
export CLRFUND=$(curl -X POST -d '{"query":"{clrFunds {id}}"}' $SUBGRPAH_URL)
export CLRFUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.CLRFUND).data.clrFunds[0].id)')
yarn hardhat clr-cancel --clrfund "${CLRFUND_ADDRESS}" --network ${NETWORK}
66 changes: 35 additions & 31 deletions .github/workflows/finalize-round.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,16 @@ name: Finalize a test round
on:
workflow_dispatch:
inputs:
branch_name:
description: 'Clrfund branch name'
required: true
default: 'develop'
subgraph_name:
description: 'Clrfund subgraph name'
required: true
default: 'yuetloo/clrfund-dev'
default: 'clrfund/clrfund-testnet'

env:
NODE_VERSION: 18.x
NETWORK: "arbitrum-goerli"
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"
NODE_VERSION: 20.x
NETWORK: "arbitrum-sepolia"
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"

Expand All @@ -35,43 +28,54 @@ 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":"{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 contracts
yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${NETWORK}"
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=@"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}"
5 changes: 2 additions & 3 deletions .github/workflows/mantle_finalize_round.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ on:

env:
NODE_VERSION: 16.x
NETWORK: "arbitrum-goerli"
COORDINATOR_ETH_PK: ${{ secrets.MANTLE_TESTNET_COORDINATOR_WALLET_PRIVATE_KEY }}
COORDINATOR_PK: ${{ secrets.MANTLE_TESTNET_COORDINATOR_MACI_PRIVATE_KEY }}

Expand Down Expand Up @@ -69,8 +68,8 @@ jobs:
echo "MACI_START_BLOCK:" $MACI_START_BLOCK
# tally and finalize
cd contracts
yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${NETWORK}"
yarn hardhat tally --round-address "${ROUND_ADDRESS}" --network "${{ github.event.inputs.network }}"
curl --location --request POST 'https://api.pinata.cloud/pinning/pinFileToIPFS' \
--header "Authorization: Bearer ${{ secrets.PINATA_JWT }}" \
--form 'file=@"tally.json"'
yarn hardhat run --network "${NETWORK}" scripts/finalize.ts
yarn hardhat run --network "${{ github.event.inputs.network }}" scripts/finalize.ts
43 changes: 43 additions & 0 deletions .github/workflows/mantle_new_recipient_registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Mantle testnet - New Recipient Registry

on:
workflow_dispatch:
inputs:
branch_name:
description: 'Clrfund branch name'
required: true
default: 'cohort/EthSingapore'
factory:
description: 'Clrfund factory address'
required: true
default: '0x006f39E6a6D15323334Be1db34C73088550BB20a'
network:
description: 'Network'
required: true
default: 'mantle-testnet'

env:
NODE_VERSION: 16.x
WALLET_PRIVATE_KEY: ${{ secrets.MANTLE_TESTNET_COORDINATOR_WALLET_PRIVATE_KEY }}

jobs:
new-recipient-registry:
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: Checkout source code
uses: actions/checkout@v3
- name: Build CLR
run: |
yarn && yarn build
- name: Create new recipient registry
run: |
cd contracts
export FACTORY_ADDRESS="${{ github.event.inputs.factory }}"
yarn hardhat deploy-recipient-registry \
--network "${{ github.event.inputs.network }}" \
--factory "${{ github.event.inputs.factory }}" \
--type "optimistic"
22 changes: 16 additions & 6 deletions .github/workflows/new-round.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: Create new round

on: workflow_dispatch
on:
workflow_dispatch:
inputs:
duration:
description: 'Round duration'
required: true
default: 3600


env:
NODE_VERSION: 18.x
SUBGRPAH_URL: "https://api.thegraph.com/subgraphs/name/clrfund/clrfund-arbitrum-goerli"
NODE_VERSION: 20.x
SUBGRPAH_URL: "https://api.thegraph.com/subgraphs/name/clrfund/clrfund-testnet"
WALLET_PRIVATE_KEY: ${{ secrets.ARBITRUM_GOERLI_COORDINATOR_WALLET_PRIVATE_KEY }}
NETWORK: arbitrum-sepolia

jobs:
create-new-round:
Expand All @@ -25,6 +33,8 @@ jobs:
- name: Run create new round script
run: |
cd contracts
export FACTORY=$(curl -X POST -d '{"query":"{fundingRoundFactories {id}}"}' $SUBGRPAH_URL)
export FACTORY_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.FACTORY).data.fundingRoundFactories[0].id)')
yarn hardhat run scripts/newRound.ts --network arbitrum-goerli
export CLRFUND=$(curl -X POST -d '{"query":"{clrFunds {id}}"}' $SUBGRPAH_URL)
export CLRFUND_ADDRESS=$(node -e 'console.log(JSON.parse(process.env.CLRFUND).data.clrFunds[0].id)')
yarn hardhat new-round --network "${NETWORK}" \
--duration ${{ github.event.inputs.duration }} \
--clrfund ${CLRFUND_ADDRESS}
74 changes: 0 additions & 74 deletions .github/workflows/test-buildsnark.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'contracts/**'

env:
NODE_VERSION: 18.x
NODE_VERSION: 20.x

jobs:
test-contracts:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'develop'

env:
NODE_VERSION: 18.x
NODE_VERSION: 20.x
CIRCUIT_TYPE: micro
ZKEYS_DOWNLOAD_SCRIPT: "download-6-8-2-3.sh"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-scripts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- '.github/workflows/test-scripts.yml'

env:
NODE_VERSION: 18.x
NODE_VERSION: 20.x
ZKEYS_DOWNLOAD_SCRIPT: "download-6-8-2-3.sh"

jobs:
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
uses: actions/checkout@v3
with:
path: monorepo
- name: Download batch 64 params
- name: Download circuit params
run: |
$GITHUB_WORKSPACE/monorepo/.github/scripts/${ZKEYS_DOWNLOAD_SCRIPT}
- name: Build CLR
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.4.0
20.11.0
4 changes: 2 additions & 2 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"dependencies": {
"@openzeppelin/merkle-tree": "^1.0.5",
"ethers": "^6.9.2",
"maci-crypto": "0.0.0-ci.45d1156",
"maci-domainobjs": "0.0.0-ci.45d1156"
"maci-crypto": "0.0.0-ci.da1e442",
"maci-domainobjs": "0.0.0-ci.da1e442"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export function getRecipientClaimData(
recipientTreeDepth: number,
tally: Tally
): any[] {
const maxRecipients = tally.perVOSpentVoiceCredits.tally.length
if (recipientIndex >= maxRecipients) {
throw new Error(`Invalid recipient index ${recipientIndex}.`)
}

// Create proof for total amount of spent voice credits
const spent = tally.perVOSpentVoiceCredits.tally[recipientIndex]
const spentSalt = tally.perVOSpentVoiceCredits.salt
Expand Down
2 changes: 1 addition & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ yarn hardhat verify-all --clrfund <clrfund-address> --network <network>
If you want to genereate a single key to coordinate multiple rounds.

```
yarn ts-node cli/newMaciKey.ts
yarn ts-node tasks/maciNewKey.ts
```
Loading

0 comments on commit 2f3b060

Please sign in to comment.