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_batcher + op_deployer #7

Merged
merged 3 commits into from
Jun 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
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ RUN git clone https://github.com/ethereum-optimism/optimism.git && \
git checkout develop && \
git pull origin develop && \
pnpm install && \
pnpm build
pnpm build && \
cd op-node && \
make
Copy link
Member

Choose a reason for hiding this comment

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

whats this dockerfile here for again?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to make the contract deployment

Op node generates the config for L2 genesis

Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously I was always compiling op node. We can probably copy the binary straight into the builder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but we still need the solidity files to run the forge script. Not sure if we can forge a remote solidity file.

Copy link
Member

Choose a reason for hiding this comment

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

yeah makes sense!




# Use multi-stage build to keep the final image lean
Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@ optimism_package:
participants:
- el_type: op-geth
cl_type: op-node
network_params:
network: kurtosis
network_id: "2151908"
seconds_per_slot: 2
ethereum_package:
participants:
- el_type: geth
#- el_type: reth
- el_type: reth
network_params:
preset: minimal
additional_services:
- dora
#- blockscout

- blockscout
```
7 changes: 6 additions & 1 deletion main.star
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def run(plan, args={}):
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)

el_cl_data, gs_private_keys = contract_deployer.launch_contract_deployer(
(
el_cl_data,
gs_private_keys,
l2oo_address,
) = contract_deployer.launch_contract_deployer(
plan,
l1_priv_key,
l1_config_env_vars,
Expand All @@ -88,6 +92,7 @@ def run(plan, args={}):
el_cl_data,
gs_private_keys,
l1_config_env_vars,
l2oo_address,
)

plan.print(all_participants)
8 changes: 2 additions & 6 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ optimism_package:
participants:
- el_type: op-geth
cl_type: op-node
network_params:
network: kurtosis
network_id: "2151908"
seconds_per_slot: 2
ethereum_package:
participants:
- el_type: geth
#- el_type: reth
- el_type: reth
network_params:
preset: minimal
additional_services:
- dora
#- blockscout
- blockscout

71 changes: 18 additions & 53 deletions src/batcher/op-batcher/op_batcher_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ constants = import_module(
"github.com/kurtosis-tech/ethereum-package/src/package_io/constants.star"
)


#
# ---------------------------------- Batcher client -------------------------------------
# The Docker container runs as the "op-batcher" user so we can't write to root
BATCHER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-batcher/op-batcher-beacon-data"
BATCHER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-batcher/op-batcher-data"

# Port IDs
BEACON_HTTP_PORT_ID = "http"
BATCHER_HTTP_PORT_ID = "http"

# Port nums
BEACON_HTTP_PORT_NUM = 8548
BATCHER_HTTP_PORT_NUM = 8548


def get_used_ports(discovery_port):
def get_used_ports():
used_ports = {
BEACON_HTTP_PORT_ID: shared_utils.new_port_spec(
BEACON_HTTP_PORT_NUM,
BATCHER_HTTP_PORT_ID: shared_utils.new_port_spec(
BATCHER_HTTP_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
Expand All @@ -32,64 +31,47 @@ def get_used_ports(discovery_port):

ENTRYPOINT_ARGS = ["sh", "-c"]

VERBOSITY_LEVELS = {
constants.GLOBAL_LOG_LEVEL.error: "ERROR",
constants.GLOBAL_LOG_LEVEL.warn: "WARN",
constants.GLOBAL_LOG_LEVEL.info: "INFO",
constants.GLOBAL_LOG_LEVEL.debug: "DEBUG",
constants.GLOBAL_LOG_LEVEL.trace: "TRACE",
}


def launch(
plan,
launcher,
service_name,
image,
el_context,
existing_cl_clients,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
):
beacon_service_name = "{0}".format(service_name)
batcher_service_name = "{0}".format(service_name)

network_name = shared_utils.get_network_name(launcher.network)
config = get_beacon_config(
config = get_batcher_config(
plan,
launcher.el_cl_genesis_data,
launcher.jwt_file,
image,
service_name,
el_context,
existing_cl_clients,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
)

beacon_service = plan.add_service(service_name, config)
batcher_service = plan.add_service(service_name, config)

beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID]
beacon_http_url = "http://{0}:{1}".format(
beacon_service.ip_address, beacon_http_port.number
batcher_http_port = batcher_service.ports[BATCHER_HTTP_PORT_ID]
batcher_http_url = "http://{0}:{1}".format(
batcher_service.ip_address, batcher_http_port.number
)

return "op_batcher"


def get_beacon_config(
def get_batcher_config(
plan,
el_cl_genesis_data,
jwt_file,
image,
service_name,
el_context,
cl_context,
l1_config_env_vars,
gs_batcher_private_key,
):
discovery_port = BEACON_DISCOVERY_PORT_NUM
used_ports = get_used_ports(discovery_port)

cmd = [
"--l2-eth-rpc=" + el_context.rpc_http_url,
"--rollup-rpc=" + cl_context.beacon_http_url,
Expand All @@ -99,35 +81,18 @@ def get_beacon_config(
"--safe-abort-nonce-too-low-count=3",
"--resubmission-timeout=30s",
"--rpc.addr=0.0.0.0",
"--rpc.port=" + BEACON_HTTP_PORT_NUM,
"--rpc.port=" + str(BATCHER_HTTP_PORT_NUM),
"--rpc.enable-admin",
"--max-channel-duration=1",
"--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"],
"--private-key=" + gs_batcher_private_key,
"--data-availability-type=blobs",
]

files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data,
constants.JWT_MOUNTPOINT_ON_CLIENTS: jwt_file,
}
ports = {}
ports.update(used_ports)

ports = get_used_ports()
return ServiceConfig(
image=image,
ports=ports,
cmd=cmd,
files=files,
private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
ready_conditions=cl_node_ready_conditions.get_ready_conditions(
BEACON_HTTP_PORT_ID
),
)


def new_op_node_launcher(el_cl_genesis_data, jwt_file, network_params):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
network=network_params.network,
)
4 changes: 1 addition & 3 deletions src/cl/cl_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ shared_utils = import_module(
"github.com/kurtosis-tech/ethereum-package/src/shared_utils/shared_utils.star"
)

cl_context_BOOTNODE = None

op_node = import_module("./op-node/op_node_launcher.star")


Expand Down Expand Up @@ -71,4 +69,4 @@ def launch(
)

all_cl_contexts.append(cl_context)
return (all_cl_contexts,)
return all_cl_contexts
32 changes: 20 additions & 12 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,22 @@ def launch_contract_deployer(
"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 \
--l1-rpc $L1_RPC_URL \
--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",
"cd /workspace/optimism/op-node/bin",
"./op-node genesis l2 \
--l1-rpc $L1_RPC_URL \
--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",
"echo -n $GS_SEQUENCER_PRIVATE_KEY >> /network-configs/GS_SEQUENCER_PRIVATE_KEY",
"echo -n $GS_BATCHER_PRIVATE_KEY >> /network-configs/GS_BATCHER_PRIVATE_KEY",
"echo -n $GS_PROPOSER_PRIVATE_KEY >> /network-configs/GS_PROPOSER_PRIVATE_KEY",
"echo -n $GS_SEQUENCER_PRIVATE_KEY > /network-configs/GS_SEQUENCER_PRIVATE_KEY",
"echo -n $GS_BATCHER_PRIVATE_KEY > /network-configs/GS_BATCHER_PRIVATE_KEY",
"echo -n $GS_PROPOSER_PRIVATE_KEY > /network-configs/GS_PROPOSER_PRIVATE_KEY",
"cat /network-configs/kurtosis.json | jq -r .L2OutputOracleProxy > /network-configs/L2OutputOracleProxy.json",
"cat /network-configs/kurtosis.json | jq -r .L1StandardBridgeProxy > /network-configs/L1StandardBridgeProxy.json",
]
),
wait="2000s",
Expand All @@ -95,10 +97,16 @@ def launch_contract_deployer(
files={"/network-configs": op_genesis.files_artifacts[0]},
)

l2oo_address = plan.run_sh(
description="Getting the L2OutputOracleProxy address",
run="cat /network-configs/L2OutputOracleProxy.json | tr -d '\n'",
files={"/network-configs": op_genesis.files_artifacts[0]},
)

private_keys = {
"GS_SEQUENCER_PRIVATE_KEY": gs_sequencer_private_key.output,
"GS_BATCHER_PRIVATE_KEY": gs_batcher_private_key.output,
"GS_PROPOSER_PRIVATE_KEY": gs_proposer_private_key.output,
}

return op_genesis.files_artifacts[0], private_keys
return op_genesis.files_artifacts[0], private_keys, l2oo_address.output
4 changes: 2 additions & 2 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ DEFAULT_CL_IMAGES = {
}

DEFAULT_BATCHER_IMAGES = {
"op-batcher": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:develop",
"op-batcher": "parithoshj/op-batcher:v1",
}

DEFAULT_PROPOSER_IMAGES = {
"op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop",
"op-proposer": "parithoshj/op-proposer:v1",
}

ATTR_TO_BE_SKIPPED_AT_ROOT = (
Expand Down
30 changes: 22 additions & 8 deletions src/participant_network.star
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
el_client_launcher = import_module("./el/el_launcher.star")
cl_client_launcher = import_module("./cl/cl_launcher.star")
participant_module = import_module("./participant.star")
input_parser = import_module("./package_io/input_parser.star")
op_batcher_launcher = import_module("./batcher/op-batcher/op_batcher_launcher.star")
op_proposer_launcher = import_module("./proposer/op-proposer/op_proposer_launcher.star")


def launch_participant_network(
Expand All @@ -11,6 +14,7 @@ def launch_participant_network(
el_cl_data,
gs_private_keys,
l1_config_env_vars,
l2oo_address,
):
num_participants = len(participants)
# Launch all execution layer clients
Expand Down Expand Up @@ -52,14 +56,24 @@ def launch_participant_network(

all_participants.append(participant_entry)

# op_batcher_launcher.launch(
# plan,
# )
# participant_module.new_participant(

# )
# op_proposer_launcher.launch(
op_batcher_launcher.launch(
plan,
"op-batcher",
input_parser.DEFAULT_BATCHER_IMAGES["op-batcher"],
all_el_contexts[0],
all_cl_contexts[0],
l1_config_env_vars,
gs_private_keys["GS_BATCHER_PRIVATE_KEY"],
)

# )
op_proposer_launcher.launch(
plan,
"op-proposer",
input_parser.DEFAULT_PROPOSER_IMAGES["op-proposer"],
all_cl_contexts[0],
l1_config_env_vars,
gs_private_keys["GS_PROPOSER_PRIVATE_KEY"],
l2oo_address,
)

return all_participants
Loading
Loading