File tree 4 files changed +26
-6
lines changed
4 files changed +26
-6
lines changed Original file line number Diff line number Diff line change @@ -73,17 +73,24 @@ export const vmBootstrapCommand = (bucketName: string): Array<string> => [
73
73
* Return the list of Node environment (and packages) installation plus artifact caching for contribution verification.
74
74
* @param zKeyPath <string> - the path to zKey artifact inside AWS S3 bucket.
75
75
* @param potPath <string> - the path to ptau artifact inside AWS S3 bucket.
76
+ * @param snsTopic <string> - the SNS topic ARN.
76
77
* @returns <Array<string>> - the array of commands to be run by the EC2 instance.
77
78
*/
78
- export const vmDependenciesAndCacheArtifactsCommand = ( zKeyPath : string , potPath : string ) : Array < string > => [
79
+ export const vmDependenciesAndCacheArtifactsCommand = (
80
+ zKeyPath : string ,
81
+ potPath : string ,
82
+ snsTopic : string ,
83
+ ) : Array < string > => [
79
84
"#!/bin/bash" ,
80
85
"sudo yum update -y" ,
81
86
"sudo yum install -y nodejs" ,
82
87
"npm install -g snarkjs" ,
83
88
`aws s3 cp s3://${ zKeyPath } /var/tmp/genesisZkey.zkey` ,
84
89
`aws s3 cp s3://${ potPath } /var/tmp/pot.ptau` ,
85
90
"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"
91
+ "chmod +x /var/tmp/blake3.bin" ,
92
+ "INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id)" ,
93
+ `aws sns publish --topic-arn ${ snsTopic } --message "$INSTANCE_ID"`
87
94
]
88
95
89
96
/**
@@ -164,6 +171,10 @@ export const createEC2Instance = async (
164
171
{
165
172
Key : "Name" ,
166
173
Value : ec2InstanceTag
174
+ } ,
175
+ {
176
+ Key : "Initialized" ,
177
+ Value : "false"
167
178
}
168
179
]
169
180
}
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ AWS_CEREMONY_BUCKET_POSTFIX="-ph2-ceremony"
16
16
AWS_AMI_ID = " ami-022e1a32d3f742bd8"
17
17
# The EC2 instance role to access S3
18
18
AWS_ROLE_ARN = " YOUR-AWS-ROLE-ARN"
19
+ # The SNS topic ARN to publish notifications
20
+ AWS_SNS_TOPIC_ARN = " YOUR-AWS-SNS-TOPIC-ARN"
19
21
20
22
# ## GENERIC ###
21
23
# ## These configs are generic and not tied to Firebase or AWS services.
Original file line number Diff line number Diff line change @@ -30,7 +30,8 @@ import {
30
30
getFinalContribution ,
31
31
htmlEncodeCircuitData ,
32
32
createEC2Client ,
33
- uploadFileToBucketNoFile
33
+ uploadFileToBucketNoFile ,
34
+ getAWSVariables
34
35
} from "../lib/utils"
35
36
import { LogLevel } from "../types/enums"
36
37
@@ -148,10 +149,14 @@ export const setupCeremony = functions
148
149
// Get EC2 client.
149
150
const ec2Client = await createEC2Client ( )
150
151
152
+ // Get AWS variables.
153
+ const { snsTopic } = getAWSVariables ( )
154
+
151
155
// Prepare dependencies and cache artifacts command.
152
156
const vmCommands = vmDependenciesAndCacheArtifactsCommand (
153
157
`${ bucketName } /${ circuit . files ?. initialZkeyStoragePath ! } ` ,
154
- `${ bucketName } /${ circuit . files ?. potStoragePath ! } `
158
+ `${ bucketName } /${ circuit . files ?. potStoragePath ! } ` ,
159
+ snsTopic
155
160
)
156
161
157
162
printLog ( vmCommands . join ( "\n" ) , LogLevel . DEBUG )
Original file line number Diff line number Diff line change @@ -400,7 +400,8 @@ export const getAWSVariables = (): any => {
400
400
! process . env . AWS_ACCESS_KEY_ID ||
401
401
! process . env . AWS_SECRET_ACCESS_KEY ||
402
402
! process . env . AWS_ROLE_ARN ||
403
- ! process . env . AWS_AMI_ID
403
+ ! process . env . AWS_AMI_ID ||
404
+ ! process . env . AWS_SNS_TOPIC
404
405
)
405
406
logAndThrowError ( COMMON_ERRORS . CM_WRONG_CONFIGURATION )
406
407
@@ -409,7 +410,8 @@ export const getAWSVariables = (): any => {
409
410
secretAccessKey : process . env . AWS_SECRET_ACCESS_KEY ! ,
410
411
region : process . env . AWS_REGION || "us-east-1" ,
411
412
roleArn : process . env . AWS_ROLE_ARN ! ,
412
- amiId : process . env . AWS_AMI_ID !
413
+ amiId : process . env . AWS_AMI_ID ! ,
414
+ snsTopic : process . env . AWS_SNS_TOPIC !
413
415
}
414
416
}
415
417
You can’t perform that action at this time.
0 commit comments