From 163884494717591dda0a302fafcb690fc6a2051d Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Thu, 6 Jun 2024 14:20:03 +0200 Subject: [PATCH] feat: add op_batcher + op_deployer --- main.star | 7 +- .../op-batcher/op_batcher_launcher.star | 70 ++++----------- src/cl/cl_launcher.star | 4 +- src/contracts/contract_deployer.star | 15 +++- src/package_io/input_parser.star | 4 +- src/participant_network.star | 30 +++++-- .../op-proposer/op_proposer_launcher.star | 90 +++++++++++++++++++ 7 files changed, 149 insertions(+), 71 deletions(-) diff --git a/main.star b/main.star index ef8f160..e2e68dc 100644 --- a/main.star +++ b/main.star @@ -65,7 +65,11 @@ def run(plan, args={}): l2_config_env_vars["L2_CHAIN_ID"] = str(network_params.network_id) l2_config_env_vars["L2_BLOCK_TIME"] = str(network_params.seconds_per_slot) - el_cl_data, gs_private_keys = contract_deployer.launch_contract_deployer( + ( + el_cl_data, + gs_private_keys, + l2oo_address, + ) = contract_deployer.launch_contract_deployer( plan, l1_priv_key, l1_config_env_vars, @@ -88,6 +92,7 @@ def run(plan, args={}): el_cl_data, gs_private_keys, l1_config_env_vars, + l2oo_address, ) plan.print(all_participants) diff --git a/src/batcher/op-batcher/op_batcher_launcher.star b/src/batcher/op-batcher/op_batcher_launcher.star index c740291..eb996b4 100644 --- a/src/batcher/op-batcher/op_batcher_launcher.star +++ b/src/batcher/op-batcher/op_batcher_launcher.star @@ -6,23 +6,22 @@ constants = import_module( "github.com/kurtosis-tech/ethereum-package/src/package_io/constants.star" ) - # # ---------------------------------- Batcher client ------------------------------------- # The Docker container runs as the "op-batcher" user so we can't write to root -BATCHER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-batcher/op-batcher-beacon-data" +BATCHER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-batcher/op-batcher-data" # Port IDs -BEACON_HTTP_PORT_ID = "http" +BATCHER_HTTP_PORT_ID = "http" # Port nums -BEACON_HTTP_PORT_NUM = 8548 +BATCHER_HTTP_PORT_NUM = 8548 -def get_used_ports(discovery_port): +def get_used_ports(): used_ports = { - BEACON_HTTP_PORT_ID: shared_utils.new_port_spec( - BEACON_HTTP_PORT_NUM, + BATCHER_HTTP_PORT_ID: shared_utils.new_port_spec( + BATCHER_HTTP_PORT_NUM, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL, ), @@ -32,54 +31,40 @@ def get_used_ports(discovery_port): ENTRYPOINT_ARGS = ["sh", "-c"] -VERBOSITY_LEVELS = { - constants.GLOBAL_LOG_LEVEL.error: "ERROR", - constants.GLOBAL_LOG_LEVEL.warn: "WARN", - constants.GLOBAL_LOG_LEVEL.info: "INFO", - constants.GLOBAL_LOG_LEVEL.debug: "DEBUG", - constants.GLOBAL_LOG_LEVEL.trace: "TRACE", -} - def launch( plan, - launcher, service_name, image, el_context, - existing_cl_clients, + cl_context, l1_config_env_vars, gs_batcher_private_key, ): - beacon_service_name = "{0}".format(service_name) + batcher_service_name = "{0}".format(service_name) - network_name = shared_utils.get_network_name(launcher.network) - config = get_beacon_config( + config = get_batcher_config( plan, - launcher.el_cl_genesis_data, - launcher.jwt_file, image, service_name, el_context, - existing_cl_clients, + cl_context, l1_config_env_vars, gs_batcher_private_key, ) - beacon_service = plan.add_service(service_name, config) + batcher_service = plan.add_service(service_name, config) - beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID] - beacon_http_url = "http://{0}:{1}".format( - beacon_service.ip_address, beacon_http_port.number + batcher_http_port = batcher_service.ports[BATCHER_HTTP_PORT_ID] + batcher_http_url = "http://{0}:{1}".format( + batcher_service.ip_address, batcher_http_port.number ) return "op_batcher" -def get_beacon_config( +def get_batcher_config( plan, - el_cl_genesis_data, - jwt_file, image, service_name, el_context, @@ -87,9 +72,6 @@ def get_beacon_config( l1_config_env_vars, gs_batcher_private_key, ): - discovery_port = BEACON_DISCOVERY_PORT_NUM - used_ports = get_used_ports(discovery_port) - cmd = [ "--l2-eth-rpc=" + el_context.rpc_http_url, "--rollup-rpc=" + cl_context.beacon_http_url, @@ -99,35 +81,17 @@ def get_beacon_config( "--safe-abort-nonce-too-low-count=3", "--resubmission-timeout=30s", "--rpc.addr=0.0.0.0", - "--rpc.port=" + BEACON_HTTP_PORT_NUM, + "--rpc.port=" + str(BATCHER_HTTP_PORT_NUM), "--rpc.enable-admin", "--max-channel-duration=1", "--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"], "--private-key=" + gs_batcher_private_key, ] - files = { - constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data, - constants.JWT_MOUNTPOINT_ON_CLIENTS: jwt_file, - } - ports = {} - ports.update(used_ports) - + ports = get_used_ports() return ServiceConfig( image=image, ports=ports, cmd=cmd, - files=files, private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( - BEACON_HTTP_PORT_ID - ), - ) - - -def new_op_node_launcher(el_cl_genesis_data, jwt_file, network_params): - return struct( - el_cl_genesis_data=el_cl_genesis_data, - jwt_file=jwt_file, - network=network_params.network, ) diff --git a/src/cl/cl_launcher.star b/src/cl/cl_launcher.star index 0c4c2e2..d874af2 100644 --- a/src/cl/cl_launcher.star +++ b/src/cl/cl_launcher.star @@ -5,8 +5,6 @@ shared_utils = import_module( "github.com/kurtosis-tech/ethereum-package/src/shared_utils/shared_utils.star" ) -cl_context_BOOTNODE = None - op_node = import_module("./op-node/op_node_launcher.star") @@ -71,4 +69,4 @@ def launch( ) all_cl_contexts.append(cl_context) - return (all_cl_contexts,) + return all_cl_contexts diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index a553ecb..148c0a9 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -69,9 +69,10 @@ def launch_contract_deployer( "mv $DEPLOY_CONFIG_PATH /network-configs/getting-started.json", "mv $DEPLOYMENT_OUTFILE /network-configs/kurtosis.json", "mv $STATE_DUMP_PATH /network-configs/state-dump.json", - "echo -n $GS_SEQUENCER_PRIVATE_KEY >> /network-configs/GS_SEQUENCER_PRIVATE_KEY", - "echo -n $GS_BATCHER_PRIVATE_KEY >> /network-configs/GS_BATCHER_PRIVATE_KEY", - "echo -n $GS_PROPOSER_PRIVATE_KEY >> /network-configs/GS_PROPOSER_PRIVATE_KEY", + "echo -n $GS_SEQUENCER_PRIVATE_KEY > /network-configs/GS_SEQUENCER_PRIVATE_KEY", + "echo -n $GS_BATCHER_PRIVATE_KEY > /network-configs/GS_BATCHER_PRIVATE_KEY", + "echo -n $GS_PROPOSER_PRIVATE_KEY > /network-configs/GS_PROPOSER_PRIVATE_KEY", + "cat $DEPLOYMENT_OUTFILE | jq -r .L2OutputOracleProxy > /network-configs/L2OutputOracleProxy.json", ] ), wait="2000s", @@ -95,10 +96,16 @@ def launch_contract_deployer( files={"/network-configs": op_genesis.files_artifacts[0]}, ) + l2oo_address = plan.run_sh( + description="Getting the L2OutputOracleProxy address", + run="cat /network-configs/L2OutputOracleProxy.json", + files={"/network-configs": op_genesis.files_artifacts[0]}, + ) + private_keys = { "GS_SEQUENCER_PRIVATE_KEY": gs_sequencer_private_key.output, "GS_BATCHER_PRIVATE_KEY": gs_batcher_private_key.output, "GS_PROPOSER_PRIVATE_KEY": gs_proposer_private_key.output, } - return op_genesis.files_artifacts[0], private_keys + return op_genesis.files_artifacts[0], private_keys, l2oo_address.output diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 1c6a4f1..c535bab 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -11,11 +11,11 @@ DEFAULT_CL_IMAGES = { } DEFAULT_BATCHER_IMAGES = { - "op-batcher": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:develop", + "op-batcher": "parithoshj/op-batcher:v1", } DEFAULT_PROPOSER_IMAGES = { - "op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop", + "op-proposer": "parithoshj/op-proposer:v1", } ATTR_TO_BE_SKIPPED_AT_ROOT = ( diff --git a/src/participant_network.star b/src/participant_network.star index 1a12987..0b47007 100644 --- a/src/participant_network.star +++ b/src/participant_network.star @@ -1,6 +1,9 @@ el_client_launcher = import_module("./el/el_launcher.star") cl_client_launcher = import_module("./cl/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_proposer_launcher = import_module("./proposer/op-proposer/op_proposer_launcher.star") def launch_participant_network( @@ -11,6 +14,7 @@ def launch_participant_network( el_cl_data, gs_private_keys, l1_config_env_vars, + l2oo_address, ): num_participants = len(participants) # Launch all execution layer clients @@ -52,14 +56,24 @@ def launch_participant_network( all_participants.append(participant_entry) - # op_batcher_launcher.launch( - # plan, - # ) - # participant_module.new_participant( - - # ) - # op_proposer_launcher.launch( + op_batcher_launcher.launch( + plan, + "op-batcher", + input_parser.DEFAULT_BATCHER_IMAGES["op-batcher"], + all_el_contexts[0], + all_cl_contexts[0], + l1_config_env_vars, + gs_private_keys["GS_BATCHER_PRIVATE_KEY"], + ) - # ) + op_proposer_launcher.launch( + plan, + "op-proposer", + input_parser.DEFAULT_PROPOSER_IMAGES["op-proposer"], + all_cl_contexts[0], + l1_config_env_vars, + gs_private_keys["GS_PROPOSER_PRIVATE_KEY"], + l2oo_address, + ) return all_participants diff --git a/src/proposer/op-proposer/op_proposer_launcher.star b/src/proposer/op-proposer/op_proposer_launcher.star index e69de29..7099b50 100644 --- a/src/proposer/op-proposer/op_proposer_launcher.star +++ b/src/proposer/op-proposer/op_proposer_launcher.star @@ -0,0 +1,90 @@ +shared_utils = import_module( + "github.com/kurtosis-tech/ethereum-package/src/shared_utils/shared_utils.star" +) + +constants = import_module( + "github.com/kurtosis-tech/ethereum-package/src/package_io/constants.star" +) + +# +# ---------------------------------- Batcher client ------------------------------------- +# The Docker container runs as the "op-proposer" user so we can't write to root +PROPOSER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-proposer/op-proposer-data" + +# Port IDs +PROPOSER_HTTP_PORT_ID = "http" + +# Port nums +PROPOSER_HTTP_PORT_NUM = 8560 + + +def get_used_ports(): + used_ports = { + PROPOSER_HTTP_PORT_ID: shared_utils.new_port_spec( + PROPOSER_HTTP_PORT_NUM, + shared_utils.TCP_PROTOCOL, + shared_utils.HTTP_APPLICATION_PROTOCOL, + ), + } + return used_ports + + +ENTRYPOINT_ARGS = ["sh", "-c"] + + +def launch( + plan, + service_name, + image, + cl_context, + l1_config_env_vars, + gs_proposer_private_key, + l2oo_address, +): + proposer_service_name = "{0}".format(service_name) + + config = get_proposer_config( + plan, + image, + service_name, + cl_context, + l1_config_env_vars, + gs_proposer_private_key, + l2oo_address, + ) + + proposer_service = plan.add_service(service_name, config) + + proposer_http_port = proposer_service.ports[PROPOSER_HTTP_PORT_ID] + proposer_http_url = "http://{0}:{1}".format( + proposer_service.ip_address, proposer_http_port.number + ) + + return "op_proposer" + + +def get_proposer_config( + plan, + image, + service_name, + cl_context, + l1_config_env_vars, + gs_proposer_private_key, + l2oo_address, +): + cmd = [ + "--poll-interval=12s", + "--rpc.port=" + str(PROPOSER_HTTP_PORT_NUM), + "--rollup-rpc=" + cl_context.beacon_http_url, + "--l2oo-address=" + str(l2oo_address), + "--private-key=" + gs_proposer_private_key, + "--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"], + ] + + ports = get_used_ports() + return ServiceConfig( + image=image, + ports=ports, + cmd=cmd, + private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + )