Skip to content

Commit

Permalink
Merge branch 'feat/add-roadmap-blogpost' of https://github.com/privac…
Browse files Browse the repository at this point in the history
…y-scaling-explorations/maci into feat/add-roadmap-blogpost
  • Loading branch information
samajammin committed Jan 10, 2024
2 parents 325192d + 0460554 commit e89709c
Show file tree
Hide file tree
Showing 231 changed files with 16,782 additions and 7,390 deletions.
115 changes: 99 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,107 @@
const fs = require("fs");
const path = require("path");

const prettierConfig = fs.readFileSync(path.resolve(__dirname, "./.prettierrc"), "utf8");
const prettierOptions = JSON.parse(prettierConfig);
const isProduction = process.env.NODE_ENV === "production";

module.exports = {
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
root: true,
extends: [
"eslint:recommended",
"airbnb",
"prettier",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:@typescript-eslint/strict",
"plugin:@typescript-eslint/strict-type-checked",
"plugin:@typescript-eslint/stylistic",
"plugin:@typescript-eslint/stylistic-type-checked",
"plugin:import/typescript",
],
plugins: ["json", "prettier", "unused-imports", "import", "@typescript-eslint"],
parser: "@typescript-eslint/parser",
env: {
node: true,
mocha: true,
es2022: true,
},
settings: {
react: {
version: "999.999.999",
},
"import/resolver": {
typescript: {},
node: {
extensions: [".ts", ".js"],
moduleDirectory: ["node_modules", "ts", "src"],
},
},
},
parserOptions: {
project: path.resolve(__dirname, "./tsconfig.json"),
sourceType: "module",
typescript: true,
ecmaVersion: 2022,
experimentalDecorators: true,
requireConfigFile: false,
ecmaFeatures: {
classes: true,
impliedStrict: true,
},
warnOnUnsupportedTypeScriptVersion: true,
},
reportUnusedDisableDirectives: isProduction,
rules: {
"no-console": "off",
"no-debugger": "off",
"no-prototype-builtins": "off",
"no-constant-condition": ["error", { checkLoops: false }],
"no-empty": ["error", { allowEmptyCatch: true }],
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/ban-ts-ignore": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/camelcase": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"import/no-cycle": ["error"],
"unused-imports/no-unused-imports": "error",
"import/no-extraneous-dependencies": [
"error",
{
devDependencies: ["**/*.test.ts"],
},
],
"no-debugger": isProduction ? "error" : "off",
"no-console": "error",
"no-underscore-dangle": "error",
"no-redeclare": ["error", { builtinGlobals: true }],
"import/order": [
"error",
{
groups: ["external", "builtin", "internal", "type", "parent", "sibling", "index", "object"],
alphabetize: {
order: "asc",
caseInsensitive: true,
},
warnOnUnassignedImports: true,
"newlines-between": "always",
},
],
"prettier/prettier": ["error", prettierOptions],
"import/prefer-default-export": "off",
"import/extensions": ["error", { json: "always" }],
"class-methods-use-this": "off",
"prefer-promise-reject-errors": "off",
"max-classes-per-file": "off",
"no-use-before-define": ["off"],
"no-shadow": "off",
curly: ["error", "all"],

"@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/prefer-nullish-coalescing": "off",
"@typescript-eslint/no-floating-promises": "off",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/explicit-module-boundary-types": "error",
"@typescript-eslint/no-use-before-define": ["error", { functions: false, classes: false }],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
"@typescript-eslint/no-shadow": [
"error",
{
builtinGlobals: true,
allow: ["location", "event", "history", "name", "status", "Option", "test", "expect"],
},
],
},
};
71 changes: 71 additions & 0 deletions .github/scripts/ceremony-param-tests-c-witness.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -e

cd "$(dirname "$0")"
cd ../../cli

HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployVkRegistry -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js setVerifyingKeys \
--state-tree-depth 6 \
--int-state-tree-depth 2 \
--msg-tree-depth 8 \
--vote-option-tree-depth 3 \
--msg-batch-depth 2 \
--process-messages-zkey ./zkeys/processMessages_6-8-2-3.zkey \
--tally-votes-zkey ./zkeys/tallyVotes_6-2-3.zkey \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js create -s 6 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js deployPoll \
-pk macipk.ea638a3366ed91f2e955110888573861f7c0fc0bb5fb8b8dca9cd7a08d7d6b93 \
--duration 30 \
--max-messages 390625 \
--max-vote-options 125 \
--int-state-tree-depth 2 \
--msg-tree-depth 8 \
--msg-batch-depth 2 \
--vote-option-tree-depth 3 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js signup \
--pubkey macipk.e743ffb5298ef0f5c1f63b6464a48fea19ea7ee5a885c67ae1b24a1d04f03f07 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \
--pubkey macipk.e743ffb5298ef0f5c1f63b6464a48fea19ea7ee5a885c67ae1b24a1d04f03f07 \
--privkey macisk.0ab0281365e01cff60afc62310daec765e590487bf989a7c4986ebc3fd49895e \
--state-index 1 \
--vote-option-index 0 \
--new-vote-weight 9 \
--nonce 1 \
--poll-id 0 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js publish \
--pubkey macipk.e743ffb5298ef0f5c1f63b6464a48fea19ea7ee5a885c67ae1b24a1d04f03f07 \
--privkey macisk.0ab0281365e01cff60afc62310daec765e590487bf989a7c4986ebc3fd49895e \
--state-index 1 \
--vote-option-index 1 \
--new-vote-weight 9 \
--nonce 2 \
--poll-id 0 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js timeTravel -s 100 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeSignups --poll-id 0 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js mergeMessages --poll-id 0 -q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js genProofs \
--privkey macisk.1751146b59d32e3c0d7426de411218172428263f93b2fc4d981c036047a4d8c0 \
--poll-id 0 \
--rapidsnark ~/rapidsnark/build/prover \
--process-zkey ./zkeys/processMessages_6-8-2-3.zkey \
--tally-zkey ./zkeys/tallyVotes_6-2-3.zkey \
--tally-file tally.json \
--output proofs/ \
--tally-witnessgen ./zkeys/tallyVotes_6-2-3 \
--process-witnessgen ./zkeys/processMessages_6-8-2-3 \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js proveOnChain \
--poll-id 0 \
--proof-dir proofs/ \
-q true
HARDHAT_CONFIG=./build/hardhat.config.js node build/ts/index.js verify \
--poll-id 0 \
--tally-file tally.json \
-q true
15 changes: 15 additions & 0 deletions .github/scripts/download-ceremony-artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -e

cd "$(dirname "$0")"
cd ..
mkdir -p ../cli/zkeys

URL=https://maci-develop-fra.s3.eu-central-1.amazonaws.com/v1.2.0/maci-ceremony-artifacts-v1.2.0.tar.gz
DIR_NAME="maci_keys.tar.gz"
OUT_DIR=../cli/

echo "downloading $URL"
curl $URL -o "$OUT_DIR/$DIR_NAME"
tar -xvf "$OUT_DIR/$DIR_NAME" -C "$OUT_DIR"
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
command: ["prettier", "lint:ts"]
command: ["prettier", "types", "lint:ts", "lint:sol"]

runs-on: ubuntu-22.04

Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/nightly-ceremony.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Nightly Ceremony

on:
schedule:
- cron: 0 0 * * *

jobs:
test-with-ceremony-keys:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
with:
ref: dev

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes \
build-essential \
libgmp-dev \
libsodium-dev \
nasm \
nlohmann-json3-dev
- name: Initialize Project
run: |
npm install
npm run bootstrap
npm run build
- name: Compile contracts with ceremony params and run hardhat fork
run: |
cd contracts
npm run compileSol 6
npm run hardhat &
- name: Download rapidsnark (1c137)
run: |
mkdir -p ~/rapidsnark/build
wget -qO ~/rapidsnark/build/prover https://maci-devops-zkeys.s3.ap-northeast-2.amazonaws.com/rapidsnark-linux-amd64-1c137
chmod +x ~/rapidsnark/build/prover
- name: Download ceremony artifacts
run: ./.github/scripts/download-ceremony-artifacts.sh

- name: Run e2e tests
run: ./.github/scripts/ceremony-param-tests-c-witness.sh

- name: Stop Hardhat
run: kill $(lsof -t -i:8545)
1 change: 1 addition & 0 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ jobs:
run: npm run ${{ matrix.command }}

- name: Stop Hardhat
if: always()
run: kill $(lsof -t -i:8545)
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
npx lint-staged && npm run types
1 change: 1 addition & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"**/*.{ts,js}": ["prettier --ignore-unknown --write", "eslint --fix"],
"**/*.sol": ["prettier --ignore-unknown --write", "solhint --fix --noPrompt"],
"*": ["prettier --ignore-unknown --write"]
}
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"avoid-suicide": "error",
"avoid-sha3": "warn",
"max-line-length": ["warn", 120],
"quotes": ["error", "single"],
"quotes": ["error", "double"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"state-visibility": "error"
}
Expand Down
20 changes: 20 additions & 0 deletions circuits/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const path = require("path");

module.exports = {
root: true,
extends: ["../.eslintrc.js"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: path.resolve(__dirname, "./tsconfig.json"),
sourceType: "module",
typescript: true,
ecmaVersion: 2022,
experimentalDecorators: true,
requireConfigFile: false,
ecmaFeatures: {
classes: true,
impliedStrict: true,
},
warnOnUnsupportedTypeScriptVersion: true,
},
};
10 changes: 10 additions & 0 deletions circuits/circom/test/ceremonyParams/processMessages_test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pragma circom 2.0.0;
include "../../processMessages.circom";
/*
stateTreeDepth,
msgTreeDepth,
msgSubTreeDepth
voteOptionTreeDepth,
*/

component main {public [inputHash]} = ProcessMessages(6, 8, 2, 3);
7 changes: 7 additions & 0 deletions circuits/circom/test/ceremonyParams/tallyVotes_test.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pragma circom 2.0.0;
include "../../tallyVotes.circom";

component main {public [inputHash]} = TallyVotes(6, 2, 3);
/*stateTreeDepth,*/
/*intStateTreeDepth,*/
/*voteOptionTreeDepth*/
Loading

0 comments on commit e89709c

Please sign in to comment.