diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index a317ba8d87..8d82e77c6c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [master, dev] + branches: [dev] pull_request: env: @@ -43,6 +43,11 @@ jobs: git config --global user.email "you@example.com" git config --global user.name "Your Name" + # Depending on the STATE_TREE_DEPTH param, there + # might be changes in the EmptyBallotRoots.sol file + git add contracts/contracts/trees/EmptyBallotRoots.sol + git diff --staged --quiet || git commit -m "Commit changes before publishing" + lerna version 0.0.0-ci.$(git rev-parse --short HEAD) --no-push --yes lerna publish from-git --dist-tag ci --yes env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8a0f5ec95..868c443c2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,6 +41,11 @@ jobs: - name: Publish NPM run: | + # Depending on the STATE_TREE_DEPTH param, there + # might be changes in the EmptyBallotRoots.sol file + git add contracts/contracts/trees/EmptyBallotRoots.sol + git diff --staged --quiet || git commit -m "Commit changes before publishing" + npx lerna publish from-git --yes env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/cli/.env.template b/cli/.env.template index f5cac2a5d7..92201b0244 100644 --- a/cli/.env.template +++ b/cli/.env.template @@ -2,6 +2,10 @@ ## and that none of these values are mandatory for testing ## purposes +# Ethereum provider, replace with your own +# needed if running in production against +# a test network +ETH_PROVIDER="the_eth_provider_url" # Ethereum secret key, replace with your own # needed if running in production against # a test network diff --git a/cli/hardhat.config.ts b/cli/hardhat.config.ts index cb2c85bba0..336520c8ea 100644 --- a/cli/hardhat.config.ts +++ b/cli/hardhat.config.ts @@ -1,4 +1,5 @@ import "@nomicfoundation/hardhat-toolbox"; +import { config as envConfig } from "dotenv"; import path from "path"; @@ -6,6 +7,8 @@ import type { HardhatUserConfig } from "hardhat/config"; import { DEFAULT_ETH_SK, DEFAULT_ETH_PROVIDER } from "./ts/utils/defaults"; +envConfig(); + const parentDir = __dirname.includes("build") ? ".." : ""; const config: HardhatUserConfig = { diff --git a/cli/testScript.sh b/cli/testScript.sh index 7c64431381..4cb633d4d6 100644 --- a/cli/testScript.sh +++ b/cli/testScript.sh @@ -13,7 +13,7 @@ HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js setVerifyingKeys HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js create -s 10 HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployPoll \ --pubkey macipk.ea638a3366ed91f2e955110888573861f7c0fc0bb5fb8b8dca9cd7a08d7d6b93 \ - -t 30 -g 25 -mv 25 -i 1 -m 2 -b 1 -v 2 + -t 30 -g 25 -mv 25 -i 1 -m 2 -b 1 -v 2 -d false HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js signup \ --pubkey macipk.e743ffb5298ef0f5c1f63b6464a48fea19ea7ee5a885c67ae1b24a1d04f03f07 HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \ @@ -47,7 +47,9 @@ HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js genProofs \ -w true HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js proveOnChain \ --poll-id 0 \ - --proof-dir proofs/ + --proof-dir proofs/ \ + --deploy-subsidy false HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js verify \ --poll-id 0 \ + --deploy-subsidy false \ --tally-file tally.json diff --git a/cli/tests/e2e/e2e.test.ts b/cli/tests/e2e/e2e.test.ts index af75eb5fea..64f9cc0d5f 100644 --- a/cli/tests/e2e/e2e.test.ts +++ b/cli/tests/e2e/e2e.test.ts @@ -64,6 +64,8 @@ describe("e2e tests", function test() { let maciAddresses: DeployedContracts; let pollAddresses: PollContracts; + const deploySubsidy = false; + // before all tests we deploy the vk registry contract and set the verifying keys before(async () => { // we deploy the vk registry contract @@ -86,7 +88,6 @@ describe("e2e tests", function test() { }); const user = new Keypair(); - const deploySubsidy = true; before(async () => { // deploy the smart contracts @@ -155,7 +156,6 @@ describe("e2e tests", function test() { tallyFileData, maciAddresses.maciAddress, pollAddresses.tally, - pollAddresses.subsidy, ); }); }); @@ -166,7 +166,6 @@ describe("e2e tests", function test() { }); const users = [new Keypair(), new Keypair(), new Keypair(), new Keypair()]; - const deploySubsidy = true; before(async () => { // deploy the smart contracts @@ -272,7 +271,6 @@ describe("e2e tests", function test() { tallyFileData, maciAddresses.maciAddress, pollAddresses.tally, - pollAddresses.subsidy, ); }); }); @@ -283,7 +281,6 @@ describe("e2e tests", function test() { }); const users = [new Keypair(), new Keypair(), new Keypair(), new Keypair()]; - const deploySubsidy = true; before(async () => { // deploy the smart contracts @@ -411,7 +408,6 @@ describe("e2e tests", function test() { tallyFileData, maciAddresses.maciAddress, pollAddresses.tally, - pollAddresses.subsidy, ); }); }); @@ -432,7 +428,6 @@ describe("e2e tests", function test() { new Keypair(), new Keypair(), ]; - const deploySubsidy = true; before(async () => { // deploy the smart contracts @@ -505,7 +500,6 @@ describe("e2e tests", function test() { tallyFileData, maciAddresses.maciAddress, pollAddresses.tally, - pollAddresses.subsidy, ); }); }); @@ -516,7 +510,6 @@ describe("e2e tests", function test() { }); const user = new Keypair(); - const deploySubsidy = true; before(async () => { // deploy the smart contracts @@ -591,7 +584,6 @@ describe("e2e tests", function test() { tallyFileData, maciAddresses.maciAddress, pollAddresses.tally, - pollAddresses.subsidy, ); }); }); @@ -620,7 +612,6 @@ describe("e2e tests", function test() { }); const user = new Keypair(); - const deploySubsidy = false; before(async () => { // deploy the smart contracts @@ -748,7 +739,6 @@ describe("e2e tests", function test() { ]; let secondPollAddresses: PollContracts; - const deploySubsidy = false; after(() => { cleanVanilla(); @@ -1004,7 +994,6 @@ describe("e2e tests", function test() { const stateOutPath = "./state.json"; const user = new Keypair(); - const deploySubsidy = false; after(() => { cleanVanilla(); @@ -1093,7 +1082,6 @@ describe("e2e tests", function test() { const user = new Keypair(); const tokenAmount = 100; let stateIndex: number | undefined; - const deploySubsidy = false; after(() => { cleanVanilla(); diff --git a/contracts/contracts/interfaces/IPoll.sol b/contracts/contracts/interfaces/IPoll.sol index ffc6ade5b5..6831c36527 100644 --- a/contracts/contracts/interfaces/IPoll.sol +++ b/contracts/contracts/interfaces/IPoll.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.10; -import { Params } from "../utilities/Params.sol"; import { DomainObjs } from "../utilities/DomainObjs.sol"; import { IMACI } from "./IMACI.sol"; import { AccQueue } from "../trees/AccQueue.sol"; diff --git a/contracts/contracts/interfaces/IPollFactory.sol b/contracts/contracts/interfaces/IPollFactory.sol index 7bc4737938..27822909f8 100644 --- a/contracts/contracts/interfaces/IPollFactory.sol +++ b/contracts/contracts/interfaces/IPollFactory.sol @@ -2,13 +2,9 @@ pragma solidity ^0.8.10; import { IMACI } from "./IMACI.sol"; -import { AccQueue } from "../trees/AccQueue.sol"; -import { AccQueueQuinaryMaci } from "../trees/AccQueueQuinaryMaci.sol"; import { TopupCredit } from "../TopupCredit.sol"; import { Params } from "../utilities/Params.sol"; import { DomainObjs } from "../utilities/DomainObjs.sol"; -import { VkRegistry } from "../VkRegistry.sol"; -import { Verifier } from "../crypto/Verifier.sol"; /// @title PollFactory interface interface IPollFactory { diff --git a/contracts/contracts/interfaces/IVkRegistry.sol b/contracts/contracts/interfaces/IVkRegistry.sol index 9d915c249f..5755ffe499 100644 --- a/contracts/contracts/interfaces/IVkRegistry.sol +++ b/contracts/contracts/interfaces/IVkRegistry.sol @@ -10,12 +10,14 @@ interface IVkRegistry { uint256 _intStateTreeDepth, uint256 _voteOptionTreeDepth ) external view returns (SnarkCommon.VerifyingKey memory vk); + function getProcessVk( uint256 _stateTreeDepth, uint256 _messageTreeDepth, uint256 _voteOptionTreeDepth, uint256 _messageBatchSize ) external view returns (SnarkCommon.VerifyingKey memory vk); + function getSubsidyVk( uint256 _stateTreeDepth, uint256 _intStateTreeDepth, diff --git a/contracts/ts/deploy.ts b/contracts/ts/deploy.ts index 8cd7b1e6ba..176d424a3e 100644 --- a/contracts/ts/deploy.ts +++ b/contracts/ts/deploy.ts @@ -287,38 +287,33 @@ export const deployMaci = async ( const [maciContractFactory, pollFactoryContractFactory, messageProcessorFactory, tallyFactory, subsidyFactory] = await Promise.all(linkedContractFactories); - const pollFactoryContract = await deployContractWithLinkedLibraries( - pollFactoryContractFactory, - "PollFactory", - quiet, - ); - - const messageProcessorFactoryContract = await deployContractWithLinkedLibraries( - messageProcessorFactory, - "MessageProcessorFactory", - quiet, - ); - - const tallyFactoryContract = await deployContractWithLinkedLibraries( - tallyFactory, - "TallyFactory", - quiet, - ); - - const subsidyFactoryContract = await deployContractWithLinkedLibraries( - subsidyFactory, - "SubsidyFactory", - quiet, - ); + const [pollFactoryContract, messageProcessorFactoryContract, tallyFactoryContract, subsidyFactoryContract] = + await Promise.all([ + deployContractWithLinkedLibraries(pollFactoryContractFactory, "PollFactory", quiet), + deployContractWithLinkedLibraries( + messageProcessorFactory, + "MessageProcessorFactory", + quiet, + ), + deployContractWithLinkedLibraries(tallyFactory, "TallyFactory", quiet), + deployContractWithLinkedLibraries(subsidyFactory, "SubsidyFactory", quiet), + ]); + + const [pollAddr, mpAddr, tallyAddr, subsidyAddr] = await Promise.all([ + pollFactoryContract.getAddress(), + messageProcessorFactoryContract.getAddress(), + tallyFactoryContract.getAddress(), + subsidyFactoryContract.getAddress(), + ]); const maciContract = await deployContractWithLinkedLibraries( maciContractFactory, "MACI", quiet, - await pollFactoryContract.getAddress(), - await messageProcessorFactoryContract.getAddress(), - await tallyFactoryContract.getAddress(), - await subsidyFactoryContract.getAddress(), + pollAddr, + mpAddr, + tallyAddr, + subsidyAddr, signUpTokenGatekeeperContractAddress, initialVoiceCreditBalanceAddress, topupCreditContractAddress, diff --git a/package-lock.json b/package-lock.json index 245c58a7a0..83cad6c69a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@commitlint/cli": "^18.4.4", "@commitlint/config-conventional": "^18.4.3", - "@typescript-eslint/eslint-plugin": "^6.13.1", + "@typescript-eslint/eslint-plugin": "^6.18.1", "@typescript-eslint/parser": "^6.18.1", "conventional-changelog-conventionalcommits": "^7.0.2", "cz-conventional-changelog": "^3.3.0", @@ -32,7 +32,7 @@ "lint-staged": "^15.1.0", "prettier": "^3.1.1", "prettier-plugin-solidity": "^1.3.1", - "solhint": "^4.0.0", + "solhint": "^4.1.1", "typedoc": "^0.25.4", "typedoc-plugin-markdown": "^3.17.1", "typescript": "^5.3.3" @@ -2889,16 +2889,16 @@ "dev": true }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.13.2.tgz", - "integrity": "sha512-3+9OGAWHhk4O1LlcwLBONbdXsAhLjyCFogJY/cWy2lxdVJ2JrcTF2pTGMaLl2AE7U1l31n8Py4a8bx5DLf/0dQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", + "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.13.2", - "@typescript-eslint/type-utils": "6.13.2", - "@typescript-eslint/utils": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/type-utils": "6.18.1", + "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -3051,13 +3051,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.13.2.tgz", - "integrity": "sha512-CXQA0xo7z6x13FeDYCgBkjWzNqzBn8RXaE3QVQVIUm74fWJLkJkaHmHdKStrxQllGh6Q4eUGyNpMe0b1hMkXFA==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", + "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2" + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3068,13 +3068,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.13.2.tgz", - "integrity": "sha512-Qr6ssS1GFongzH2qfnWKkAQmMUyZSyOr0W54nZNU1MDfo+U4Mv3XveeLZzadc/yq8iYhQZHYT+eoXJqnACM1tw==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", + "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.13.2", - "@typescript-eslint/utils": "6.13.2", + "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/utils": "6.18.1", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -3095,9 +3095,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.13.2.tgz", - "integrity": "sha512-7sxbQ+EMRubQc3wTfTsycgYpSujyVbI1xw+3UMRUcrhSy+pN09y/lWzeKDbvhoqcRbHdc+APLs/PWYi/cisLPg==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", + "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3108,16 +3108,17 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.13.2.tgz", - "integrity": "sha512-SuD8YLQv6WHnOEtKv8D6HZUzOub855cfPnPMKvdM/Bh1plv1f7Q/0iFUDLKKlxHcEstQnaUU4QZskgQq74t+3w==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", + "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/visitor-keys": "6.13.2", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/visitor-keys": "6.18.1", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", + "minimatch": "9.0.3", "semver": "^7.5.4", "ts-api-utils": "^1.0.1" }, @@ -3134,18 +3135,42 @@ } } }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.3.tgz", + "integrity": "sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/@typescript-eslint/utils": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.13.2.tgz", - "integrity": "sha512-b9Ptq4eAZUym4idijCRzl61oPCwwREcfDI8xGk751Vhzig5fFZR9CyzDz4Sp/nxSLBYxUPyh4QdIDqWykFhNmQ==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", + "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.13.2", - "@typescript-eslint/types": "6.13.2", - "@typescript-eslint/typescript-estree": "6.13.2", + "@typescript-eslint/scope-manager": "6.18.1", + "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/typescript-estree": "6.18.1", "semver": "^7.5.4" }, "engines": { @@ -3160,12 +3185,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.13.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.13.2.tgz", - "integrity": "sha512-OGznFs0eAQXJsp+xSd6k/O1UbFi/K/L7WjqeRoFE7vadjAF9y0uppXhYNQNEqygjou782maGClOoZwPqF0Drlw==", + "version": "6.18.1", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", + "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.13.2", + "@typescript-eslint/types": "6.18.1", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -13929,9 +13954,9 @@ } }, "node_modules/solhint": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/solhint/-/solhint-4.0.0.tgz", - "integrity": "sha512-bFViMcFvhqVd/HK3Roo7xZXX5nbujS7Bxeg5vnZc9QvH0yCWCrQ38Yrn1pbAY9tlKROc6wFr+rK1mxYgYrjZgA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/solhint/-/solhint-4.1.1.tgz", + "integrity": "sha512-7G4iF8H5hKHc0tR+/uyZesSKtfppFIMvPSW+Ku6MSL25oVRuyFeqNhOsXHfkex64wYJyXs4fe+pvhB069I19Tw==", "dev": true, "dependencies": { "@solidity-parser/parser": "^0.16.0", diff --git a/package.json b/package.json index 4a3a921da1..1f799383e4 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "devDependencies": { "@commitlint/cli": "^18.4.4", "@commitlint/config-conventional": "^18.4.3", - "@typescript-eslint/eslint-plugin": "^6.13.1", + "@typescript-eslint/eslint-plugin": "^6.18.1", "@typescript-eslint/parser": "^6.18.1", "conventional-changelog-conventionalcommits": "^7.0.2", "cz-conventional-changelog": "^3.3.0", @@ -47,7 +47,7 @@ "lint-staged": "^15.1.0", "prettier": "^3.1.1", "prettier-plugin-solidity": "^1.3.1", - "solhint": "^4.0.0", + "solhint": "^4.1.1", "typedoc": "^0.25.4", "typedoc-plugin-markdown": "^3.17.1", "typescript": "^5.3.3"