Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ethereum-package
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
ethereum-package
Commits
c4b5786f
Commit
c4b5786f
authored
Oct 28, 2022
by
Gyanendra Mishra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
el & cl seem done
parent
263bd973
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
138 additions
and
9 deletions
+138
-9
cl_genesis_data_generator.star
..._data_generator/cl_genesis/cl_genesis_data_generator.star
+7
-9
el_genesis_data.star
.../prelaunch_data_generator/el_genesis/el_genesis_data.star
+0
-0
el_genesis_data_generator.star
..._data_generator/el_genesis/el_genesis_data_generator.star
+131
-0
No files found.
src/participant_network/prelaunch_data_generator/cl_genesis/cl_genesis_data_generator.star
View file @
c4b5786f
...
@@ -52,15 +52,14 @@ def generate_cl_genesis_data(
...
@@ -52,15 +52,14 @@ def generate_cl_genesis_data(
genesis_generation_config_artifact_uuid = render_templates(template_and_data_by_rel_dest_filepath)
genesis_generation_config_artifact_uuid = render_templates(template_and_data_by_rel_dest_filepath)
# TODO Make this the actual data generator
# TODO Make this the actual data generator
service_id = prelaunch_data_generator_launcher.launch_prelaunch_data_generator(
launcher_service_id = launch_prelaunch_data_generator(
enclaveCtx,
{
{
genesis_generation_config_artifact_uuid: CONFIG_DIRPATH_ON_GENERATOR,
genesis_generation_config_artifact_uuid: CONFIG_DIRPATH_ON_GENERATOR,
el_genesis_data.files_artifact_uuid: EL_GENESIS_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
# do that when https://github.com/kurtosis-tech/kurtosis/issues/244 is closed
all_dirpaths_to_create_on_generator = [
all_dirpaths_to_create_on_generator = [
...
@@ -71,7 +70,6 @@ def generate_cl_genesis_data(
...
@@ -71,7 +70,6 @@ def generate_cl_genesis_data(
all_dirpath_creation_commands = []
all_dirpath_creation_commands = []
for dirpath_to_create_on_generator in all_dirpaths_to_create_on_generator:
for dirpath_to_create_on_generator in all_dirpaths_to_create_on_generator:
all_dirpath_creation_commands.append(
all_dirpath_creation_commands.append(
all_dirpath_creation_commands,
"mkdir -p {0}".format(dirpathToCreateOnGenerator))
"mkdir -p {0}".format(dirpathToCreateOnGenerator))
dir_creation_cmd = [
dir_creation_cmd = [
...
@@ -80,7 +78,7 @@ def generate_cl_genesis_data(
...
@@ -80,7 +78,7 @@ def generate_cl_genesis_data(
(" && ").join(all_dirpath_creation_commands),
(" && ").join(all_dirpath_creation_commands),
]
]
exec(
service_id, dirCreationC
md, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
exec(
launcher_service_id, dir_creation_c
md, SUCCESSFUL_EXEC_CMD_EXIT_CODE)
# Copy files to output
# Copy files to output
...
@@ -96,7 +94,7 @@ def generate_cl_genesis_data(
...
@@ -96,7 +94,7 @@ def generate_cl_genesis_data(
filepath_on_generator,
filepath_on_generator,
OUTPUT_DIRPATH_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
# Generate files that need dynamic content
content_to_write_to_output_filename = {
content_to_write_to_output_filename = {
...
@@ -113,7 +111,7 @@ def generate_cl_genesis_data(
...
@@ -113,7 +111,7 @@ def generate_cl_genesis_data(
destFilepath,
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 = [
cl_genesis_generation_cmd_args = [
...
@@ -126,9 +124,9 @@ def generate_cl_genesis_data(
...
@@ -126,9 +124,9 @@ def generate_cl_genesis_data(
"--state-output", path_join(OUTPUT_DIRPATH_ON_GENERATOR, GENESIS_STATE_FILENAME)
"--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(
jwt_secret_rel_filepath = path_join(
path_base(OUTPUT_DIRPATH_ON_GENERATOR),
path_base(OUTPUT_DIRPATH_ON_GENERATOR),
...
...
src/participant_network/prelaunch_data_generator/el_genesis/el_genesis.star
→
src/participant_network/prelaunch_data_generator/el_genesis/el_genesis
_data
.star
View file @
c4b5786f
File moved
src/participant_network/prelaunch_data_generator/el_genesis/el_genesis_data_generator.star
View file @
c4b5786f
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment