Skip to content

Commit

Permalink
chore: apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Jan 11, 2024
2 parents e510d81 + 0689040 commit 3d723b1
Show file tree
Hide file tree
Showing 12 changed files with 115 additions and 91 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI

on:
push:
branches: [master, dev]
branches: [dev]
pull_request:

env:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 4 additions & 0 deletions cli/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cli/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import "@nomicfoundation/hardhat-toolbox";
import { config as envConfig } from "dotenv";

import path from "path";

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 = {
Expand Down
6 changes: 4 additions & 2 deletions cli/testScript.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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
16 changes: 2 additions & 14 deletions cli/tests/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -86,7 +88,6 @@ describe("e2e tests", function test() {
});

const user = new Keypair();
const deploySubsidy = true;

before(async () => {
// deploy the smart contracts
Expand Down Expand Up @@ -155,7 +156,6 @@ describe("e2e tests", function test() {
tallyFileData,
maciAddresses.maciAddress,
pollAddresses.tally,
pollAddresses.subsidy,
);
});
});
Expand All @@ -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
Expand Down Expand Up @@ -272,7 +271,6 @@ describe("e2e tests", function test() {
tallyFileData,
maciAddresses.maciAddress,
pollAddresses.tally,
pollAddresses.subsidy,
);
});
});
Expand All @@ -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
Expand Down Expand Up @@ -411,7 +408,6 @@ describe("e2e tests", function test() {
tallyFileData,
maciAddresses.maciAddress,
pollAddresses.tally,
pollAddresses.subsidy,
);
});
});
Expand All @@ -432,7 +428,6 @@ describe("e2e tests", function test() {
new Keypair(),
new Keypair(),
];
const deploySubsidy = true;

before(async () => {
// deploy the smart contracts
Expand Down Expand Up @@ -505,7 +500,6 @@ describe("e2e tests", function test() {
tallyFileData,
maciAddresses.maciAddress,
pollAddresses.tally,
pollAddresses.subsidy,
);
});
});
Expand All @@ -516,7 +510,6 @@ describe("e2e tests", function test() {
});

const user = new Keypair();
const deploySubsidy = true;

before(async () => {
// deploy the smart contracts
Expand Down Expand Up @@ -591,7 +584,6 @@ describe("e2e tests", function test() {
tallyFileData,
maciAddresses.maciAddress,
pollAddresses.tally,
pollAddresses.subsidy,
);
});
});
Expand Down Expand Up @@ -620,7 +612,6 @@ describe("e2e tests", function test() {
});

const user = new Keypair();
const deploySubsidy = false;

before(async () => {
// deploy the smart contracts
Expand Down Expand Up @@ -748,7 +739,6 @@ describe("e2e tests", function test() {
];

let secondPollAddresses: PollContracts;
const deploySubsidy = false;

after(() => {
cleanVanilla();
Expand Down Expand Up @@ -1004,7 +994,6 @@ describe("e2e tests", function test() {
const stateOutPath = "./state.json";

const user = new Keypair();
const deploySubsidy = false;

after(() => {
cleanVanilla();
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion contracts/contracts/interfaces/IPoll.sol
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
4 changes: 0 additions & 4 deletions contracts/contracts/interfaces/IPollFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions contracts/contracts/interfaces/IVkRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
49 changes: 22 additions & 27 deletions contracts/ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,38 +287,33 @@ export const deployMaci = async (
const [maciContractFactory, pollFactoryContractFactory, messageProcessorFactory, tallyFactory, subsidyFactory] =
await Promise.all(linkedContractFactories);

const pollFactoryContract = await deployContractWithLinkedLibraries<PollFactory>(
pollFactoryContractFactory,
"PollFactory",
quiet,
);

const messageProcessorFactoryContract = await deployContractWithLinkedLibraries<MessageProcessorFactory>(
messageProcessorFactory,
"MessageProcessorFactory",
quiet,
);

const tallyFactoryContract = await deployContractWithLinkedLibraries<TallyFactory>(
tallyFactory,
"TallyFactory",
quiet,
);

const subsidyFactoryContract = await deployContractWithLinkedLibraries<SubsidyFactory>(
subsidyFactory,
"SubsidyFactory",
quiet,
);
const [pollFactoryContract, messageProcessorFactoryContract, tallyFactoryContract, subsidyFactoryContract] =
await Promise.all([
deployContractWithLinkedLibraries<PollFactory>(pollFactoryContractFactory, "PollFactory", quiet),
deployContractWithLinkedLibraries<MessageProcessorFactory>(
messageProcessorFactory,
"MessageProcessorFactory",
quiet,
),
deployContractWithLinkedLibraries<TallyFactory>(tallyFactory, "TallyFactory", quiet),
deployContractWithLinkedLibraries<SubsidyFactory>(subsidyFactory, "SubsidyFactory", quiet),
]);

const [pollAddr, mpAddr, tallyAddr, subsidyAddr] = await Promise.all([
pollFactoryContract.getAddress(),
messageProcessorFactoryContract.getAddress(),
tallyFactoryContract.getAddress(),
subsidyFactoryContract.getAddress(),
]);

const maciContract = await deployContractWithLinkedLibraries<MACI>(
maciContractFactory,
"MACI",
quiet,
await pollFactoryContract.getAddress(),
await messageProcessorFactoryContract.getAddress(),
await tallyFactoryContract.getAddress(),
await subsidyFactoryContract.getAddress(),
pollAddr,
mpAddr,
tallyAddr,
subsidyAddr,
signUpTokenGatekeeperContractAddress,
initialVoiceCreditBalanceAddress,
topupCreditContractAddress,
Expand Down
Loading

0 comments on commit 3d723b1

Please sign in to comment.