Skip to content

Commit

Permalink
fix rapidsnark path
Browse files Browse the repository at this point in the history
  • Loading branch information
yuetloo committed Nov 27, 2023
1 parent 7e56fd6 commit c11fdca
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 36 deletions.
5 changes: 2 additions & 3 deletions contracts/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ const roundDuration = 7 * 86400
// MACI zkFiles
const circuit = process.env.CIRCUIT_TYPE || DEFAULT_CIRCUIT
const circuitDirectory = process.env.CIRCUIT_DIRECTORY || '../../params'
const rapidSnarkDirectory =
process.env.RAPID_SNARK || '~/rapidsnark/package/bin/prover'
const rapidSnark = process.env.RAPID_SNARK || '~/rapidsnark/package/bin/prover'
const proofOutputDirectory = process.env.PROOF_OUTPUT_DIR || './proof_output'
const tallyBatchSize = Number(process.env.TALLY_BATCH_SIZE || 8)

Expand Down Expand Up @@ -332,7 +331,7 @@ describe('End-to-end Tests', function () {
pollId: pollId.toString(),
coordinatorMacisk: coordinatorKeypair.privKey.serialize(),
maciTxHash: maciTransactionHash,
rapidSnarkDirectory,
rapidSnark,
circuitType: circuit,
circuitDirectory,
outputDir,
Expand Down
77 changes: 44 additions & 33 deletions contracts/utils/maci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
proveOnChain,
} from '@clrfund/maci-cli'

import { getTalyFilePath } from './misc'
import { getTalyFilePath, isPathExist } from './misc'
import { CIRCUITS } from './circuits'
import path from 'path'

Expand Down Expand Up @@ -238,6 +238,7 @@ export function getGenProofArgs(
rapidSnark,
outputDir,
} = args

const tallyFile = getTalyFilePath(outputDir)
const maciStateFile = path.join(outputDir, `macistate`)

Expand All @@ -253,38 +254,48 @@ export function getGenProofArgs(
// do not cleanup threads after calling genProofs,
// the script will exit and end threads at the end
const cleanup = false
return isOsArm
? {
contract: maciAddress,
eth_provider: providerUrl,
poll_id: pollId.toString(),
tally_file: tallyFile,
process_wasm: processWasm,
process_zkey: processZkFile,
tally_zkey: tallyZkFile,
tally_wasm: tallyWasm,
transaction_hash: maciTxHash,
output: outputDir,
privkey: coordinatorMacisk,
macistate: maciStateFile,
cleanup,
}
: {
contract: maciAddress,
eth_provider: providerUrl,
poll_id: pollId.toString(),
tally_file: tallyFile,
rapidsnark: rapidSnark,
process_witnessgen: processWitness,
tally_witnessgen: tallyWitness,
process_zkey: processZkFile,
tally_zkey: tallyZkFile,
transaction_hash: maciTxHash,
output: outputDir,
privkey: coordinatorMacisk,
macistate: maciStateFile,
cleanup,
}
if (isOsArm) {
return {
contract: maciAddress,
eth_provider: providerUrl,
poll_id: pollId.toString(),
tally_file: tallyFile,
process_wasm: processWasm,
process_zkey: processZkFile,
tally_zkey: tallyZkFile,
tally_wasm: tallyWasm,
transaction_hash: maciTxHash,
output: outputDir,
privkey: coordinatorMacisk,
macistate: maciStateFile,
cleanup,
}
} else {
if (!rapidSnark) {
throw new Error('Please specify the path to the rapidsnark binary')
}

if (!isPathExist(rapidSnark)) {
throw new Error(`Path ${rapidSnark} does not exist`)
}

return {
contract: maciAddress,
eth_provider: providerUrl,
poll_id: pollId.toString(),
tally_file: tallyFile,
rapidsnark: rapidSnark,
process_witnessgen: processWitness,
tally_witnessgen: tallyWitness,
process_zkey: processZkFile,
tally_zkey: tallyZkFile,
transaction_hash: maciTxHash,
output: outputDir,
privkey: coordinatorMacisk,
macistate: maciStateFile,
cleanup,
}
}
}

/**
Expand Down

0 comments on commit c11fdca

Please sign in to comment.