Commit ded68bdc authored by Andrew Davis's avatar Andrew Davis Committed by GitHub

feat: forky (#625)

Co-authored-by: default avatarBarnabas Busa <busa.barnabas@gmail.com>
parent 08a65c33
......@@ -586,6 +586,7 @@ additional_services:
- blobscan
- dugtrio
- blutgang
- forky
- apache
# Configuration place for dora the explorer - https:#github.com/ethpandaops/dora
......
......@@ -24,6 +24,7 @@ dora = import_module("./src/dora/dora_launcher.star")
dugtrio = import_module("./src/dugtrio/dugtrio_launcher.star")
blutgang = import_module("./src/blutgang/blutgang_launcher.star")
blobscan = import_module("./src/blobscan/blobscan_launcher.star")
forky = import_module("./src/forky/forky_launcher.star")
apache = import_module("./src/apache/apache_launcher.star")
full_beaconchain_explorer = import_module(
"./src/full_beaconchain/full_beaconchain_launcher.star"
......@@ -490,6 +491,22 @@ def run(plan, args={}):
global_node_selectors,
)
plan.print("Successfully launched blobscan")
elif additional_service == "forky":
plan.print("Launching forky")
forky_config_template = read_file(
static_files.FORKY_CONFIG_TEMPLATE_FILEPATH
)
forky.launch_forky(
plan,
forky_config_template,
all_participants,
args_with_right_defaults.participants,
el_cl_data_files_artifact_uuid,
network_params,
global_node_selectors,
final_genesis_timestamp,
)
plan.print("Successfully launched forky")
elif additional_service == "apache":
plan.print("Launching apache")
apache.launch_apache(
......
shared_utils = import_module("../shared_utils/shared_utils.star")
constants = import_module("../package_io/constants.star")
SERVICE_NAME = "forky"
HTTP_PORT_ID = "http"
HTTP_PORT_NUMBER = 8080
FORKY_CONFIG_FILENAME = "forky-config.yaml"
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE = "/validator-ranges"
VALIDATOR_RANGES_ARTIFACT_NAME = "validator-ranges"
# The min/max CPU/memory that forky can use
MIN_CPU = 100
MAX_CPU = 1000
MIN_MEMORY = 128
MAX_MEMORY = 2048
USED_PORTS = {
HTTP_PORT_ID: shared_utils.new_port_spec(
HTTP_PORT_NUMBER,
shared_utils.TCP_PROTOCOL,
shared_utils.HTTP_APPLICATION_PROTOCOL,
)
}
def launch_forky(
plan,
config_template,
participant_contexts,
participant_configs,
el_cl_data_files_artifact_uuid,
network_params,
global_node_selectors,
final_genesis_timestamp,
):
all_cl_client_info = []
all_el_client_info = []
for index, participant in enumerate(participant_contexts):
full_name, cl_client, el_client, _ = shared_utils.get_client_names(
participant, index, participant_contexts, participant_configs
)
all_cl_client_info.append(
new_cl_client_info(
cl_client.beacon_http_url,
full_name,
)
)
all_el_client_info.append(
new_el_client_info(
"http://{0}:{1}".format(
el_client.ip_addr,
el_client.rpc_port_num,
),
full_name,
)
)
template_data = new_config_template_data(
network_params.network,
network_params.seconds_per_slot,
final_genesis_timestamp,
network_params.preset,
HTTP_PORT_NUMBER,
all_cl_client_info,
all_el_client_info,
)
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[FORKY_CONFIG_FILENAME] = template_and_data
config_files_artifact_name = plan.render_templates(
template_and_data_by_rel_dest_filepath, "forky-config"
)
el_cl_data_files_artifact_uuid = el_cl_data_files_artifact_uuid
config = get_config(
config_files_artifact_name,
el_cl_data_files_artifact_uuid,
network_params,
global_node_selectors,
)
plan.add_service(SERVICE_NAME, config)
def get_config(
config_files_artifact_name,
el_cl_data_files_artifact_uuid,
network_params,
node_selectors,
):
config_file_path = shared_utils.path_join(
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE,
FORKY_CONFIG_FILENAME,
)
IMAGE_NAME = "ethpandaops/forky:latest"
return ServiceConfig(
image=IMAGE_NAME,
ports=USED_PORTS,
files={
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE: VALIDATOR_RANGES_ARTIFACT_NAME,
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_data_files_artifact_uuid,
},
cmd=["--config", config_file_path],
min_cpu=MIN_CPU,
max_cpu=MAX_CPU,
min_memory=MIN_MEMORY,
max_memory=MAX_MEMORY,
node_selectors=node_selectors,
)
def new_config_template_data(
network,
seconds_per_slot,
final_genesis_timestamp,
preset,
listen_port_num,
cl_client_info,
el_client_info,
):
return {
"Network": network,
"SecondsPerSlot": seconds_per_slot,
"FinalGenesisTimestamp": final_genesis_timestamp,
"Preset": preset,
"ListenPortNum": listen_port_num,
"CLClientInfo": cl_client_info,
"ELClientInfo": el_client_info,
"PublicNetwork": True if network in constants.PUBLIC_NETWORKS else False,
}
def new_cl_client_info(beacon_http_url, full_name):
return {
"Beacon_HTTP_URL": beacon_http_url,
"FullName": full_name,
}
def new_el_client_info(execution_http_url, full_name):
return {
"Execution_HTTP_URL": execution_http_url,
"FullName": full_name,
}
......@@ -28,6 +28,7 @@ DUGTRIO_CONFIG_TEMPLATE_FILEPATH = (
BLUTGANG_CONFIG_TEMPLATE_FILEPATH = (
STATIC_FILES_DIRPATH + "/blutgang-config/config.toml.tmpl"
)
FORKY_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/forky-config/config.yaml.tmpl"
FULL_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = (
STATIC_FILES_DIRPATH + "/full-beaconchain-config/config.yaml.tmpl"
......
listen_addr: ":8080"
log_level: "info"
metrics:
enabled: false
http:
edge_cache:
enabled: true
frame_ttl: 1440m
forky:
retention_period: "30m"
store:
type: memory
config: {}
indexer:
dsn: "file::memory:?cache=shared"
driver_name: sqlite
sources:
{{ range $clClient := .CLClientInfo }}
- name: "{{ $clClient.FullName }}"
type: "beacon_node"
config:
address: "{{ $clClient.Beacon_HTTP_URL }}"
polling_interval: "{{ .SecondsPerSlot }}s"
{{- end }}
ethereum:
network:
name: "{{ .Network }}"
spec:
seconds_per_slot: {{ .SecondsPerSlot }}
slots_per_epoch: {{ if eq .Preset "minimal" }}8{{ else }}32{{ end }}
genesis_time: {{ .FinalGenesisTimestamp }}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment