Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(benchmarks): add benchmarks for proof generation #1082

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 79 additions & 7 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,48 @@ name: Benchmarks

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

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
Loading