Skip to content
Merged
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
2 changes: 2 additions & 0 deletions .github/tests/zkboost.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ participants:
additional_services:
- zkboost
- dora
- prometheus
- grafana

zkboost_params:
zkvms:
Expand Down
5 changes: 2 additions & 3 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -1051,19 +1051,18 @@ def run(plan, args={}):
zkboost_config_template = read_file(
static_files.ZKBOOST_CONFIG_TEMPLATE_FILEPATH
)
zkboost.launch_zkboost(
zkboost_metrics_jobs = zkboost.launch_zkboost(
plan,
zkboost_config_template,
all_participants,
args_with_right_defaults.participants,
args_with_right_defaults.zkboost_params,
global_node_selectors,
global_tolerations,
args_with_right_defaults.port_publisher,
index,
args_with_right_defaults.docker_cache_params,
{},
)
prometheus_additional_metrics_jobs.extend(zkboost_metrics_jobs)
plan.print("Successfully launched zkboost")
else:
fail("Invalid additional service %s" % (additional_service))
Expand Down
4 changes: 4 additions & 0 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,12 @@ def input_parser(plan, input_args):
),
zkboost_params=struct(
image=result["zkboost_params"]["image"],
port=result["zkboost_params"]["port"],
witness_timeout_secs=result["zkboost_params"]["witness_timeout_secs"],
proof_timeout_secs=result["zkboost_params"]["proof_timeout_secs"],
witness_cache_size=result["zkboost_params"]["witness_cache_size"],
proof_cache_size=result["zkboost_params"]["proof_cache_size"],
instances=result["zkboost_params"]["instances"],
zkvms=result["zkboost_params"]["zkvms"],
env=result["zkboost_params"]["env"],
),
Expand Down Expand Up @@ -2000,10 +2002,12 @@ def get_default_bootnodoor_params():
def get_default_zkboost_params():
return {
"image": constants.DEFAULT_ZKBOOST_IMAGE,
"port": 3000,
"witness_timeout_secs": 12,
"proof_timeout_secs": 12,
"witness_cache_size": 128,
"proof_cache_size": 128,
"instances": [{"name": "zkboost", "el_participant_index": 0}],
"zkvms": [],
"env": {},
}
Expand Down
2 changes: 2 additions & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -447,10 +447,12 @@ SUBCATEGORY_PARAMS = {
],
"zkboost_params": [
"image",
"port",
"witness_timeout_secs",
"proof_timeout_secs",
"witness_cache_size",
"proof_cache_size",
"instances",
"zkvms",
"env",
],
Expand Down
149 changes: 87 additions & 62 deletions src/zkboost/zkboost_launcher.star
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
shared_utils = import_module("../shared_utils/shared_utils.star")
constants = import_module("../package_io/constants.star")

SERVICE_NAME = "zkboost"

HTTP_PORT_NUMBER = 3000
SERVICE_NAME_PREFIX = "zkboost"

ZKBOOST_CONFIG_FILENAME = "config.toml"

Expand All @@ -14,21 +12,11 @@ MAX_CPU = 1000
MIN_MEMORY = 256
MAX_MEMORY = 2048

USED_PORTS = {
constants.HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
wait=None,
)
}


def launch_zkboost(
plan,
config_template,
participant_contexts,
participant_configs,
zkboost_params,
global_node_selectors,
global_tolerations,
Expand All @@ -38,61 +26,89 @@ def launch_zkboost(
):
tolerations = shared_utils.get_tolerations(global_tolerations=global_tolerations)

first_real_el_endpoint = None
for index, participant in enumerate(participant_contexts):
el_type = participant_configs[index].el_type
if el_type != "dummy":
el_client = participant.el_context
first_real_el_endpoint = "http://{0}:{1}".format(
el_client.dns_name, el_client.rpc_port_num
metrics_jobs = []
for instance_index, instance in enumerate(zkboost_params.instances):
name = instance["name"]
el_participant_index = instance["el_participant_index"]

if el_participant_index >= len(participant_contexts):
fail(
"zkboost instance '{0}' references el_participant_index {1} but only {2} participants exist".format(
name, el_participant_index, len(participant_contexts)
)
)
break

zkvms = []
for zkvm in zkboost_params.zkvms:
entry = {
"Kind": zkvm["kind"],
"ProofType": zkvm["proof_type"],
el_client = participant_contexts[el_participant_index].el_context
el_endpoint = "http://{0}:{1}".format(
el_client.dns_name, el_client.rpc_port_num
)

zkvms = []
for zkvm in zkboost_params.zkvms:
entry = {
"Kind": zkvm["kind"],
"ProofType": zkvm["proof_type"],
}
if zkvm["kind"] == "external":
fail("TODO: external zkvm kind is not yet supported")
elif zkvm["kind"] == "mock":
entry["MockProvingTimeMs"] = zkvm.get("mock_proving_time_ms", 5000)
entry["MockProofSize"] = zkvm.get("mock_proof_size", 1024)
zkvms.append(entry)

template_data = {
"Port": zkboost_params.port,
"ELEndpoint": el_endpoint,
"WitnessTimeoutSecs": zkboost_params.witness_timeout_secs,
"ProofTimeoutSecs": zkboost_params.proof_timeout_secs,
"WitnessCacheSize": zkboost_params.witness_cache_size,
"ProofCacheSize": zkboost_params.proof_cache_size,
"Zkvms": zkvms,
}
if zkvm["kind"] == "external":
fail("TODO: external zkvm kind is not yet supported")
elif zkvm["kind"] == "mock":
entry["MockProvingTimeMs"] = zkvm.get("mock_proving_time_ms", 5000)
entry["MockProofSize"] = zkvm.get("mock_proof_size", 1024)
zkvms.append(entry)

template_data = {
"ELEndpoint": first_real_el_endpoint,
"WitnessTimeoutSecs": zkboost_params.witness_timeout_secs,
"ProofTimeoutSecs": zkboost_params.proof_timeout_secs,
"WitnessCacheSize": zkboost_params.witness_cache_size,
"ProofCacheSize": zkboost_params.proof_cache_size,
"Zkvms": zkvms,
}

template_and_data = shared_utils.new_template_and_data(
config_template, template_data
)
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[ZKBOOST_CONFIG_FILENAME] = template_and_data

config_files_artifact_name = plan.render_templates(
template_and_data_by_rel_dest_filepath, "zkboost-config"
)
config = get_config(
config_files_artifact_name,
zkboost_params,
global_node_selectors,
tolerations,
port_publisher,
additional_service_index,
docker_cache_params,
)

plan.add_service(SERVICE_NAME, config)
template_and_data = shared_utils.new_template_and_data(
config_template, template_data
)
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[
ZKBOOST_CONFIG_FILENAME
] = template_and_data

config_files_artifact_name = plan.render_templates(
template_and_data_by_rel_dest_filepath, name + "-config"
)
config = get_config(
name,
config_files_artifact_name,
zkboost_params,
global_node_selectors,
tolerations,
port_publisher,
additional_service_index + instance_index,
docker_cache_params,
)

plan.add_service(name, config)
metrics_jobs.append(get_metrics_job(name, zkboost_params.port))

return metrics_jobs


def get_metrics_job(service_name, port):
return {
"Name": service_name,
"Endpoint": "{0}:{1}".format(service_name, port),
"MetricsPath": "/metrics",
"Labels": {
"service": service_name,
"client_type": SERVICE_NAME_PREFIX,
},
"ScrapeInterval": "15s",
}


def get_config(
service_name,
config_files_artifact_name,
zkboost_params,
node_selectors,
Expand All @@ -106,6 +122,15 @@ def get_config(
ZKBOOST_CONFIG_FILENAME,
)

used_ports = {
constants.HTTP_PORT_ID: shared_utils.new_port_spec(
zkboost_params.port,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
wait=None,
)
}

public_ports = shared_utils.get_additional_service_standard_public_port(
port_publisher,
constants.HTTP_PORT_ID,
Expand All @@ -120,7 +145,7 @@ def get_config(

return ServiceConfig(
image=IMAGE_NAME,
ports=USED_PORTS,
ports=used_ports,
public_ports=public_ports,
files={
ZKBOOST_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
Expand Down
Loading
Loading