From 0ad5f4f0e35dd25738fae4337391a31744bd3b3f Mon Sep 17 00:00:00 2001 From: Matthew Sevey <15232757+MSevey@users.noreply.github.com> Date: Fri, 6 Sep 2024 11:24:45 -0400 Subject: [PATCH] feat: add da selection --- main.star | 89 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 16 deletions(-) diff --git a/main.star b/main.star index 124b564..d87cf48 100644 --- a/main.star +++ b/main.star @@ -2,30 +2,57 @@ # # NOTE: currently this is only connecting to a local DA node -da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.0") +# DA Types +celestia = "celestia" +avail = "avail" +local_da = "local-da" -def run(plan): - ########## - # DA - ########## - da_address = da_node.run( - plan, - ) - plan.print("connecting to da layer via {0}".format(da_address)) +def run(plan, da=local_da): + # Define vars + da_address = None + da_auth_token = None + # Start up the DA node + plan.print("Starting up GM rollup with DA: {0}".format(da)) + if da == local_da: + plan.print("Using local-da") + da_node = import_module("github.com/rollkit/local-da/main.star@v0.3.1") + da_address = da_node.run( + plan, + ) + elif da == celestia: + plan.print("Using celestia for DA") + da_node = import_module("github.com/MSevey/celestia-da-node-package/main.star") + da_address, da_auth_token = da_node.run( + plan, + ) + else: + fail("Unknown DA: {0}".format(da)) + + plan.print("connecting to da layer via {0}".format(da_address)) ##### # GM ##### plan.print("Adding GM service") plan.print("NOTE: This can take a few minutes to start up...") - gm_start_cmd = [ - "rollkit", - "start", - "--rollkit.aggregator", - "--rollkit.da_address {0}".format(da_address), - ] + gm_start_cmd = [] + if da == celestia: + gm_start_cmd = rollkitCMD( + da, + da_auth_token=da_auth_token, + da_namespace="00000000000000000000000000000000000000000008e5f679bf7116cb", # Make an input, people can set this to whatever they want + da_start_height=2535482, # Make an input, people can pull this from a block explorer + ) + elif da == avail: + fail("Avail DA is not yet supported") + elif da == local_da: + gm_start_cmd = rollkitCMD(da, da_address) + else: + fail("Unknown DA: {0}".format(da)) + + plan.print("GM start command: {0}".format(gm_start_cmd)) gm_port_number = 26657 gm_port_spec = PortSpec( number=gm_port_number, transport_protocol="TCP", application_protocol="http" @@ -41,7 +68,11 @@ def run(plan): name="gm", config=ServiceConfig( # Using rollkit version v0.13.5 - image="ghcr.io/rollkit/gm:05bd40e", + # image="ghcr.io/rollkit/gm:05bd40e", + image=ImageBuildSpec( + image_name="gm_temp", + build_context_dir=".", + ), cmd=["/bin/sh", "-c", " ".join(gm_start_cmd)], ports=gm_ports, public_ports=gm_ports, @@ -82,3 +113,29 @@ def run(plan): public_ports=frontend_ports, ), ) + + +def rollkitCMD( + da, da_address=None, da_auth_token=None, da_namespace=None, da_start_height=None +): + if da == celestia: + return [ + "rollkit", + "start", + "--rollkit.aggregator", + "--rollkit.da_auth_token {0}".format(da_auth_token), + "--rollkit.da_namespace {0}".format(da_namespace), + "--rollkit.da_start_height {0}".format(da_start_height), + "--minimum-gas-price=0.025stake", + ] + elif da == avail: + fail("Avail DA is not yet supported") + elif da == local_da: + return [ + "rollkit", + "start", + "--rollkit.aggregator", + "--rollkit.da_address {0}".format(da_address), + ] + else: + fail("Unknown DA: {0}".format(da))