From 491cfed7863233b0778590e05c9348341a6bf293 Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Wed, 5 Feb 2025 11:38:29 +0900 Subject: [PATCH 1/2] feat: add helper function for sanity checking parameters Signed-off-by: Ji Hwan --- main.star | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/main.star b/main.star index 11522c97..9a65ca5f 100644 --- a/main.star +++ b/main.star @@ -38,6 +38,10 @@ def run(plan, args={}): if verbosity == constants.LOG_LEVEL.debug or verbosity == constants.LOG_LEVEL.trace: plan.print("Deploying CDK stack with the following configuration: " + str(args)) + # Sanity check for conflicting parameters. + plan.print("Checking for incompatible parameters...") + sanity_check(plan, deployment_stages, args, op_stack_args) + # Deploy a local L1. if deployment_stages.get("deploy_l1", False): plan.print("Deploying a local L1") @@ -278,3 +282,14 @@ def deploy_additional_service(plan, name, package, args, contract_setup_addresse else: import_module(package).run(plan, service_args, contract_setup_addresses) plan.print("Successfully launched %s" % name) + + +# Helper function to check for parameter combinations that will result in errors within individual services even though the deployment may succeed. +def sanity_check(plan, deployment_stages, args, op_stack_args): + # deploy_optimistic_rollup and consensus_contract_type check + if deployment_stages.get("deploy_optimism_rollup", False): + if args.get("consensus_contract_type", "cdk-validium") != "pessimistic": + plan.print( + "OP Stack rollup requires pessimistic consensus contract type, halting further deployment..." + ) + return fail("Incompatible parameters") From 2926e59c3545f20962d229edc7f129850ef5996b Mon Sep 17 00:00:00 2001 From: Ji Hwan Date: Thu, 6 Feb 2025 00:37:30 +0900 Subject: [PATCH 2/2] refactor: move op-stack check to input_parser.star Signed-off-by: Ji Hwan --- input_parser.star | 8 ++++++++ main.star | 15 --------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/input_parser.star b/input_parser.star index e0f3c37b..751237a6 100644 --- a/input_parser.star +++ b/input_parser.star @@ -27,6 +27,8 @@ DEFAULT_DEPLOYMENT_STAGES = { # TODO: Remove this parameter to incorporate cdk-erigon inside the central environment. "deploy_cdk_erigon_node": True, # Deploy Optimism rollup. + # Setting to True will deploy the Aggkit components and Sovereign contracts as well. + # Requires consensus_contract_type to be "pessimistic". "deploy_optimism_rollup": False, # Deploy contracts on L2 (as well as fund accounts). "deploy_l2_contracts": False, @@ -459,6 +461,12 @@ def parse_args(plan, user_args): # Determine OP stack args. op_stack_args = get_op_stack_args(plan, args, op_stack_args) + # deploy_optimistic_rollup and consensus_contract_type check + if deployment_stages.get("deploy_optimism_rollup", False): + if args.get("consensus_contract_type", "cdk-validium") != "pessimistic": + fail( + "OP Stack rollup requires pessimistic consensus contract type. Change the consensus_contract_type parameter" + ) # When using assertoor to test L1 scenarios, l1_preset should be mainnet for deposits and withdrawls to work. if "assertoor" in args["l1_additional_services"]: diff --git a/main.star b/main.star index 9a65ca5f..11522c97 100644 --- a/main.star +++ b/main.star @@ -38,10 +38,6 @@ def run(plan, args={}): if verbosity == constants.LOG_LEVEL.debug or verbosity == constants.LOG_LEVEL.trace: plan.print("Deploying CDK stack with the following configuration: " + str(args)) - # Sanity check for conflicting parameters. - plan.print("Checking for incompatible parameters...") - sanity_check(plan, deployment_stages, args, op_stack_args) - # Deploy a local L1. if deployment_stages.get("deploy_l1", False): plan.print("Deploying a local L1") @@ -282,14 +278,3 @@ def deploy_additional_service(plan, name, package, args, contract_setup_addresse else: import_module(package).run(plan, service_args, contract_setup_addresses) plan.print("Successfully launched %s" % name) - - -# Helper function to check for parameter combinations that will result in errors within individual services even though the deployment may succeed. -def sanity_check(plan, deployment_stages, args, op_stack_args): - # deploy_optimistic_rollup and consensus_contract_type check - if deployment_stages.get("deploy_optimism_rollup", False): - if args.get("consensus_contract_type", "cdk-validium") != "pessimistic": - plan.print( - "OP Stack rollup requires pessimistic consensus contract type, halting further deployment..." - ) - return fail("Incompatible parameters")