@@ -103,86 +103,15 @@ export const generateVMCommand = (zKeyPath: string, ptauPath: string): string[]
103
103
104
104
/**
105
105
* Determine the VM specs based on the circuit constraints (TODO)
106
- * @param circuitConstraints <string> the constraints of the circuit
106
+ * @param requiredSpace <string> the required disk space
107
+ * @return <any> the disk space and ram requirements
107
108
*/
108
- // export const determineVMSpecs = async (circuitConstraints: string) => {}
109
-
110
- // // RAM -> instanceId
111
- // const instancesTypes = {
112
- // "t3.nano": {
113
- // RAM: "0.5 GiB",
114
- // VCPU: "2"
115
- // },
116
- // "t3.micro": {
117
- // RAM: "1 GiB",
118
- // VCPU: "2"
119
- // },
120
- // "t3.small": {
121
- // RAM: "2 GiB",
122
- // VCPU: "2"
123
- // },
124
- // "t3.medium": {
125
- // RAM: "4 GiB",
126
- // VCPU: "2"
127
- // },
128
- // "t3.large": {
129
- // RAM: "8 GiB",
130
- // VCPU: "2"
131
- // },
132
- // "t3.xlarge": {
133
- // RAM: "16 GiB",
134
- // VCPU: "4"
135
- // },
136
- // "t3.2xlarge": {
137
- // RAM: "32 GiB",
138
- // VCPU: "8"
139
- // },
140
- // "c5.9xlarge": {
141
- // RAM: "36 GiB",
142
- // VCPU: "36"
143
- // },
144
- // "c5.18xlarge": {
145
- // RAM: "72 GiB",
146
- // VCPU: "72"
147
- // },
148
- // "c5a.8xlarge": {
149
- // RAM: "64 GiB",
150
- // VCPU: "32"
151
- // },
152
- // "c5.12xlarge": {
153
- // RAM: "96 GiB",
154
- // VCPU: "48"
155
- // },
156
- // "c5a.16xlarge": {
157
- // RAM: "128 GiB",
158
- // VCPU: "64"
159
- // },
160
- // "c6i.32xlarge": {
161
- // RAM: "256 GiB",
162
- // VCPU: "128"
163
- // },
164
- // "m6a.32xlarge": {
165
- // RAM: "512 GiB",
166
- // VCPU: "128"
167
- // }
168
- // }
169
-
170
- // 1. create ssh key in ec2 tab -> save the name
171
- // 2. IAM role: access to ssh key ("iam:GetSSHPublicKey",)
172
- // 3. IAM role: ec2 access
173
- // 4. ec2 give role for s3 access
174
- // 5. have an api (express) running on the vm
175
- // 6. have a script that runs on the vm that does the verification
176
- // 7. JWT Authorization: Bearer <token>
177
- // each circuit document needs to have the instance id of the vm
178
- /*
179
- {
180
- bucket: "x",
181
- action: "verify/checkStatus",
182
- "zKeyIndex": 0,
183
- "zKeyStoragePath": /circuit/..,
109
+ export const determineVMSpecs = ( requiredSpace : string ) => {
110
+ return {
111
+ "vm" : "c5.x9large" ,
112
+ "disk" : 32
113
+ }
184
114
}
185
- */
186
115
187
116
/**
188
117
* Creates a new EC2 instance
@@ -192,6 +121,7 @@ export const generateVMCommand = (zKeyPath: string, ptauPath: string): string[]
192
121
* @param amiId <string> the AMI ID to be used
193
122
* @param keyName <string> the name of the key to be used
194
123
* @param roleArn <string> the ARN of the role to be used
124
+ * @param volumeSize <number> the size of the volume to be used
195
125
* @returns <Promise<P0tionEC2Instance>> the instance that was created
196
126
*/
197
127
export const createEC2Instance = async (
@@ -200,7 +130,8 @@ export const createEC2Instance = async (
200
130
instanceType : string ,
201
131
amiId : string ,
202
132
keyName : string ,
203
- roleArn : string
133
+ roleArn : string ,
134
+ volumeSize : number
204
135
) : Promise < P0tionEC2Instance > => {
205
136
// create the params
206
137
const params = {
@@ -214,7 +145,17 @@ export const createEC2Instance = async (
214
145
Arn : roleArn
215
146
} ,
216
147
// how to run commands on startup
217
- UserData : Buffer . from ( commands . join ( "\n" ) ) . toString ( "base64" )
148
+ UserData : Buffer . from ( commands . join ( "\n" ) ) . toString ( "base64" ) ,
149
+ BlockDeviceMappings : [
150
+ {
151
+ DeviceName : '/dev/xvda' ,
152
+ Ebs : {
153
+ DeleteOnTermination : true ,
154
+ VolumeSize : volumeSize , // size in GB
155
+ VolumeType : 'gp2' , // change this as per your needs
156
+ } ,
157
+ } ,
158
+ ] ,
218
159
}
219
160
220
161
// create command
0 commit comments