Skip to content

Commit

Permalink
nest supervisor_params in interop config section
Browse files Browse the repository at this point in the history
  • Loading branch information
edobry committed Dec 19, 2024
1 parent dda7fc3 commit 07824fd
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 48 deletions.
16 changes: 8 additions & 8 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ def run(plan, args):
persistent,
))

# deploy op-supervisor

op_supervisor_launcher.launch(
plan,
"op-supervisor",
all_participants,
optimism_args_with_right_defaults.supervisor_params,
)
if optimism_args_with_right_defaults.interop.enabled:
# deploy op-supervisor
op_supervisor_launcher.launch(
plan,
"op-supervisor",
all_participants,
optimism_args_with_right_defaults.interop.supervisor_params,
)

return

Expand Down
64 changes: 40 additions & 24 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,21 @@ def external_l1_network_params_input_parser(plan, input_args):
def input_parser(plan, input_args):
sanity_check.sanity_check(plan, input_args)
results = parse_network_params(plan, input_args)

results["global_log_level"] = "info"
results["global_node_selectors"] = {}
results["global_tolerations"] = []
results["persistent"] = False

return struct(
interop=struct(
enabled=results["interop"]["enabled"],
supervisor_params=struct(
image=results["interop"]["supervisor_params"]["image"],
dependency_set=results["interop"]["supervisor_params"]["dependency_set"],
extra_params=results["interop"]["supervisor_params"]["extra_params"],
)
),
chains=[
struct(
participants=[
Expand Down Expand Up @@ -130,11 +140,6 @@ def input_parser(plan, input_args):
"l2_artifacts_locator"
],
),
supervisor_params=struct(
image=results["supervisor_params"]["image"],
dependency_set=results["supervisor_params"]["dependency_set"],
extra_params=results["supervisor_params"]["extra_params"],
),
global_log_level=results["global_log_level"],
global_node_selectors=results["global_node_selectors"],
global_tolerations=results["global_tolerations"],
Expand All @@ -144,6 +149,22 @@ def input_parser(plan, input_args):

def parse_network_params(plan, input_args):
results = {}

# configure interop

results["interop"] = default_interop_args()
results["interop"].update(
input_args.get("interop", {})
)
results["interop"]["supervisor_params"] = default_supervisor_params()
if "supervisor_params" in input_args["interop"]:
results["interop"]["supervisor_params"].update(
input_args["interop"]["supervisor_params"]
)


# configure chains

chains = []

seen_names = {}
Expand Down Expand Up @@ -239,30 +260,21 @@ def parse_network_params(plan, input_args):

results["chains"] = chains

# configure supervisor

results["supervisor_params"] = default_supervisor_params()
results["supervisor_params"].update(
input_args.get("supervisor_params", {})
)

results["supervisor_params"]["image"] = (
results["supervisor_params"]["image"]
if results["supervisor_params"]["image"] != ""
else DEFAULT_SUPERVISOR_IMAGES["op-supervisor"]
)
# configur op-deployer

results["op_contract_deployer_params"] = default_op_contract_deployer_params()
results["op_contract_deployer_params"].update(
input_args.get("op_contract_deployer_params", {})
)

results["global_log_level"] = input_args.get("global_log_level", "info")

return results


def default_optimism_args():
return {
"interop": default_interop_args(),
"chains": default_chains(),
"op_contract_deployer_params": default_op_contract_deployer_params(),
"global_log_level": "info",
Expand All @@ -271,6 +283,17 @@ def default_optimism_args():
"persistent": False,
}

def default_interop_args():
return {
"enabled": False,
}

def default_supervisor_params():
return {
"image": DEFAULT_SUPERVISOR_IMAGES["op-supervisor"],
"dependency_set": "",
"extra_params": [],
}

def default_mev_params():
return {
Expand Down Expand Up @@ -356,13 +379,6 @@ def default_op_contract_deployer_params():
"extra_params": [],
}

def default_supervisor_params():
return {
"image": "",
"dependency_set": "",
"extra_params": [],
}

def default_ethereum_package_network_params():
return {
"network_params": {
Expand Down
44 changes: 28 additions & 16 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
INTEROP_PARAMS = [
"enabled",
"supervisor_params",
]

SUPERVISOR_PARAMS = [
"image",
"dependency_set",
"extra_params",
]

PARTICIPANT_CATEGORIES = {
"participants": [
"el_type",
Expand Down Expand Up @@ -57,21 +68,15 @@ OP_CONTRACT_DEPLOYER_PARAMS = [
"l2_artifacts_locator",
]

SUPERVISOR_PARAMS = [
"image",
"dependency_set",
"extra_params",
]

ADDITIONAL_SERVICES_PARAMS = [
"blockscout",
"rollup-boost",
]

ROOT_PARAMS = [
"interop",
"chains",
"op_contract_deployer_params",
"supervisor_params",
"global_log_level",
"global_node_selectors",
"global_tolerations",
Expand All @@ -87,7 +92,6 @@ EXTERNAL_L1_NETWORK_PARAMS = [
"priv_key",
]


def deep_validate_params(plan, input_args, category, allowed_params):
if category in input_args:
for item in input_args[category]:
Expand Down Expand Up @@ -119,6 +123,22 @@ def sanity_check(plan, optimism_config):
if key not in ROOT_PARAMS:
fail("Invalid parameter {0}, allowed fields: {1}".format(key, ROOT_PARAMS))

if "interop" in optimism_config:
validate_params(
plan,
optimism_config,
"interop",
INTEROP_PARAMS,
)

if "supervisor_params" in optimism_config["interop"]:
validate_params(
plan,
optimism_config["interop"],
"supervisor_params",
SUPERVISOR_PARAMS,
)

chains = optimism_config.get("chains", [])

if type(chains) != "list":
Expand Down Expand Up @@ -171,14 +191,6 @@ def sanity_check(plan, optimism_config):
OP_CONTRACT_DEPLOYER_PARAMS,
)

if "supervisor_params" in optimism_config:
validate_params(
plan,
optimism_config,
"supervisor_params",
SUPERVISOR_PARAMS,
)

plan.print("Sanity check for OP package passed")


Expand Down

0 comments on commit 07824fd

Please sign in to comment.