Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vouch #809

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ participants:

# VC (Validator Client) Specific flags
# The type of validator client that should be used
# Valid values are nimbus, lighthouse, lodestar, teku, and prysm
# Valid values are nimbus, lighthouse, lodestar, teku, prysm and vouch
# ( The prysm validator only works with a prysm CL client )
# Defaults to matching the chosen CL client (cl_type)
vc_type: ""
Expand All @@ -308,6 +308,7 @@ participants:
# - nimbus: statusim/nimbus-validator-client:multiarch-latest
# - prysm: gcr.io/prysmaticlabs/prysm/validator:latest
# - teku: consensys/teku:latest
# - vouch: attestant/vouch:latest
vc_image: ""

# The number of validator clients to run for this participant
Expand Down
1 change: 1 addition & 0 deletions src/package_io/constants.star
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ VC_TYPE = struct(
nimbus="nimbus",
prysm="prysm",
teku="teku",
vouch="vouch"
)

REMOTE_SIGNER_TYPE = struct(web3signer="web3signer")
Expand Down
2 changes: 2 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DEFAULT_VC_IMAGES = {
"prysm": "gcr.io/prysmaticlabs/prysm/validator:stable",
"teku": "consensys/teku:latest",
"grandine": "sifrai/grandine:stable",
"vouch": "attestant/vouch:latest",
}

DEFAULT_VC_IMAGES_MINIMAL = {
Expand All @@ -50,6 +51,7 @@ DEFAULT_VC_IMAGES_MINIMAL = {
"prysm": "ethpandaops/prysm-validator:develop-minimal",
"teku": "consensys/teku:latest",
"grandine": "ethpandaops/grandine:master-minimal",
"vouch": "attestant/vouch:latest",
}

DEFAULT_REMOTE_SIGNER_IMAGES = {
Expand Down
19 changes: 19 additions & 0 deletions src/vc/vc_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ lodestar = import_module("./lodestar.star")
nimbus = import_module("./nimbus.star")
prysm = import_module("./prysm.star")
teku = import_module("./teku.star")
vouch = import_module("./vouch.star")
vc_shared = import_module("./shared.star")
shared_utils = import_module("../shared_utils/shared_utils.star")

Expand Down Expand Up @@ -151,6 +152,24 @@ def launch(
port_publisher=port_publisher,
vc_index=vc_index,
)
elif vc_type == constants.VC_TYPE.vouch:
config = vouch.get_config(
participant=participant,
el_cl_genesis_data=launcher.el_cl_genesis_data,
image=image,
keymanager_file=keymanager_file,
beacon_http_url=beacon_http_url,
cl_context=cl_context,
el_context=el_context,
remote_signer_context=remote_signer_context,
full_name=full_name,
node_keystore_files=node_keystore_files,
tolerations=tolerations,
node_selectors=node_selectors,
keymanager_enabled=keymanager_enabled,
port_publisher=port_publisher,
vc_index=vc_index,
)
elif vc_type == constants.VC_TYPE.grandine:
fail("Grandine VC is not yet supported")
else:
Expand Down
133 changes: 133 additions & 0 deletions src/vc/vouch.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
constants = import_module("../package_io/constants.star")
shared_utils = import_module("../shared_utils/shared_utils.star")
vc_shared = import_module("./shared.star")


def get_config(
participant,
el_cl_genesis_data,
image,
keymanager_file,
beacon_http_url,
cl_context,
el_context,
remote_signer_context,
full_name,
node_keystore_files,
tolerations,
node_selectors,
keymanager_enabled,
port_publisher,
vc_index,
):
validator_keys_dirpath = ""
validator_secrets_dirpath = ""
if node_keystore_files != None:
validator_keys_dirpath = shared_utils.path_join(
constants.VALIDATOR_KEYS_DIRPATH_ON_SERVICE_CONTAINER,
node_keystore_files.nimbus_keys_relative_dirpath,
)
validator_secrets_dirpath = shared_utils.path_join(
constants.VALIDATOR_KEYS_DIRPATH_ON_SERVICE_CONTAINER,
node_keystore_files.raw_secrets_relative_dirpath,
)

# general startup flags
# change them to vouch specific flags but keep constants
cmd = [
"--beacon-node=" + beacon_http_url,
"--suggested-fee-recipient=" + constants.VALIDATING_REWARDS_ACCOUNT,
# vvvvvvvvvvvvvvvvvvv METRICS CONFIG vvvvvvvvvvvvvvvvvvvvv
"--metrics",
"--metrics-address=0.0.0.0",
"--metrics-port={0}".format(vc_shared.VALIDATOR_CLIENT_METRICS_PORT_NUM),
"--graffiti=" + full_name,
]

if remote_signer_context == None:
cmd.extend(
[
"--validators-dir=" + validator_keys_dirpath,
"--secrets-dir=" + validator_secrets_dirpath,
]
)
else:
cmd.extend(
[
"--web3-signer-url={0}".format(remote_signer_context.http_url),
]
)

# is keymanager supported by vouch?
# if yes, adapt accordingly
# keep constants
keymanager_api_cmd = [
"--keymanager",
"--keymanager-port={0}".format(vc_shared.VALIDATOR_HTTP_PORT_NUM),
"--keymanager-address=0.0.0.0",
"--keymanager-allow-origin=*",
"--keymanager-token-file=" + constants.KEYMANAGER_MOUNT_PATH_ON_CONTAINER,
]

if len(participant.vc_extra_params) > 0:
# this is a repeated<proto type>, we convert it into Starlark
cmd.extend([param for param in participant.vc_extra_params])

files = {
constants.VALIDATOR_KEYS_DIRPATH_ON_SERVICE_CONTAINER: node_keystore_files.files_artifact_uuid,
constants.KEYMANAGER_MOUNT_PATH_ON_CLIENTS: keymanager_file,
}

public_ports = {}
public_keymanager_port_assignment = {}
if port_publisher.vc_enabled:
public_ports_for_component = shared_utils.get_public_ports_for_component(
"vc", port_publisher, vc_index
)
public_port_assignments = {
constants.METRICS_PORT_ID: public_ports_for_component[0]
}
public_keymanager_port_assignment = {
constants.VALIDATOR_HTTP_PORT_ID: public_ports_for_component[1]
}
public_ports = shared_utils.get_port_specs(public_port_assignments)

ports = {}
ports.update(vc_shared.VALIDATOR_CLIENT_USED_PORTS)

if keymanager_enabled:
cmd.extend(keymanager_api_cmd)
ports.update(vc_shared.VALIDATOR_KEYMANAGER_USED_PORTS)
public_ports.update(
shared_utils.get_port_specs(public_keymanager_port_assignment)
)

config_args = {
"image": image,
"ports": ports,
"public_ports": public_ports,
"cmd": cmd,
"files": files,
"env_vars": participant.vc_extra_env_vars,
"labels": shared_utils.label_maker(
client=constants.VC_TYPE.vouch,
client_type=constants.CLIENT_TYPES.validator,
image=image,
connected_client=cl_context.client_name,
extra_labels=participant.vc_extra_labels,
supernode=participant.supernode,
),
"tolerations": tolerations,
"node_selectors": node_selectors,
"user": User(uid=0, gid=0),
}

if participant.vc_min_cpu > 0:
config_args["min_cpu"] = participant.vc_min_cpu
if participant.vc_max_cpu > 0:
config_args["max_cpu"] = participant.vc_max_cpu
if participant.vc_min_mem > 0:
config_args["min_memory"] = participant.vc_min_mem
if participant.vc_max_mem > 0:
config_args["max_memory"] = participant.vc_max_mem
return ServiceConfig(**config_args)