Skip to content

Commit

Permalink
fix: make this work with kurtosis 0.65.0 (#73)
Browse files Browse the repository at this point in the history
Can be merged after `service-name` gets merged.

Co-authored-by: Gyanendra Mishra <[email protected]>
  • Loading branch information
Peeeekay and h4ck3rk3y authored Jan 26, 2023
1 parent 968f073 commit 13c72ec
Show file tree
Hide file tree
Showing 24 changed files with 132 additions and 148 deletions.
8 changes: 3 additions & 5 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ def run(plan, args):
if args_with_right_defaults.wait_for_finalization:
plan.print("Waiting for the first finalized epoch")
first_cl_client = all_cl_client_contexts[0]
first_cl_client_id = first_cl_client.beacon_service_id
epoch_recipe = struct(
service_id = first_cl_client_id,
method= "GET",
first_client_beacon_name = first_cl_client.beacon_service_name
epoch_recipe = GetHttpRequestRecipe(
service_name = first_client_beacon_name,
endpoint = "/eth/v1/beacon/states/head/finality_checkpoints",
content_type = "application/json",
port_id = HTTP_PORT_ID_FOR_FACT,
extract = {
"finalized_epoch": ".data.finalized.epoch"
Expand Down
4 changes: 2 additions & 2 deletions src/forkmon/forkmon_launcher.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")


SERVICE_ID = "forkmon"
SERVICE_NAME = "forkmon"
IMAGE_NAME = "ralexstokes/ethereum_consensus_monitor:latest"

HTTP_PORT_ID = "http"
Expand Down Expand Up @@ -40,7 +40,7 @@ def launch_forkmon(

config = get_config(config_files_artifact_name)

plan.add_service(SERVICE_ID, config)
plan.add_service(SERVICE_NAME, config)


def get_config(config_files_artifact_name):
Expand Down
4 changes: 2 additions & 2 deletions src/grafana/grafana_launcher.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")
static_files = import_module("github.com/kurtosis-tech/eth2-package/src/static_files/static_files.star")

SERVICE_ID = "grafana"
SERVICE_NAME = "grafana"

IMAGE_NAME = "grafana/grafana-enterprise:9.2.3"

Expand Down Expand Up @@ -30,7 +30,7 @@ def launch_grafana(plan, datasource_config_template, dashboard_providers_config_

config = get_config(grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid)

plan.add_service(SERVICE_ID, config)
plan.add_service(SERVICE_NAME, config)


def get_grafana_config_dir_artifact_uuid(plan, datasource_config_template, dashboard_providers_config_template, prometheus_private_url):
Expand Down
4 changes: 2 additions & 2 deletions src/participant_network/cl/cl_client_context.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def new_cl_client_context(client_name, enr, ip_addr, http_port_num, cl_nodes_metrics_info, beacon_service_id):
def new_cl_client_context(client_name, enr, ip_addr, http_port_num, cl_nodes_metrics_info, beacon_service_name):
return struct(
client_name = client_name,
enr = enr,
ip_addr = ip_addr,
http_port_num = http_port_num,
cl_nodes_metrics_info = cl_nodes_metrics_info,
beacon_service_id = beacon_service_id
beacon_service_name = beacon_service_name
)
8 changes: 3 additions & 5 deletions src/participant_network/cl/cl_node_health_checker.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
def wait_for_healthy(plan, service_id, port_id):
recipe = struct(
service_id = service_id,
method= "GET",
def wait_for_healthy(plan, service_name, port_id):
recipe = GetHttpRequestRecipe(
service_name = service_name,
endpoint = "/eth/v1/node/health",
content_type = "application/json",
port_id = port_id
)
return plan.wait(recipe, "code", "IN", [200, 206, 503])
28 changes: 13 additions & 15 deletions src/participant_network/cl/lighthouse/lighthouse_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ VALIDATOR_METRICS_PORT_NUM = 5064

METRICS_PATH = "/metrics"

BEACON_SUFFIX_SERVICE_ID = "beacon"
VALIDATOR_SUFFIX_SERVICE_ID = "validator"
BEACON_SUFFIX_SERVICE_NAME = "beacon"
VALIDATOR_SUFFIX_SERVICE_NAME = "validator"

PRIVATE_IP_ADDRESS_PLACEHOLDER = "KURTOSIS_IP_ADDR_PLACEHOLDER"

Expand All @@ -68,7 +68,7 @@ LIGHTHOUSE_LOG_LEVELS = {
def launch(
plan,
launcher,
service_id,
service_name,
image,
participant_log_level,
global_log_level,
Expand All @@ -79,8 +79,8 @@ def launch(
extra_beacon_params,
extra_validator_params):

beacon_node_service_id = "{0}-{1}".format(service_id, BEACON_SUFFIX_SERVICE_ID)
validator_node_service_id = "{0}-{1}".format(service_id, VALIDATOR_SUFFIX_SERVICE_ID)
beacon_node_service_name = "{0}-{1}".format(service_name, BEACON_SUFFIX_SERVICE_NAME)
validator_node_service_name = "{0}-{1}".format(service_name, VALIDATOR_SUFFIX_SERVICE_NAME)

log_level = parse_input.get_client_log_level_or_default(participant_log_level, global_log_level, LIGHTHOUSE_LOG_LEVELS)

Expand All @@ -95,9 +95,9 @@ def launch(
extra_beacon_params,
)

beacon_service = plan.add_service(beacon_node_service_id, beacon_config)
beacon_service = plan.add_service(beacon_node_service_name, beacon_config)

cl_node_health_checker.wait_for_healthy(plan, beacon_node_service_id, BEACON_HTTP_PORT_ID)
cl_node_health_checker.wait_for_healthy(plan, beacon_node_service_name, BEACON_HTTP_PORT_ID)

beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID]

Expand All @@ -114,14 +114,12 @@ def launch(
extra_validator_params,
)

validator_service = plan.add_service(validator_node_service_id, validator_config)
validator_service = plan.add_service(validator_node_service_name, validator_config)

# 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 = struct(
service_id = beacon_node_service_id,
method= "GET",
beacon_node_identity_recipe = GetHttpRequestRecipe(
service_name = beacon_node_service_name,
endpoint = "/eth/v1/node/identity",
content_type = "application/json",
port_id = BEACON_HTTP_PORT_ID,
extract = {
"enr": ".data.enr"
Expand All @@ -135,8 +133,8 @@ def launch(
validator_metrics_port = validator_service.ports[VALIDATOR_METRICS_PORT_ID]
validator_metrics_url = "{0}:{1}".format(validator_service.ip_address, validator_metrics_port.number)

beacon_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(beacon_node_service_id, METRICS_PATH, beacon_metrics_url)
validator_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(validator_node_service_id, METRICS_PATH, validator_metrics_url)
beacon_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(beacon_node_service_name, METRICS_PATH, beacon_metrics_url)
validator_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(validator_node_service_name, METRICS_PATH, validator_metrics_url)
nodes_metrics_info = [beacon_node_metrics_info, validator_node_metrics_info]

return cl_client_context.new_cl_client_context(
Expand All @@ -145,7 +143,7 @@ def launch(
beacon_service.ip_address,
BEACON_HTTP_PORT_NUM,
nodes_metrics_info,
beacon_node_service_id,
beacon_node_service_name,
)


Expand Down
32 changes: 15 additions & 17 deletions src/participant_network/cl/lodestar/lodestar_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ HTTP_PORT_NUM = 4000
METRICS_PORT_NUM = 8008
VALIDATOR_METRICS_PORT_NUM = 5064

BEACON_SUFFIX_SERVICE_ID = "beacon"
VALIDATOR_SUFFIX_SERVICE_ID = "validator"
BEACON_SUFFIX_SERVICE_NAME = "beacon"
VALIDATOR_SUFFIX_SERVICE_NAME = "validator"

METRICS_PATH = "/metrics"

Expand All @@ -52,7 +52,7 @@ LODESTAR_LOG_LEVELS = {
def launch(
plan,
launcher,
service_id,
service_name,
image,
participant_log_level,
global_log_level,
Expand All @@ -63,8 +63,8 @@ def launch(
extra_beacon_params,
extra_validator_params):

beacon_node_service_id = "{0}-{1}".format(service_id, BEACON_SUFFIX_SERVICE_ID)
validator_node_service_id = "{0}-{1}".format(service_id, VALIDATOR_SUFFIX_SERVICE_ID)
beacon_node_service_name = "{0}-{1}".format(service_name, BEACON_SUFFIX_SERVICE_NAME)
validator_node_service_name = "{0}-{1}".format(service_name, VALIDATOR_SUFFIX_SERVICE_NAME)

log_level = parse_input.get_client_log_level_or_default(participant_log_level, global_log_level, LODESTAR_LOG_LEVELS)

Expand All @@ -79,18 +79,18 @@ def launch(
extra_beacon_params,
)

beacon_service = plan.add_service(beacon_node_service_id, beacon_config)
beacon_service = plan.add_service(beacon_node_service_name, beacon_config)

beacon_http_port = beacon_service.ports[HTTP_PORT_ID]

cl_node_health_checker.wait_for_healthy(plan, beacon_node_service_id, HTTP_PORT_ID)
cl_node_health_checker.wait_for_healthy(plan, beacon_node_service_name, HTTP_PORT_ID)


# Launch validator node
beacon_http_url = "http://{0}:{1}".format(beacon_service.ip_address, beacon_http_port.number)

validator_config = get_validator_config(
validator_node_service_id,
validator_node_service_name,
launcher.cl_genesis_data,
image,
log_level,
Expand All @@ -100,15 +100,13 @@ def launch(
extra_validator_params,
)

validator_service = plan.add_service(validator_node_service_id, validator_config)
validator_service = plan.add_service(validator_node_service_name, validator_config)

# 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 = struct(
service_id = beacon_node_service_id,
method= "GET",
beacon_node_identity_recipe = GetHttpRequestRecipe(
service_name = beacon_node_service_name,
endpoint = "/eth/v1/node/identity",
content_type = "application/json",
port_id = HTTP_PORT_ID,
extract = {
"enr": ".data.enr"
Expand All @@ -119,7 +117,7 @@ def launch(
beacon_metrics_port = beacon_service.ports[METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(beacon_service.ip_address, beacon_metrics_port.number)

beacon_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(service_id, METRICS_PATH, beacon_metrics_url)
beacon_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(service_name, METRICS_PATH, beacon_metrics_url)
nodes_metrics_info = [beacon_node_metrics_info]

return cl_client_context.new_cl_client_context(
Expand All @@ -128,7 +126,7 @@ def launch(
beacon_service.ip_address,
HTTP_PORT_NUM,
nodes_metrics_info,
beacon_node_service_id
beacon_node_service_name
)


Expand Down Expand Up @@ -210,7 +208,7 @@ def get_beacon_config(


def get_validator_config(
service_id,
service_name,
genesis_data,
image,
log_level,
Expand All @@ -219,7 +217,7 @@ def get_validator_config(
mev_boost_context,
extra_params):

root_dirpath = shared_utils.path_join(CONSENSUS_DATA_DIRPATH_ON_SERVICE_CONTAINER, service_id)
root_dirpath = shared_utils.path_join(CONSENSUS_DATA_DIRPATH_ON_SERVICE_CONTAINER, service_name)

genesis_config_filepath = shared_utils.path_join(GENESIS_DATA_MOUNT_DIRPATH_ON_SERVICE_CONTAINER, genesis_data.config_yml_rel_filepath)
validator_keys_dirpath = shared_utils.path_join(VALIDATOR_KEYS_MOUNT_DIRPATH_ON_SERVICE_CONTAINER, node_keystore_files.raw_keys_relative_dirpath)
Expand Down
16 changes: 7 additions & 9 deletions src/participant_network/cl/nimbus/nimbus_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENTRYPOINT_ARGS = ["sh", "-c"]
def launch(
plan,
launcher,
service_id,
service_name,
image,
participant_log_level,
global_log_level,
Expand All @@ -79,15 +79,13 @@ def launch(

config = get_config(launcher.cl_genesis_data, image, bootnode_context, el_client_context, mev_boost_context, log_level, node_keystore_files, extra_params)

nimbus_service = plan.add_service(service_id, config)
nimbus_service = plan.add_service(service_name, config)

cl_node_health_checker.wait_for_healthy(plan, service_id, HTTP_PORT_ID)
cl_node_health_checker.wait_for_healthy(plan, service_name, HTTP_PORT_ID)

cl_node_identity_recipe = struct(
service_id = service_id,
method= "GET",
cl_node_identity_recipe = GetHttpRequestRecipe(
service_name = service_name,
endpoint = "/eth/v1/node/identity",
content_type = "application/json",
port_id = HTTP_PORT_ID,
extract = {
"enr": ".data.enr"
Expand All @@ -98,7 +96,7 @@ def launch(
metrics_port = nimbus_service.ports[METRICS_PORT_ID]
metrics_url = "{0}:{1}".format(nimbus_service.ip_address, metrics_port.number)

nimbus_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(service_id, METRICS_PATH, metrics_url)
nimbus_node_metrics_info = cl_node_metrics.new_cl_node_metrics_info(service_name, METRICS_PATH, metrics_url)
nodes_metrics_info = [nimbus_node_metrics_info]


Expand All @@ -108,7 +106,7 @@ def launch(
nimbus_service.ip_address,
HTTP_PORT_NUM,
nodes_metrics_info,
service_id,
service_name,
)


Expand Down
Loading

0 comments on commit 13c72ec

Please sign in to comment.