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

merge dev #123

Merged
merged 203 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
203 commits
Select commit Hold shift + click to select a range
1a35fc7
Merge branch 'dev' of github.com:privacy-scaling-explorations/p0tion …
ctrlc03 Apr 19, 2023
37f4351
fix: set cli as a es module
cedoor Apr 20, 2023
79faae9
fix: bump 0.3.0; minor missing imports for enums
0xjei Apr 20, 2023
8827fc2
Merge pull request #19 from privacy-scaling-explorations/fix/npm-publish
ctrlc03 Apr 20, 2023
26d6104
feat (EC2-demo) testing VMs
ctrlc03 Apr 22, 2023
3e3763e
Merge branch 'dev' of github.com:privacy-scaling-explorations/p0tion …
ctrlc03 Apr 22, 2023
461a3a9
feat(ec2) - continuing with poc
ctrlc03 May 9, 2023
513182b
Merge branch 'dev' of github.com:privacy-scaling-explorations/p0tion …
ctrlc03 May 9, 2023
ec092bf
fix(sybil) - add tests
ctrlc03 May 9, 2023
ff2ebb9
fix(sybil) - added prod test switch
ctrlc03 May 9, 2023
061ae36
build: update external packages dependencies
0xjei May 10, 2023
8363f50
feat(public ceremonies) - allow to download ceremony data to everyone
ctrlc03 May 10, 2023
1254731
refactor: move auto-generated types to root
0xjei May 12, 2023
cfe6217
refactor: improve package configuration; remove unused files
0xjei May 12, 2023
b245856
refactor: complete configuration; lint and small fix
0xjei May 12, 2023
d740a90
fix: wrong prod Firebase project for CI
0xjei May 12, 2023
c0fc6c5
refactor: update phase2cli package config; fixed bin overwrite when i…
0xjei May 12, 2023
fc03ed7
refactor: use meta import to optimize repository file read
0xjei May 13, 2023
6192998
refactor: use ts-node instead of dist to execute phase2cli
0xjei May 14, 2023
33cd41b
refactor: update .env and package.json imports
0xjei May 14, 2023
75bbd98
fix: wrong path for environment config file
0xjei May 14, 2023
5a45a68
Merge pull request #32 from privacy-scaling-explorations/config/packages
0xjei May 15, 2023
16ad3ea
fix(public-data) merge dev
ctrlc03 May 15, 2023
5439cd6
fix(sybil) - merge dev
ctrlc03 May 15, 2023
a4fb273
fix(public-data) remove cloud function
ctrlc03 May 15, 2023
0b6771e
fix(public-data) remove function from index.ts
ctrlc03 May 15, 2023
5110c11
fix(public data) yarn.locl
ctrlc03 May 15, 2023
846053f
Merge pull request #36 from privacy-scaling-explorations/feat/public_…
ctrlc03 May 15, 2023
7433e38
fix: missing skipLibCheck option was causing docs script to exit
0xjei May 15, 2023
215e929
Merge pull request #37 from privacy-scaling-explorations/fix/docs
ctrlc03 May 15, 2023
ef68800
Merge branch 'dev' of github.com:privacy-scaling-explorations/p0tion …
ctrlc03 May 15, 2023
d3aedf5
Merge pull request #27 from privacy-scaling-explorations/fix/sybil
ctrlc03 May 15, 2023
9e05617
fix: add missing options to ts config
0xjei May 15, 2023
6d9e0e1
Merge pull request #39 from privacy-scaling-explorations/fix/docs
ctrlc03 May 15, 2023
97ae32e
chore(release): publish 0.3.0
0xjei May 15, 2023
6ac2c77
Merge pull request #40 from privacy-scaling-explorations/tag/0.3.0
ctrlc03 May 15, 2023
037c87b
build: update yarn version
0xjei May 15, 2023
2d58e11
Merge pull request #42 from privacy-scaling-explorations/update/yarn
0xjei May 15, 2023
345bdcb
fix: spinner does not stop correctly after contribution verification
0xjei May 15, 2023
3376da2
Merge pull request #44 from privacy-scaling-explorations/fix/spinner
0xjei May 16, 2023
042f411
chore(release): publish 0.3.1
0xjei May 16, 2023
2235d46
Merge pull request #45 from privacy-scaling-explorations/patch/0.3.1
0xjei May 16, 2023
88a730b
fix: missing updates for current contributor fields when coordinating
0xjei May 17, 2023
61fbd19
fix: duplicate messages when waiting for contribution; remove wrong l…
0xjei May 17, 2023
ccf1ce5
chore(release): publish 0.3.5
0xjei May 17, 2023
c28e2f0
fix(sybil checks): amended env var name and added to the backend
ctrlc03 May 18, 2023
12ad715
fix(s3): creating public bucket with object ACL enabled
ctrlc03 May 18, 2023
d4a6dc8
fix(tests): fixed tests
ctrlc03 May 18, 2023
1413631
Merge branch 'patch/0.3.x' into fix/s3
0xjei May 19, 2023
d342a06
Merge pull request #49 from privacy-scaling-explorations/fix/s3
0xjei May 19, 2023
07fc79b
fix: unconsistency when resuming a contribution
0xjei May 18, 2023
5044da6
fix: add missing alternative case; fix wrong tests
0xjei May 19, 2023
eafe259
Merge pull request #50 from privacy-scaling-explorations/fix/resume-c…
0xjei May 19, 2023
e8ac943
chore(release): publish 0.4.0
0xjei May 19, 2023
1304473
fix: wrong ci env project
0xjei May 19, 2023
819b792
fix: missing sort for ceremony circuits
0xjei May 19, 2023
9612144
Merge pull request #46 from privacy-scaling-explorations/patch/0.3.x
0xjei May 20, 2023
fbe22ea
fix: wrong document property lead to error when checking github antis…
0xjei May 31, 2023
d76af26
build: missing dependencies on actions package
0xjei May 31, 2023
005d1dd
chore(release): publish 0.4.1
0xjei May 31, 2023
8c1b53a
chore(release): publish 0.4.2
0xjei May 31, 2023
e804760
test: update github anti-sybil tests
0xjei May 31, 2023
d450e69
Merge pull request #56 from privacy-scaling-explorations/fix/patch
0xjei May 31, 2023
80d9858
fix(ux): added more verbose messages to inform the user of waiting ti…
ctrlc03 Jun 7, 2023
bdd6d0f
Merge pull request #58 from privacy-scaling-explorations/fix/ui
ctrlc03 Jun 13, 2023
debed05
Merge branch 'dev' into feat/ec2
0xjei Jun 21, 2023
2658c1a
feat(ec2): added tests and ip function
ctrlc03 Jun 21, 2023
5e8a76f
feat(ec2): merge udpates and add tests
ctrlc03 Jun 21, 2023
f9a251a
feat(vms): added ssm code and more tests + changes on backend
ctrlc03 Jun 22, 2023
08486b2
feat(vms): refactoring
ctrlc03 Jun 22, 2023
8b8b84f
fix: imports and package version
0xjei Jun 22, 2023
89b621b
feat(vms): added tests
ctrlc03 Jun 22, 2023
dfbf3a7
fix(vms): tests
ctrlc03 Jun 22, 2023
f7e8de7
feat(ec2): fixed bug in running commands at deployment and refactored…
ctrlc03 Jun 22, 2023
14e2636
test(ec2): added setup e2e test
ctrlc03 Jun 23, 2023
0ebe401
fix(vms): refactoring and code fixes
ctrlc03 Jun 23, 2023
f4ae99d
fix(vm): bug fix
ctrlc03 Jun 23, 2023
64f5019
fix(vm): missing files
ctrlc03 Jun 23, 2023
684123a
feat(vms): implemented e2e test for contribution verification
ctrlc03 Jun 23, 2023
3a19f95
feat(vms): tests and refactoring
ctrlc03 Jun 26, 2023
80ce491
fix(vms): remove redundant code
ctrlc03 Jun 26, 2023
93fdb0b
test(vms): completed e2e tests with VMs
ctrlc03 Jun 26, 2023
c0a2922
fix(vms): cleanup test
ctrlc03 Jun 26, 2023
8f3dc42
fix(vms): remove redundant parameter on VM startup - ssh keypair
ctrlc03 Jun 26, 2023
0347289
fix(vms): add tags on EC2 creation
ctrlc03 Jun 27, 2023
b75b3d3
refactor: add missing hash computation; minor conflicts and changes
0xjei Jun 27, 2023
a39fd5f
fix(vms): fix VM commands
ctrlc03 Jun 27, 2023
f3081b5
test(vms): fix test to also delete the verification transcript
ctrlc03 Jun 27, 2023
235e252
chore: publish 0.4.7
0xjei Jun 27, 2023
a89e11b
test(vms): refactoring of VM tests with extra debug options
ctrlc03 Jun 27, 2023
b5a17bd
test(vms): fixed finalize test and cloud function. Adding extra debug…
ctrlc03 Jun 27, 2023
9aec4e7
fix(vms): fixed wrong path in blake3 bin command and various fixes on…
ctrlc03 Jun 28, 2023
218340d
chore: publish 0.4.8
0xjei Jun 28, 2023
0bf3034
fix(vms): removed stdin/stdout redirection in VM command and added re…
ctrlc03 Jun 28, 2023
3ca22a5
fix(vms): fixed cloud function for VM verification
ctrlc03 Jun 28, 2023
7c56ead
chore: publish 0.4.9
0xjei Jun 29, 2023
db35a5f
fix(vms): fix cloud function bug related to the wrong verification tr…
ctrlc03 Jun 29, 2023
7d63cd1
test(vms): fix broken tests due to VM upgrade
ctrlc03 Jun 29, 2023
2c426cb
fix(vms): disable eslint rule for regex
ctrlc03 Jun 29, 2023
f5f73bb
feat(vms): implement SNS topic command to trigger Lambda that stops t…
ctrlc03 Jun 29, 2023
dfda857
feat(vms): add marker file in userData to avoid running initializatio…
ctrlc03 Jun 29, 2023
cd65566
fix(vms): fix userData commands
ctrlc03 Jun 30, 2023
b73b2d7
refactor: add VM prices
0xjei Jun 30, 2023
404efa1
refactor: add selector for VM disk type
0xjei Jun 30, 2023
65cb97e
test: update tests
0xjei Jun 30, 2023
d281dd4
refactor: complete and remove old todos
0xjei Jun 30, 2023
3e83c78
refactor: add retry mechanism for VM
0xjei Jun 30, 2023
b414166
fix: wrong path to Verifier smart contract template
0xjei Jun 30, 2023
b168cd0
feat(vms): implement terraform script to deploy AWS inf
ctrlc03 Jun 30, 2023
7e7f9f6
fix(vms): fix import error
ctrlc03 Jun 30, 2023
f55e832
fix: correct failing tests
0xjei Jun 30, 2023
b98e088
fix(vms): fix cloud function multipartupload wrong parameter name
ctrlc03 Jun 30, 2023
ea64d18
chore: publish 0.4.10
0xjei Jun 30, 2023
2714912
fix(vms): fix terraform and lambda config
ctrlc03 Jun 30, 2023
5d0375d
fix(vms): temp revert of retry feature in verifyContribution
ctrlc03 Jun 30, 2023
98af9d0
fix(vms): fix emulator tests
ctrlc03 Jul 3, 2023
f8b4397
fix(vms): fix prod tests
ctrlc03 Jul 3, 2023
2fb29e7
refactor: improve verifycontribution function code; minor changes to …
0xjei Jul 3, 2023
86beca7
fix(vms): fix prod test - wrong parameter order in ec2 tests
ctrlc03 Jul 4, 2023
5fd87b0
chore: publish 0.5.0
0xjei Jul 4, 2023
627e1dd
Merge pull request #72 from privacy-scaling-explorations/feat/vm
0xjei Jul 4, 2023
716843d
fix: missing else statement for verifycontribution function; wrong re…
0xjei Jul 4, 2023
1e74a4c
fix(vms): revert part of the verifyContribution refactoring and updat…
ctrlc03 Jul 4, 2023
1f5accd
fix(vms): retry mechanism for VM startup
ctrlc03 Jul 5, 2023
8d38ed2
Merge pull request #75 from privacy-scaling-explorations/fix/retry
ctrlc03 Jul 5, 2023
0cc2662
refactor: add options for contribute command
0xjei Jul 6, 2023
d4e40cd
Merge pull request #79 from privacy-scaling-explorations/command/cont…
0xjei Jul 6, 2023
26cd357
refactor: make coordinator artifacts publicly downloadable by default
0xjei Jul 6, 2023
39fbdd2
chore: update backend firebase default prod project
0xjei Jul 7, 2023
19ba15d
fix(tests): add extra sleep when setting custom claims to allow propa…
ctrlc03 Jul 7, 2023
9346a6f
fix(tests): skip a test that would fail due to environment not clean
ctrlc03 Jul 7, 2023
14a6ecd
fix(tests): fix issues with user not being recognized as coordinator
ctrlc03 Jul 7, 2023
3e31cd2
fix(tests): add extra sleep and coordinator checks within tests
ctrlc03 Jul 8, 2023
1cdc784
Merge pull request #81 from privacy-scaling-explorations/chore/public…
ctrlc03 Jul 8, 2023
dd6f4c6
refactor: avoid mandatory memory check; add missing loader and messag…
0xjei Jul 7, 2023
697c535
Merge pull request #82 from privacy-scaling-explorations/refactor/mem…
ctrlc03 Jul 10, 2023
e72c2f8
feat(setup): start to implement non interactive setup
ctrlc03 Jul 5, 2023
c3638d4
feat(setup): implement non interactive setup
ctrlc03 Jul 6, 2023
46260eb
fix(setup): change test file
ctrlc03 Jul 6, 2023
2e21885
fix(setup): remove non working test
ctrlc03 Jul 6, 2023
cf8e698
fix(setup): change setup test file
ctrlc03 Jul 6, 2023
8c104ef
fix(setup): amend after PR review
ctrlc03 Jul 7, 2023
9306eae
feat(setup): add option to pass the authentication token as cli param
ctrlc03 Jul 8, 2023
6745c45
fix(tests): add extra coordinator user to resolve random test failure
ctrlc03 Jul 9, 2023
b637b9e
fix(tests): add extra sleep after user creation
ctrlc03 Jul 9, 2023
0f4dfea
fix(auth): fix non interactive auth and force token refresh for coord…
ctrlc03 Jul 9, 2023
865a06f
fix(setup): fix local path to circuit artifacts + change error in sec…
ctrlc03 Jul 9, 2023
15b8743
fix(setup): add missing circuit artifacts local path
ctrlc03 Jul 9, 2023
905b6c0
fix(tests): fix tests
ctrlc03 Jul 9, 2023
7e007e2
Merge pull request #80 from privacy-scaling-explorations/feat/non-int…
0xjei Jul 10, 2023
be6c1aa
refactor: improve ux ui of auth and logout commands
0xjei Jul 10, 2023
66f8837
feat(setup): add a cli command to validate the ceremony setup file an…
ctrlc03 Jul 11, 2023
920a073
Merge pull request #85 from privacy-scaling-explorations/design/auth
ctrlc03 Jul 11, 2023
d76a44d
Merge pull request #86 from privacy-scaling-explorations/feat/validat…
ctrlc03 Jul 11, 2023
470fd73
refactor: add spinners to avoid delays; add custom feedback messages …
0xjei Jul 11, 2023
0a602bc
chore: correct text
0xjei Jul 11, 2023
34aca69
Merge pull request #88 from privacy-scaling-explorations/design/contr…
ctrlc03 Jul 11, 2023
d2723f2
feat(list ceremonies): add a command to list all ceremonies
ctrlc03 Jul 11, 2023
805c28e
feat(list): exit with code 1 when calling showError with exit=true
ctrlc03 Jul 11, 2023
05d6b16
Merge pull request #89 from privacy-scaling-explorations/feat/list-ce…
ctrlc03 Jul 11, 2023
152b4da
fix(tests and setup): fix tests and cleanup config file
ctrlc03 Jul 12, 2023
01a2b19
Merge pull request #91 from privacy-scaling-explorations/fix/config_f…
baumstern Jul 12, 2023
bd121d7
chore: publish 1.0.0
0xjei Jul 11, 2023
12b99f1
fix(verifycontribution): fix issue with failing to deconstruct undefi…
ctrlc03 Jul 14, 2023
33c220e
Revise workflow
baumstern Jul 14, 2023
c368a3f
Merge pull request #90 from privacy-scaling-explorations/publish/1.0.0
daodesigner Jul 14, 2023
af157c8
Merge pull request #94 from privacy-scaling-explorations/fix/verify-c…
daodesigner Jul 14, 2023
bf17106
Merge pull request #93 from privacy-scaling-explorations/cicd
daodesigner Jul 14, 2023
93b6d78
Fix a typo
baumstern Jul 14, 2023
e7b9630
V1.1.1
baumstern Jul 14, 2023
f16ef43
Merge branch 'staging' into dev
daodesigner Jul 14, 2023
4a1972b
Separate deploy and test (#99)
baumstern Jul 14, 2023
331d2cb
nit:fix merge conflicts, test against same environment deployed
daodesigner Jul 14, 2023
d032f37
feat(setup): non interactive setup with artifacts download
ctrlc03 Jul 18, 2023
f7b059d
feat(setup): add cloud function for file transfer and unit tests
ctrlc03 Jul 18, 2023
7c743bb
feat(setup): add transfer of object inside phase2cli
ctrlc03 Jul 18, 2023
c407bee
feat(setup): remove return value and amend tests
ctrlc03 Jul 18, 2023
690da25
fix(setup): revert transfer of object and add region to config
ctrlc03 Jul 19, 2023
80d9581
feat(setup) fix test template
ctrlc03 Jul 19, 2023
a233767
fix(setup): fix not waiting for file download
ctrlc03 Jul 19, 2023
8467f62
fix(setup): remove redundant function
ctrlc03 Jul 19, 2023
fb03211
Merge pull request #102 from privacy-scaling-explorations/feat/larger…
0xjei Jul 19, 2023
fef04e6
chore(release): publish 1.0.1
0xjei Jul 19, 2023
a227f25
Merge pull request #104 from privacy-scaling-explorations/bump/1.0.1
0xjei Jul 19, 2023
1cc1485
fix(vms): specify region in sns command
ctrlc03 Jul 20, 2023
1745f9f
fix(vms) - missing param
ctrlc03 Jul 20, 2023
8c6d7e0
fix(vms): missing doc
ctrlc03 Jul 20, 2023
14e9f49
fix(vms): fix default region
ctrlc03 Jul 20, 2023
2548570
Merge pull request #105 from privacy-scaling-explorations/fix/aws_region
0xjei Jul 20, 2023
87a629b
chore(release): publish 1.0.2
0xjei Jul 20, 2023
8f9f491
Merge pull request #106 from privacy-scaling-explorations/bump/1.0.1
0xjei Jul 20, 2023
1d6a748
fix(setup): fix vm command due to differences in AMI config between r…
ctrlc03 Jul 20, 2023
385adcd
Merge pull request #107 from privacy-scaling-explorations/fix/vm_comm…
0xjei Jul 20, 2023
dce802f
chore(release): publish 1.0.4
0xjei Jul 20, 2023
d8f56c6
Merge pull request #108 from privacy-scaling-explorations/bump/1.0.4
0xjei Jul 20, 2023
1627b21
fix (ceremony) - fix various bugs (#116)
ctrlc03 Jul 24, 2023
54d1972
Ensure all CFs are deployed into `europe-west1` region
baumstern Jul 24, 2023
9dd2cb6
Merge pull request #118 from privacy-scaling-explorations/cfs
ctrlc03 Jul 24, 2023
45b8fc5
fix(verification): set concurrency to 1 and ensure that files are dow…
ctrlc03 Jul 24, 2023
70263f2
Merge pull request #121 from privacy-scaling-explorations/fix/verific…
baumstern Jul 24, 2023
1013a0c
chore(release): publish 1.0.5 (#120)
0xjei Jul 24, 2023
aa87f8a
fix(verify): revert removing concurrency and add unique filenames (#122)
ctrlc03 Jul 24, 2023
9b6fd60
Merge branch 'staging' into dev
daodesigner Jul 24, 2023
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [1.0.5](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.4...v1.0.5) (2023-07-24)

**Note:** Version bump only for package p0tion



## [1.0.4](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.2...v1.0.4) (2023-07-20)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"npmClient": "yarn",
"useWorkspaces": true,
"version": "1.0.4",
"version": "1.0.5",
"changelogPreset": {
"name": "conventionalcommits",
"issuePrefixes": [
Expand Down
7 changes: 7 additions & 0 deletions packages/actions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.


## [1.0.5](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.4...v1.0.5) (2023-07-24)

**Note:** Version bump only for package @p0tion/actions



## [1.0.4](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.2...v1.0.4) (2023-07-20)


Expand Down
2 changes: 1 addition & 1 deletion packages/actions/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@p0tion/actions",
"version": "1.0.4",
"version": "1.0.5",
"description": "A set of actions and helpers for CLI commands",
"repository": "[email protected]:privacy-scaling-explorations/p0tion.git",
"homepage": "https://github.com/privacy-scaling-explorations/p0tion",
Expand Down
64 changes: 44 additions & 20 deletions packages/actions/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,63 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false):
// check that the timeout is provided for the correct configuration
let dynamicThreshold: number | undefined
let fixedTimeWindow: number | undefined

let circuit: CircuitDocument | CircuitInputData = {} as CircuitDocument | CircuitInputData

if (data.timeoutMechanismType === CeremonyTimeoutType.DYNAMIC) {
if (circuitData.dynamicThreshold <= 0)
throw new Error("The dynamic threshold should be > 0.")
dynamicThreshold = circuitData.dynamicThreshold

// the Circuit data for the ceremony setup
circuit = {
name: circuitData.name,
description: circuitData.description,
prefix: circuitPrefix,
sequencePosition: i+1,
metadata: metadata,
files: files,
template: template,
compiler: compiler,
verification: verification,
dynamicThreshold: dynamicThreshold,
avgTimings: {
contributionComputation: 0,
fullContribution: 0,
verifyCloudFunction: 0
},

}
}

if (data.timeoutMechanismType === CeremonyTimeoutType.FIXED) {
if (circuitData.fixedTimeWindow <= 0)
throw new Error("The fixed time window threshold should be > 0.")
fixedTimeWindow = circuitData.fixedTimeWindow
}

// the Circuit data for the ceremony setup
const circuit: CircuitDocument | CircuitInputData = {
name: circuitData.name,
description: circuitData.description,
prefix: circuitPrefix,
sequencePosition: i+1,
metadata: metadata,
files: files,
template: template,
compiler: compiler,
verification: verification,
fixedTimeWindow: fixedTimeWindow,
// dynamicThreshold: dynamicThreshold,
avgTimings: {
contributionComputation: 0,
fullContribution: 0,
verifyCloudFunction: 0
},


// the Circuit data for the ceremony setup
circuit = {
name: circuitData.name,
description: circuitData.description,
prefix: circuitPrefix,
sequencePosition: i+1,
metadata: metadata,
files: files,
template: template,
compiler: compiler,
verification: verification,
fixedTimeWindow: fixedTimeWindow,
avgTimings: {
contributionComputation: 0,
fullContribution: 0,
verifyCloudFunction: 0
},

}
}


circuits.push(circuit)

// remove the local r1cs download (if used for verifying the config only vs setup)
Expand Down
7 changes: 7 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.


## [1.0.5](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.4...v1.0.5) (2023-07-24)

**Note:** Version bump only for package @p0tion/backend



## [1.0.4](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.0.2...v1.0.4) (2023-07-20)

**Note:** Version bump only for package @p0tion/backend
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@p0tion/backend",
"version": "1.0.4",
"version": "1.0.5",
"description": "MPC Phase 2 backend for Firebase services management",
"repository": "[email protected]:privacy-scaling-explorations/p0tion.git",
"homepage": "https://github.com/privacy-scaling-explorations/p0tion",
Expand Down Expand Up @@ -67,7 +67,7 @@
"@aws-sdk/client-ssm": "^3.357.0",
"@aws-sdk/middleware-endpoint": "^3.329.0",
"@aws-sdk/s3-request-presigner": "^3.329.0",
"@p0tion/actions": "^1.0.4",
"@p0tion/actions": "^1.0.5",
"blakejs": "^1.2.1",
"dotenv": "^16.0.3",
"ethers": "5.7.2",
Expand Down
155 changes: 98 additions & 57 deletions packages/backend/src/functions/circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { zKey } from "snarkjs"
import { CommandInvocationStatus, SSMClient } from "@aws-sdk/client-ssm"
import { FinalizeCircuitData, VerifyContributionData } from "../types/index"
import { LogLevel } from "../types/enums"
import { COMMON_ERRORS, logAndThrowError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
import { COMMON_ERRORS, logAndThrowError, makeError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
import {
createEC2Client,
createSSMClient,
Expand Down Expand Up @@ -236,9 +236,6 @@ const waitForVMCommandExecution = (
if (cmdStatus === CommandInvocationStatus.SUCCESS) {
printLog(`Command ${commandId} successfully completed`, LogLevel.DEBUG)

// Clear the interval.
clearInterval(interval)

// Resolve the promise.
resolve()
} else if (cmdStatus === CommandInvocationStatus.FAILED) {
Expand Down Expand Up @@ -268,6 +265,62 @@ const waitForVMCommandExecution = (
}, 60000) // 1 minute.
}

/**
* Wait until the artifacts have been downloaded.
* @param {any} resolve the promise.
* @param {any} reject the promise.
* @param {string} potTempFilePath the tmp path to the locally downloaded pot file.
* @param {string} firstZkeyTempFilePath the tmp path to the locally downloaded first zkey file.
* @param {string} lastZkeyTempFilePath the tmp path to the locally downloaded last zkey file.
*/
const waitForFileDownload = (
resolve: any,
reject: any,
potTempFilePath: string,
firstZkeyTempFilePath: string,
lastZkeyTempFilePath: string,
circuitId: string,
participantId: string
) => {
const maxWaitTime = 5 * 60 * 1000 // 5 minutes
// every second check if the file download was completed
const interval = setInterval(async () => {
printLog(`Verifying that the artifacts were downloaded for circuit ${circuitId} and participant ${participantId}`, LogLevel.DEBUG)
try {
// check if files have been downloaded
if (!fs.existsSync(potTempFilePath)) {
printLog(`Pot file not found at ${potTempFilePath}`, LogLevel.DEBUG)
}
if (!fs.existsSync(firstZkeyTempFilePath)) {
printLog(`First zkey file not found at ${firstZkeyTempFilePath}`, LogLevel.DEBUG)
}
if (!fs.existsSync(lastZkeyTempFilePath)) {
printLog(`Last zkey file not found at ${lastZkeyTempFilePath}`, LogLevel.DEBUG)
}

// if all files were downloaded
if (fs.existsSync(potTempFilePath) && fs.existsSync(firstZkeyTempFilePath) && fs.existsSync(lastZkeyTempFilePath)) {
printLog(`All required files are present on disk.`, LogLevel.INFO)
// resolve the promise
resolve()
}
} catch (error: any) {
// if we have an error then we print it as a warning and reject
printLog(`Error while downloading files: ${error}`, LogLevel.WARN)
reject()
} finally {
printLog(`Clearing the interval for file download. Circuit ${circuitId} and participant ${participantId}`, LogLevel.DEBUG)
clearInterval(interval)
}
}, 5000)

// we want to clean in 5 minutes in case
setTimeout(() => {
clearInterval(interval)
reject(new Error('Timeout exceeded while waiting for files to be downloaded.'))
}, maxWaitTime)
}

/**
* This method is used to coordinate the waiting queues of ceremony circuits.
* @dev this cloud function is triggered whenever an update of a document related to a participant of a ceremony occurs.
Expand Down Expand Up @@ -525,7 +578,7 @@ export const verifycontribution = functionsV2.https.onCall(
? `${contributorOrCoordinatorIdentifier}_${finalContributionIndex}_verification_transcript.log`
: `${lastZkeyIndex}_${contributorOrCoordinatorIdentifier}_verification_transcript.log`
}`
const firstZkeyFilename = `${prefix}_${genesisZkeyIndex}.zkey`

const lastZkeyFilename = `${prefix}_${isFinalizing ? finalContributionIndex : lastZkeyIndex}.zkey`

// Prepare state for VM verification (if needed).
Expand Down Expand Up @@ -555,7 +608,7 @@ export const verifycontribution = functionsV2.https.onCall(
if (isUsingVM) {
// Create temporary path.
verificationTranscriptTemporaryLocalPath = createTemporaryLocalPath(
verificationTranscriptCompleteFilename
`${circuitId}_${participantDoc.id}.log`
)

await sleep(1000) // wait 1s for file creation.
Expand Down Expand Up @@ -807,9 +860,9 @@ export const verifycontribution = functionsV2.https.onCall(
verificationTranscriptTemporaryLocalPath = createTemporaryLocalPath(
verificationTranscriptCompleteFilename
)
const potTempFilePath = createTemporaryLocalPath(files.potFilename)
const firstZkeyTempFilePath = createTemporaryLocalPath(firstZkeyFilename)
const lastZkeyTempFilePath = createTemporaryLocalPath(lastZkeyFilename)
const potTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}.pot`)
const firstZkeyTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}_genesis.zkey`)
const lastZkeyTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}_last.zkey`)

// Create and populate transcript.
const transcriptLogger = createCustomLoggerForFile(verificationTranscriptTemporaryLocalPath)
Expand All @@ -826,57 +879,45 @@ export const verifycontribution = functionsV2.https.onCall(
await downloadArtifactFromS3Bucket(bucketName, firstZkeyStoragePath, firstZkeyTempFilePath)
await downloadArtifactFromS3Bucket(bucketName, lastZkeyStoragePath, lastZkeyTempFilePath)

await sleep(10000)
await sleep(6000)

// check if files have been downloaded
if (!fs.existsSync(potTempFilePath)) {
printLog(`Pot file not found at ${potTempFilePath}`, LogLevel.DEBUG)
// retry once
printLog(`Retrying to download pot file from ${potStoragePath} to ${potTempFilePath}`, LogLevel.DEBUG)
await downloadArtifactFromS3Bucket(bucketName, potStoragePath, potTempFilePath)
}
if (!fs.existsSync(firstZkeyTempFilePath)) {
printLog(`First zkey file not found at ${firstZkeyTempFilePath}`, LogLevel.DEBUG)
// retry once
printLog(`Retrying to download first zkey file from ${firstZkeyStoragePath} to ${firstZkeyTempFilePath}`, LogLevel.DEBUG)
await downloadArtifactFromS3Bucket(bucketName, firstZkeyStoragePath, firstZkeyTempFilePath)
}
if (!fs.existsSync(lastZkeyTempFilePath)) {
printLog(`Last zkey file not found at ${lastZkeyTempFilePath}`, LogLevel.DEBUG)
// retry once
printLog(`Retrying to download last zkey file from ${lastZkeyStoragePath} to ${lastZkeyTempFilePath}`, LogLevel.DEBUG)
await downloadArtifactFromS3Bucket(bucketName, lastZkeyStoragePath, lastZkeyTempFilePath)
}
// wait until the files are actually downloaded
return new Promise<void>((resolve, reject) =>
waitForFileDownload(resolve, reject, potTempFilePath, firstZkeyTempFilePath, lastZkeyTempFilePath, circuitId, participantDoc.id)
)
.then(async () => {
printLog(`Downloads from AWS S3 bucket completed - ceremony ${ceremonyId} circuit ${circuitId}`, LogLevel.DEBUG)

// Step (1.A.4).
isContributionValid = await zKey.verifyFromInit(
firstZkeyTempFilePath,
potTempFilePath,
lastZkeyTempFilePath,
transcriptLogger
)

// Compute contribution hash.
lastZkeyBlake2bHash = await blake512FromPath(lastZkeyTempFilePath)

// Free resources by unlinking temporary folders.
// Do not free-up verification transcript path here.
try {
fs.unlinkSync(potTempFilePath)
fs.unlinkSync(firstZkeyTempFilePath)
fs.unlinkSync(lastZkeyTempFilePath)
} catch (error: any) {
printLog(`Error while unlinking temporary files - Error ${error}`, LogLevel.WARN)
}

printLog(`Downloads from AWS S3 bucket completed - ceremony ${ceremonyId}`, LogLevel.DEBUG)
await completeVerification()
})
.catch((error: any) => {
// Throw the new error
const commonError = COMMON_ERRORS.CM_INVALID_REQUEST
const additionalDetails = error.toString()

// Step (1.A.4).
try {
isContributionValid = await zKey.verifyFromInit(
firstZkeyTempFilePath,
potTempFilePath,
lastZkeyTempFilePath,
transcriptLogger
)
} catch (error: any) {
printLog(`Error while verifying contribution - Error ${error}`, LogLevel.WARN)
isContributionValid = false
}

// Compute contribution hash.
lastZkeyBlake2bHash = await blake512FromPath(lastZkeyTempFilePath)

await completeVerification()

// Free resources by unlinking temporary folders.
// Do not free-up verification transcript path here.
try {
fs.unlinkSync(potTempFilePath)
fs.unlinkSync(firstZkeyTempFilePath)
fs.unlinkSync(lastZkeyTempFilePath)
} catch (error: any) {
printLog(`Error while unlinking temporary files - Error ${error}`, LogLevel.WARN)
}
logAndThrowError(makeError(commonError.code, commonError.message, additionalDetails))
})
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/functions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const registerAuthUser = functions
* which uses the Firebase Authentication service.
*/
export const processSignUpWithCustomClaims = functions
.region("europe-west1")
.runWith({
memory: "512MB"
})
Expand Down
9 changes: 7 additions & 2 deletions packages/backend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import admin from "firebase-admin"
import dotenv from "dotenv"
import { DeleteObjectCommand, GetObjectCommand, PutObjectCommand } from "@aws-sdk/client-s3"
import { getSignedUrl } from "@aws-sdk/s3-request-presigner"
import { createWriteStream } from "node:fs"
import { createWriteStream, fstat } from "node:fs"
import { pipeline } from "node:stream"
import { promisify } from "node:util"
import { readFileSync } from "fs"
Expand Down Expand Up @@ -213,8 +213,13 @@ export const downloadArtifactFromS3Bucket = async (bucketName: string, objectKey
if (response.status !== 200 || !response.ok) logAndThrowError(SPECIFIC_ERRORS.SE_STORAGE_DOWNLOAD_FAILED)

// Write the file locally using streams.
const writeStream = createWriteStream(localFilePath)
const streamPipeline = promisify(pipeline)
await streamPipeline(response.body, createWriteStream(localFilePath))
await streamPipeline(response.body, writeStream)

writeStream.on('finish', () => {
writeStream.end()
})
}

/**
Expand Down
Loading
Loading