From f8097d789c75aae7c1aab4b86cb1129c695162de Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Wed, 4 Sep 2024 15:07:39 -0700 Subject: [PATCH 1/2] feat: add support for alt-da with da-server fix: type bugs in da_server related configs chore: refactor da-server launcher to not hardcode image feat: add optimism repo as submodule to build da-server image revert: changes to network_params.yaml --- .gitmodules | 3 + README.md | 8 ++ main.star | 2 + optimism | 1 + src/alt-da/da-server/da_server_launcher.star | 98 +++++++++++++++++++ .../op-batcher/op_batcher_launcher.star | 8 +- src/cl/hildr/hildr_launcher.star | 6 ++ src/cl/op-node/op_node_launcher.star | 7 ++ src/contracts/contract_deployer.star | 7 +- src/el_cl_launcher.star | 2 + src/l2.star | 28 ++++++ src/package_io/input_parser.star | 31 ++++++ src/package_io/sanity_check.star | 7 ++ src/participant_network.star | 3 + 14 files changed, 209 insertions(+), 2 deletions(-) create mode 100644 .gitmodules create mode 160000 optimism create mode 100644 src/alt-da/da-server/da_server_launcher.star diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..24f1f8f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "optimism"] + path = optimism + url = git@github.com:ethereum-optimism/optimism.git diff --git a/README.md b/README.md index c8038df..969730d 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,14 @@ optimism_package: # - blockscout additional_services: [] + # Configuration place for da-server - https://github.com/ethereum-optimism/optimism/tree/develop/op-alt-da + da_server_params: + image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:dev + build_image: true + # A list of optional extra params that will be passed to the da-server container for modifying its behaviour + da_server_extra_args: [] + generic_commitment: false + # L2 contract deployer configuration - used for all L2 networks # The docker image that should be used for the L2 contract deployer op_contract_deployer_params: diff --git a/main.star b/main.star index 69678d2..2901d7c 100644 --- a/main.star +++ b/main.star @@ -27,6 +27,7 @@ def run(plan, args): global_node_selectors = optimism_args_with_right_defaults.global_node_selectors global_log_level = optimism_args_with_right_defaults.global_log_level persistent = optimism_args_with_right_defaults.persistent + da_server_params = args_with_right_defaults.da_server_params # Deploy the L1 plan.print("Deploying a local L1") @@ -55,6 +56,7 @@ def run(plan, args): l1_priv_key, l1_config_env_vars, optimism_args_with_right_defaults, + da_server_params, ) for chain in optimism_args_with_right_defaults.chains: diff --git a/optimism b/optimism new file mode 160000 index 0000000..90700b9 --- /dev/null +++ b/optimism @@ -0,0 +1 @@ +Subproject commit 90700b9bb37080961747420882b14578577d47cc diff --git a/src/alt-da/da-server/da_server_launcher.star b/src/alt-da/da-server/da_server_launcher.star new file mode 100644 index 0000000..53b3d39 --- /dev/null +++ b/src/alt-da/da-server/da_server_launcher.star @@ -0,0 +1,98 @@ +shared_utils = import_module( + "github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star" +) +constants = import_module( + "github.com/ethpandaops/ethereum-package/src/package_io/constants.star" +) + +# The dirpath of the data directory on the da-server container +# note that we use /home which is available but not persistent +# because we aren't mounting an external kurtosis file +# this means that the data is lost when the container is deleted +DATA_DIRPATH_ON_DA_SERVER_CONTAINER = "/home" + +# Port IDs +DA_SERVER_HTTP_PORT_ID = "http" + +# Port nums +DA_SERVER_HTTP_PORT_NUM = 3100 + + +def get_used_ports(): + used_ports = { + DA_SERVER_HTTP_PORT_ID: shared_utils.new_port_spec( + DA_SERVER_HTTP_PORT_NUM, + shared_utils.TCP_PROTOCOL, + shared_utils.HTTP_APPLICATION_PROTOCOL, + ), + } + return used_ports + +def launch( + plan, + service_name, + image, + da_server_extra_args, + generic_commitment, +): + + config = get_da_server_config( + plan, + service_name, + image, + da_server_extra_args, + generic_commitment, + ) + + da_server_service = plan.add_service(service_name, config) + + http_url = "http://{0}:{1}".format(da_server_service.ip_address, DA_SERVER_HTTP_PORT_NUM) + return new_da_server_context( + http_url=http_url, + generic_commitment=generic_commitment, + ) + + +def get_da_server_config( + plan, + service_name, + image, + da_server_extra_args, + generic_commitment, +): + ports = get_used_ports() + + cmd = [ + "da-server", + "--file.path=" + DATA_DIRPATH_ON_DA_SERVER_CONTAINER, + "--addr=0.0.0.0", + "--port=3100", + "--log.level=debug", + "--generic-commitment=" + str(generic_commitment), + ] + + if len(da_server_extra_args) > 0: + cmd.extend([param for param in da_server_extra_args]) + + return ServiceConfig( + image=image, + ports=ports, + cmd=cmd, + private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + ) + +def disabled_da_server_context(): + return new_da_server_context( + http_url="", + generic_commitment=True, + ) + +def new_da_server_context( + http_url, + generic_commitment +): + return struct( + enabled=http_url != "", + http_url=http_url, + generic_commitment=generic_commitment, + ) diff --git a/src/batcher/op-batcher/op_batcher_launcher.star b/src/batcher/op-batcher/op_batcher_launcher.star index e20d065..5d9125f 100644 --- a/src/batcher/op-batcher/op_batcher_launcher.star +++ b/src/batcher/op-batcher/op_batcher_launcher.star @@ -41,6 +41,7 @@ def launch( l1_config_env_vars, gs_batcher_private_key, batcher_params, + da_server_context, ): batcher_service_name = "{0}".format(service_name) @@ -53,6 +54,7 @@ def launch( l1_config_env_vars, gs_batcher_private_key, batcher_params, + da_server_context, ) batcher_service = plan.add_service(service_name, config) @@ -74,6 +76,7 @@ def get_batcher_config( l1_config_env_vars, gs_batcher_private_key, batcher_params, + da_server_context, ): cmd = [ "op-batcher", @@ -90,7 +93,10 @@ def get_batcher_config( "--max-channel-duration=1", "--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"], "--private-key=" + gs_batcher_private_key, - "--data-availability-type=blobs", + "--altda.enabled=" + str(da_server_context.enabled), + "--altda.da-server=" + da_server_context.http_url, + "--altda.da-service=" + str(da_server_context.generic_commitment), + "--data-availability-type=" + "calldata" if da_server_context.enabled else "blobs", ] cmd += batcher_params.extra_params diff --git a/src/cl/hildr/hildr_launcher.star b/src/cl/hildr/hildr_launcher.star index 266684f..d3eb2a9 100644 --- a/src/cl/hildr/hildr_launcher.star +++ b/src/cl/hildr/hildr_launcher.star @@ -73,6 +73,7 @@ def launch( existing_cl_clients, l1_config_env_vars, sequencer_enabled, + da_server_context, ): # beacon_node_identity_recipe = PostHttpRequestRecipe( # endpoint="/", @@ -103,6 +104,7 @@ def launch( existing_cl_clients, l1_config_env_vars, sequencer_enabled, + da_server_context, ) beacon_service = plan.add_service(service_name, config) @@ -143,6 +145,7 @@ def get_beacon_config( existing_cl_clients, l1_config_env_vars, sequencer_enabled, + da_server_context, ): EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format( el_context.ip_addr, @@ -169,6 +172,9 @@ def get_beacon_config( "--network=" + ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + "/rollup-{0}.json".format(launcher.network_params.network_id), + # TODO: support altda flags once they are implemented. + # See https://github.com/optimism-java/hildr/issues/134 + # eg: "--altda.enabled=" + str(da_server_context.enabled), ] sequencer_private_key = util.read_network_config_value( diff --git a/src/cl/op-node/op_node_launcher.star b/src/cl/op-node/op_node_launcher.star index 8376dbc..9eda1ad 100644 --- a/src/cl/op-node/op_node_launcher.star +++ b/src/cl/op-node/op_node_launcher.star @@ -73,6 +73,7 @@ def launch( existing_cl_clients, l1_config_env_vars, sequencer_enabled, + da_server_context, ): beacon_node_identity_recipe = PostHttpRequestRecipe( endpoint="/", @@ -104,6 +105,7 @@ def launch( l1_config_env_vars, beacon_node_identity_recipe, sequencer_enabled, + da_server_context, ) beacon_service = plan.add_service(service_name, config) @@ -148,6 +150,7 @@ def get_beacon_config( l1_config_env_vars, beacon_node_identity_recipe, sequencer_enabled, + da_server_context, ): EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format( el_context.ip_addr, @@ -178,7 +181,11 @@ def get_beacon_config( "--p2p.listen.ip=0.0.0.0", "--p2p.listen.tcp={0}".format(BEACON_DISCOVERY_PORT_NUM), "--p2p.listen.udp={0}".format(BEACON_DISCOVERY_PORT_NUM), + "--altda.enabled=" + str(da_server_context.enabled), + "--altda.da-service=" + str(da_server_context.generic_commitment), + "--altda.da-server=" + da_server_context.http_url, ] + plan.print(da_server_context.generic_commitment) sequencer_private_key = util.read_network_config_value( plan, diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index 19097d8..565e0c3 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -14,6 +14,7 @@ def deploy_contracts( priv_key, l1_config_env_vars, optimism_args, + da_server_params, # for alt-da ): l2_chain_ids = ",".join( [str(chain.network_params.network_id) for chain in optimism_args.chains] @@ -23,7 +24,11 @@ def deploy_contracts( name="op-deployer-init", description="Initialize L2 contract deployments", image=optimism_args.op_contract_deployer_params.image, - env_vars=l1_config_env_vars, + env_vars=l1_config_env_vars + | { + "USE_ALTDA": "true" if da_server_params.enabled else "false", + "DA_COMMITMENT_TYPE": "GenericCommitment" if da_server_params.generic_commitment else "KeccakCommitment" + }, store=[ StoreSpec( src="/network-data", diff --git a/src/el_cl_launcher.star b/src/el_cl_launcher.star index 92c245d..bf9dc04 100644 --- a/src/el_cl_launcher.star +++ b/src/el_cl_launcher.star @@ -30,6 +30,7 @@ def launch( global_node_selectors, global_tolerations, persistent, + da_server_context, ): el_launchers = { "op-geth": { @@ -177,6 +178,7 @@ def launch( all_cl_contexts, l1_config_env_vars, sequencer_enabled, + da_server_context, ) sequencer_enabled = False diff --git a/src/l2.star b/src/l2.star index f3ff471..b8b3f00 100644 --- a/src/l2.star +++ b/src/l2.star @@ -1,5 +1,6 @@ participant_network = import_module("./participant_network.star") blockscout = import_module("./blockscout/blockscout_launcher.star") +da_server_launcher = import_module("./alt-da/da-server/da_server_launcher.star") contract_deployer = import_module("./contracts/contract_deployer.star") input_parser = import_module("./package_io/input_parser.star") ethereum_package_static_files = import_module( @@ -30,6 +31,32 @@ def launch_l2( name="op_jwt_file{0}".format(l2_services_suffix), ) + # we need to launch da-server before launching the participant network + # because op-node and op-batcher need to know the da-server url, if present + da_server_context = da_server_launcher.disabled_da_server_context() + if "da_server" in args_with_right_defaults.additional_services: + da_server_image = args_with_right_defaults.da_server_params.image + if args_with_right_defaults.da_server_params.build_image: + plan.print("Building da-server image") + da_server_image = ImageBuildSpec( + image_name=args_with_right_defaults.da_server_params.image, + # TODO: this doesn't work... because can't point to a dir outside of the kurtosis package + # also can't install optimism monorepo as a submodule because that makes the kurtosis package > 100MB, which is not allowed. + # Not sure how to fix this... detailed problem in https://github.com/ethpandaops/optimism-package/issues/72 + build_context_dir="/optimism/ops/docker/op-stack-go", + target_stage="da-server-target", + ) + plan.print("Successfully built da-server image") + plan.print("Launching da-server") + da_server_context = da_server_launcher.launch( + plan, + "da-server{0}".format(l2_services_suffix), + da_server_image, + args_with_right_defaults.da_server_params.da_server_extra_args, + args_with_right_defaults.da_server_params.generic_commitment, + ) + plan.print("Successfully launched da-server") + all_l2_participants = participant_network.launch_participant_network( plan, l2_args.participants, @@ -43,6 +70,7 @@ def launch_l2( global_node_selectors, global_tolerations, persistent, + da_server_context, ) all_el_contexts = [] diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 7f19251..c9ad564 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -25,6 +25,13 @@ DEFAULT_PROPOSER_IMAGES = { "op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop", } +DEFAULT_DA_SERVER_IMAGES = { + # latest tag is super outdated, and doesn't have the --generic-commitment flag + # so we use the dev tag as default, which requires building locally (see default_da_server_params) + "da-server": "us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:dev", +} + + DEFAULT_ADDITIONAL_SERVICES = [] @@ -35,6 +42,14 @@ def input_parser(plan, input_args): results["global_node_selectors"] = {} results["global_tolerations"] = [] results["persistent"] = False + + results["da_server_params"] = default_da_server_params() + for attr, value in input_args.items(): + if attr == "da_server_params": + results["da_server_params"]["enabled"] = "true" + for sub_attr, sub_value in value.items(): + results["da_server_params"][sub_attr] = sub_value + return struct( chains=[ struct( @@ -99,6 +114,13 @@ def input_parser(plan, input_args): global_node_selectors=results["global_node_selectors"], global_tolerations=results["global_tolerations"], persistent=results["persistent"], + da_server_params=struct( + enabled=result["da_server_params"]["enabled"], + image=result["da_server_params"]["image"], + build_image=result["da_server_params"]["build_image"], + da_server_extra_args=result["da_server_params"]["da_server_extra_args"], + generic_commitment=result["da_server_params"]["generic_commitment"], + ), ) @@ -275,3 +297,12 @@ def default_ethereum_package_network_params(): ), } } + +def default_da_server_params(): + return { + "enabled": False, + "image": DEFAULT_DA_SERVER_IMAGES["da-server"], + "build_image": True, + "da_server_extra_args": [], + "generic_commitment": False, + } diff --git a/src/package_io/sanity_check.star b/src/package_io/sanity_check.star index 33fedb1..d350046 100644 --- a/src/package_io/sanity_check.star +++ b/src/package_io/sanity_check.star @@ -43,6 +43,12 @@ SUBCATEGORY_PARAMS = { "fund_dev_accounts", ], "batcher_params": ["image", "extra_params"], + "da_server_params": [ + "image", + "build_image", + "da_server_extra_args", + "generic_commitment", + ], } OP_CONTRACT_DEPLOYER_PARAMS = [ @@ -52,6 +58,7 @@ OP_CONTRACT_DEPLOYER_PARAMS = [ ADDITIONAL_SERVICES_PARAMS = [ "blockscout", + "da_server", ] ROOT_PARAMS = [ diff --git a/src/participant_network.star b/src/participant_network.star index ab8f244..06edc74 100644 --- a/src/participant_network.star +++ b/src/participant_network.star @@ -19,6 +19,7 @@ def launch_participant_network( global_node_selectors, global_tolerations, persistent, + da_server_context, ): num_participants = len(participants) # First EL and sequencer CL @@ -35,6 +36,7 @@ def launch_participant_network( global_node_selectors, global_tolerations, persistent, + da_server_context, ) all_participants = [] @@ -82,6 +84,7 @@ def launch_participant_network( l1_config_env_vars, batcher_key, batcher_params, + da_server_context, ) # The OP Stack don't run the proposer anymore, it has been replaced with the challenger From 29f0183eac76ca1b825a844626b048428feb92a3 Mon Sep 17 00:00:00 2001 From: Samuel Laferriere Date: Mon, 11 Nov 2024 22:39:08 +0400 Subject: [PATCH 2/2] wip: fixing altda after rebase --- README.md | 3 ++- main.star | 5 ++++- network_params.yaml | 9 ++++++++- src/l2.star | 12 ++++++------ src/package_io/input_parser.star | 32 ++++++++++++++------------------ 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 969730d..da2edfd 100644 --- a/README.md +++ b/README.md @@ -249,11 +249,12 @@ optimism_package: # Defaults to [] # Available services: # - blockscout + # - da_server additional_services: [] # Configuration place for da-server - https://github.com/ethereum-optimism/optimism/tree/develop/op-alt-da da_server_params: - image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:dev + image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest build_image: true # A list of optional extra params that will be passed to the da-server container for modifying its behaviour da_server_extra_args: [] diff --git a/main.star b/main.star index 2901d7c..2de6b72 100644 --- a/main.star +++ b/main.star @@ -27,7 +27,10 @@ def run(plan, args): global_node_selectors = optimism_args_with_right_defaults.global_node_selectors global_log_level = optimism_args_with_right_defaults.global_log_level persistent = optimism_args_with_right_defaults.persistent - da_server_params = args_with_right_defaults.da_server_params + # TODO: Not sure how to deal with these da_server_params, + # basically when/how to turn on altda mode. + # If any one chain uses altda?? + da_server_params = optimism_args_with_right_defaults.chains[0].da_server_params # Deploy the L1 plan.print("Deploying a local L1") diff --git a/network_params.yaml b/network_params.yaml index 5aed7bd..1e701d1 100644 --- a/network_params.yaml +++ b/network_params.yaml @@ -41,7 +41,14 @@ optimism_package: batcher_params: image: "" extra_params: [] - additional_services: [] + da_server_params: + image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest + build_image: false + # A list of optional extra params that will be passed to the da-server container for modifying its behaviour + da_server_extra_args: [] + generic_commitment: false + additional_services: + - da_server op_contract_deployer_params: image: mslipper/op-deployer:latest artifacts_url: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-4accd01f0c35c26f24d2aa71aba898dd7e5085a2ce5daadc8a84b10caf113409.tar.gz diff --git a/src/l2.star b/src/l2.star index b8b3f00..a8d5db8 100644 --- a/src/l2.star +++ b/src/l2.star @@ -34,12 +34,12 @@ def launch_l2( # we need to launch da-server before launching the participant network # because op-node and op-batcher need to know the da-server url, if present da_server_context = da_server_launcher.disabled_da_server_context() - if "da_server" in args_with_right_defaults.additional_services: - da_server_image = args_with_right_defaults.da_server_params.image - if args_with_right_defaults.da_server_params.build_image: + if "da_server" in l2_args.additional_services: + da_server_image = l2_args.da_server_params.image + if l2_args.da_server_params.build_image: plan.print("Building da-server image") da_server_image = ImageBuildSpec( - image_name=args_with_right_defaults.da_server_params.image, + image_name=l2_args.da_server_params.image, # TODO: this doesn't work... because can't point to a dir outside of the kurtosis package # also can't install optimism monorepo as a submodule because that makes the kurtosis package > 100MB, which is not allowed. # Not sure how to fix this... detailed problem in https://github.com/ethpandaops/optimism-package/issues/72 @@ -52,8 +52,8 @@ def launch_l2( plan, "da-server{0}".format(l2_services_suffix), da_server_image, - args_with_right_defaults.da_server_params.da_server_extra_args, - args_with_right_defaults.da_server_params.generic_commitment, + l2_args.da_server_params.da_server_extra_args, + l2_args.da_server_params.generic_commitment, ) plan.print("Successfully launched da-server") diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index c9ad564..9cb2fab 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -26,9 +26,7 @@ DEFAULT_PROPOSER_IMAGES = { } DEFAULT_DA_SERVER_IMAGES = { - # latest tag is super outdated, and doesn't have the --generic-commitment flag - # so we use the dev tag as default, which requires building locally (see default_da_server_params) - "da-server": "us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:dev", + "da-server": "us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest", } @@ -43,13 +41,6 @@ def input_parser(plan, input_args): results["global_tolerations"] = [] results["persistent"] = False - results["da_server_params"] = default_da_server_params() - for attr, value in input_args.items(): - if attr == "da_server_params": - results["da_server_params"]["enabled"] = "true" - for sub_attr, sub_value in value.items(): - results["da_server_params"][sub_attr] = sub_value - return struct( chains=[ struct( @@ -102,6 +93,13 @@ def input_parser(plan, input_args): image=result["batcher_params"]["image"], extra_params=result["batcher_params"]["extra_params"], ), + da_server_params=struct( + enabled=result["da_server_params"]["enabled"], + image=result["da_server_params"]["image"], + build_image=result["da_server_params"]["build_image"], + da_server_extra_args=result["da_server_params"]["da_server_extra_args"], + generic_commitment=result["da_server_params"]["generic_commitment"], + ), additional_services=result["additional_services"], ) for result in results["chains"] @@ -114,13 +112,6 @@ def input_parser(plan, input_args): global_node_selectors=results["global_node_selectors"], global_tolerations=results["global_tolerations"], persistent=results["persistent"], - da_server_params=struct( - enabled=result["da_server_params"]["enabled"], - image=result["da_server_params"]["image"], - build_image=result["da_server_params"]["build_image"], - da_server_extra_args=result["da_server_params"]["da_server_extra_args"], - generic_commitment=result["da_server_params"]["generic_commitment"], - ), ) @@ -137,6 +128,9 @@ def parse_network_params(plan, input_args): batcher_params = default_batcher_params() batcher_params.update(chain.get("batcher_params", {})) + da_server_params = default_da_server_params() + da_server_params.update(chain.get("da_server_params", {})) + network_name = network_params["name"] network_id = network_params["network_id"] @@ -181,6 +175,7 @@ def parse_network_params(plan, input_args): "participants": participants, "network_params": network_params, "batcher_params": batcher_params, + "da_server_params": da_server_params, "additional_services": chain.get( "additional_services", DEFAULT_ADDITIONAL_SERVICES ), @@ -214,6 +209,7 @@ def default_chains(): "participants": [default_participant()], "network_params": default_network_params(), "batcher_params": default_batcher_params(), + "da_server_params": default_da_server_params(), "additional_services": DEFAULT_ADDITIONAL_SERVICES, } ] @@ -302,7 +298,7 @@ def default_da_server_params(): return { "enabled": False, "image": DEFAULT_DA_SERVER_IMAGES["da-server"], - "build_image": True, + "build_image": False, "da_server_extra_args": [], "generic_commitment": False, }