Skip to content

Commit

Permalink
feat: add op_batcher + op_deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed Jun 6, 2024
1 parent c28dd50 commit 1638844
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 71 deletions.
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)
70 changes: 17 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,17 @@ 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,
]

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
15 changes: 11 additions & 4 deletions src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ def launch_contract_deployer(
"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 $DEPLOYMENT_OUTFILE | jq -r .L2OutputOracleProxy > /network-configs/L2OutputOracleProxy.json",
]
),
wait="2000s",
Expand All @@ -95,10 +96,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",
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
90 changes: 90 additions & 0 deletions src/proposer/op-proposer/op_proposer_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
shared_utils = import_module(
"github.com/kurtosis-tech/ethereum-package/src/shared_utils/shared_utils.star"
)

constants = import_module(
"github.com/kurtosis-tech/ethereum-package/src/package_io/constants.star"
)

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

# Port IDs
PROPOSER_HTTP_PORT_ID = "http"

# Port nums
PROPOSER_HTTP_PORT_NUM = 8560


def get_used_ports():
used_ports = {
PROPOSER_HTTP_PORT_ID: shared_utils.new_port_spec(
PROPOSER_HTTP_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
}
return used_ports


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


def launch(
plan,
service_name,
image,
cl_context,
l1_config_env_vars,
gs_proposer_private_key,
l2oo_address,
):
proposer_service_name = "{0}".format(service_name)

config = get_proposer_config(
plan,
image,
service_name,
cl_context,
l1_config_env_vars,
gs_proposer_private_key,
l2oo_address,
)

proposer_service = plan.add_service(service_name, config)

proposer_http_port = proposer_service.ports[PROPOSER_HTTP_PORT_ID]
proposer_http_url = "http://{0}:{1}".format(
proposer_service.ip_address, proposer_http_port.number
)

return "op_proposer"


def get_proposer_config(
plan,
image,
service_name,
cl_context,
l1_config_env_vars,
gs_proposer_private_key,
l2oo_address,
):
cmd = [
"--poll-interval=12s",
"--rpc.port=" + str(PROPOSER_HTTP_PORT_NUM),
"--rollup-rpc=" + cl_context.beacon_http_url,
"--l2oo-address=" + str(l2oo_address),
"--private-key=" + gs_proposer_private_key,
"--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"],
]

ports = get_used_ports()
return ServiceConfig(
image=image,
ports=ports,
cmd=cmd,
private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
)

0 comments on commit 1638844

Please sign in to comment.