Skip to content

Commit ded68bd

Browse files
Savidbarnabasbusa
andauthored
feat: forky (#625)
Co-authored-by: Barnabas Busa <[email protected]>
1 parent 08a65c3 commit ded68bd

File tree

5 files changed

+210
-0
lines changed

5 files changed

+210
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,7 @@ additional_services:
586586
- blobscan
587587
- dugtrio
588588
- blutgang
589+
- forky
589590
- apache
590591

591592
# Configuration place for dora the explorer - https:#github.com/ethpandaops/dora

main.star

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dora = import_module("./src/dora/dora_launcher.star")
2424
dugtrio = import_module("./src/dugtrio/dugtrio_launcher.star")
2525
blutgang = import_module("./src/blutgang/blutgang_launcher.star")
2626
blobscan = import_module("./src/blobscan/blobscan_launcher.star")
27+
forky = import_module("./src/forky/forky_launcher.star")
2728
apache = import_module("./src/apache/apache_launcher.star")
2829
full_beaconchain_explorer = import_module(
2930
"./src/full_beaconchain/full_beaconchain_launcher.star"
@@ -490,6 +491,22 @@ def run(plan, args={}):
490491
global_node_selectors,
491492
)
492493
plan.print("Successfully launched blobscan")
494+
elif additional_service == "forky":
495+
plan.print("Launching forky")
496+
forky_config_template = read_file(
497+
static_files.FORKY_CONFIG_TEMPLATE_FILEPATH
498+
)
499+
forky.launch_forky(
500+
plan,
501+
forky_config_template,
502+
all_participants,
503+
args_with_right_defaults.participants,
504+
el_cl_data_files_artifact_uuid,
505+
network_params,
506+
global_node_selectors,
507+
final_genesis_timestamp,
508+
)
509+
plan.print("Successfully launched forky")
493510
elif additional_service == "apache":
494511
plan.print("Launching apache")
495512
apache.launch_apache(

src/forky/forky_launcher.star

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
shared_utils = import_module("../shared_utils/shared_utils.star")
2+
constants = import_module("../package_io/constants.star")
3+
SERVICE_NAME = "forky"
4+
5+
HTTP_PORT_ID = "http"
6+
HTTP_PORT_NUMBER = 8080
7+
8+
FORKY_CONFIG_FILENAME = "forky-config.yaml"
9+
10+
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
11+
12+
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE = "/validator-ranges"
13+
VALIDATOR_RANGES_ARTIFACT_NAME = "validator-ranges"
14+
15+
# The min/max CPU/memory that forky can use
16+
MIN_CPU = 100
17+
MAX_CPU = 1000
18+
MIN_MEMORY = 128
19+
MAX_MEMORY = 2048
20+
21+
USED_PORTS = {
22+
HTTP_PORT_ID: shared_utils.new_port_spec(
23+
HTTP_PORT_NUMBER,
24+
shared_utils.TCP_PROTOCOL,
25+
shared_utils.HTTP_APPLICATION_PROTOCOL,
26+
)
27+
}
28+
29+
30+
def launch_forky(
31+
plan,
32+
config_template,
33+
participant_contexts,
34+
participant_configs,
35+
el_cl_data_files_artifact_uuid,
36+
network_params,
37+
global_node_selectors,
38+
final_genesis_timestamp,
39+
):
40+
all_cl_client_info = []
41+
all_el_client_info = []
42+
for index, participant in enumerate(participant_contexts):
43+
full_name, cl_client, el_client, _ = shared_utils.get_client_names(
44+
participant, index, participant_contexts, participant_configs
45+
)
46+
all_cl_client_info.append(
47+
new_cl_client_info(
48+
cl_client.beacon_http_url,
49+
full_name,
50+
)
51+
)
52+
all_el_client_info.append(
53+
new_el_client_info(
54+
"http://{0}:{1}".format(
55+
el_client.ip_addr,
56+
el_client.rpc_port_num,
57+
),
58+
full_name,
59+
)
60+
)
61+
62+
template_data = new_config_template_data(
63+
network_params.network,
64+
network_params.seconds_per_slot,
65+
final_genesis_timestamp,
66+
network_params.preset,
67+
HTTP_PORT_NUMBER,
68+
all_cl_client_info,
69+
all_el_client_info,
70+
)
71+
72+
template_and_data = shared_utils.new_template_and_data(
73+
config_template, template_data
74+
)
75+
template_and_data_by_rel_dest_filepath = {}
76+
template_and_data_by_rel_dest_filepath[FORKY_CONFIG_FILENAME] = template_and_data
77+
78+
config_files_artifact_name = plan.render_templates(
79+
template_and_data_by_rel_dest_filepath, "forky-config"
80+
)
81+
el_cl_data_files_artifact_uuid = el_cl_data_files_artifact_uuid
82+
config = get_config(
83+
config_files_artifact_name,
84+
el_cl_data_files_artifact_uuid,
85+
network_params,
86+
global_node_selectors,
87+
)
88+
89+
plan.add_service(SERVICE_NAME, config)
90+
91+
92+
def get_config(
93+
config_files_artifact_name,
94+
el_cl_data_files_artifact_uuid,
95+
network_params,
96+
node_selectors,
97+
):
98+
config_file_path = shared_utils.path_join(
99+
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE,
100+
FORKY_CONFIG_FILENAME,
101+
)
102+
103+
IMAGE_NAME = "ethpandaops/forky:latest"
104+
105+
return ServiceConfig(
106+
image=IMAGE_NAME,
107+
ports=USED_PORTS,
108+
files={
109+
FORKY_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
110+
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE: VALIDATOR_RANGES_ARTIFACT_NAME,
111+
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_data_files_artifact_uuid,
112+
},
113+
cmd=["--config", config_file_path],
114+
min_cpu=MIN_CPU,
115+
max_cpu=MAX_CPU,
116+
min_memory=MIN_MEMORY,
117+
max_memory=MAX_MEMORY,
118+
node_selectors=node_selectors,
119+
)
120+
121+
122+
def new_config_template_data(
123+
network,
124+
seconds_per_slot,
125+
final_genesis_timestamp,
126+
preset,
127+
listen_port_num,
128+
cl_client_info,
129+
el_client_info,
130+
):
131+
return {
132+
"Network": network,
133+
"SecondsPerSlot": seconds_per_slot,
134+
"FinalGenesisTimestamp": final_genesis_timestamp,
135+
"Preset": preset,
136+
"ListenPortNum": listen_port_num,
137+
"CLClientInfo": cl_client_info,
138+
"ELClientInfo": el_client_info,
139+
"PublicNetwork": True if network in constants.PUBLIC_NETWORKS else False,
140+
}
141+
142+
143+
def new_cl_client_info(beacon_http_url, full_name):
144+
return {
145+
"Beacon_HTTP_URL": beacon_http_url,
146+
"FullName": full_name,
147+
}
148+
149+
150+
def new_el_client_info(execution_http_url, full_name):
151+
return {
152+
"Execution_HTTP_URL": execution_http_url,
153+
"FullName": full_name,
154+
}

src/static_files/static_files.star

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ DUGTRIO_CONFIG_TEMPLATE_FILEPATH = (
2828
BLUTGANG_CONFIG_TEMPLATE_FILEPATH = (
2929
STATIC_FILES_DIRPATH + "/blutgang-config/config.toml.tmpl"
3030
)
31+
FORKY_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/forky-config/config.yaml.tmpl"
3132

3233
FULL_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = (
3334
STATIC_FILES_DIRPATH + "/full-beaconchain-config/config.yaml.tmpl"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
listen_addr: ":8080"
2+
log_level: "info"
3+
metrics:
4+
enabled: false
5+
6+
http:
7+
edge_cache:
8+
enabled: true
9+
frame_ttl: 1440m
10+
11+
forky:
12+
retention_period: "30m"
13+
14+
store:
15+
type: memory
16+
config: {}
17+
18+
indexer:
19+
dsn: "file::memory:?cache=shared"
20+
driver_name: sqlite
21+
22+
sources:
23+
{{ range $clClient := .CLClientInfo }}
24+
- name: "{{ $clClient.FullName }}"
25+
type: "beacon_node"
26+
config:
27+
address: "{{ $clClient.Beacon_HTTP_URL }}"
28+
polling_interval: "{{ .SecondsPerSlot }}s"
29+
{{- end }}
30+
31+
ethereum:
32+
network:
33+
name: "{{ .Network }}"
34+
spec:
35+
seconds_per_slot: {{ .SecondsPerSlot }}
36+
slots_per_epoch: {{ if eq .Preset "minimal" }}8{{ else }}32{{ end }}
37+
genesis_time: {{ .FinalGenesisTimestamp }}

0 commit comments

Comments
 (0)