Skip to content

Commit

Permalink
fix: handling of config options (#85)
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
klkvr authored Oct 23, 2024
1 parent 05d0fe9 commit 5b085c8
Show file tree
Hide file tree
Showing 15 changed files with 91 additions and 14 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down
4 changes: 4 additions & 0 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/batcher/op-batcher/op_batcher_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -71,6 +73,7 @@ def get_batcher_config(
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
batcher_params,
):
cmd = [
"op-batcher",
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/cl/hildr/hildr_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 30 additions & 4 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
]
),
)
Expand Down
1 change: 1 addition & 0 deletions src/el/op-besu/op_besu_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ def get_config(
)
)

cmd += participant.el_extra_params
cmd_str = " ".join(cmd)

files = {
Expand Down
1 change: 1 addition & 0 deletions src/el/op-erigon/op_erigon_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions src/el/op-geth/op_geth_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions src/el/op-nethermind/op_nethermind_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/el/op-reth/op_reth_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -38,6 +35,7 @@ def launch_l2(
l2_args.participants,
jwt_file,
network_params,
batcher_params,
deployment_output,
l1_config,
l2_services_suffix,
Expand Down
23 changes: 18 additions & 5 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []


Expand Down Expand Up @@ -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"],
)
Expand All @@ -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"]

Expand Down Expand Up @@ -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
),
Expand Down Expand Up @@ -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,
}
]
Expand All @@ -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": [],
}


Expand Down
2 changes: 2 additions & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
10 changes: 9 additions & 1 deletion src/participant_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def launch_participant_network(
participants,
jwt_file,
network_params,
batcher_params,
deployment_output,
l1_config_env_vars,
l2_services_suffix,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b085c8

Please sign in to comment.