From a39e0a39ec41a1ed53dc66162ea4a05071a7deb9 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Fri, 27 Sep 2024 21:57:33 +0100 Subject: [PATCH 1/3] add commit-boost --- .github/tests/mev-commit-boost.yaml | 17 +++ README.md | 1 + main.star | 33 ++++- .../mev_boost/mev_boost_context.star | 11 ++ .../mev_boost/mev_boost_launcher.star | 124 ++++++++++++++++++ src/package_io/constants.star | 2 + src/package_io/input_parser.star | 23 +++- src/static_files/static_files.star | 4 + .../mev/commit-boost/cb-config.toml.tmpl | 10 ++ 9 files changed, 222 insertions(+), 3 deletions(-) create mode 100644 .github/tests/mev-commit-boost.yaml create mode 100644 src/mev/commit-boost/mev_boost/mev_boost_context.star create mode 100644 src/mev/commit-boost/mev_boost/mev_boost_launcher.star create mode 100644 static_files/mev/commit-boost/cb-config.toml.tmpl diff --git a/.github/tests/mev-commit-boost.yaml b/.github/tests/mev-commit-boost.yaml new file mode 100644 index 000000000..249624fb5 --- /dev/null +++ b/.github/tests/mev-commit-boost.yaml @@ -0,0 +1,17 @@ +participants: + - el_type: geth + cl_type: lighthouse +mev_type: commit-boost +additional_services: + - tx_spammer + - blob_spammer + - custom_flood + - el_forkmon + - beacon_metrics_gazer + - dora + - prometheus_grafana +mev_params: + mev_boost_image: ghcr.io/commit-boost/pbs:latest + mev_relay_image: flashbots/mev-boost-relay:latest +network_params: + seconds_per_slot: 3 diff --git a/README.md b/README.md index c73f7307b..608416fc5 100644 --- a/README.md +++ b/README.md @@ -736,6 +736,7 @@ persistent: false # "mock" - mock-builder & mev-boost are spun up # "flashbots" - mev-boost, relays, flooder and builder are all spun up, powered by [flashbots](https://github.com/flashbots) # "mev-rs" - mev-boost, relays and builder are all spun up, powered by [mev-rs](https://github.com/ralexstokes/mev-rs/) +# "commit-boost" - mev-boost, relays and builder are all spun up, powered by [commit-boost](https://github.com/Commit-Boost/commit-boost-client) # We have seen instances of multibuilder instances failing to start mev-relay-api with non zero epochs mev_type: null diff --git a/main.star b/main.star index 9dce197c9..a2bb4ec54 100644 --- a/main.star +++ b/main.star @@ -33,6 +33,9 @@ full_beaconchain_explorer = import_module( blockscout = import_module("./src/blockscout/blockscout_launcher.star") prometheus = import_module("./src/prometheus/prometheus_launcher.star") grafana = import_module("./src/grafana/grafana_launcher.star") +commit_boost_mev_boost = import_module( + "./src/mev/commit-boost/mev_boost/mev_boost_launcher.star" +) mev_rs_mev_boost = import_module("./src/mev/mev-rs/mev_boost/mev_boost_launcher.star") mev_rs_mev_relay = import_module("./src/mev/mev-rs/mev_relay/mev_relay_launcher.star") mev_rs_mev_builder = import_module( @@ -241,6 +244,7 @@ def run(plan, args={}): elif args_with_right_defaults.mev_type and ( args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE or args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE + or args_with_right_defaults.mev_type == constants.COMMIT_BOOST_MEV_TYPE ): builder_uri = "http://{0}:{1}".format( all_el_contexts[-1].ip_addr, all_el_contexts[-1].rpc_port_num @@ -274,7 +278,10 @@ def run(plan, args={}): timeout="20m", service_name=first_client_beacon_name, ) - if args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE: + if ( + args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE + or args_with_right_defaults.mev_type == constants.COMMIT_BOOST_MEV_TYPE + ): endpoint = flashbots_mev_relay.launch_mev_relay( plan, mev_params, @@ -367,6 +374,30 @@ def run(plan, args={}): el_cl_data_files_artifact_uuid, global_node_selectors, ) + elif ( + args_with_right_defaults.mev_type == constants.COMMIT_BOOST_MEV_TYPE + ): + plan.print("Launching commit-boost PBS service") + mev_boost_launcher = commit_boost_mev_boost.new_mev_boost_launcher( + MEV_BOOST_SHOULD_CHECK_RELAY, + mev_endpoints, + ) + mev_boost_service_name = "{0}-{1}-{2}-{3}".format( + input_parser.MEV_BOOST_SERVICE_NAME_PREFIX, + index_str, + participant.cl_type, + participant.el_type, + ) + mev_boost_context = commit_boost_mev_boost.launch( + plan, + mev_boost_launcher, + mev_boost_service_name, + network_params.network, + mev_params, + mev_endpoints, + el_cl_data_files_artifact_uuid, + global_node_selectors, + ) else: fail("Invalid MEV type") all_mevboost_contexts.append(mev_boost_context) diff --git a/src/mev/commit-boost/mev_boost/mev_boost_context.star b/src/mev/commit-boost/mev_boost/mev_boost_context.star new file mode 100644 index 000000000..1d6cb6c1d --- /dev/null +++ b/src/mev/commit-boost/mev_boost/mev_boost_context.star @@ -0,0 +1,11 @@ +def new_mev_boost_context(private_ip_address, port): + return struct( + private_ip_address=private_ip_address, + port=port, + ) + + +def mev_boost_endpoint(mev_boost_context): + return "http://{0}:{1}".format( + mev_boost_context.private_ip_address, mev_boost_context.port + ) diff --git a/src/mev/commit-boost/mev_boost/mev_boost_launcher.star b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star new file mode 100644 index 000000000..49bd1a05d --- /dev/null +++ b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star @@ -0,0 +1,124 @@ +shared_utils = import_module("../../../shared_utils/shared_utils.star") +mev_boost_context_module = import_module("../mev_boost/mev_boost_context.star") +input_parser = import_module("../../../package_io/input_parser.star") +static_files = import_module("../../../static_files/static_files.star") +constants = import_module("../../../package_io/constants.star") + +CB_CONFIG_FILENAME = "cb-config.toml" +CB_CONFIG_MOUNT_DIRPATH_ON_SERVICE = "/config" +CB_CONFIG_FILES_ARTIFACT_NAME = "commit-boost-config" + +USED_PORTS = { + "http": shared_utils.new_port_spec( + input_parser.MEV_BOOST_PORT, shared_utils.TCP_PROTOCOL + ) +} + +# The min/max CPU/memory that mev-boost can use +MIN_CPU = 10 +MAX_CPU = 500 +MIN_MEMORY = 16 +MAX_MEMORY = 256 + +KNOWN_NETWORKS = ( + "mainnet", + "holesky", +) + + +def launch( + plan, + mev_boost_launcher, + service_name, + network, + mev_params, + relays, + el_cl_genesis_data, + global_node_selectors, +): + network = ( + network + if network in KNOWN_NETWORKS + else constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER + "/config.yaml" + ) + + image = mev_params.mev_boost_image + template_data = new_config_template_data( + network, + input_parser.MEV_BOOST_PORT, + relays, + ) + + mev_rs_boost_config_template = read_file(static_files.COMMIT_BOOST_CONFIG_FILEPATH) + + template_and_data = shared_utils.new_template_and_data( + mev_rs_boost_config_template, template_data + ) + + template_and_data_by_rel_dest_filepath = {} + template_and_data_by_rel_dest_filepath[CB_CONFIG_FILENAME] = template_and_data + + config_files_artifact_name = plan.render_templates( + template_and_data_by_rel_dest_filepath, + CB_CONFIG_FILES_ARTIFACT_NAME + service_name, + ) + + config_file_path = shared_utils.path_join( + CB_CONFIG_MOUNT_DIRPATH_ON_SERVICE, CB_CONFIG_FILENAME + ) + + config = get_config( + mev_boost_launcher, + image, + config_file_path, + config_files_artifact_name, + el_cl_genesis_data, + global_node_selectors, + ) + + mev_boost_service = plan.add_service(service_name, config) + + return mev_boost_context_module.new_mev_boost_context( + mev_boost_service.ip_address, input_parser.MEV_BOOST_PORT + ) + + +def get_config( + mev_boost_launcher, + image, + config_file_path, + config_file, + el_cl_genesis_data, + node_selectors, +): + return ServiceConfig( + image=image, + ports=USED_PORTS, + cmd=[], + env_vars={ + "CB_CONFIG": config_file_path, + }, + files={ + CB_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_file, + constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: el_cl_genesis_data, + }, + min_cpu=MIN_CPU, + max_cpu=MAX_CPU, + min_memory=MIN_MEMORY, + max_memory=MAX_MEMORY, + node_selectors=node_selectors, + ) + + +def new_mev_boost_launcher(should_check_relay, relay_end_points): + return struct( + should_check_relay=should_check_relay, relay_end_points=relay_end_points + ) + + +def new_config_template_data(network, port, relays): + return { + "Network": network, + "Port": port, + "Relays": relays, + } diff --git a/src/package_io/constants.star b/src/package_io/constants.star index e35b52625..fb1a65192 100644 --- a/src/package_io/constants.star +++ b/src/package_io/constants.star @@ -79,6 +79,7 @@ KEYMANAGER_MOUNT_PATH_ON_CONTAINER = ( MOCK_MEV_TYPE = "mock" FLASHBOTS_MEV_TYPE = "flashbots" MEV_RS_MEV_TYPE = "mev-rs" +COMMIT_BOOST_MEV_TYPE = "commit-boost" DEFAULT_SNOOPER_IMAGE = "ethpandaops/rpc-snooper:latest" DEFAULT_FLASHBOTS_RELAY_IMAGE = "flashbots/mev-boost-relay:0.27" @@ -86,6 +87,7 @@ DEFAULT_FLASHBOTS_BUILDER_IMAGE = "flashbots/builder:latest" DEFAULT_FLASHBOTS_MEV_BOOST_IMAGE = "flashbots/mev-boost" DEFAULT_MEV_RS_IMAGE = "ethpandaops/mev-rs:main" DEFAULT_MEV_RS_IMAGE_MINIMAL = "ethpandaops/mev-rs:main-minimal" +DEFAULT_COMMIT_BOOST_MEV_BOOST_IMAGE = "ghcr.io/commit-boost/pbs:latest" DEFAULT_MEV_PUBKEY = "0xa55c1285d84ba83a5ad26420cd5ad3091e49c55a813eee651cd467db38a8c8e63192f47955e9376f6b42f6d190571cb5" DEFAULT_MEV_SECRET_KEY = ( "0x607a11b45a7219cc61a3d9c5fd08c7eebd602a6a19a977f8d3771d5711a550f2" diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index 7c4b7418e..a71437640 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -166,6 +166,7 @@ def input_parser(plan, input_args): constants.MOCK_MEV_TYPE, constants.FLASHBOTS_MEV_TYPE, constants.MEV_RS_MEV_TYPE, + constants.COMMIT_BOOST_MEV_TYPE, ): result = enrich_mev_extra_params( result, @@ -177,7 +178,7 @@ def input_parser(plan, input_args): pass else: fail( - "Unsupported MEV type: {0}, please use 'mock', 'flashbots' or 'mev-rs' type".format( + "Unsupported MEV type: {0}, please use 'mock', 'flashbots', 'mev-rs' or 'commit-boost' type".format( result.get("mev_type") ) ) @@ -971,6 +972,21 @@ def get_default_mev_params(mev_type, preset): mev_builder_extra_data = "0x68656C6C6F20776F726C640A" # "hello world\n" mev_builder_extra_args = ["--mev-builder-config=" + "/config/config.toml"] + if mev_type == constants.COMMIT_BOOST_MEV_TYPE: + mev_relay_image = constants.DEFAULT_FLASHBOTS_RELAY_IMAGE + mev_builder_image = constants.DEFAULT_FLASHBOTS_BUILDER_IMAGE + mev_boost_image = constants.DEFAULT_COMMIT_BOOST_MEV_BOOST_IMAGE + if preset == "minimal": + mev_builder_cl_image = DEFAULT_CL_IMAGES_MINIMAL[ + constants.CL_TYPE.lighthouse + ] + else: + mev_builder_cl_image = DEFAULT_CL_IMAGES[constants.CL_TYPE.lighthouse] + + mev_builder_extra_data = ( + "0x436f6d6d69742d426f6f737420f09f93bb" # Commit-Boost 📻 + ) + return { "mev_relay_image": mev_relay_image, "mev_builder_image": mev_builder_image, @@ -1148,7 +1164,10 @@ def enrich_mev_extra_params(parsed_arguments_dict, mev_prefix, mev_port, mev_typ index_str = shared_utils.zfill_custom( num_participants + 1, len(str(num_participants + 1)) ) - if mev_type == constants.FLASHBOTS_MEV_TYPE: + if ( + mev_type == constants.FLASHBOTS_MEV_TYPE + or mev_type == constants.COMMIT_BOOST_MEV_TYPE + ): mev_participant = default_participant() mev_participant["el_type"] = "geth" mev_participant.update( diff --git a/src/static_files/static_files.star b/src/static_files/static_files.star index b05031d71..2a4248a5f 100644 --- a/src/static_files/static_files.star +++ b/src/static_files/static_files.star @@ -96,3 +96,7 @@ MEV_RS_MEV_RELAY_CONFIG_FILEPATH = ( MEV_RS_MEV_BUILDER_CONFIG_FILEPATH = ( STATIC_FILES_DIRPATH + "/mev/mev-rs/mev_builder/config.toml.tmpl" ) + +COMMIT_BOOST_CONFIG_FILEPATH = ( + STATIC_FILES_DIRPATH + "/mev/commit-boost/cb-config.toml.tmpl" +) diff --git a/static_files/mev/commit-boost/cb-config.toml.tmpl b/static_files/mev/commit-boost/cb-config.toml.tmpl new file mode 100644 index 000000000..fd7692e0d --- /dev/null +++ b/static_files/mev/commit-boost/cb-config.toml.tmpl @@ -0,0 +1,10 @@ +chain = "{{ .Network }}" + +[pbs] +port = {{ .Port }} + +{{ range $index, $relay := .Relays }} +[[relays]] +id = "mev_relay_{{$index}}" +url = "{{ $relay }}" +{{- end }} \ No newline at end of file From ac2dfd0fe49c556147a7032ff5a9e047a92ca0a2 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Wed, 16 Oct 2024 21:14:52 +0100 Subject: [PATCH 2/3] address comments --- src/mev/commit-boost/mev_boost/mev_boost_launcher.star | 8 +------- src/package_io/input_parser.star | 8 +------- static_files/mev/commit-boost/cb-config.toml.tmpl | 6 +++++- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/mev/commit-boost/mev_boost/mev_boost_launcher.star b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star index 49bd1a05d..fcaf9d3f3 100644 --- a/src/mev/commit-boost/mev_boost/mev_boost_launcher.star +++ b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star @@ -20,12 +20,6 @@ MAX_CPU = 500 MIN_MEMORY = 16 MAX_MEMORY = 256 -KNOWN_NETWORKS = ( - "mainnet", - "holesky", -) - - def launch( plan, mev_boost_launcher, @@ -38,7 +32,7 @@ def launch( ): network = ( network - if network in KNOWN_NETWORKS + if network in constants.PUBLIC_NETWORKS else constants.GENESIS_CONFIG_MOUNT_PATH_ON_CONTAINER + "/config.yaml" ) diff --git a/src/package_io/input_parser.star b/src/package_io/input_parser.star index a71437640..6c0ded268 100644 --- a/src/package_io/input_parser.star +++ b/src/package_io/input_parser.star @@ -976,13 +976,7 @@ def get_default_mev_params(mev_type, preset): mev_relay_image = constants.DEFAULT_FLASHBOTS_RELAY_IMAGE mev_builder_image = constants.DEFAULT_FLASHBOTS_BUILDER_IMAGE mev_boost_image = constants.DEFAULT_COMMIT_BOOST_MEV_BOOST_IMAGE - if preset == "minimal": - mev_builder_cl_image = DEFAULT_CL_IMAGES_MINIMAL[ - constants.CL_TYPE.lighthouse - ] - else: - mev_builder_cl_image = DEFAULT_CL_IMAGES[constants.CL_TYPE.lighthouse] - + mev_builder_cl_image = DEFAULT_CL_IMAGES[constants.CL_TYPE.lighthouse] mev_builder_extra_data = ( "0x436f6d6d69742d426f6f737420f09f93bb" # Commit-Boost 📻 ) diff --git a/static_files/mev/commit-boost/cb-config.toml.tmpl b/static_files/mev/commit-boost/cb-config.toml.tmpl index fd7692e0d..fdb6cb2eb 100644 --- a/static_files/mev/commit-boost/cb-config.toml.tmpl +++ b/static_files/mev/commit-boost/cb-config.toml.tmpl @@ -7,4 +7,8 @@ port = {{ .Port }} [[relays]] id = "mev_relay_{{$index}}" url = "{{ $relay }}" -{{- end }} \ No newline at end of file +{{- end }} + +[logs] +log_level = "debug" +max_log_files = 7 From 64693984bd4a88f3e4f9d6371a476695d6afa657 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Wed, 16 Oct 2024 21:16:37 +0100 Subject: [PATCH 3/3] lint --- src/mev/commit-boost/mev_boost/mev_boost_launcher.star | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mev/commit-boost/mev_boost/mev_boost_launcher.star b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star index fcaf9d3f3..5b67a5dd0 100644 --- a/src/mev/commit-boost/mev_boost/mev_boost_launcher.star +++ b/src/mev/commit-boost/mev_boost/mev_boost_launcher.star @@ -20,6 +20,7 @@ MAX_CPU = 500 MIN_MEMORY = 16 MAX_MEMORY = 256 + def launch( plan, mev_boost_launcher,