Commit c4b5786f authored by Gyanendra Mishra's avatar Gyanendra Mishra

el & cl seem done

parent 263bd973
......@@ -52,15 +52,14 @@ def generate_cl_genesis_data(
genesis_generation_config_artifact_uuid = render_templates(template_and_data_by_rel_dest_filepath)
# TODO Make this the actual data generator
service_id = prelaunch_data_generator_launcher.launch_prelaunch_data_generator(
enclaveCtx,
launcher_service_id = launch_prelaunch_data_generator(
{
genesis_generation_config_artifact_uuid: CONFIG_DIRPATH_ON_GENERATOR,
el_genesis_data.files_artifact_uuid: EL_GENESIS_DIRPATH_ON_GENERATOR,
},
)
# TODO add a remove_service call that removes the service_id, before the function returns
# TODO add a remove_service call that removes the launcher_service_id, before the function returns
# do that when https://github.com/kurtosis-tech/kurtosis/issues/244 is closed
all_dirpaths_to_create_on_generator = [
......@@ -71,7 +70,6 @@ def generate_cl_genesis_data(
all_dirpath_creation_commands = []
for dirpath_to_create_on_generator in all_dirpaths_to_create_on_generator:
all_dirpath_creation_commands.append(
all_dirpath_creation_commands,
"mkdir -p {0}".format(dirpathToCreateOnGenerator))
dir_creation_cmd = [
......@@ -80,7 +78,7 @@ def generate_cl_genesis_data(
(" && ").join(all_dirpath_creation_commands),
]
exec(service_id, dirCreationCmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
exec(launcher_service_id, dir_creation_cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
# Copy files to output
......@@ -96,7 +94,7 @@ def generate_cl_genesis_data(
filepath_on_generator,
OUTPUT_DIRPATH_ON_GENERATOR,
]
exec(service_id, cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
exec(launcher_service_id, cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
# Generate files that need dynamic content
content_to_write_to_output_filename = {
......@@ -113,7 +111,7 @@ def generate_cl_genesis_data(
destFilepath,
)
]
exec(service_id, cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
exec(launcher_service_id, cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
cl_genesis_generation_cmd_args = [
......@@ -126,9 +124,9 @@ def generate_cl_genesis_data(
"--state-output", path_join(OUTPUT_DIRPATH_ON_GENERATOR, GENESIS_STATE_FILENAME)
]
exec(service_id, cl_genesis_generation_cmd_args, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
exec(launcher_service_id, cl_genesis_generation_cmd_args, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
cl_genesis_data_artifact_uuid = store_files_on_service(service_id, OUTPUT_DIRPATH_ON_GENERATOR)
cl_genesis_data_artifact_uuid = store_files_from_service(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR)
jwt_secret_rel_filepath = path_join(
path_base(OUTPUT_DIRPATH_ON_GENERATOR),
......
load("github.com/kurtosis-tech/eth2-merge-startosis-module/src/shared_utils/shared_utils.star", "new_template_and_data", "path_join", "path_base")
load("github.com/kurtosis-tech/eth2-merge-startosis-module/src/participant_network/prelaunch_data_generator/el_genesis/el_genesis_data.star", "new_el_genesis_data")
CONFIG_DIRPATH_ON_GENERATOR = "/config"
GENESIS_CONFIG_FILENAME = "genesis-config.yaml"
OUTPUT_DIRPATH_ON_GENERATOR = "/output"
GETH_GENESIS_FILENAME = "geth.json"
ERIGON_GENESIS_FILENAME = "erigon.json"
NETHERMIND_GENESIS_FILENAME = "nethermind.json"
BESU_GENESIS_FILENAME = "besu.json"
JWT_SECRET_FILENAME = "jwtsecret"
SUCCESSFUL_EXEC_CMD_EXIT_CODE = 0
# Mapping of output genesis filename -> generator to create the file
all_genesis_generation_cmds = {
GETH_GENESIS_FILENAME: lambda genesis_config_filepath_on_generator: ["python3", "/apps/el-gen/genesis_geth.py", genesis_config_filepath_on_generator],
ERIGON_GENESIS_FILENAME: lambda genesis_config_filepath_on_generator: ["python3", "/apps/el-gen/genesis_geth.py",genesis_config_filepath_on_generator],
NETHERMIND_GENESIS_FILENAME: lambda genesis_config_filepath_on_generator: ["python3", "/apps/el-gen/genesis_chainspec.py", genesis_config_filepath_on_generator],
BESU_GENESIS_FILENAME: lambda genesis_config_filepath_on_generator :["python3", "/apps/el-gen/genesis_besu.py", genesis_config_filepath_on_generator]
}
def generate_el_genesis_data(
genesis_generation_config_template,
genesis_unix_timestamp,
network_id,
deposit_contract_address):
template_data = genesis_generation_config_template_data(
network_id,
deposit_contract_address,
genesis_unix_timestamp,
0 # set terminal difficulty to 0
)
genesis_config_file_template_and_data = new_template_and_data(genesis_generation_config_template, template_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 = render_templates(template_and_data_by_rel_dest_filepath)
# TODO Make this the actual data generator
launcher_service_id = launch_prelaunch_data_generator(
{
genesis_generation_config_artifact_uuid: CONFIG_DIRPATH_ON_GENERATOR,
},
)
# TODO defer remove the above generated service
all_dirpaths_to_create_on_generator = [
CONFIG_DIRPATH_ON_GENERATOR,
OUTPUT_DIRPATH_ON_GENERATOR,
]
all_dirpath_creation_commands = []
for dirpath_to_create_on_generator in all_dirpaths_to_create_on_generator:
all_dirpath_creation_commands.append(
"mkdir -p {0}".format(dirpath_to_create_on_generator),
)
dir_creation_cmd = [
"bash",
"-c",
" && ".join(all_dirpath_creation_commands),
]
exec(launcher_service_id, dir_creation_cmd, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
genesis_config_filepath_on_generator = path_join(CONFIG_DIRPATH_ON_GENERATOR, GENESIS_CONFIG_FILENAME)
genesis_filename_to_relative_filepath_in_artifact = map[string]string{}
for output_filename, generation_cmd in all_genesis_generation_cmds.items():
cmd = generation_cmd(genesis_config_filepath_on_generator)
output_filepath_on_generator = path_join(OUTPUT_DIRPATH_ON_GENERATOR, output_filename)
cmd.append(">", output_filepath_on_generator)
cmd_to_execute = [
"bash",
"-c",
" ".join(all_genesis_generation_cmds)
]
exec(launcher_service_id, cmd_to_execute, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
genesis_filename_to_relative_filepath_in_artifact[output_filename] = path_join(
path_base(OUTPUT_DIRPATH_ON_GENERATOR),
output_filename,
)
jwt_secret_filepath_on_generator = path_join(OUTPUT_DIRPATH_ON_GENERATOR, JWT_SECRET_FILENAME)
jwt_secret_generation_cmd_args = [
"bash",
"-c",
"openssl rand -hex 32 | tr -d \"\\n\" | sed 's/^/0x/' > {0}".format(
jwt_secret_filepath_on_generator,
)
]
exec(launcher_service_id, jwt_secret_filepath_on_generator, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
elGenesisDataArtifactUuid = store_files_from_service(launcher_service_id, OUTPUT_DIRPATH_ON_GENERATOR)
result = new_el_genesis_data(
elGenesisDataArtifactUuid,
path_join(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],
genesis_filename_to_relative_filepath_in_artifact[NETHERMIND_GENESIS_FILENAME],
genesis_filename_to_relative_filepath_in_artifact[BESU_GENESIS_FILENAME],
)
return result
def genesis_generation_config_template_data(network_id, deposit_contract_address, unix_timestamp, total_terminal_difficulty):
return {
"NetworkId": network_id,
"DepositContractAddress": deposit_contract_address,
"UnixTimestamp": unix_timestamp,
"TotalTerminalDifficulty": total_terminal_difficulty,
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment