From 5b085c892aa02448af21e6e50b11b169a879c05f Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Wed, 23 Oct 2024 23:22:38 +0400 Subject: [PATCH] fix: handling of config options (#85) This PR adds 2 configuration options and fixes handling of existing ones: - `fund_dev_accounts` option is added to `network_params`, allowing to configure whether dev accounts should be funded on L2. In one of recent updates they stopped being funded by default, this PR changes it, let me know if this is undesired - adds `batcher_image` option allowing to configure custom op-batcher image - fixes handling of `el_extra_params`, right now this argument is not respected - fixes handling of `seconds_per_slot`, right now this argument is not respected Also it seems that `count` key for participants is no more respected. Is this intentional? --- README.md | 11 ++++++ network_params.yaml | 4 +++ .../op-batcher/op_batcher_launcher.star | 5 +++ src/cl/hildr/hildr_launcher.star | 2 ++ src/cl/op-node/op_node_launcher.star | 2 ++ src/contracts/contract_deployer.star | 34 ++++++++++++++++--- src/el/op-besu/op_besu_launcher.star | 1 + src/el/op-erigon/op_erigon_launcher.star | 1 + src/el/op-geth/op_geth_launcher.star | 1 + .../op-nethermind/op_nethermind_launcher.star | 2 ++ src/el/op-reth/op_reth_launcher.star | 1 + src/l2.star | 6 ++-- src/package_io/input_parser.star | 23 ++++++++++--- src/package_io/sanity_check.star | 2 ++ src/participant_network.star | 10 +++++- 15 files changed, 91 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 82205c86..c8038dfe 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,17 @@ optimism_package: # Offset is in seconds interop_time_offset: "" + # Whether to fund dev accounts on L2 + # Defaults to True + fund_dev_accounts: true + + # Default batcher configuration + batcher_params: + # The Docker image that should be used for the batcher; leave blank to use the default op-batcher image + image: "" + + # A list of optional extra params that will be passed to the batcher container for modifying its behaviour + extra_params: [] # Additional services to run alongside the network # Defaults to [] diff --git a/network_params.yaml b/network_params.yaml index 6af39b25..5aed7bd0 100644 --- a/network_params.yaml +++ b/network_params.yaml @@ -37,6 +37,10 @@ optimism_package: granite_time_offset: "" holocene_time_offset: "" interop_time_offset: "" + fund_dev_accounts: true + batcher_params: + image: "" + extra_params: [] additional_services: [] op_contract_deployer_params: image: mslipper/op-deployer:latest diff --git a/src/batcher/op-batcher/op_batcher_launcher.star b/src/batcher/op-batcher/op_batcher_launcher.star index 112205aa..e20d0654 100644 --- a/src/batcher/op-batcher/op_batcher_launcher.star +++ b/src/batcher/op-batcher/op_batcher_launcher.star @@ -40,6 +40,7 @@ def launch( cl_context, l1_config_env_vars, gs_batcher_private_key, + batcher_params, ): batcher_service_name = "{0}".format(service_name) @@ -51,6 +52,7 @@ def launch( cl_context, l1_config_env_vars, gs_batcher_private_key, + batcher_params, ) batcher_service = plan.add_service(service_name, config) @@ -71,6 +73,7 @@ def get_batcher_config( cl_context, l1_config_env_vars, gs_batcher_private_key, + batcher_params, ): cmd = [ "op-batcher", @@ -90,6 +93,8 @@ def get_batcher_config( "--data-availability-type=blobs", ] + cmd += batcher_params.extra_params + ports = get_used_ports() return ServiceConfig( image=image, diff --git a/src/cl/hildr/hildr_launcher.star b/src/cl/hildr/hildr_launcher.star index 0cd2d9fa..266684f4 100644 --- a/src/cl/hildr/hildr_launcher.star +++ b/src/cl/hildr/hildr_launcher.star @@ -196,6 +196,8 @@ def get_beacon_config( ) ) + cmd += participant.cl_extra_params + files = { ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.deployment_output, ethereum_package_constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file, diff --git a/src/cl/op-node/op_node_launcher.star b/src/cl/op-node/op_node_launcher.star index 9e1477b8..8376dbca 100644 --- a/src/cl/op-node/op_node_launcher.star +++ b/src/cl/op-node/op_node_launcher.star @@ -205,6 +205,8 @@ def get_beacon_config( ) ) + cmd += participant.cl_extra_params + files = { ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.deployment_output, ethereum_package_constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file, diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index 29e46fc0..19097d8c 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -40,6 +40,32 @@ def deploy_contracts( ), ) + intent_updates = ( + [ + ( + "string", + "contractArtifactsURL", + optimism_args.op_contract_deployer_params.artifacts_url, + ), + ] + + [ + ( + "int", + "chains.[{0}].deployOverrides.l2BlockTime".format(index), + str(chain.network_params.seconds_per_slot), + ) + for index, chain in enumerate(optimism_args.chains) + ] + + [ + ( + "bool", + "chains.[{0}].deployOverrides.fundDevAccounts".format(index), + "true" if chain.network_params.fund_dev_accounts else "false", + ) + for index, chain in enumerate(optimism_args.chains) + ] + ) + op_deployer_configure = plan.run_sh( name="op-deployer-configure", description="Configure L2 contract deployments", @@ -55,10 +81,10 @@ def deploy_contracts( }, run=" && ".join( [ - "cat /network-data/intent.toml | dasel put -r toml -t string -v '{0}' 'contractArtifactsURL' > /network-data/.intent.toml".format( - optimism_args.op_contract_deployer_params.artifacts_url - ), - "mv /network-data/.intent.toml /network-data/intent.toml", + "cat /network-data/intent.toml | dasel put -r toml -t {0} -v '{2}' '{1}' -o /network-data/intent.toml".format( + t, k, v + ) + for t, k, v in intent_updates ] ), ) diff --git a/src/el/op-besu/op_besu_launcher.star b/src/el/op-besu/op_besu_launcher.star index bcd201aa..c8c01b41 100644 --- a/src/el/op-besu/op_besu_launcher.star +++ b/src/el/op-besu/op_besu_launcher.star @@ -222,6 +222,7 @@ def get_config( ) ) + cmd += participant.el_extra_params cmd_str = " ".join(cmd) files = { diff --git a/src/el/op-erigon/op_erigon_launcher.star b/src/el/op-erigon/op_erigon_launcher.star index 98375643..d81aeed8 100644 --- a/src/el/op-erigon/op_erigon_launcher.star +++ b/src/el/op-erigon/op_erigon_launcher.star @@ -211,6 +211,7 @@ def get_config( ) ) + cmd += participant.el_extra_params cmd_str = " ".join(cmd) if launcher.network not in ethereum_package_constants.PUBLIC_NETWORKS: subcommand_strs = [ diff --git a/src/el/op-geth/op_geth_launcher.star b/src/el/op-geth/op_geth_launcher.star index 9341bc74..9384dac7 100644 --- a/src/el/op-geth/op_geth_launcher.star +++ b/src/el/op-geth/op_geth_launcher.star @@ -226,6 +226,7 @@ def get_config( ) ) + cmd += participant.el_extra_params cmd_str = " ".join(cmd) if launcher.network not in ethereum_package_constants.PUBLIC_NETWORKS: subcommand_strs = [ diff --git a/src/el/op-nethermind/op_nethermind_launcher.star b/src/el/op-nethermind/op_nethermind_launcher.star index a063ca6a..ee1d6aff 100644 --- a/src/el/op-nethermind/op_nethermind_launcher.star +++ b/src/el/op-nethermind/op_nethermind_launcher.star @@ -225,6 +225,8 @@ def get_config( constants.EL_TYPE.op_nethermind + "_volume_size" ], ) + + cmd += participant.el_extra_params env_vars = participant.el_extra_env_vars config_args = { "image": participant.el_image, diff --git a/src/el/op-reth/op_reth_launcher.star b/src/el/op-reth/op_reth_launcher.star index 548c9dc6..e531ee83 100644 --- a/src/el/op-reth/op_reth_launcher.star +++ b/src/el/op-reth/op_reth_launcher.star @@ -223,6 +223,7 @@ def get_config( ], ) + cmd += participant.el_extra_params env_vars = participant.el_extra_env_vars config_args = { "image": participant.el_image, diff --git a/src/l2.star b/src/l2.star index f12c6b10..f3ff471e 100644 --- a/src/l2.star +++ b/src/l2.star @@ -22,10 +22,7 @@ def launch_l2( persistent, ): network_params = l2_args.network_params - - l2_config_env_vars = {} - 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) + batcher_params = l2_args.batcher_params plan.print("Deploying L2 with name {0}".format(network_params.name)) jwt_file = plan.upload_files( @@ -38,6 +35,7 @@ def launch_l2( l2_args.participants, jwt_file, network_params, + batcher_params, deployment_output, l1_config, l2_services_suffix, diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 24d681de..7f192519 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -25,11 +25,6 @@ DEFAULT_PROPOSER_IMAGES = { "op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop", } -ATTR_TO_BE_SKIPPED_AT_ROOT = ( - "network_params", - "participants", -) - DEFAULT_ADDITIONAL_SERVICES = [] @@ -86,6 +81,11 @@ def input_parser(plan, input_args): "holocene_time_offset" ], interop_time_offset=result["network_params"]["interop_time_offset"], + fund_dev_accounts=result["network_params"]["fund_dev_accounts"], + ), + batcher_params=struct( + image=result["batcher_params"]["image"], + extra_params=result["batcher_params"]["extra_params"], ), additional_services=result["additional_services"], ) @@ -112,6 +112,9 @@ def parse_network_params(plan, input_args): network_params = default_network_params() network_params.update(chain.get("network_params", {})) + batcher_params = default_batcher_params() + batcher_params.update(chain.get("batcher_params", {})) + network_name = network_params["name"] network_id = network_params["network_id"] @@ -155,6 +158,7 @@ def parse_network_params(plan, input_args): result = { "participants": participants, "network_params": network_params, + "batcher_params": batcher_params, "additional_services": chain.get( "additional_services", DEFAULT_ADDITIONAL_SERVICES ), @@ -187,6 +191,7 @@ def default_chains(): { "participants": [default_participant()], "network_params": default_network_params(), + "batcher_params": default_batcher_params(), "additional_services": DEFAULT_ADDITIONAL_SERVICES, } ] @@ -202,6 +207,14 @@ def default_network_params(): "granite_time_offset": None, "holocene_time_offset": None, "interop_time_offset": None, + "fund_dev_accounts": True, + } + + +def default_batcher_params(): + return { + "image": "", + "extra_params": [], } diff --git a/src/package_io/sanity_check.star b/src/package_io/sanity_check.star index c0e67845..33fedb1d 100644 --- a/src/package_io/sanity_check.star +++ b/src/package_io/sanity_check.star @@ -40,7 +40,9 @@ SUBCATEGORY_PARAMS = { "granite_time_offset", "holocene_time_offset", "interop_time_offset", + "fund_dev_accounts", ], + "batcher_params": ["image", "extra_params"], } OP_CONTRACT_DEPLOYER_PARAMS = [ diff --git a/src/participant_network.star b/src/participant_network.star index 96735627..ab8f2443 100644 --- a/src/participant_network.star +++ b/src/participant_network.star @@ -11,6 +11,7 @@ def launch_participant_network( participants, jwt_file, network_params, + batcher_params, deployment_output, l1_config_env_vars, l2_services_suffix, @@ -66,14 +67,21 @@ def launch_participant_network( ".privateKey", ) + op_batcher_image = ( + batcher_params.image + if batcher_params.image != "" + else input_parser.DEFAULT_BATCHER_IMAGES["op-batcher"] + ) + op_batcher_launcher.launch( plan, "op-batcher-{0}".format(l2_services_suffix), - input_parser.DEFAULT_BATCHER_IMAGES["op-batcher"], + op_batcher_image, all_el_contexts[0], all_cl_contexts[0], l1_config_env_vars, batcher_key, + batcher_params, ) # The OP Stack don't run the proposer anymore, it has been replaced with the challenger