Skip to content

Commit

Permalink
test(stress): add stress test with ceremony params
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 committed Jan 14, 2024
1 parent 1f72f6c commit d16acbd
Show file tree
Hide file tree
Showing 10 changed files with 527 additions and 89 deletions.
74 changes: 0 additions & 74 deletions .github/scripts/ceremony-param-tests-c-witness.sh

This file was deleted.

70 changes: 64 additions & 6 deletions .github/workflows/nightly-ceremony.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,54 @@
name: Nightly Ceremony

on:
schedule:
- cron: 0 0 * * *
push:
branches:
- test/stress-test

env:
STATE_TREE_DEPTH: ${{ vars.STATE_TREE_DEPTH }}

jobs:
start-runner:
name: Start self-hosted EC2 runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ami-04950f0be945cc4c7
ec2-instance-type: t3.2xlarge
subnet-id: subnet-0817be1b2160793b5
security-group-id: sg-0aea3cbb15e30a921
aws-resource-tags: >
[
{ "Key": "Name", "Value": "maci-github-runner" },
{ "Key": "GitHubRepository", "Value": "${{ github.repository }}" }
]
test-with-ceremony-keys:
runs-on: ubuntu-22.04
# required to start the main job when the runner is ready
needs: start-runner
# run the job on the newly created runner
runs-on: ${{ needs.start-runner.outputs.label }}

steps:
- uses: actions/checkout@v4
with:
ref: dev
ref: test/stress-test
- uses: pnpm/action-setup@v2
with:
version: latest
Expand Down Expand Up @@ -57,9 +91,33 @@ jobs:
- 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: Run stress tests
run: pnpm run test:stress

- name: Stop Hardhat
if: always()
run: kill $(lsof -t -i:8545)

stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- test-with-ceremony-keys # required to wait when the main job is done
runs-on: ubuntu-latest
# required to stop the runner even if the error happened in the previous jobs
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
1 change: 1 addition & 0 deletions .github/workflows/reusable-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
matrix:
command: ["test:cli", "test:integration"]

timeout-minutes: 240
runs-on: ubuntu-22.04

steps:
Expand Down
2 changes: 1 addition & 1 deletion circuits/scripts/build_intel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ do
make

cd "$CWD"
done
done
11 changes: 6 additions & 5 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@
"build": "tsc -p tsconfig.build.json",
"postbuild": "cp package.json ./build",
"types": "tsc -p tsconfig.json --noEmit",
"test": "nyc ts-mocha --exit tests/**/*.test.ts",
"test:e2e": "ts-mocha --exit tests/e2e/e2e.test.ts",
"test:e2e-subsidy": "ts-mocha --exit tests/e2e/e2e.subsidy.test.ts",
"test:keyChange": "ts-mocha --exit tests/e2e/keyChange.test.ts",
"test": "nyc ts-mocha --exit tests/e2e/*.test.ts tests/unit/*.test.ts",
"test:e2e": "ts-mocha --exit tests/e2e.test.ts",
"test:e2e-subsidy": "ts-mocha --exit tests/e2e.subsidy.test.ts",
"test:keyChange": "ts-mocha --exit tests/keyChange.test.ts",
"test:unit": "nyc ts-mocha --exit tests/unit/*.test.ts",
"test:airdrop": "nyc ts-mocha --exit tests/unit/airdrop.test.ts",
"test:genPubKey": "ts-mocha --exit tests/unit/genPubKey.test.ts",
"test:genKeypair": "ts-mocha --exit tests/unit/genKeyPair.test.ts",
"test:timeTravel": "ts-mocha --exit tests/unit/timeTravel.test.ts",
"test:fundWallet": "ts-mocha --exit tests/unit/fundWallet.test.ts",
"test:utils": "ts-mocha --exit tests/unit/utils.test.ts"
"test:utils": "ts-mocha --exit tests/unit/utils.test.ts",
"test:stress": "ts-mocha --exit tests/stress/*.test.ts"
},
"dependencies": {
"@commander-js/extra-typings": "^11.1.0",
Expand Down
17 changes: 14 additions & 3 deletions cli/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ import { Keypair } from "maci-domainobjs";

import { homedir } from "os";

// config params
export const STATE_TREE_DEPTH = 10;
export const INT_STATE_TREE_DEPTH = 1;
export const MSG_TREE_DEPTH = 2;
export const VOTE_OPTION_TREE_DEPTH = 2;
export const MSG_BATCH_DEPTH = 1;
export const pollDuration = 90;
export const maxMessages = 25;
export const maxVoteOptions = 25;

// coordinator keypair
const coordinatorKeypair = new Keypair();
export const coordinatorPubKey = coordinatorKeypair.pubKey.serialize();
export const coordinatorPrivKey = coordinatorKeypair.privKey.serialize();

// local paths to zkeys, wasm, and witnesses
export const processMessageTestZkeyPath = "./zkeys/ProcessMessages_10-2-1-2_test.0.zkey";
export const tallyVotesTestZkeyPath = "./zkeys/TallyVotes_10-1-2_test.0.zkey";
export const subsidyTestZkeyPath = "./zkeys/SubsidyPerBatch_10-1-2_test.0.zkey";
Expand All @@ -24,6 +32,9 @@ export const testProcessMessagesWasmPath =
export const testTallyVotesWasmPath = "./zkeys/TallyVotes_10-1-2_test_js/TallyVotes_10-1-2_test.wasm";
export const testSubsidyWasmPath = "./zkeys/SubsidyPerBatch_10-1-2_test_js/SubsidyPerBatch_10-1-2_test.wasm";
export const testRapidsnarkPath = `${homedir()}/rapidsnark/build/prover`;
export const pollDuration = 90;
export const maxMessages = 25;
export const maxVoteOptions = 25;
export const ceremonyProcessMessageZkeyPath = "./zkeys/processMessages_6-8-2-3.zkey";
export const ceremonyTallyVotesZkeyPath = "./zkeys/tallyVotes_6-2-3.zkey";
export const cermeonyProcessMessagesWitnessPath = "./zkeys/processMessages_6-8-2-3";
export const ceremonyTallyVotesWitnessPath = "./zkeys/tallyVotes_6-2-3";
export const ceremonyProcessMessagesWasmPath = "./zkeys/processMessages_6-8-2-3.wasm";
export const ceremonyTallyVotesWasmPath = "./zkeys/tallyVotes_6-2-3.wasm";
Loading

0 comments on commit d16acbd

Please sign in to comment.