diff --git a/README.md b/README.md index ebf83ebd1..f92ecd7bf 100644 --- a/README.md +++ b/README.md @@ -220,7 +220,7 @@ participants: # Resource management for el containers # CPU is milicores # RAM is in MB - # Defaults are set per client + # Defaults to 0, which results in no resource limits el_min_cpu: 0 el_max_cpu: 0 el_min_mem: 0 @@ -278,7 +278,7 @@ participants: # Resource management for cl containers # CPU is milicores # RAM is in MB - # Defaults are set per client + # Defaults to 0, which results in no resource limits cl_min_cpu: 0 cl_max_cpu: 0 cl_min_mem: 0 @@ -340,7 +340,7 @@ participants: # Resource management for vc containers # CPU is milicores # RAM is in MB - # Defaults are set per client + # Defaults to 0, which results in no resource limits vc_min_cpu: 0 vc_max_cpu: 0 vc_min_mem: 0 diff --git a/src/cl/cl_launcher.star b/src/cl/cl_launcher.star index ef16e2ba0..69fd5ee91 100644 --- a/src/cl/cl_launcher.star +++ b/src/cl/cl_launcher.star @@ -95,7 +95,7 @@ def launch( or constants.NETWORK_NAME.shadowfork in network_params.network else None ) - + network_name = shared_utils.get_network_name(network_params.network) for index, participant in enumerate(participants): cl_type = participant.cl_type el_type = participant.el_type @@ -104,6 +104,26 @@ def launch( global_node_selectors, ) + tolerations = input_parser.get_client_tolerations( + participant.cl_tolerations, participant.tolerations, global_tolerations + ) + + ( + cl_min_cpu, + cl_max_cpu, + cl_min_mem, + cl_max_mem, + cl_volume_size, + ) = shared_utils.get_cpu_mem_resource_limits( + participant.cl_min_cpu, + participant.cl_max_cpu, + participant.cl_min_mem, + participant.cl_max_mem, + participant.cl_volume_size, + network_name, + participant.cl_type, + ) + if cl_type not in cl_launchers: fail( "Unsupported launcher '{0}', need one of '{1}'".format( @@ -158,10 +178,10 @@ def launch( el_context, full_name, new_cl_node_validator_keystores, - participant.cl_min_cpu, - participant.cl_max_cpu, - participant.cl_min_mem, - participant.cl_max_mem, + cl_min_cpu, + cl_max_cpu, + cl_min_mem, + cl_max_mem, participant.snooper_enabled, snooper_engine_context, participant.blobber_enabled, @@ -170,10 +190,8 @@ def launch( participant.cl_extra_env_vars, participant.cl_extra_labels, persistent, - participant.cl_volume_size, - participant.cl_tolerations, - participant.tolerations, - global_tolerations, + cl_volume_size, + tolerations, node_selectors, participant.use_separate_vc, participant.keymanager_enabled, @@ -195,10 +213,10 @@ def launch( el_context, full_name, new_cl_node_validator_keystores, - participant.cl_min_cpu, - participant.cl_max_cpu, - participant.cl_min_mem, - participant.cl_max_mem, + cl_min_cpu, + cl_max_cpu, + cl_min_mem, + cl_max_mem, participant.snooper_enabled, snooper_engine_context, participant.blobber_enabled, @@ -207,10 +225,8 @@ def launch( participant.cl_extra_env_vars, participant.cl_extra_labels, persistent, - participant.cl_volume_size, - participant.cl_tolerations, - participant.tolerations, - global_tolerations, + cl_volume_size, + tolerations, node_selectors, participant.use_separate_vc, participant.keymanager_enabled, diff --git a/src/cl/grandine/grandine_launcher.star b/src/cl/grandine/grandine_launcher.star index c5dbae4de..d0305bb51 100644 --- a/src/cl/grandine/grandine_launcher.star +++ b/src/cl/grandine/grandine_launcher.star @@ -15,10 +15,6 @@ BEACON_DISCOVERY_PORT_NUM = 9000 BEACON_HTTP_PORT_NUM = 4000 BEACON_METRICS_PORT_NUM = 8008 -# The min/max CPU/memory that the beacon node can use -BEACON_MIN_CPU = 50 -BEACON_MIN_MEMORY = 1024 - BEACON_METRICS_PATH = "/metrics" MIN_PEERS = 1 @@ -58,9 +54,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -74,33 +68,8 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - extra_params = [param for param in extra_params] - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["grandine_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["grandine_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["grandine_volume_size"] - ) - config = get_beacon_config( plan, launcher.el_cl_genesis_data, @@ -386,33 +355,42 @@ def get_beacon_config( persistent_key="data-{0}".format(service_name), size=cl_volume_size, ) - - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.grandine, constants.CLIENT_TYPES.cl, image, el_context.client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + "user": User(uid=0, gid=0), + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_grandine_launcher( diff --git a/src/cl/lighthouse/lighthouse_launcher.star b/src/cl/lighthouse/lighthouse_launcher.star index 158763409..b27511a02 100644 --- a/src/cl/lighthouse/lighthouse_launcher.star +++ b/src/cl/lighthouse/lighthouse_launcher.star @@ -60,9 +60,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -77,31 +75,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["lighthouse_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["lighthouse_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["lighthouse_volume_size"] - ) - # Launch Beacon node beacon_config = get_beacon_config( plan, @@ -374,31 +347,41 @@ def get_beacon_config( ) env = {RUST_BACKTRACE_ENVVAR_NAME: RUST_FULL_BACKTRACE_KEYWORD} env.update(extra_env_vars) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - files=files, - env_vars=env, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": env, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.lighthouse, constants.CLIENT_TYPES.cl, image, el_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_lighthouse_launcher(el_cl_genesis_data, jwt_file, network_params): diff --git a/src/cl/lodestar/lodestar_launcher.star b/src/cl/lodestar/lodestar_launcher.star index 85c607c3b..8bfea661a 100644 --- a/src/cl/lodestar/lodestar_launcher.star +++ b/src/cl/lodestar/lodestar_launcher.star @@ -15,10 +15,6 @@ BEACON_DISCOVERY_PORT_NUM = 9000 BEACON_HTTP_PORT_NUM = 4000 BEACON_METRICS_PORT_NUM = 8008 -# The min/max CPU/memory that the beacon node can use -BEACON_MIN_CPU = 50 -BEACON_MIN_MEMORY = 256 - METRICS_PATH = "/metrics" VERBOSITY_LEVELS = { @@ -54,9 +50,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -70,31 +64,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["lodestar_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["lodestar_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["lodestar_volume_size"] - ) - # Launch Beacon node beacon_config = get_beacon_config( plan, @@ -368,31 +337,41 @@ def get_beacon_config( if preset == "minimal": extra_env_vars["LODESTAR_PRESET"] = "minimal" - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.lodestar, constants.CLIENT_TYPES.cl, image, el_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_lodestar_launcher(el_cl_genesis_data, jwt_file, network_params): diff --git a/src/cl/nimbus/nimbus_launcher.star b/src/cl/nimbus/nimbus_launcher.star index 72804ef49..3705565a2 100644 --- a/src/cl/nimbus/nimbus_launcher.star +++ b/src/cl/nimbus/nimbus_launcher.star @@ -70,9 +70,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -87,31 +85,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nimbus_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nimbus_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["nimbus_volume_size"] - ) - beacon_config = get_beacon_config( plan, launcher.el_cl_genesis_data, @@ -365,32 +338,42 @@ def get_beacon_config( size=cl_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.nimbus, constants.CLIENT_TYPES.cl, image, el_context.client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + "user": User(uid=0, gid=0), + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_nimbus_launcher(el_cl_genesis_data, jwt_file, network_params, keymanager_file): diff --git a/src/cl/prysm/prysm_launcher.star b/src/cl/prysm/prysm_launcher.star index 861284b7c..d3bcb6ef7 100644 --- a/src/cl/prysm/prysm_launcher.star +++ b/src/cl/prysm/prysm_launcher.star @@ -17,10 +17,6 @@ HTTP_PORT_NUM = 3500 BEACON_MONITORING_PORT_NUM = 8080 PROFILING_PORT_NUM = 6060 -# The min/max CPU/memory that the beacon node can use -BEACON_MIN_CPU = 100 -BEACON_MIN_MEMORY = 256 - METRICS_PATH = "/metrics" MIN_PEERS = 1 @@ -58,9 +54,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -74,31 +68,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["prysm_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["prysm_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["prysm_volume_size"] - ) - beacon_config = get_beacon_config( plan, launcher.el_cl_genesis_data, @@ -359,31 +328,41 @@ def get_beacon_config( size=cl_volume_size, ) - return ServiceConfig( - image=beacon_image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": beacon_image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.prysm, constants.CLIENT_TYPES.cl, beacon_image, el_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_prysm_launcher( diff --git a/src/cl/teku/teku_launcher.star b/src/cl/teku/teku_launcher.star index 7140f423f..d30c33a47 100644 --- a/src/cl/teku/teku_launcher.star +++ b/src/cl/teku/teku_launcher.star @@ -18,10 +18,6 @@ BEACON_DISCOVERY_PORT_NUM = 9000 BEACON_HTTP_PORT_NUM = 4000 BEACON_METRICS_PORT_NUM = 8008 -# The min/max CPU/memory that the beacon node can use -BEACON_MIN_CPU = 50 -BEACON_MIN_MEMORY = 1024 - BEACON_METRICS_PATH = "/metrics" MIN_PEERS = 1 @@ -61,9 +57,7 @@ def launch( extra_labels, persistent, cl_volume_size, - cl_tolerations, - participant_tolerations, - global_tolerations, + tolerations, node_selectors, use_separate_vc, keymanager_enabled, @@ -77,33 +71,8 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - tolerations = input_parser.get_client_tolerations( - cl_tolerations, participant_tolerations, global_tolerations - ) - extra_params = [param for param in extra_params] - network_name = shared_utils.get_network_name(launcher.network) - - cl_min_cpu = int(cl_min_cpu) if int(cl_min_cpu) > 0 else BEACON_MIN_CPU - cl_max_cpu = ( - int(cl_max_cpu) - if int(cl_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["teku_max_cpu"] - ) - cl_min_mem = int(cl_min_mem) if int(cl_min_mem) > 0 else BEACON_MIN_MEMORY - cl_max_mem = ( - int(cl_max_mem) - if int(cl_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["teku_max_mem"] - ) - - cl_volume_size = ( - int(cl_volume_size) - if int(cl_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["teku_volume_size"] - ) - config = get_beacon_config( plan, launcher.el_cl_genesis_data, @@ -410,32 +379,42 @@ def get_beacon_config( size=cl_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - ready_conditions=cl_node_ready_conditions.get_ready_conditions( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "ready_conditions": cl_node_ready_conditions.get_ready_conditions( constants.HTTP_PORT_ID ), - min_cpu=cl_min_cpu, - max_cpu=cl_max_cpu, - min_memory=cl_min_mem, - max_memory=cl_max_mem, - labels=shared_utils.label_maker( + "labels": shared_utils.label_maker( constants.CL_TYPE.teku, constants.CLIENT_TYPES.cl, image, el_context.client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + "user": User(uid=0, gid=0), + } + + if cl_min_cpu > 0: + config_args["min_cpu"] = cl_min_cpu + + if cl_max_cpu > 0: + config_args["max_cpu"] = cl_max_cpu + + if cl_min_mem > 0: + config_args["min_memory"] = cl_min_mem + + if cl_max_mem > 0: + config_args["max_memory"] = cl_max_mem + + return ServiceConfig(**config_args) def new_teku_launcher(el_cl_genesis_data, jwt_file, network_params, keymanager_file): diff --git a/src/el/besu/besu_launcher.star b/src/el/besu/besu_launcher.star index ea82fb69c..64c637c8e 100644 --- a/src/el/besu/besu_launcher.star +++ b/src/el/besu/besu_launcher.star @@ -17,12 +17,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_HTTP_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MAX_CPU = 1000 -EXECUTION_MIN_MEMORY = 512 -EXECUTION_MAX_MEMORY = 2048 - JAVA_OPTS = {"JAVA_OPTS": "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n"} ENTRYPOINT_ARGS = ["sh", "-c"] @@ -62,27 +56,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["besu_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["besu_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["besu_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -270,30 +243,37 @@ def get_config( persistent_key="data-{0}".format(service_name), size=el_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=[cmd_str], - files=files, - env_vars=extra_env_vars, - entrypoint=ENTRYPOINT_ARGS, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - labels=shared_utils.label_maker( + + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": [cmd_str], + "files": files, + "entrypoint": ENTRYPOINT_ARGS, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.besu, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "user": User(uid=0, gid=0), + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_besu_launcher(el_cl_genesis_data, jwt_file, network): diff --git a/src/el/el_launcher.star b/src/el/el_launcher.star index e78c7daff..c27402d85 100644 --- a/src/el/el_launcher.star +++ b/src/el/el_launcher.star @@ -36,16 +36,6 @@ def launch( ), "launch_method": geth.launch, }, - constants.EL_TYPE.geth_builder: { - "launcher": geth.new_geth_launcher( - el_cl_data, - jwt_file, - network_params.network, - network_id, - el_cl_data.prague_time, - ), - "launch_method": geth.launch, - }, constants.EL_TYPE.besu: { "launcher": besu.new_besu_launcher( el_cl_data, @@ -108,7 +98,7 @@ def launch( } all_el_contexts = [] - + network_name = shared_utils.get_network_name(network_params.network) for index, participant in enumerate(participants): cl_type = participant.cl_type el_type = participant.el_type @@ -119,6 +109,23 @@ def launch( tolerations = input_parser.get_client_tolerations( participant.el_tolerations, participant.tolerations, global_tolerations ) + + ( + el_min_cpu, + el_max_cpu, + el_min_mem, + el_max_mem, + el_volume_size, + ) = shared_utils.get_cpu_mem_resource_limits( + participant.el_min_cpu, + participant.el_max_cpu, + participant.el_min_mem, + participant.el_max_mem, + participant.el_volume_size, + network_name, + participant.el_type, + ) + if el_type not in el_launchers: fail( "Unsupported launcher '{0}', need one of '{1}'".format( @@ -144,15 +151,15 @@ def launch( participant.el_log_level, global_log_level, all_el_contexts, - participant.el_min_cpu, - participant.el_max_cpu, - participant.el_min_mem, - participant.el_max_mem, + el_min_cpu, + el_max_cpu, + el_min_mem, + el_max_mem, participant.el_extra_params, participant.el_extra_env_vars, participant.el_extra_labels, persistent, - participant.el_volume_size, + el_volume_size, tolerations, node_selectors, port_publisher, diff --git a/src/el/erigon/erigon_launcher.star b/src/el/erigon/erigon_launcher.star index b0191a190..06c27a874 100644 --- a/src/el/erigon/erigon_launcher.star +++ b/src/el/erigon/erigon_launcher.star @@ -16,10 +16,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MIN_MEMORY = 512 - ENTRYPOINT_ARGS = ["sh", "-c"] VERBOSITY_LEVELS = { @@ -57,27 +53,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["erigon_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["erigon_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["erigon_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -265,30 +240,36 @@ def get_config( else: command_arg_str = " ".join(cmd) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=[command_arg_str], - files=files, - entrypoint=ENTRYPOINT_ARGS, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": [command_arg_str], + "files": files, + "entrypoint": ENTRYPOINT_ARGS, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.erigon, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + "user": User(uid=0, gid=0), + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_erigon_launcher(el_cl_genesis_data, jwt_file, network, networkid, prague_time): diff --git a/src/el/ethereumjs/ethereumjs_launcher.star b/src/el/ethereumjs/ethereumjs_launcher.star index 71854ae96..74534fccd 100644 --- a/src/el/ethereumjs/ethereumjs_launcher.star +++ b/src/el/ethereumjs/ethereumjs_launcher.star @@ -13,10 +13,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MIN_MEMORY = 256 - METRICS_PATH = "/metrics" # The dirpath of the execution data directory on the client container @@ -59,27 +55,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["ethereumjs_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["ethereumjs_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["ethereumjs_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -253,29 +228,36 @@ def get_config( persistent_key="data-{0}".format(service_name), size=el_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - files=files, - entrypoint=ENTRYPOINT_ARGS, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( + + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "entrypoint": ENTRYPOINT_ARGS, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.ethereumjs, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_ethereumjs_launcher(el_cl_genesis_data, jwt_file, network): diff --git a/src/el/geth/geth_launcher.star b/src/el/geth/geth_launcher.star index 9a739d95b..36ca0c4f1 100644 --- a/src/el/geth/geth_launcher.star +++ b/src/el/geth/geth_launcher.star @@ -15,10 +15,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 300 -EXECUTION_MIN_MEMORY = 512 - # TODO(old) Scale this dynamically based on CPUs available and Geth nodes mining NUM_MINING_THREADS = 1 @@ -68,27 +64,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["geth_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["geth_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["geth_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -348,29 +323,35 @@ def get_config( persistent_key="data-{0}".format(service_name), size=el_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=[command_str], - files=files, - entrypoint=ENTRYPOINT_ARGS, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": [command_str], + "files": files, + "entrypoint": ENTRYPOINT_ARGS, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.geth, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_geth_launcher( diff --git a/src/el/nethermind/nethermind_launcher.star b/src/el/nethermind/nethermind_launcher.star index 855057b9c..cb1525d23 100644 --- a/src/el/nethermind/nethermind_launcher.star +++ b/src/el/nethermind/nethermind_launcher.star @@ -17,10 +17,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MIN_MEMORY = 512 - VERBOSITY_LEVELS = { constants.GLOBAL_LOG_LEVEL.error: "ERROR", constants.GLOBAL_LOG_LEVEL.warn: "WARN", @@ -56,27 +52,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nethermind_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nethermind_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["nethermind_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -262,28 +237,34 @@ def get_config( size=el_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.nethermind, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_nethermind_launcher(el_cl_genesis_data, jwt_file, network): diff --git a/src/el/nimbus-eth1/nimbus_launcher.star b/src/el/nimbus-eth1/nimbus_launcher.star index 20b5ec3f4..70bf762c6 100644 --- a/src/el/nimbus-eth1/nimbus_launcher.star +++ b/src/el/nimbus-eth1/nimbus_launcher.star @@ -11,10 +11,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MIN_MEMORY = 256 - # Paths METRICS_PATH = "/metrics" @@ -57,27 +53,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nimbus_eth1_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["nimbus_eth1_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["nimbus_eth1_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -248,28 +223,34 @@ def get_config( size=el_volume_size, ) - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=cmd, - files=files, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( constants.EL_TYPE.nimbus, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_nimbus_launcher(el_cl_genesis_data, jwt_file, network): diff --git a/src/el/reth/reth_launcher.star b/src/el/reth/reth_launcher.star index df45a062e..8469aaead 100644 --- a/src/el/reth/reth_launcher.star +++ b/src/el/reth/reth_launcher.star @@ -13,10 +13,6 @@ DISCOVERY_PORT_NUM = 30303 ENGINE_RPC_PORT_NUM = 8551 METRICS_PORT_NUM = 9001 -# The min/max CPU/memory that the execution node can use -EXECUTION_MIN_CPU = 100 -EXECUTION_MIN_MEMORY = 256 - # Paths METRICS_PATH = "/metrics" @@ -61,27 +57,6 @@ def launch( participant_log_level, global_log_level, VERBOSITY_LEVELS ) - network_name = shared_utils.get_network_name(launcher.network) - - el_min_cpu = int(el_min_cpu) if int(el_min_cpu) > 0 else EXECUTION_MIN_CPU - el_max_cpu = ( - int(el_max_cpu) - if int(el_max_cpu) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["reth_max_cpu"] - ) - el_min_mem = int(el_min_mem) if int(el_min_mem) > 0 else EXECUTION_MIN_MEMORY - el_max_mem = ( - int(el_max_mem) - if int(el_max_mem) > 0 - else constants.RAM_CPU_OVERRIDES[network_name]["reth_max_mem"] - ) - - el_volume_size = ( - el_volume_size - if int(el_volume_size) > 0 - else constants.VOLUME_SIZE[network_name]["reth_volume_size"] - ) - cl_client_name = service_name.split("-")[3] config = get_config( @@ -266,29 +241,35 @@ def get_config( mev_rs_builder.MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE ] = mev_rs_builder.MEV_BUILDER_FILES_ARTIFACT_NAME - return ServiceConfig( - image=image, - ports=used_ports, - public_ports=public_ports, - cmd=[cmd_str], - files=files, - entrypoint=ENTRYPOINT_ARGS, - private_ip_address_placeholder=constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, - min_cpu=el_min_cpu, - max_cpu=el_max_cpu, - min_memory=el_min_mem, - max_memory=el_max_mem, - env_vars=extra_env_vars, - labels=shared_utils.label_maker( - constants.EL_TYPE.reth, + config_args = { + "image": image, + "ports": used_ports, + "public_ports": public_ports, + "cmd": [cmd_str], + "files": files, + "entrypoint": ENTRYPOINT_ARGS, + "private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( + constants.EL_TYPE.geth, constants.CLIENT_TYPES.el, image, cl_client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if el_min_cpu > 0: + config_args["min_cpu"] = el_min_cpu + if el_max_cpu > 0: + config_args["max_cpu"] = el_max_cpu + if el_min_mem > 0: + config_args["min_memory"] = el_min_mem + if el_max_mem > 0: + config_args["max_memory"] = el_max_mem + return ServiceConfig(**config_args) def new_reth_launcher(el_cl_genesis_data, jwt_file, network, builder=False): diff --git a/src/package_io/constants.star b/src/package_io/constants.star index d2e9cd74f..2abbb587c 100644 --- a/src/package_io/constants.star +++ b/src/package_io/constants.star @@ -1,5 +1,4 @@ EL_TYPE = struct( - geth_builder="geth-builder", geth="geth", erigon="erigon", nethermind="nethermind", @@ -250,174 +249,3 @@ VOLUME_SIZE = { "grandine_volume_size": 1000, # 1GB }, } - -RAM_CPU_OVERRIDES = { - "mainnet": { - "geth_max_mem": 16384, # 16GB - "geth_max_cpu": 4000, # 4 cores - "erigon_max_mem": 16384, # 16GB - "erigon_max_cpu": 4000, # 4 cores - "nethermind_max_mem": 16384, # 16GB - "nethermind_max_cpu": 4000, # 4 cores - "besu_max_mem": 16384, # 16GB - "besu_max_cpu": 4000, # 4 cores - "reth_max_mem": 16384, # 16GB - "reth_max_cpu": 4000, # 4 cores - "ethereumjs_max_mem": 16384, # 16GB - "ethereumjs_max_cpu": 4000, # 4 cores - "nimbus_eth1_max_mem": 16384, # 16GB - "nimbus_eth1_max_cpu": 4000, # 4 cores - "prysm_max_mem": 16384, # 16GB - "prysm_max_cpu": 4000, # 4 cores - "lighthouse_max_mem": 16384, # 16GB - "lighthouse_max_cpu": 4000, # 4 cores - "teku_max_mem": 16384, # 16GB - "teku_max_cpu": 4000, # 4 cores - "nimbus_max_mem": 16384, # 16GB - "nimbus_max_cpu": 4000, # 4 cores - "lodestar_max_mem": 16384, # 16GB - "lodestar_max_cpu": 4000, # 4 cores - "grandine_max_mem": 16384, # 16GB - "grandine_max_cpu": 4000, # 4 cores - }, - "sepolia": { - "geth_max_mem": 4096, # 4GB - "geth_max_cpu": 1000, # 1 core - "erigon_max_mem": 4096, # 4GB - "erigon_max_cpu": 1000, # 1 core - "nethermind_max_mem": 4096, # 4GB - "nethermind_max_cpu": 1000, # 1 core - "besu_max_mem": 4096, # 4GB - "besu_max_cpu": 1000, # 1 core - "reth_max_mem": 4096, # 4GB - "reth_max_cpu": 1000, # 1 core - "ethereumjs_max_mem": 4096, # 4GB - "ethereumjs_max_cpu": 1000, # 1 core - "nimbus_eth1_max_mem": 4096, # 4GB - "nimbus_eth1_max_cpu": 1000, # 1 core - "prysm_max_mem": 4096, # 4GB - "prysm_max_cpu": 1000, # 1 core - "lighthouse_max_mem": 4096, # 4GB - "lighthouse_max_cpu": 1000, # 1 core - "teku_max_mem": 4096, # 4GB - "teku_max_cpu": 1000, # 1 core - "nimbus_max_mem": 4096, # 4GB - "nimbus_max_cpu": 1000, # 1 core - "lodestar_max_mem": 4096, # 4GB - "lodestar_max_cpu": 1000, # 1 core - "grandine_max_mem": 4096, # 4GB - "grandine_max_cpu": 1000, # 1 core - }, - "holesky": { - "geth_max_mem": 8192, # 8GB - "geth_max_cpu": 2000, # 2 cores - "erigon_max_mem": 8192, # 8GB - "erigon_max_cpu": 2000, # 2 cores - "nethermind_max_mem": 8192, # 8GB - "nethermind_max_cpu": 2000, # 2 cores - "besu_max_mem": 8192, # 8GB - "besu_max_cpu": 2000, # 2 cores - "reth_max_mem": 8192, # 8GB - "reth_max_cpu": 2000, # 2 cores - "ethereumjs_max_mem": 8192, # 8GB - "ethereumjs_max_cpu": 2000, # 2 cores - "nimbus_eth1_max_mem": 8192, # 8GB - "nimbus_eth1_max_cpu": 2000, # 2 cores - "prysm_max_mem": 8192, # 8GB - "prysm_max_cpu": 2000, # 2 cores - "lighthouse_max_mem": 8192, # 8GB - "lighthouse_max_cpu": 2000, # 2 cores - "teku_max_mem": 8192, # 8GB - "teku_max_cpu": 2000, # 2 cores - "nimbus_max_mem": 8192, # 8GB - "nimbus_max_cpu": 2000, # 2 cores - "lodestar_max_mem": 8192, # 8GB - "lodestar_max_cpu": 2000, # 2 cores - "grandine_max_mem": 8192, # 8GB - "grandine_max_cpu": 2000, # 2 cores - }, - "devnets": { - "geth_max_mem": 4096, # 4GB - "geth_max_cpu": 1000, # 1 core - "erigon_max_mem": 4096, # 4GB - "erigon_max_cpu": 1000, # 1 core - "nethermind_max_mem": 4096, # 4GB - "nethermind_max_cpu": 1000, # 1 core - "besu_max_mem": 4096, # 4GB - "besu_max_cpu": 1000, # 1 core - "reth_max_mem": 4096, # 4GB - "reth_max_cpu": 1000, # 1 core - "ethereumjs_max_mem": 4096, # 4GB - "ethereumjs_max_cpu": 1000, # 1 core - "nimbus_eth1_max_mem": 4096, # 4GB - "nimbus_eth1_max_cpu": 1000, # 1 core - "prysm_max_mem": 4096, # 4GB - "prysm_max_cpu": 1000, # 1 core - "lighthouse_max_mem": 4096, # 4GB - "lighthouse_max_cpu": 1000, # 1 core - "teku_max_mem": 4096, # 4GB - "teku_max_cpu": 1000, # 1 core - "nimbus_max_mem": 4096, # 4GB - "nimbus_max_cpu": 1000, # 1 core - "lodestar_max_mem": 4096, # 4GB - "lodestar_max_cpu": 1000, # 1 core - "grandine_max_mem": 4096, # 4GB - "grandine_max_cpu": 1000, # 1 core - }, - "ephemery": { - "geth_max_mem": 1024, # 1GB - "geth_max_cpu": 1000, # 1 core - "erigon_max_mem": 1024, # 1GB - "erigon_max_cpu": 1000, # 1 core - "nethermind_max_mem": 1024, # 1GB - "nethermind_max_cpu": 1000, # 1 core - "besu_max_mem": 1024, # 1GB - "besu_max_cpu": 1000, # 1 core - "reth_max_mem": 1024, # 1GB - "reth_max_cpu": 1000, # 1 core - "ethereumjs_max_mem": 1024, # 1GB - "ethereumjs_max_cpu": 1000, # 1 core - "nimbus_eth1_max_mem": 1024, # 1GB - "nimbus_eth1_max_cpu": 1000, # 1 core - "prysm_max_mem": 1024, # 1GB - "prysm_max_cpu": 1000, # 1 core - "lighthouse_max_mem": 1024, # 1GB - "lighthouse_max_cpu": 1000, # 1 core - "teku_max_mem": 1024, # 1GB - "teku_max_cpu": 1000, # 1 core - "nimbus_max_mem": 1024, # 1GB - "nimbus_max_cpu": 1000, # 1 core - "lodestar_max_mem": 1024, # 1GB - "lodestar_max_cpu": 1000, # 1 core - "grandine_max_mem": 1024, # 1GB - "grandine_max_cpu": 1000, # 1 core - }, - "kurtosis": { - "geth_max_mem": 1024, # 1GB - "geth_max_cpu": 1000, # 1 core - "erigon_max_mem": 1024, # 1GB - "erigon_max_cpu": 1000, # 1 core - "nethermind_max_mem": 2048, # 2GB - "nethermind_max_cpu": 1000, # 1 core - "besu_max_mem": 1024, # 1GB - "besu_max_cpu": 1000, # 1 core - "reth_max_mem": 1024, # 1GB - "reth_max_cpu": 1000, # 1 core - "ethereumjs_max_mem": 1024, # 1GB - "ethereumjs_max_cpu": 1000, # 1 core - "nimbus_eth1_max_mem": 1024, # 1GB - "nimbus_eth1_max_cpu": 1000, # 1 core - "prysm_max_mem": 1024, # 1GB - "prysm_max_cpu": 1000, # 1 core - "lighthouse_max_mem": 1024, # 1GB - "lighthouse_max_cpu": 1000, # 1 core - "teku_max_mem": 2048, # 2GB - "teku_max_cpu": 1000, # 1 core - "nimbus_max_mem": 1024, # 1GB - "nimbus_max_cpu": 1000, # 1 core - "lodestar_max_mem": 2048, # 2GB - "lodestar_max_cpu": 1000, # 1 core - "grandine_max_mem": 2048, # 2GB - "grandine_max_cpu": 1000, # 1 core - }, -} diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 34dcd665f..b373b277e 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -1119,7 +1119,7 @@ def enrich_mev_extra_params(parsed_arguments_dict, mev_prefix, mev_port, mev_typ ) if mev_type == constants.FLASHBOTS_MEV_TYPE: mev_participant = default_participant() - mev_participant["el_type"] = "geth-builder" + mev_participant["el_type"] = "geth" mev_participant.update( { "el_image": parsed_arguments_dict["mev_params"]["mev_builder_image"], diff --git a/src/participant_network.star b/src/participant_network.star index fabfd4b85..b519dc8d8 100644 --- a/src/participant_network.star +++ b/src/participant_network.star @@ -343,7 +343,6 @@ def launch_participant_network( service_name="vc-{0}".format(full_name), vc_type=vc_type, image=participant.vc_image, - participant_log_level=participant.vc_log_level, global_log_level=global_log_level, cl_context=cl_context, el_context=el_context, @@ -351,20 +350,11 @@ def launch_participant_network( snooper_enabled=participant.snooper_enabled, snooper_beacon_context=snooper_beacon_context, node_keystore_files=vc_keystores, - vc_min_cpu=participant.vc_min_cpu, - vc_max_cpu=participant.vc_max_cpu, - vc_min_mem=participant.vc_min_mem, - vc_max_mem=participant.vc_max_mem, - extra_params=participant.vc_extra_params, - extra_env_vars=participant.vc_extra_env_vars, - extra_labels=participant.vc_extra_labels, + participant=participant, prysm_password_relative_filepath=prysm_password_relative_filepath, prysm_password_artifact_uuid=prysm_password_artifact_uuid, - vc_tolerations=participant.vc_tolerations, - participant_tolerations=participant.tolerations, global_tolerations=global_tolerations, node_selectors=node_selectors, - keymanager_enabled=participant.keymanager_enabled, preset=network_params.preset, network=network_params.network, electra_fork_epoch=network_params.electra_fork_epoch, diff --git a/src/shared_utils/shared_utils.star b/src/shared_utils/shared_utils.star index 435df113e..7742d643d 100644 --- a/src/shared_utils/shared_utils.star +++ b/src/shared_utils/shared_utils.star @@ -318,3 +318,18 @@ def get_additional_service_standard_public_port( ) public_ports = get_port_specs({port_id: public_ports_for_component[port_index]}) return public_ports + + +def get_cpu_mem_resource_limits( + min_cpu, max_cpu, min_mem, max_mem, volume_size, network_name, client_type +): + min_cpu = int(min_cpu) if int(min_cpu) > 0 else 0 + max_cpu = int(max_cpu) if int(max_cpu) > 0 else 0 + min_mem = int(min_mem) if int(min_mem) > 0 else 0 + max_mem = int(max_mem) if int(max_mem) > 0 else 0 + volume_size = ( + int(volume_size) + if int(volume_size) > 0 + else constants.VOLUME_SIZE[network_name][client_type + "_volume_size"] + ) + return min_cpu, max_cpu, min_mem, max_mem, volume_size diff --git a/src/vc/lighthouse.star b/src/vc/lighthouse.star index a4aa61ceb..b3361af9e 100644 --- a/src/vc/lighthouse.star +++ b/src/vc/lighthouse.star @@ -118,24 +118,34 @@ def get_config( shared_utils.get_port_specs(public_keymanager_port_assignment) ) - return ServiceConfig( - image=image, - ports=ports, - public_ports=public_ports, - cmd=cmd, - env_vars=env, - files=files, - min_cpu=vc_min_cpu, - max_cpu=vc_max_cpu, - min_memory=vc_min_mem, - max_memory=vc_max_mem, - labels=shared_utils.label_maker( - constants.VC_TYPE.lighthouse, + config_args = { + "image": image, + "ports": ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": env, + "labels": shared_utils.label_maker( + constants.CL_TYPE.lighthouse, constants.CLIENT_TYPES.validator, image, cl_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if vc_min_cpu > 0: + config_args["min_cpu"] = vc_min_cpu + + if vc_max_cpu > 0: + config_args["max_cpu"] = vc_max_cpu + + if vc_min_mem > 0: + config_args["min_memory"] = vc_min_mem + + if vc_max_mem > 0: + config_args["max_memory"] = vc_max_mem + + return ServiceConfig(**config_args) diff --git a/src/vc/lodestar.star b/src/vc/lodestar.star index 5b7ba8a91..29204b4ca 100644 --- a/src/vc/lodestar.star +++ b/src/vc/lodestar.star @@ -117,24 +117,34 @@ def get_config( if preset == "minimal": extra_env_vars["LODESTAR_PRESET"] = "minimal" - return ServiceConfig( - image=image, - ports=ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - min_cpu=vc_min_cpu, - max_cpu=vc_max_cpu, - min_memory=vc_min_mem, - max_memory=vc_max_mem, - labels=shared_utils.label_maker( - constants.VC_TYPE.lodestar, + config_args = { + "image": image, + "ports": ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( + constants.CL_TYPE.lodestar, constants.CLIENT_TYPES.validator, image, cl_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if vc_min_cpu > 0: + config_args["min_cpu"] = vc_min_cpu + + if vc_max_cpu > 0: + config_args["max_cpu"] = vc_max_cpu + + if vc_min_mem > 0: + config_args["min_memory"] = vc_min_mem + + if vc_max_mem > 0: + config_args["max_memory"] = vc_max_mem + + return ServiceConfig(**config_args) diff --git a/src/vc/nimbus.star b/src/vc/nimbus.star index 30ff00dab..e6b9bd8ac 100644 --- a/src/vc/nimbus.star +++ b/src/vc/nimbus.star @@ -90,25 +90,35 @@ def get_config( shared_utils.get_port_specs(public_keymanager_port_assignment) ) - return ServiceConfig( - image=image, - ports=ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - min_cpu=vc_min_cpu, - max_cpu=vc_max_cpu, - min_memory=vc_min_mem, - max_memory=vc_max_mem, - labels=shared_utils.label_maker( - constants.VC_TYPE.nimbus, + config_args = { + "image": image, + "ports": ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( + constants.CL_TYPE.nimbus, constants.CLIENT_TYPES.validator, image, cl_context.client_name, extra_labels, ), - user=User(uid=0, gid=0), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + "user": User(uid=0, gid=0), + } + + if vc_min_cpu > 0: + config_args["min_cpu"] = vc_min_cpu + + if vc_max_cpu > 0: + config_args["max_cpu"] = vc_max_cpu + + if vc_min_mem > 0: + config_args["min_memory"] = vc_min_mem + + if vc_max_mem > 0: + config_args["max_memory"] = vc_max_mem + + return ServiceConfig(**config_args) diff --git a/src/vc/prysm.star b/src/vc/prysm.star index 9d6c43b31..2fdd63a12 100644 --- a/src/vc/prysm.star +++ b/src/vc/prysm.star @@ -110,24 +110,34 @@ def get_config( ) public_ports.update(shared_utils.get_port_specs(public_gprc_port_assignment)) - return ServiceConfig( - image=image, - ports=ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - min_cpu=vc_min_cpu, - max_cpu=vc_max_cpu, - min_memory=vc_min_mem, - max_memory=vc_max_mem, - labels=shared_utils.label_maker( - constants.VC_TYPE.prysm, + config_args = { + "image": image, + "ports": ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( + constants.CL_TYPE.prysm, constants.CLIENT_TYPES.validator, image, cl_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if vc_min_cpu > 0: + config_args["min_cpu"] = vc_min_cpu + + if vc_max_cpu > 0: + config_args["max_cpu"] = vc_max_cpu + + if vc_min_mem > 0: + config_args["min_memory"] = vc_min_mem + + if vc_max_mem > 0: + config_args["max_memory"] = vc_max_mem + + return ServiceConfig(**config_args) diff --git a/src/vc/teku.star b/src/vc/teku.star index 99e9bf388..df8700b3c 100644 --- a/src/vc/teku.star +++ b/src/vc/teku.star @@ -101,24 +101,34 @@ def get_config( shared_utils.get_port_specs(public_keymanager_port_assignment) ) - return ServiceConfig( - image=image, - ports=ports, - public_ports=public_ports, - cmd=cmd, - env_vars=extra_env_vars, - files=files, - min_cpu=vc_min_cpu, - max_cpu=vc_max_cpu, - min_memory=vc_min_mem, - max_memory=vc_max_mem, - labels=shared_utils.label_maker( - constants.VC_TYPE.teku, + config_args = { + "image": image, + "ports": ports, + "public_ports": public_ports, + "cmd": cmd, + "files": files, + "env_vars": extra_env_vars, + "labels": shared_utils.label_maker( + constants.CL_TYPE.teku, constants.CLIENT_TYPES.validator, image, cl_context.client_name, extra_labels, ), - tolerations=tolerations, - node_selectors=node_selectors, - ) + "tolerations": tolerations, + "node_selectors": node_selectors, + } + + if vc_min_cpu > 0: + config_args["min_cpu"] = vc_min_cpu + + if vc_max_cpu > 0: + config_args["max_cpu"] = vc_max_cpu + + if vc_min_mem > 0: + config_args["min_memory"] = vc_min_mem + + if vc_max_mem > 0: + config_args["max_memory"] = vc_max_mem + + return ServiceConfig(**config_args) diff --git a/src/vc/vc_launcher.star b/src/vc/vc_launcher.star index 3512b3442..328b35b35 100644 --- a/src/vc/vc_launcher.star +++ b/src/vc/vc_launcher.star @@ -9,12 +9,7 @@ nimbus = import_module("./nimbus.star") prysm = import_module("./prysm.star") teku = import_module("./teku.star") vc_shared = import_module("./shared.star") - -# The defaults for min/max CPU/memory that the validator client can use -MIN_CPU = 50 -MAX_CPU = 300 -MIN_MEMORY = 128 -MAX_MEMORY = 512 +shared_utils = import_module("../shared_utils/shared_utils.star") def launch( @@ -24,7 +19,6 @@ def launch( service_name, vc_type, image, - participant_log_level, global_log_level, cl_context, el_context, @@ -32,20 +26,11 @@ def launch( snooper_enabled, snooper_beacon_context, node_keystore_files, - vc_min_cpu, - vc_max_cpu, - vc_min_mem, - vc_max_mem, - extra_params, - extra_env_vars, - extra_labels, + participant, prysm_password_relative_filepath, prysm_password_artifact_uuid, - vc_tolerations, - participant_tolerations, global_tolerations, node_selectors, - keymanager_enabled, preset, network, # TODO: remove when deneb rebase is done electra_fork_epoch, # TODO: remove when deneb rebase is done @@ -56,7 +41,7 @@ def launch( return None tolerations = input_parser.get_client_tolerations( - vc_tolerations, participant_tolerations, global_tolerations + participant.vc_tolerations, participant.tolerations, global_tolerations ) if snooper_enabled: @@ -68,11 +53,27 @@ def launch( beacon_http_url = "{0}".format( cl_context.beacon_http_url, ) - vc_min_cpu = int(vc_min_cpu) if int(vc_min_cpu) > 0 else MIN_CPU - vc_max_cpu = int(vc_max_cpu) if int(vc_max_cpu) > 0 else MAX_CPU - vc_min_mem = int(vc_min_mem) if int(vc_min_mem) > 0 else MIN_MEMORY - vc_max_mem = int(vc_max_mem) if int(vc_max_mem) > 0 else MAX_MEMORY + ( + vc_min_cpu, + vc_max_cpu, + vc_min_mem, + vc_max_mem, + _, + ) = shared_utils.get_cpu_mem_resource_limits( + participant.vc_min_cpu, + participant.vc_max_cpu, + participant.vc_min_mem, + participant.vc_max_mem, + 0, + network, + vc_type, + ) + extra_params = participant.vc_extra_params + extra_env_vars = participant.vc_extra_env_vars + extra_labels = participant.vc_extra_labels + participant_log_level = participant.vc_log_level + keymanager_enabled = participant.keymanager_enabled if vc_type == constants.VC_TYPE.lighthouse: config = lighthouse.get_config( el_cl_genesis_data=launcher.el_cl_genesis_data,