Skip to content

Commit

Permalink
feat: enable one parameter supernode
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasbusa committed Sep 27, 2024
1 parent cb87a9a commit 77ef93c
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 408 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ participants:
cl_min_mem: 0
cl_max_mem: 0
# Whether to act as a supernode for the network
# Supernodes will subscribe to all subnet topics
# This flag should only be used with peerdas
# Defaults to false
supernode: false
# Whether to use a separate validator client attached to the CL client.
# Defaults to false for clients that can run both in one process (Teku, Nimbus)
use_separate_vc: true
Expand Down
1 change: 1 addition & 0 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ participants:
cl_max_cpu: 0
cl_min_mem: 0
cl_max_mem: 0
supernode: false
use_separate_vc: true
# Validator
vc_type: lighthouse
Expand Down
28 changes: 4 additions & 24 deletions src/cl/cl_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def launch(
el_cl_data,
jwt_file,
network_params,
prysm_password_relative_filepath,
prysm_password_artifact_uuid,
),
"launch_method": prysm.launch,
},
Expand Down Expand Up @@ -171,8 +169,7 @@ def launch(
plan,
cl_launcher,
cl_service_name,
participant.cl_image,
participant.cl_log_level,
participant,
global_log_level,
cl_context_BOOTNODE,
el_context,
Expand All @@ -182,19 +179,11 @@ def launch(
cl_max_cpu,
cl_min_mem,
cl_max_mem,
participant.snooper_enabled,
cl_volume_size,
snooper_engine_context,
participant.blobber_enabled,
participant.blobber_extra_params,
participant.cl_extra_params,
participant.cl_extra_env_vars,
participant.cl_extra_labels,
persistent,
cl_volume_size,
tolerations,
node_selectors,
participant.use_separate_vc,
participant.keymanager_enabled,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
Expand All @@ -206,8 +195,7 @@ def launch(
plan,
cl_launcher,
cl_service_name,
participant.cl_image,
participant.cl_log_level,
participant,
global_log_level,
boot_cl_client_ctx,
el_context,
Expand All @@ -217,19 +205,11 @@ def launch(
cl_max_cpu,
cl_min_mem,
cl_max_mem,
participant.snooper_enabled,
cl_volume_size,
snooper_engine_context,
participant.blobber_enabled,
participant.blobber_extra_params,
participant.cl_extra_params,
participant.cl_extra_env_vars,
participant.cl_extra_labels,
persistent,
cl_volume_size,
tolerations,
node_selectors,
participant.use_separate_vc,
participant.keymanager_enabled,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
Expand Down
120 changes: 51 additions & 69 deletions src/cl/grandine/grandine_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -33,66 +33,46 @@ VERBOSITY_LEVELS = {
def launch(
plan,
launcher,
service_name,
image,
participant_log_level,
beacon_service_name,
participant,
global_log_level,
bootnode_context,
bootnode_contexts,
el_context,
full_name,
node_keystore_files,
cl_min_cpu,
cl_max_cpu,
cl_min_mem,
cl_max_mem,
snooper_enabled,
snooper_engine_context,
blobber_enabled,
blobber_extra_params,
extra_params,
extra_env_vars,
extra_labels,
persistent,
cl_volume_size,
tolerations,
node_selectors,
use_separate_vc,
keymanager_enabled,
checkpoint_sync_enabled,
checkpoint_sync_url,
port_publisher,
participant_index,
):
beacon_service_name = "{0}".format(service_name)
log_level = input_parser.get_client_log_level_or_default(
participant_log_level, global_log_level, VERBOSITY_LEVELS
participant.cl_log_level, global_log_level, VERBOSITY_LEVELS
)

extra_params = [param for param in extra_params]

config = get_beacon_config(
plan,
launcher.el_cl_genesis_data,
launcher.jwt_file,
launcher.network,
keymanager_enabled,
image,
launcher,
beacon_service_name,
bootnode_context,
participant,
log_level,
bootnode_contexts,
el_context,
full_name,
log_level,
node_keystore_files,
cl_min_cpu,
cl_max_cpu,
cl_min_mem,
cl_max_mem,
snooper_enabled,
snooper_engine_context,
extra_params,
extra_env_vars,
extra_labels,
use_separate_vc,
persistent,
cl_volume_size,
tolerations,
Expand All @@ -103,7 +83,7 @@ def launch(
participant_index,
)

beacon_service = plan.add_service(service_name, config)
beacon_service = plan.add_service(beacon_service_name, config)

beacon_http_port = beacon_service.ports[constants.HTTP_PORT_ID]
beacon_http_url = "http://{0}:{1}".format(
Expand All @@ -125,14 +105,14 @@ def launch(
},
)
response = plan.request(
recipe=beacon_node_identity_recipe, service_name=service_name
recipe=beacon_node_identity_recipe, service_name=beacon_service_name
)
beacon_node_enr = response["extract.enr"]
beacon_multiaddr = response["extract.multiaddr"]
beacon_peer_id = response["extract.peer_id"]

beacon_node_metrics_info = node_metrics.new_node_metrics_info(
service_name, BEACON_METRICS_PATH, beacon_metrics_url
beacon_service_name, BEACON_METRICS_PATH, beacon_metrics_url
)
nodes_metrics_info = [beacon_node_metrics_info]
return cl_context.new_cl_context(
Expand All @@ -145,7 +125,7 @@ def launch(
beacon_service_name=beacon_service_name,
multiaddr=beacon_multiaddr,
peer_id=beacon_peer_id,
snooper_enabled=snooper_enabled,
snooper_enabled=participant.snooper_enabled,
snooper_engine_context=snooper_engine_context,
validator_keystore_files_artifact_uuid=node_keystore_files.files_artifact_uuid
if node_keystore_files
Expand All @@ -155,27 +135,19 @@ def launch(

def get_beacon_config(
plan,
el_cl_genesis_data,
jwt_file,
network,
keymanager_enabled,
image,
service_name,
launcher,
beacon_service_name,
participant,
log_level,
bootnode_contexts,
el_context,
full_name,
log_level,
node_keystore_files,
cl_min_cpu,
cl_max_cpu,
cl_min_mem,
cl_max_mem,
snooper_enabled,
snooper_engine_context,
extra_params,
extra_env_vars,
extra_labels,
use_separate_vc,
persistent,
cl_volume_size,
tolerations,
Expand All @@ -197,7 +169,7 @@ def get_beacon_config(
node_keystore_files.teku_secrets_relative_dirpath,
)
# If snooper is enabled use the snooper engine context, otherwise use the execution client context
if snooper_enabled:
if participant.snooper_enabled:
EXECUTION_ENGINE_ENDPOINT = "http://{0}:{1}".format(
snooper_engine_context.ip_addr,
snooper_engine_context.engine_rpc_port_num,
Expand Down Expand Up @@ -232,7 +204,9 @@ def get_beacon_config(

cmd = [
"--network={0}".format(
network if network in constants.PUBLIC_NETWORKS else "custom"
launcher.network
if launcher.network in constants.PUBLIC_NETWORKS
else "custom"
),
"--data-dir=" + BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER,
"--http-address=0.0.0.0",
Expand Down Expand Up @@ -270,31 +244,39 @@ def get_beacon_config(
# "--validator-api-bearer-file=" + constants.KEYMANAGER_MOUNT_PATH_ON_CONTAINER, Not yet supported
]

supernode_cmd = [
"--subscribe-all-data-column-subnets",
]

if participant.supernode:
cmd.extend(supernode_cmd)

# If checkpoint sync is enabled, add the checkpoint sync url
if checkpoint_sync_enabled:
if checkpoint_sync_url:
cmd.append("--checkpoint-sync-url=" + checkpoint_sync_url)
else:
if (
network in constants.PUBLIC_NETWORKS
or network == constants.NETWORK_NAME.ephemery
launcher.network in constants.PUBLIC_NETWORKS
or launcher.network == constants.NETWORK_NAME.ephemery
):
cmd.append(
"--checkpoint-sync-url=" + constants.CHECKPOINT_SYNC_URL[network]
"--checkpoint-sync-url="
+ constants.CHECKPOINT_SYNC_URL[launcher.network]
)
else:
fail(
"Checkpoint sync URL is required if you enabled checkpoint_sync for custom networks. Please provide a valid URL."
)

if network not in constants.PUBLIC_NETWORKS:
if launcher.network not in constants.PUBLIC_NETWORKS:
cmd.append(
"--configuration-directory="
+ constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER
)
if (
network == constants.NETWORK_NAME.kurtosis
or constants.NETWORK_NAME.shadowfork in network
launcher.network == constants.NETWORK_NAME.kurtosis
or constants.NETWORK_NAME.shadowfork in launcher.network
):
if bootnode_contexts != None:
cmd.append(
Expand All @@ -306,44 +288,44 @@ def get_beacon_config(
]
)
)
elif network == constants.NETWORK_NAME.ephemery:
elif launcher.network == constants.NETWORK_NAME.ephemery:
cmd.append(
"--boot-nodes="
+ shared_utils.get_devnet_enrs_list(
plan, el_cl_genesis_data.files_artifact_uuid
plan, launcher.el_cl_genesis_data.files_artifact_uuid
)
)
elif constants.NETWORK_NAME.shadowfork in network:
elif constants.NETWORK_NAME.shadowfork in launcher.network:
cmd.append(
"--boot-nodes="
+ shared_utils.get_devnet_enrs_list(
plan, el_cl_genesis_data.files_artifact_uuid
plan, launcher.el_cl_genesis_data.files_artifact_uuid
)
)
else: # Devnets
cmd.append(
"--boot-nodes="
+ shared_utils.get_devnet_enrs_list(
plan, el_cl_genesis_data.files_artifact_uuid
plan, launcher.el_cl_genesis_data.files_artifact_uuid
)
)

if len(extra_params) > 0:
# we do the list comprehension as the default extra_params is a proto repeated string
cmd.extend([param for param in extra_params])
if len(participant.cl_extra_params) > 0:
# we do the list comprehension as the default participant.extra_params is a proto repeated string
cmd.extend([param for param in participant.cl_extra_params])

files = {
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data.files_artifact_uuid,
constants.JWT_MOUNTPOINT_ON_CLIENTS: jwt_file,
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.el_cl_genesis_data.files_artifact_uuid,
constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file,
}

if node_keystore_files != None and not use_separate_vc:
if node_keystore_files != None and not participant.use_separate_vc:
cmd.extend(validator_default_cmd)
files[
constants.VALIDATOR_KEYS_DIRPATH_ON_SERVICE_CONTAINER
] = node_keystore_files.files_artifact_uuid

if keymanager_enabled:
if participant.keymanager_enabled:
cmd.extend(keymanager_api_cmd)
used_ports.update(vc_shared.VALIDATOR_KEYMANAGER_USED_PORTS)
public_ports.update(
Expand All @@ -352,26 +334,26 @@ def get_beacon_config(

if persistent:
files[BEACON_DATA_DIRPATH_ON_SERVICE_CONTAINER] = Directory(
persistent_key="data-{0}".format(service_name),
persistent_key="data-{0}".format(beacon_service_name),
size=cl_volume_size,
)
config_args = {
"image": image,
"image": participant.cl_image,
"ports": used_ports,
"public_ports": public_ports,
"cmd": cmd,
"files": files,
"env_vars": extra_env_vars,
"env_vars": participant.cl_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
),
"labels": shared_utils.label_maker(
constants.CL_TYPE.grandine,
constants.CLIENT_TYPES.cl,
image,
participant.cl_image,
el_context.client_name,
extra_labels,
participant.cl_extra_labels,
),
"tolerations": tolerations,
"node_selectors": node_selectors,
Expand Down
Loading

0 comments on commit 77ef93c

Please sign in to comment.