Skip to content

Commit

Permalink
test(benchmarks): add benchmarks for process messages proof gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 committed Jan 22, 2024
1 parent 24c0bd4 commit fed3612
Show file tree
Hide file tree
Showing 12 changed files with 548 additions and 165 deletions.
88 changes: 80 additions & 8 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
name: Benchmarks
name: Nightly Ceremony

on:
push:
branches: [dev]
pull_request:
branches:
- test/stress-test

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
STATE_TREE_DEPTH: ${{ vars.STATE_TREE_DEPTH }}

jobs:
build:
runs-on: ubuntu-22.04
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 }}" }
]
benchmarks:
# 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
Expand All @@ -33,5 +65,45 @@ jobs:
run: |
pnpm build
- 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 circom Binary v2.1.6
run: |
wget -qO ${{ github.workspace }}/circom https://github.com/iden3/circom/releases/download/v2.1.6/circom-linux-amd64
chmod +x ${{ github.workspace }}/circom
sudo mv ${{ github.workspace }}/circom /bin/circom
- name: Download zkeys
run: |
pnpm download:test-zkeys
- name: Benchmarks
run: pnpm benchmarks

stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- benchmarks # 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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ publish
# typedoc
docs/typedoc/*

**/ts/__benchmarks__/results/**
**/ts/__benchmarks__/results
4 changes: 4 additions & 0 deletions circuits/ts/proofs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const genProof = async ({
}

const { proof, publicSignals } = await groth16.fullProve(inputs, wasmPath, zkeyPath);

// ensure we clean up all threads spawned by snarkjs
await cleanThreads();

return { proof, publicSignals };
}

Expand Down
2 changes: 1 addition & 1 deletion cli/tests/e2e/e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ describe("e2e tests", function test() {
});
});

describe("5 signups, 1 message", () => {
describe("9 signups, 1 message", () => {
after(() => {
cleanVanilla();
});
Expand Down
2 changes: 1 addition & 1 deletion integrationTests/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
!ts/__tests__/data/
cache
cache
5 changes: 4 additions & 1 deletion integrationTests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"scripts": {
"watch": "tsc --watch",
"build": "tsc",
"benchmarks": "ts-node ts/__benchmarks__/benchmarks.ts",
"types": "tsc -p tsconfig.json --noEmit",
"test": "ts-mocha --exit ./ts/__tests__/**.test.ts",
"test:integration": "NODE_OPTIONS=--max-old-space-size=4096 ts-mocha --exit ./ts/__tests__/integration.test.ts",
Expand All @@ -22,13 +23,15 @@
"@types/chai-as-promised": "^7.1.8",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.5",
"benny": "^3.7.1",
"chai": "^4.3.10",
"chai-as-promised": "^7.1.1",
"hardhat": "^2.19.2",
"hardhat-artifactor": "^0.2.0",
"hardhat-contract-sizer": "^2.0.3",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0"
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1"
},
"dependencies": {
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
Expand Down
Loading

0 comments on commit fed3612

Please sign in to comment.