Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to deploy the package to an external layer 1 #104

Merged
merged 22 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/tests/external-l1/ethereum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
network_params:
preset: minimal
genesis_delay: 5
additional_preloaded_contracts: '
{
"0x4e59b44847b379578588920cA78FbF26c0B4956C": {
"balance": "0ETH",
"code": "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3",
"storage": {},
"nonce": "1"
}
}
'
7 changes: 7 additions & 0 deletions .github/tests/external-l1/optimism.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
external_l1_network_params:
network_id: "3151908"
rpc_kind: standard
el_rpc_url: http://el-1-geth-lighthouse:8545
el_ws_url: ws://el-1-geth-lighthouse:8546
cl_rpc_url: http://cl-1-lighthouse-geth:4000
priv_key: "0xbcdf20249abf0ed6d944c0288fad489e33f66b3960d9e6229c1cd214ed3bbe31"
20 changes: 20 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,23 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
args: "The nightly test for ${{matrix.file_name}} on optimism-package has failed find it here ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"

run_with_external_l1_args:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Setup Kurtosis
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli
kurtosis analytics disable

- name: Deploy L1
run: kurtosis run --enclave test --args-file ./.github/tests/external-l1/ethereum.yaml github.com/ethpandaops/ethereum-package

- name: Run Starlark
run: |
kurtosis run --enclave test --verbosity detailed --args-file ./.github/tests/external-l1/optimism.yaml ${{ github.workspace }}
2 changes: 1 addition & 1 deletion kurtosis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "github.com/ethpandaops/optimism-package"
name: github.com/ethpandaops/optimism-package
description: |
# Optimism Package
This is a Kurtosis package for deploying an Optimism Rollup
61 changes: 42 additions & 19 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ 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", {})
if "network_params" not in ethereum_args:
ethereum_args.update(input_parser.default_ethereum_package_network_params())
external_l1_args = args.get("external_l1_network_params", {})
if external_l1_args:
external_l1_args = input_parser.external_l1_network_params_input_parser(
plan, external_l1_args
)
else:
if "network_params" not in ethereum_args:
ethereum_args.update(input_parser.default_ethereum_package_network_params())

# need to do a raw get here in case only optimism_package is provided.
# .get will return None if the key is in the config with a None value.
Expand All @@ -29,21 +35,38 @@ def run(plan, args):
persistent = optimism_args_with_right_defaults.persistent

# Deploy the L1
plan.print("Deploying a local L1")
l1 = ethereum_package.run(plan, ethereum_args)
plan.print(l1.network_params)
# Get L1 info
all_l1_participants = l1.all_participants
l1_network_params = l1.network_params
l1_network_id = l1.network_id
l1_priv_key = l1.pre_funded_accounts[
12
].private_key # reserved for L2 contract deployers
l1_config_env_vars = get_l1_config(
all_l1_participants, l1_network_params, l1_network_id
)
l1_network = ""
if external_l1_args:
plan.print("Using external L1")
plan.print(external_l1_args)

l1_rpc_url = external_l1_args.el_rpc_url
l1_priv_key = external_l1_args.priv_key

l1_config_env_vars = {
"L1_RPC_KIND": external_l1_args.rpc_kind,
"L1_RPC_URL": l1_rpc_url,
"CL_RPC_URL": external_l1_args.cl_rpc_url,
"L1_WS_URL": external_l1_args.el_ws_url,
"L1_CHAIN_ID": external_l1_args.network_id,
}
else:
plan.print("Deploying a local L1")
l1 = ethereum_package.run(plan, ethereum_args)
plan.print(l1.network_params)
# Get L1 info
all_l1_participants = l1.all_participants
l1_network_params = l1.network_params
l1_network_id = l1.network_id
l1_rpc_url = all_l1_participants[0].el_context.rpc_http_url
l1_priv_key = l1.pre_funded_accounts[
12
].private_key # reserved for L2 contract deployers
l1_config_env_vars = get_l1_config(
all_l1_participants, l1_network_params, l1_network_id
)

if l1_network_params.network == "kurtosis":
if l1_network == "kurtosis":
plan.print("Waiting for L1 to start up")
wait_for_sync.wait_for_startup(plan, l1_config_env_vars)
else:
Expand All @@ -65,7 +88,7 @@ def run(plan, args):
deployment_output,
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l1_rpc_url,
global_log_level,
global_node_selectors,
global_tolerations,
Expand All @@ -83,7 +106,7 @@ def run(plan, args):
optimism_args,
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l1_rpc_url,
global_log_level,
global_node_selectors,
global_tolerations,
Expand Down Expand Up @@ -117,7 +140,7 @@ def run(plan, args):
l2_args,
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l1_rpc_url,
global_log_level,
global_node_selectors,
global_tolerations,
Expand Down
8 changes: 4 additions & 4 deletions src/blockscout/blockscout_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ VERIF_USED_PORTS = {
def launch_blockscout(
plan,
l2_services_suffix,
l1_el_context,
l1_rpc_url,
l2_el_context,
l2_network_name,
deployment_output,
Expand Down Expand Up @@ -79,7 +79,7 @@ def launch_blockscout(

config_backend = get_config_backend(
postgres_output,
l1_el_context,
l1_rpc_url,
l2_el_context,
verif_url,
l2_network_name,
Expand Down Expand Up @@ -122,7 +122,7 @@ def get_config_verif():

def get_config_backend(
postgres_output,
l1_el_context,
l1_rpc_url,
l2_el_context,
verif_url,
l2_network_name,
Expand All @@ -139,7 +139,7 @@ def get_config_backend(

optimism_env_vars = {
"CHAIN_TYPE": "optimism",
"INDEXER_OPTIMISM_L1_RPC": l1_el_context.rpc_http_url,
"INDEXER_OPTIMISM_L1_RPC": l1_rpc_url,
# "INDEXER_OPTIMISM_L1_PORTAL_CONTRACT": "",
# "INDEXER_OPTIMISM_L1_BATCH_START_BLOCK": "",
"INDEXER_OPTIMISM_L1_BATCH_INBOX": "0xff00000000000000000000000000000000042069",
Expand Down
4 changes: 2 additions & 2 deletions src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def launch_l2(
deployment_output,
l1_config,
l1_priv_key,
l1_bootnode_context,
l1_rpc_url,
global_log_level,
global_node_selectors,
global_tolerations,
Expand Down Expand Up @@ -67,7 +67,7 @@ def launch_l2(
blockscout.launch_blockscout(
plan,
l2_services_suffix,
l1_bootnode_context, # first l1 EL url
l1_rpc_url,
all_el_contexts[0], # first l2 EL url
network_params.name,
deployment_output,
Expand Down
12 changes: 12 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ DEFAULT_PROPOSER_IMAGES = {
DEFAULT_ADDITIONAL_SERVICES = []


def external_l1_network_params_input_parser(plan, input_args):
sanity_check.external_l1_network_params_input_parser(plan, input_args)
return struct(
network_id=input_args["network_id"],
rpc_kind=input_args["rpc_kind"],
el_rpc_url=input_args["el_rpc_url"],
el_ws_url=input_args["el_ws_url"],
cl_rpc_url=input_args["cl_rpc_url"],
priv_key=input_args["priv_key"],
)


def input_parser(plan, input_args):
sanity_check.sanity_check(plan, input_args)
results = parse_network_params(plan, input_args)
Expand Down
20 changes: 20 additions & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ ROOT_PARAMS = [
]


EXTERNAL_L1_NETWORK_PARAMS = [
"network_id",
"rpc_kind",
"el_rpc_url",
"el_ws_url",
"cl_rpc_url",
"priv_key",
]


def deep_validate_params(plan, input_args, category, allowed_params):
if category in input_args:
for item in input_args[category]:
Expand Down Expand Up @@ -149,3 +159,13 @@ def sanity_check(plan, optimism_config):
)

plan.print("Sanity check for OP package passed")


def external_l1_network_params_input_parser(plan, external_l1_network_params):
for key in external_l1_network_params.keys():
if key not in EXTERNAL_L1_NETWORK_PARAMS:
fail(
"Invalid parameter {0}, allowed fields: {1}".format(
key, EXTERNAL_L1_NETWORK_PARAMS
)
)
Loading