Skip to content

Commit 83e01a1

Browse files
authored
feat: add light-beaconchain-explorer (ethereum#125)
Changelog picked up from commits here: feat: add light-beaconchain-explorer
1 parent 1cb1a92 commit 83e01a1

File tree

5 files changed

+157
-3
lines changed

5 files changed

+157
-3
lines changed

main.star

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ transaction_spammer = import_module("github.com/kurtosis-tech/eth2-package/src/t
88
cl_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/cl_forkmon/cl_forkmon_launcher.star")
99
el_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/el_forkmon/el_forkmon_launcher.star")
1010
beacon_metrics_gazer = import_module("github.com/kurtosis-tech/eth2-package/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star")
11+
light_beaconchain_explorer = import_module("github.com/kurtosis-tech/eth2-package/src/light_beaconchain/light_beaconchain_launcher.star")
1112
prometheus = import_module("github.com/kurtosis-tech/eth2-package/src/prometheus/prometheus_launcher.star")
1213
grafana =import_module("github.com/kurtosis-tech/eth2-package/src/grafana/grafana_launcher.star")
1314
testnet_verifier = import_module("github.com/kurtosis-tech/eth2-package/src/testnet_verifier/testnet_verifier.star")
@@ -119,6 +120,11 @@ def run(plan, args):
119120
beacon_metrics_gazer.launch_beacon_metrics_gazer(plan, beacon_metrics_gazer_config_template, all_cl_client_contexts,network_params)
120121
plan.print("Succesfully launched beacon metrics gazer")
121122

123+
plan.print("Launching light-beaconchain-explorer")
124+
light_beaconchain_explorer_config_template = read_file(static_files.LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH)
125+
light_beaconchain_explorer.launch_light_beacon(plan, light_beaconchain_explorer_config_template, all_cl_client_contexts)
126+
plan.print("Succesfully light-beaconchain-explorer")
127+
122128
plan.print("Launching prometheus...")
123129
prometheus_private_url = prometheus.launch_prometheus(
124130
plan,

src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ IMAGE_NAME = "dapplion/beacon-metrics-gazer:latest"
77
HTTP_PORT_ID = "http"
88
HTTP_PORT_NUMBER = 8080
99

10-
BEACON_METRICS_GAZER_CONFIG_FILENAME = "beacon-metrics-gazer-ranges.yaml"
10+
BEACON_METRICS_GAZER_CONFIG_FILENAME = "validator-ranges.yaml"
1111

1212
BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
1313

@@ -35,7 +35,7 @@ def launch_beacon_metrics_gazer(
3535
template_and_data_by_rel_dest_filepath = {}
3636
template_and_data_by_rel_dest_filepath[BEACON_METRICS_GAZER_CONFIG_FILENAME] = shared_utils.new_template_and_data(config_template, template_data)
3737

38-
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "beacon-metrics-gazer-config")
38+
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "validator-ranges")
3939

4040
config = get_config(
4141
config_files_artifact_name,
@@ -59,7 +59,7 @@ def get_config(
5959
cmd = [
6060
"http://{0}:{1}".format(ip_addr, http_port_num),
6161
"--ranges-file",
62-
"/config/{0}".format(BEACON_METRICS_GAZER_CONFIG_FILENAME),
62+
config_file_path,
6363
"--port",
6464
"{0}".format(HTTP_PORT_NUMBER),
6565
"--address",
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star")
2+
3+
4+
SERVICE_NAME = "light-beaconchain"
5+
IMAGE_NAME = "pk910/light-beaconchain-explorer:latest"
6+
7+
HTTP_PORT_ID = "http"
8+
HTTP_PORT_NUMBER = 8080
9+
10+
LIGHT_BEACONCHAIN_CONFIG_FILENAME = "light-beaconchain-config.yaml"
11+
12+
LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config"
13+
14+
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE = "/validator-ranges"
15+
VALIDATOR_RANGES_ARTIFACT_NAME = "validator-ranges"
16+
17+
CL_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/cl-genesis-data"
18+
CL_CONFIG_ARTIFACT_NAME = "cl-genesis-data"
19+
20+
21+
USED_PORTS = {
22+
HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL)
23+
}
24+
25+
26+
def launch_light_beacon(
27+
plan,
28+
config_template,
29+
cl_client_contexts,
30+
):
31+
32+
cl_client_info = []
33+
cl_client_info.append(new_cl_client_info(cl_client_contexts[0].ip_addr, cl_client_contexts[0].http_port_num, cl_client_contexts[0].beacon_service_name))
34+
35+
template_data = new_config_template_data(HTTP_PORT_NUMBER, cl_client_info)
36+
37+
template_and_data = shared_utils.new_template_and_data(config_template, template_data)
38+
template_and_data_by_rel_dest_filepath = {}
39+
template_and_data_by_rel_dest_filepath[LIGHT_BEACONCHAIN_CONFIG_FILENAME] = template_and_data
40+
41+
config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "light-beaconchain-config")
42+
43+
config = get_config(config_files_artifact_name)
44+
45+
plan.add_service(SERVICE_NAME, config)
46+
47+
def get_config(config_files_artifact_name):
48+
config_file_path = shared_utils.path_join(LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE, LIGHT_BEACONCHAIN_CONFIG_FILENAME)
49+
return ServiceConfig(
50+
image = IMAGE_NAME,
51+
ports = USED_PORTS,
52+
files = {
53+
LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name,
54+
VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE: VALIDATOR_RANGES_ARTIFACT_NAME,
55+
CL_CONFIG_MOUNT_DIRPATH_ON_SERVICE: CL_CONFIG_ARTIFACT_NAME
56+
57+
},
58+
cmd = [
59+
"-config",
60+
config_file_path
61+
]
62+
)
63+
64+
65+
def new_config_template_data(listen_port_num, cl_client_info):
66+
return {
67+
"ListenPortNum": listen_port_num,
68+
"CLClientInfo": cl_client_info,
69+
}
70+
71+
72+
def new_cl_client_info(ip_addr, port_num, service_name):
73+
return {
74+
"IPAddr": ip_addr,
75+
"PortNum": port_num,
76+
"Name": service_name
77+
}

src/static_files/static_files.star

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PROMETHEUS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
1717
BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
1818
"/beacon-metrics-gazer-config/config.yaml.tmpl"
1919

20+
LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
21+
"/light-beaconchain-config/config.yaml.tmpl"
22+
2023
# Grafana config
2124
GRAFANA_CONFIG_DIRPATH = "/grafana-config"
2225
GRAFANA_DATASOURCE_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
logging:
3+
outputLevel: "info"
4+
#outputStderr: false
5+
6+
#filePath: "explorer.log"
7+
#fileLevel: "warn"
8+
9+
# Chain network configuration
10+
chain:
11+
name: "kurtosis-testnet"
12+
configPath: "/cl-genesis-data/output/config.yaml"
13+
displayName: "Kurtosis Testnet"
14+
15+
# HTTP Server configuration
16+
server:
17+
host: "0.0.0.0" # Address to listen on
18+
port: "8080" # Port to listen on
19+
20+
frontend:
21+
enabled: true # Enable or disable to web frontend
22+
debug: false
23+
minimize: false # minimize html templates
24+
25+
# Name of the site, displayed in the title tag
26+
siteName: "Beaconchain Light"
27+
siteSubtitle: "Kurtosis Testnet"
28+
29+
# link to EL Explorer
30+
ethExplorerLink: ""
31+
32+
# file or inventory url to load validator names from
33+
validatorNamesYaml: "/validator-ranges/validator-ranges.yaml"
34+
35+
beaconapi:
36+
# CL Client RPC
37+
{{ range $clClient := .CLClientInfo }}
38+
endpoint: "http://{{ $clClient.IPAddr }}:{{ $clClient.PortNum }}"
39+
{{- end }}
40+
# local cache for page models
41+
localCacheSize: 100 # 100MB
42+
43+
# remote cache for page models
44+
redisCacheAddr: ""
45+
redisCachePrefix: ""
46+
47+
# indexer keeps track of the latest epochs in memory.
48+
indexer:
49+
# number of epochs to load on startup
50+
prepopulateEpochs: 2
51+
52+
# max number of epochs to keep in memory
53+
inMemoryEpochs: 3
54+
55+
# epoch processing delay (should be >= 2)
56+
epochProcessingDelay: 2
57+
58+
# disable synchronizing and everything that writes to the db (indexer just maintains local cache)
59+
disableIndexWriter: false
60+
61+
# number of seconds to wait between each epoch (don't overload CL client)
62+
syncEpochCooldown: 2
63+
64+
65+
database:
66+
engine: "sqlite"
67+
sqlite:
68+
file: ":memory:"

0 commit comments

Comments
 (0)