Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to tally votes on localhost network #383

Closed
johnson86tw opened this issue Sep 19, 2021 · 9 comments
Closed

Fail to tally votes on localhost network #383

johnson86tw opened this issue Sep 19, 2021 · 9 comments

Comments

@johnson86tw
Copy link
Contributor

I tried to deploy contracts on localhost and follow the steps, but failed to tally votes...

Reproduce

yarn start:node

In a new terminal

cd contracts
yarn deploy:local
yarn contribute:local
yarn vote:local

Tally votes

ipfs get --output snark-params QmRzp3vkFPNHPpXiu7iKpPqVnZB97wq7gyih2mp6pa5bmD
export NODE_CONFIG='{"snarkParamsPath": "../../../contracts/snark-params/", "zkutil_bin": "/usr/bin/zkutil"}'

yarn tally:local

Error:

Generating proofs of message processing...

Progress: 1 / 1; batch index: 0
/bin/sh: /Users/**/Desktop/monorepo/contracts/snark-params/batchUst32: No such file or directory
Error: unable to compute batch update state tree witness data
Error: exec: /bin/sh: /Users/**/Desktop/monorepo/contracts/snark-params/batchUst32: No such file or directory

    at Object.error (/Users/**/Desktop/monorepo/node_modules/shelljs/src/common.js:110:27)
    at execSync (/Users/**/Desktop/monorepo/node_modules/shelljs/src/exec.js:102:12)
    at Object._exec (/Users/**/Desktop/monorepo/node_modules/shelljs/src/exec.js:205:12)
    at Object.exec (/Users/**/Desktop/monorepo/node_modules/shelljs/src/common.js:335:23)
    at /Users/**/Desktop/monorepo/node_modules/maci-circuits/ts/index.ts:230:11
    at step (/Users/**/Desktop/monorepo/node_modules/maci-circuits/build/index.js:33:23)
    at Object.next (/Users/**/Desktop/monorepo/node_modules/maci-circuits/build/index.js:14:53)
    at /Users/**/Desktop/monorepo/node_modules/maci-circuits/build/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/**/Desktop/monorepo/node_modules/maci-circuits/build/index.js:4:12)
Error: generation of proofs failed
    at main (/Users/**/Desktop/monorepo/contracts/scripts/tally.ts:42:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@auryn-macmillan
Copy link
Member

Looks like this is an issue with our documentation being out of date.
The script is wanting the x32 circuits, but the IPFS hash you listed above has the medium circuits.

The final zkey file, qvt32_final.zkey, can be found here
The verification key file, qvt32_verification_key.json, can be found here
The final zkey key file, batchUst32_final.zkey, can be found here
The verification key file, batchUst32_verification_key.json, can be found here

@johnson86tw
Copy link
Contributor Author

johnson86tw commented Sep 22, 2021

Hi @auryn-macmillan,

Thanks for the reply. I used the wrong snark-params to the circuits level in the example above. To make it clear, just list existing snark-params I found in clrfund/contracts/snarkVerifiers/README.md

But when I change function deployMaciFactory circuit level into 'test' or 'medium' and using files above, I still fail to generate proofs because of /bin/sh: /Users/**/Desktop/clrfund/contracts/snark-params/batchUst: No such file or directory in 'test' level, and /bin/sh: /Users/**/Desktop/clrfund/contracts/snark-params/batchUstMedium: No such file or directory in 'medium' level.

// contracts/utils/deployment.ts
export async function deployMaciFactory(
  account: Signer,
  circuit = 'test', // I changed this line for testing
  { poseidonT3, poseidonT6, batchUstVerifier, qvtVerifier }: MaciFactoryDependencies = {},
): Promise<Contract>

It seems to be that the function genProofs from maci-cli needs a binary file batchUst or batchUstMedium but it doesn't exist on ipfs...

However, for x32 circuits files on ipfs, it actually provides the binary file named batchUst32. I downloaded these files (about 1.5 GB...very big...), run it again, and it failed to execute binary file:

Generating proofs of message processing...

Progress: 1 / 1; batch index: 0
/bin/sh: /Users/howard/Desktop/clrfund/snark-params/batchUst32: cannot execute binary file
Error: unable to compute batch update state tree witness data
Error: exec: /bin/sh: /Users/howard/Desktop/clrfund/snark-params/batchUst32: cannot execute binary file

Reference

@weijiekoh
Copy link

Hi @chnejohnson, what is your OS and CPU type?

@johnson86tw
Copy link
Contributor Author

Hi @chnejohnson, what is your OS and CPU type?

macOS - Intel Core i5

@weijiekoh
Copy link

The binaries are compiled for Linux on Intel and won't work in macOS. It's best to try again in a Linux VM. Hope this helps!

@johnson86tw
Copy link
Contributor Author

johnson86tw commented Sep 23, 2021

Hi @weijiekoh,

Thanks for the reply. Now I use Ubuntu 20.04, and successfully run buildBatchUpdateStateTreeSnark and buildQuadVoteTallySnark with maci.

It created a folder named params in maci/circuits/params. From my understanding, it's the snark-params I can use in clrfund to tally votes. But it still give me this error:

Generating proofs of message processing...

Progress: 1 / 1; batch index: 0
/bin/sh: 1: /home/johnson/clrfund-contracts/snark-params/batchUst: not found

Apparently there is no batchUst in the folder params. Do you have any thoughts...

// maci/circuits/params
❯ ls
BatchUpdateStateTreeVerifier.sol  batchUstVk.json  fr.o                       qvtPk.bin
batchUst.c                        calcwit.cpp      main.cpp                   qvt.sym
batchUstCircuit.r1cs              calcwit.hpp      QuadVoteTallyVerifier.sol  qvtVk.json
batchUst.dat                      circom.hpp       qvt.c                      utils.cpp
batchUst.params                   fr.asm           qvtCircuit.r1cs            utils.hpp
batchUstPk.json                   fr.cpp           qvt.dat
batchUst.sym                      fr.hpp           qvt.params

@weijiekoh
Copy link

Hi @chnejohnson , please try:

sudo apt-get install build-essential libgmp-dev libsodium-dev git nlohmann-json3-dev nasm g++

and run buildBatchUpdateStateTreeSnark & buildQuadVoteTallySnark again.

I'll update the readme to reflect this!

@johnson86tw
Copy link
Contributor Author

Hi @weijiekoh,

Thanks. It successfully created batchUst binary file.

But there is a new problem...any thoughts?

❯ node build/index.js genProofs \
    -x 0x856e4424f806D16E8CBC702B3c0F2ede5468eae5 \
    -sk macisk.1e67c39a50b1fdc2ac21ac46d9af3f2700ce9f4eff730ca82a71601832932fed \
    -o proofs.json \
    -t tally.json
Generating proofs of message processing...

Progress: 1 / 1; batch index: 0
Illegal instruction (core dumped)
Error: unable to compute batch update state tree witness data
Error: exec: Illegal instruction (core dumped)

    at Object.error (/home/johnson/maci/circuits/node_modules/shelljs/src/common.js:110:27)
    at execSync (/home/johnson/maci/circuits/node_modules/shelljs/src/exec.js:102:12)
    at Object._exec (/home/johnson/maci/circuits/node_modules/shelljs/src/exec.js:205:12)
    at Object.exec (/home/johnson/maci/circuits/node_modules/shelljs/src/common.js:335:23)
    at /home/johnson/maci/circuits/ts/index.ts:230:11
    at step (/home/johnson/maci/circuits/build/index.js:33:23)
    at Object.next (/home/johnson/maci/circuits/build/index.js:14:53)
    at /home/johnson/maci/circuits/build/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/johnson/maci/circuits/build/index.js:4:12)

daodesigner pushed a commit that referenced this issue Oct 28, 2021
@auryn-macmillan
Copy link
Member

Closing as this issue has gone stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants