-
Notifications
You must be signed in to change notification settings - Fork 326
Expand file tree
/
Copy pathprysm_launcher.star
More file actions
376 lines (344 loc) · 13 KB
/
prysm_launcher.star
File metadata and controls
376 lines (344 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
shared_utils = import_module("../../shared_utils/shared_utils.star")
input_parser = import_module("../../package_io/input_parser.star")
cl_context = import_module("../../cl/cl_context.star")
cl_node_ready_conditions = import_module("../../cl/cl_node_ready_conditions.star")
cl_shared = import_module("../cl_shared.star")
node_metrics = import_module("../../node_metrics_info.star")
constants = import_module("../../package_io/constants.star")
# ---------------------------------- Beacon client -------------------------------------
BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/prysm/beacon-data/"
# Port nums
DISCOVERY_TCP_PORT_NUM = 13000
DISCOVERY_UDP_PORT_NUM = 12000
DISCOVERY_QUIC_PORT_NUM = 13000
BEACON_HTTP_PORT_NUM = 3500
RPC_PORT_NUM = 4000
BEACON_MONITORING_PORT_NUM = 8080
PROFILING_PORT_NUM = 6060
METRICS_PATH = "/metrics"
VERBOSITY_LEVELS = {
constants.GLOBAL_LOG_LEVEL.error: "error",
constants.GLOBAL_LOG_LEVEL.warn: "warn",
constants.GLOBAL_LOG_LEVEL.info: "info",
constants.GLOBAL_LOG_LEVEL.debug: "debug",
constants.GLOBAL_LOG_LEVEL.trace: "trace",
}
def launch(
plan,
launcher,
beacon_service_name,
participant,
global_log_level,
bootnode_contexts,
el_context,
full_name,
node_keystore_files,
snooper_el_engine_context,
persistent,
tolerations,
node_selectors,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
participant_index,
network_params,
):
log_level = input_parser.get_client_log_level_or_default(
participant.cl_log_level, global_log_level, VERBOSITY_LEVELS
)
beacon_config = get_beacon_config(
plan,
launcher,
beacon_service_name,
participant,
log_level,
bootnode_contexts,
el_context,
full_name,
node_keystore_files,
snooper_el_engine_context,
persistent,
tolerations,
node_selectors,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
participant_index,
network_params,
)
beacon_service = plan.add_service(beacon_service_name, beacon_config)
beacon_http_port = beacon_service.ports[constants.HTTP_PORT_ID]
beacon_http_url = "http://{0}:{1}".format(
beacon_service.ip_address, BEACON_HTTP_PORT_NUM
)
beacon_grpc_url = "{0}:{1}".format(beacon_service.ip_address, RPC_PORT_NUM)
# TODO(old) add validator availability using the validator API: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v1#/ValidatorRequiredApi | from eth2-merge-kurtosis-module
beacon_node_identity_recipe = GetHttpRequestRecipe(
endpoint="/eth/v1/node/identity",
port_id=constants.HTTP_PORT_ID,
extract={
"enr": ".data.enr",
"multiaddr": ".data.p2p_addresses[0]",
"peer_id": ".data.peer_id",
},
)
response = plan.request(
recipe=beacon_node_identity_recipe, service_name=beacon_service_name
)
beacon_node_enr = response["extract.enr"]
beacon_multiaddr = response["extract.multiaddr"]
beacon_peer_id = response["extract.peer_id"]
beacon_metrics_port = beacon_service.ports[constants.METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(
beacon_service.ip_address, beacon_metrics_port.number
)
beacon_node_metrics_info = node_metrics.new_node_metrics_info(
beacon_service_name, METRICS_PATH, beacon_metrics_url
)
nodes_metrics_info = [beacon_node_metrics_info]
return cl_context.new_cl_context(
client_name="prysm",
enr=beacon_node_enr,
ip_addr=beacon_service.ip_address,
http_port=beacon_http_port.number,
beacon_http_url=beacon_http_url,
cl_nodes_metrics_info=nodes_metrics_info,
beacon_service_name=beacon_service_name,
beacon_grpc_url=beacon_grpc_url,
multiaddr=beacon_multiaddr,
peer_id=beacon_peer_id,
snooper_enabled=participant.snooper_enabled,
snooper_el_engine_context=snooper_el_engine_context,
validator_keystore_files_artifact_uuid=node_keystore_files.files_artifact_uuid
if node_keystore_files
else "",
supernode=participant.supernode,
)
def get_beacon_config(
plan,
launcher,
beacon_service_name,
participant,
log_level,
bootnode_contexts,
el_context,
full_name,
node_keystore_files,
snooper_el_engine_context,
persistent,
tolerations,
node_selectors,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
participant_index,
network_params,
):
# If snooper is enabled use the snooper engine context, otherwise use the execution client context
if participant.snooper_enabled:
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
snooper_el_engine_context.ip_addr,
snooper_el_engine_context.engine_rpc_port_num,
)
else:
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
el_context.ip_addr,
el_context.engine_rpc_port_num,
)
public_ports = {}
public_ports_for_component = None
if port_publisher.cl_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component(
"cl", port_publisher, participant_index
)
public_ports = cl_shared.get_general_cl_public_port_specs(
public_ports_for_component
)
public_ports.update(
shared_utils.get_port_specs(
{constants.QUIC_DISCOVERY_PORT_ID: public_ports_for_component[0]}
)
)
public_ports.update(
shared_utils.get_port_specs(
{constants.UDP_DISCOVERY_PORT_ID: public_ports_for_component[1]}
)
)
public_ports.update(
shared_utils.get_port_specs(
{constants.RPC_PORT_ID: public_ports_for_component[5]}
)
)
public_ports.update(
shared_utils.get_port_specs(
{constants.PROFILING_PORT_ID: public_ports_for_component[6]}
)
)
discovery_port_tcp = (
public_ports_for_component[0]
if public_ports_for_component
else DISCOVERY_TCP_PORT_NUM
)
discovery_port_udp = (
public_ports_for_component[1]
if public_ports_for_component
else DISCOVERY_UDP_PORT_NUM
)
discovery_port_quic = (
public_ports_for_component[0]
if public_ports_for_component
else DISCOVERY_QUIC_PORT_NUM
) # use the same port for quic and tcp
used_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: discovery_port_tcp,
constants.UDP_DISCOVERY_PORT_ID: discovery_port_udp,
constants.HTTP_PORT_ID: BEACON_HTTP_PORT_NUM,
constants.METRICS_PORT_ID: BEACON_MONITORING_PORT_NUM,
constants.QUIC_DISCOVERY_PORT_ID: discovery_port_quic,
constants.RPC_PORT_ID: RPC_PORT_NUM,
constants.PROFILING_PORT_ID: PROFILING_PORT_NUM,
}
used_ports = shared_utils.get_port_specs(used_port_assignments)
cmd = [
"--accept-terms-of-use=true", # it's mandatory in order to run the node
"--datadir=" + BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER,
"--execution-endpoint=" + EXECUTION_ENGINE_ENDPOINT,
"--rpc-host=0.0.0.0",
"--rpc-port={0}".format(RPC_PORT_NUM),
"--http-host=0.0.0.0",
"--http-cors-domain=*",
"--http-port={0}".format(BEACON_HTTP_PORT_NUM),
"--p2p-host-ip=" + port_publisher.nat_exit_ip,
"--p2p-tcp-port={0}".format(discovery_port_tcp),
"--p2p-udp-port={0}".format(discovery_port_udp),
"--p2p-quic-port={0}".format(discovery_port_quic),
"--min-sync-peers={0}".format(constants.MIN_PEERS),
"--verbosity=" + log_level,
"--slots-per-archive-point={0}".format(32 if constants.ARCHIVE_MODE else 8192),
"--suggested-fee-recipient=" + constants.VALIDATING_REWARDS_ACCOUNT,
"--jwt-secret=" + constants.JWT_MOUNT_PATH_ON_CONTAINER,
# vvvvvvvvv METRICS CONFIG vvvvvvvvvvvvvvvvvvvvv
"--disable-monitoring=false",
"--monitoring-host=0.0.0.0",
"--monitoring-port={0}".format(BEACON_MONITORING_PORT_NUM),
# vvvvvvvvv PROFILING CONFIG vvvvvvvvvvvvvvvvvvvvv
"--pprof",
"--pprofaddr=0.0.0.0",
"--pprofport={0}".format(PROFILING_PORT_NUM),
]
supernode_cmd = [
"--subscribe-all-data-subnets=true",
]
if network_params.perfect_peerdas_enabled and participant_index < 16:
cmd.append(
"--p2p-priv-key="
+ constants.NODE_KEY_MOUNTPOINT_ON_CLIENTS
+ "/node-key-file-{0}".format(participant_index + 1)
)
if participant.supernode:
cmd.extend(supernode_cmd)
if checkpoint_sync_enabled:
cmd.append("--checkpoint-sync-url=" + checkpoint_sync_url)
cmd.append("--genesis-beacon-api-url=" + checkpoint_sync_url)
if network_params.preset == "minimal":
cmd.append("--minimal-config=true")
if network_params.network not in constants.PUBLIC_NETWORKS:
cmd.append("--p2p-static-id=true")
cmd.append(
"--chain-config-file="
+ constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER
+ "/config.yaml"
)
cmd.append(
"--genesis-state="
+ constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER
+ "/genesis.ssz",
)
cmd.append("--contract-deployment-block=0")
if (
network_params.network == constants.NETWORK_NAME.kurtosis
or constants.NETWORK_NAME.shadowfork in network_params.network
):
if bootnode_contexts != None:
for ctx in bootnode_contexts[: constants.MAX_ENR_ENTRIES]:
cmd.append("--bootstrap-node=" + ctx.enr)
elif network_params.network == constants.NETWORK_NAME.ephemery:
cmd.append(
"--genesis-beacon-api-url="
+ constants.CHECKPOINT_SYNC_URL[network_params.network]
)
cmd.append(
"--bootstrap-node="
+ constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER
+ "/bootstrap_nodes.yaml"
)
else: # Devnets
cmd.append(
"--bootstrap-node="
+ constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER
+ "/bootstrap_nodes.yaml"
)
else: # Public network
cmd.append("--{}".format(network_params.network))
if len(participant.cl_extra_params) > 0:
# we do the for loop as otherwise its a proto repeated array
cmd.extend([param for param in participant.cl_extra_params])
files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.el_cl_genesis_data.files_artifact_uuid,
constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file,
}
if network_params.perfect_peerdas_enabled and participant_index < 16:
files[constants.NODE_KEY_MOUNTPOINT_ON_CLIENTS] = Directory(
artifact_names=["node-key-file-{0}".format(participant_index + 1)]
)
if persistent:
volume_size_key = (
"devnets" if "devnet" in network_params.network else network_params.network
)
files[BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER] = Directory(
persistent_key="data-{0}".format(beacon_service_name),
size=int(participant.cl_volume_size)
if int(participant.cl_volume_size) > 0
else constants.VOLUME_SIZE[volume_size_key][
constants.CL_TYPE.prysm + "_volume_size"
],
)
config_args = {
"image": participant.cl_image,
"ports": used_ports,
"public_ports": public_ports,
"cmd": cmd,
"files": files,
"env_vars": participant.cl_extra_env_vars,
"private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
"ready_conditions": cl_node_ready_conditions.get_ready_conditions(
constants.HTTP_PORT_ID
),
"labels": shared_utils.label_maker(
client=constants.CL_TYPE.prysm,
client_type=constants.CLIENT_TYPES.cl,
image=participant.cl_image[-constants.MAX_LABEL_LENGTH :],
connected_client=el_context.client_name,
extra_labels=participant.cl_extra_labels,
supernode=participant.supernode,
),
"tolerations": tolerations,
"node_selectors": node_selectors,
}
if int(participant.cl_min_cpu) > 0:
config_args["min_cpu"] = int(participant.cl_min_cpu)
if int(participant.cl_max_cpu) > 0:
config_args["max_cpu"] = int(participant.cl_max_cpu)
if int(participant.cl_min_mem) > 0:
config_args["min_memory"] = int(participant.cl_min_mem)
if int(participant.cl_max_mem) > 0:
config_args["max_memory"] = int(participant.cl_max_mem)
return ServiceConfig(**config_args)
def new_prysm_launcher(
el_cl_genesis_data,
jwt_file,
):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
)