diff --git a/main.star b/main.star index f9dea1a4d..4eb9e7a46 100644 --- a/main.star +++ b/main.star @@ -8,6 +8,7 @@ transaction_spammer = import_module("github.com/kurtosis-tech/eth2-package/src/t cl_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/cl_forkmon/cl_forkmon_launcher.star") el_forkmon = import_module("github.com/kurtosis-tech/eth2-package/src/el_forkmon/el_forkmon_launcher.star") beacon_metrics_gazer = import_module("github.com/kurtosis-tech/eth2-package/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star") +light_beaconchain_explorer = import_module("github.com/kurtosis-tech/eth2-package/src/light_beaconchain/light_beaconchain_launcher.star") prometheus = import_module("github.com/kurtosis-tech/eth2-package/src/prometheus/prometheus_launcher.star") grafana =import_module("github.com/kurtosis-tech/eth2-package/src/grafana/grafana_launcher.star") testnet_verifier = import_module("github.com/kurtosis-tech/eth2-package/src/testnet_verifier/testnet_verifier.star") @@ -119,6 +120,11 @@ def run(plan, args): beacon_metrics_gazer.launch_beacon_metrics_gazer(plan, beacon_metrics_gazer_config_template, all_cl_client_contexts,network_params) plan.print("Succesfully launched beacon metrics gazer") + plan.print("Launching light-beaconchain-explorer") + light_beaconchain_explorer_config_template = read_file(static_files.LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH) + light_beaconchain_explorer.launch_light_beacon(plan, light_beaconchain_explorer_config_template, all_cl_client_contexts) + plan.print("Succesfully light-beaconchain-explorer") + plan.print("Launching prometheus...") prometheus_private_url = prometheus.launch_prometheus( plan, diff --git a/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star b/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star index 3919be251..72333165e 100644 --- a/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star +++ b/src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star @@ -7,7 +7,7 @@ IMAGE_NAME = "dapplion/beacon-metrics-gazer:latest" HTTP_PORT_ID = "http" HTTP_PORT_NUMBER = 8080 -BEACON_METRICS_GAZER_CONFIG_FILENAME = "beacon-metrics-gazer-ranges.yaml" +BEACON_METRICS_GAZER_CONFIG_FILENAME = "validator-ranges.yaml" BEACON_METRICS_GAZER_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" @@ -35,7 +35,7 @@ def launch_beacon_metrics_gazer( template_and_data_by_rel_dest_filepath = {} template_and_data_by_rel_dest_filepath[BEACON_METRICS_GAZER_CONFIG_FILENAME] = shared_utils.new_template_and_data(config_template, template_data) - config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "beacon-metrics-gazer-config") + config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "validator-ranges") config = get_config( config_files_artifact_name, @@ -59,7 +59,7 @@ def get_config( cmd = [ "http://{0}:{1}".format(ip_addr, http_port_num), "--ranges-file", - "/config/{0}".format(BEACON_METRICS_GAZER_CONFIG_FILENAME), + config_file_path, "--port", "{0}".format(HTTP_PORT_NUMBER), "--address", diff --git a/src/light_beaconchain/light_beaconchain_launcher.star b/src/light_beaconchain/light_beaconchain_launcher.star new file mode 100644 index 000000000..3cd023a18 --- /dev/null +++ b/src/light_beaconchain/light_beaconchain_launcher.star @@ -0,0 +1,77 @@ +shared_utils = import_module("github.com/kurtosis-tech/eth2-package/src/shared_utils/shared_utils.star") + + +SERVICE_NAME = "light-beaconchain" +IMAGE_NAME = "pk910/light-beaconchain-explorer:latest" + +HTTP_PORT_ID = "http" +HTTP_PORT_NUMBER = 8080 + +LIGHT_BEACONCHAIN_CONFIG_FILENAME = "light-beaconchain-config.yaml" + +LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" + +VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE = "/validator-ranges" +VALIDATOR_RANGES_ARTIFACT_NAME = "validator-ranges" + +CL_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/cl-genesis-data" +CL_CONFIG_ARTIFACT_NAME = "cl-genesis-data" + + +USED_PORTS = { + HTTP_PORT_ID:shared_utils.new_port_spec(HTTP_PORT_NUMBER, shared_utils.TCP_PROTOCOL, shared_utils.HTTP_APPLICATION_PROTOCOL) +} + + +def launch_light_beacon( + plan, + config_template, + cl_client_contexts, + ): + + cl_client_info = [] + 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)) + + template_data = new_config_template_data(HTTP_PORT_NUMBER, cl_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[LIGHT_BEACONCHAIN_CONFIG_FILENAME] = template_and_data + + config_files_artifact_name = plan.render_templates(template_and_data_by_rel_dest_filepath, "light-beaconchain-config") + + config = get_config(config_files_artifact_name) + + plan.add_service(SERVICE_NAME, config) + +def get_config(config_files_artifact_name): + config_file_path = shared_utils.path_join(LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE, LIGHT_BEACONCHAIN_CONFIG_FILENAME) + return ServiceConfig( + image = IMAGE_NAME, + ports = USED_PORTS, + files = { + LIGHT_BEACONCHAIN_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name, + VALIDATOR_RANGES_MOUNT_DIRPATH_ON_SERVICE: VALIDATOR_RANGES_ARTIFACT_NAME, + CL_CONFIG_MOUNT_DIRPATH_ON_SERVICE: CL_CONFIG_ARTIFACT_NAME + + }, + cmd = [ + "-config", + config_file_path + ] + ) + + +def new_config_template_data(listen_port_num, cl_client_info): + return { + "ListenPortNum": listen_port_num, + "CLClientInfo": cl_client_info, + } + + +def new_cl_client_info(ip_addr, port_num, service_name): + return { + "IPAddr": ip_addr, + "PortNum": port_num, + "Name": service_name + } diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index 27f2cdd09..15db3096f 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -17,6 +17,9 @@ PROMETHEUS_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ BEACON_METRICS_GAZER_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ "/beacon-metrics-gazer-config/config.yaml.tmpl" +LIGHT_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ + "/light-beaconchain-config/config.yaml.tmpl" + # Grafana config GRAFANA_CONFIG_DIRPATH = "/grafana-config" GRAFANA_DATASOURCE_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + \ diff --git a/static_files/light-beaconchain-config/config.yaml.tmpl b/static_files/light-beaconchain-config/config.yaml.tmpl new file mode 100644 index 000000000..2931a29bf --- /dev/null +++ b/static_files/light-beaconchain-config/config.yaml.tmpl @@ -0,0 +1,68 @@ + +logging: + outputLevel: "info" + #outputStderr: false + + #filePath: "explorer.log" + #fileLevel: "warn" + +# Chain network configuration +chain: + name: "kurtosis-testnet" + configPath: "/cl-genesis-data/output/config.yaml" + displayName: "Kurtosis Testnet" + +# HTTP Server configuration +server: + host: "0.0.0.0" # Address to listen on + port: "8080" # Port to listen on + +frontend: + enabled: true # Enable or disable to web frontend + debug: false + minimize: false # minimize html templates + + # Name of the site, displayed in the title tag + siteName: "Beaconchain Light" + siteSubtitle: "Kurtosis Testnet" + + # link to EL Explorer + ethExplorerLink: "" + + # file or inventory url to load validator names from + validatorNamesYaml: "/validator-ranges/validator-ranges.yaml" + +beaconapi: + # CL Client RPC +{{ range $clClient := .CLClientInfo }} + endpoint: "http://{{ $clClient.IPAddr }}:{{ $clClient.PortNum }}" +{{- end }} + # local cache for page models + localCacheSize: 100 # 100MB + + # remote cache for page models + redisCacheAddr: "" + redisCachePrefix: "" + +# indexer keeps track of the latest epochs in memory. +indexer: + # number of epochs to load on startup + prepopulateEpochs: 2 + + # max number of epochs to keep in memory + inMemoryEpochs: 3 + + # epoch processing delay (should be >= 2) + epochProcessingDelay: 2 + + # disable synchronizing and everything that writes to the db (indexer just maintains local cache) + disableIndexWriter: false + + # number of seconds to wait between each epoch (don't overload CL client) + syncEpochCooldown: 2 + + +database: + engine: "sqlite" + sqlite: + file: ":memory:"