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 op_geth #4

Merged
merged 7 commits into from
Jun 5, 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
22 changes: 0 additions & 22 deletions .github/workflows/conventional-pr-title-checker.yml

This file was deleted.

4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ RUN foundryup

RUN git clone https://github.com/ethereum-optimism/optimism.git && \
cd optimism && \
git checkout tutorials/chain && \
git checkout develop && \
git pull origin develop && \
parithosh marked this conversation as resolved.
Show resolved Hide resolved
pnpm install && \
pnpm build

Expand All @@ -55,6 +56,7 @@ WORKDIR /workspace
RUN apt-get update && apt-get install -y --no-install-recommends \
jq \
direnv \
git \
bash \
curl \
ca-certificates \
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
## Welcome to Optimism Package
default package for Optimism
```yaml
optimism_package:
participants:
- el_type: op-geth
el_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest
cl_type: op-node
cl_image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop
count: 1
network_params:
network: kurtosis
network_id: "2151908"
seconds_per_slot: 2
```
58 changes: 49 additions & 9 deletions main.star
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
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 get_l1_stuff(all_l1_participants, l1_network_params):
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
l1_chain_id = l1_network_params.network_id
l1_block_time = l1_network_params.seconds_per_slot
return first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time


def run(plan, args={}):
Expand All @@ -21,22 +33,50 @@ def run(plan, args={}):
plan.print("Deploying a local L1")
l1 = ethereum_package.run(plan, ethereum_args)
all_l1_participants = l1.all_participants
l1_network_params = l1.network_params
priv_key = l1.pre_funded_accounts[
12
].private_key # reserved for L2 contract deployer
# Deploy L2 smart contracts
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
)

# Parse the values for the args
plan.print("Parsing the L2 input args")
optimism_args = args["optimism_package"]

first_l1_el_node, first_l1_cl_node, l1_chain_id, l1_block_time = 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_block_time = network_params.seconds_per_slot
l2_chain_id = network_params.network_id

el_cl_data = contract_deployer.launch_contract_deployer(
plan,
first_l1_el_node,
first_l1_cl_node,
priv_key,
l1_chain_id,
l2_chain_id,
l1_block_time,
l2_block_time,
)

# 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",
)

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
47 changes: 33 additions & 14 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
IMAGE = "parithoshj/op-test:v3"
IMAGE = "bbusa/op:latest"

ENVRC_PATH = "/workspace/optimism/.envrc"

Expand All @@ -11,15 +11,33 @@ def launch_contract_deployer(
el_rpc_http_url,
cl_rpc_http_url,
priv_key,
l1_chain_id,
l2_chain_id,
l1_block_time,
l2_block_time,
):
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={
"WEB3_RPC_URL": str(el_rpc_http_url),
"WEB3_PRIVATE_KEY": str(priv_key),
"CL_RPC_URL": str(cl_rpc_http_url),
"FUND_VALUE": "10",
"DEPLOYMENT_OUTFILE": "/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_chain_id)
+ "/kurtosis.json",
"DEPLOY_CONFIG_PATH": "/workspace/optimism/packages/contracts-bedrock/deploy-config/getting-started.json",
"STATE_DUMP_PATH": "/workspace/optimism/packages/contracts-bedrock/deployments/"
+ str(l1_chain_id)
+ "/state-dump.json",
"L1_RPC_KIND": "any",
"L1_RPC_URL": str(el_rpc_http_url),
"L1_CHAIN_ID": str(l1_chain_id),
"L2_CHAIN_ID": str(l2_chain_id),
"L1_BLOCK_TIME": str(l1_block_time),
"L2_BLOCK_TIME": str(l2_block_time),
"DEPLOYMENT_CONTEXT": "getting-started",
},
store=[
StoreSpec(src="/network-configs", name="op-genesis-configs"),
Expand All @@ -32,17 +50,11 @@ def launch_contract_deployer(
"sed -i '1d' {0}".format(
ENVRC_PATH
), # Remove the first line (not commented out)
"echo 'export L1_RPC_KIND=any' >> {0}".format(ENVRC_PATH),
"echo 'export L1_RPC_URL={0}' >> {1}".format(
el_rpc_http_url, ENVRC_PATH
),
"echo 'export IMPL_SALT=$(openssl rand -hex 32)' >> {0}".format(
ENVRC_PATH
),
"echo 'export DEPLOYMENT_CONTEXT=getting-started' >> {0}".format(
ENVRC_PATH
),
". {0}".format(ENVRC_PATH),
"mkdir -p /network-configs",
"web3 transfer $FUND_VALUE to $GS_ADMIN_ADDRESS", # Fund Admin
"sleep 3",
"web3 transfer $FUND_VALUE to $GS_BATCHER_ADDRESS", # Fund Batcher
Expand All @@ -63,13 +75,20 @@ def launch_contract_deployer(
"sleep 12",
"forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL",
"sleep 3",
"CONTRACT_ADDRESSES_PATH=$DEPLOYMENT_OUTFILE forge script scripts/L2Genesis.s.sol:L2Genesis --sig 'runWithStateDump()' --chain-id $L2_CHAIN_ID",
"cd /workspace/optimism/op-node",
"go run cmd/main.go genesis l2 --deploy-config ../packages/contracts-bedrock/deploy-config/getting-started.json --l1-deployments ../packages/contracts-bedrock/deployments/getting-started/.deploy --outfile.l2 genesis.json --outfile.rollup rollup.json --l1-rpc $L1_RPC_URL",
"mkdir -p /network-configs",
"mv /workspace/optimism/op-node/genesis.json /network-configs/genesis.json",
"mv /workspace/optimism/op-node/rollup.json /network-configs/rollup.json",
"mv /workspace/optimism/packages/contracts-bedrock/deployments/getting-started/.deploy /network-configs/.deploy",
"go run cmd/main.go genesis l2 \
--l1-rpc $L1_RPC_URL \
parithosh marked this conversation as resolved.
Show resolved Hide resolved
--deploy-config $DEPLOY_CONFIG_PATH \
--l2-allocs $STATE_DUMP_PATH \
--l1-deployments $DEPLOYMENT_OUTFILE \
--outfile.l2 /network-configs/genesis.json \
--outfile.rollup /network-configs/rollup.json",
"mv $DEPLOY_CONFIG_PATH /network-configs/getting-started.json",
"mv $DEPLOYMENT_OUTFILE /network-configs/kurtosis.json",
"mv $STATE_DUMP_PATH /network-configs/state-dump.json",
]
),
wait="2000s",
)
return op_genesis.files_artifacts[0]
69 changes: 69 additions & 0 deletions src/el/el_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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
Loading