Skip to content

Commit

Permalink
Merge pull request #330 from privacy-scaling-explorations/dev
Browse files Browse the repository at this point in the history
bump to 1.2.5
  • Loading branch information
NicoSerranoP authored Sep 24, 2024
2 parents 4d91ce6 + 3f25ebe commit 0a3fe56
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 25 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.



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





## [1.2.3](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.2.2...v1.2.3) (2024-04-10)


Expand Down
8 changes: 8 additions & 0 deletions packages/actions/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.



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





## [1.2.0](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.1.1...v1.2.0) (2024-04-05)

**Note:** Version bump only for package @p0tion/actions
Expand Down
8 changes: 8 additions & 0 deletions packages/backend/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.



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





## [1.2.3](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.2.2...v1.2.3) (2024-04-10)

**Note:** Version bump only for package @p0tion/backend
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@p0tion/backend",
"version": "1.2.4",
"version": "1.2.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
50 changes: 35 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 @@ -563,6 +563,19 @@ export const verifycontribution = functionsV2.https.onCall(

const verificationTaskTimer = new Timer({ label: `${ceremonyId}-${circuitId}-${participantDoc.id}` })

const dumpLog = async (path: string) => {
const fs = require('fs');
printLog(`transcript >>>>>>`, LogLevel.DEBUG)
fs.readFile(path, 'utf8', (err: any, data: any) => {
if (err) {
printLog(err, LogLevel.ERROR);
return;
}
printLog(data, LogLevel.DEBUG);
});

}

const completeVerification = async () => {
// Stop verification task timer.
printLog("Completing verification", LogLevel.DEBUG)
Expand Down Expand Up @@ -769,7 +782,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 +830,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 All @@ -828,12 +841,17 @@ export const verifycontribution = functionsV2.https.onCall(

const potStoragePath = getPotStorageFilePath(files.potFilename)
const firstZkeyStoragePath = getZkeyStorageFilePath(prefix, `${prefix}_${genesisZkeyIndex}.zkey`)
printLog(`pot file: ${potStoragePath}`, LogLevel.DEBUG)
printLog(`zkey file: ${firstZkeyStoragePath}`, LogLevel.DEBUG)
// Prepare temporary file paths.
// (nb. these are needed to download the necessary artifacts for verification from AWS S3).
verificationTranscriptTemporaryLocalPath = createTemporaryLocalPath(verificationTranscriptCompleteFilename)
const potTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}.pot`)
const firstZkeyTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}_genesis.zkey`)
const lastZkeyTempFilePath = createTemporaryLocalPath(`${circuitId}_${participantDoc.id}_last.zkey`)
printLog(`pot file: ${potTempFilePath}`, LogLevel.DEBUG)
printLog(`firstZkey file: ${firstZkeyTempFilePath}`, LogLevel.DEBUG)
printLog(`last zkey file: ${lastZkeyTempFilePath}`, LogLevel.DEBUG)

// Create and populate transcript.
const transcriptLogger = createCustomLoggerForFile(verificationTranscriptTemporaryLocalPath)
Expand All @@ -858,6 +876,8 @@ export const verifycontribution = functionsV2.https.onCall(
transcriptLogger
)

dumpLog(verificationTranscriptTemporaryLocalPath)

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

Expand Down Expand Up @@ -957,8 +977,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
18 changes: 9 additions & 9 deletions packages/backend/src/functions/timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const checkAndRemoveBlockingContributor = functions
// Do not use `logAndThrowError` method to avoid the function to exit before checking every ceremony.
printLog(
`No current contributor for circuit ${circuit.id} - ceremony ${ceremony.id}`,
LogLevel.WARN
LogLevel.DEBUG
)
else if (
avgFullContribution === 0 &&
Expand Down Expand Up @@ -155,19 +155,19 @@ export const checkAndRemoveBlockingContributor = functions
)
timeoutType = TimeoutType.BLOCKING_CLOUD_FUNCTION

printLog(
`${timeoutType} detected for circuit ${circuit.id} - ceremony ${ceremony.id}`,
LogLevel.DEBUG
)

if (!timeoutType)
// Do not use `logAndThrowError` method to avoid the function to exit before checking every ceremony.
printLog(
`No timeout for circuit ${circuit.id} - ceremony ${ceremony.id}`,
LogLevel.WARN
LogLevel.DEBUG
)
else {
// Case (E).
printLog(
`${timeoutType} detected for circuit ${circuit.id} - ceremony ${ceremony.id}`,
LogLevel.WARN
)

// Case (E).
let nextCurrentContributorId = ""

// Prepare Firestore batch of txs.
Expand Down Expand Up @@ -235,7 +235,7 @@ export const checkAndRemoveBlockingContributor = functions

printLog(
`The contributor ${participant.id} has been identified as potential blocking contributor. A timeout of type ${timeoutType} has been triggered w/ a penalty of ${timeoutPenaltyInMs} ms`,
LogLevel.DEBUG
LogLevel.WARN
)
}
}
Expand Down
8 changes: 8 additions & 0 deletions packages/phase2cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.



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





## [1.2.4](https://github.com/privacy-scaling-explorations/p0tion/compare/v1.2.3...v1.2.2) (2024-07-06)


Expand Down

0 comments on commit 0a3fe56

Please sign in to comment.