Skip to content

Commit

Permalink
feat: add op_geth
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed Jun 4, 2024
1 parent 3232610 commit aa415e8
Show file tree
Hide file tree
Showing 10 changed files with 422 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ RUN foundryup

RUN git clone https://github.com/ethereum-optimism/optimism.git && \
cd optimism && \
git checkout tutorials/chain && \
git checkout develop && \
pnpm install && \
pnpm build

Expand Down
24 changes: 20 additions & 4 deletions main.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
input_parser = import_module("./src/package_io/input_parser.star")
ethereum_package = import_module("github.com/kurtosis-tech/ethereum-package/main.star")
contract_deployer = import_module("./src/contracts/contract_deployer.star")

static_files = import_module("github.com/kurtosis-tech/ethereum-package/src/static_files/static_files.star")
participant_network = import_module("./src/participant_network.star")

def run(plan, args={}):
"""Deploy a Optimism L2 with a local L1.
Expand All @@ -28,8 +29,8 @@ def run(plan, args={}):
plan.print("Deploying the L2 smart contracts")
first_l1_el_node = all_l1_participants[0].el_context.rpc_http_url
first_l1_cl_node = all_l1_participants[0].cl_context.beacon_http_url
contract_deployer.launch_contract_deployer(
plan, first_l1_el_node, first_l1_cl_node, priv_key
el_cl_data = contract_deployer.launch_contract_deployer(
plan, first_l1_el_node, first_l1_cl_node, priv_key
)

# Parse the values for the args
Expand All @@ -39,4 +40,19 @@ def run(plan, args={}):
# Deploy the L2
plan.print("Deploying a local L2")
args_with_right_defaults = input_parser.input_parser(plan, optimism_args)
plan.print(args_with_right_defaults)

jwt_file = plan.upload_files(
src=static_files.JWT_PATH_FILEPATH,
name="op_jwt_file",
)
network_params = args_with_right_defaults.network_params

all_participants = participant_network.launch_participant_network(
plan,
args_with_right_defaults.participants,
jwt_file,
network_params,
el_cl_data,
)

plan.print(all_participants)
4 changes: 2 additions & 2 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ optimism_package:
ethereum_package:
participants:
- el_type: geth
- el_type: reth
#- el_type: reth
network_params:
preset: minimal
additional_services:
- dora
- blockscout
#- blockscout
3 changes: 2 additions & 1 deletion src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def launch_contract_deployer(
cl_rpc_http_url,
priv_key,
):
plan.run_sh(
op_genesis = plan.run_sh(
description="Deploying L2 contracts (takes a few minutes (30 mins for mainnet preset - 4 mins for minimal preset) -- L1 has to be finalized first)",
image=IMAGE,
env_vars={
Expand Down Expand Up @@ -73,3 +73,4 @@ def launch_contract_deployer(
),
wait="2000s",
)
return op_genesis.files_artifacts[0]
68 changes: 68 additions & 0 deletions src/el/el_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
constants = import_module("github.com/kurtosis-tech/ethereum-package/src/package_io/constants.star")
shared_utils = import_module("github.com/kurtosis-tech/ethereum-package/src/shared_utils/shared_utils.star")

op_geth = import_module("./op-geth/op_geth_launcher.star")





def launch(
plan,
jwt_file,
network_params,
el_cl_data,
participants,
num_participants,
):
el_launchers = {
"op-geth": {
"launcher": op_geth.new_op_geth_launcher(
el_cl_data,
jwt_file,
network_params.network,
network_params.network_id,
),
"launch_method": op_geth.launch,
},
}

all_el_contexts = []

for index, participant in enumerate(participants):
cl_type = participant.cl_type
el_type = participant.el_type

if el_type not in el_launchers:
fail(
"Unsupported launcher '{0}', need one of '{1}'".format(
el_type, ",".join(el_launchers.keys())
)
)

el_launcher, launch_method = (
el_launchers[el_type]["launcher"],
el_launchers[el_type]["launch_method"],
)

# Zero-pad the index using the calculated zfill value
index_str = shared_utils.zfill_custom(index + 1, len(str(len(participants))))

el_service_name = "op-el-{0}-{1}-{2}".format(index_str, el_type, cl_type)

el_context = launch_method(
plan,
el_launcher,
el_service_name,
participant.el_image,
all_el_contexts,
)
# # Add participant el additional prometheus metrics
# for metrics_info in el_context.el_metrics_info:
# if metrics_info != None:
# metrics_info["config"] = participant.prometheus_config

all_el_contexts.append(el_context)

plan.print("Successfully added {0} EL participants".format(num_participants))
return all_el_contexts
Loading

0 comments on commit aa415e8

Please sign in to comment.