Skip to content

Commit a39fd5f

Browse files
committed
fix(vms): fix VM commands
1 parent b75b3d3 commit a39fd5f

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

packages/actions/src/helpers/vm.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ export const vmDependenciesAndCacheArtifactsCommand = (zKeyPath: string, potPath
8080
"sudo yum update -y",
8181
"sudo yum install -y nodejs",
8282
"npm install -g snarkjs",
83-
"wget https://github.com/BLAKE3-team/BLAKE3/releases/download/1.4.0/b3sum_linux_x64_bin -O /var/tmp/blake3.bin",
84-
"chmod +x /var/tmp/blake3.bin",
8583
`aws s3 cp s3://${zKeyPath} /var/tmp/genesisZkey.zkey`,
86-
`aws s3 cp s3://${potPath} /var/tmp/pot.ptau`
84+
`aws s3 cp s3://${potPath} /var/tmp/pot.ptau`,
85+
"wget https://github.com/BLAKE3-team/BLAKE3/releases/download/1.4.0/b3sum_linux_x64_bin -O /var/tmp/blake3.bin",
86+
"chmod +x /var/tmp/blake3.bin"
8787
]
8888

8989
/**
@@ -99,11 +99,11 @@ export const vmContributionVerificationCommand = (
9999
lastZkeyStoragePath: string,
100100
verificationTranscriptStoragePathAndFilename: string
101101
): Array<string> => [
102-
`aws s3 cp s3://${bucketName}/${lastZkeyStoragePath} /var/tmp/lastZKey.zkey > /dev/null`,
102+
`aws s3 cp s3://${bucketName}/${lastZkeyStoragePath} /var/tmp/lastZKey.zkey &>/dev/null`,
103103
`snarkjs zkvi /var/tmp/genesisZkey.zkey /var/tmp/pot.ptau /var/tmp/lastZKey.zkey > /var/tmp/verification_transcript.log`,
104-
`aws s3 cp /var/tmp/verification_transcript.log s3://${bucketName}/${verificationTranscriptStoragePathAndFilename} > /dev/null`,
104+
`aws s3 cp /var/tmp/verification_transcript.log s3://${bucketName}/${verificationTranscriptStoragePathAndFilename} &>/dev/null`,
105105
`./var/tmp/blake3.bin /var/tmp/verification_transcript.log | awk '{print $1}'`,
106-
`rm /var/tmp/lastZKey.zkey /var/tmp/verification_transcript.log > /dev/null`
106+
`rm /var/tmp/lastZKey.zkey /var/tmp/verification_transcript.log &>/dev/null`
107107
]
108108

109109
/**

packages/backend/src/functions/ceremony.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import {
1717
computeDiskSizeForVM,
1818
vmBootstrapCommand,
1919
vmDependenciesAndCacheArtifactsCommand,
20-
vmBootstrapScriptFilename,
21-
stopEC2Instance
20+
vmBootstrapScriptFilename
2221
} from "@p0tion/actions"
2322
import { encode } from "html-entities"
2423
import { SetupCeremonyData } from "../types/index"
@@ -161,6 +160,7 @@ export const setupCeremony = functions
161160
// Compute the VM disk space requirement (in GB).
162161
const vmDiskSize = computeDiskSizeForVM(circuit.zKeySizeInBytes!, circuit.metadata?.pot!)
163162

163+
printLog(startupCommand.join("\n"), LogLevel.DEBUG)
164164
// Configure and instantiate a new VM based on the coordinator input.
165165
const instance = await createEC2Instance(
166166
ec2Client,
@@ -172,9 +172,6 @@ export const setupCeremony = functions
172172
// Get the VM instance identifier.
173173
vmInstanceId = instance.instanceId
174174

175-
// Stop the instance after creation.
176-
await stopEC2Instance(ec2Client, vmInstanceId)
177-
178175
// Update the circuit document info accordingly.
179176
circuit = {
180177
...circuit,

packages/backend/src/functions/circuit.ts

+14-7
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,22 @@ export const verifycontribution = functionsV2.https.onCall(
483483
)
484484
)
485485

486+
// @todo check sleep
487+
await sleep(1000)
488+
486489
// Wait until the command completes with a success status.
487490
const interval = setInterval(async () => {
488-
const cmdStatus = await retrieveCommandStatus(ssm, commandId, vmInstanceId)
489-
490-
// TODO: make an enum.
491-
if (cmdStatus === "Success") clearInterval(interval)
492-
else if (cmdStatus === "Failed" || cmdStatus === "AccessDenied")
493-
// Refactoring error.
494-
logAndThrowError(makeError("aborted", `Invalid command execution ${cmdStatus}`))
491+
try {
492+
const cmdStatus = await retrieveCommandStatus(ssm, commandId, vmInstanceId)
493+
printLog("CMD STATUS" + cmdStatus, LogLevel.DEBUG)
494+
// TODO: make an enum.
495+
if (cmdStatus === "Success") clearInterval(interval)
496+
else if (cmdStatus === "Failed" || cmdStatus === "AccessDenied")
497+
// Refactoring error.
498+
logAndThrowError(makeError("aborted", `Invalid command execution ${cmdStatus}`))
499+
} catch (error: any) {
500+
printLog(error.toString(), LogLevel.DEBUG)
501+
}
495502
}, 60000)
496503

497504
// TODO To be deleted

0 commit comments

Comments
 (0)