Skip to content

Commit

Permalink
Merge pull request #16 from privacy-scaling-explorations:ci/e2e
Browse files Browse the repository at this point in the history
Add nightly run
  • Loading branch information
baumstern authored Jun 29, 2023
2 parents 17366f3 + 527b2e8 commit 99f3010
Show file tree
Hide file tree
Showing 5 changed files with 1,297 additions and 7 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
name: Nightly

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

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-0d65ed0872506990c
ec2-instance-type: t3.2xlarge
subnet-id: subnet-0817be1b2160793b5
security-group-id: sg-0aea3cbb15e30a921
aws-resource-tags: >
[
{ "Key": "Name", "Value": "maci-coordinator-github-runner" },
{ "Key": "GitHubRepository", "Value": "${{ github.repository }}" }
]
do-the-job:
name: Do the job on the runner
needs: start-runner
runs-on: ${{ needs.start-runner.outputs.label }}

steps:

- name: Install Docker
run: |
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# maci-coordinator will listen on port 8080 locally
- name: Run maci-coordinator
run: |
sudo docker run --detach --platform linux/amd64 -p 8080:8080 ghcr.io/privacy-scaling-explorations/maci-coordinator:main
# Run `maci-coordinator` flavored e2e test suite of MACI
- name: Checkout code
uses: actions/checkout@v3
with:
repository: 'gurrpi/maci'
ref: 'maci-coordinator'
path: 'maci'

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Build MACI
run: |
cd maci
npm install
npm run bootstrap
npm run build
cd contracts
npm run compileSol
- name: Run local hardhat node
run: |
cd maci
bash ./.github/scripts/hnctl.sh start_hardhat_network
- name: Run E2E Test Suite
run: |
cd maci/cli
bash test_coordinator-service.sh
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner
- do-the-job
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ coverage/**
instruments
data/zkeys/**
*.wtns
outputs/**

.DS_Store
26 changes: 19 additions & 7 deletions demo/cli_demo.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
### api/genproof
### /api/generateProof

Send a POST request to the `/api/generateProof` endpoint with a JSON body containing the cicuit input of the desired circuit:

ProcessMessages:
```
curl \
-X POST \
-H "Content-Type: application/json" \
-d @demo/request_generateProof_ProcessMessages.json \
http://localhost:8080/api/generateProof
```

TallyVotes:
```
curl \
-X POST \
-H "Content-Type: application/json" \
-d '{"maciPollId":"12345","name":"Ethcon Korea 2023","authToken":"PVT_kwDOBheqls4AMmQM"}' \
http://localhost:8080/api/genproof
-d @demo/request_generateProof_TallyVotes.json \
http://localhost:8080/api/generateProof
```

### /api/checkStatus/{maciPollId}
### /api/getResult

```
curl http://localhost:8080/api/checkStatus/12345
curl http://localhost:8080/api/getResult
```

### /api/getResult/{maciPollId}
## Generate Proof using snarkjs

```
curl http://localhost:8080/api/getResult/12345
snarkjs groth16 prove instruments/TallyVotes_10-1-2_test.0.zkey data/TallyVotes/10-1-2/witness_wasm.wtns outputs/proof_TallyVotes_10-1-2.json outputs/public_TallyVotes_10-1-2.json
```
Loading

0 comments on commit 99f3010

Please sign in to comment.