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: deploy multiple op l2s #20

Merged
merged 43 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e3364b0
deploy multiple l2s
tedim52 Jun 11, 2024
cd5c11c
separate deploying factory contract and l2 contracts
tedim52 Jun 11, 2024
d1903b8
adjust network params
tedim52 Jun 11, 2024
ead655a
Merge pull request #1 from tedim52/tedi/multil2
tedim52 Jun 11, 2024
023bc7b
adjust locator
tedim52 Jun 11, 2024
bba66fe
remove redundant steps
tedim52 Jun 11, 2024
db87257
add package icon
tedim52 Jun 11, 2024
0aae947
remove priv key
tedim52 Jun 11, 2024
d3025c1
add back funding
tedim52 Jun 11, 2024
05b4a80
remove unused vars
tedim52 Jun 11, 2024
1aafeef
Apply suggestions from code review
tedim52 Jun 12, 2024
a0272aa
only add service suffix if > 1 l2s
tedim52 Jun 12, 2024
38a7a40
elaborate on deploy contract timing
tedim52 Jun 12, 2024
1bb1ca0
clarify comments
tedim52 Jun 12, 2024
4249230
redirect ethereum package
tedim52 Jun 13, 2024
6987bbf
prefund l2 accounts
tedim52 Jun 13, 2024
f88243f
switch to ethpandaops
tedim52 Jun 13, 2024
3fee4f2
fix json
tedim52 Jun 13, 2024
269be6b
create separate op genesis files artifacts for each roll up
tedim52 Jun 14, 2024
9900c98
Merge branch 'tedi/multil2'
tedim52 Jun 14, 2024
d9a0851
fix typo
tedim52 Jun 14, 2024
18d18b9
update locator
tedim52 Jun 14, 2024
3044b6f
use l2 rpc url
tedim52 Jun 17, 2024
682a970
address pr comments
tedim52 Jun 17, 2024
581bcb0
fix nested if else
tedim52 Jun 17, 2024
7c3925f
get private keys once
tedim52 Jun 17, 2024
ca3407d
add name
tedim52 Jun 17, 2024
75753d0
Merge branch 'main' into tedi/multil2
tedim52 Jun 17, 2024
47b4518
remove edit script
tedim52 Jun 17, 2024
4585858
add multi l2 config to readme
tedim52 Jun 17, 2024
3e0fc36
re order config
tedim52 Jun 17, 2024
87c27ba
rename locator
tedim52 Jun 17, 2024
8e88b7f
update readme
tedim52 Jun 17, 2024
bf13744
rm num from prefix
tedim52 Jun 17, 2024
ccfcaf6
add multi roll up yaml
tedim52 Jun 17, 2024
08bbfa0
- -> _
tedim52 Jun 17, 2024
d72c769
fix typo
tedim52 Jun 17, 2024
e8010a8
adjust docstring
tedim52 Jun 17, 2024
e88592f
rm commented sections
tedim52 Jun 17, 2024
e61f875
suffix only if multiple l2s
tedim52 Jun 18, 2024
3dd1ca2
add sanity check
barnabasbusa Jun 18, 2024
71489ac
add some tests
barnabasbusa Jun 18, 2024
332020b
add some tests
barnabasbusa Jun 18, 2024
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
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.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently, our package indexer only picks up json (you can still pass it in as yaml but starlark converts it to json) so in order for the package to show up in package catalog, has to be set to json instead of yaml. I can update package indexer to support yaml type as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which package indexer?

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