From 80d985887b3dd5966b3e98cd7a8fac19b8aa2658 Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Wed, 7 Jun 2023 10:35:23 +0100 Subject: [PATCH] fix(ux): added more verbose messages to inform the user of waiting times and errors --- packages/phase2cli/src/commands/contribute.ts | 10 ++++- packages/phase2cli/src/lib/utils.ts | 37 +++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/packages/phase2cli/src/commands/contribute.ts b/packages/phase2cli/src/commands/contribute.ts index 3bd18fb9..99fcaf9d 100644 --- a/packages/phase2cli/src/commands/contribute.ts +++ b/packages/phase2cli/src/commands/contribute.ts @@ -890,9 +890,17 @@ const contribute = async () => { const spinner = customSpinner(`Verifying your participant status...`, `clock`) spinner.start() + // Check that the user's document is created + const userDoc = await getDocumentById(firestoreDatabase, commonTerms.collections.users.name, user.uid) + const userData = userDoc.data() + if (!userData) { + spinner.fail(`Unfortunately we could not find a user document with your information. This likely means that you did not pass the GitHub reputation checks and therefore are not elegible to contribute to any ceremony. Please contact the coordinator if you believe this to be an error.`) + process.exit(0) + } + // Check the user's current participant readiness for contribution status (eligible, already contributed, timed out). const canParticipantContributeToCeremony = await checkParticipantForCeremony(firebaseFunctions, selectedCeremony.id) - + await sleep(2000) // wait for CF execution. // Get updated participant data. diff --git a/packages/phase2cli/src/lib/utils.ts b/packages/phase2cli/src/lib/utils.ts index 17604355..e255302a 100644 --- a/packages/phase2cli/src/lib/utils.ts +++ b/packages/phase2cli/src/lib/utils.ts @@ -316,7 +316,7 @@ export const generateCustomUrlToTweetAboutParticipation = ( ) => isFinalizing ? `https://twitter.com/intent/tweet?text=I%20have%20finalized%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20view%20my%20final%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP%20#PSE` - : `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20contribute%20here:%20https://github.com/quadratic-funding/mpc-phase2-suite%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP` + : `https://twitter.com/intent/tweet?text=I%20contributed%20to%20the%20${ceremonyName}%20Phase%202%20Trusted%20Setup%20ceremony!%20You%20can%20contribute%20here:%20https://github.com/privacy-scaling-explorations/p0tion%20You%20can%20view%20my%20attestation%20here:%20${gistUrl}%20#Ethereum%20#ZKP` /** * Return a custom progress bar. @@ -543,8 +543,8 @@ export const handleStartOrResumeContribution = async ( const spinner = customSpinner( `${ participantData.contributionStep === ParticipantContributionStep.DOWNLOADING - ? `Preparing to begin the contribution...` - : `Preparing to resume contribution` + ? `Preparing to begin the contribution. Please note that the contribution can take a long time depending on the size of the circuits and your internet connection.` + : `Preparing to resume contribution. Please note that the contribution can take a long time depending on the size of the circuits and your internet connection.` }`, `clock` ) @@ -687,7 +687,7 @@ export const handleStartOrResumeContribution = async ( if (isFinalizing || participantData.contributionStep === ParticipantContributionStep.UPLOADING) { spinner.text = `Uploading ${isFinalizing ? "final" : "your"} contribution ${ !isFinalizing ? theme.text.bold(`#${nextZkeyIndex}`) : "" - } to storage...` + } to storage. Please note that this step might take a while depending on your connection speed and the zKey's size` spinner.start() if (!isFinalizing) @@ -712,7 +712,7 @@ export const handleStartOrResumeContribution = async ( spinner.succeed( `${ isFinalizing ? `Contribution` : `Contribution ${theme.text.bold(`#${nextZkeyIndex}`)}` - } correctly saved on storage` + } correctly saved to storage` ) // Advance to next contribution step (VERIFYING) if not finalizing. @@ -735,7 +735,7 @@ export const handleStartOrResumeContribution = async ( const { seconds, minutes, hours } = getSecondsMinutesHoursFromMillis(avgTimings.verifyCloudFunction) process.stdout.write( - `${theme.symbols.info} Your contribution is under verification ${ + `${theme.symbols.info} Your contribution is under verification. Please note that this step can take up to one hour, depending on the cicuit size ${ avgTimings.verifyCloudFunction > 0 ? `(~ ${theme.text.bold( `${convertToDoubleDigits(hours)}:${convertToDoubleDigits(minutes)}:${convertToDoubleDigits( @@ -746,14 +746,21 @@ export const handleStartOrResumeContribution = async ( }` ) - // Execute contribution verification. - await verifyContribution( - cloudFunctions, - ceremony.id, - circuit, - bucketName, - contributorOrCoordinatorIdentifier, - String(process.env.FIREBASE_CF_URL_VERIFY_CONTRIBUTION) - ) + try { + // Execute contribution verification. + await verifyContribution( + cloudFunctions, + ceremony.id, + circuit, + bucketName, + contributorOrCoordinatorIdentifier, + String(process.env.FIREBASE_CF_URL_VERIFY_CONTRIBUTION) + ) + } catch(error: any) { + process.stdout.write( + `\n${theme.symbols.error} ${theme.text.bold("Unfortunately there was an error with the contribution verification. Please restart phase2cli and try again. If the problem persists, please contact the ceremony coordinator.")}\n` + ) + } + } }