diff --git a/contracts/sh/runScriptTests.sh b/contracts/sh/runScriptTests.sh index f03a47bf9..b17de7b2f 100755 --- a/contracts/sh/runScriptTests.sh +++ b/contracts/sh/runScriptTests.sh @@ -33,13 +33,15 @@ yarn hardhat contribute --network ${HARDHAT_NETWORK} yarn hardhat time-travel --seconds ${ROUND_DURATION} --network ${HARDHAT_NETWORK} -# run the tally script +# tally the votes NODE_OPTIONS="--max-old-space-size=4096" -yarn hardhat tally \ +yarn hardhat gen-proofs \ --rapidsnark ${RAPID_SNARK} \ - --batch-size 8 \ - --output-dir ${OUTPUT_DIR} \ + --proof-dir ${OUTPUT_DIR} \ + --maci-start-block 0 \ --network "${HARDHAT_NETWORK}" +yarn hardhat prove-on-chain --proof-dir ${OUTPUT_DIR} --network "${HARDHAT_NETWORK}" +yarn hardhat publish-tally-results --proof-dir ${OUTPUT_DIR} --network "${HARDHAT_NETWORK}" # finalize the round yarn hardhat finalize --tally-file ${TALLY_FILE} --network ${HARDHAT_NETWORK} diff --git a/contracts/tasks/runners/genProofs.ts b/contracts/tasks/runners/genProofs.ts index 55c9d5521..c9da580f3 100644 --- a/contracts/tasks/runners/genProofs.ts +++ b/contracts/tasks/runners/genProofs.ts @@ -15,7 +15,7 @@ * * Sample usage: * - * yarn hardhat tally --clrfund --proof-dir \ + * yarn hardhat gen-proofs --clrfund --proof-dir \ * --maci-tx-hash --network * */ @@ -36,9 +36,10 @@ import { getMaciStateFilePath } from '../../utils/misc' import { EContracts } from '../../utils/types' import { Subtask } from '../helpers/Subtask' import { getCurrentFundingRoundContract } from '../../utils/contracts' +import { ContractStorage } from '../helpers/ContractStorage' task('gen-proofs', 'Generate MACI proofs offchain') - .addParam('clrfund', 'FundingRound contract address') + .addOptionalParam('clrfund', 'FundingRound contract address') .addParam('proofDir', 'The proof output directory') .addOptionalParam('maciTxHash', 'MACI creation transaction hash') .addOptionalParam( @@ -89,6 +90,7 @@ task('gen-proofs', 'Generate MACI proofs offchain') console.log('Verbose logging enabled:', !quiet) const { ethers, network } = hre + const storage = ContractStorage.getInstance() const subtask = Subtask.getInstance(hre) subtask.setHre(hre) @@ -121,8 +123,10 @@ task('gen-proofs', 'Generate MACI proofs offchain') await subtask.logStart() + const clrfundContractAddress = + clrfund ?? storage.mustGetAddress(EContracts.ClrFund, network.name) const fundingRoundContract = await getCurrentFundingRoundContract( - clrfund, + clrfundContractAddress, coordinator, ethers ) diff --git a/contracts/tasks/runners/proveOnChain.ts b/contracts/tasks/runners/proveOnChain.ts index b1eb499de..af777ed12 100644 --- a/contracts/tasks/runners/proveOnChain.ts +++ b/contracts/tasks/runners/proveOnChain.ts @@ -19,6 +19,7 @@ import { HardhatEthersHelpers } from '@nomicfoundation/hardhat-ethers/types' import { EContracts } from '../../utils/types' import { Subtask } from '../helpers/Subtask' import { getCurrentFundingRoundContract } from '../../utils/contracts' +import { ContractStorage } from '../helpers/ContractStorage' /** * Get the message processor contract address from the tally contract @@ -40,7 +41,7 @@ async function getMessageProcessorAddress( } task('prove-on-chain', 'Prove on chain with the MACI proofs') - .addParam('clrfund', 'ClrFund contract address') + .addOptionalParam('clrfund', 'ClrFund contract address') .addParam('proofDir', 'The proof output directory') .addFlag('manageNonce', 'Whether to manually manage transaction nonce') .addOptionalParam( @@ -52,7 +53,8 @@ task('prove-on-chain', 'Prove on chain with the MACI proofs') .setAction(async ({ clrfund, quiet, manageNonce, proofDir }, hre) => { console.log('Verbose logging enabled:', !quiet) - const { ethers } = hre + const { ethers, network } = hre + const storage = ContractStorage.getInstance() const subtask = Subtask.getInstance(hre) subtask.setHre(hre) @@ -67,8 +69,10 @@ task('prove-on-chain', 'Prove on chain with the MACI proofs') await subtask.logStart() + const clrfundContractAddress = + clrfund ?? storage.mustGetAddress(EContracts.ClrFund, network.name) const fundingRoundContract = await getCurrentFundingRoundContract( - clrfund, + clrfundContractAddress, coordinator, ethers ) diff --git a/contracts/tasks/runners/publishTallyResults.ts b/contracts/tasks/runners/publishTallyResults.ts index 46f535f8b..d2fef14f1 100644 --- a/contracts/tasks/runners/publishTallyResults.ts +++ b/contracts/tasks/runners/publishTallyResults.ts @@ -24,6 +24,7 @@ import { EContracts } from '../../utils/types' import { Subtask } from '../helpers/Subtask' import { getCurrentFundingRoundContract } from '../../utils/contracts' import { getTalyFilePath } from '../../utils/misc' +import { ContractStorage } from '../helpers/ContractStorage' /** * Publish the tally IPFS hash on chain if it's not already published @@ -94,7 +95,7 @@ async function getRecipientTreeDepth( } task('publish-tally-results', 'Publish tally results') - .addParam('clrfund', 'ClrFund contract address') + .addOptionalParam('clrfund', 'ClrFund contract address') .addParam('proofDir', 'The proof output directory') .addOptionalParam( 'batchSize', @@ -106,7 +107,8 @@ task('publish-tally-results', 'Publish tally results') .addFlag('quiet', 'Whether to log on the console') .setAction( async ({ clrfund, proofDir, batchSize, manageNonce, quiet }, hre) => { - const { ethers } = hre + const { ethers, network } = hre + const storage = ContractStorage.getInstance() const subtask = Subtask.getInstance(hre) subtask.setHre(hre) @@ -119,8 +121,10 @@ task('publish-tally-results', 'Publish tally results') await subtask.logStart() + const clrfundContractAddress = + clrfund ?? storage.mustGetAddress(EContracts.ClrFund, network.name) const fundingRoundContract = await getCurrentFundingRoundContract( - clrfund, + clrfundContractAddress, coordinator, ethers )