Skip to content

Commit

Permalink
fix!: Use plan object (#65)
Browse files Browse the repository at this point in the history
BREAKING-CHANGE: Uses the `plan` object. Users will have to update their
Kurtosis CLI to >= 0.63.0 and restart the engine
  • Loading branch information
h4ck3rk3y committed Dec 20, 2022
1 parent 4f350ba commit 8e5d185
Show file tree
Hide file tree
Showing 24 changed files with 155 additions and 126 deletions.
9 changes: 8 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ workflows:
# -- PR check jobs ------------------------------------------
- kurtosis-docs-checker/check-docs:
should-check-changelog: false
markdown-link-check-config-json: "{}"
markdown-link-check-config-json: |
{
"ignorePatterns": [
{
"pattern": "https://github.com/kurtosis-tech/eth2-package"
}
]
}
filters:
branches:
ignore:
Expand Down
49 changes: 25 additions & 24 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ GRAFANA_DASHBOARD_PATH_URL = "/d/QdTOwy-nz/eth2-merge-kurtosis-module-dashboard?
FIRST_NODE_FINALIZATION_FACT = "cl-boot-finalization-fact"
HTTP_PORT_ID_FOR_FACT = "http"

def run(args):
def run(plan, args):
args_with_right_defaults = parse_input.parse_input(args)

num_participants = len(args_with_right_defaults.participants)
Expand All @@ -27,10 +27,10 @@ def run(args):
grafana_dashboards_config_template = read_file(static_files.GRAFANA_DASHBOARD_PROVIDERS_CONFIG_TEMPLATE_FILEPATH)
prometheus_config_template = read_file(static_files.PROMETHEUS_CONFIG_TEMPLATE_FILEPATH)

print("Read the prometheus, grafana templates")
plan.print("Read the prometheus, grafana templates")

print("Launching participant network with {0} participants and the following network params {1}".format(num_participants, network_params))
all_participants, cl_gensis_timestamp = participant_network.launch_participant_network(args_with_right_defaults.participants, network_params, args_with_right_defaults.global_client_log_level)
plan.print("Launching participant network with {0} participants and the following network params {1}".format(num_participants, network_params))
all_participants, cl_gensis_timestamp = participant_network.launch_participant_network(plan, args_with_right_defaults.participants, network_params, args_with_right_defaults.global_client_log_level)

all_el_client_contexts = []
all_cl_client_contexts = []
Expand All @@ -42,39 +42,40 @@ def run(args):
if not args_with_right_defaults.launch_additional_services:
return

print("Launching transaction spammer")
transaction_spammer.launch_transaction_spammer(genesis_constants.PRE_FUNDED_ACCOUNTS, all_el_client_contexts[0])
print("Succesfully launched transaction spammer")
plan.print("Launching transaction spammer")
transaction_spammer.launch_transaction_spammer(plan, genesis_constants.PRE_FUNDED_ACCOUNTS, all_el_client_contexts[0])
plan.print("Succesfully launched transaction spammer")

# We need a way to do time.sleep
# TODO add code that waits for CL genesis

print("Launching forkmon")
plan.print("Launching forkmon")
forkmon_config_template = read_file(static_files.FORKMON_CONFIG_TEMPLATE_FILEPATH)
forkmon.launch_forkmon(forkmon_config_template, all_cl_client_contexts, cl_gensis_timestamp, network_params.seconds_per_slot, network_params.slots_per_epoch)
print("Succesfully launched forkmon")
forkmon.launch_forkmon(plan, forkmon_config_template, all_cl_client_contexts, cl_gensis_timestamp, network_params.seconds_per_slot, network_params.slots_per_epoch)
plan.print("Succesfully launched forkmon")

print("Launching prometheus...")
plan.print("Launching prometheus...")
prometheus_private_url = prometheus.launch_prometheus(
plan,
prometheus_config_template,
all_cl_client_contexts,
)
print("Successfully launched Prometheus")
plan.print("Successfully launched Prometheus")

print("Launching grafana...")
grafana.launch_grafana(grafana_datasource_config_template, grafana_dashboards_config_template, prometheus_private_url)
print("Succesfully launched grafana")
plan.print("Launching grafana...")
grafana.launch_grafana(plan, grafana_datasource_config_template, grafana_dashboards_config_template, prometheus_private_url)
plan.print("Succesfully launched grafana")

if args_with_right_defaults.wait_for_verifications:
print("Running synchrnous testnet verifier")
testnet_verifier.run_synchronous_testnet_verification(args_with_right_defaults, all_el_client_contexts, all_cl_client_contexts)
print("Verification succeeded")
plan.print("Running synchrnous testnet verifier")
testnet_verifier.run_synchronous_testnet_verification(plan, args_with_right_defaults, all_el_client_contexts, all_cl_client_contexts)
plan.print("Verification succeeded")
else:
print("Running asynchronous verification")
testnet_verifier.launch_testnet_verifier(args_with_right_defaults, all_el_client_contexts, all_cl_client_contexts)
print("Succesfully launched asynchronous verifier")
plan.print("Running asynchronous verification")
testnet_verifier.launch_testnet_verifier(plan, args_with_right_defaults, all_el_client_contexts, all_cl_client_contexts)
plan.print("Succesfully launched asynchronous verifier")
if args_with_right_defaults.wait_for_finalization:
print("Waiting for the first finalized epoch")
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(
Expand All @@ -87,8 +88,8 @@ def run(args):
"finalized_epoch": ".data.finalized.epoch"
}
)
wait(epoch_recipe, "extract.finalized_epoch", "!=", "0", timeout="40m")
print("First finalized epoch occurred successfully")
plan.wait(epoch_recipe, "extract.finalized_epoch", "!=", "0", timeout="40m")
plan.print("First finalized epoch occurred successfully")


grafana_info = struct(
Expand Down
5 changes: 3 additions & 2 deletions src/forkmon/forkmon_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ USED_PORTS = {


def launch_forkmon(
plan,
config_template,
cl_client_contexts,
genesis_unix_timestamp,
Expand All @@ -35,11 +36,11 @@ def launch_forkmon(
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[FORKMON_CONFIG_FILENAME] = template_and_data

config_files_artifact_uuid = render_templates(template_and_data_by_rel_dest_filepath)
config_files_artifact_uuid = plan.render_templates(template_and_data_by_rel_dest_filepath)

config = get_config(config_files_artifact_uuid)

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


def get_config(config_files_artifact_uuid):
Expand Down
12 changes: 6 additions & 6 deletions src/grafana/grafana_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ USED_PORTS = {
}


def launch_grafana(datasource_config_template, dashboard_providers_config_template, prometheus_private_url):
grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid = get_grafana_config_dir_artifact_uuid(datasource_config_template, dashboard_providers_config_template, prometheus_private_url)
def launch_grafana(plan, datasource_config_template, dashboard_providers_config_template, prometheus_private_url):
grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid = get_grafana_config_dir_artifact_uuid(plan, datasource_config_template, dashboard_providers_config_template, prometheus_private_url)

config = get_config(grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid)

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


def get_grafana_config_dir_artifact_uuid(datasource_config_template, dashboard_providers_config_template, prometheus_private_url):
def get_grafana_config_dir_artifact_uuid(plan, datasource_config_template, dashboard_providers_config_template, prometheus_private_url):
datasource_data = new_datasource_config_template_data(prometheus_private_url)
datasource_template_and_data = shared_utils.new_template_and_data(datasource_config_template, datasource_data)

Expand All @@ -44,9 +44,9 @@ def get_grafana_config_dir_artifact_uuid(datasource_config_template, dashboard_p
template_and_data_by_rel_dest_filepath[DATASOURCE_CONFIG_REL_FILEPATH] = datasource_template_and_data
template_and_data_by_rel_dest_filepath[DASHBOARD_PROVIDERS_CONFIG_REL_FILEPATH] = dashboard_providers_template_and_data

grafana_config_artifacts_uuid = render_templates(template_and_data_by_rel_dest_filepath)
grafana_config_artifacts_uuid = plan.render_templates(template_and_data_by_rel_dest_filepath)

grafana_dashboards_artifacts_uuid = upload_files(static_files.GRAFANA_DASHBOARDS_CONFIG_DIRPATH)
grafana_dashboards_artifacts_uuid = plan.upload_files(static_files.GRAFANA_DASHBOARDS_CONFIG_DIRPATH)

return grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid

Expand Down
4 changes: 2 additions & 2 deletions src/participant_network/cl/cl_node_health_checker.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def wait_for_healthy(service_id, port_id):
def wait_for_healthy(plan, service_id, port_id):
recipe = struct(
service_id = service_id,
method= "GET",
endpoint = "/eth/v1/node/health",
content_type = "application/json",
port_id = port_id
)
return wait(recipe, "code", "IN", [200, 206, 503])
return plan.wait(recipe, "code", "IN", [200, 206, 503])
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ LIGHTHOUSE_LOG_LEVELS = {
}

def launch(
plan,
launcher,
service_id,
image,
Expand Down Expand Up @@ -94,9 +95,9 @@ def launch(
extra_beacon_params,
)

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

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

beacon_http_port = beacon_service.ports[BEACON_HTTP_PORT_ID]

Expand All @@ -113,7 +114,7 @@ def launch(
extra_validator_params,
)

validator_service = add_service(validator_node_service_id, validator_config)
validator_service = plan.add_service(validator_node_service_id, 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(
Expand All @@ -126,7 +127,7 @@ def launch(
"enr": ".data.enr"
}
)
beacon_node_enr = request(beacon_node_identity_recipe)["extract.enr"]
beacon_node_enr = plan.request(beacon_node_identity_recipe)["extract.enr"]

beacon_metrics_port = beacon_service.ports[BEACON_METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(beacon_service.ip_address, beacon_metrics_port.number)
Expand Down
10 changes: 5 additions & 5 deletions src/participant_network/cl/lodestar/lodestar_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ USED_PORTS = {
}



LODESTAR_LOG_LEVELS = {
package_io.GLOBAL_CLIENT_LOG_LEVEL.error: "error",
package_io.GLOBAL_CLIENT_LOG_LEVEL.warn: "warn",
Expand All @@ -51,6 +50,7 @@ LODESTAR_LOG_LEVELS = {


def launch(
plan,
launcher,
service_id,
image,
Expand Down Expand Up @@ -79,11 +79,11 @@ def launch(
extra_beacon_params,
)

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

beacon_http_port = beacon_service.ports[HTTP_PORT_ID]

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


# Launch validator node
Expand All @@ -100,7 +100,7 @@ def launch(
extra_validator_params,
)

validator_service = add_service(validator_node_service_id, validator_config)
validator_service = plan.add_service(validator_node_service_id, 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

Expand All @@ -114,7 +114,7 @@ def launch(
"enr": ".data.enr"
}
)
beacon_node_enr = request(beacon_node_identity_recipe)["extract.enr"]
beacon_node_enr = plan.request(beacon_node_identity_recipe)["extract.enr"]

beacon_metrics_port = beacon_service.ports[METRICS_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(beacon_service.ip_address, beacon_metrics_port.number)
Expand Down
7 changes: 4 additions & 3 deletions src/participant_network/cl/nimbus/nimbus_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ NIMBUS_LOG_LEVELS = {
ENTRYPOINT_ARGS = ["sh", "-c"]

def launch(
plan,
launcher,
service_id,
image,
Expand All @@ -78,9 +79,9 @@ 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 = add_service(service_id, config)
nimbus_service = plan.add_service(service_id, config)

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

cl_node_identity_recipe = struct(
service_id = service_id,
Expand All @@ -92,7 +93,7 @@ def launch(
"enr": ".data.enr"
}
)
node_enr = request(cl_node_identity_recipe)["extract.enr"]
node_enr = plan.request(cl_node_identity_recipe)["extract.enr"]

metrics_port = nimbus_service.ports[METRICS_PORT_ID]
metrics_url = "{0}:{1}".format(nimbus_service.ip_address, metrics_port.number)
Expand Down
9 changes: 5 additions & 4 deletions src/participant_network/cl/prysm/prysm_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ PRYSM_LOG_LEVELS = {


def launch(
plan,
launcher,
service_id,
images,
Expand Down Expand Up @@ -101,9 +102,9 @@ def launch(
extra_beacon_params,
)

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

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

beacon_http_port = beacon_service.ports[HTTP_PORT_ID]

Expand All @@ -125,7 +126,7 @@ def launch(
launcher.prysm_password_artifact_uuid
)

validator_service = add_service(validator_node_service_id, validator_config)
validator_service = plan.add_service(validator_node_service_id, 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(
Expand All @@ -138,7 +139,7 @@ def launch(
"enr": ".data.enr"
}
)
beacon_node_enr = request(beacon_node_identity_recipe)["extract.enr"]
beacon_node_enr = plan.request(beacon_node_identity_recipe)["extract.enr"]

beacon_metrics_port = beacon_service.ports[BEACON_MONITORING_PORT_ID]
beacon_metrics_url = "{0}:{1}".format(beacon_service.ip_address, beacon_metrics_port.number)
Expand Down
7 changes: 4 additions & 3 deletions src/participant_network/cl/teku/teku_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ TEKU_LOG_LEVELS = {
}

def launch(
plan,
launcher,
service_id,
image,
Expand All @@ -85,9 +86,9 @@ 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)

teku_service = add_service(service_id, config)
teku_service = plan.add_service(service_id, config)

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

node_identity_recipe = struct(
service_id = service_id,
Expand All @@ -99,7 +100,7 @@ def launch(
"enr": ".data.enr"
}
)
node_enr = request(node_identity_recipe)["extract.enr"]
node_enr = plan.request(node_identity_recipe)["extract.enr"]


teku_metrics_port = teku_service.ports[METRICS_PORT_ID]
Expand Down
5 changes: 3 additions & 2 deletions src/participant_network/el/besu/besu_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ BESU_LOG_LEVELS = {
}

def launch(
plan,
launcher,
service_id,
image,
Expand All @@ -58,9 +59,9 @@ def launch(
config = get_config(launcher.network_id, launcher.el_genesis_data,
image, existing_el_clients, log_level, extra_params)

service = add_service(service_id, config)
service = plan.add_service(service_id, config)

enode = el_admin_node_info.get_enode_for_node(service_id, RPC_PORT_ID)
enode = el_admin_node_info.get_enode_for_node(plan, service_id, RPC_PORT_ID)

return el_client_context.new_el_client_context(
"besu",
Expand Down
Loading

0 comments on commit 8e5d185

Please sign in to comment.