Skip to content

Commit

Permalink
docs: update integrating doc in v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Apr 16, 2024
1 parent 0398b8e commit 3c4c1ac
Showing 1 changed file with 91 additions and 2 deletions.
93 changes: 91 additions & 2 deletions website/versioned_docs/version-v1.3_alpha/integrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ Here we will be looking at QFI and how it was used. Please note that this will b

## Deployment

First, you need to deploy contracts to start using MACI. This can be easily done via `maci-cli`.
First, you need to deploy contracts to start using MACI. This could be done through either `maci-cli` or by using hardhat tasks in the `contracts` folder.

### Via `maci-cli`

This can be easily done via `maci-cli`.
Deployment order is:

1. Deploy crypto (Hasher, Poseidon)
Expand All @@ -29,6 +33,12 @@ Deployment order is:

Before running the deploy command make sure you have [zkey files](https://maci.pse.dev/docs/trusted-setup) from trusted setup and env variables `ETH_PROVIDER` (RPC endpoint) and `ETH_SK` (wallet private key) are set. For production environment make sure you don't use zkey files from our examples.

:::note Non Quadratic Voting

Make sure that if you intend to run a non quadratic voting Poll, you set the **NonQv** zKey files on the VkRegistry contract, as well as deploy the Poll with the option `--use-quadratic-voting false`. Finally, remember to use the correct zk-SNARK artifacts (zKeys, and witnesses) in the genProof/prove commands.

:::

```bash
maci-cli deployVkRegistry
maci-cli setVerifyingKeys \
Expand All @@ -49,6 +59,67 @@ maci-cli deployPoll \
--vote-option-tree-depth 2
```

### Deploy contracts in `maci/contracts`

This could also be done via running commands in `maci/contracts`. Please download the maci repository, install and build everything, then navigate to the `contracts` folder.

First of all, modify the `deploy-config.json` file:

```
{
"choose-a-network": {
"ConstantInitialVoiceCreditProxy": {
"deploy": true,
"amount": 99
},
"FreeForAllGatekeeper": {
"deploy": false
},
"EASGatekeeper": {
"deploy": true,
"easAddress": "0xC2679fBD37d54388Ce493F1DB75320D236e1815e",
"schema": "0xe2636f31239f7948afdd9a9c477048b7fc2a089c347af60e3aa1251e5bf63e5c",
"attester": "attester-address"
},
"MACI": {
"stateTreeDepth": 10,
"gatekeeper": "EASGatekeeper"
},
"VkRegistry": {
"stateTreeDepth": 10,
"intStateTreeDepth": 1,
"messageTreeDepth": 2,
"voteOptionTreeDepth": 2,
"messageBatchDepth": 1,
"zkeys": {
"qv": {
"processMessagesZkey": "../cli/zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test.0.zkey",
"tallyVotesZkey": "../cli/zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test.0.zkey"
},
"nonQv": {
"processMessagesZkey": "../cli/zkeys/ProcessMessagesNonQv_10-2-1-2_test/ProcessMessagesNonQv_10-2-1-2_test.0.zkey",
"tallyVotesZkey": "../cli/zkeys/TallyVotesNonQv_10-1-2_test/TallyVotesNonQv_10-1-2_test.0.zkey"
}
}
},
"Poll": {
"pollDuration": 30,
"coordinatorPubkey": "macipk.9a59264310d95cfd8eb7083aebeba221b5c26e77427f12b7c0f50bc1cc35e621",
"useQuadraticVoting": true
}
}
}
```

and run the following command:

```
pnpm run deploy:[network]
pnpm run deploy-poll:[network]
```

The network options are: **_localhost, sepolia, and optimism-sepolia_**.

## Signups and votes

Next, you can start accept user signup and votes. This can be done via `maci-cli` as well:
Expand All @@ -70,6 +141,10 @@ maci-cli publish \

As a coordinator, first you need to merge signups and messages (votes). Signups and messages are stored in a queue so when the poll in over, the coordinator needs to create the tree from the queue. This optimization is needed to reduce gas cost for voters. Then coordinator generates proofs for the message processing, and tally calculations. This allows to publish the poll results on-chain and then everyone can verify the results when the poll is over.

This could also be done by `maci-cli` or run commands in `contracts` folder.

### Via `maci-cli`

```bash
maci-cli mergeSignups --poll-id 0
maci-cli mergeMessages --poll-id 0
Expand All @@ -91,7 +166,21 @@ maci-cli verify \
--tally-file tally.json # this file is generated in genProofs
```

When poll finishes, [Tally contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/Tally.sol) emits the event with poll address so you can track the state changes.
### Finalize in `maci/contracts`

```
pnpm merge:[network] --poll 0
pnpm run prove:[network] --poll 0 \
--coordinator-private-key "macisk.1751146b59d32e3c0d7426de411218172428263f93b2fc4d981c036047a4d8c0" \
--process-zkey ../cli/zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test.0.zkey \
--tally-zkey ../cli/zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test.0.zkey \
--tally-file ../cli/tally.json \
--output-dir ../cli/proofs/ \
--tally-wasm ../cli/zkeys/TallyVotes_10-1-2_test/TallyVotes_10-1-2_test_js/TallyVotes_10-1-2_test.wasm \
--process-wasm ../cli/zkeys/ProcessMessages_10-2-1-2_test/ProcessMessages_10-2-1-2_test_js/ProcessMessages_10-2-1-2_test.wasm
```

When a poll finishes, the [Tally contract](https://github.com/privacy-scaling-explorations/maci/blob/dev/contracts/contracts/Tally.sol) emits an event with the poll address so you can track the state changes.

```javascript
event BallotsTallied(address poll);
Expand Down

0 comments on commit 3c4c1ac

Please sign in to comment.