Skip to content

Commit

Permalink
feat(el): WIP: Add static port support for el clients
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiWo committed Jun 24, 2024
1 parent cf0092a commit 6d8b560
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 310 deletions.
68 changes: 25 additions & 43 deletions src/el/besu/besu_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -21,40 +21,8 @@ EXECUTION_MAX_CPU = 1000
EXECUTION_MIN_MEMORY = 512
EXECUTION_MAX_MEMORY = 2048

# Port IDs
RPC_PORT_ID = "rpc"
WS_PORT_ID = "ws"
TCP_DISCOVERY_PORT_ID = "tcp-discovery"
UDP_DISCOVERY_PORT_ID = "udp-discovery"
ENGINE_HTTP_RPC_PORT_ID = "engine-rpc"
METRICS_PORT_ID = "metrics"
JAVA_OPTS = {"JAVA_OPTS": "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"}


def get_used_ports(discovery_port=DISCOVERY_PORT_NUM):
used_ports = {
RPC_PORT_ID: shared_utils.new_port_spec(
RPC_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
WS_PORT_ID: shared_utils.new_port_spec(WS_PORT_NUM, shared_utils.TCP_PROTOCOL),
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
ENGINE_HTTP_RPC_PORT_ID: shared_utils.new_port_spec(
ENGINE_HTTP_RPC_PORT_NUM, shared_utils.TCP_PROTOCOL
),
METRICS_PORT_ID: shared_utils.new_port_spec(
METRICS_PORT_NUM, shared_utils.TCP_PROTOCOL
),
}
return used_ports


ENTRYPOINT_ARGS = ["sh", "-c"]

VERBOSITY_LEVELS = {
Expand Down Expand Up @@ -86,6 +54,7 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
log_level = input_parser.get_client_log_level_or_default(
participant_log_level, global_log_level, VERBOSITY_LEVELS
Expand Down Expand Up @@ -136,11 +105,12 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
)

service = plan.add_service(service_name, config)

enode = el_admin_node_info.get_enode_for_node(plan, service_name, RPC_PORT_ID)
enode = el_admin_node_info.get_enode_for_node(plan, service_name, constants.RPC_PORT_ID)

metrics_url = "{0}:{1}".format(service.ip_address, METRICS_PORT_NUM)
besu_metrics_info = node_metrics.new_node_metrics_info(
Expand Down Expand Up @@ -184,20 +154,32 @@ def get_config(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
public_ports = {}
discovery_port = DISCOVERY_PORT_NUM
if port_publisher.public_port_start:
discovery_port = port_publisher.el_start + len(existing_el_clients)
public_ports = {
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
if port_publisher.el_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component("el", port_publisher, participant_index)
public_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.UDP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.RPC_PORT_ID: public_ports_for_component[1],
constants.WS_RPC_PORT_ID: public_ports_for_component[2],
constants.ENGINE_RPC_PORT_ID: public_ports_for_component[3],
constants.METRICS_PORT_ID: public_ports_for_component[4]
}
used_ports = get_used_ports(discovery_port)
public_ports = shared_utils.get_port_specs(public_port_assignments)
discovery_port = public_ports_for_component[0]

used_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: discovery_port,
constants.UDP_DISCOVERY_PORT_ID: discovery_port,
constants.RPC_PORT_ID: RPC_PORT_NUM,
constants.WS_RPC_PORT_ID: WS_PORT_NUM,
constants.ENGINE_RPC_PORT_ID: ENGINE_HTTP_RPC_PORT_NUM,
constants.METRICS_PORT_ID: METRICS_PORT_NUM
}
used_ports = shared_utils.get_port_specs(used_port_assignments)

cmd = [
"besu",
Expand Down
65 changes: 23 additions & 42 deletions src/el/erigon/erigon_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,6 @@ METRICS_PORT_NUM = 9001
EXECUTION_MIN_CPU = 100
EXECUTION_MIN_MEMORY = 512

# Port IDs
WS_RPC_PORT_ID = "ws-rpc"
TCP_DISCOVERY_PORT_ID = "tcp-discovery"
UDP_DISCOVERY_PORT_ID = "udp-discovery"
ENGINE_RPC_PORT_ID = "engine-rpc"
METRICS_PORT_ID = "metrics"


def get_used_ports(discovery_port=DISCOVERY_PORT_NUM):
used_ports = {
WS_RPC_PORT_ID: shared_utils.new_port_spec(
WS_RPC_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
ENGINE_RPC_PORT_ID: shared_utils.new_port_spec(
ENGINE_RPC_PORT_NUM, shared_utils.TCP_PROTOCOL
),
METRICS_PORT_ID: shared_utils.new_port_spec(
METRICS_PORT_NUM, shared_utils.TCP_PROTOCOL
),
}
return used_ports


ENTRYPOINT_ARGS = ["sh", "-c"]

VERBOSITY_LEVELS = {
Expand Down Expand Up @@ -82,6 +51,7 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
log_level = input_parser.get_client_log_level_or_default(
participant_log_level, global_log_level, VERBOSITY_LEVELS
Expand Down Expand Up @@ -134,12 +104,13 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
)

service = plan.add_service(service_name, config)

enode, enr = el_admin_node_info.get_enode_enr_for_node(
plan, service_name, WS_RPC_PORT_ID
plan, service_name, constants.WS_RPC_PORT_ID
)

metrics_url = "{0}:{1}".format(service.ip_address, METRICS_PORT_NUM)
Expand Down Expand Up @@ -187,6 +158,7 @@ def get_config(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
init_datadir_cmd_str = "erigon init --datadir={0} {1}".format(
EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER,
Expand All @@ -195,17 +167,26 @@ def get_config(

public_ports = {}
discovery_port = DISCOVERY_PORT_NUM
if port_publisher.public_port_start:
discovery_port = port_publisher.el_start + len(existing_el_clients)
public_ports = {
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
if port_publisher.el_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component("el", port_publisher, participant_index)
public_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.UDP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.WS_RPC_PORT_ID: public_ports_for_component[1],
constants.ENGINE_RPC_PORT_ID: public_ports_for_component[2],
constants.METRICS_PORT_ID: public_ports_for_component[3]
}
used_ports = get_used_ports(discovery_port)
public_ports = shared_utils.get_port_specs(public_port_assignments)
discovery_port = public_ports_for_component[0]

used_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: discovery_port,
constants.UDP_DISCOVERY_PORT_ID: discovery_port,
constants.WS_RPC_PORT_ID: WS_RPC_PORT_NUM,
constants.ENGINE_RPC_PORT_ID: ENGINE_RPC_PORT_NUM,
constants.METRICS_PORT_ID: METRICS_PORT_NUM
}
used_ports = shared_utils.get_port_specs(used_port_assignments)

cmd = [
"erigon",
Expand Down
70 changes: 25 additions & 45 deletions src/el/ethereumjs/ethereumjs_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,11 @@ METRICS_PORT_NUM = 9001
EXECUTION_MIN_CPU = 100
EXECUTION_MIN_MEMORY = 256

# Port IDs
RPC_PORT_ID = "rpc"
WS_PORT_ID = "ws"
TCP_DISCOVERY_PORT_ID = "tcp-discovery"
UDP_DISCOVERY_PORT_ID = "udp-discovery"
ENGINE_RPC_PORT_ID = "engine-rpc"
WS_PORT_ENGINE_ID = "ws-engine"
METRICS_PORT_ID = "metrics"
METRICS_PATH = "/metrics"

# The dirpath of the execution data directory on the client container
EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER = "/data/ethereumjs/execution-data"


def get_used_ports(discovery_port=DISCOVERY_PORT_NUM):
used_ports = {
RPC_PORT_ID: shared_utils.new_port_spec(
RPC_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
WS_PORT_ID: shared_utils.new_port_spec(WS_PORT_NUM, shared_utils.TCP_PROTOCOL),
WS_PORT_ENGINE_ID: shared_utils.new_port_spec(
WS_PORT_ENGINE_NUM, shared_utils.TCP_PROTOCOL
),
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
ENGINE_RPC_PORT_ID: shared_utils.new_port_spec(
ENGINE_RPC_PORT_NUM, shared_utils.TCP_PROTOCOL
),
# METRICS_PORT_ID: shared_utils.new_port_spec(METRICS_PORT_NUM, shared_utils.TCP_PROTOCOL)
}
return used_ports


ENTRYPOINT_ARGS = []

VERBOSITY_LEVELS = {
Expand Down Expand Up @@ -87,6 +53,7 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
log_level = input_parser.get_client_log_level_or_default(
participant_log_level, global_log_level, VERBOSITY_LEVELS
Expand Down Expand Up @@ -137,11 +104,12 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
)

service = plan.add_service(service_name, config)

enode = el_admin_node_info.get_enode_for_node(plan, service_name, RPC_PORT_ID)
enode = el_admin_node_info.get_enode_for_node(plan, service_name, constants.RPC_PORT_ID)

# TODO: Passing empty string for metrics_url for now https://github.com/ethpandaops/ethereum-package/issues/127
# metrics_url = "http://{0}:{1}".format(service.ip_address, METRICS_PORT_NUM)
Expand Down Expand Up @@ -185,20 +153,32 @@ def get_config(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
public_ports = {}
discovery_port = DISCOVERY_PORT_NUM
if port_publisher.public_port_start:
discovery_port = port_publisher.el_start + len(existing_el_clients)
public_ports = {
TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
if port_publisher.el_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component("el", port_publisher, participant_index)
public_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.UDP_DISCOVERY_PORT_ID: public_ports_for_component[0],
constants.RPC_PORT_ID: public_ports_for_component[1],
constants.WS_RPC_PORT_ID: public_ports_for_component[2],
constants.ENGINE_RPC_PORT_ID: public_ports_for_component[3],
constants.ENGINE_WS_PORT_ID: public_ports_for_component[4]
}
used_ports = get_used_ports(discovery_port)
public_ports = shared_utils.get_port_specs(public_port_assignments)
discovery_port = public_ports_for_component[0]

used_port_assignments = {
constants.TCP_DISCOVERY_PORT_ID: discovery_port,
constants.UDP_DISCOVERY_PORT_ID: discovery_port,
constants.RPC_PORT_ID: RPC_PORT_NUM,
constants.WS_RPC_PORT_ID: WS_PORT_NUM,
constants.ENGINE_RPC_PORT_ID: ENGINE_RPC_PORT_NUM,
constants.ENGINE_WS_PORT_ID: WS_PORT_ENGINE_NUM
}
used_ports = shared_utils.get_port_specs(used_port_assignments)

cmd = [
"--dataDir=" + EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER,
Expand Down
Loading

0 comments on commit 6d8b560

Please sign in to comment.