@devtion/backend 0.0.0-eb3bb7d → 0.0.0-f3ea056

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/backend
3
- * @version 1.0.5
2
+ * @module @devtion/backend
3
+ * @version 1.0.6
4
4
  * @file MPC Phase 2 backend for Firebase services management
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -11,7 +11,7 @@
11
11
  var admin = require('firebase-admin');
12
12
  var functions = require('firebase-functions');
13
13
  var dotenv = require('dotenv');
14
- var actions = require('@p0tion/actions');
14
+ var actions = require('@devtion/actions');
15
15
  var htmlEntities = require('html-entities');
16
16
  var firestore = require('firebase-admin/firestore');
17
17
  var clientS3 = require('@aws-sdk/client-s3');
@@ -733,7 +733,7 @@ const setupCeremony = functions__namespace
733
733
  // Check if using the VM approach for contribution verification.
734
734
  if (circuit.verification.cfOrVm === "VM" /* CircuitContributionVerificationMechanism.VM */) {
735
735
  // VM command to be run at the startup.
736
- const startupCommand = actions.vmBootstrapCommand(bucketName);
736
+ const startupCommand = actions.vmBootstrapCommand(`${bucketName}/circuits/${circuit.name}`);
737
737
  // Get EC2 client.
738
738
  const ec2Client = await createEC2Client();
739
739
  // Get AWS variables.
@@ -742,7 +742,8 @@ const setupCeremony = functions__namespace
742
742
  const vmCommands = actions.vmDependenciesAndCacheArtifactsCommand(`${bucketName}/${circuit.files?.initialZkeyStoragePath}`, `${bucketName}/${circuit.files?.potStoragePath}`, snsTopic, region);
743
743
  printLog(`Check VM dependencies and cache artifacts commands ${vmCommands.join("\n")}`, LogLevel.DEBUG);
744
744
  // Upload the post-startup commands script file.
745
- await uploadFileToBucketNoFile(bucketName, actions.vmBootstrapScriptFilename, vmCommands.join("\n"));
745
+ printLog(`Uploading VM post-startup commands script file ${actions.vmBootstrapScriptFilename}`, LogLevel.DEBUG);
746
+ await uploadFileToBucketNoFile(bucketName, `circuits/${circuit.name}/${actions.vmBootstrapScriptFilename}`, vmCommands.join("\n"));
746
747
  // Compute the VM disk space requirement (in GB).
747
748
  const vmDiskSize = actions.computeDiskSizeForVM(circuit.zKeySizeInBytes, circuit.metadata?.pot);
748
749
  printLog(`Check VM startup commands ${startupCommand.join("\n")}`, LogLevel.DEBUG);
@@ -1647,8 +1648,6 @@ const verifycontribution = functionsV2__namespace.https.onCall({ memory: "16GiB"
1647
1648
  lastZkeyBlake2bHash = match.at(0);
1648
1649
  // re upload the formatted verification transcript
1649
1650
  await uploadFileToBucket(bucketName, verificationTranscriptStoragePathAndFilename, verificationTranscriptTemporaryLocalPath, true);
1650
- // Stop VM instance.
1651
- await actions.stopEC2Instance(ec2, vmInstanceId);
1652
1651
  }
1653
1652
  else {
1654
1653
  // Upload verification transcript.
@@ -1709,6 +1708,9 @@ const verifycontribution = functionsV2__namespace.https.onCall({ memory: "16GiB"
1709
1708
  lastUpdated: getCurrentServerTimestampInMillis()
1710
1709
  });
1711
1710
  }
1711
+ // Stop VM instance
1712
+ if (isUsingVM)
1713
+ await actions.stopEC2Instance(ec2, vmInstanceId);
1712
1714
  // Step (1.A.4.C)
1713
1715
  if (!isFinalizing) {
1714
1716
  // Step (1.A.4.C.1)
@@ -2563,7 +2565,8 @@ const resumeContributionAfterTimeoutExpiration = functions__namespace
2563
2565
  if (status === "EXHUMED" /* ParticipantStatus.EXHUMED */)
2564
2566
  await participantDoc.ref.update({
2565
2567
  status: "READY" /* ParticipantStatus.READY */,
2566
- lastUpdated: getCurrentServerTimestampInMillis()
2568
+ lastUpdated: getCurrentServerTimestampInMillis(),
2569
+ tempContributionData: {}
2567
2570
  });
2568
2571
  else
2569
2572
  logAndThrowError(SPECIFIC_ERRORS.SE_CONTRIBUTE_CANNOT_PROGRESS_TO_NEXT_CIRCUIT);
@@ -1,6 +1,6 @@
1
1
  /**
2
- * @module @p0tion/backend
3
- * @version 1.0.5
2
+ * @module @devtion/backend
3
+ * @version 1.0.6
4
4
  * @file MPC Phase 2 backend for Firebase services management
5
5
  * @copyright Ethereum Foundation 2022
6
6
  * @license MIT
@@ -9,7 +9,7 @@
9
9
  import admin from 'firebase-admin';
10
10
  import * as functions from 'firebase-functions';
11
11
  import dotenv from 'dotenv';
12
- import { getCircuitsCollectionPath, getTimeoutsCollectionPath, commonTerms, finalContributionIndex, getContributionsCollectionPath, githubReputation, getBucketName, vmBootstrapCommand, vmDependenciesAndCacheArtifactsCommand, vmBootstrapScriptFilename, computeDiskSizeForVM, createEC2Instance, getParticipantsCollectionPath, terminateEC2Instance, formatZkeyIndex, getTranscriptStorageFilePath, getZkeyStorageFilePath, startEC2Instance, vmContributionVerificationCommand, runCommandUsingSSM, getPotStorageFilePath, genesisZkeyIndex, createCustomLoggerForFile, blake512FromPath, getVerificationKeyStorageFilePath, getVerifierContractStorageFilePath, computeSHA256ToHex, retrieveCommandStatus, checkIfRunning, retrieveCommandOutput, stopEC2Instance, verificationKeyAcronym, verifierSmartContractAcronym } from '@p0tion/actions';
12
+ import { getCircuitsCollectionPath, getTimeoutsCollectionPath, commonTerms, finalContributionIndex, getContributionsCollectionPath, githubReputation, getBucketName, vmBootstrapCommand, vmDependenciesAndCacheArtifactsCommand, vmBootstrapScriptFilename, computeDiskSizeForVM, createEC2Instance, getParticipantsCollectionPath, terminateEC2Instance, formatZkeyIndex, getTranscriptStorageFilePath, getZkeyStorageFilePath, startEC2Instance, vmContributionVerificationCommand, runCommandUsingSSM, getPotStorageFilePath, genesisZkeyIndex, createCustomLoggerForFile, blake512FromPath, getVerificationKeyStorageFilePath, getVerifierContractStorageFilePath, computeSHA256ToHex, retrieveCommandStatus, checkIfRunning, retrieveCommandOutput, stopEC2Instance, verificationKeyAcronym, verifierSmartContractAcronym } from '@devtion/actions';
13
13
  import { encode } from 'html-entities';
14
14
  import { Timestamp, FieldValue } from 'firebase-admin/firestore';
15
15
  import { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadBucketCommand, CreateBucketCommand, PutPublicAccessBlockCommand, PutBucketCorsCommand, HeadObjectCommand, CreateMultipartUploadCommand, UploadPartCommand, CompleteMultipartUploadCommand } from '@aws-sdk/client-s3';
@@ -710,7 +710,7 @@ const setupCeremony = functions
710
710
  // Check if using the VM approach for contribution verification.
711
711
  if (circuit.verification.cfOrVm === "VM" /* CircuitContributionVerificationMechanism.VM */) {
712
712
  // VM command to be run at the startup.
713
- const startupCommand = vmBootstrapCommand(bucketName);
713
+ const startupCommand = vmBootstrapCommand(`${bucketName}/circuits/${circuit.name}`);
714
714
  // Get EC2 client.
715
715
  const ec2Client = await createEC2Client();
716
716
  // Get AWS variables.
@@ -719,7 +719,8 @@ const setupCeremony = functions
719
719
  const vmCommands = vmDependenciesAndCacheArtifactsCommand(`${bucketName}/${circuit.files?.initialZkeyStoragePath}`, `${bucketName}/${circuit.files?.potStoragePath}`, snsTopic, region);
720
720
  printLog(`Check VM dependencies and cache artifacts commands ${vmCommands.join("\n")}`, LogLevel.DEBUG);
721
721
  // Upload the post-startup commands script file.
722
- await uploadFileToBucketNoFile(bucketName, vmBootstrapScriptFilename, vmCommands.join("\n"));
722
+ printLog(`Uploading VM post-startup commands script file ${vmBootstrapScriptFilename}`, LogLevel.DEBUG);
723
+ await uploadFileToBucketNoFile(bucketName, `circuits/${circuit.name}/${vmBootstrapScriptFilename}`, vmCommands.join("\n"));
723
724
  // Compute the VM disk space requirement (in GB).
724
725
  const vmDiskSize = computeDiskSizeForVM(circuit.zKeySizeInBytes, circuit.metadata?.pot);
725
726
  printLog(`Check VM startup commands ${startupCommand.join("\n")}`, LogLevel.DEBUG);
@@ -1624,8 +1625,6 @@ const verifycontribution = functionsV2.https.onCall({ memory: "16GiB", timeoutSe
1624
1625
  lastZkeyBlake2bHash = match.at(0);
1625
1626
  // re upload the formatted verification transcript
1626
1627
  await uploadFileToBucket(bucketName, verificationTranscriptStoragePathAndFilename, verificationTranscriptTemporaryLocalPath, true);
1627
- // Stop VM instance.
1628
- await stopEC2Instance(ec2, vmInstanceId);
1629
1628
  }
1630
1629
  else {
1631
1630
  // Upload verification transcript.
@@ -1686,6 +1685,9 @@ const verifycontribution = functionsV2.https.onCall({ memory: "16GiB", timeoutSe
1686
1685
  lastUpdated: getCurrentServerTimestampInMillis()
1687
1686
  });
1688
1687
  }
1688
+ // Stop VM instance
1689
+ if (isUsingVM)
1690
+ await stopEC2Instance(ec2, vmInstanceId);
1689
1691
  // Step (1.A.4.C)
1690
1692
  if (!isFinalizing) {
1691
1693
  // Step (1.A.4.C.1)
@@ -2540,7 +2542,8 @@ const resumeContributionAfterTimeoutExpiration = functions
2540
2542
  if (status === "EXHUMED" /* ParticipantStatus.EXHUMED */)
2541
2543
  await participantDoc.ref.update({
2542
2544
  status: "READY" /* ParticipantStatus.READY */,
2543
- lastUpdated: getCurrentServerTimestampInMillis()
2545
+ lastUpdated: getCurrentServerTimestampInMillis(),
2546
+ tempContributionData: {}
2544
2547
  });
2545
2548
  else
2546
2549
  logAndThrowError(SPECIFIC_ERRORS.SE_CONTRIBUTE_CANNOT_PROGRESS_TO_NEXT_CIRCUIT);
@@ -1 +1 @@
1
- {"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../../../src/functions/ceremony.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuC/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kCAiBpB,CAAA;AAEN;;;;;GAKG;AACH,eAAO,MAAM,YAAY,kCAkBnB,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,aAAa,mDAyHpB,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,+BAA+B,oEAsCtC,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mDAiEvB,CAAA"}
1
+ {"version":3,"file":"ceremony.d.ts","sourceRoot":"","sources":["../../../src/functions/ceremony.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuC/C;;;;;GAKG;AACH,eAAO,MAAM,aAAa,kCAiBpB,CAAA;AAEN;;;;;GAKG;AACH,eAAO,MAAM,YAAY,kCAkBnB,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,aAAa,mDA0HpB,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,+BAA+B,oEAsCtC,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,mDAiEvB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"circuit.d.ts","sourceRoot":"","sources":["../../../src/functions/circuit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AAyCpD,OAAO,EAAuB,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAkO5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,4FAoGpC,CAAA;AA8BN;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,0EA0Z9B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,+CAA+C,wEA4EtD,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,eAAe,uDA8EtB,CAAA"}
1
+ {"version":3,"file":"circuit.d.ts","sourceRoot":"","sources":["../../../src/functions/circuit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA;AAyCpD,OAAO,EAAuB,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAkO5E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,6BAA6B,4FAoGpC,CAAA;AA8BN;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,kBAAkB,0EA2Z9B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,+CAA+C,wEA4EtD,CAAA;AAEN;;;;GAIG;AACH,eAAO,MAAM,eAAe,uDA8EtB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/functions/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,kCA6MxC,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,wCAAwC,mDAyC/C,CAAA"}
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../../src/functions/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAuB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,iCAAiC,kCA6MxC,CAAA;AAEN;;;GAGG;AACH,eAAO,MAAM,wCAAwC,mDA0C/C,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/functions/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAW/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,mEAsGvB,CAAA;AACN;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,mEA+BpC,CAAA"}
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../../src/functions/user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAW/C;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,mEAqGvB,CAAA;AACN;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,mEA+BpC,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { DocumentData, QuerySnapshot, DocumentSnapshot, QueryDocumentSnapshot, WhereFilterOp } from "firebase-admin/firestore";
2
2
  import admin from "firebase-admin";
3
- import { CircuitDocument } from "@p0tion/actions";
3
+ import { CircuitDocument } from "@devtion/actions";
4
4
  import { SSMClient } from "@aws-sdk/client-ssm";
5
5
  import { EC2Client } from "@aws-sdk/client-ec2";
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,qBAAqB,EAErB,aAAa,EAChB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,MAAM,gBAAgB,CAAA;AAWlC,OAAO,EAOH,eAAe,EAClB,MAAM,iBAAiB,CAAA;AAIxB,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAM/C;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe,eACZ,MAAM,cACN,MAAM,KACnB,QAAQ,iBAAiB,YAAY,CAAC,CASxC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAO,MAAoC,CAAA;AAEzF;;;GAGG;AACH,eAAO,MAAM,KAAK,OAAc,MAAM,KAAG,QAAQ,IAAI,CAAmB,CAAA;AAExE;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,eAAsB,MAAM,KAAG,QAAQ,MAAM,sBAAsB,YAAY,CAAC,CAAC,CAYhH,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,eAC5B,MAAM,aACP,MAAM,KAClB,QAAQ,MAAM,sBAAsB,YAAY,CAAC,CAAC,CAUpD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,eACpB,MAAM,iBACH,MAAM,KACtB,QAAQ,cAAc,YAAY,CAAC,CASrC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAa,QAAQ,MAAM,sBAAsB,YAAY,CAAC,CAAC,CAWhG,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,eACzB,MAAM,oBACA,MAAM,KACzB,QAAQ,sBA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,aAAa,MAAM,iBAAiB,MAAM,kBA6B9G,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,eACf,MAAM,aACP,MAAM,iBACF,MAAM,aACX,OAAO,kBA4BpB,CAAA;AAED,eAAO,MAAM,wBAAwB,eACrB,MAAM,aACP,MAAM,QACX,MAAM,aACF,OAAO,kBAyBpB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,YAAY,eAAsB,MAAM,aAAa,MAAM,kBAWvE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,UAC/B,MAAM,wBACS,OAAO,SACtB,aAAa,KACrB,QAAQ,MAAM,SAAS,cAAc,CAAC,MAAM,SAAS,aAAa,CAAC,CAYxD,CAAA;AAEd;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,eACjB,MAAM,aACP,MAAM,KAClB,QAAQ,sBAAsB,YAAY,CAAC,CAgB7C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,oBAAqB,eAAe,KAAG,eAKvE,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,GAarC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,GAkBlC,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,QAAQ,SAAS,CAYzD,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAa,QAAQ,SAAS,CAYzD,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,cAAqB,MAAM,KAAG,QAAQ,MAAM,CAQxE,CAAA"}
@@ -1,4 +1,4 @@
1
- import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@p0tion/actions";
1
+ import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@devtion/actions";
2
2
  /**
3
3
  * Group all the necessary data needed for running the `setupCeremony` cloud function.
4
4
  * @typedef {Object} SetupCeremonyData
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts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BAAsB,GAAG;IAClE,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,GAAG;IAC/D,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAA;IAChC,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,8CAA8C,GAAG;IACzD,UAAU,EAAE,MAAM,CAAA;IAClB,2BAA2B,EAAE,MAAM,CAAA;IACnC,gBAAgB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;CACnB,CAAA;AAED;;;;;GAKG;AACH,MAAM,MAAM,kDAAkD,GAAG;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,kBAAkB,CAAA;CAC5B,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,kCAAkC,EAAE,MAAM,CAAA;CAC7C,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtion/backend",
3
- "version": "0.0.0-eb3bb7d",
3
+ "version": "0.0.0-f3ea056",
4
4
  "description": "MPC Phase 2 backend for Firebase services management",
5
5
  "repository": "git@github.com:privacy-scaling-explorations/p0tion.git",
6
6
  "homepage": "https://github.com/privacy-scaling-explorations/p0tion",
@@ -67,7 +67,7 @@
67
67
  "@aws-sdk/client-ssm": "^3.357.0",
68
68
  "@aws-sdk/middleware-endpoint": "^3.329.0",
69
69
  "@aws-sdk/s3-request-presigner": "^3.329.0",
70
- "@p0tion/actions": "^1.0.5",
70
+ "@devtion/actions": "latest",
71
71
  "blakejs": "^1.2.1",
72
72
  "dotenv": "^16.0.3",
73
73
  "ethers": "5.7.2",
@@ -85,5 +85,5 @@
85
85
  "publishConfig": {
86
86
  "access": "public"
87
87
  },
88
- "gitHead": "d21d2002b8d020289595aaea83be0202d28486cb"
88
+ "gitHead": "7abc6a0bd781de4a52c12f6b557f27a579291a41"
89
89
  }
@@ -18,7 +18,7 @@ import {
18
18
  vmBootstrapCommand,
19
19
  vmDependenciesAndCacheArtifactsCommand,
20
20
  vmBootstrapScriptFilename
21
- } from "@p0tion/actions"
21
+ } from "@devtion/actions"
22
22
  import { encode } from "html-entities"
23
23
  import { SetupCeremonyData } from "../types/index"
24
24
  import { COMMON_ERRORS, logAndThrowError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
@@ -146,7 +146,7 @@ export const setupCeremony = functions
146
146
  // Check if using the VM approach for contribution verification.
147
147
  if (circuit.verification.cfOrVm === CircuitContributionVerificationMechanism.VM) {
148
148
  // VM command to be run at the startup.
149
- const startupCommand = vmBootstrapCommand(bucketName)
149
+ const startupCommand = vmBootstrapCommand(`${bucketName}/circuits/${circuit.name!}`)
150
150
 
151
151
  // Get EC2 client.
152
152
  const ec2Client = await createEC2Client()
@@ -165,7 +165,8 @@ export const setupCeremony = functions
165
165
  printLog(`Check VM dependencies and cache artifacts commands ${vmCommands.join("\n")}`, LogLevel.DEBUG)
166
166
 
167
167
  // Upload the post-startup commands script file.
168
- await uploadFileToBucketNoFile(bucketName, vmBootstrapScriptFilename, vmCommands.join("\n"))
168
+ printLog(`Uploading VM post-startup commands script file ${vmBootstrapScriptFilename}`, LogLevel.DEBUG)
169
+ await uploadFileToBucketNoFile(bucketName, `circuits/${circuit.name!}/${vmBootstrapScriptFilename}`, vmCommands.join("\n"))
169
170
 
170
171
  // Compute the VM disk space requirement (in GB).
171
172
  const vmDiskSize = computeDiskSizeForVM(circuit.zKeySizeInBytes!, circuit.metadata?.pot!)
@@ -37,7 +37,7 @@ import {
37
37
  createCustomLoggerForFile,
38
38
  retrieveCommandStatus,
39
39
  stopEC2Instance
40
- } from "@p0tion/actions"
40
+ } from "@devtion/actions"
41
41
  import { zKey } from "snarkjs"
42
42
  import { CommandInvocationStatus, SSMClient } from "@aws-sdk/client-ssm"
43
43
  import { FinalizeCircuitData, VerifyContributionData } from "../types/index"
@@ -611,8 +611,6 @@ export const verifycontribution = functionsV2.https.onCall(
611
611
  true
612
612
  )
613
613
 
614
- // Stop VM instance.
615
- await stopEC2Instance(ec2, vmInstanceId)
616
614
  } else {
617
615
  // Upload verification transcript.
618
616
  /// nb. do not use multi-part upload here due to small file size.
@@ -689,6 +687,9 @@ export const verifycontribution = functionsV2.https.onCall(
689
687
  })
690
688
  }
691
689
 
690
+ // Stop VM instance
691
+ if (isUsingVM) await stopEC2Instance(ec2, vmInstanceId)
692
+
692
693
  // Step (1.A.4.C)
693
694
  if (!isFinalizing) {
694
695
  // Step (1.A.4.C.1)
@@ -8,7 +8,7 @@ import {
8
8
  ParticipantContributionStep,
9
9
  getParticipantsCollectionPath,
10
10
  commonTerms
11
- } from "@p0tion/actions"
11
+ } from "@devtion/actions"
12
12
  import { FieldValue } from "firebase-admin/firestore"
13
13
  import {
14
14
  PermanentlyStoreCurrentContributionTimeAndHash,
@@ -20,7 +20,7 @@ import {
20
20
  ParticipantContributionStep,
21
21
  formatZkeyIndex,
22
22
  getZkeyStorageFilePath
23
- } from "@p0tion/actions"
23
+ } from "@devtion/actions"
24
24
  import { getCeremonyCircuits, getDocumentById } from "../lib/utils"
25
25
  import { COMMON_ERRORS, logAndThrowError, makeError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
26
26
  import { LogLevel } from "../types/enums"
@@ -9,7 +9,7 @@ import {
9
9
  ParticipantStatus,
10
10
  getTimeoutsCollectionPath,
11
11
  commonTerms
12
- } from "@p0tion/actions"
12
+ } from "@devtion/actions"
13
13
  import {
14
14
  getCeremonyCircuits,
15
15
  getCurrentServerTimestampInMillis,
@@ -281,7 +281,8 @@ export const resumeContributionAfterTimeoutExpiration = functions
281
281
  if (status === ParticipantStatus.EXHUMED)
282
282
  await participantDoc.ref.update({
283
283
  status: ParticipantStatus.READY,
284
- lastUpdated: getCurrentServerTimestampInMillis()
284
+ lastUpdated: getCurrentServerTimestampInMillis(),
285
+ tempContributionData: {}
285
286
  })
286
287
  else logAndThrowError(SPECIFIC_ERRORS.SE_CONTRIBUTE_CANNOT_PROGRESS_TO_NEXT_CIRCUIT)
287
288
 
@@ -2,7 +2,7 @@ import * as functions from "firebase-functions"
2
2
  import { UserRecord } from "firebase-functions/v1/auth"
3
3
  import admin from "firebase-admin"
4
4
  import dotenv from "dotenv"
5
- import { commonTerms, githubReputation } from "@p0tion/actions"
5
+ import { commonTerms, githubReputation } from "@devtion/actions"
6
6
  import { encode } from "html-entities"
7
7
  import { getGitHubVariables, getCurrentServerTimestampInMillis } from "../lib/utils"
8
8
  import { logAndThrowError, makeError, printLog, SPECIFIC_ERRORS } from "../lib/errors"
@@ -114,7 +114,6 @@ export const registerAuthUser = functions
114
114
  await avatarRef.set({
115
115
  avatarUrl: avatarUrl || "",
116
116
  })
117
-
118
117
  printLog(`Authenticated user document with identifier ${uid} has been correctly stored`, LogLevel.DEBUG)
119
118
  printLog(`Authenticated user avatar with identifier ${uid} has been correctly stored`, LogLevel.DEBUG)
120
119
  })
package/src/lib/utils.ts CHANGED
@@ -25,7 +25,7 @@ import {
25
25
  CeremonyState,
26
26
  finalContributionIndex,
27
27
  CircuitDocument
28
- } from "@p0tion/actions"
28
+ } from "@devtion/actions"
29
29
  import fetch from "@adobe/node-fetch-retry"
30
30
  import path from "path"
31
31
  import os from "os"
@@ -1,4 +1,4 @@
1
- import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@p0tion/actions"
1
+ import { CeremonyInputData, CircuitDocument, ETagWithPartNumber } from "@devtion/actions"
2
2
 
3
3
  /**
4
4
  * Group all the necessary data needed for running the `setupCeremony` cloud function.