Skip to content

Commit

Permalink
feat(cl): WIP: Update grandine, lighthouse, lodestar and nimbus launcher
Browse files Browse the repository at this point in the history
* Add participant id to launch and get_config method
* Delete port id constants
* Add shared_utils port id constants
* Delete kurtosis port spec getter
* Add general kurtosis port spec getter from shared_utils
  • Loading branch information
TobiWo committed Jun 18, 2024
1 parent 1f55bd2 commit e812c4c
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 175 deletions.
66 changes: 24 additions & 42 deletions src/cl/grandine/grandine_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ vc_shared = import_module("../../vc/shared.star")
# The Docker container runs as the "grandine" user so we can't write to root
BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER = "/data/grandine/grandine-beacon-data"

# Port IDs
BEACON_TCP_DISCOVERY_PORT_ID = "tcp-discovery"
BEACON_UDP_DISCOVERY_PORT_ID = "udp-discovery"
BEACON_HTTP_PORT_ID = "http"
BEACON_METRICS_PORT_ID = "metrics"
VALIDATOR_HTTP_PORT_ID = "http-validator"

# Port nums
BEACON_DISCOVERY_PORT_NUM = 9000
BEACON_HTTP_PORT_NUM = 4000
Expand All @@ -29,25 +22,6 @@ BEACON_METRICS_PATH = "/metrics"

MIN_PEERS = 1


def get_used_ports(discovery_port):
beacon_used_ports = {
BEACON_TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
BEACON_UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
BEACON_HTTP_PORT_ID: shared_utils.new_port_spec(
BEACON_HTTP_PORT_NUM, shared_utils.TCP_PROTOCOL
),
BEACON_METRICS_PORT_ID: shared_utils.new_port_spec(
BEACON_METRICS_PORT_NUM, shared_utils.TCP_PROTOCOL
),
}
return beacon_used_ports


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

VERBOSITY_LEVELS = {
Expand Down Expand Up @@ -90,6 +64,7 @@ def launch(
use_separate_vc,
keymanager_enabled,
port_publisher,
participant_index,
):
beacon_service_name = "{0}".format(service_name)
log_level = input_parser.get_client_log_level_or_default(
Expand Down Expand Up @@ -151,23 +126,24 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
)

beacon_service = plan.add_service(service_name, config)

beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID]
beacon_http_port = beacon_service.ports[shared_utils.BEACON_HTTP_PORT_ID]
beacon_http_url = "http://{0}:{1}".format(
beacon_service.ip_address, beacon_http_port.number
)

beacon_metrics_port = beacon_service.ports[BEACON_METRICS_PORT_ID]
beacon_metrics_port = beacon_service.ports[shared_utils.METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(
beacon_service.ip_address, beacon_metrics_port.number
)

beacon_node_identity_recipe = GetHttpRequestRecipe(
endpoint="/eth/v1/node/identity",
port_id=BEACON_HTTP_PORT_ID,
port_id=shared_utils.BEACON_HTTP_PORT_ID,
extract={
"enr": ".data.enr",
"multiaddr": ".data.p2p_addresses[0]",
Expand Down Expand Up @@ -231,6 +207,7 @@ def get_beacon_config(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
validator_keys_dirpath = ""
validator_secrets_dirpath = ""
Expand All @@ -257,19 +234,24 @@ def get_beacon_config(

public_ports = {}
discovery_port = BEACON_DISCOVERY_PORT_NUM
if port_publisher.public_port_start:
discovery_port = port_publisher.cl_start
if bootnode_contexts and len(bootnode_contexts) > 0:
discovery_port = discovery_port + len(bootnode_contexts)
public_ports = {
BEACON_TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
BEACON_UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
if port_publisher.cl_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component("cl", port_publisher, participant_index)
public_port_assignments = {
shared_utils.TCP_DISCOVERY_PORT_ID: public_ports_for_component[0],
shared_utils.UDP_DISCOVERY_PORT_ID: public_ports_for_component[0],
shared_utils.BEACON_HTTP_PORT_ID: public_ports_for_component[1],
shared_utils.METRICS_PORT_ID: public_ports_for_component[2]
}
used_ports = get_used_ports(discovery_port)
public_ports = shared_utils.get_ports(public_port_assignments)
discovery_port = public_ports_for_component[0]

used_port_assignments = {
shared_utils.TCP_DISCOVERY_PORT_ID: BEACON_DISCOVERY_PORT_NUM,
shared_utils.UDP_DISCOVERY_PORT_ID: BEACON_DISCOVERY_PORT_NUM,
shared_utils.BEACON_HTTP_PORT_ID: BEACON_HTTP_PORT_NUM,
shared_utils.METRICS_PORT_ID: BEACON_METRICS_PORT_NUM
}
used_ports = shared_utils.get_ports(used_port_assignments)

cmd = [
"--network={0}".format(
Expand Down Expand Up @@ -400,7 +382,7 @@ def get_beacon_config(
files=files,
private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
ready_conditions=cl_node_ready_conditions.get_ready_conditions(
BEACON_HTTP_PORT_ID
shared_utils.BEACON_HTTP_PORT_ID
),
min_cpu=cl_min_cpu,
max_cpu=cl_max_cpu,
Expand Down
71 changes: 25 additions & 46 deletions src/cl/lighthouse/lighthouse_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ RUST_FULL_BACKTRACE_KEYWORD = "full"
# ---------------------------------- Beacon client -------------------------------------
BEACON_DATA_DIRPATH_ON_BEACON_SERVICE_CONTAINER = "/data/lighthouse/beacon-data"

# Port IDs
BEACON_TCP_DISCOVERY_PORT_ID = "tcp-discovery"
BEACON_UDP_DISCOVERY_PORT_ID = "udp-discovery"
BEACON_HTTP_PORT_ID = "http"
BEACON_METRICS_PORT_ID = "metrics"

# Port nums
BEACON_DISCOVERY_PORT_NUM = 9000
BEACON_HTTP_PORT_NUM = 4000
Expand All @@ -32,29 +26,6 @@ BEACON_MIN_MEMORY = 256

METRICS_PATH = "/metrics"


def get_used_ports(discovery_port):
beacon_used_ports = {
BEACON_TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
BEACON_UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
BEACON_HTTP_PORT_ID: shared_utils.new_port_spec(
BEACON_HTTP_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
BEACON_METRICS_PORT_ID: shared_utils.new_port_spec(
BEACON_METRICS_PORT_NUM,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
),
}
return beacon_used_ports


VERBOSITY_LEVELS = {
constants.GLOBAL_LOG_LEVEL.error: "error",
constants.GLOBAL_LOG_LEVEL.warn: "warn",
Expand Down Expand Up @@ -95,6 +66,7 @@ def launch(
use_separate_vc,
keymanager_enabled,
port_publisher,
participant_index,
):
beacon_service_name = "{0}".format(service_name)

Expand Down Expand Up @@ -152,10 +124,11 @@ def launch(
tolerations,
node_selectors,
port_publisher,
participant_index,
)

beacon_service = plan.add_service(beacon_service_name, beacon_config)
beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID]
beacon_http_port = beacon_service.ports[shared_utils.BEACON_HTTP_PORT_ID]
beacon_http_url = "http://{0}:{1}".format(
beacon_service.ip_address, beacon_http_port.number
)
Expand Down Expand Up @@ -183,7 +156,7 @@ def launch(
# TODO(old) add validator availability using the validator API: https://ethereum.github.io/beacon-APIs/?urls.primaryName=v1#/ValidatorRequiredApi | from eth2-merge-kurtosis-module
beacon_node_identity_recipe = GetHttpRequestRecipe(
endpoint="/eth/v1/node/identity",
port_id=BEACON_HTTP_PORT_ID,
port_id=shared_utils.BEACON_HTTP_PORT_ID,
extract={
"enr": ".data.enr",
"multiaddr": ".data.p2p_addresses[0]",
Expand All @@ -197,7 +170,7 @@ def launch(
beacon_multiaddr = response["extract.multiaddr"]
beacon_peer_id = response["extract.peer_id"]

beacon_metrics_port = beacon_service.ports[BEACON_METRICS_PORT_ID]
beacon_metrics_port = beacon_service.ports[shared_utils.METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(
beacon_service.ip_address, beacon_metrics_port.number
)
Expand Down Expand Up @@ -247,6 +220,7 @@ def get_beacon_config(
tolerations,
node_selectors,
port_publisher,
participant_index,
):
# If snooper is enabled use the snooper engine context, otherwise use the execution client context
if snooper_enabled:
Expand All @@ -262,19 +236,24 @@ def get_beacon_config(

public_ports = {}
discovery_port = BEACON_DISCOVERY_PORT_NUM
if port_publisher.public_port_start:
discovery_port = port_publisher.cl_start
if boot_cl_client_ctxs and len(boot_cl_client_ctxs) > 0:
discovery_port = discovery_port + len(boot_cl_client_ctxs)
public_ports = {
BEACON_TCP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.TCP_PROTOCOL
),
BEACON_UDP_DISCOVERY_PORT_ID: shared_utils.new_port_spec(
discovery_port, shared_utils.UDP_PROTOCOL
),
if port_publisher.cl_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component("cl", port_publisher, participant_index)
public_port_assignments = {
shared_utils.TCP_DISCOVERY_PORT_ID: public_ports_for_component[0],
shared_utils.UDP_DISCOVERY_PORT_ID: public_ports_for_component[0],
shared_utils.BEACON_HTTP_PORT_ID: public_ports_for_component[1],
shared_utils.METRICS_PORT_ID: public_ports_for_component[2]
}
used_ports = get_used_ports(discovery_port)
public_ports = shared_utils.get_ports(public_port_assignments)
discovery_port = public_ports_for_component[0]

used_port_assignments = {
shared_utils.TCP_DISCOVERY_PORT_ID: BEACON_DISCOVERY_PORT_NUM,
shared_utils.UDP_DISCOVERY_PORT_ID: BEACON_DISCOVERY_PORT_NUM,
shared_utils.BEACON_HTTP_PORT_ID: BEACON_HTTP_PORT_NUM,
shared_utils.METRICS_PORT_ID: BEACON_METRICS_PORT_NUM
}
used_ports = shared_utils.get_ports(used_port_assignments)

# NOTE: If connecting to the merge devnet remotely we DON'T want the following flags; when they're not set, the node's external IP address is auto-detected
# from the peers it communicates with but when they're set they basically say "override the autodetection and
Expand Down Expand Up @@ -373,7 +352,7 @@ def get_beacon_config(
cmd.extend([param for param in extra_params])

recipe = GetHttpRequestRecipe(
endpoint="/eth/v1/node/identity", port_id=BEACON_HTTP_PORT_ID
endpoint="/eth/v1/node/identity", port_id=shared_utils.BEACON_HTTP_PORT_ID
)
files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data.files_artifact_uuid,
Expand All @@ -396,7 +375,7 @@ def get_beacon_config(
env_vars=env,
private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
ready_conditions=cl_node_ready_conditions.get_ready_conditions(
BEACON_HTTP_PORT_ID
shared_utils.BEACON_HTTP_PORT_ID
),
min_cpu=cl_min_cpu,
max_cpu=cl_max_cpu,
Expand Down
Loading

0 comments on commit e812c4c

Please sign in to comment.