Skip to content

Commit

Permalink
fix: use named artifacts (#69)
Browse files Browse the repository at this point in the history
Closes #70
  • Loading branch information
h4ck3rk3y authored Jan 10, 2023
1 parent 094352d commit 968f073
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/forkmon/forkmon_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@ 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 = plan.render_templates(template_and_data_by_rel_dest_filepath)
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "forkmon-config")

config = get_config(config_files_artifact_uuid)
config = get_config(config_files_artifact_name)

plan.add_service(SERVICE_ID, config)


def get_config(config_files_artifact_uuid):
def get_config(config_files_artifact_name):
config_file_path = shared_utils.path_join(FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE, FORKMON_CONFIG_FILENAME)
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
files = {
FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_uuid,
FORKMON_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
},
cmd = ["--config-path", config_file_path]
)
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 @@ -44,21 +44,21 @@ def get_grafana_config_dir_artifact_uuid(plan, datasource_config_template, dashb
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 = plan.render_templates(template_and_data_by_rel_dest_filepath)
grafana_config_artifacts_name = plan.render_templates(template_and_data_by_rel_dest_filepath, name="grafana-config")

grafana_dashboards_artifacts_uuid = plan.upload_files(static_files.GRAFANA_DASHBOARDS_CONFIG_DIRPATH)
grafana_dashboards_artifacts_name = plan.upload_files(static_files.GRAFANA_DASHBOARDS_CONFIG_DIRPATH, name="grafana-dashboards")

return grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid
return grafana_config_artifacts_name, grafana_dashboards_artifacts_name


def get_config(grafana_config_artifacts_uuid, grafana_dashboards_artifacts_uuid):
def get_config(grafana_config_artifacts_name, grafana_dashboards_artifacts_name):
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
env_vars = {CONFIG_DIRPATH_ENV_VAR: GRAFANA_CONFIG_DIRPATH_ON_SERVICE},
files = {
GRAFANA_CONFIG_DIRPATH_ON_SERVICE: grafana_config_artifacts_uuid,
GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE: grafana_dashboards_artifacts_uuid
GRAFANA_CONFIG_DIRPATH_ON_SERVICE: grafana_config_artifacts_name,
GRAFANA_DASHBOARDS_DIRPATH_ON_SERVICE: grafana_dashboards_artifacts_name
}
)

Expand Down
4 changes: 2 additions & 2 deletions src/participant_network/participant_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def launch_participant_network(plan, participants, network_params, global_log_le

plan.print("Uploading GETH prefunded keys")

geth_prefunded_keys_artifact_id = plan.upload_files(static_files.GETH_PREFUNDED_KEYS_DIRPATH)
geth_prefunded_keys_artifact_name = plan.upload_files(static_files.GETH_PREFUNDED_KEYS_DIRPATH, name="geth-prefunded-keys")

plan.print("Uploaded GETH files succesfully, launching EL participants")

el_launchers = {
package_io.EL_CLIENT_TYPE.geth : {"launcher": geth.new_geth_launcher(network_params.network_id, el_genesis_data, geth_prefunded_keys_artifact_id, genesis_constants.PRE_FUNDED_ACCOUNTS), "launch_method": geth.launch},
package_io.EL_CLIENT_TYPE.geth : {"launcher": geth.new_geth_launcher(network_params.network_id, el_genesis_data, geth_prefunded_keys_artifact_name, genesis_constants.PRE_FUNDED_ACCOUNTS), "launch_method": geth.launch},
package_io.EL_CLIENT_TYPE.besu : {"launcher": besu.new_besu_launcher(network_params.network_id, el_genesis_data), "launch_method": besu.launch},
package_io.EL_CLIENT_TYPE.erigon : {"launcher": erigon.new_erigon_launcher(network_params.network_id, el_genesis_data), "launch_method": erigon.launch},
package_io.EL_CLIENT_TYPE.nethermind : {"launcher": nethermind.new_nethermind_launcher(el_genesis_data), "launch_method": nethermind.launch},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def generate_cl_genesis_data(
template_and_data_by_rel_dest_filepath[MNEMONICS_YML_FILENAME] = genesis_generation_mnemonics_template_and_data
template_and_data_by_rel_dest_filepath[GENESIS_CONFIG_YML_FILENAME] = genesis_generation_config_template_and_data

genesis_generation_config_artifact_uuid = plan.render_templates(template_and_data_by_rel_dest_filepath)
genesis_generation_config_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "genesis-generation-config-cl")

# TODO(old) Make this the actual data generator - comment copied from the original module
launcher_service_id = prelaunch_data_generator_launcher.launch_prelaunch_data_generator(
plan,
{
CONFIG_DIRPATH_ON_GENERATOR: genesis_generation_config_artifact_uuid,
CONFIG_DIRPATH_ON_GENERATOR: genesis_generation_config_artifact_name,
EL_GENESIS_DIRPATH_ON_GENERATOR: el_genesis_data.files_artifact_uuid,
},
)
Expand Down Expand Up @@ -135,7 +135,7 @@ def generate_cl_genesis_data(
genesis_generation_result = plan.exec(struct(service_id=launcher_service_id, command=cl_genesis_generation_cmd))
plan.assert(genesis_generation_result["code"], "==", SUCCESSFUL_EXEC_CMD_EXIT_CODE)

cl_genesis_data_artifact_uuid = plan.store_service_files(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR)
cl_genesis_data_artifact_name = plan.store_service_files(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR, name = "cl-genesis-data")

jwt_secret_rel_filepath = shared_utils.path_join(
shared_utils.path_base(OUTPUT_DIRPATH_ON_GENERATOR),
Expand All @@ -150,7 +150,7 @@ def generate_cl_genesis_data(
GENESIS_STATE_FILENAME,
)
result = cl_genesis_data.new_cl_genesis_data(
cl_genesis_data_artifact_uuid,
cl_genesis_data_artifact_name,
jwt_secret_rel_filepath,
genesis_config_rel_filepath,
genesis_ssz_rel_filepath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ def generate_cl_validator_keystores(
# Store outputs into files artifacts
keystore_files = []
for idx, output_dirpath in enumerate(all_output_dirpaths):
artifact_uuid = plan.store_service_files(service_id, output_dirpath)
artifact_name = plan.store_service_files(service_id, output_dirpath, name = "validator-keystore-" + str(idx))

# This is necessary because the way Kurtosis currently implements artifact-storing is
base_dirname_in_artifact = shared_utils.path_base(output_dirpath)
to_add = keystore_files_module.new_keystore_files(
artifact_uuid,
artifact_name,
shared_utils.path_join(base_dirname_in_artifact, RAW_KEYS_DIRNAME),
shared_utils.path_join(base_dirname_in_artifact, RAW_SECRETS_DIRNAME),
shared_utils.path_join(base_dirname_in_artifact, NIMBUS_KEYS_DIRNAME),
Expand All @@ -100,10 +100,10 @@ def generate_cl_validator_keystores(
write_prysm_password_file_cmd_result = plan.exec(struct(service_id=service_id, command=write_prysm_password_file_cmd))
plan.assert(write_prysm_password_file_cmd_result["code"], "==", SUCCESSFUL_EXEC_CMD_EXIT_CODE)

prysm_password_artifact_uuid = plan.store_service_files(service_id, PRYSM_PASSWORD_FILEPATH_ON_GENERATOR)
prysm_password_artifact_name = plan.store_service_files(service_id, PRYSM_PASSWORD_FILEPATH_ON_GENERATOR, name = "prysm-password")

result = keystores_result.new_generate_keystores_result(
prysm_password_artifact_uuid,
prysm_password_artifact_name,
shared_utils.path_base(PRYSM_PASSWORD_FILEPATH_ON_GENERATOR),
keystore_files,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def generate_el_genesis_data(
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[GENESIS_CONFIG_FILENAME] = genesis_config_file_template_and_data

genesis_generation_config_artifact_uuid = plan.render_templates(template_and_data_by_rel_dest_filepath)
genesis_generation_config_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, name="genesis-generation-config-el")


# TODO(old) Make this the actual data generator - comment copied from the original module
launcher_service_id = prelaunch_data_generator_launcher.launch_prelaunch_data_generator(
plan,
{
CONFIG_DIRPATH_ON_GENERATOR: genesis_generation_config_artifact_uuid,
CONFIG_DIRPATH_ON_GENERATOR: genesis_generation_config_artifact_name,
},
)

Expand Down Expand Up @@ -118,10 +118,10 @@ def generate_el_genesis_data(
jwt_secret_generation_cmd_result = plan.exec(struct(service_id=launcher_service_id, command=jwt_secret_generation_cmd))
plan.assert(jwt_secret_generation_cmd_result["code"], "==", SUCCESSFUL_EXEC_CMD_EXIT_CODE)

elGenesisDataArtifactUuid = plan.store_service_files(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR)
el_genesis_data_artifact_name = plan.store_service_files(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR, name = "el-genesis-data")

result = el_genesis.new_el_genesis_data(
elGenesisDataArtifactUuid,
el_genesis_data_artifact_name,
shared_utils.path_join(shared_utils.path_base(OUTPUT_DIRPATH_ON_GENERATOR), JWT_SECRET_FILENAME),
genesis_filename_to_relative_filepath_in_artifact[GETH_GENESIS_FILENAME],
genesis_filename_to_relative_filepath_in_artifact[ERIGON_GENESIS_FILENAME],
Expand Down
8 changes: 4 additions & 4 deletions src/prometheus/prometheus_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def launch_prometheus(plan, config_template, cl_client_contexts):
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[CONFIG_FILENAME] = template_and_data

config_files_artifact_uuid = plan.render_templates(template_and_data_by_rel_dest_filepath)
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "prometheus-config")

config = get_config(config_files_artifact_uuid)
config = get_config(config_files_artifact_name)
prometheus_service = plan.add_service(SERVICE_ID, config)

private_ip_address = prometheus_service.ip_address
Expand All @@ -36,13 +36,13 @@ def launch_prometheus(plan, config_template, cl_client_contexts):
return "http://{0}:{1}".format(private_ip_address, prometheus_service_http_port)


def get_config(config_files_artifact_uuid):
def get_config(config_files_artifact_name):
config_file_path = shared_utils.path_join(CONFIG_DIR_MOUNTPOINT_ON_PROMETHEUS, shared_utils.path_base(CONFIG_FILENAME))
return ServiceConfig(
image = IMAGE_NAME,
ports = USED_PORTS,
files = {
CONFIG_DIR_MOUNTPOINT_ON_PROMETHEUS: config_files_artifact_uuid
CONFIG_DIR_MOUNTPOINT_ON_PROMETHEUS: config_files_artifact_name
},
cmd = [
# You can check all the cli flags starting the container and going to the flags section
Expand Down

0 comments on commit 968f073

Please sign in to comment.