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

Bolt mev boost support #1

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/tests/mev-commit-boost.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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_boost_image: ghcr.io/chainbound/bolt-boost:v0.3.0-alpha
mev_relay_image: flashbots/mev-boost-relay:latest
network_params:
seconds_per_slot: 3
128 changes: 103 additions & 25 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ 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"
)
bolt_boost = import_module("./src/mev/bolt_boost/bolt_boost_launcher.star")
bolt_sidecar = import_module("./src/mev/bolt_sidecar/bolt_sidecar_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(
Expand All @@ -44,6 +49,7 @@ flashbots_mev_boost = import_module(
flashbots_mev_relay = import_module(
"./src/mev/flashbots/mev_relay/mev_relay_launcher.star"
)
helix_relay = import_module("./src/mev/mev_relay/helix_launcher.star")
mock_mev = import_module("./src/mev/flashbots/mock_mev/mock_mev_launcher.star")
mev_flood = import_module("./src/mev/flashbots/mev_flood/mev_flood_launcher.star")
mev_custom_flood = import_module(
Expand Down Expand Up @@ -259,6 +265,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
Expand Down Expand Up @@ -292,29 +299,31 @@ def run(plan, args={}):
timeout="20m",
service_name=first_client_beacon_name,
)
if args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE:
endpoint = flashbots_mev_relay.launch_mev_relay(
plan,
mev_params,
network_id,
beacon_uris,
genesis_validators_root,
builder_uri,
network_params.seconds_per_slot,
persistent,
global_node_selectors,
)
elif args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE:
endpoint, relay_ip_address, relay_port = mev_rs_mev_relay.launch_mev_relay(
plan,
mev_params,
network_params.network,
beacon_uri,
el_cl_data_files_artifact_uuid,
global_node_selectors,
)
else:
fail("Invalid MEV type")

# Get real genesis timestamp for helix
bolt_genesis_timestamp = plan.run_python(
description="Getting real genesis timestamp for helix",
run="""
import sys
a = int(sys.argv[1])
b = int(sys.argv[2])
print(int(a+b), end="")
""",
args=[str(final_genesis_timestamp),str(network_params.genesis_delay)],
).output
# Run helix relay
helix_endpoint = helix_relay.launch_helix_relay(
plan,
mev_params,
network_params,
beacon_uris,
genesis_validators_root,
builder_uri,
network_params.seconds_per_slot,
persistent,
bolt_genesis_timestamp,
global_node_selectors,
)

# Restart MEV builder
plan.stop_service(
Expand All @@ -335,7 +344,7 @@ def run(plan, args={}):
contract_owner.private_key,
normal_user.private_key,
)
mev_endpoints.append(endpoint)
mev_endpoints.append(helix_endpoint)
mev_endpoint_names.append(args_with_right_defaults.mev_type)

# spin up the mev boost contexts if some endpoints for relays have been passed
Expand All @@ -351,6 +360,25 @@ def run(plan, args={}):
)
)
if args_with_right_defaults.participants[index].validator_count != 0:
# Initialize the Bolt Sidecar configure if needed
bolt_sidecar_config = None
if mev_params.bolt_sidecar_image != None:
# NOTE: this is a stub missing the `"constraints_api_url"` entry
bolt_sidecar_config = {
"beacon_api_url": participant.cl_context.beacon_http_url,
"execution_api_url": "http://{0}:{1}".format(
participant.el_context.ip_addr,
participant.el_context.rpc_port_num,
),
"engine_api_url": "http://{0}:{1}".format(
participant.el_context.ip_addr,
participant.el_context.engine_rpc_port_num
),
"jwt_hex": raw_jwt_secret,
"metrics_port": bolt_sidecar.BOLT_SIDECAR_METRICS_PORT,
"validator_keystore_files_artifact_uuid": participant.cl_context.validator_keystore_files_artifact_uuid,
"participant_index": index,
}
if (
args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE
or args_with_right_defaults.mev_type == constants.MOCK_MEV_TYPE
Expand Down Expand Up @@ -396,10 +424,59 @@ 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 bolt boost service")
mev_boost_launcher = commit_boost_mev_boost.new_mev_boost_launcher(
MEV_BOOST_SHOULD_CHECK_RELAY,
mev_endpoints,
)

bolt_boost_service_name = "{0}-{1}-{2}-{3}".format(
input_parser.MEV_BOOST_SERVICE_NAME_PREFIX,
index_str,
participant.cl_type,
participant.el_type,
)
relays_config = [{
"id": "helix_relay",
"url": helix_endpoint,
}]
if bolt_sidecar_config != None:
bolt_sidecar_config["constraints_api_url"] = "http://{0}:{1}".format(
bolt_boost_service_name, input_parser.MEV_BOOST_PORT
)
mev_boost_context = bolt_boost.launch(
plan,
bolt_boost_service_name,
mev_params.bolt_boost_image,
relays_config,
bolt_sidecar_config,
network_params,
bolt_genesis_timestamp,
global_node_selectors,
)
else:
fail("Invalid MEV type")
all_mevboost_contexts.append(mev_boost_context)

if bolt_sidecar_config != None:
service_name = "{0}-{1}-{2}-{3}".format(
input_parser.BOLT_SIDECAR_SERVICE_NAME_PREFIX,
index_str,
participant.cl_type,
participant.el_type,
)
bolt_sidecar_config["service_name"] = service_name
bolt_sidecar_context = bolt_sidecar.launch_bolt_sidecar(
plan,
mev_params.bolt_sidecar_image,
bolt_sidecar_config,
network_params,
global_node_selectors,
)

if len(args_with_right_defaults.additional_services) == 0:
output = struct(
all_participants=all_participants,
Expand Down Expand Up @@ -746,10 +823,10 @@ def run(plan, args={}):
p2pbootnode_context = p2p_bootnode.launch(
plan,
)

# Launch Preconf AVS 1
preconf_avs.launch(
plan,
preconf_params.preconf_avs_image,
network_id,
all_el_contexts[0],
all_cl_contexts[0],
Expand All @@ -767,6 +844,7 @@ def run(plan, args={}):
# Launch Preconf AVS 2
preconf_avs.launch(
plan,
preconf_params.preconf_avs_image,
network_id,
all_el_contexts[0],
all_cl_contexts[0],
Expand Down
10 changes: 7 additions & 3 deletions network_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ parallel_keystore_generation: false
disable_peer_scoring: false
grafana_additional_dashboards: []
persistent: false
mev_type: flashbots
mev_type: commit-boost
mev_params:
mev_relay_image: ghcr.io/chainbound/bolt-relay:v0.2.1-alpha
mev_builder_image: ghcr.io/chainbound/bolt-builder:v0.2.1-alpha
mev_builder_image: ghcr.io/chainbound/bolt-builder:v0.3.0-alpha.rc3
mev_builder_cl_image: sigp/lighthouse:latest
mev_boost_image: ghcr.io/chainbound/bolt-mev-boost:v0.2.1-alpha
mev_boost_image: ghcr.io/chainbound/bolt-boost:v0.3.0-alpha
bolt_sidecar_image: ghcr.io/chainbound/bolt-sidecar:v0.3.0-alpha
bolt_boost_image: ghcr.io/chainbound/bolt-boost:v0.3.0-alpha
helix_relay_image: ghcr.io/chainbound/helix:v0.3.0-alpha.rc4
helix_relay_config_extension: {}
mev_boost_args: ["mev-boost", "--relay-check"]
mev_relay_api_extra_args: []
mev_relay_housekeeper_extra_args: []
Expand Down
2 changes: 1 addition & 1 deletion src/cl/lighthouse/lighthouse_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def get_beacon_config(
"--http",
"--http-address=0.0.0.0",
"--http-port={0}".format(BEACON_HTTP_PORT_NUM),
"--http-allow-sync-stalled",
# "--http-allow-sync-stalled",
"--slots-per-restore-point={0}".format(32 if constants.ARCHIVE_MODE else 8192),
# NOTE: This comes from:
# https://github.com/sigp/lighthouse/blob/7c88f582d955537f7ffff9b2c879dcf5bf80ce13/scripts/local_testnet/beacon_node.sh
Expand Down
138 changes: 138 additions & 0 deletions src/mev/bolt_boost/bolt_boost_launcher.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
shared_utils = import_module("../../shared_utils/shared_utils.star")
mev_boost_context_module = import_module("../mev_boost/mev_boost_context.star")
static_files = import_module("../../static_files/static_files.star")
constants = import_module("../../package_io/constants.star")
input_parser = import_module("../../package_io/input_parser.star")

BOLT_BOOST_CONFIG_FILENAME="cb-bolt-config.toml"
BOLT_BOOST_CONFIG_MOUNT_DIRPATH_ON_SERVICE="/config"

USED_PORTS = {
"api": shared_utils.new_port_spec(
input_parser.MEV_BOOST_PORT, "TCP", 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,
service_name,
bolt_boost_image,
relays_config,
bolt_sidecar_config,
network_params,
final_genesis_timestamp,
global_node_selectors,
):
plan.print(network_params)
config = get_bolt_boost_config(
plan,
bolt_boost_image,
relays_config,
bolt_sidecar_config,
network_params,
final_genesis_timestamp,
global_node_selectors,
)

bolt_boost_service = plan.add_service(service_name, config)

return mev_boost_context_module.new_mev_boost_context(
bolt_boost_service.ip_address, bolt_boost_service.ports["api"].number
)


def get_bolt_boost_config(
plan,
image,
relays_config,
bolt_sidecar_config,
network_params,
final_genesis_timestamp,
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,
network_params,
final_genesis_timestamp,
)
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={
"RUST_LOG": "debug",
"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,
network_params,
final_genesis_timestamp,
):
return {
"chain_config": {
"name": network_params.network.capitalize(),
"genesis_timestamp": final_genesis_timestamp,
"seconds_per_slot": network_params.seconds_per_slot,
"genesis_fork_version": constants.GENESIS_FORK_VERSION,
},
"image": image,
"port": input_parser.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": input_parser.MEV_BOOST_PORT,
}
}
Loading