@devtion/devcli 0.0.0-7e983e3 → 0.0.0-8bb9489
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/.env +3 -3
- package/dist/index.js +106 -76
- package/dist/types/commands/contribute.d.ts +1 -1
- package/dist/types/commands/finalize.d.ts +4 -3
- package/dist/types/commands/observe.d.ts +1 -1
- package/dist/types/commands/setup.d.ts +2 -2
- package/dist/types/lib/prompts.d.ts +6 -6
- package/dist/types/lib/utils.d.ts +3 -2
- package/package.json +4 -3
- package/src/commands/auth.ts +23 -8
- package/src/commands/contribute.ts +12 -9
- package/src/commands/finalize.ts +19 -10
- package/src/commands/index.ts +1 -1
- package/src/commands/listCeremonies.ts +2 -3
- package/src/commands/observe.ts +3 -3
- package/src/commands/setup.ts +41 -43
- package/src/commands/validate.ts +2 -3
- package/src/index.ts +17 -8
- package/src/lib/localConfigs.ts +1 -1
- package/src/lib/prompts.ts +21 -20
- package/src/lib/services.ts +1 -3
- package/src/lib/utils.ts +42 -8
package/src/lib/prompts.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
CircuitContributionVerificationMechanism,
|
|
15
15
|
vmConfigurationTypes,
|
|
16
16
|
DiskTypeForVM
|
|
17
|
-
} from "@
|
|
17
|
+
} from "@devtion/actions"
|
|
18
18
|
import theme from "./theme.js"
|
|
19
19
|
import { COMMAND_ERRORS, showError } from "./errors.js"
|
|
20
20
|
|
|
@@ -203,7 +203,7 @@ export const promptCircomCompiler = async (): Promise<CircomCompilerData> => {
|
|
|
203
203
|
* Shows a list of circuits for a single option selection.
|
|
204
204
|
* @dev the circuit names are derived from local R1CS files.
|
|
205
205
|
* @param options <Array<string>> - an array of circuits names.
|
|
206
|
-
* @returns Promise<string> - the name of the
|
|
206
|
+
* @returns Promise<string> - the name of the chosen circuit.
|
|
207
207
|
*/
|
|
208
208
|
export const promptCircuitSelector = async (options: Array<string>): Promise<string> => {
|
|
209
209
|
const { circuitFilename } = await prompts({
|
|
@@ -223,7 +223,7 @@ export const promptCircuitSelector = async (options: Array<string>): Promise<str
|
|
|
223
223
|
* Shows a list of standard EC2 VM instance types for a single option selection.
|
|
224
224
|
* @notice the suggested VM configuration type is calculated based on circuit constraint size.
|
|
225
225
|
* @param constraintSize <number> - the amount of circuit constraints
|
|
226
|
-
* @returns Promise<string> - the name of the
|
|
226
|
+
* @returns Promise<string> - the name of the chosen VM type.
|
|
227
227
|
*/
|
|
228
228
|
export const promptVMTypeSelector = async (constraintSize): Promise<string> => {
|
|
229
229
|
let suggestedConfiguration: number = 0
|
|
@@ -325,7 +325,7 @@ export const promptVMDiskTypeSelector = async (): Promise<DiskTypeForVM> => {
|
|
|
325
325
|
/**
|
|
326
326
|
* Show a series of questions about the circuits.
|
|
327
327
|
* @param constraintSize <number> - the amount of circuit constraints.
|
|
328
|
-
* @param timeoutMechanismType <CeremonyTimeoutType> - the
|
|
328
|
+
* @param timeoutMechanismType <CeremonyTimeoutType> - the chosen timeout mechanism type for the ceremony.
|
|
329
329
|
* @param needPromptCircomCompiler <boolean> - a boolean value indicating if the questions related to the Circom compiler version and commit hash must be asked.
|
|
330
330
|
* @param enforceVM <boolean> - a boolean value indicating if the contribution verification could be supported by VM-only approach or not.
|
|
331
331
|
* @returns Promise<Array<Circuit>> - circuit info prompted by the coordinator.
|
|
@@ -343,7 +343,7 @@ export const promptCircuitInputData = async (
|
|
|
343
343
|
let circomVersion: string = ""
|
|
344
344
|
let circomCommitHash: string = ""
|
|
345
345
|
let circuitInputData: CircuitInputData
|
|
346
|
-
let
|
|
346
|
+
let cfOrVm: CircuitContributionVerificationMechanism
|
|
347
347
|
let vmDiskType: DiskTypeForVM
|
|
348
348
|
let vmConfigurationType: string = ""
|
|
349
349
|
|
|
@@ -422,19 +422,24 @@ export const promptCircuitInputData = async (
|
|
|
422
422
|
circomCommitHash = commitHash
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
-
// Ask for
|
|
425
|
+
// Ask for preferred contribution verification method (CF vs VM).
|
|
426
426
|
if (!enforceVM) {
|
|
427
427
|
const { confirmation } = await askForConfirmation(
|
|
428
428
|
`The contribution verification can be performed using Cloud Functions (CF, cheaper for small contributions but limited to 1M constraints) or custom virtual machines (expensive but could scale up to 30M constraints). Be aware about VM costs and if you wanna learn more, please visit the documentation to have a complete overview about cost estimation of the two mechanisms.\nChoose the contribution verification mechanism`,
|
|
429
429
|
`CF`, // eq. true.
|
|
430
430
|
`VM` // eq. false.
|
|
431
431
|
)
|
|
432
|
-
|
|
433
|
-
|
|
432
|
+
cfOrVm = confirmation
|
|
433
|
+
? CircuitContributionVerificationMechanism.CF
|
|
434
|
+
: CircuitContributionVerificationMechanism.VM
|
|
434
435
|
|
|
435
|
-
|
|
436
|
+
} else {
|
|
437
|
+
cfOrVm = CircuitContributionVerificationMechanism.VM
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
if (cfOrVm === undefined) showError(COMMAND_ERRORS.COMMAND_ABORT_PROMPT, true)
|
|
436
441
|
|
|
437
|
-
if (
|
|
442
|
+
if (cfOrVm === CircuitContributionVerificationMechanism.VM) {
|
|
438
443
|
// Ask for selecting the specific VM configuration type.
|
|
439
444
|
vmConfigurationType = await promptVMTypeSelector(constraintSize)
|
|
440
445
|
|
|
@@ -478,9 +483,7 @@ export const promptCircuitInputData = async (
|
|
|
478
483
|
paramsConfiguration: circuitConfigurationValues
|
|
479
484
|
},
|
|
480
485
|
verification: {
|
|
481
|
-
cfOrVm
|
|
482
|
-
? CircuitContributionVerificationMechanism.CF
|
|
483
|
-
: CircuitContributionVerificationMechanism.VM,
|
|
486
|
+
cfOrVm,
|
|
484
487
|
vm: {
|
|
485
488
|
vmConfigurationType,
|
|
486
489
|
vmDiskType
|
|
@@ -520,9 +523,7 @@ export const promptCircuitInputData = async (
|
|
|
520
523
|
paramsConfiguration: circuitConfigurationValues
|
|
521
524
|
},
|
|
522
525
|
verification: {
|
|
523
|
-
cfOrVm
|
|
524
|
-
? CircuitContributionVerificationMechanism.CF
|
|
525
|
-
: CircuitContributionVerificationMechanism.VM,
|
|
526
|
+
cfOrVm,
|
|
526
527
|
vm: {
|
|
527
528
|
vmConfigurationType,
|
|
528
529
|
vmDiskType
|
|
@@ -586,7 +587,7 @@ export const promptCircuitAddition = async (): Promise<boolean> => {
|
|
|
586
587
|
* Shows a list of pre-computed zKeys for a single option selection.
|
|
587
588
|
* @dev the names are derived from local zKeys files.
|
|
588
589
|
* @param options <Array<string>> - an array of pre-computed zKeys names.
|
|
589
|
-
* @returns Promise<string> - the name of the
|
|
590
|
+
* @returns Promise<string> - the name of the chosen pre-computed zKey.
|
|
590
591
|
*/
|
|
591
592
|
export const promptPreComputedZkeySelector = async (options: Array<string>): Promise<string> => {
|
|
592
593
|
const { preComputedZkeyFilename } = await prompts({
|
|
@@ -633,13 +634,13 @@ export const promptNeededPowersForCircuit = async (suggestedSmallestNeededPowers
|
|
|
633
634
|
* Shows a list of PoT files for a single option selection.
|
|
634
635
|
* @dev the names are derived from local PoT files.
|
|
635
636
|
* @param options <Array<string>> - an array of PoT file names.
|
|
636
|
-
* @returns Promise<string> - the name of the
|
|
637
|
+
* @returns Promise<string> - the name of the chosen PoT.
|
|
637
638
|
*/
|
|
638
639
|
export const promptPotSelector = async (options: Array<string>): Promise<string> => {
|
|
639
640
|
const { potFilename } = await prompts({
|
|
640
641
|
type: "select",
|
|
641
642
|
name: "potFilename",
|
|
642
|
-
message: theme.text.bold("Select the Powers of Tau file
|
|
643
|
+
message: theme.text.bold("Select the Powers of Tau file chosen for the circuit"),
|
|
643
644
|
choices: options.map((option: string) => {
|
|
644
645
|
console.log(option)
|
|
645
646
|
return { title: option, value: option }
|
|
@@ -731,7 +732,7 @@ export const promptToTypeEntropyOrBeacon = async (isEntropy = true): Promise<str
|
|
|
731
732
|
* @return <Promise<string>> - the entropy.
|
|
732
733
|
*/
|
|
733
734
|
export const promptForEntropy = async (): Promise<string> => {
|
|
734
|
-
// Prompt for entropy generation
|
|
735
|
+
// Prompt for entropy generation preferred method.
|
|
735
736
|
const { confirmation } = await askForConfirmation(
|
|
736
737
|
`Do you prefer to type your entropy or generate it randomly?`,
|
|
737
738
|
"Manually",
|
package/src/lib/services.ts
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
getCurrentFirebaseAuthUser,
|
|
3
3
|
initializeFirebaseCoreServices,
|
|
4
4
|
signInToFirebaseWithCredentials
|
|
5
|
-
} from "@
|
|
5
|
+
} from "@devtion/actions"
|
|
6
6
|
import clear from "clear"
|
|
7
7
|
import figlet from "figlet"
|
|
8
8
|
import { FirebaseApp } from "firebase/app"
|
|
@@ -117,8 +117,6 @@ export const signInToFirebase = async (firebaseApp: FirebaseApp, credentials: OA
|
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
|
|
121
|
-
|
|
122
120
|
/**
|
|
123
121
|
* Ensure that the callee is an authenticated user.
|
|
124
122
|
* @notice The token will be passed as parameter.
|
package/src/lib/utils.ts
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
permanentlyStoreCurrentContributionTimeAndHash,
|
|
20
20
|
progressToNextContributionStep,
|
|
21
21
|
verifyContribution
|
|
22
|
-
} from "@
|
|
22
|
+
} from "@devtion/actions"
|
|
23
23
|
import { Presets, SingleBar } from "cli-progress"
|
|
24
24
|
import dotenv from "dotenv"
|
|
25
25
|
import { GithubAuthProvider, OAuthCredential } from "firebase/auth"
|
|
@@ -311,8 +311,22 @@ export const generateCustomUrlToTweetAboutParticipation = (
|
|
|
311
311
|
isFinalizing: boolean
|
|
312
312
|
) =>
|
|
313
313
|
isFinalizing
|
|
314
|
-
? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}
|
|
315
|
-
|
|
314
|
+
? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}${
|
|
315
|
+
ceremonyName.toLowerCase().includes("trusted") ||
|
|
316
|
+
ceremonyName.toLowerCase().includes("setup") ||
|
|
317
|
+
ceremonyName.toLowerCase().includes("phase2") ||
|
|
318
|
+
ceremonyName.toLowerCase().includes("ceremony")
|
|
319
|
+
? "!"
|
|
320
|
+
: "%20Phase%202%20Trusted%20Setup%20ceremony!"
|
|
321
|
+
}%20You%20can%20view%20my%20final%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP%20#PSE`
|
|
322
|
+
: `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}${
|
|
323
|
+
ceremonyName.toLowerCase().includes("trusted") ||
|
|
324
|
+
ceremonyName.toLowerCase().includes("setup") ||
|
|
325
|
+
ceremonyName.toLowerCase().includes("phase2") ||
|
|
326
|
+
ceremonyName.toLowerCase().includes("ceremony")
|
|
327
|
+
? "!"
|
|
328
|
+
: "%20Phase%202%20Trusted%20Setup%20ceremony!"
|
|
329
|
+
}%20You%20can%20view%20the%20steps%20to%20contribute%20here:%20https://ceremony.pse.dev%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP`
|
|
316
330
|
|
|
317
331
|
/**
|
|
318
332
|
* Return a custom progress bar.
|
|
@@ -521,6 +535,7 @@ export const getLatestUpdatesFromParticipant = async (
|
|
|
521
535
|
* @param entropyOrBeaconHash <string> - the entropy or beacon hash (only when finalizing) for the contribution.
|
|
522
536
|
* @param contributorOrCoordinatorIdentifier <string> - the identifier of the contributor or coordinator (only when finalizing).
|
|
523
537
|
* @param isFinalizing <boolean> - flag to discriminate between ceremony finalization (true) and contribution (false).
|
|
538
|
+
* @param circuitsLength <number> - the total number of circuits in the ceremony.
|
|
524
539
|
*/
|
|
525
540
|
export const handleStartOrResumeContribution = async (
|
|
526
541
|
cloudFunctions: Functions,
|
|
@@ -530,7 +545,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
530
545
|
participant: FirebaseDocumentInfo,
|
|
531
546
|
entropyOrBeaconHash: any,
|
|
532
547
|
contributorOrCoordinatorIdentifier: string,
|
|
533
|
-
isFinalizing: boolean
|
|
548
|
+
isFinalizing: boolean,
|
|
549
|
+
circuitsLength: number
|
|
534
550
|
): Promise<void> => {
|
|
535
551
|
// Extract data.
|
|
536
552
|
const { prefix: ceremonyPrefix } = ceremony.data
|
|
@@ -538,7 +554,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
538
554
|
const { completedContributions } = waitingQueue // = current progress.
|
|
539
555
|
|
|
540
556
|
console.log(
|
|
541
|
-
`${theme.text.bold(
|
|
557
|
+
`${theme.text.bold(
|
|
558
|
+
`\n- Circuit # ${theme.colors.magenta(`${sequencePosition}/${circuitsLength}`)}`
|
|
559
|
+
)} (Contribution Steps)`
|
|
542
560
|
)
|
|
543
561
|
|
|
544
562
|
// Get most up-to-date data from the participant document.
|
|
@@ -607,6 +625,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
607
625
|
`${theme.symbols.success} Contribution ${theme.text.bold(`#${lastZkeyIndex}`)} correctly downloaded`
|
|
608
626
|
)
|
|
609
627
|
|
|
628
|
+
await sleep(3000)
|
|
629
|
+
|
|
610
630
|
// Advance to next contribution step (COMPUTING) if not finalizing.
|
|
611
631
|
if (!isFinalizing) {
|
|
612
632
|
spinner.text = `Preparing for contribution computation...`
|
|
@@ -650,6 +670,8 @@ export const handleStartOrResumeContribution = async (
|
|
|
650
670
|
// Format contribution hash.
|
|
651
671
|
const contributionHash = matchContributionHash?.at(0)?.replace("\n\t\t", "")!
|
|
652
672
|
|
|
673
|
+
await sleep(500)
|
|
674
|
+
|
|
653
675
|
// Make request to cloud functions to permanently store the information.
|
|
654
676
|
await permanentlyStoreCurrentContributionTimeAndHash(
|
|
655
677
|
cloudFunctions,
|
|
@@ -675,6 +697,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
675
697
|
)}`
|
|
676
698
|
)
|
|
677
699
|
|
|
700
|
+
// ensure the previous step is completed
|
|
701
|
+
await sleep(5000)
|
|
702
|
+
|
|
678
703
|
// Advance to next contribution step (UPLOADING) if not finalizing.
|
|
679
704
|
if (!isFinalizing) {
|
|
680
705
|
spinner.text = `Preparing for uploading the contribution...`
|
|
@@ -696,10 +721,12 @@ export const handleStartOrResumeContribution = async (
|
|
|
696
721
|
!isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : ""
|
|
697
722
|
} to storage.\n${
|
|
698
723
|
theme.symbols.warning
|
|
699
|
-
} This step may take a while based on circuit size and your
|
|
724
|
+
} This step may take a while based on circuit size and your internet speed. Everything's fine, just be patient.`
|
|
700
725
|
spinner.start()
|
|
701
726
|
|
|
702
|
-
|
|
727
|
+
const progressBar = customProgressBar(ProgressBarType.UPLOAD, `your contribution`)
|
|
728
|
+
|
|
729
|
+
if (!isFinalizing) {
|
|
703
730
|
await multiPartUpload(
|
|
704
731
|
cloudFunctions,
|
|
705
732
|
bucketName,
|
|
@@ -707,8 +734,12 @@ export const handleStartOrResumeContribution = async (
|
|
|
707
734
|
nextZkeyLocalFilePath,
|
|
708
735
|
Number(process.env.CONFIG_STREAM_CHUNK_SIZE_IN_MB),
|
|
709
736
|
ceremony.id,
|
|
710
|
-
participantData.tempContributionData
|
|
737
|
+
participantData.tempContributionData,
|
|
738
|
+
progressBar
|
|
711
739
|
)
|
|
740
|
+
|
|
741
|
+
progressBar.stop()
|
|
742
|
+
}
|
|
712
743
|
else
|
|
713
744
|
await multiPartUpload(
|
|
714
745
|
cloudFunctions,
|
|
@@ -718,6 +749,9 @@ export const handleStartOrResumeContribution = async (
|
|
|
718
749
|
Number(process.env.CONFIG_STREAM_CHUNK_SIZE_IN_MB)
|
|
719
750
|
)
|
|
720
751
|
|
|
752
|
+
// small sleep to ensure the previous step is completed
|
|
753
|
+
await sleep(5000)
|
|
754
|
+
|
|
721
755
|
spinner.succeed(
|
|
722
756
|
`${
|
|
723
757
|
isFinalizing ? `Contribution` : `Contribution ${theme.text.bold(`#${nextZkeyIndex}`)}`
|