From fe79e49a98d04104abeb8f03b11c7beb51c50b60 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Wed, 17 Apr 2024 11:46:20 +0200 Subject: [PATCH 1/3] feat: add dugtrio beacon load balancer --- .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 | 2 +- main.star | 14 +++ src/dugtrio/dugtrio_launcher.star | 110 +++++++++++++++++++ src/static_files/static_files.star | 1 + static_files/dugtrio-config/config.yaml.tmpl | 57 ++++++++++ 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 src/dugtrio/dugtrio_launcher.star create mode 100644 static_files/dugtrio-config/config.yaml.tmpl diff --git a/.github/tests/mix-with-tools-mev.yaml b/.github/tests/mix-with-tools-mev.yaml index 829d88381..97b6b8501 100644 --- a/.github/tests/mix-with-tools-mev.yaml +++ b/.github/tests/mix-with-tools-mev.yaml @@ -22,6 +22,7 @@ additional_services: - custom_flood - blobscan - blockscout + - dugtrio ethereum_metrics_exporter_enabled: true snooper_enabled: true mev_type: full diff --git a/.github/tests/mix-with-tools-minimal.yaml b/.github/tests/mix-with-tools-minimal.yaml index 3240340ff..fcee8c720 100644 --- a/.github/tests/mix-with-tools-minimal.yaml +++ b/.github/tests/mix-with-tools-minimal.yaml @@ -32,6 +32,7 @@ additional_services: - custom_flood - blobscan - blockscout + - dugtrio 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 f172b0ce6..b8f635404 100644 --- a/.github/tests/mix-with-tools.yaml +++ b/.github/tests/mix-with-tools.yaml @@ -24,6 +24,7 @@ additional_services: - custom_flood - blobscan - blockscout + - dugtrio ethereum_metrics_exporter_enabled: true snooper_enabled: true keymanager_enabled: true diff --git a/README.md b/README.md index e7f466205..a5aac1ef5 100644 --- a/README.md +++ b/README.md @@ -542,7 +542,7 @@ additional_services: - full_beaconchain_explorer - prometheus_grafana - blobscan - + - dugtrio # Configuration place for transaction spammer - https:#github.com/MariusVanDerWijden/tx-fuzz tx_spammer_params: diff --git a/main.star b/main.star index a77d8cc61..391e2d1c1 100644 --- a/main.star +++ b/main.star @@ -21,6 +21,7 @@ beacon_metrics_gazer = import_module( "./src/beacon_metrics_gazer/beacon_metrics_gazer_launcher.star" ) dora = import_module("./src/dora/dora_launcher.star") +dugtrio = import_module("./src/dugtrio/dugtrio_launcher.star") blobscan = import_module("./src/blobscan/blobscan_launcher.star") full_beaconchain_explorer = import_module( "./src/full_beaconchain/full_beaconchain_launcher.star" @@ -382,6 +383,19 @@ def run(plan, args={}): global_node_selectors, ) plan.print("Successfully launched dora") + elif additional_service == "dugtrio": + plan.print("Launching dugtrio") + dugtrio_config_template = read_file(static_files.DUGTRIO_CONFIG_TEMPLATE_FILEPATH) + dugtrio.launch_dugtrio( + plan, + dugtrio_config_template, + all_participants, + args_with_right_defaults.participants, + el_cl_data_files_artifact_uuid, + network_params, + global_node_selectors, + ) + plan.print("Successfully launched dugtrio") elif additional_service == "blobscan": plan.print("Launching blobscan") blobscan.launch_blobscan( diff --git a/src/dugtrio/dugtrio_launcher.star b/src/dugtrio/dugtrio_launcher.star new file mode 100644 index 000000000..b3efebc78 --- /dev/null +++ b/src/dugtrio/dugtrio_launcher.star @@ -0,0 +1,110 @@ +shared_utils = import_module("../shared_utils/shared_utils.star") +constants = import_module("../package_io/constants.star") +SERVICE_NAME = "dugtrio" + +HTTP_PORT_ID = "http" +HTTP_PORT_NUMBER = 8080 + +DUGTRIO_CONFIG_FILENAME = "dugtrio-config.yaml" + +DUGTRIO_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" + +IMAGE_NAME = "ethpandaops/dugtrio:latest" + +# The min/max CPU/memory that dugtrio 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_dugtrio( + plan, + config_template, + participant_contexts, + participant_configs, + el_cl_data_files_artifact_uuid, + network_params, + global_node_selectors, +): + all_cl_client_info = [] + for index, participant in enumerate(participant_contexts): + full_name, cl_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, + ) + ) + + template_data = new_config_template_data( + network_params.network, HTTP_PORT_NUMBER, all_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[DUGTRIO_CONFIG_FILENAME] = template_and_data + + config_files_artifact_name = plan.render_templates( + template_and_data_by_rel_dest_filepath, "dugtrio-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( + DUGTRIO_CONFIG_MOUNT_DIRPATH_ON_SERVICE, + DUGTRIO_CONFIG_FILENAME, + ) + + return ServiceConfig( + image=IMAGE_NAME, + ports=USED_PORTS, + files={ + DUGTRIO_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_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, listen_port_num, cl_client_info): + return { + "Network": network, + "ListenPortNum": listen_port_num, + "CLClientInfo": cl_client_info, + } + +def new_cl_client_info(beacon_http_url, full_name): + return { + "Beacon_HTTP_URL": beacon_http_url, + "FullName": full_name, + } diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index 98d2c838e..fb55dfd1c 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -17,6 +17,7 @@ VALIDATOR_RANGES_CONFIG_TEMPLATE_FILEPATH = ( ) DORA_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dora-config/config.yaml.tmpl" +DUGTRIO_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dugtrio-config/config.yaml.tmpl" FULL_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = ( STATIC_FILES_DIRPATH + "/full-beaconchain-config/config.yaml.tmpl" diff --git a/static_files/dugtrio-config/config.yaml.tmpl b/static_files/dugtrio-config/config.yaml.tmpl new file mode 100644 index 000000000..d74488717 --- /dev/null +++ b/static_files/dugtrio-config/config.yaml.tmpl @@ -0,0 +1,57 @@ +logging: + outputLevel: "debug" + #outputStderr: false + #filePath: "explorer.log" + #fileLevel: "warn" + +# HTTP Server configuration +server: + # Address to listen on + host: "0.0.0.0" + + # Port to listen on + port: "8080" + +# Beacon Node Endpoints +endpoints: +{{ range $clClient := .CLClientInfo }} + - url: "{{ $clClient.Beacon_HTTP_URL }}" + name: "{{ $clClient.FullName }}" +{{- end }} + +# Pool configuration +pool: + schedulerMode: "rr" + followDistance: 10 + maxHeadDistance: 2 + +# Proxy configuration +proxy: + # number of proxies in front of dugtrio + proxyCount: 0 + + # proxy call timeout + callTimeout: 60s + + # proxy session timeout + sessionTimeout: 10m + + # reuse the same endpoint when possible + stickyEndpoint: true + + # call rate limit (calls per second) + callRateLimit: 100 + + # call rate burst limit + callRateBurst: 1000 + + # blocked api paths (regex patterns) + blockedPaths: + - ^/eth/v[0-9]+/debug/.* + +# Frontend configuration +frontend: + # Enable or disable to web frontend + enabled: true + minify: true + siteName: "Dugtrio-Kurtosis" From eb4621b0aadf113391db8d72b98bb3d804feaeeb Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Wed, 17 Apr 2024 12:00:30 +0200 Subject: [PATCH 2/3] fix lint --- main.star | 4 +++- src/dugtrio/dugtrio_launcher.star | 3 +++ src/static_files/static_files.star | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.star b/main.star index 391e2d1c1..40f5da0de 100644 --- a/main.star +++ b/main.star @@ -385,7 +385,9 @@ def run(plan, args={}): plan.print("Successfully launched dora") elif additional_service == "dugtrio": plan.print("Launching dugtrio") - dugtrio_config_template = read_file(static_files.DUGTRIO_CONFIG_TEMPLATE_FILEPATH) + dugtrio_config_template = read_file( + static_files.DUGTRIO_CONFIG_TEMPLATE_FILEPATH + ) dugtrio.launch_dugtrio( plan, dugtrio_config_template, diff --git a/src/dugtrio/dugtrio_launcher.star b/src/dugtrio/dugtrio_launcher.star index b3efebc78..3276a5384 100644 --- a/src/dugtrio/dugtrio_launcher.star +++ b/src/dugtrio/dugtrio_launcher.star @@ -25,6 +25,7 @@ USED_PORTS = { ) } + def launch_dugtrio( plan, config_template, @@ -96,6 +97,7 @@ def get_config( node_selectors=node_selectors, ) + def new_config_template_data(network, listen_port_num, cl_client_info): return { "Network": network, @@ -103,6 +105,7 @@ def new_config_template_data(network, listen_port_num, cl_client_info): "CLClientInfo": cl_client_info, } + def new_cl_client_info(beacon_http_url, full_name): return { "Beacon_HTTP_URL": beacon_http_url, diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index fb55dfd1c..dad3520df 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -17,7 +17,9 @@ VALIDATOR_RANGES_CONFIG_TEMPLATE_FILEPATH = ( ) DORA_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dora-config/config.yaml.tmpl" -DUGTRIO_CONFIG_TEMPLATE_FILEPATH = STATIC_FILES_DIRPATH + "/dugtrio-config/config.yaml.tmpl" +DUGTRIO_CONFIG_TEMPLATE_FILEPATH = ( + STATIC_FILES_DIRPATH + "/dugtrio-config/config.yaml.tmpl" +) FULL_BEACONCHAIN_CONFIG_TEMPLATE_FILEPATH = ( STATIC_FILES_DIRPATH + "/full-beaconchain-config/config.yaml.tmpl" From 87dea905565ff4883a89ecee12d1102111760ae2 Mon Sep 17 00:00:00 2001 From: Barnabas Busa Date: Wed, 17 Apr 2024 13:08:39 +0200 Subject: [PATCH 3/3] fix lint, cleanup --- main.star | 1 - src/dugtrio/dugtrio_launcher.star | 14 +++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/main.star b/main.star index 40f5da0de..2fc721354 100644 --- a/main.star +++ b/main.star @@ -393,7 +393,6 @@ def run(plan, args={}): dugtrio_config_template, all_participants, args_with_right_defaults.participants, - el_cl_data_files_artifact_uuid, network_params, global_node_selectors, ) diff --git a/src/dugtrio/dugtrio_launcher.star b/src/dugtrio/dugtrio_launcher.star index 3276a5384..968460a32 100644 --- a/src/dugtrio/dugtrio_launcher.star +++ b/src/dugtrio/dugtrio_launcher.star @@ -31,7 +31,6 @@ def launch_dugtrio( config_template, participant_contexts, participant_configs, - el_cl_data_files_artifact_uuid, network_params, global_node_selectors, ): @@ -60,10 +59,8 @@ def launch_dugtrio( config_files_artifact_name = plan.render_templates( template_and_data_by_rel_dest_filepath, "dugtrio-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, ) @@ -73,7 +70,6 @@ def launch_dugtrio( def get_config( config_files_artifact_name, - el_cl_data_files_artifact_uuid, network_params, node_selectors, ): @@ -87,7 +83,6 @@ def get_config( ports=USED_PORTS, files={ DUGTRIO_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name, - constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_data_files_artifact_uuid, }, cmd=["-config", config_file_path], min_cpu=MIN_CPU, @@ -95,6 +90,15 @@ def get_config( min_memory=MIN_MEMORY, max_memory=MAX_MEMORY, node_selectors=node_selectors, + ready_conditions=ReadyCondition( + recipe=GetHttpRequestRecipe( + port_id="http", + endpoint="/healthcheck", + ), + field="code", + assertion="==", + target_value=200, + ), )