Skip to content

Commit

Permalink
chore: get contract setup addresses only once (#393)
Browse files Browse the repository at this point in the history
* chore: get contract setup addresses only once

* fix: deploy additional services

* fix: panoptichain deployment

* fix: attempt to fix the issue with contract setup addresses
  • Loading branch information
leovct authored Nov 25, 2024
1 parent 529a3e7 commit 56c58fb
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 40 deletions.
10 changes: 5 additions & 5 deletions agglayer.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
databases_package = import_module("./databases.star")
service_package = import_module("./lib/service.star")
ports_package = import_module("./src/package_io/ports.star")


def run(plan, args):
def run(plan, args, contract_setup_addresses):
# Create agglayer prover service.
agglayer_prover_config_artifact = create_agglayer_prover_config_artifact(plan, args)
(ports, public_ports) = get_agglayer_prover_ports(args)
Expand Down Expand Up @@ -41,7 +40,7 @@ def run(plan, args):

# Deploy agglayer service.
agglayer_config_artifact = create_agglayer_config_artifact(
plan, args, agglayer_prover_url
plan, args, agglayer_prover_url, contract_setup_addresses
)
agglayer_keystore_artifact = plan.store_service_files(
name="agglayer-keystore",
Expand Down Expand Up @@ -104,11 +103,12 @@ def create_agglayer_prover_config_artifact(plan, args):
)


def create_agglayer_config_artifact(plan, args, agglayer_prover_url):
def create_agglayer_config_artifact(
plan, args, agglayer_prover_url, contract_setup_addresses
):
agglayer_config_template = read_file(
src="./templates/bridge-infra/agglayer-config.toml"
)
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
db_configs = databases_package.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
Expand Down
4 changes: 1 addition & 3 deletions cdk_bridge_infra.star
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
service_package = import_module("./lib/service.star")
zkevm_bridge_package = import_module("./lib/zkevm_bridge.star")
databases = import_module("./databases.star")


def run(plan, args):
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
def run(plan, args, contract_setup_addresses):
db_configs = databases.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
Expand Down
13 changes: 5 additions & 8 deletions cdk_central_environment.star
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
data_availability_package = import_module("./lib/data_availability.star")
service_package = import_module("./lib/service.star")
zkevm_dac_package = import_module("./lib/zkevm_dac.star")
zkevm_node_package = import_module("./lib/zkevm_node.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")
Expand All @@ -8,7 +7,7 @@ cdk_node_package = import_module("./lib/cdk_node.star")
databases = import_module("./databases.star")


def run(plan, args):
def run(plan, args, contract_setup_addresses):
db_configs = databases.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
Expand Down Expand Up @@ -89,7 +88,9 @@ def run(plan, args):

# Start the DAC if in validium mode.
if data_availability_package.is_cdk_validium(args):
dac_config_artifact = create_dac_config_artifact(plan, args, db_configs)
dac_config_artifact = create_dac_config_artifact(
plan, args, db_configs, contract_setup_addresses
)
dac_config = zkevm_dac_package.create_dac_service_config(
args, dac_config_artifact, keystore_artifacts.dac
)
Expand All @@ -103,9 +104,6 @@ def run(plan, args):
node_config_template = read_file(
src="./templates/trusted-node/cdk-node-config.toml"
)
contract_setup_addresses = service_package.get_contract_setup_addresses(
plan, args
)
node_config_artifact = plan.render_templates(
name="cdk-node-config-artifact",
config={
Expand Down Expand Up @@ -169,9 +167,8 @@ def get_keystores_artifacts(plan, args):
)


def create_dac_config_artifact(plan, args, db_configs):
def create_dac_config_artifact(plan, args, db_configs, contract_setup_addresses):
dac_config_template = read_file(src="./templates/trusted-node/dac-config.toml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
return plan.render_templates(
name="dac-config-artifact",
config={
Expand Down
7 changes: 2 additions & 5 deletions cdk_erigon.star
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
service_package = import_module("./lib/service.star")
cdk_erigon_package = import_module("./lib/cdk_erigon.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")


def run_sequencer(plan, args):
def run_sequencer(plan, args, contract_setup_addresses):
cdk_erigon_config_template = read_file(src="./templates/cdk-erigon/config.yml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
cdk_erigon_sequencer_config_artifact = plan.render_templates(
name="cdk-erigon-sequencer-config-artifact",
config={
Expand Down Expand Up @@ -63,7 +61,7 @@ def run_sequencer(plan, args):
)


def run_rpc(plan, args):
def run_rpc(plan, args, contract_setup_addresses):
# Start the zkevm stateless executor if strict mode is enabled.
if args["erigon_strict_mode"]:
stateless_configs = {}
Expand Down Expand Up @@ -106,7 +104,6 @@ def run_rpc(plan, args):
pool_manager_service.ports["http"].number,
)
cdk_erigon_config_template = read_file(src="./templates/cdk-erigon/config.yml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
cdk_erigon_rpc_config_artifact = plan.render_templates(
name="cdk-erigon-rpc-config-artifact",
config={
Expand Down
43 changes: 34 additions & 9 deletions main.star
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
constants = import_module("./src/package_io/constants.star")
input_parser = import_module("./input_parser.star")
service_package = import_module("./lib/service.star")

# Main service packages.
agglayer_package = "./agglayer.star"
Expand Down Expand Up @@ -41,9 +42,13 @@ def run(plan, args={}):
plan.print("Skipping the deployment of a local L1")

# Deploy zkevm contracts on L1.
contract_setup_addresses = {}
if deployment_stages.get("deploy_zkevm_contracts_on_l1", False):
plan.print("Deploying zkevm contracts on L1")
import_module(deploy_zkevm_contracts_package).run(plan, args)
contract_setup_addresses = service_package.get_contract_setup_addresses(
plan, args
)
else:
plan.print("Skipping the deployment of zkevm contracts on L1")

Expand All @@ -56,6 +61,9 @@ def run(plan, args={}):
):
plan.print("Deploying helper service to retrieve rollup data")
deploy_helper_service(plan, args)
contract_setup_addresses = service_package.get_contract_setup_addresses(
plan, args
)
else:
plan.print("Skipping the deployment of helper service to retrieve rollup data")

Expand All @@ -79,7 +87,7 @@ def run(plan, args={}):
# Deploy the agglayer.
if deployment_stages.get("deploy_agglayer", False):
plan.print("Deploying the agglayer")
import_module(agglayer_package).run(plan, args)
import_module(agglayer_package).run(plan, args, contract_setup_addresses)
else:
plan.print("Skipping the deployment of the agglayer")

Expand All @@ -88,7 +96,9 @@ def run(plan, args={}):
# Deploy cdk-erigon sequencer node.
if args["sequencer_type"] == "erigon":
plan.print("Deploying cdk-erigon sequencer")
import_module(cdk_erigon_package).run_sequencer(plan, args)
import_module(cdk_erigon_package).run_sequencer(
plan, args, contract_setup_addresses
)
else:
plan.print("Skipping the deployment of cdk-erigon sequencer")

Expand All @@ -102,15 +112,17 @@ def run(plan, args={}):
# Deploy cdk-erigon node.
if deployment_stages.get("deploy_cdk_erigon_node", False):
plan.print("Deploying cdk-erigon node")
import_module(cdk_erigon_package).run_rpc(plan, args)
import_module(cdk_erigon_package).run_rpc(
plan, args, contract_setup_addresses
)
else:
plan.print("Skipping the deployment of cdk-erigon node")

plan.print("Deploying cdk central/trusted environment")
central_environment_args = dict(args)
central_environment_args["genesis_artifact"] = genesis_artifact
import_module(cdk_central_environment_package).run(
plan, central_environment_args
plan, central_environment_args, contract_setup_addresses
)
else:
plan.print("Skipping the deployment of cdk central/trusted environment")
Expand All @@ -119,7 +131,9 @@ def run(plan, args={}):
if deployment_stages.get("deploy_cdk_bridge_infra", False):
plan.print("Deploying cdk/bridge infrastructure")
import_module(cdk_bridge_infra_package).run(
plan, args | {"use_local_l1": deployment_stages.get("deploy_l1", False)}
plan,
args | {"use_local_l1": deployment_stages.get("deploy_l1", False)},
contract_setup_addresses,
)
else:
plan.print("Skipping the deployment of cdk/bridge infrastructure")
Expand Down Expand Up @@ -160,11 +174,19 @@ def run(plan, args={}):
elif additional_service == "erpc":
deploy_additional_service(plan, "erpc", erpc_package, args)
elif additional_service == "prometheus_grafana":
deploy_additional_service(plan, "panoptichain", panoptichain_package, args)
deploy_additional_service(
plan,
"panoptichain",
panoptichain_package,
args,
contract_setup_addresses,
)
deploy_additional_service(plan, "prometheus", prometheus_package, args)
deploy_additional_service(plan, "grafana", grafana_package, args)
elif additional_service == "tx_spammer":
deploy_additional_service(plan, "tx_spammer", tx_spammer_package, args)
deploy_additional_service(
plan, "tx_spammer", tx_spammer_package, args, contract_setup_addresses
)
elif additional_service == "assertoor":
deploy_additional_service(plan, "assertoor", assertoor_package, args)
else:
Expand Down Expand Up @@ -216,8 +238,11 @@ def deploy_helper_service(plan, args):
)


def deploy_additional_service(plan, name, package, args):
def deploy_additional_service(plan, name, package, args, contract_setup_addresses={}):
plan.print("Launching %s" % name)
service_args = dict(args)
import_module(package).run(plan, service_args)
if contract_setup_addresses == {}:
import_module(package).run(plan, service_args)
else:
import_module(package).run(plan, service_args, contract_setup_addresses)
plan.print("Successfully launched %s" % name)
9 changes: 5 additions & 4 deletions src/additional_services/panoptichain.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ service_package = import_module("../../lib/service.star")
PANOPTICHAIN_IMAGE = "minhdvu/panoptichain:0.1.62"


def run(plan, args):
panoptichain_config_artifact = get_panoptichain_config(plan, args)
def run(plan, args, contract_setup_addresses):
panoptichain_config_artifact = get_panoptichain_config(
plan, args, contract_setup_addresses
)
(ports, public_ports) = get_panoptichain_ports(args)
plan.add_service(
name="panoptichain" + args["deployment_suffix"],
Expand All @@ -18,11 +20,10 @@ def run(plan, args):
)


def get_panoptichain_config(plan, args):
def get_panoptichain_config(plan, args, contract_setup_addresses):
panoptichain_config_template = read_file(
src="../../static_files/additional_services/panoptichain-config/config.yml"
)
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
l2_rpc_url = service_package.get_l2_rpc_url(plan, args)

# Ensure that the `l2_accounts_to_fund` parameter is > 0 or else the l2 time
Expand Down
11 changes: 5 additions & 6 deletions src/additional_services/tx_spammer.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
constants = import_module("../../src/package_io/constants.star")
service_package = import_module("../../lib/service.star")


def run(plan, args):
tx_spammer_config_artifacts = get_tx_spammer_config(plan, args)
def run(plan, args, contract_setup_addresses):
tx_spammer_config_artifacts = get_tx_spammer_config(
plan, args, contract_setup_addresses
)
plan.add_service(
name="tx-spammer" + args["deployment_suffix"],
config=ServiceConfig(
Expand All @@ -17,16 +18,14 @@ def run(plan, args):
)


def get_tx_spammer_config(plan, args):
def get_tx_spammer_config(plan, args, contract_setup_addresses):
spam_script_template = read_file(
src="../../static_files/additional_services/tx-spammer-config/spam.sh"
)
bridge_script_template = read_file(
src="../../static_files/additional_services/tx-spammer-config/bridge.sh"
)

contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)

l2_rpc_service = plan.get_service(args["l2_rpc_name"] + args["deployment_suffix"])
l2_rpc_url = "http://{}:{}".format(
l2_rpc_service.ip_address, l2_rpc_service.ports["rpc"].number
Expand Down

0 comments on commit 56c58fb

Please sign in to comment.