From f9b638bc1c26be34fd3dd0ad6e4d59ee4ecd66c3 Mon Sep 17 00:00:00 2001 From: Anders Schwartz Date: Wed, 2 Aug 2023 16:43:04 -0400 Subject: [PATCH] feat: counting by summing each participant (#112) This PR changes the way we count the actual number of validators by summing `count`s for each participant and multiplying by the number of validator keys per node. Resolves https://github.com/kurtosis-tech/eth2-package/issues/111 Changelog picked up from commits here: feat: counting by summing each participant --- src/package_io/parse_input.star | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/package_io/parse_input.star b/src/package_io/parse_input.star index 14927e4b2..455bca452 100644 --- a/src/package_io/parse_input.star +++ b/src/package_io/parse_input.star @@ -45,6 +45,7 @@ def parse_input(input_args): participants.append(new_participant) result["participants"] = participants + total_participant_count = 0 # validation of the above defaults for index, participant in enumerate(result["participants"]): el_client_type = participant["el_client_type"] @@ -76,6 +77,8 @@ def parse_input(input_args): validator_extra_params = participant.get("validator_extra_params", []) participant["validator_extra_params"] = validator_extra_params + total_participant_count += participant["count"] + if result["network_params"]["network_id"].strip() == "": fail("network_id is empty or spaces it needs to be of non zero length") @@ -100,10 +103,13 @@ def parse_input(input_args): if result["network_params"]["deneb_fork_epoch"] == 0: fail("deneb_fork_epoch is 0 needs to be > 0 ") - required_num_validtors = 2 * result["network_params"]["slots_per_epoch"] - actual_num_validators = len(result["participants"]) * result["network_params"]["num_validator_keys_per_node"] - if required_num_validtors > actual_num_validators: - fail("required_num_validtors - {0} is greater than actual_num_validators - {1}".format(required_num_validtors, actual_num_validators)) + if total_participant_count < 1: + total_participant_count = 1 + + required_num_validators = 2 * result["network_params"]["slots_per_epoch"] + actual_num_validators = total_participant_count * result["network_params"]["num_validator_keys_per_node"] + if required_num_validators > actual_num_validators: + fail("required_num_validators - {0} is greater than actual_num_validators - {1}".format(required_num_validators, actual_num_validators)) # Remove if nethermind doesn't break as second node we already test above if its the first node if len(result["participants"]) >= 2 and result["participants"][1]["el_client_type"] == NETHERMIND_NODE_NAME: