Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Bolt Boost and Helix configuration #9

Merged
merged 11 commits into from
Oct 3, 2024
126 changes: 79 additions & 47 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ blockscout = import_module("./src/blockscout/blockscout_launcher.star")
prometheus = import_module("./src/prometheus/prometheus_launcher.star")
grafana = import_module("./src/grafana/grafana_launcher.star")
mev_boost = import_module("./src/mev/mev_boost/mev_boost_launcher.star")
bolt_boost = import_module("./src/mev/bolt-boost/bolt-boost-launcher.star")
mock_mev = import_module("./src/mev/mock_mev/mock_mev_launcher.star")
mev_relay = import_module("./src/mev/mev_relay/mev_relay_launcher.star")
helix_relay = import_module("./src/mev/mev_relay/helix_launcher.star")
mev_flood = import_module("./src/mev/mev_flood/mev_flood_launcher.star")
mev_custom_flood = import_module(
"./src/mev/mev_custom_flood/mev_custom_flood_launcher.star"
Expand Down Expand Up @@ -126,10 +128,11 @@ def run(plan, args={}):
)
)

mev_sidecar_context=struct(
ip_addr="",
metrics_port_num=0,
)
#mev_sidecar_context=struct(
# ip_addr="",
# metrics_port_num=0,
#)
mev_sidecar_context = None
all_el_contexts = []
all_cl_contexts = []
all_vc_contexts = []
Expand Down Expand Up @@ -212,6 +215,7 @@ def run(plan, args={}):
beacon_uris = ",".join(
["{0}".format(context.beacon_http_url) for context in all_cl_contexts]
)
plan.print(beacon_uris)

first_cl_client = all_cl_contexts[0]
first_client_beacon_name = first_cl_client.beacon_service_name
Expand All @@ -237,15 +241,16 @@ def run(plan, args={}):
timeout="20m",
service_name=first_client_beacon_name,
)
endpoint = mev_relay.launch_mev_relay(
helix_endpoint = helix_relay.launch_helix_relay(
plan,
mev_params,
network_params.network_id,
network_params,
beacon_uris,
genesis_validators_root,
builder_uri,
network_params.seconds_per_slot,
persistent,
final_genesis_timestamp,
global_node_selectors,
)
mev_flood.spam_in_background(
Expand All @@ -256,7 +261,7 @@ def run(plan, args={}):
contract_owner.private_key,
normal_user.private_key,
)
mev_endpoints.append(endpoint)
mev_endpoints.append(helix_endpoint)

# spin up the mev boost contexts if some endpoints for relays have been passed
all_mevboost_contexts = []
Expand All @@ -266,47 +271,74 @@ def run(plan, args={}):
index + 1, len(str(len(all_participants)))
)
if args_with_right_defaults.participants[index].validator_count != 0:
mev_boost_launcher = 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 = mev_boost.launch(
plan,
mev_boost_launcher,
mev_boost_service_name,
network_params.network_id,
mev_params.mev_boost_image,
mev_params.mev_boost_args,
global_node_selectors,
network_params,
)
all_mevboost_contexts.append(mev_boost_context)
if mev_params.bolt_boost_image == None:
mev_boost_launcher = 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 = mev_boost.launch(
plan,
mev_boost_launcher,
mev_boost_service_name,
network_params.network_id,
mev_params.mev_boost_image,
mev_params.mev_boost_args,
global_node_selectors,
network_params,
)
all_mevboost_contexts.append(mev_boost_context)

# add mev-sidecar
mev_sidecar_ctx = mev_sidecar.launch_mev_sidecar(
plan,
mev_params,
global_node_selectors,
mev_boost_context,
all_cl_contexts[0].beacon_http_url,
"http://{0}:{1}".format(
all_el_contexts[0].ip_addr,
all_el_contexts[0].rpc_port_num,
),
"http://{0}:{1}".format(
all_el_contexts[0].ip_addr,
all_el_contexts[0].engine_rpc_port_num
),
raw_jwt_secret,
network_params.seconds_per_slot
)
mev_sidecar_context = mev_sidecar_ctx
else:
bolt_boost_service_name = "{0}-{1}-{2}-{3}".format(
input_parser.BOLT_BOOST_SERVICE_NAME_PREFIX,
index_str,
participant.cl_type,
participant.el_type,
)
relays_config = [{
"id": "helix_relay",
"url": helix_endpoint,
}]
bolt_sidecar_config = {
"constraints_api_url": "{0}:{1}".format(
mev_sidecar.MEV_SIDECAR_ENDPOINT, mev_sidecar.MEV_SIDECAR_ENDPOINT_PORT
),
"beacon_api_url": all_cl_contexts[0].beacon_http_url,
"execution_api_url": "http://{0}:{1}".format(
all_el_contexts[0].ip_addr,
all_el_contexts[0].rpc_port_num,
),
"engine_api_url": "http://{0}:{1}".format(
all_el_contexts[0].ip_addr,
all_el_contexts[0].engine_rpc_port_num
),
"jwt_hex": raw_jwt_secret,
"metrics_port": mev_sidecar.MEV_SIDECAR_METRICS_PORT,
}
bolt_boost_context = bolt_boost.launch(
plan,
mev_params.bolt_boost_image,
bolt_boost_service_name,
relays_config,
bolt_sidecar_config,
network_params,
global_node_selectors,
)
all_mevboost_contexts.append(bolt_boost_context)
# add mev-sidecar
mev_sidecar_context = mev_sidecar.launch_mev_sidecar(
plan,
mev_params.mev_sidecar_image,
bolt_sidecar_config,
network_params,
global_node_selectors,
)

if len(args_with_right_defaults.additional_services) == 0:
output = struct(
Expand Down
117 changes: 117 additions & 0 deletions src/mev/bolt-boost/bolt-boost-launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
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")

FLASHBOTS_MEV_BOOST_PROTOCOL = "TCP"

SERVICE_NAME="bolt-boost"
BOLT_BOOST_CONFIG_FILENAME="cb-bolt-config.toml"
BOLT_BOOST_CONFIG_MOUNT_DIRPATH_ON_SERVICE="/config"
BOLT_BOOST_BUILDER_PROXY_PORT=18551

USED_PORTS = {
"api": shared_utils.new_port_spec(
input_parser.FLASHBOTS_MEV_BOOST_PORT, FLASHBOTS_MEV_BOOST_PROTOCOL, wait="5s"
)
}

# The min/max CPU/memory that mev-boost can use
MIN_CPU = 10
MAX_CPU = 500
MIN_MEMORY = 16
MAX_MEMORY = 256


def launch(
plan,
bolt_boost_image,
service_name,
relays_config,
bolt_sidecar_config,
network_params,
global_node_selectors,
):
config = get_bolt_boost_config(
plan,
bolt_boost_image,
relays_config,
bolt_sidecar_config,
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.FLASHBOTS_MEV_BOOST_PORT
)


def get_bolt_boost_config(
plan,
image,
relays_config,
bolt_sidecar_config,
node_selectors,
):
# Read the template file for Bolt Boost configuration
bolt_boost_config_template = read_file(
static_files.BOLT_BOOST_CONFIG_TEMPLATE_FILEPATH
)

# Generate the data to be used in the Bolt Boost configuration,
# wrap them together in a struct
bolt_boost_config_template_data = new_bolt_boost_config_template_data(image, relays_config, bolt_sidecar_config)
bolt_boost_config_template_and_data = shared_utils.new_template_and_data(
bolt_boost_config_template, bolt_boost_config_template_data
)

# Map the relative destination filepaths to the template/data pairs
template_and_data_by_rel_dest_filepath = {}
template_and_data_by_rel_dest_filepath[BOLT_BOOST_CONFIG_FILENAME] = bolt_boost_config_template_and_data

# Render the templates to files in the artifact directory
config_files_artifact_name = plan.render_templates(
template_and_data_by_rel_dest_filepath
)

return ServiceConfig(
image=image,
ports=USED_PORTS,
files={
BOLT_BOOST_CONFIG_MOUNT_DIRPATH_ON_SERVICE: config_files_artifact_name
},
env_vars={
"CB_CONFIG": shared_utils.path_join(
BOLT_BOOST_CONFIG_MOUNT_DIRPATH_ON_SERVICE,
BOLT_BOOST_CONFIG_FILENAME,
)
},
min_cpu=MIN_CPU,
max_cpu=MAX_CPU,
min_memory=MIN_MEMORY,
max_memory=MAX_MEMORY,
node_selectors=node_selectors,
)

def new_bolt_boost_config_template_data(image, relays_config, bolt_sidecar_config):
return {
"chain": "Holesky",
thedevbirb marked this conversation as resolved.
Show resolved Hide resolved
"image": image,
"port": input_parser.FLASHBOTS_MEV_BOOST_PORT,
"relays_config": [
{
"id": relay_config["id"],
"url": relay_config["url"],
} for relay_config in relays_config
],
"bolt_sidecar_config": {
"constraints_api_url": bolt_sidecar_config["constraints_api_url"],
"beacon_api_url": bolt_sidecar_config["beacon_api_url"],
"execution_api_url": bolt_sidecar_config["execution_api_url"],
"engine_api_url": bolt_sidecar_config["engine_api_url"],
"jwt_hex": bolt_sidecar_config["jwt_hex"],
"metrics_port": bolt_sidecar_config["metrics_port"],
"builder_proxy_port": BOLT_BOOST_BUILDER_PROXY_PORT,
}
}
Loading
Loading