From 03faabb88c4f2d3c1cba01894f942464bc2def1c Mon Sep 17 00:00:00 2001 From: Zach Howard Date: Wed, 18 Dec 2024 14:35:04 -0500 Subject: [PATCH] feat: adds op-challenger support --- README.md | 25 +++++ main.star | 7 ++ .../op-challenger/op_challenger_launcher.star | 106 ++++++++++++++++++ src/cl/op-node/op_node_launcher.star | 1 + src/l2.star | 4 + src/package_io/input_parser.star | 25 +++++ src/package_io/sanity_check.star | 2 + src/participant_network.star | 30 +++++ static_files/prestates/prestate-proof.json | 8 ++ 9 files changed, 208 insertions(+) create mode 100644 src/challenger/op-challenger/op_challenger_launcher.star create mode 100755 static_files/prestates/prestate-proof.json diff --git a/README.md b/README.md index 7add927d..cf2a050c 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,28 @@ optimism_package: # A list of optional extra params that will be passed to the batcher container for modifying its behaviour extra_params: [] + # Default challenger configuration + challenger_params: + # The Docker image that should be used for the challenger; leave blank to use the default op-challenger image + image: "" + + # A list of optional extra params that will be passed to the challenger container for modifying its behaviour + extra_params: [] + + # Default proposer configuration + proposer_params: + # The Docker image that should be used for the proposer; leave blank to use the default op-proposer image + image: "" + + # A list of optional extra params that will be passed to the proposer container for modifying its behaviour + extra_params: [] + + # Dispute game type to create via the configured DisputeGameFactory + game_type: 1 + + # Interval between submitting L2 output proposals + proposal_internal: 10m + # Default MEV configuration mev_params: # The Docker image that should be used for rollup boost; leave blank to use the default rollup-boost image @@ -350,6 +372,9 @@ optimism_package: # Defaults to false persistent: false + # Path to folder containing cannon prestate-proof.json file + prestates_path: "static_files/prestates" + # Ethereum package configuration ethereum_package: network_params: diff --git a/main.star b/main.star index 66baba2f..7ae88d4b 100644 --- a/main.star +++ b/main.star @@ -33,6 +33,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 + prestates_path = optimism_args_with_right_defaults.prestates_path # Deploy the L1 l1_network = "" @@ -82,6 +83,11 @@ def run(plan, args): l1_network, ) + prestates_artifact = plan.upload_files( + src=prestates_path, + name="op-challenger-prestates", + ) + for l2_num, chain in enumerate(optimism_args_with_right_defaults.chains): l2_launcher.launch_l2( plan, @@ -89,6 +95,7 @@ def run(plan, args): chain.network_params.name, chain, deployment_output, + prestates_artifact, l1_config_env_vars, l1_priv_key, l1_rpc_url, diff --git a/src/challenger/op-challenger/op_challenger_launcher.star b/src/challenger/op-challenger/op_challenger_launcher.star new file mode 100644 index 00000000..f3e46de4 --- /dev/null +++ b/src/challenger/op-challenger/op_challenger_launcher.star @@ -0,0 +1,106 @@ +ethereum_package_shared_utils = import_module( + "github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star" +) + +ethereum_package_constants = import_module( + "github.com/ethpandaops/ethereum-package/src/package_io/constants.star" +) + +# +# ---------------------------------- Challenger client ------------------------------------- +CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-challenger/op-challenger-data" +ENTRYPOINT_ARGS = ["sh", "-c"] + + +def get_used_ports(): + used_ports = {} + return used_ports + + +def launch( + plan, + service_name, + image, + el_context, + cl_context, + l1_config_env_vars, + gs_challenger_private_key, + game_factory_address, + deployment_output, + prestates_artifact, + network_params, + challenger_params, +): + challenger_service_name = "{0}".format(service_name) + + config = get_challenger_config( + plan, + service_name, + image, + el_context, + cl_context, + l1_config_env_vars, + gs_challenger_private_key, + game_factory_address, + deployment_output, + prestates_artifact, + network_params, + challenger_params, + ) + + challenger_service = plan.add_service(service_name, config) + + return "op_challenger" + + +def get_challenger_config( + plan, + service_name, + image, + el_context, + cl_context, + l1_config_env_vars, + gs_challenger_private_key, + game_factory_address, + deployment_output, + prestates_artifact, + network_params, + challenger_params, +): + cmd = [ + "op-challenger", + "--cannon-l2-genesis=" + + ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + + "/genesis-{0}.json".format(network_params.network_id), + "--cannon-prestate=/prestates/prestate-proof.json", + "--cannon-rollup-config=" + + ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + + "/rollup-{0}.json".format(network_params.network_id), + "--game-factory-address=" + game_factory_address, + "--datadir=" + CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER, + "--l1-beacon=" + l1_config_env_vars["CL_RPC_URL"], + "--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"], + "--l2-eth-rpc=" + el_context.rpc_http_url, + "--private-key=" + gs_challenger_private_key, + "--rollup-rpc=" + cl_context.beacon_http_url, + "--trace-type=" + "cannon,permissioned", + ] + cmd += challenger_params.extra_params + cmd = "mkdir -p {0} && {1}".format( + CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER, " ".join(cmd) + ) + + files = { + ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: deployment_output, + "/prestates": prestates_artifact, + } + + ports = get_used_ports() + return ServiceConfig( + image=image, + ports=ports, + entrypoint=ENTRYPOINT_ARGS, + cmd=[cmd], + files=files, + private_ip_address_placeholder=ethereum_package_constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + ) diff --git a/src/cl/op-node/op_node_launcher.star b/src/cl/op-node/op_node_launcher.star index 97c10495..31b14783 100644 --- a/src/cl/op-node/op_node_launcher.star +++ b/src/cl/op-node/op_node_launcher.star @@ -178,6 +178,7 @@ 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), + "--safedb.path={0}".format(BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER), ] sequencer_private_key = util.read_network_config_value( diff --git a/src/l2.star b/src/l2.star index 5d6acf82..5153789b 100644 --- a/src/l2.star +++ b/src/l2.star @@ -14,6 +14,7 @@ def launch_l2( l2_services_suffix, l2_args, deployment_output, + prestates_artifact, l1_config, l1_priv_key, l1_rpc_url, @@ -24,6 +25,7 @@ def launch_l2( ): network_params = l2_args.network_params batcher_params = l2_args.batcher_params + challenger_params = l2_args.challenger_params proposer_params = l2_args.proposer_params mev_params = l2_args.mev_params @@ -39,9 +41,11 @@ def launch_l2( jwt_file, network_params, batcher_params, + challenger_params, proposer_params, mev_params, deployment_output, + prestates_artifact, l1_config, l2_num, l2_services_suffix, diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 96772577..d4efd4a3 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -21,6 +21,10 @@ DEFAULT_BATCHER_IMAGES = { "op-batcher": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:develop", } +DEFAULT_CHALLENGER_IMAGES = { + "op-challenger": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-challenger:develop", +} + DEFAULT_PROPOSER_IMAGES = { "op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop", } @@ -108,6 +112,10 @@ def input_parser(plan, input_args): image=result["batcher_params"]["image"], extra_params=result["batcher_params"]["extra_params"], ), + challenger_params=struct( + image=result["challenger_params"]["image"], + extra_params=result["challenger_params"]["extra_params"], + ), proposer_params=struct( image=result["proposer_params"]["image"], extra_params=result["proposer_params"]["extra_params"], @@ -136,6 +144,7 @@ def input_parser(plan, input_args): global_node_selectors=results["global_node_selectors"], global_tolerations=results["global_tolerations"], persistent=results["persistent"], + prestates_path=results["prestates_path"], ) @@ -152,6 +161,9 @@ def parse_network_params(plan, input_args): batcher_params = default_batcher_params() batcher_params.update(chain.get("batcher_params", {})) + challenger_params = default_challenger_params() + challenger_params.update(chain.get("challenger_params", {})) + proposer_params = default_proposer_params() proposer_params.update(chain.get("proposer_params", {})) @@ -230,6 +242,7 @@ def parse_network_params(plan, input_args): "participants": participants, "network_params": network_params, "batcher_params": batcher_params, + "challenger_params": challenger_params, "proposer_params": proposer_params, "mev_params": mev_params, "additional_services": chain.get( @@ -244,6 +257,9 @@ def parse_network_params(plan, input_args): input_args.get("op_contract_deployer_params", {}) ) results["global_log_level"] = input_args.get("global_log_level", "info") + results["prestates_path"] = input_args.get( + "prestates_path", "static_files/prestates" + ) return results @@ -256,6 +272,7 @@ def default_optimism_args(): "global_node_selectors": {}, "global_tolerations": [], "persistent": False, + "prestates_path": "static_files/prestates", } @@ -273,6 +290,7 @@ def default_chains(): "participants": [default_participant()], "network_params": default_network_params(), "batcher_params": default_batcher_params(), + "challenger_params": default_challenger_params(), "proposer_params": default_proposer_params(), "mev_params": default_mev_params(), "additional_services": DEFAULT_ADDITIONAL_SERVICES, @@ -302,6 +320,13 @@ def default_batcher_params(): } +def default_challenger_params(): + return { + "image": "", + "extra_params": [], + } + + def default_proposer_params(): return { "image": "", diff --git a/src/package_io/sanity_check.star b/src/package_io/sanity_check.star index 68a38ac1..f967df00 100644 --- a/src/package_io/sanity_check.star +++ b/src/package_io/sanity_check.star @@ -48,6 +48,7 @@ SUBCATEGORY_PARAMS = { "fund_dev_accounts", ], "batcher_params": ["image", "extra_params"], + "challenger_params": ["image", "extra_params"], "proposer_params": ["image", "extra_params", "game_type", "proposal_interval"], "mev_params": ["rollup_boost_image", "builder_host", "builder_port"], } @@ -70,6 +71,7 @@ ROOT_PARAMS = [ "global_node_selectors", "global_tolerations", "persistent", + "prestates_path", ] diff --git a/src/participant_network.star b/src/participant_network.star index 824263ab..e282806f 100644 --- a/src/participant_network.star +++ b/src/participant_network.star @@ -2,6 +2,9 @@ el_cl_client_launcher = import_module("./el_cl_launcher.star") participant_module = import_module("./participant.star") input_parser = import_module("./package_io/input_parser.star") op_batcher_launcher = import_module("./batcher/op-batcher/op_batcher_launcher.star") +op_challenger_launcher = import_module( + "./challenger/op-challenger/op_challenger_launcher.star" +) op_proposer_launcher = import_module("./proposer/op-proposer/op_proposer_launcher.star") util = import_module("./util.star") @@ -12,9 +15,11 @@ def launch_participant_network( jwt_file, network_params, batcher_params, + challenger_params, proposer_params, mev_params, deployment_output, + prestates_artifact, l1_config_env_vars, l2_num, l2_services_suffix, @@ -88,6 +93,31 @@ def launch_participant_network( "state", ".opChainDeployments[{0}].disputeGameFactoryProxyAddress".format(l2_num), ) + challenger_key = util.read_network_config_value( + plan, + deployment_output, + "challenger-{0}".format(network_params.network_id), + ".privateKey", + ) + op_challenger_image = ( + challenger_params.image + if challenger_params.image != "" + else input_parser.DEFAULT_CHALLENGER_IMAGES["op-challenger"] + ) + op_challenger_launcher.launch( + plan, + "op-challenger-{0}".format(l2_services_suffix), + op_challenger_image, + all_el_contexts[0], + all_cl_contexts[0], + l1_config_env_vars, + challenger_key, + game_factory_address, + deployment_output, + prestates_artifact, + network_params, + challenger_params, + ) proposer_key = util.read_network_config_value( plan, diff --git a/static_files/prestates/prestate-proof.json b/static_files/prestates/prestate-proof.json new file mode 100755 index 00000000..23871f68 --- /dev/null +++ b/static_files/prestates/prestate-proof.json @@ -0,0 +1,8 @@ +{ + "step": 0, + "pre": "0x03ce1018d75e7f6fbd5e815d64376e1e82a1334456d5a50be0afabeb17a8a421", + "post": "0x0315e881131ef96baffee5184c11c953c7fdfd9285c718cb1ac54a6283c0ea5f", + "state-data": "0x7918ea9554d1b92c840422beadbbd557fa73e66054bc7e06e4c3100367d1e07e000000000000000000000000000000000000000000000000000000000000000000000000000b8e60000b8e640000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffd0000000000000000000", + "proof-data": "0x0802e3940000000000000000000000003c01000b2421617c00200008000000008fb7000023bd00f802e00008000000008fa4000023a500040802e39c00000000e6e13ab33c13b7c5ab8dd2460d69d876b824fabf1a061c1de6b52b5059932274db9f30f7255f6be0c6bb974735e3723b3aa819e698556497dbbced9276dc5711652054894e3720fc284b59fc2cab41b8719ad830df29b1c60f393b52d10b98dcedb7e9ffde946fd94f6b2c10b8501ef0193f796656df23aefe537e9a28ffb3ea1ff0a7b9c78670b358b4a0876b2a64ad9006f281facecfec6f4d19c95f4a9ff1d9ddf4224339581003567680d0425facaa73fc6c558ce7767f7ce7451b6aeb801a931a0f0cb866780afd50d61ecd99f52099cefe1ac83f0f3f59c93ce559dd164dc2bc151618c363f38bbfe60a194bd7f239da7eead37fc9271d9a3fd26be85e3db62c86327a8ac8a238265089d931e8ce786881bfe13017c2765b39830875e7ab2a7aedc8d01896c7f7298f10dc8ea15e7ab41750bc7dd6ababfaa8112667b94ed7d7eb2f10bd66bc811505e4728e327ee428e1d89314cac1b6c6a5056504ed6f90a88d44ed0eed9cc7cf9ffec8a44d2e2047a80a260560a95a1906b8e93fa116d2321217e50c05cc0cf5bd69778766cfc63a79cac154b653e9e54177ac4d063edba23c9e364396c62106276860881d8b417d8c16254b5554da28f1e17355f5322b1acc8bea58f0ee9d21f1ff415cacd3460159067ec583ef505f5c2cf1b847b832e5e82e32a2e92ad0a79a9742c465b1383b0f19547b0c308e0b6a637bd531ed482dabb189dbdf9909c82569c822b07a8ed5110418c133764d43785a8fa75b69f138bc4002ffc97516bad2ebfabe121735495387b5072e67a640b0ca8ccb0114224cfa7c0cf3009790ac96e2f7689df915a0ae88b82e238668aefdb3478ab2ffc1e3dd17153f19fe95d2af10a51a85cf0f09b72ee1d6a118be2be1d35845b9f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef595531c28e98ea6e36fe4ab6cace6caf693027a8539fe6ee29c3deafe1b70ec5b8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" +} +