Skip to content

Commit

Permalink
Merge pull request #20 from tedim52/tedi/multil2
Browse files Browse the repository at this point in the history
feat: deploy multiple op l2s
  • Loading branch information
barnabasbusa authored Jun 18, 2024
2 parents 16f5ed8 + 332020b commit 5bb15fa
Show file tree
Hide file tree
Showing 19 changed files with 469 additions and 152 deletions.
24 changes: 24 additions & 0 deletions .github/tests/multiple_l2s.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
optimism_package:
- participants:
- el_type: op-geth
network_params:
name: op-rollup-one
network_id: "3151909"
additional_services:
- blockscout
- participants:
- el_type: op-geth
network_params:
name: op-rollup-two
network_id: "3151910"
additional_services:
- blockscout
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal
additional_services:
- dora
- blockscout
11 changes: 11 additions & 0 deletions .github/tests/op-geth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
optimism_package:
participants:
- el_type: op-geth
cl_type: op-node
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal

13 changes: 13 additions & 0 deletions .github/tests/op-node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
optimism_package:
participants:
- el_type: op-geth
cl_type: op-node
- el_type: op-reth
cl_type: op-node
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal

11 changes: 11 additions & 0 deletions .github/tests/op-reth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
optimism_package:
participants:
- el_type: op-reth
cl_type: op-node
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal

10 changes: 10 additions & 0 deletions .github/tests/single_l2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
optimism_package:
participants:
- count: 2
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal

50 changes: 50 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Nightly test Workflow

on:
schedule:
- cron: "0 2 * * *" # This schedules the workflow to run at 02:00 UTC every day
workflow_dispatch:

jobs:
list-yamls:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
# List all yaml files in the .github/tests directory, except for the k8s.yaml file
run: echo "matrix=$(ls ./.github/tests/*.yaml | grep -vE 'k8s.yaml$' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
run_with_args:
needs: list-yamls
strategy:
matrix:
file_name: ${{ fromJson(needs.list-yamls.outputs.matrix) }}
runs-on: ubuntu-latest
continue-on-error: true
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: Run Starlark
run: |
if [ "${{ matrix.file_name }}" != "./.github/tests/mix-with-tools-mev.yaml" ]; then
kurtosis run ${{ github.workspace }} --verbosity detailed --args-file ${{ matrix.file_name }}
else
echo "Skipping ./.github/tests/mix-with-tools-mev.yaml"
fi
# - name: Notify
# if: cancelled() || failure()
# uses: Ilshidur/action-discord@master
# env:
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
# with:
# args: "The nightly test for ${{matrix.file_name}} on ethereum-package has failed find it here ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,33 @@ ethereum_package:
- dora
- blockscout
```

Additionally, you can spin up multiple L2 networks by providing a list of L2 configuration parameters like so:

```yaml
optimism_package:
- participants:
- el_type: op-geth
network_params:
name: op-rollup-one
network_id: "3151909"
additional_services:
- blockscout
- participants:
- el_type: op-geth
network_params:
name: op-rollup-two
network_id: "3151910"
additional_services:
- blockscout
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal
additional_services:
- dora
- blockscout
```
Note: if configuring multiple L2s, make sure that the `network_id` and `name` are set to differentiate networks.
Binary file added kurtosis-package-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
169 changes: 74 additions & 95 deletions main.star
Original file line number Diff line number Diff line change
@@ -1,123 +1,102 @@
input_parser = import_module("./src/package_io/input_parser.star")
ethereum_package = import_module("github.com/ethpandaops/ethereum-package/main.star")
contract_deployer = import_module("./src/contracts/contract_deployer.star")
static_files = import_module(
"github.com/ethpandaops/ethereum-package/src/static_files/static_files.star"
)
participant_network = import_module("./src/participant_network.star")
blockscout = import_module("./src/blockscout/blockscout_launcher.star")
l2_launcher = import_module("./src/l2.star")


def get_l1_stuff(all_l1_participants, l1_network_params):
env_vars = {}
env_vars["L1_RPC_KIND"] = "any"
env_vars["WEB3_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["L1_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["CL_RPC_URL"] = str(all_l1_participants[0].cl_context.beacon_http_url)
env_vars["L1_CHAIN_ID"] = str(l1_network_params.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_params.network_id)
+ "/kurtosis.json"
)
env_vars["STATE_DUMP_PATH"] = (
"/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_network_params.network_id)
+ "/state-dump.json"
)

return env_vars


def run(plan, args={}):
"""Deploy a Optimism L2 with a local L1.
def run(plan, args):
"""Deploy Optimism L2s on an Ethereum L1.
Args:
args(yaml): Configures other aspects of the environment.
args(json): Configures other aspects of the environment.
Returns:
A full deployment of Optimism L2
A full deployment of Optimism L2(s)
"""

# Parse the values for the args
plan.print("Parsing the L1 input args")

ethereum_args = args["ethereum_package"]

# Deploy the L1
plan.print("Deploying a local L1")
l1 = ethereum_package.run(plan, ethereum_args)

# Get L1 info
all_l1_participants = l1.all_participants
l1_network_params = l1.network_params
l1_priv_key = l1.pre_funded_accounts[
12
].private_key # reserved for L2 contract deployer
# Deploy L2 smart contracts
# Parse the values for the args
plan.print("Parsing the L2 input args")
optimism_args = args["optimism_package"]

l1_config_env_vars = get_l1_stuff(all_l1_participants, l1_network_params)

args_with_right_defaults = input_parser.input_parser(plan, optimism_args)
network_params = args_with_right_defaults.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)
].private_key # reserved for L2 contract deployers
l1_config_env_vars = get_l1_config(all_l1_participants, l1_network_params)

(
el_cl_data,
gs_private_keys,
l2oo_address,
l1_bridge_address,
blockscout_env_variables,
) = contract_deployer.launch_contract_deployer(
plan,
l1_priv_key,
l1_config_env_vars,
l2_config_env_vars,
# Deploy Create2 Factory contract (only need to do this once for multiple l2s)
l2_private_keys = contract_deployer.deploy_factory_contract(
plan, l1_priv_key, l1_config_env_vars
)

# Deploy the L2
plan.print("Deploying a local L2")

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

all_l2_participants = participant_network.launch_participant_network(
plan,
args_with_right_defaults.participants,
jwt_file,
network_params,
el_cl_data,
gs_private_keys,
l1_config_env_vars,
l2oo_address,
)

all_el_contexts = []
all_cl_contexts = []
for participant in all_l2_participants:
all_el_contexts.append(participant.el_context)
all_cl_contexts.append(participant.cl_context)

for additional_service in args_with_right_defaults.additional_services:
if additional_service == "blockscout":
plan.print("Launching op-blockscout")
blockscout_launcher = blockscout.launch_blockscout(
# Deploy L2s
if type(args["optimism_package"]) == "dict":
l2_services_suffix = "" # no suffix if one l2
l2_launcher.launch_l2(
plan,
l2_services_suffix,
args["optimism_package"],
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l2_private_keys,
)
elif type(args["optimism_package"]) == "list":
seen_names = {}
seen_network_ids = {}
for l2_num, l2_args in enumerate(args["optimism_package"]):
name = l2_args["network_params"]["name"]
network_id = l2_args["network_params"]["network_id"]
if name in seen_names:
fail(
"Duplicate name: {0} provided, make sure you use unique names.".format(
name
)
)
if network_id in seen_network_ids:
fail(
"Duplicate network_id: {0} provided, make sure you use unique network_ids.".format(
network_id
)
)
seen_names[name] = True
seen_network_ids[network_id] = True
l2_services_suffix = "-{0}".format(name)
l2_launcher.launch_l2(
plan,
all_l1_participants[0].el_context, # first L1 EL url,
l2oo_address,
blockscout_env_variables,
l2_services_suffix,
l2_args,
l1_config_env_vars,
l1_priv_key,
all_l1_participants[0].el_context,
l2_private_keys,
)
plan.print("Successfully launched op-blockscout")
else:
fail("invalid type provided for param: `optimism-package`")

plan.print(all_l2_participants)
plan.print(
"Begin your L2 adventures by depositing some L1 Kurtosis ETH to: {0}".format(
l1_bridge_address
)

def get_l1_config(all_l1_participants, l1_network_params):
env_vars = {}
env_vars["L1_RPC_KIND"] = "any"
env_vars["WEB3_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["L1_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["CL_RPC_URL"] = str(all_l1_participants[0].cl_context.beacon_http_url)
env_vars["L1_CHAIN_ID"] = str(l1_network_params.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_params.network_id)
+ "/kurtosis.json"
)
env_vars["STATE_DUMP_PATH"] = (
"/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_network_params.network_id)
+ "/state-dump.json"
)

return env_vars
3 changes: 1 addition & 2 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ ethereum_package:
preset: minimal
additional_services:
- dora
- blockscout

- blockscout
21 changes: 21 additions & 0 deletions network_params_two_rollups.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ethereum_package:
participants:
- el_type: geth
- el_type: reth
network_params:
preset: minimal
optimism_package:
- participants:
- el_type: op-geth
additional_services:
- blockscout
network_params:
name: op-rollup-one
network_id: "3151909"
- participants:
- el_type: op-geth
network_params:
name: op-rollup-two
network_id: "3151910"
additional_services:
- blockscout
Loading

0 comments on commit 5bb15fa

Please sign in to comment.