Skip to content

Commit

Permalink
Merge pull request #324 from privacy-scaling-explorations/fix-current…
Browse files Browse the repository at this point in the history
…Contributor-bug

fix: adjusts conditions to rigger coordinate function
  • Loading branch information
glamperd authored Sep 2, 2024
2 parents f688bf4 + 45438fa commit 7045762
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions packages/backend/src/functions/circuit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const coordinate = async (
if (isSingleParticipantCoordination) {
// Scenario (A).
if (emptyWaitingQueue) {
printLog(`Coordinate - executing scenario A - emptyWaitingQueue`, LogLevel.DEBUG)
printLog(`Coordinate - executing scenario A - emptyWaitingQueue`, LogLevel.INFO)

// Update.
newCurrentContributorId = participant.id
Expand All @@ -127,7 +127,7 @@ const coordinate = async (
else if (participantResumingAfterTimeoutExpiration) {
printLog(
`Coordinate - executing scenario A - single - participantResumingAfterTimeoutExpiration`,
LogLevel.DEBUG
LogLevel.INFO
)

newParticipantStatus = ParticipantStatus.CONTRIBUTING
Expand All @@ -136,7 +136,7 @@ const coordinate = async (
}
// Scenario (B).
else if (participantIsNotCurrentContributor) {
printLog(`Coordinate - executing scenario B - single - participantIsNotCurrentContributor`, LogLevel.DEBUG)
printLog(`Coordinate - executing scenario B - single - participantIsNotCurrentContributor`, LogLevel.INFO)

newCurrentContributorId = currentContributor
newParticipantStatus = ParticipantStatus.WAITING
Expand All @@ -160,7 +160,7 @@ const coordinate = async (
} else if (participantIsCurrentContributor && participantCompletedOneOrAllContributions && !!ceremonyId) {
printLog(
`Coordinate - executing scenario C - multi - participantIsCurrentContributor && participantCompletedOneOrAllContributions`,
LogLevel.DEBUG
LogLevel.INFO
)

newParticipantStatus = ParticipantStatus.CONTRIBUTING
Expand Down Expand Up @@ -190,7 +190,7 @@ const coordinate = async (

printLog(
`Participant ${newCurrentContributorId} is the new current contributor for circuit ${circuit.id}`,
LogLevel.DEBUG
LogLevel.INFO
)
}
}
Expand Down Expand Up @@ -346,10 +346,10 @@ export const coordinateCeremonyParticipant = functionsV1
contributionStep: changedContributionStep
} = changedParticipant.data()!

printLog(`Coordinate participant ${exParticipant.id} for ceremony ${ceremonyId}`, LogLevel.DEBUG)
printLog(`Coordinate participant ${exParticipant.id} for ceremony ${ceremonyId}`, LogLevel.INFO)
printLog(
`Participant status: ${prevStatus} => ${changedStatus} - Participant contribution step: ${prevContributionStep} => ${changedContributionStep}`,
LogLevel.DEBUG
LogLevel.INFO
)

// Define pre-conditions.
Expand All @@ -370,8 +370,8 @@ export const coordinateCeremonyParticipant = functionsV1

const participantCompletedContribution =
prevContributionProgress === changedContributionProgress &&
prevStatus === ParticipantStatus.CONTRIBUTING &&
prevContributionStep === ParticipantContributionStep.VERIFYING &&
(prevStatus === ParticipantStatus.CONTRIBUTING ||
prevContributionStep === ParticipantContributionStep.VERIFYING) &&
changedStatus === ParticipantStatus.CONTRIBUTED &&
changedContributionStep === ParticipantContributionStep.COMPLETED

Expand All @@ -384,7 +384,7 @@ export const coordinateCeremonyParticipant = functionsV1
// Step (2.A).
printLog(
`Participant is ready for first contribution (${participantReadyForFirstContribution}) or for the next contribution (${participantReadyForNextContribution}) or is resuming after a timeout expiration (${participantResumingContributionAfterTimeout})`,
LogLevel.DEBUG
LogLevel.INFO
)

// Get the circuit.
Expand All @@ -398,7 +398,7 @@ export const coordinateCeremonyParticipant = functionsV1
// Step (2.B).
printLog(
`Participant completed a contribution (${participantCompletedContribution}) or every contribution for each circuit (${participantCompletedEveryCircuitContribution})`,
LogLevel.DEBUG
LogLevel.INFO
)

// Get the circuit.
Expand Down Expand Up @@ -769,7 +769,7 @@ export const verifycontribution = functionsV2.https.onCall(
} of circuit ${circuitId} (ceremony ${ceremonyId}) has been verified as ${
isContributionValid ? "valid" : "invalid"
} for the participant ${participantDoc.id}`,
LogLevel.DEBUG
LogLevel.INFO
)
}

Expand Down Expand Up @@ -817,7 +817,7 @@ export const verifycontribution = functionsV2.https.onCall(
})
.catch((error: any) => {
// Command execution aborted.
printLog(`Command ${commandId} execution has been aborted - Error ${error}`, LogLevel.DEBUG)
printLog(`Command ${commandId} execution has been aborted - Error ${error}`, LogLevel.WARN)

logAndThrowError(COMMON_ERRORS.CM_INVALID_COMMAND_EXECUTION)
})
Expand Down Expand Up @@ -957,8 +957,8 @@ export const refreshParticipantAfterContributionVerification = functionsV1
await batch.commit()

printLog(
`Participant ${participantId} refreshed after contribution ${createdContribution.id} - The participant was finalizing the ceremony ${isFinalizing}`,
LogLevel.DEBUG
`Participant ${participantId} refreshed after contribution ${createdContribution.id} - The participant was finalizing the ceremony? ${isFinalizing}`,
LogLevel.INFO
)
})

Expand Down

0 comments on commit 7045762

Please sign in to comment.