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 support for alt-da with da-server #69

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "optimism"]
path = optimism
url = [email protected]:ethereum-optimism/optimism.git
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,17 @@ optimism_package:
# Defaults to []
# Available services:
# - blockscout
# - da_server
additional_services: []

# Configuration place for da-server - https://github.com/ethereum-optimism/optimism/tree/develop/op-alt-da
da_server_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest
build_image: true
# A list of optional extra params that will be passed to the da-server container for modifying its behaviour
da_server_extra_args: []
generic_commitment: false

# 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
5 changes: 5 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ 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
# TODO: Not sure how to deal with these da_server_params,
# basically when/how to turn on altda mode.
# If any one chain uses altda??
da_server_params = optimism_args_with_right_defaults.chains[0].da_server_params

# Deploy the L1
plan.print("Deploying a local L1")
Expand Down Expand Up @@ -55,6 +59,7 @@ def run(plan, args):
l1_priv_key,
l1_config_env_vars,
optimism_args_with_right_defaults,
da_server_params,
)

for chain in optimism_args_with_right_defaults.chains:
Expand Down
9 changes: 8 additions & 1 deletion network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ optimism_package:
batcher_params:
image: ""
extra_params: []
additional_services: []
da_server_params:
image: us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest
build_image: false
# A list of optional extra params that will be passed to the da-server container for modifying its behaviour
da_server_extra_args: []
generic_commitment: false
additional_services:
- da_server
op_contract_deployer_params:
image: mslipper/op-deployer:latest
artifacts_url: https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-4accd01f0c35c26f24d2aa71aba898dd7e5085a2ce5daadc8a84b10caf113409.tar.gz
Expand Down
1 change: 1 addition & 0 deletions optimism
Submodule optimism added at 90700b
98 changes: 98 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,98 @@
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"
)

# The dirpath of the data directory on the da-server container
# note that we use /home which is available but not persistent
# because we aren't mounting an external kurtosis file
# this means that the data is lost when the container is deleted
DATA_DIRPATH_ON_DA_SERVER_CONTAINER = "/home"

# 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(
plan,
service_name,
image,
da_server_extra_args,
generic_commitment,
):

config = get_da_server_config(
plan,
service_name,
image,
da_server_extra_args,
generic_commitment,
)

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)
return new_da_server_context(
http_url=http_url,
generic_commitment=generic_commitment,
)


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

cmd = [
"da-server",
"--file.path=" + DATA_DIRPATH_ON_DA_SERVER_CONTAINER,
"--addr=0.0.0.0",
"--port=3100",
"--log.level=debug",
"--generic-commitment=" + str(generic_commitment),
Copy link
Member

Choose a reason for hiding this comment

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

da_server image complains on this at startup: Incorrect Usage: flag provided but not defined: -generic-commitment

I'd image the latest image found here us-docker.pkg.dev/oplabs-tools-artifacts/images/da-server:latest is stale and missing the flag?

Copy link
Author

Choose a reason for hiding this comment

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

Yes confirmed that the latest image is missing the flag. And the more recent one v0.1.0-rc.1 from June gives me this error when I try to run on my mac: rosetta error: failed to open elf at /lib/ld-musl-x86_64.so.1

Copy link
Author

Choose a reason for hiding this comment

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

WIth the latest kurtosis 1.3 release I was able to add optimism repo as a submodule and build the da-server image locally: e709d7c

]

if len(da_server_extra_args) > 0:
cmd.extend([param for param in da_server_extra_args])

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="",
generic_commitment=True,
)

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

Expand All @@ -53,6 +54,7 @@ def launch(
l1_config_env_vars,
gs_batcher_private_key,
batcher_params,
da_server_context,
)

batcher_service = plan.add_service(service_name, config)
Expand All @@ -74,6 +76,7 @@ def get_batcher_config(
l1_config_env_vars,
gs_batcher_private_key,
batcher_params,
da_server_context,
):
cmd = [
"op-batcher",
Expand All @@ -90,7 +93,10 @@ 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",
"--altda.enabled=" + str(da_server_context.enabled),
parithosh marked this conversation as resolved.
Show resolved Hide resolved
"--altda.da-server=" + da_server_context.http_url,
"--altda.da-service=" + str(da_server_context.generic_commitment),
"--data-availability-type=" + "calldata" if da_server_context.enabled else "blobs",
]

cmd += batcher_params.extra_params
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 @@ -73,6 +73,7 @@ def launch(
existing_cl_clients,
l1_config_env_vars,
sequencer_enabled,
da_server_context,
):
# beacon_node_identity_recipe = PostHttpRequestRecipe(
# endpoint="/",
Expand Down Expand Up @@ -103,6 +104,7 @@ def launch(
existing_cl_clients,
l1_config_env_vars,
sequencer_enabled,
da_server_context,
)

beacon_service = plan.add_service(service_name, config)
Expand Down Expand Up @@ -143,6 +145,7 @@ def get_beacon_config(
existing_cl_clients,
l1_config_env_vars,
sequencer_enabled,
da_server_context,
):
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
el_context.ip_addr,
Expand All @@ -169,6 +172,9 @@ def get_beacon_config(
"--network="
+ ethereum_package_constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS
+ "/rollup-{0}.json".format(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),
]

sequencer_private_key = util.read_network_config_value(
Expand Down
7 changes: 7 additions & 0 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def launch(
existing_cl_clients,
l1_config_env_vars,
sequencer_enabled,
da_server_context,
):
beacon_node_identity_recipe = PostHttpRequestRecipe(
endpoint="/",
Expand Down Expand Up @@ -104,6 +105,7 @@ def launch(
l1_config_env_vars,
beacon_node_identity_recipe,
sequencer_enabled,
da_server_context,
)

beacon_service = plan.add_service(service_name, config)
Expand Down Expand Up @@ -148,6 +150,7 @@ def get_beacon_config(
l1_config_env_vars,
beacon_node_identity_recipe,
sequencer_enabled,
da_server_context,
):
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
el_context.ip_addr,
Expand Down Expand Up @@ -178,7 +181,11 @@ 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),
"--altda.enabled=" + str(da_server_context.enabled),
Copy link
Member

Choose a reason for hiding this comment

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

Similar check would be needed here instead of adding it by default to all nodes irrespective of if the da server is present

Copy link
Author

Choose a reason for hiding this comment

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

see my other comment. enabled is set to false by default, so its safe to add by default (and is what the other docker-compose devnet was doing).

"--altda.da-service=" + str(da_server_context.generic_commitment),
"--altda.da-server=" + da_server_context.http_url,
]
plan.print(da_server_context.generic_commitment)

sequencer_private_key = util.read_network_config_value(
plan,
Expand Down
7 changes: 6 additions & 1 deletion src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def deploy_contracts(
priv_key,
l1_config_env_vars,
optimism_args,
da_server_params, # for alt-da
):
l2_chain_ids = ",".join(
[str(chain.network_params.network_id) for chain in optimism_args.chains]
Expand All @@ -23,7 +24,11 @@ def deploy_contracts(
name="op-deployer-init",
description="Initialize L2 contract deployments",
image=optimism_args.op_contract_deployer_params.image,
env_vars=l1_config_env_vars,
env_vars=l1_config_env_vars
| {
"USE_ALTDA": "true" if da_server_params.enabled else "false",
"DA_COMMITMENT_TYPE": "GenericCommitment" if da_server_params.generic_commitment else "KeccakCommitment"
},
store=[
StoreSpec(
src="/network-data",
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 @@ -30,6 +30,7 @@ def launch(
global_node_selectors,
global_tolerations,
persistent,
da_server_context,
):
el_launchers = {
"op-geth": {
Expand Down Expand Up @@ -177,6 +178,7 @@ def launch(
all_cl_contexts,
l1_config_env_vars,
sequencer_enabled,
da_server_context,
)

sequencer_enabled = False
Expand Down
28 changes: 28 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")
ethereum_package_static_files = import_module(
Expand Down Expand Up @@ -30,6 +31,32 @@ def launch_l2(
name="op_jwt_file{0}".format(l2_services_suffix),
)

# we need to launch da-server before launching the participant network
# because op-node and op-batcher 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
if l2_args.da_server_params.build_image:
plan.print("Building da-server image")
da_server_image = ImageBuildSpec(
image_name=l2_args.da_server_params.image,
# TODO: this doesn't work... because can't point to a dir outside of the kurtosis package
# also can't install optimism monorepo as a submodule because that makes the kurtosis package > 100MB, which is not allowed.
# Not sure how to fix this... detailed problem in https://github.com/ethpandaops/optimism-package/issues/72
build_context_dir="/optimism/ops/docker/op-stack-go",
target_stage="da-server-target",
)
plan.print("Successfully built da-server image")
plan.print("Launching da-server")
da_server_context = da_server_launcher.launch(
plan,
"da-server{0}".format(l2_services_suffix),
da_server_image,
l2_args.da_server_params.da_server_extra_args,
l2_args.da_server_params.generic_commitment,
)
plan.print("Successfully launched da-server")

all_l2_participants = participant_network.launch_participant_network(
plan,
l2_args.participants,
Expand All @@ -43,6 +70,7 @@ def launch_l2(
global_node_selectors,
global_tolerations,
persistent,
da_server_context,
)

all_el_contexts = []
Expand Down
Loading