Skip to content

Commit

Permalink
Add support for op-deployer, fix multiple L2s
Browse files Browse the repository at this point in the history
  • Loading branch information
mslipper committed Sep 20, 2024
1 parent 74b6417 commit 56c9895
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 406 deletions.
42 changes: 23 additions & 19 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def run(plan, args):
plan.print("Parsing the L1 input args")
# If no args are provided, use the default values with minimal preset
ethereum_args = args.get(
"ethereum_package", {"network_params": {"preset": "minimal"}}
"ethereum_package", input_parser.default_ethereum_config()
)
optimism_args = args.get("optimism_package", {})
optimism_args_with_right_defaults = input_parser.input_parser(plan, optimism_args)
Expand All @@ -38,17 +38,32 @@ def run(plan, args):
all_l1_participants, l1_network_params, l1_network_id
)

if l1_network_params.network != "kurtosis":
if l1_network_params.network == "kurtosis":
plan.print("Waiting for L1 to start up")
wait_for_sync.wait_for_startup(plan, l1_config_env_vars)
else:
plan.print("Waiting for network to sync")
wait_for_sync.wait_for_sync(plan, l1_config_env_vars)

l2_contract_deployer_image = (
optimism_args_with_right_defaults.op_contract_deployer_params.image
deployment_output = contract_deployer.deploy_contracts(
plan,
l1_priv_key,
l1_config_env_vars,
optimism_args_with_right_defaults,
)

# Deploy Create2 Factory contract (only need to do this once for multiple l2s)
contract_deployer.deploy_factory_contract(
plan, l1_priv_key, l1_config_env_vars, l2_contract_deployer_image
)
for chain in optimism_args_with_right_defaults.chains:
l2_launcher.launch_l2(
plan,
chain.network_params.name,
chain,
deployment_output,
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
)

return
# Deploy L2s
plan.print("Deploying a local L2")
if type(optimism_args) == "dict":
Expand Down Expand Up @@ -104,15 +119,4 @@ def get_l1_config(all_l1_participants, l1_network_params, l1_network_id):
env_vars["L1_WS_URL"] = str(all_l1_participants[0].el_context.ws_url)
env_vars["L1_CHAIN_ID"] = str(l1_network_id)
env_vars["L1_BLOCK_TIME"] = str(l1_network_params.seconds_per_slot)
env_vars["DEPLOYMENT_OUTFILE"] = (
"/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_network_id)
+ "/kurtosis.json"
)
env_vars["STATE_DUMP_PATH"] = (
"/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_network_id)
+ "/state-dump.json"
)

return env_vars
26 changes: 17 additions & 9 deletions network_params.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
optimism_package:
participants:
- el_type: op-geth
- el_type: op-reth
- el_type: op-erigon
- el_type: op-nethermind
- el_type: op-besu
additional_services:
- blockscout
chains:
- participants:
- el_type: op-geth
sequencer: true
additional_services:
- blockscout
network_params:
network_id: 777
name: rollup-1
- participants:
- el_type: op-geth
sequencer: true
network_params:
network_id: 999
name: rollup-2
op_contract_deployer_params:
image: ethpandaops/optimism-contract-deployer:develop
image: ethereumoptimism/op-deployer:latest
artifacts_url: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-4accd01f0c35c26f24d2aa71aba898dd7e5085a2ce5daadc8a84b10caf113409.tar.gz
36 changes: 18 additions & 18 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ constants = import_module(
"github.com/ethpandaops/ethereum-package/src/package_io/constants.star"
)

util = import_module("../../util.star")

# ---------------------------------- Beacon client -------------------------------------

# The Docker container runs as the "op-node" user so we can't write to root
BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-node/op-node-beacon-data"
ROLLUP_CONFIG_MOUNT_PATH_ON_CONTAINER = "/network-configs/rollup.json"
# Port IDs
BEACON_TCP_DISCOVERY_PORT_ID = "tcp-discovery"
BEACON_UDP_DISCOVERY_PORT_ID = "udp-discovery"
Expand Down Expand Up @@ -64,10 +65,8 @@ def launch(
el_context,
existing_cl_clients,
l1_config_env_vars,
gs_sequencer_private_key,
sequencer_enabled,
):
network_name = shared_utils.get_network_name(launcher.network)

beacon_node_identity_recipe = PostHttpRequestRecipe(
endpoint="/",
Expand All @@ -83,14 +82,11 @@ def launch(

config = get_beacon_config(
plan,
launcher.el_cl_genesis_data,
launcher.jwt_file,
launcher,
image,
service_name,
el_context,
existing_cl_clients,
l1_config_env_vars,
gs_sequencer_private_key,
beacon_node_identity_recipe,
sequencer_enabled,
)
Expand Down Expand Up @@ -125,14 +121,11 @@ def launch(

def get_beacon_config(
plan,
el_cl_genesis_data,
jwt_file,
launcher,
image,
service_name,
el_context,
existing_cl_clients,
l1_config_env_vars,
gs_sequencer_private_key,
beacon_node_identity_recipe,
sequencer_enabled,
):
Expand All @@ -148,7 +141,7 @@ def get_beacon_config(
"--l2={0}".format(EXECUTION_ENGINE_ENDPOINT),
"--l2.jwt-secret=" + constants.JWT_MOUNT_PATH_ON_CONTAINER,
"--verifier.l1-confs=4",
"--rollup.config=" + ROLLUP_CONFIG_MOUNT_PATH_ON_CONTAINER,
"--rollup.config=" + constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS + "/rollup-{0}.json".format(launcher.network_params.network_id),
"--rpc.addr=0.0.0.0",
"--rpc.port={0}".format(BEACON_HTTP_PORT_NUM),
"--rpc.enable-admin",
Expand All @@ -164,8 +157,15 @@ def get_beacon_config(
"--p2p.listen.udp={0}".format(BEACON_DISCOVERY_PORT_NUM),
]

sequencer_private_key = util.read_network_config_value(
plan,
launcher.deployment_output,
"sequencer-{0}".format(launcher.network_params.network_id),
".privateKey",
)

if sequencer_enabled:
cmd.append("--p2p.sequencer.key=" + gs_sequencer_private_key)
cmd.append("--p2p.sequencer.key=" + sequencer_private_key)
cmd.append("--sequencer.enabled")
cmd.append("--sequencer.l1-confs=5")

Expand All @@ -178,8 +178,8 @@ def get_beacon_config(
)

files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data,
constants.JWT_MOUNTPOINT_ON_CLIENTS: jwt_file,
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.deployment_output,
constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file,
}
ports = {}
ports.update(used_ports)
Expand All @@ -200,9 +200,9 @@ def get_beacon_config(
)


def new_op_node_launcher(el_cl_genesis_data, jwt_file, network_params):
def new_op_node_launcher(deployment_output, jwt_file, network_params):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
deployment_output=deployment_output,
jwt_file=jwt_file,
network=network_params.network,
network_params=network_params,
)
Loading

0 comments on commit 56c9895

Please sign in to comment.