Skip to content

Commit

Permalink
Merge pull request #71 from privacy-scaling-explorations/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
daodesigner authored Aug 24, 2023
2 parents 9543280 + 3412d03 commit 561719e
Show file tree
Hide file tree
Showing 15 changed files with 521 additions and 158 deletions.
13 changes: 8 additions & 5 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ Please provide a detailed description of the ceremony you are proposing.
- fill the *p0tionConfig.json* file accordingly:
+ The title of the ceremony will end up being its prefix. Prefixes are simply the title all lowercase, with dashes (*-*) instead of whitespace. For example, given a title of *Example Ceremony*, the prefix will be *example-ceremony*.
+ Fill the rest of the fields with the desired data, ensuring that each circuit details are correct, and that you chose the required Verification method.
+ In the artifacts fields, please add the correct path which should be:
*./ceremonies/$PREFIX/$CIRCUIT_NAME.$EXTENSION* - note that we require both the *r1cs* and the *wasm* files.
+ In the artifacts fields, please add the correct storage path and bucket name - note that we require both the *r1cs* and the *wasm* files.
+ *Note* that you can use [p0tion phase2cli](https://github.com/privacy-scaling-explorations/p0tion) as follows to verify that the config file is correct:
* `phase2cli validate --template $PATH_TO_THE_TEMPLATE`
- create a directory inside *./ceremonies* and name it with the *prefix* (detailed in the bullet point above).
Expand Down Expand Up @@ -69,6 +68,8 @@ Failing to follow the above instructions, will result in the CI checks failing.
"cfOrVm": "<DESIRED_VERIFICATION_MECHANISM (VM/CF)>"
},
"artifacts": {
"bucket": "<THE_BUCKET_NAME>",
"region": "<THE_AWS_REGION_WHERE_THE_BUCKET_LIVES>",
"r1csLocalFilePath": "<PATH_TO_THE_CIRCUIT_R1CS>",
"wasmLocalFilePath": "<PATH_TO_THE_CIRCUIT_WASM>"
},
Expand Down Expand Up @@ -111,9 +112,11 @@ Failing to follow the above instructions, will result in the CI checks failing.
* "io1"
* "st1"
* "sc1"
- artifacts - an object with the local paths to the r1cs and wasm
- r1csLocalFilePath - a string with the r1cs path e.g. "./ceremonies/ceremonyPrefix/circuit.r1cs"
- wasmLocalFilePath - a string with the r1cs path e.g. "./ceremonies/ceremonyPrefix/circuit.wasm"
- artifacts - an object with the storage path to the r1cs and wasm on s3
- bucket - a string with the bucket name
- region - the AWS region where the bucket live
- r1csStoragePath - a string with the r1cs storage path e.g. "test-ceremony/circuit.r1cs"
- wasmStoragePath - a string with the wasm storage path e.g. "test-ceremony/circuit.wasm"
- name - a string with the circuit name
- dynamicThreshold - if selected dynamic timeout please enter the threshold here as a number
- fixedTimeWindow - if selected fixed timeout please enter the time window here as a number
Expand Down
45 changes: 10 additions & 35 deletions .github/workflows/check-pr-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Install jq
run: sudo apt-get install jq

- name: Get changed files
id: get-changed-files
uses: jitterbit/get-changed-files@v1
with:
format: 'csv'

- name: Parse p0tionConfig.json
id: parse-config
run: |
directory_name="ceremonies/$(echo $GITHUB_HEAD_REF | tr '[:upper:]' '[:lower:]')"
config_file="${directory_name}/p0tionConfig.json"
num_circuits=$(jq '.circuits | length' $config_file)
echo "NUM_CIRCUITS=$num_circuits" >> $GITHUB_ENV
- name: Validate files
run: |
changed_files="${{ steps.get-changed-files.outputs.all }}"
IFS=', ' read -r -a files <<< "$changed_files"
expected_files=$((NUM_CIRCUITS * 2 + 1))
if [[ ${#files[@]} -ne $expected_files ]]; then
echo "The PR should have $expected_files files changed only"
exit 1
fi
r1cs_files=()
wasm_files=()
json_files=()
config_found=false
for file in "${files[@]}"; do
if [[ $file == *.r1cs ]]; then r1cs_files+=("$file")
elif [[ $file == *.wasm ]]; then wasm_files+=("$file")
elif [[ $file == *p0tionConfig.json ]]; then json_files+=("$file")
if [[ $file == ceremonies/$(echo $GITHUB_HEAD_REF | tr '[:upper:]' '[:lower:]')/p0tionConfig.json ]]; then
config_found=true
else
echo "Invalid file detected: $file"
exit 1
fi
done
if [[ ${#r1cs_files[@]} -ne $NUM_CIRCUITS || ${#wasm_files[@]} -ne $NUM_CIRCUITS || ${#json_files[@]} -ne 1 ]]; then
echo "Invalid or missing circuit artifacts"
if [[ $config_found = false ]]; then
echo "No p0tionConfig.json file found in PR."
exit 1
fi
echo "Ceremony artifacts are present"
directory_name="ceremonies/$(echo $GITHUB_HEAD_REF | tr '[:upper:]' '[:lower:]')"
echo "Checking that all files are inside $directory_name"
for file in "${files[@]}"; do
if [[ ! $file =~ ^$directory_name/ ]]; then
echo "Files must be inside the $directory_name directory"
exit 1
fi
done
echo "All checks passed"
echo "p0tionConfig.json file is present and no other files were changed."
2 changes: 1 addition & 1 deletion .github/workflows/setup-ceremony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
for ceremony in "${ALL_CEREMONIES[@]}"; do
if [[ ! " ${EXISTING_CEREMONIES[@]} " =~ " ${ceremony} " ]]; then
echo 'Setting up ceremony: ./ceremonies/$ceremony/p0tionConfig.json'
phase2cli coordinate setup --template "./ceremonies/$ceremony/p0tionConfig.json" --auth "${{ secrets.ACCESS_TOKEN }}"
NODE_OPTIONS=--max-old-space-size=12288 phase2cli coordinate setup --template "./ceremonies/$ceremony/p0tionConfig.json" --auth "${{ secrets.ACCESS_TOKEN }}"
fi
done
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/validate-ceremony-setup.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
# Run for each PR that changes files in the ceremonies directory
name: Check PR with new ceremony files

on:
pull_request:
paths:
- 'ceremonies/**'

jobs:
check:
runs-on: ubuntu-latest
if: endsWith(github.head_ref, '-ceremony')

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'

- name: Install p0tion
run: npm install -g @p0tion/phase2cli
# Run for each PR that changes files in the ceremonies directory
name: Check PR with new ceremony files

on:
pull_request:
paths:
Expand Down
31 changes: 16 additions & 15 deletions ceremonies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| This folder contains a collection of ceremony artifacts (r1cs, wasm) and setup configuration file which are used to setup a phase2 trusted setup ceremony using [p0tion](https://github.com/privacy-scaling-explorations/p0tion/). |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

To request a new ceremony to be setup, you will need to submit a PR with a folder including your ceremony files.
To request a new ceremony to be setup, you will need to submit a PR with a folder including your ceremony configuration file.

## Guidelines

Expand All @@ -18,14 +18,11 @@ To request a new ceremony to be setup, you will need to submit a PR with a folde
- fill the *p0tionConfig.json* file accordingly:
+ The title of the ceremony will end up being its prefix. Prefixes are simply the title all lowercase, with dashes (*-*) instead of whitespace. For example, given a title of *Example Ceremony*, the prefix will be *example-ceremony*.
+ Fill the rest of the fields with the desired data, ensuring that each circuit details are correct, and that you chose the required Verification method.
+ In the artifacts fields, please add the correct path which should be:
*./ceremonies/$PREFIX/$CIRCUIT_NAME.$EXTENSION* - note that we require both the *r1cs* and the *wasm* files.
+ In the artifacts fields, please add the correct storage path and bucket name - note that we require both the *r1cs* and the *wasm* files.
+ *Note* that you can use [p0tion phase2cli](https://github.com/privacy-scaling-explorations/p0tion) as follows to verify that the config file is correct:
* `phase2cli validate --template $PATH_TO_THE_TEMPLATE`
- create a directory inside *./ceremonies* and name it with the *prefix* (detailed in the bullet point above).
- ensure that only these three files were added:
+ r1cs
+ wasm
- ensure that only one file is added:
+ p0tionConfig.json
- the destination path of the PR should be either of:
+ main (for production runs)
Expand Down Expand Up @@ -57,7 +54,7 @@ The script will upload your artifacts to a S3 bucket of your choice (must be own
"startDate": "<START_DATE FORMAT: 2023-08-07T00:00:00>",
"endDate": "<END_DATE FORMAT: 2023-09-10T00:00:00>",
"timeoutMechanismType": "<TIMEOUT_MECHANISM FIXED/DYNAMIC>",
"penalty": 10,
"penalty": "<THE_PENALTY_APPLIED_TO_USERS (NUMBER)>",
"circuits": [
{
"description": "<CIRCUIT_DESCRIPTION>",
Expand All @@ -68,19 +65,21 @@ The script will upload your artifacts to a S3 bucket of your choice (must be own
"template": {
"source": "<HTTPS_URL_OF_THE_CIRCOM_FILE>",
"commitHash": "<TEMPLATE_COMMIT_HASH>",
"paramConfiguration": [6,8,3,2]
"paramConfiguration": ["<CIRCUIT_INSTANCE_PARAMETERS_ARRAY>"]
},
"verification": {
"cfOrVm": "CF"
"cfOrVm": "<DESIRED_VERIFICATION_MECHANISM (VM/CF)>"
},
"artifacts": {
"bucket": "<THE_BUCKET_NAME>",
"region": "<THE_AWS_REGION_WHERE_THE_BUCKET_LIVES>",
"r1csLocalFilePath": "<PATH_TO_THE_CIRCUIT_R1CS>",
"wasmLocalFilePath": "<PATH_TO_THE_CIRCUIT_WASM>"
},
"name": "<CIRCUIT_NAME>",
"dynamicThreshold": 0,
"fixedTimeWindow": 3600,
"sequencePosition": 1
"dynamicThreshold": "<THE_DYNAMIC_THRESHOLD (NUMBER)>",
"fixedTimeWindow": "<THE_FIXED_TIME_WINDOW_FOR_CONTRIBUTION (NUMBER)>",
"sequencePosition": "<THE_SEQUENCE_POSITION_OF_THE_CIRCUIT_INSTANCE (NUMBER)>"
}
]
}
Expand Down Expand Up @@ -116,9 +115,11 @@ The script will upload your artifacts to a S3 bucket of your choice (must be own
* "io1"
* "st1"
* "sc1"
- artifacts - an object with the local paths to the r1cs and wasm
- r1csLocalFilePath - a string with the r1cs path e.g. "./ceremonies/ceremonyPrefix/circuit.r1cs"
- wasmLocalFilePath - a string with the r1cs path e.g. "./ceremonies/ceremonyPrefix/circuit.wasm"
- artifacts - an object with the storage path to the r1cs and wasm on s3
- bucket - a string with the bucket name
- region - the AWS region where the bucket live
- r1csStoragePath - a string with the r1cs storage path e.g. "test-ceremony/circuit.r1cs"
- wasmStoragePath - a string with the wasm storage path e.g. "test-ceremony/circuit.wasm"
- name - a string with the circuit name
- dynamicThreshold - if selected dynamic timeout please enter the threshold here as a number
- fixedTimeWindow - if selected fixed timeout please enter the time window here as a number
Expand Down
Binary file removed ceremonies/example-ceremony/circuit.r1cs
Binary file not shown.
Binary file removed ceremonies/example-ceremony/circuit.wasm
Binary file not shown.
33 changes: 0 additions & 33 deletions ceremonies/example-ceremony/p0tionConfig.json

This file was deleted.

Loading

0 comments on commit 561719e

Please sign in to comment.