From b100cb6fac5646783c0ee580ec3425fd74e0e4a1 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Fri, 7 Jun 2024 03:26:38 +0200 Subject: [PATCH] feat: add tracoor (#651) cc: @samcm min config: ```yaml additional_services: - tracoor ``` --------- Co-authored-by: Sam Calder-Mason --- .github/tests/mix-with-tools-mev.yaml | 1 + .github/tests/mix-with-tools-minimal.yaml | 1 + .github/tests/mix-with-tools.yaml | 1 + README.md | 1 + main.star | 17 +++ src/static_files/static_files.star | 4 +- src/tracoor/tracoor_launcher.star | 136 +++++++++++++++++++ static_files/dora-config/config.yaml.tmpl | 6 +- static_files/tracoor-config/config.yaml.tmpl | 39 ++++++ 9 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 src/tracoor/tracoor_launcher.star create mode 100644 static_files/tracoor-config/config.yaml.tmpl diff --git a/.github/tests/mix-with-tools-mev.yaml b/.github/tests/mix-with-tools-mev.yaml index 260749643..728fb31a5 100644 --- a/.github/tests/mix-with-tools-mev.yaml +++ b/.github/tests/mix-with-tools-mev.yaml @@ -25,6 +25,7 @@ additional_services: - dugtrio - blutgang - apache + - tracoor ethereum_metrics_exporter_enabled: true snooper_enabled: true mev_type: flashbots diff --git a/.github/tests/mix-with-tools-minimal.yaml b/.github/tests/mix-with-tools-minimal.yaml index 7c3a452ef..695c4a9dd 100644 --- a/.github/tests/mix-with-tools-minimal.yaml +++ b/.github/tests/mix-with-tools-minimal.yaml @@ -27,6 +27,7 @@ additional_services: - dugtrio - blutgang - apache + - tracoor ethereum_metrics_exporter_enabled: true snooper_enabled: true keymanager_enabled: true diff --git a/.github/tests/mix-with-tools.yaml b/.github/tests/mix-with-tools.yaml index 82a740da8..ed4fc57e5 100644 --- a/.github/tests/mix-with-tools.yaml +++ b/.github/tests/mix-with-tools.yaml @@ -27,6 +27,7 @@ additional_services: - dugtrio - blutgang - apache + - tracoor ethereum_metrics_exporter_enabled: true snooper_enabled: true keymanager_enabled: true diff --git a/README.md b/README.md index 0ed499c28..2db43bd25 100644 --- a/README.md +++ b/README.md @@ -592,6 +592,7 @@ additional_services: - blutgang - forky - apache + - tracoor # Configuration place for dora the explorer - https://github.com/ethpandaops/dora dora_params: diff --git a/main.star b/main.star index 225c7f943..0c014e369 100644 --- a/main.star +++ b/main.star @@ -25,6 +25,7 @@ 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") +tracoor = import_module("./src/tracoor/tracoor_launcher.star") apache = import_module("./src/apache/apache_launcher.star") full_beaconchain_explorer = import_module( "./src/full_beaconchain/full_beaconchain_launcher.star" @@ -507,6 +508,22 @@ def run(plan, args={}): final_genesis_timestamp, ) plan.print("Successfully launched forky") + elif additional_service == "tracoor": + plan.print("Launching tracoor") + tracoor_config_template = read_file( + static_files.TRACOOR_CONFIG_TEMPLATE_FILEPATH + ) + tracoor.launch_tracoor( + plan, + tracoor_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 tracoor") elif additional_service == "apache": plan.print("Launching apache") apache.launch_apache( diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index 249bccc42..b05031d71 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -29,7 +29,9 @@ BLUTGANG_CONFIG_TEMPLATE_FILEPATH = ( STATIC_FILES_DIRPATH + "/blutgang-config/config.toml.tmpl" ) FORKY_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/forky-config/config.yaml.tmpl" - +TRACOOR_CONFIG_TEMPLATE_FILEPATH = ( + STATIC_FILES_DIRPATH + "/tracoor-config/config.yaml.tmpl" +) FULL_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = ( STATIC_FILES_DIRPATH + "/full-beaconchain-config/config.yaml.tmpl" ) diff --git a/src/tracoor/tracoor_launcher.star b/src/tracoor/tracoor_launcher.star new file mode 100644 index 000000000..9fc01c866 --- /dev/null +++ b/src/tracoor/tracoor_launcher.star @@ -0,0 +1,136 @@ +shared_utils = import_module("../shared_utils/shared_utils.star") +constants = import_module("../package_io/constants.star") + +IMAGE_NAME = "ethpandaops/tracoor:0.0.18" +SERVICE_NAME = "tracoor" + +HTTP_PORT_ID = "http" +HTTP_PORT_NUMBER = 7007 + +TRACOOR_CONFIG_FILENAME = "tracoor-config.yaml" + +TRACOOR_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" + +# The min/max CPU/memory that tracoor 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_tracoor( + plan, + config_template, + participant_contexts, + participant_configs, + el_cl_data_files_artifact_uuid, + network_params, + global_node_selectors, + final_genesis_timestamp, +): + all_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 + ) + + beacon = new_cl_client_info(cl_client.beacon_http_url, full_name) + execution = new_el_client_info( + "http://{0}:{1}".format( + el_client.ip_addr, + el_client.rpc_port_num, + ), + full_name, + ) + + client_info = { + "Beacon": beacon, + "Execution": execution, + "Network": network_params.network, + } + all_client_info.append(client_info) + plan.print(network_params.network) + template_data = new_config_template_data( + HTTP_PORT_NUMBER, + all_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[TRACOOR_CONFIG_FILENAME] = template_and_data + + config_files_artifact_name = plan.render_templates( + template_and_data_by_rel_dest_filepath, "tracoor-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( + TRACOOR_CONFIG_MOUNT_DIRPATH_ON_SERVICE, + TRACOOR_CONFIG_FILENAME, + ) + + return ServiceConfig( + image=IMAGE_NAME, + ports=USED_PORTS, + files={ + TRACOOR_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name, + }, + cmd=[ + "single", + "--single-config={0}".format(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( + listen_port_num, + client_info, +): + return { + "ListenPortNum": listen_port_num, + "ParticipantClientInfo": client_info, + } + + +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, + } diff --git a/static_files/dora-config/config.yaml.tmpl b/static_files/dora-config/config.yaml.tmpl index e511fd468..78f559aec 100644 --- a/static_files/dora-config/config.yaml.tmpl +++ b/static_files/dora-config/config.yaml.tmpl @@ -47,9 +47,9 @@ beaconapi: executionapi: endpoints: -{{ range $clClient := .ELClientInfo }} - - url: "{{ $clClient.Execution_HTTP_URL }}" - name: "{{ $clClient.FullName }}" +{{ range $elClient := .ELClientInfo }} + - url: "{{ $elClient.Execution_HTTP_URL }}" + name: "{{ $elClient.FullName }}" archive: true {{- end }} depositLogBatchSize: 1000 diff --git a/static_files/tracoor-config/config.yaml.tmpl b/static_files/tracoor-config/config.yaml.tmpl new file mode 100644 index 000000000..9350ca2d8 --- /dev/null +++ b/static_files/tracoor-config/config.yaml.tmpl @@ -0,0 +1,39 @@ +server: + addr: ":8081" + metricsAddr: ":9091" + pprofAddr: ":6060" + gatewayAddr: ":{{ .ListenPortNum }}" + preStopSleepSeconds: 1 + ntpServer: time.google.com + + persistence: + dsn: "file:/tmp/tracoor.db" + driver_name: sqlite + + services: + indexer: + retention: + beaconStates: 30m + executionBlockTraces: 30m + beaconBlocks: 30m + +agents: +{{- range $client := .ParticipantClientInfo }} + - name: "{{ $client.Beacon.FullName }}" + ethereum: + overrideNetworkName: "{{ $client.Network }}" + beacon: + nodeAddress: "{{ $client.Beacon.Beacon_HTTP_URL }}" + execution: + nodeAddress: "{{ $client.Execution.Execution_HTTP_URL }}" +{{- end }} + +shared: + metricsAddr: ":9091" + logging: "debug" + indexer: + address: 0.0.0.0:8081 + store: + type: fs + config: + base_path: "/data/tracoor"