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: support for public ports #325

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8bd4917
feat: agglayer static port
leovct Oct 21, 2024
ffc3f2e
chore: disable static ports by default and add ci test
leovct Oct 21, 2024
e846bdd
fix: ci
leovct Oct 21, 2024
d0567b9
ci: update job names
leovct Oct 21, 2024
fa2e7d1
chore: rename file
leovct Oct 22, 2024
da84a63
feat: cdk node static port
leovct Oct 22, 2024
3aa3919
chore: nit
leovct Oct 22, 2024
887a493
fix: typos
leovct Oct 22, 2024
5a24713
fix: typo
leovct Oct 22, 2024
dfcfa38
feat: bridge static ports
leovct Oct 22, 2024
30be547
feat: db static port
leovct Oct 22, 2024
0308034
chore: lint
leovct Oct 22, 2024
48d91de
fix: typos
leovct Oct 22, 2024
6f7694d
feat: more static ports
leovct Oct 22, 2024
27e70a6
feat: add ethereum pkg static ports
leovct Oct 22, 2024
8e63948
fix: typo
leovct Oct 22, 2024
fbf2185
fix: eth params
leovct Oct 22, 2024
821e759
fix: eth pkg config
leovct Oct 22, 2024
3b140d2
test
leovct Oct 22, 2024
ab057e2
chore: nit
leovct Oct 22, 2024
178ff6e
test
leovct Oct 22, 2024
54a6a69
fix: typo
leovct Oct 22, 2024
a9e3b45
fix: dac typo
leovct Oct 23, 2024
ff2a04c
chore: update static ports
leovct Oct 23, 2024
3f106b1
feat: add another flag to use default public ports
leovct Oct 23, 2024
0347fd2
chore: update custom public ports
leovct Oct 23, 2024
3765b5f
Merge branch 'main' into feat/static-ports
leovct Oct 23, 2024
c7ff7d3
fix: typo
leovct Oct 23, 2024
7ba4845
chore: clean up ports lib
leovct Oct 23, 2024
d8e9be5
fix: typos
leovct Oct 23, 2024
18b5ad8
fix: default public ports
leovct Oct 23, 2024
b5f0b3c
chore: nit
leovct Oct 23, 2024
428ebb8
Merge branch 'main' into feat/static-ports
leovct Oct 23, 2024
24aeeb0
Merge branch 'main' into feat/static-ports
leovct Oct 24, 2024
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
23 changes: 23 additions & 0 deletions .github/tests/public-ports/custom-public-ports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
args:
public_ports:
# L1 public ports (60000-60999).
l1_el_start_port: 60000
l1_cl_start_port: 60100
l1_vc_start_port: 60200
l1_additional_services_start_port: 60300

# L2/CDK public ports (61000-61999).
agglayer_start_port: 61000
cdk_node_start_port: 61100
zkevm_bridge_service_start_port: 61210
zkevm_bridge_ui_start_port: 61220
reverse_proxy_start_port: 61230
database_start_port: 61300
zkevm_pool_manager_start_port: 61400
zkevm_dac_start_port: 61500

# L2 additional services (62000-62999).
arpeggio_start_port: 62000
blutgang_start_port: 62100
erpc_start_port: 62200
panoptichain_start_port: 62300
2 changes: 2 additions & 0 deletions .github/tests/public-ports/default-public-ports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
args:
use_default_public_ports: true
8 changes: 4 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

- id: set-matrix
# List all yml files in the .github/tests directory, as well as test combinations, except for the additional-services.yml file.
run: echo "matrix=$(ls -R ./.github/tests/combinations/*.yml | grep -v 'additional-services.yml' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
run: echo "matrix=$(ls -R ./.github/tests/combinations/*.yml ./.github/tests/public-ports/*.yml | grep -v 'additional-services.yml' | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT

run-with-args:
needs: list-ymls
Expand Down Expand Up @@ -167,7 +167,7 @@ jobs:
name: ${{ env.ARCHIVE_NAME }}
path: ./dump

additional_services:
additional-services:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -270,7 +270,7 @@ jobs:
name: dump_additional_services_${{ github.run_id }}
path: ./dump

attach_cdks:
attach-second-cdk:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down Expand Up @@ -339,7 +339,7 @@ jobs:
name: dump_attach_ckds_${{ github.run_id }}
path: ./dump

deploy_to_external_l1:
deploy-to-external-l1:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
Expand Down
25 changes: 15 additions & 10 deletions agglayer.star
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
databases_package = import_module("./databases.star")
service_package = import_module("./lib/service.star")
databases = import_module("./databases.star")
ports_package = import_module("./src/package_io/ports.star")


def run(plan, args):
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
db_configs = databases.get_db_configs(
db_configs = databases_package.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
agglayer_config_artifact = create_agglayer_config_artifact(
Expand All @@ -17,18 +18,13 @@ def run(plan, args):
src="/opt/zkevm/agglayer.keystore",
)

(ports, public_ports) = get_agglayer_ports(args)
plan.add_service(
name="agglayer",
config=ServiceConfig(
image=args["agglayer_image"],
ports={
"agglayer": PortSpec(
args["agglayer_port"], application_protocol="http"
),
"prometheus": PortSpec(
args["prometheus_port"], application_protocol="http"
),
},
ports=ports,
public_ports=public_ports,
files={
"/etc/zkevm": Directory(
artifact_names=[
Expand Down Expand Up @@ -76,3 +72,12 @@ def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_con
)
},
)


def get_agglayer_ports(args):
ports = {
"agglayer": PortSpec(args["agglayer_port"], application_protocol="http"),
"prometheus": PortSpec(args["prometheus_port"], application_protocol="http"),
}
public_ports = ports_package.get_public_ports(ports, "agglayer_start_port", args)
return (ports, public_ports)
29 changes: 20 additions & 9 deletions databases.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ports_package = import_module("./src/package_io/ports.star")

# We support both local and remote Postgres databases within our Kurtosis-CDK package
# When 'USE_REMOTE_POSTGRES' is False, service automatically creates all CDK databases locally
# When 'USE_REMOTE_POSTGRES' is True, service is created just as a helper for param injection across pods
Expand Down Expand Up @@ -91,9 +93,10 @@ CDK_ERIGON_DBS = {
DATABASES = CENTRAL_ENV_DBS | PROVER_DB | ZKEVM_NODE_DBS | CDK_ERIGON_DBS


def run(plan, suffix, sequencer_type):
db_configs = get_db_configs(suffix, sequencer_type)
create_postgres_service(plan, db_configs, suffix)
def run(plan, args):
sequencer_type = args["sequencer_type"]
db_configs = get_db_configs(args["deployment_suffix"], sequencer_type)
create_postgres_service(plan, db_configs, args)


def get_db_configs(suffix, sequencer_type):
Expand Down Expand Up @@ -146,10 +149,10 @@ def _pless_suffix(suffix):
return "-pless" + suffix


def create_postgres_service(plan, db_configs, suffix):
def create_postgres_service(plan, db_configs, args):
init_script_tpl = read_file(src="./templates/databases/init.sql")
init_script = plan.render_templates(
name="init.sql" + suffix,
name="init.sql" + args["deployment_suffix"],
config={
"init.sql": struct(
template=init_script_tpl,
Expand All @@ -162,11 +165,11 @@ def create_postgres_service(plan, db_configs, suffix):
},
)

(ports, public_ports) = get_database_ports(args)
postgres_service_cfg = ServiceConfig(
image=POSTGRES_IMAGE,
ports={
"postgres": PortSpec(POSTGRES_PORT, application_protocol="postgresql"),
},
ports=ports,
public_ports=public_ports,
env_vars={
"POSTGRES_DB": POSTGRES_MASTER_DB,
"POSTGRES_USER": POSTGRES_MASTER_USER,
Expand All @@ -177,7 +180,15 @@ def create_postgres_service(plan, db_configs, suffix):
)

plan.add_service(
name=_service_name(suffix),
name=_service_name(args["deployment_suffix"]),
config=postgres_service_cfg,
description="Starting Postgres Service",
)


def get_database_ports(args):
ports = {
"postgres": PortSpec(POSTGRES_PORT, application_protocol="postgresql"),
}
public_ports = ports_package.get_public_ports(ports, "database_start_port", args)
return (ports, public_ports)
23 changes: 23 additions & 0 deletions ethereum.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ethereum_package = import_module(


def run(plan, args):
port_publisher = generate_port_publisher_config(args)
ethereum_package.run(
plan,
{
Expand All @@ -23,5 +24,27 @@ def run(plan, args):
"seconds_per_slot": args["l1_seconds_per_slot"],
},
"additional_services": args["l1_additional_services"],
"port_publisher": port_publisher,
},
)


# Generate ethereum package public ports configuration.
def generate_port_publisher_config(args):
port_mappings = {
"el": "l1_el_start_port",
"cl": "l1_cl_start_port",
"vc": "l1_vc_start_port",
"additional_services": "l1_additional_services_start_port",
}

port_publisher_config = {}
public_port_config = args.get("public_ports", {})
for key, value in port_mappings.items():
public_port_start = public_port_config.get(value, None)
if public_port_start:
port_publisher_config[key] = {
"enabled": True,
"public_port_start": public_port_start,
}
return port_publisher_config
41 changes: 38 additions & 3 deletions input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,31 @@ DEFAULT_PORTS = {
"zkevm_rpc_ws_port": 8133,
}

# By default, we rely on dynamic ports set by Kurtosis.
DEFAULT_PUBLIC_PORTS = {
"public_ports": {
# L1 public ports (50000-50999).
"l1_el_start_port": 50000,
"l1_cl_start_port": 50100,
"l1_vc_start_port": 50200,
"l1_additional_services_start_port": 50300,
# L2/CDK public ports (51000-51999).
"agglayer_start_port": 51000,
"cdk_node_start_port": 51100,
"zkevm_bridge_service_start_port": 51210,
"zkevm_bridge_ui_start_port": 51220,
"reverse_proxy_start_port": 51230,
"database_start_port": 51300,
"zkevm_pool_manager_start_port": 51400,
"zkevm_dac_start_port": 51500,
# L2 additional services (52000-52999).
"arpeggio_start_port": 52000,
"blutgang_start_port": 52100,
"erpc_start_port": 52200,
"panoptichain_start_port": 52300,
}
}

# Addresses and private keys of the different components.
# They have been generated using the following command:
# polycli wallet inspect --mnemonic 'lab code glass agree maid neutral vessel horror deny frequent favorite soft gate galaxy proof vintage once figure diary virtual scissors marble shrug drop' --addresses 9 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "# " roles[NR] "\n\"zkevm_l2_" roles[NR] "_address\": \"" $1 "\","; print "\"zkevm_l2_" roles[NR] "_private_key\": \"0x" $2 "\",\n"}'
Expand Down Expand Up @@ -159,6 +184,8 @@ DEFAULT_ROLLUP_ARGS = {
"erigon_strict_mode": True,
# Set to true to automatically deploy an ERC20 contract on L1 to be used as the gas token on the rollup.
"zkevm_use_gas_token_contract": False,
# Use the default public ports.
"use_default_public_ports": False,
}

DEFAULT_PLESS_ZKEVM_NODE_ARGS = {
Expand Down Expand Up @@ -229,12 +256,20 @@ def parse_args(plan, args):
sequencer_type = args.get("sequencer_type", "")
sequencer_name = get_sequencer_name(sequencer_type)

plan.print(
"DEBUG: " + str(deployment_stages.get("deploy_cdk_erigon_node", False))
) # DEBUG
deploy_cdk_erigon_node = deployment_stages.get("deploy_cdk_erigon_node", False)
l2_rpc_name = get_l2_rpc_name(deploy_cdk_erigon_node)

# Determine public ports.
# By default, we rely on dynamic ports set by Kurtosis.
if args.get("use_default_public_ports", False):
plan.print("Using default public ports.")
args = args | DEFAULT_PUBLIC_PORTS
else:
public_ports = args.get("public_ports", {})
if public_ports:
plan.print("Using custom public ports.")
args = args | {"public_ports": public_ports}

# Remove deployment stages from the args struct.
# This prevents updating already deployed services when updating the deployment stages.
if "deployment_stages" in args:
Expand Down
20 changes: 14 additions & 6 deletions lib/cdk_node.star
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
data_availability_package = import_module("./data_availability.star")
ports_package = import_module("../src/package_io/ports.star")

NODE_COMPONENTS = struct(
sequence_sender="sequence-sender",
Expand All @@ -13,14 +14,11 @@ def create_cdk_node_service_config(
keystore_artifact,
):
cdk_node_name = "cdk-node" + args["deployment_suffix"]

(ports, public_ports) = get_cdk_node_ports(args)
cdk_node_service_config = ServiceConfig(
image=args["cdk_node_image"],
ports={
"aggregator": PortSpec(
args["zkevm_aggregator_port"], application_protocol="grpc"
),
},
ports=ports,
public_ports=public_ports,
files={
"/etc/cdk": Directory(
artifact_names=[
Expand Down Expand Up @@ -49,3 +47,13 @@ def create_cdk_node_service_config(
)

return {cdk_node_name: cdk_node_service_config}


def get_cdk_node_ports(args):
ports = {
"aggregator": PortSpec(
args["zkevm_aggregator_port"], application_protocol="grpc"
),
}
public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args)
return (ports, public_ports)
Loading
Loading