Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:privacy-scaling-explorations/maci in…
Browse files Browse the repository at this point in the history
…to feat/fetchlogs
  • Loading branch information
ctrlc03 committed Oct 30, 2023
2 parents 99669e2 + 1ba362b commit 54ed045
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 100 deletions.
20 changes: 0 additions & 20 deletions .github/scripts/hnctl.sh

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/circuit-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [18]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/contracts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [18]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/core-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [18]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/crypto-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [18]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/domainobjs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [18]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'

# To prevent `npm install` failure of circuit package,
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Use Node.js 16
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'

# To prevent `npm install` failure of circuit package,
Expand Down
33 changes: 29 additions & 4 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 16

# Check for changes in the 'circuit' folder
- name: Get changed files
id: get-changed-files
uses: jitterbit/get-changed-files@v1
with:
format: 'csv'

- name: Check for changes in 'circuit' folder
id: check_changes
run: |
CHANGED_FILES=${{ steps.get-changed-files.outputs.all }}
if echo "$CHANGED_FILES" | grep -q "circuit" && ! echo "$CHANGED_FILES" | grep -q ".github/workflows/circuit-build.yml"; then
echo "CHANGED=true" >> $GITHUB_ENV
echo "Circuits have changes."
else
echo "CHANGED=false" >> $GITHUB_ENV
echo "No changes on circuits."
fi
- name: Install dependencies
run: |
Expand Down Expand Up @@ -47,6 +66,8 @@ jobs:
run: |
cd contracts
npm run compileSol
npm run hardhat &
sleep 5
- name: Download rapidsnark (1c137)
run: |
Expand All @@ -61,15 +82,19 @@ jobs:
chmod +x /home/runner/work/maci/.local/bin/circom
- name: Generate zkeys
if: ${{ env.CHANGED == 'true' }}
run: |
cd cli
mkdir -p zkeys
wget -qO zkeys/powersOfTau28_hez_final_20.ptau https://maci-devops-zkeys.s3.ap-northeast-2.amazonaws.com/powersOfTau28_hez_final_20.ptau
npx zkey-manager compile -c ./zkeys.config.yml
npx zkey-manager genZkeys -c ./zkeys.config.yml
- name: Run Hardhat Network
run: ./.github/scripts/hnctl.sh start_hardhat_network
- name: Download zkeys
if: ${{ env.CHANGED == 'false' }}
run: |
cd integrationTests
npm run download-zkeys
- name: Bespoke Test
run: ./.github/scripts/run-e2e-tests.sh
Expand All @@ -79,5 +104,5 @@ jobs:
cd integrationTests
npm run test
- name: Destroy Hardhat Network
run: ./.github/scripts/hnctl.sh destroy_hardhat_network
- name: Stop Hardhat
run: kill $(lsof -t -i:8545)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Below you can find a list of the packages included in this repository.

### Requirements

You should have Node.js (version `>=14 and <=18`) installed. Use `nvm` to install it and manage versions.
You should have Node.js v18 installed. Use `nvm` to install it and manage versions. This code has been tested with earlier Node versions (14 and 16), however we do recommend using Node 18.

You also need a Ubuntu/Debian Linux machine on an Intel CPU.

Expand All @@ -48,7 +48,7 @@ Install dependencies:

If you are missing the correct version of glibc see `circuits/scripts/installGlibc.sh`

Clone this repository, install NodeJS dependencies, and build the source code:
Clone this repository, install Node.js dependencies, and build the source code:

```bash
git clone [email protected]:privacy-scaling-explorations/maci.git
Expand Down
25 changes: 19 additions & 6 deletions cli/ts/deployPollWithSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ const { ethers } = require('hardhat')
import {
parseArtifact,
deployVerifier,
deployPpt,
getDefaultSigner,
getDefaultSigner,
deployMessageProcessor,
deployTally,
deploySubsidy
} from 'maci-contracts'

import {
Expand Down Expand Up @@ -188,8 +190,15 @@ const deployPollWithSigner = async (args: any) => {
// Deploy a PollProcessorAndTallyer contract
const verifierContract = await deployVerifier(true)
console.log('Verifier:', verifierContract.address)
const pptContract = await deployPpt(verifierContract.address, true)
await pptContract.deployTransaction.wait()

const mpContract = await deployMessageProcessor(verifierContract.address, contractAddrs['PoseidonT3'],contractAddrs['PoseidonT4'],contractAddrs['PoseidonT5'],contractAddrs['PoseidonT6'])
await mpContract.deployTransaction.wait()

const tallyContract = await deployTally(verifierContract.address, contractAddrs['PoseidonT3'],contractAddrs['PoseidonT4'],contractAddrs['PoseidonT5'],contractAddrs['PoseidonT6'])
await tallyContract.deployTransaction.wait()

const subsidyContract = await deploySubsidy(verifierContract.address, contractAddrs['PoseidonT3'],contractAddrs['PoseidonT4'],contractAddrs['PoseidonT5'],contractAddrs['PoseidonT6'])
await subsidyContract.deployTransaction.wait()

const [ maciAbi ] = parseArtifact('MACI')
const maciContract = new ethers.Contract(
Expand Down Expand Up @@ -223,9 +232,13 @@ const deployPollWithSigner = async (args: any) => {
const pollAddr = log.args._pollAddr
console.log('Poll ID:', pollId.toString())
console.log('Poll contract:', pollAddr)
console.log('PollProcessorAndTallyer contract:', pptContract.address)
console.log('MessageProcessor contract:', mpContract.address)
console.log('Tally contract:', tallyContract.address)
console.log('Subsidy contract:', subsidyContract.address)
contractAddrs['Verifier-' + pollId.toString()] = verifierContract.address
contractAddrs['PollProcessorAndTally-' + pollId.toString()] = pptContract.address
contractAddrs['MessageProcessor-' + pollId.toString()] = mpContract.address
contractAddrs['Tally-' + pollId.toString()] = tallyContract.address
contractAddrs['Subsidy-' + pollId.toString()] = subsidyContract.address
contractAddrs['Poll-' + pollId.toString()] = pollAddr
writeJSONFile(contractFilepath, contractAddrs)

Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ RUN apt-get update \
&& apt-get install -y libgmp-dev nlohmann-json3-dev nasm g++


# install nvm and nodejs
# install nvm and Node.js
ENV NODE_VERSION=14.18.1
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
Expand Down
3 changes: 1 addition & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ MACI offers the following guarantees:

* **Collusion resistance**: no-one except a trusted coordinator should be
certain of the validity of a vote, reducing the effectiveness of bribery.
* **Receipt-freeness**: no-one voter prove (besides to the coordinator) which
way they voted.
* **Receipt-freeness**: no voter should be able to prove (besides to the coordinator) which way they voted.
* **Privacy**: no-one except a trusted coordinator should be able to decrypt a
vote.
* **Uncensorability**: no-one — not even the trusted coordinator — should be
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ You need the following to use MACI:

- An x86-64 system
- A Linux system, preferably a Debian-based distribution like Ubuntu
- NodeJS. Use [`nvm`](https://github.com/nvm-sh/nvm) to install it. MACI has
been tested with Node 14 and 16.
- Node.js: use [`nvm`](https://github.com/nvm-sh/nvm) to install it. MACI has
been tested with Node 14, 16 and 18. We do however recommend to use Node 18 as Node 14 is deprecated and Node 16 will soon be deprecated too.
- The `libgmp-dev` `nlohmann-json3-dev` `nasm` and `g++` Debian/Ubuntu
packages. They are needed to run `circom-helper`, which in turn is used to
develop and test zk-SNARK circuits.
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ invalidVote:
voteCreditBalance: 1
constants:
poll:
duration: 120
duration: 250
intStateTreeDepth: 1
messageTreeDepth: 2
messageBatchDepth: 1
Expand Down
21 changes: 7 additions & 14 deletions integrationTests/scripts/download_zkeys.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ cd ..

mkdir -p ../cli/zkeys

PKGS="zkeys_10-2-1-2_glibc-211.tar.gz ProcessMessages_10-2-1-2_test.0.zkey TallyVotes_10-1-2_test.0.zkey SubsidyPerBatch_10-1-2_test.0.zkey"
URL=https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.2/maci_keys_10-2-1-2_dev.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"

BASE_URL=https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.1.1-aa4ba27/10-2-1-2
OUT_DIR=../cli/zkeys

for p in $PKGS
do
url="$BASE_URL/$p"
echo "downloading $url"
curl $url -o "$OUT_DIR/$p"
extension="${p##*.}"
if [ "$extension" == "gz" ]
then
tar -xvf "$OUT_DIR/$p" -C "$OUT_DIR"
fi
done
77 changes: 39 additions & 38 deletions integrationTests/ts/__tests__/deployPollWithRandomSigner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,51 @@ describe('Test deployPollWithSigner', () => {
const test = data.suites[0]
it(test.description, async () => {
const result = await executeSuite(test, expect)
console.log(result)
expect(result).toBeTruthy()


let caughtException = false
try {
let caughtException = false
try {
const config = loadYaml()

const tally = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../cli/tally.json')).toString())
const coordinatorKeypair = new Keypair()
const tally = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../cli/tally.json')).toString())
const coordinatorKeypair = new Keypair()

// start another round by a random user
const wallet = Wallet.createRandom()

// start another round by a random user
const wallet = Wallet.createRandom()
// fund wallet with 1 ETH
const totalAmount = utils.parseEther("1")
const fundWalletCommand = `node build/index.js fundWallet` +
` -w ${wallet.address}` +
` -a ${totalAmount.toString()}`
execute(fundWalletCommand)

// fund wallet with 1 ETH
const totalAmount = utils.parseEther("1")
const fundWalletCommand = `node build/index.js fundWallet` +
` -w ${wallet.address}` +
` -a ${totalAmount.toString()}`
execute(fundWalletCommand)

const duration = 999999
const deployPollCommand = `node build/index.js deployPollWithSigner` +
` -x ${tally.maci}` +
` -s ${wallet.privateKey}` +
` -pk ${coordinatorKeypair.pubKey.serialize()}` +
` -t ${duration}` +
` -g ${config.constants.maci.maxMessages}` +
` -mv ${config.constants.maci.maxVoteOptions}` +
` -i ${config.constants.poll.intStateTreeDepth}` +
` -m ${config.constants.poll.messageTreeDepth}` +
` -b ${config.constants.poll.messageBatchDepth}` +
` -v ${config.constants.maci.voteOptionTreeDepth}`
execute(deployPollCommand)
// sleep for 5 seconds
await new Promise(resolve => setTimeout(resolve, 5000))

const duration = 999999
const deployPollCommand = `node build/index.js deployPollWithSigner` +
` -x ${tally.maci}` +
` -s ${wallet.privateKey}` +
` -pk ${coordinatorKeypair.pubKey.serialize()}` +
` -t ${duration}` +
` -g ${config.constants.maci.maxMessages}` +
` -mv ${config.constants.maci.maxVoteOptions}` +
` -i ${config.constants.poll.intStateTreeDepth}` +
` -m ${config.constants.poll.messageTreeDepth}` +
` -b ${config.constants.poll.messageBatchDepth}` +
` -v ${config.constants.maci.voteOptionTreeDepth}`
execute(deployPollCommand)

// this is the second poll with pollId = 1
const pollId = 1
const pollDuration = await getPollDuration(tally.provider, tally.maci, pollId)
expect(pollDuration.toString()).toEqual(duration.toString())
} catch (e) {
console.log(e)
caughtException = true
expect(caughtException).toEqual(false)
}
// this is the second poll with pollId = 1
const pollId = 1
const pollDuration = await getPollDuration(tally.provider, tally.maci, pollId)
expect(pollDuration.toString()).toEqual(duration.toString())
} catch (e) {
console.log(e)
caughtException = true
}
expect(caughtException).toEqual(false)
})
})
2 changes: 1 addition & 1 deletion integrationTests/ts/__tests__/suites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const executeSuite = async (data: any, expect: any) => {
}
}

const timeTravelCommand = `node build/index.js timeTravel -s ${config.constants.maci.votingDuration}`
const timeTravelCommand = `node build/index.js timeTravel -s ${config.constants.poll.duration}`
execute(timeTravelCommand)

const mergeMessagesCommand = `node build/index.js mergeMessages -x ${maciAddress} -o ${pollId}`
Expand Down

0 comments on commit 54ed045

Please sign in to comment.