Skip to content

Commit

Permalink
fix: zero count validators and parallel keystore generation (#302)
Browse files Browse the repository at this point in the history
Co-authored-by: Barnabas Busa <busa.barnabas@gmail.com>
  • Loading branch information
h4ck3rk3y and barnabasbusa committed Oct 18, 2023
1 parent 49596fd commit 18b141e
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 4 deletions.
39 changes: 37 additions & 2 deletions .circleci/config.yml
Expand Up @@ -251,6 +251,25 @@ jobs:
- checkout
- run: kurtosis run ${PWD} "$(cat ./.circleci/tests/mix-with-tools.json)"

parallel_key_store_generation_1:
executor: ubuntu_vm
steps:
- <<: *setup_kurtosis
- checkout
- run: kurtosis run ${PWD} "$(cat ./.circleci/tests/parallel-keystores-1.json)"
parallel_key_store_generation_2:
executor: ubuntu_vm
steps:
- <<: *setup_kurtosis
- checkout
- run: kurtosis run ${PWD} "$(cat ./.circleci/tests/parallel-keystores-2.json)"
parallel_key_store_generation_3:
executor: ubuntu_vm
steps:
- <<: *setup_kurtosis
- checkout
- run: kurtosis run ${PWD} "$(cat ./.circleci/tests/parallel-keystores-3.json)"

workflows:
check_latest_version:
when: << pipeline.parameters.should-enable-check-latest-version-workflow >>
Expand Down Expand Up @@ -301,12 +320,12 @@ workflows:
filters:
branches:
ignore:
- main
- main
- lint:
filters:
branches:
ignore:
- main
- main
- mev:
filters:
branches:
Expand All @@ -325,3 +344,19 @@ workflows:
branches:
ignore:
- main

- parallel_key_store_generation_1:
filters:
branches:
ignore:
- main
- parallel_key_store_generation_2:
filters:
branches:
ignore:
- main
- parallel_key_store_generation_3:
filters:
branches:
ignore:
- main
14 changes: 14 additions & 0 deletions .circleci/tests/parallel-keystores-1.json
@@ -0,0 +1,14 @@
{
"participants": [
{
"el_client_type": "geth",
"cl_client_type": "teku"
},
{
"el_client_type": "geth",
"cl_client_type": "teku",
"validator_count": 0
}
],
"parallel_keystore_generation": true
}
14 changes: 14 additions & 0 deletions .circleci/tests/parallel-keystores-2.json
@@ -0,0 +1,14 @@
{
"participants": [
{
"el_client_type": "geth",
"cl_client_type": "teku",
"validator_count": 0
},
{
"el_client_type": "geth",
"cl_client_type": "teku"
}
],
"parallel_keystore_generation": true
}
18 changes: 18 additions & 0 deletions .circleci/tests/parallel-keystores-3.json
@@ -0,0 +1,18 @@
{
"participants": [
{
"el_client_type": "geth",
"cl_client_type": "teku"
},
{
"el_client_type": "geth",
"cl_client_type": "teku",
"validator_count": 0
},
{
"el_client_type": "geth",
"cl_client_type": "teku"
}
],
"parallel_keystore_generation": true
}
Expand Up @@ -163,7 +163,9 @@ def generate_cl_valdiator_keystores_in_parallel(plan, mnemonic, participants):
for idx, participant in enumerate(participants):
output_dirpath = NODE_KEYSTORES_OUTPUT_DIRPATH_FORMAT_STR.format(idx)
if participant.validator_count == 0:
all_output_dirpaths.append(output_dirpath)
all_generation_commands.append(None)
all_output_dirpaths.append(None)
finished_files_to_verify.append(None)
continue
start_index = idx * participant.validator_count
stop_index = (idx + 1) * participant.validator_count
Expand All @@ -188,6 +190,9 @@ def generate_cl_valdiator_keystores_in_parallel(plan, mnemonic, participants):
for idx in range(0, len(participants)):
service_name = service_names[idx]
generation_command = all_generation_commands[idx]
if generation_command == None:
# no generation command as validator count is 0
continue
plan.exec(
recipe=ExecRecipe(
command=["sh", "-c", generation_command + " >/dev/null 2>&1 &"]
Expand All @@ -199,6 +204,9 @@ def generate_cl_valdiator_keystores_in_parallel(plan, mnemonic, participants):
for idx in range(0, len(participants)):
service_name = service_names[idx]
output_dirpath = all_output_dirpaths[idx]
if output_dirpath == None:
# no output dir path as validator count is 0
continue
generation_finished_filepath = finished_files_to_verify[idx]
verificaiton_command = ["ls", generation_finished_filepath]
plan.wait(
Expand All @@ -221,7 +229,6 @@ def generate_cl_valdiator_keystores_in_parallel(plan, mnemonic, participants):
service_name = service_names[idx]
output_dirpath = all_output_dirpaths[idx]

running_total_validator_count += participant.validator_count
padded_idx = zfill_custom(idx + 1, len(str(len(participants))))
keystore_start_index = running_total_validator_count
running_total_validator_count += participant.validator_count
Expand Down

0 comments on commit 18b141e

Please sign in to comment.