From 77d8454f597e795725f90cc476c334e911cdc122 Mon Sep 17 00:00:00 2001 From: shuoer86 <129674997+shuoer86@users.noreply.github.com> Date: Thu, 2 Nov 2023 22:58:37 +0800 Subject: [PATCH 1/3] chore: fix typos --- packages/actions/.env.default | 4 ++-- packages/actions/src/types/index.ts | 2 +- packages/actions/test/unit/contribute.test.ts | 2 +- packages/actions/test/unit/finalize.test.ts | 2 +- packages/actions/test/unit/security.test.ts | 2 +- packages/actions/test/unit/storage.test.ts | 2 +- packages/backend/src/functions/ceremony.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/actions/.env.default b/packages/actions/.env.default index bdcf0a3c..e8163121 100644 --- a/packages/actions/.env.default +++ b/packages/actions/.env.default @@ -1,4 +1,4 @@ -# This environemnt must be configured both for core functionalities and testing. +# This environment must be configured both for core functionalities and testing. # The tests can be executed against a pre-deployed Firebase instance or # locally on your machine using the Firebase emulator. @@ -37,7 +37,7 @@ CONFIG_CEREMONY_BUCKET_POSTFIX="-ph2-ceremony" # The amount of time in seconds which indicates the duration about the validity of a pre-signed URL. # default: 7200 seconds = 2 hours. CONFIG_PRESIGNED_URL_EXPIRATION_IN_SECONDS=7200 -# AWS S3 access keys only required for unit/e2e testing (can be ommited) +# AWS S3 access keys only required for unit/e2e testing (can be omitted) # The AWS access key identifier related to S3 APIs. AWS_ACCESS_KEY_ID="YOUR-AWS-ACCESS-KEY-ID" # The AWS secret access key related to S3 APIs. diff --git a/packages/actions/src/types/index.ts b/packages/actions/src/types/index.ts index 8f8be6f3..906aab22 100644 --- a/packages/actions/src/types/index.ts +++ b/packages/actions/src/types/index.ts @@ -190,7 +190,7 @@ export type VMConfiguration = { /** * Group information about the circuit contribution verification mechanism. * @typedef {Object} CircuitContributionVerification - * @property {CircuitContributionVerificationMechanism} cfOrVm - the mechanism choosen by the coordinator. + * @property {CircuitContributionVerificationMechanism} cfOrVm - the mechanism chosen by the coordinator. * @property {VMConfiguration} [vm] - the VM configuration specs. */ export type CircuitContributionVerification = { diff --git a/packages/actions/test/unit/contribute.test.ts b/packages/actions/test/unit/contribute.test.ts index b11effdd..a3d2168b 100644 --- a/packages/actions/test/unit/contribute.test.ts +++ b/packages/actions/test/unit/contribute.test.ts @@ -436,7 +436,7 @@ describe("Contribute", () => { resumeContributionAfterTimeoutExpiration(userFunctions, fakeCeremoniesData.fakeCeremonyOpenedFixed.uid) ).to.be.rejectedWith("Unable to progress to next circuit for contribution") }) - it("should succesfully resume the contribution", async () => { + it("should successfully resume the contribution", async () => { await signInWithEmailAndPassword(userAuth, users[0].data.email, passwords[0]) await expect( resumeContributionAfterTimeoutExpiration(userFunctions, fakeCeremoniesData.fakeCeremonyOpenedFixed.uid) diff --git a/packages/actions/test/unit/finalize.test.ts b/packages/actions/test/unit/finalize.test.ts index 9464376c..4813b6bb 100644 --- a/packages/actions/test/unit/finalize.test.ts +++ b/packages/actions/test/unit/finalize.test.ts @@ -298,7 +298,7 @@ describe("Finalize", () => { ) ).to.be.rejectedWith("Unable to download the AWS S3 object from the provided ceremony bucket.") }) - it("should succesfully finalize the last contribution", async () => { + it("should successfully finalize the last contribution", async () => { // prepare coordinator for finalization await checkAndPrepareCoordinatorForFinalization( userFunctions, diff --git a/packages/actions/test/unit/security.test.ts b/packages/actions/test/unit/security.test.ts index ba345a7d..889973c7 100644 --- a/packages/actions/test/unit/security.test.ts +++ b/packages/actions/test/unit/security.test.ts @@ -830,7 +830,7 @@ describe("Security", () => { }) /// @note these test should be running last if (envType === TestingEnvironment.PRODUCTION) { - /// @note it is not recommended to allow anynomous access to firebase + /// @note it is not recommended to allow anonymous access to firebase it("should not allow to authenticate anynomously to Firebase", async () => { const auth = getAuth() await expect(signInAnonymously(auth)).to.be.rejectedWith( diff --git a/packages/actions/test/unit/storage.test.ts b/packages/actions/test/unit/storage.test.ts index f996754c..1d1e73cf 100644 --- a/packages/actions/test/unit/storage.test.ts +++ b/packages/actions/test/unit/storage.test.ts @@ -133,7 +133,7 @@ describe("Storage", () => { const exists = await checkIfObjectExist(userFunctions, bucketName, objectName) expect(exists).to.be.equal(true) }) - it("should return false when given a non existant bucket name", async () => { + it("should return false when given a non existent bucket name", async () => { // check existence const exists = await checkIfObjectExist(userFunctions, "nonExistingBucket", objectName) expect(exists).to.be.equal(false) diff --git a/packages/backend/src/functions/ceremony.ts b/packages/backend/src/functions/ceremony.ts index 0e255e24..908bd518 100644 --- a/packages/backend/src/functions/ceremony.ts +++ b/packages/backend/src/functions/ceremony.ts @@ -298,7 +298,7 @@ export const finalizeCeremony = functions const circuits = await getCeremonyCircuits(ceremonyId) // Get final contribution for each circuit. - // nb. the `getFinalContributionDocument` checks the existance of the final contribution document (if not present, throws). + // nb. the `getFinalContributionDocument` checks the existence of the final contribution document (if not present, throws). // Therefore, we just need to call the method without taking any data to verify the pre-condition of having already computed // the final contributions for each ceremony circuit. for await (const circuit of circuits) await getFinalContribution(ceremonyId, circuit.id) From f11504f772c61c052994da69b42f9266ce0e05be Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:08:53 +0000 Subject: [PATCH 2/3] fix(setup): fix issue with wasm file always being deleted --- packages/actions/src/helpers/utils.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/actions/src/helpers/utils.ts b/packages/actions/src/helpers/utils.ts index 03e7b2e3..fcde7ac6 100644 --- a/packages/actions/src/helpers/utils.ts +++ b/packages/actions/src/helpers/utils.ts @@ -712,8 +712,10 @@ export const parseCeremonyFile = async (path: string, cleanup: boolean = false): circuits.push(circuit) // remove the local r1cs and wasm downloads (if used for verifying the config only vs setup) - if (cleanup) fs.unlinkSync(localR1csPath) - fs.unlinkSync(localWasmPath) + if (cleanup) { + fs.unlinkSync(localR1csPath) + fs.unlinkSync(localWasmPath) + } } const setupData: SetupCeremonyData = { From a4da4e8050a9c55e521d9e1c49302978fc623bd1 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Fri, 29 Dec 2023 09:42:53 +0000 Subject: [PATCH 3/3] feat(setup-local-keys): do not compute zkeys again if found locally for non interactive setup --- packages/phase2cli/src/commands/setup.ts | 33 +++++++++++++++++------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/packages/phase2cli/src/commands/setup.ts b/packages/phase2cli/src/commands/setup.ts index e877b85d..3b5dc5f3 100644 --- a/packages/phase2cli/src/commands/setup.ts +++ b/packages/phase2cli/src/commands/setup.ts @@ -2,7 +2,7 @@ import { zKey } from "snarkjs" import boxen from "boxen" -import { createWriteStream, Dirent, renameSync } from "fs" +import { createWriteStream, Dirent, renameSync, existsSync } from "fs" import { pipeline } from "node:stream" import { promisify } from "node:util" import fetch from "node-fetch" @@ -537,20 +537,33 @@ const setup = async (cmd: { template?: string; auth?: string }) => { `clock` ) spinner.start() - await zKey.newZKey( - r1csLocalPathAndFileName, - getPotLocalFilePath(circuit.files.potFilename), - zkeyLocalPathAndFileName, - undefined - ) - spinner.succeed( - `Generation of the genesis zKey for citcui ${theme.text.bold(circuit.name)} completed successfully` - ) + if (existsSync(zkeyLocalPathAndFileName)) { + spinner.succeed( + `The genesis zKey for circuit ${theme.text.bold(circuit.name)} is already present on disk` + ) + } else { + await zKey.newZKey( + r1csLocalPathAndFileName, + getPotLocalFilePath(circuit.files.potFilename), + zkeyLocalPathAndFileName, + undefined + ) + spinner.succeed( + `Generation of the genesis zKey for circuit ${theme.text.bold(circuit.name)} completed successfully` + ) + } + + const hashSpinner = customSpinner( + `Calculating hashes for circuit ${theme.text.bold(circuit.name)}...`, + `clock` + ) + hashSpinner.start() // 4. calculate the hashes const wasmBlake2bHash = await blake512FromPath(wasmLocalPathAndFileName) const potBlake2bHash = await blake512FromPath(getPotLocalFilePath(circuit.files.potFilename)) const initialZkeyBlake2bHash = await blake512FromPath(zkeyLocalPathAndFileName) + hashSpinner.succeed(`Hashes for circuit ${theme.text.bold(circuit.name)} calculated successfully`) // 5. upload the artifacts