Skip to content

Commit 3d2c71c

Browse files
authored
fix: sanity check for all subfields (ethpandaops#1130)
1 parent b1f4e5c commit 3d2c71c

File tree

1 file changed

+80
-11
lines changed

1 file changed

+80
-11
lines changed

src/package_io/sanity_check.star

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,46 @@ PARTICIPANT_MATRIX_PARAMS = {
138138
},
139139
}
140140

141+
PORT_PUBLISHER_PARAMS = {
142+
"port_publisher": {
143+
"el": [
144+
"enabled",
145+
"public_port_start",
146+
"nat_exit_ip",
147+
],
148+
"cl": [
149+
"enabled",
150+
"public_port_start",
151+
"nat_exit_ip",
152+
],
153+
"vc": [
154+
"enabled",
155+
"public_port_start",
156+
"nat_exit_ip",
157+
],
158+
"remote_signer": [
159+
"enabled",
160+
"public_port_start",
161+
"nat_exit_ip",
162+
],
163+
"additional_services": [
164+
"enabled",
165+
"public_port_start",
166+
"nat_exit_ip",
167+
],
168+
"mev": [
169+
"enabled",
170+
"public_port_start",
171+
"nat_exit_ip",
172+
],
173+
"other": [
174+
"enabled",
175+
"public_port_start",
176+
"nat_exit_ip",
177+
],
178+
},
179+
}
180+
141181
SUBCATEGORY_PARAMS = {
142182
"network_params": [
143183
"network",
@@ -289,16 +329,6 @@ SUBCATEGORY_PARAMS = {
289329
"ethereum_genesis_generator_params": [
290330
"image",
291331
],
292-
"port_publisher": [
293-
"nat_exit_ip",
294-
"el",
295-
"cl",
296-
"vc",
297-
"remote_signer",
298-
"additional_services",
299-
"mev",
300-
"other",
301-
],
302332
}
303333

304334
ADDITIONAL_SERVICES_PARAMS = [
@@ -366,12 +396,41 @@ def validate_params(plan, input_args, category, allowed_params):
366396
)
367397

368398

399+
def validate_nested_params(
400+
plan, input_args, category, nested_param_definition, special_keys=None
401+
):
402+
if category not in input_args:
403+
return
404+
405+
special_keys = special_keys or []
406+
allowed_top_level_keys = list(nested_param_definition.keys()) + special_keys
407+
408+
# Validate top-level keys
409+
for param in input_args[category].keys():
410+
if param not in allowed_top_level_keys:
411+
fail(
412+
"Invalid parameter {0} for {1}, allowed fields: {2}".format(
413+
param, category, allowed_top_level_keys
414+
)
415+
)
416+
417+
# Validate nested parameters
418+
for sub_param in input_args[category]:
419+
if sub_param not in special_keys and sub_param in nested_param_definition:
420+
validate_params(
421+
plan,
422+
input_args[category],
423+
sub_param,
424+
nested_param_definition[sub_param],
425+
)
426+
427+
369428
def sanity_check(plan, input_args):
370429
# Checks participants
371430
deep_validate_params(
372431
plan, input_args, "participants", PARTICIPANT_CATEGORIES["participants"]
373432
)
374-
# Checks participants_matrix
433+
# Checks participants_matrix (uses original logic for arrays of objects)
375434
if "participants_matrix" in input_args:
376435
for sub_matrix_participant in input_args["participants_matrix"]:
377436
if (
@@ -394,6 +453,15 @@ def sanity_check(plan, input_args):
394453
],
395454
)
396455

456+
# Checks port_publisher (uses new generic validation for key-value mappings)
457+
validate_nested_params(
458+
plan,
459+
input_args,
460+
"port_publisher",
461+
PORT_PUBLISHER_PARAMS["port_publisher"],
462+
["nat_exit_ip"],
463+
)
464+
397465
# Checks additional services
398466
if "additional_services" in input_args:
399467
for additional_services in input_args["additional_services"]:
@@ -414,6 +482,7 @@ def sanity_check(plan, input_args):
414482
combined_root_params = (
415483
PARTICIPANT_CATEGORIES.keys()
416484
+ PARTICIPANT_MATRIX_PARAMS.keys()
485+
+ PORT_PUBLISHER_PARAMS.keys()
417486
+ SUBCATEGORY_PARAMS.keys()
418487
+ ADDITIONAL_CATEGORY_PARAMS.keys()
419488
)

0 commit comments

Comments
 (0)