diff --git a/.github/tests/blockscout.yaml b/.github/tests/blockscout.yaml index 7fd40dbb..8ae841eb 100644 --- a/.github/tests/blockscout.yaml +++ b/.github/tests/blockscout.yaml @@ -13,11 +13,3 @@ optimism_package: network_id: '3151910' additional_services: - blockscout -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - blockscout diff --git a/.github/tests/multiple_l2s.yaml b/.github/tests/multiple_l2s.yaml index f0d36065..7216479e 100644 --- a/.github/tests/multiple_l2s.yaml +++ b/.github/tests/multiple_l2s.yaml @@ -1,21 +1,7 @@ optimism_package: - - participants: - - el_type: op-geth - network_params: + - network_params: name: op-rollup-one network_id: '3151909' - additional_services: [] - - participants: - - el_type: op-geth - network_params: + - network_params: name: op-rollup-two network_id: '3151910' - additional_services: [] -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/op-erigon.yaml b/.github/tests/op-erigon.yaml index 61b150bb..df9f573b 100644 --- a/.github/tests/op-erigon.yaml +++ b/.github/tests/op-erigon.yaml @@ -2,11 +2,3 @@ optimism_package: participants: - el_type: op-erigon cl_type: op-node -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/op-geth.yaml b/.github/tests/op-geth.yaml index 1a3085b9..cb00eaf5 100644 --- a/.github/tests/op-geth.yaml +++ b/.github/tests/op-geth.yaml @@ -2,11 +2,3 @@ optimism_package: participants: - el_type: op-geth cl_type: op-node -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/op-nethermind.yaml b/.github/tests/op-nethermind.yaml index 8a9ae48b..afe9909a 100644 --- a/.github/tests/op-nethermind.yaml +++ b/.github/tests/op-nethermind.yaml @@ -3,11 +3,3 @@ optimism_package: - el_type: op-geth - el_type: op-nethermind cl_type: op-node -ethereum_package: - participants: - - el_type: geth - - el_type: nethermind - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/op-node.yaml b/.github/tests/op-node.yaml index 871cfbf8..8ce3425a 100644 --- a/.github/tests/op-node.yaml +++ b/.github/tests/op-node.yaml @@ -8,11 +8,3 @@ optimism_package: cl_type: op-node - el_type: op-nethermind cl_type: op-node -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/op-reth.yaml b/.github/tests/op-reth.yaml index 0d65a6ad..27f52fdd 100644 --- a/.github/tests/op-reth.yaml +++ b/.github/tests/op-reth.yaml @@ -2,11 +2,3 @@ optimism_package: participants: - el_type: op-reth cl_type: op-node -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/.github/tests/single_l2.yaml b/.github/tests/single_l2.yaml index dde7e3f1..fd243dad 100644 --- a/.github/tests/single_l2.yaml +++ b/.github/tests/single_l2.yaml @@ -1,11 +1,3 @@ optimism_package: participants: - count: 2 -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora diff --git a/main.star b/main.star index b32910e4..1849201a 100644 --- a/main.star +++ b/main.star @@ -16,8 +16,11 @@ def run(plan, args): A full deployment of Optimism L2(s) """ plan.print("Parsing the L1 input args") - ethereum_args = args["ethereum_package"] - + # If no args are provided, use the default values with minimal preset + ethereum_args = args.get( + "ethereum_package", {"network_params": {"preset": "minimal"}} + ) + optimism_args = args.get("optimism_package", {}) # Deploy the L1 plan.print("Deploying a local L1") l1 = ethereum_package.run(plan, ethereum_args) @@ -41,20 +44,20 @@ def run(plan, args): # Deploy L2s plan.print("Deploying a local L2") - if type(args["optimism_package"]) == "dict": + if type(optimism_args) == "dict": l2_services_suffix = "" # no suffix if one l2 l2_launcher.launch_l2( plan, l2_services_suffix, - args["optimism_package"], + optimism_args, l1_config_env_vars, l1_priv_key, all_l1_participants[0].el_context, ) - elif type(args["optimism_package"]) == "list": + elif type(optimism_args) == "list": seen_names = {} seen_network_ids = {} - for l2_num, l2_args in enumerate(args["optimism_package"]): + for l2_num, l2_args in enumerate(optimism_args): name = l2_args["network_params"]["name"] network_id = l2_args["network_params"]["network_id"] if name in seen_names: diff --git a/network_params.yaml b/network_params.yaml index 493845fc..8f88ec82 100644 --- a/network_params.yaml +++ b/network_params.yaml @@ -5,13 +5,4 @@ optimism_package: - el_type: op-erigon - el_type: op-nethermind additional_services: - - blockscout -ethereum_package: - participants: - - el_type: geth - - el_type: reth - network_params: - preset: minimal - additional_services: - - dora - blockscout diff --git a/src/contracts/contract_deployer.star b/src/contracts/contract_deployer.star index b95c0438..bd2b4d9a 100644 --- a/src/contracts/contract_deployer.star +++ b/src/contracts/contract_deployer.star @@ -53,7 +53,7 @@ def deploy_l2_contracts( ): chainspec_files_artifact = plan.upload_files( src=CHAINSPEC_JQ_FILEPATH, - name="chainspec-config", + name="op-chainspec-config{0}".format(l2_services_suffix), ) op_genesis = plan.run_sh( diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 7d53d1ca..de03ddfe 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -2,6 +2,8 @@ ethereum_package_input_parser = import_module( "github.com/ethpandaops/ethereum-package/src/package_io/input_parser.star" ) +sanity_check = import_module("./sanity_check.star") + DEFAULT_EL_IMAGES = { "op-geth": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest", "op-reth": "parithoshj/op-reth:latest", @@ -31,6 +33,7 @@ DEFAULT_ADDITIONAL_SERVICES = [] def input_parser(plan, input_args): + sanity_check.sanity_check(plan, input_args) result = parse_network_params(plan, input_args) return struct( diff --git a/src/package_io/sanity_check.star b/src/package_io/sanity_check.star new file mode 100644 index 00000000..181b836c --- /dev/null +++ b/src/package_io/sanity_check.star @@ -0,0 +1,82 @@ +PARTICIPANT_CATEGORIES = { + "participants": [ + "el_type", + "el_image", + "cl_type", + "cl_image", + "count", + ], +} + +SUBCATEGORY_PARAMS = { + "network_params": [ + "network", + "network_id", + "seconds_per_slot", + "name", + ], +} + +ADDITIONAL_SERVICES_PARAMS = [ + "blockscout", +] + + +def deep_validate_params(plan, input_args, category, allowed_params): + if category in input_args: + for item in input_args[category]: + for param in item.keys(): + if param not in allowed_params: + fail( + "Invalid parameter {0} for {1}. Allowed fields: {2}".format( + param, category, allowed_params + ) + ) + + +def validate_params(plan, input_args, category, allowed_params): + if category in input_args: + for param in input_args[category].keys(): + if param not in allowed_params: + fail( + "Invalid parameter {0} for {1}. Allowed fields: {2}".format( + param, category, allowed_params + ) + ) + + +def sanity_check(plan, input_args): + # Checks participants + deep_validate_params( + plan, input_args, "participants", PARTICIPANT_CATEGORIES["participants"] + ) + + # Checks additional_services + if "additional_services" in input_args: + for additional_services in input_args["additional_services"]: + if additional_services not in ADDITIONAL_SERVICES_PARAMS: + fail( + "Invalid additional_services {0}, allowed fields: {1}".format( + additional_services, ADDITIONAL_SERVICES_PARAMS + ) + ) + + # Checks subcategories + for subcategories in SUBCATEGORY_PARAMS.keys(): + validate_params( + plan, input_args, subcategories, SUBCATEGORY_PARAMS[subcategories] + ) + # Checks everything else + for param in input_args.keys(): + combined_root_params = PARTICIPANT_CATEGORIES.keys() + SUBCATEGORY_PARAMS.keys() + combined_root_params.append("additional_services") + + if param not in combined_root_params: + fail( + "Invalid parameter {0}, allowed fields {1}".format( + param, combined_root_params + ) + ) + + # If everything passes, print a message + plan.print("Sanity check for OP package passed")