johnson86tw / maci

Minimal anti collusion infrastructure
https://appliedzkp.github.io/maci/
Other
0 stars 1 forks source link

Failed to generate proofs #7

Closed johnson86tw closed 2 years ago

johnson86tw commented 2 years ago

Run cli/test.sh

Error:

...
All state subtrees have been merged.
Merging subroots to a main state root...
Executed mergeStateAq(); gas used: 1015876
Transaction hash: 0xf9346a01dcafa30da9aecf57303660706bdc5995d86587be7ceaf24a948ea358
The state tree has been merged.

fromBlock = 0
Generating proofs of message processing...
(node:2707) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'copy' of undefined
    at Poll.processMessages (/root/maci/core/ts/MaciState.ts:358:58)
    at /root/maci/cli/ts/genProofs.ts:335:36
    at step (/root/maci/cli/build/genProofs.js:33:23)
    at Object.next (/root/maci/cli/build/genProofs.js:14:53)
    at fulfilled (/root/maci/cli/build/genProofs.js:5:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2707) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2707) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The problem is in maci/core/ts/MaciState.ts:

...
  if (r) {
                // TODO: replace with try/catch after implementing error
                // handling
                const index = r.stateLeafIndex

                currentStateLeaves.unshift(r.originalStateLeaf)
                currentBallots.unshift(r.originalBallot)
                currentVoteWeights.unshift(r.originalVoteWeight)
                currentVoteWeightsPathElements.unshift(r.originalVoteWeightsPathElements)

                currentStateLeavesPathElements.unshift(r.originalStateLeafPathElements)
                currentBallotsPathElements.unshift(r.originalBallotPathElements)

                this.stateLeaves[index] = r.newStateLeaf.copy()      // Error: r.newStateLeaf is undefined
                this.stateTree.update(index, r.newStateLeaf.hash())

                this.ballots[index] = r.newBallot
                this.ballotTree.update(index, r.newBallot.hash())

            } else {
...
johnson86tw commented 2 years ago

appliedzkp#375 fixed.