From 464fbbaeaa0b4feefe13d1a9db782f6f39bd7fd4 Mon Sep 17 00:00:00 2001 From: Zach Howard Date: Thu, 9 Jan 2025 17:21:34 -0600 Subject: [PATCH] feat: generate op-supervisor dependency set json (#131) --- README.md | 2 +- main.star | 1 + .../op-supervisor/op_supervisor_launcher.star | 22 ++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 732dc7cc..d7b36a93 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ optimism_package: # The Docker image that should be used for the supervisor; leave blank to use the default op-supervisor image image: "" - # A JSON string containing chain dependencies + # A JSON string containing chain dependencies (generated by default). dependency_set: "" # A list of optional extra params that will be passed to the supervisor container for modifying its behaviour diff --git a/main.star b/main.star index 94d51d9b..923a7f12 100644 --- a/main.star +++ b/main.star @@ -116,6 +116,7 @@ def run(plan, args): op_supervisor_launcher.launch( plan, l1_config_env_vars, + optimism_args_with_right_defaults.chains, all_participants, jwt_file, interop_params.supervisor_params, diff --git a/src/interop/op-supervisor/op_supervisor_launcher.star b/src/interop/op-supervisor/op_supervisor_launcher.star index 8636cbd1..24f612d1 100644 --- a/src/interop/op-supervisor/op_supervisor_launcher.star +++ b/src/interop/op-supervisor/op_supervisor_launcher.star @@ -26,15 +26,35 @@ DATA_DIR = "/etc/op-supervisor" DEPENDENCY_SET_FILE_NAME = "dependency_set.json" +def create_dependency_set(chains): + result = { + "dependencies": { + str(chain.network_params.network_id): { + "chainIndex": str(chain.network_params.network_id), + "activationTime": 0, + "historyMinTime": 0, + } + for chain in chains + } + } + return result + + def launch( plan, l1_config_env_vars, + chains, all_participants, jwt_file, supervisor_params, ): + dependency_set_json = supervisor_params.dependency_set + if not dependency_set_json: + dependency_set = create_dependency_set(chains) + dependency_set_json = json.encode(dependency_set) + dependency_set_artifact = utils.write_to_file( - plan, supervisor_params.dependency_set, DATA_DIR, DEPENDENCY_SET_FILE_NAME + plan, dependency_set_json, DATA_DIR, DEPENDENCY_SET_FILE_NAME ) config = get_supervisor_config(