-
Notifications
You must be signed in to change notification settings - Fork 44
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
Changes from all commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
e3364b0
deploy multiple l2s
tedim52 cd5c11c
separate deploying factory contract and l2 contracts
tedim52 d1903b8
adjust network params
tedim52 ead655a
Merge pull request #1 from tedim52/tedi/multil2
tedim52 023bc7b
adjust locator
tedim52 bba66fe
remove redundant steps
tedim52 db87257
add package icon
tedim52 0aae947
remove priv key
tedim52 d3025c1
add back funding
tedim52 05b4a80
remove unused vars
tedim52 1aafeef
Apply suggestions from code review
tedim52 a0272aa
only add service suffix if > 1 l2s
tedim52 38a7a40
elaborate on deploy contract timing
tedim52 1bb1ca0
clarify comments
tedim52 4249230
redirect ethereum package
tedim52 6987bbf
prefund l2 accounts
tedim52 f88243f
switch to ethpandaops
tedim52 3fee4f2
fix json
tedim52 269be6b
create separate op genesis files artifacts for each roll up
tedim52 9900c98
Merge branch 'tedi/multil2'
tedim52 d9a0851
fix typo
tedim52 18d18b9
update locator
tedim52 3044b6f
use l2 rpc url
tedim52 682a970
address pr comments
tedim52 581bcb0
fix nested if else
tedim52 7c3925f
get private keys once
tedim52 ca3407d
add name
tedim52 75753d0
Merge branch 'main' into tedi/multil2
tedim52 47b4518
remove edit script
tedim52 4585858
add multi l2 config to readme
tedim52 3e0fc36
re order config
tedim52 87c27ba
rename locator
tedim52 8e88b7f
update readme
tedim52 bf13744
rm num from prefix
tedim52 ccfcaf6
add multi roll up yaml
tedim52 08bbfa0
- -> _
tedim52 d72c769
fix typo
tedim52 e8010a8
adjust docstring
tedim52 e88592f
rm commented sections
tedim52 e61f875
suffix only if multiple l2s
tedim52 3dd1ca2
add sanity check
barnabasbusa 71489ac
add some tests
barnabasbusa 332020b
add some tests
barnabasbusa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,4 @@ ethereum_package: | |
preset: minimal | ||
additional_services: | ||
- dora | ||
- blockscout | ||
|
||
- blockscout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 wellThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which package indexer?