maci
maci copied to clipboard
cannot merge and genProof for multiple polls
When I deployed two polls and tally the results of each poll, the second one will fail. When mergeSignUp for the second poll, the code will check the stateAq of MACI is already merged (by the first poll merge), but when genProof for the second poll, it complained the stateAq of second poll was no merged.
how to repeat the issue
I modified the code to cache the contract addresses into local file and use this script: https://github.com/chaosma/maci/blob/cordservice/cli/test.sh
# in one terminal
cd contracts && npm run hardhat
# in second terminal
cd cli && ./test.sh
output of the test
Check the last several lines of log.
VkRegistry: 0xfc0A7938B9fC084039f3E1D059BA8B94da0d43A5
Setting verifying keys...
Transaction hash: 0x25d17886feb3b58b6cb62209ffb5d19b0e7eefe51d27175b9d9a45064010f313
Deploying InitialVoiceCreditProxy
Deploying Poseidon contracts
Linking Poseidon libraries to MACI
Linking Poseidon libraries to PollFactory
Linking Poseidon libraries to MessageAqFactory
Deploying MACI
Transferring PollFactory ownership to MACI
Transferring MessageAqFactory ownership to PollFactory
Initialising MACI
MACI: 0x4b71fA2E9613ABc9e5E05148106a5fFf448956Dd
Verifier: 0x98F5dC60DF5Eb721162357091735cdb25aBF1068
Poll ID: 0
Poll contract: 0x18Caf5894CF016317d409EB22130864fE95D4181
PollProcessorAndTallyer contract: 0x0C5069e7383dF83472892277a255DC79d304b7a3
Verifier: 0xd06154527140C0a476746971fDb66472f2b9212A
Poll ID: 1
Poll contract: 0x36e34e434EC2039580B0De78899b69a9A7479838
PollProcessorAndTallyer contract: 0x27EEf3831704664aA82fCF7C1C4413DAdB1e4c49
Transaction hash: 0x87c7c82625f8686657887779bec5b6923945fe13694c5e374dd27c31b6ae5210
State index: 1
Transaction hash: 0xf95d0e37a9266f4333d9b552b95973e49c5858f5d26882dc84ed627da214d500
Ephemeral private key: macisk.2d85e7a59fa8358ba64e6b5f454d531fe7fe3275163bc64b301c4a1c9c24e83b
Transaction hash: 0x2bae8d63005d5fbafa1302effc03c139f405d7e1a786751e4b6b37d4ee9bab01
Ephemeral private key: macisk.2c769cc149134164c8da694bb3e770837a4088d185935471a2887caeae55ae88
--------------- Process the first poll (pollId = 0)
Merging message subroots 1 / 1
Executed mergeMaciStateAqSubRoots(); gas used: 349287
Transaction hash: 0x3921781e66f5113fb00ed668c90a2e047db7c93c7cbadecd6192992a41138c69
All message subtrees have been merged.
Merging subroots to a main message root...
Executed mergeMessageAq(); gas used: 154236
Transaction hash: 0x7a3e53e16b5ddfc1d7a35fe8684525bf2af27d7ca56aea19ada49f26f22bee2a
The message tree has been merged.
Merging state subroots 1 / 1
Executed mergeMaciStateAqSubRoots(); gas used: 486002
Transaction hash: 0x28afa1c8f31429a7d304bb3de02df08adc2d3ceb4dc94f705c7cf1d03ba91794
All state subtrees have been merged.
Merging subroots to a main state root...
Executed mergeStateAq(); gas used: 999779
Transaction hash: 0xe74dd8f08dbd4ae7308661d05b17f6a732b7fe4a77ee585bd752952d58de44f2
The state tree has been merged.
Generating proofs of message processing...
Progress: 1 / 1
Generating proofs of vote tallying...
Progress: 1 / 1
OK
Submitting proofs of message processing...
Transaction hash: 0x57826e1ffbfda8401a6a41a91e09fd1653725488f1b7c43b602ebd62f9456f36
Progress: 1 / 1
All message processing proofs have been submitted.
Submitting proofs of vote tallying...
Progress: 1 / 1
Transaction hash: 0xa518d14ea3817bec758d91ae76c0672f5f10d748ec8b78f6598d191d06df5087
All vote tallying proofs have been submitted.
OK
2898eb587448c9565a14471fb421944645c53cb6e50b5a99afe0c1a7024d481a
{
provider: 'http://localhost:8545',
maci: null,
pollId: 0,
newTallyCommitment: '0x2898eb587448c9565a14471fb421944645c53cb6e50b5a99afe0c1a7024d481a',
results: {
tally: [
'9', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0'
],
salt: '0x1e335a82e6b126c800e758dc986225bfd7d461903fff514d9d71c2c29146cbbd'
},
totalSpentVoiceCredits: {
spent: '81',
salt: '0x301b9ad777601c9116576ab59ef48be48225d70c203c02382f28a4e79abe57'
},
perVOSpentVoiceCredits: {
tally: [
'81', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0', '0', '0', '0', '0', '0',
'0'
],
salt: '0x21bcc13f37a552170be9fbc7447dcba06e3d13429888baddd40d1ee566229122'
}
}
OK
-------------process the second poll (pollId=1)
Merging message subroots 1 / 1
Executed mergeMaciStateAqSubRoots(); gas used: 349287
Transaction hash: 0xda06f4627b101daec237cddf1f851e092c3b297b3546a6f61af9f397fe687fd9
All message subtrees have been merged.
Merging subroots to a main message root...
Executed mergeMessageAq(); gas used: 154236
Transaction hash: 0x2a286b2875ea68343b4323e232b8d978d747ec73888673a92317acc8f1776bee
The message tree has been merged.
merge signup...
All state subtrees have been merged.
The state tree has already been merged.
genProof...
Error: the state tree has not been merged yet. Please use the mergeSignups subcommmand to do so.
Error: could not parse the proof file
0
Error: unable to open tally.json
The error is directly caused by this line: https://github.com/appliedzkp/maci/blob/v1/cli/ts/genProofs.ts#L253 In Poll.sol, it checks whether stateAq is merged. However, since the polls share the same stateAq from MACI contract, only the first mergeSignUp call will merge the stateAq in MACI. The second mergeSignUp call will fail
Fixed in https://github.com/privacy-scaling-explorations/maci/pull/311