Skip to content

Commit

Permalink
feat: add alt-da support
Browse files Browse the repository at this point in the history
  • Loading branch information
samlaf committed Feb 4, 2025
1 parent c32a626 commit ddea15f
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 3 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,29 @@ optimism_package:

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

# AltDA Deploy Configuration, which is passed to op-deployer.
#
# For simplicity we currently enforce chains to all be altda or all rollups.
# Adding a single altda chain to a cluster essentially makes all chains have altda levels of security.
#
# To setup an altda cluster, make sure to
# 1. Set altda_deploy_config.use_altda to true (and da_commitment_type to KeccakCommitment, see TODO below)
# 2. For each chain,
# - Add "da_server" to the additional_services list if it should use alt-da
# - For altda chains, set da_server_params to use an image and cmd of your choice (one could use da-server, another eigenda-proxy, another celestia proxy, etc). If unset, op's default da-server image will be used.
altda_deploy_config:
use_altda: false
# TODO: Is this field redundant? Afaiu setting it to GenericCommitment will not deploy the
# DAChallengeContract, and hence is equivalent to setting use_altda to false.
# Furthermore, altda rollups using generic commitments might anyways need to support failing over
# to keccak commitments if the altda layer is down.
da_commitment_type: KeccakCommitment
da_challenge_window: 100
da_resolve_window: 100
da_bond_size: 0
da_resolver_refund_percentage: 0

# An array of L2 networks to run
chains:
# Specification of the optimism-participants in the network
Expand Down Expand Up @@ -391,8 +414,25 @@ optimism_package:
# Available services:
# - blockscout
# - rollup-boost
# - da_server
additional_services: []

# Configuration for da-server - https://specs.optimism.io/experimental/alt-da.html#da-server
# TODO: each op-node and op-batcher should potentially have their own da-server, instead of sharing one like we currently do. For eg batcher needs to write via its da-server, whereas op-nodes don't.
da_server_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest
# Command to pass to the container.
# This is kept maximally generic to allow for any possible configuration, given that different
# da layer da-servers might have completely different flags.
# The below arguments are also the default, so can be omitted, and will work as long as the image
# is the da-server above (which is also the default, so can also be omitted).
cmd:
- "da-server"
- "--file.path=/home"
- "--addr=0.0.0.0"
- "--port=3100"
- "--log.level=debug"

# L2 contract deployer configuration - used for all L2 networks
# The docker image that should be used for the L2 contract deployer
op_contract_deployer_params:
Expand Down
2 changes: 2 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def run(plan, args):
global_node_selectors = optimism_args_with_right_defaults.global_node_selectors
global_log_level = optimism_args_with_right_defaults.global_log_level
persistent = optimism_args_with_right_defaults.persistent
altda_deploy_config = optimism_args_with_right_defaults.altda_deploy_config

observability_params = optimism_args_with_right_defaults.observability
interop_params = optimism_args_with_right_defaults.interop
Expand Down Expand Up @@ -94,6 +95,7 @@ def run(plan, args):
l1_config_env_vars,
optimism_args_with_right_defaults,
l1_network,
altda_deploy_config,
)

jwt_file = plan.upload_files(
Expand Down
19 changes: 18 additions & 1 deletion network_params.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
optimism_package:
altda_deploy_config:
use_altda: true
da_commitment_type: KeccakCommitment
da_challenge_window: 100
da_resolve_window: 100
da_bond_size: 0
da_resolver_refund_percentage: 0
chains:
- participants:
- el_type: op-geth
Expand Down Expand Up @@ -39,7 +46,17 @@ optimism_package:
mev_params:
builder_host: ""
builder_port: ""
additional_services: []
da_server_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest
# A list of optional extra params that will be passed to the da-server container for modifying its behaviour
cmd:
- "da-server"
- "--file.path=/home"
- "--addr=0.0.0.0"
- "--port=3100"
- "--log.level=debug"
additional_services:
- da_server
op_contract_deployer_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-deployer:v0.0.11
l1_artifacts_locator: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-c193a1863182092bc6cb723e523e8313a0f4b6e9c9636513927f1db74c047c15.tar.gz
Expand Down
76 changes: 76 additions & 0 deletions src/alt-da/da-server/da_server_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
shared_utils = import_module(
"github.com/ethpandaops/ethereum-package/src/shared_utils/shared_utils.star"
)
constants = import_module(
"github.com/ethpandaops/ethereum-package/src/package_io/constants.star"
)

# Port IDs
DA_SERVER_HTTP_PORT_ID = "http"

# Port nums
DA_SERVER_HTTP_PORT_NUM = 3100


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


def launch_da_server(
plan,
service_name,
image,
cmd,
):
config = get_da_server_config(
plan,
service_name,
image,
cmd,
)

da_server_service = plan.add_service(service_name, config)

http_url = "http://{0}:{1}".format(
da_server_service.ip_address, DA_SERVER_HTTP_PORT_NUM
)
# da_server_context is passed as argument to op-batcher and op-node(s)
return new_da_server_context(
http_url=http_url,
)


def get_da_server_config(
plan,
service_name,
image,
cmd,
):
ports = get_used_ports()

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


def disabled_da_server_context():
return new_da_server_context(
http_url="",
)


def new_da_server_context(http_url):
return struct(
enabled=http_url != "",
http_url=http_url,
)
13 changes: 12 additions & 1 deletion src/batcher/op-batcher/op_batcher_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def launch(
gs_batcher_private_key,
batcher_params,
observability_helper,
da_server_context,
):
batcher_service_name = "{0}".format(service_name)

Expand All @@ -58,6 +59,7 @@ def launch(
gs_batcher_private_key,
batcher_params,
observability_helper,
da_server_context,
)

batcher_service = plan.add_service(service_name, config)
Expand All @@ -82,6 +84,7 @@ def get_batcher_config(
gs_batcher_private_key,
batcher_params,
observability_helper,
da_server_context,
):
ports = dict(get_used_ports())

Expand All @@ -100,7 +103,15 @@ def get_batcher_config(
"--max-channel-duration=1",
"--l1-eth-rpc=" + l1_config_env_vars["L1_RPC_URL"],
"--private-key=" + gs_batcher_private_key,
"--data-availability-type=blobs",
# da commitments currently have to be sent as calldata to the batcher inbox
"--data-availability-type=" + "calldata"
if da_server_context.enabled
else "blobs",
"--altda.enabled=" + str(da_server_context.enabled),
"--altda.da-server=" + da_server_context.http_url,
# This flag is very badly named, but is needed in order to let the da-server compute the commitment.
# This leads to sending POST requests to /put instead of /put/<keccak256(data)>
"--altda.da-service",
]

# apply customizations
Expand Down
6 changes: 6 additions & 0 deletions src/cl/hildr/hildr_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def launch(
sequencer_enabled,
observability_helper,
interop_params,
da_server_context,
):
# beacon_node_identity_recipe = PostHttpRequestRecipe(
# endpoint="/",
Expand Down Expand Up @@ -109,6 +110,7 @@ def launch(
l1_config_env_vars,
sequencer_enabled,
observability_helper,
da_server_context,
)

beacon_service = plan.add_service(service_name, config)
Expand Down Expand Up @@ -155,6 +157,7 @@ def get_beacon_config(
l1_config_env_vars,
sequencer_enabled,
observability_helper,
da_server_context,
):
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
el_context.ip_addr,
Expand Down Expand Up @@ -183,6 +186,9 @@ def get_beacon_config(
ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS,
launcher.network_params.network_id,
),
# TODO: support altda flags once they are implemented.
# See https://github.com/optimism-java/hildr/issues/134
# eg: "--altda.enabled=" + str(da_server_context.enabled),
]

# configure files
Expand Down
5 changes: 5 additions & 0 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def launch(
sequencer_enabled,
observability_helper,
interop_params,
da_server_context,
):
beacon_node_identity_recipe = PostHttpRequestRecipe(
endpoint="/",
Expand Down Expand Up @@ -110,6 +111,7 @@ def launch(
sequencer_enabled,
observability_helper,
interop_params,
da_server_context,
)

beacon_service = plan.add_service(service_name, config)
Expand Down Expand Up @@ -158,6 +160,7 @@ def get_beacon_config(
sequencer_enabled,
observability_helper,
interop_params,
da_server_context,
):
ports = dict(get_used_ports(BEACON_DISCOVERY_PORT_NUM))

Expand Down Expand Up @@ -190,6 +193,8 @@ def get_beacon_config(
"--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),
"--altda.enabled=" + str(da_server_context.enabled),
"--altda.da-server=" + da_server_context.http_url,
]

# configure files
Expand Down
35 changes: 34 additions & 1 deletion src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ CANNED_VALUES = (
)


def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_network):
def deploy_contracts(
plan, priv_key, l1_config_env_vars, optimism_args, l1_network, altda_args
):
l2_chain_ids_list = [
str(chain.network_params.network_id) for chain in optimism_args.chains
]
Expand Down Expand Up @@ -201,6 +203,37 @@ def deploy_contracts(plan, priv_key, l1_config_env_vars, optimism_args, l1_netwo
address_update(
chain_key(i, "roles.unsafeBlockSigner"), "sequencer", chain_id
),
# altda deploy config
(
"bool",
chain_key(i, "dangerousAltDAConfig.useAltDA"),
altda_args.use_altda,
),
(
"string",
chain_key(i, "dangerousAltDAConfig.daCommitmentType"),
altda_args.da_commitment_type,
),
(
"int",
chain_key(i, "dangerousAltDAConfig.daChallengeWindow"),
altda_args.da_challenge_window,
),
(
"int",
chain_key(i, "dangerousAltDAConfig.daResolveWindow"),
altda_args.da_resolve_window,
),
(
"int",
chain_key(i, "dangerousAltDAConfig.daBondSize"),
altda_args.da_bond_size,
),
(
"int",
chain_key(i, "dangerousAltDAConfig.daResolverRefundPercentage"),
altda_args.da_resolver_refund_percentage,
),
]
)
intent_updates.extend([(t, chain_key(i, k), v) for t, k, v in CANNED_VALUES])
Expand Down
2 changes: 2 additions & 0 deletions src/el_cl_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def launch(
additional_services,
observability_helper,
interop_params,
da_server_context,
):
el_launchers = {
"op-geth": {
Expand Down Expand Up @@ -336,6 +337,7 @@ def launch(
sequencer_enabled,
observability_helper,
interop_params,
da_server_context,
)

for metrics_info in [x for x in cl_context.cl_nodes_metrics_info if x != None]:
Expand Down
16 changes: 16 additions & 0 deletions src/l2.star
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
participant_network = import_module("./participant_network.star")
blockscout = import_module("./blockscout/blockscout_launcher.star")
da_server_launcher = import_module("./alt-da/da-server/da_server_launcher.star")
contract_deployer = import_module("./contracts/contract_deployer.star")
input_parser = import_module("./package_io/input_parser.star")
util = import_module("./util.star")
Expand Down Expand Up @@ -30,6 +31,20 @@ def launch_l2(

plan.print("Deploying L2 with name {0}".format(network_params.name))

# we need to launch da-server before launching the participant network
# because op-batcher and op-node(s) need to know the da-server url, if present
da_server_context = da_server_launcher.disabled_da_server_context()
if "da_server" in l2_args.additional_services:
da_server_image = l2_args.da_server_params.image
plan.print("Launching da-server")
da_server_context = da_server_launcher.launch_da_server(
plan,
"da-server-{0}".format(l2_services_suffix),
da_server_image,
l2_args.da_server_params.cmd,
)
plan.print("Successfully launched da-server")

all_l2_participants = participant_network.launch_participant_network(
plan,
l2_args.participants,
Expand All @@ -50,6 +65,7 @@ def launch_l2(
l2_args.additional_services,
observability_helper,
interop_params,
da_server_context,
)

all_el_contexts = []
Expand Down
Loading

0 comments on commit ddea15f

Please sign in to comment.