Skip to content

Commit

Permalink
feat: adds op-challenger support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhwrd committed Dec 23, 2024
1 parent f062776 commit 7a46324
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ optimism_package:
# A list of optional extra params that will be passed to the batcher container for modifying its behaviour
extra_params: []

# Default challenger configuration
challenger_params:
# The Docker image that should be used for the challenger; leave blank to use the default op-challenger image
image: ""

# A list of optional extra params that will be passed to the challenger container for modifying its behaviour
extra_params: []

# Default proposer configuration
proposer_params:
# The Docker image that should be used for the proposer; leave blank to use the default op-proposer image
image: ""

# A list of optional extra params that will be passed to the proposer container for modifying its behaviour
extra_params: []

# Dispute game type to create via the configured DisputeGameFactory
game_type: 1

# Interval between submitting L2 output proposals
proposal_internal: 10m

# Default MEV configuration
mev_params:
# The Docker image that should be used for rollup boost; leave blank to use the default rollup-boost image
Expand Down
8 changes: 8 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ l2_launcher = import_module("./src/l2.star")
wait_for_sync = import_module("./src/wait/wait_for_sync.star")
input_parser = import_module("./src/package_io/input_parser.star")

PRESTATES_FILEPATH = "static_files/prestates"


def run(plan, args):
"""Deploy Optimism L2s on an Ethereum L1.
Expand Down Expand Up @@ -82,13 +84,19 @@ def run(plan, args):
l1_network,
)

prestates_artifact = plan.upload_files(
src=PRESTATES_FILEPATH,
name="op-challenger-prestates",
)

for l2_num, chain in enumerate(optimism_args_with_right_defaults.chains):
l2_launcher.launch_l2(
plan,
l2_num,
chain.network_params.name,
chain,
deployment_output,
prestates_artifact,
l1_config_env_vars,
l1_priv_key,
l1_rpc_url,
Expand Down
106 changes: 106 additions & 0 deletions src/challenger/op-challenger/op_challenger_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
ethereum_package_shared_utils = import_module(
"github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star"
)

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

#
# ---------------------------------- Challenger client -------------------------------------
CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/op-challenger/op-challenger-data"
ENTRYPOINT_ARGS = ["sh", "-c"]


def get_used_ports():
used_ports = {}
return used_ports


def launch(
plan,
service_name,
image,
el_context,
cl_context,
l1_config_env_vars,
gs_challenger_private_key,
game_factory_address,
deployment_output,
prestates_artifact,
network_params,
challenger_params,
):
challenger_service_name = "{0}".format(service_name)

config = get_challenger_config(
plan,
service_name,
image,
el_context,
cl_context,
l1_config_env_vars,
gs_challenger_private_key,
game_factory_address,
deployment_output,
prestates_artifact,
network_params,
challenger_params,
)

challenger_service = plan.add_service(service_name, config)

return "op_challenger"


def get_challenger_config(
plan,
service_name,
image,
el_context,
cl_context,
l1_config_env_vars,
gs_challenger_private_key,
game_factory_address,
deployment_output,
prestates_artifact,
network_params,
challenger_params,
):
cmd = [
"op-challenger",
"--cannon-l2-genesis="
+ ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS
+ "/genesis-{0}.json".format(network_params.network_id),
"--cannon-prestate=/prestates/prestate-proof.json",
"--cannon-rollup-config="
+ ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS
+ "/rollup-{0}.json".format(network_params.network_id),
"--game-factory-address=" + game_factory_address,
"--datadir=" + CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER,
"--l1-beacon=" + l1_config_env_vars["CL_RPC_URL"],
"--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"],
"--l2-eth-rpc=" + el_context.rpc_http_url,
"--private-key=" + gs_challenger_private_key,
"--rollup-rpc=" + cl_context.beacon_http_url,
"--trace-type=" + "cannon,permissioned",
]
cmd += challenger_params.extra_params
cmd = "mkdir -p {0} && {1}".format(
CHALLENGER_DATA_DIRPATH_ON_SERVICE_CONTAINER, " ".join(cmd)
)

files = {
ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: deployment_output,
"/prestates": prestates_artifact,
}

ports = get_used_ports()
return ServiceConfig(
image=image,
ports=ports,
entrypoint=ENTRYPOINT_ARGS,
cmd=[cmd],
files=files,
private_ip_address_placeholder=ethereum_package_constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
)
1 change: 1 addition & 0 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def get_beacon_config(
"--p2p.listen.ip=0.0.0.0",
"--p2p.listen.tcp={0}".format(BEACON_DISCOVERY_PORT_NUM),
"--p2p.listen.udp={0}".format(BEACON_DISCOVERY_PORT_NUM),
"--safedb.path={0}".format(BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER),
]

sequencer_private_key = util.read_network_config_value(
Expand Down
4 changes: 4 additions & 0 deletions src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def launch_l2(
l2_services_suffix,
l2_args,
deployment_output,
prestates_artifact,
l1_config,
l1_priv_key,
l1_rpc_url,
Expand All @@ -24,6 +25,7 @@ def launch_l2(
):
network_params = l2_args.network_params
batcher_params = l2_args.batcher_params
challenger_params = l2_args.challenger_params
proposer_params = l2_args.proposer_params
mev_params = l2_args.mev_params

Expand All @@ -39,9 +41,11 @@ def launch_l2(
jwt_file,
network_params,
batcher_params,
challenger_params,
proposer_params,
mev_params,
deployment_output,
prestates_artifact,
l1_config,
l2_num,
l2_services_suffix,
Expand Down
20 changes: 20 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ DEFAULT_BATCHER_IMAGES = {
"op-batcher": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:develop",
}

DEFAULT_CHALLENGER_IMAGES = {
"op-challenger": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-challenger:develop",
}

DEFAULT_PROPOSER_IMAGES = {
"op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop",
}
Expand Down Expand Up @@ -108,6 +112,10 @@ def input_parser(plan, input_args):
image=result["batcher_params"]["image"],
extra_params=result["batcher_params"]["extra_params"],
),
challenger_params=struct(
image=result["challenger_params"]["image"],
extra_params=result["challenger_params"]["extra_params"],
),
proposer_params=struct(
image=result["proposer_params"]["image"],
extra_params=result["proposer_params"]["extra_params"],
Expand Down Expand Up @@ -152,6 +160,9 @@ def parse_network_params(plan, input_args):
batcher_params = default_batcher_params()
batcher_params.update(chain.get("batcher_params", {}))

challenger_params = default_challenger_params()
challenger_params.update(chain.get("challenger_params", {}))

proposer_params = default_proposer_params()
proposer_params.update(chain.get("proposer_params", {}))

Expand Down Expand Up @@ -230,6 +241,7 @@ def parse_network_params(plan, input_args):
"participants": participants,
"network_params": network_params,
"batcher_params": batcher_params,
"challenger_params": challenger_params,
"proposer_params": proposer_params,
"mev_params": mev_params,
"additional_services": chain.get(
Expand Down Expand Up @@ -273,6 +285,7 @@ def default_chains():
"participants": [default_participant()],
"network_params": default_network_params(),
"batcher_params": default_batcher_params(),
"challenger_params": default_challenger_params(),
"proposer_params": default_proposer_params(),
"mev_params": default_mev_params(),
"additional_services": DEFAULT_ADDITIONAL_SERVICES,
Expand Down Expand Up @@ -302,6 +315,13 @@ def default_batcher_params():
}


def default_challenger_params():
return {
"image": "",
"extra_params": [],
}


def default_proposer_params():
return {
"image": "",
Expand Down
1 change: 1 addition & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ SUBCATEGORY_PARAMS = {
"fund_dev_accounts",
],
"batcher_params": ["image", "extra_params"],
"challenger_params": ["image", "extra_params"],
"proposer_params": ["image", "extra_params", "game_type", "proposal_interval"],
"mev_params": ["rollup_boost_image", "builder_host", "builder_port"],
}
Expand Down
30 changes: 30 additions & 0 deletions src/participant_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ el_cl_client_launcher = import_module("./el_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_challenger_launcher = import_module(
"./challenger/op-challenger/op_challenger_launcher.star"
)
op_proposer_launcher = import_module("./proposer/op-proposer/op_proposer_launcher.star")
util = import_module("./util.star")

Expand All @@ -12,9 +15,11 @@ def launch_participant_network(
jwt_file,
network_params,
batcher_params,
challenger_params,
proposer_params,
mev_params,
deployment_output,
prestates_artifact,
l1_config_env_vars,
l2_num,
l2_services_suffix,
Expand Down Expand Up @@ -88,6 +93,31 @@ def launch_participant_network(
"state",
".opChainDeployments[{0}].disputeGameFactoryProxyAddress".format(l2_num),
)
challenger_key = util.read_network_config_value(
plan,
deployment_output,
"challenger-{0}".format(network_params.network_id),
".privateKey",
)
op_challenger_image = (
challenger_params.image
if challenger_params.image != ""
else input_parser.DEFAULT_CHALLENGER_IMAGES["op-challenger"]
)
op_challenger_launcher.launch(
plan,
"op-challenger-{0}".format(l2_services_suffix),
op_challenger_image,
all_el_contexts[0],
all_cl_contexts[0],
l1_config_env_vars,
challenger_key,
game_factory_address,
deployment_output,
prestates_artifact,
network_params,
challenger_params,
)

proposer_key = util.read_network_config_value(
plan,
Expand Down
8 changes: 8 additions & 0 deletions static_files/prestates/prestate-proof.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"step": 0,
"pre": "0x03ce1018d75e7f6fbd5e815d64376e1e82a1334456d5a50be0afabeb17a8a421",
"post": "0x0315e881131ef96baffee5184c11c953c7fdfd9285c718cb1ac54a6283c0ea5f",
"state-data": "0x7918ea9554d1b92c840422beadbbd557fa73e66054bc7e06e4c3100367d1e07e000000000000000000000000000000000000000000000000000000000000000000000000000b8e60000b8e640000000000000000050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fffd0000000000000000000",
"proof-data": "0x0802e3940000000000000000000000003c01000b2421617c00200008000000008fb7000023bd00f802e00008000000008fa4000023a500040802e39c00000000e6e13ab33c13b7c5ab8dd2460d69d876b824fabf1a061c1de6b52b5059932274db9f30f7255f6be0c6bb974735e3723b3aa819e698556497dbbced9276dc5711652054894e3720fc284b59fc2cab41b8719ad830df29b1c60f393b52d10b98dcedb7e9ffde946fd94f6b2c10b8501ef0193f796656df23aefe537e9a28ffb3ea1ff0a7b9c78670b358b4a0876b2a64ad9006f281facecfec6f4d19c95f4a9ff1d9ddf4224339581003567680d0425facaa73fc6c558ce7767f7ce7451b6aeb801a931a0f0cb866780afd50d61ecd99f52099cefe1ac83f0f3f59c93ce559dd164dc2bc151618c363f38bbfe60a194bd7f239da7eead37fc9271d9a3fd26be85e3db62c86327a8ac8a238265089d931e8ce786881bfe13017c2765b39830875e7ab2a7aedc8d01896c7f7298f10dc8ea15e7ab41750bc7dd6ababfaa8112667b94ed7d7eb2f10bd66bc811505e4728e327ee428e1d89314cac1b6c6a5056504ed6f90a88d44ed0eed9cc7cf9ffec8a44d2e2047a80a260560a95a1906b8e93fa116d2321217e50c05cc0cf5bd69778766cfc63a79cac154b653e9e54177ac4d063edba23c9e364396c62106276860881d8b417d8c16254b5554da28f1e17355f5322b1acc8bea58f0ee9d21f1ff415cacd3460159067ec583ef505f5c2cf1b847b832e5e82e32a2e92ad0a79a9742c465b1383b0f19547b0c308e0b6a637bd531ed482dabb189dbdf9909c82569c822b07a8ed5110418c133764d43785a8fa75b69f138bc4002ffc97516bad2ebfabe121735495387b5072e67a640b0ca8ccb0114224cfa7c0cf3009790ac96e2f7689df915a0ae88b82e238668aefdb3478ab2ffc1e3dd17153f19fe95d2af10a51a85cf0f09b72ee1d6a118be2be1d35845b9f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd95a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e3774df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef595531c28e98ea6e36fe4ab6cace6caf693027a8539fe6ee29c3deafe1b70ec5b8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
}

0 comments on commit 7a46324

Please sign in to comment.