Skip to content

Commit

Permalink
feat: forky (#625)
Browse files Browse the repository at this point in the history
Co-authored-by: Barnabas Busa <[email protected]>
  • Loading branch information
Savid and barnabasbusa authored May 17, 2024
1 parent 08a65c3 commit ded68bd
Show file tree
Hide file tree
Showing 5 changed files with 210 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ additional_services:
- blobscan
- dugtrio
- blutgang
- forky
- apache

# Configuration place for dora the explorer - https:#github.com/ethpandaops/dora
Expand Down
17 changes: 17 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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(
Expand Down
154 changes: 154 additions & 0 deletions src/forky/forky_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
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,
}
1 change: 1 addition & 0 deletions src/static_files/static_files.star
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
37 changes: 37 additions & 0 deletions static_files/forky-config/config.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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 }}

0 comments on commit ded68bd

Please sign in to comment.