Skip to content

Commit

Permalink
feat!: add mev-rs relay/builder/boost (#586)
Browse files Browse the repository at this point in the history
This PR introduces a new mev boost/mev relay created by @ralexstokes.
It can be triggered by:
`mev_type: mev-rs`

It gets rid of the previously used `full` flag and flashbots will work
under the `mev_type: flashbots` following this PR.
  • Loading branch information
barnabasbusa authored May 6, 2024
1 parent 2a20d5a commit 525a8fb
Show file tree
Hide file tree
Showing 38 changed files with 772 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .github/tests/mev.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mev_type: full
mev_type: flashbots
additional_services:
- tx_spammer
- blob_spammer
Expand Down
23 changes: 23 additions & 0 deletions .github/tests/minimal-mev-rs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
participants:
- el_type: geth
cl_type: teku
- el_type: geth
cl_type: prysm
- el_type: erigon
cl_type: nimbus
- el_type: besu
cl_type: lighthouse
- el_type: reth
cl_type: lodestar
- el_type: geth
cl_type: grandine
network_params:
preset: minimal
seconds_per_slot: 6
additional_services:
- dora
- tx_spammer
- apache

mev_type: mev-rs

7 changes: 0 additions & 7 deletions .github/tests/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ participants:
cl_type: teku
- el_type: geth
cl_type: prysm
cl_extra_params: [--minimal-config=true]
cl_image: ethpandaops/prysm-beacon-chain:develop-minimal
- el_type: erigon
cl_type: nimbus
cl_image: ethpandaops/nimbus-eth2:unstable-minimal
- el_type: besu
cl_type: lighthouse
cl_image: ethpandaops/lighthouse:unstable-minimal
- el_type: reth
cl_type: lodestar
cl_extra_env_vars: { LODESTAR_PRESET: minimal }
vc_extra_env_vars: { LODESTAR_PRESET: minimal }
- el_type: geth
cl_type: grandine
cl_image: ethpandaops/grandine:develop-minimal
network_params:
preset: minimal
seconds_per_slot: 6
Expand Down
2 changes: 1 addition & 1 deletion .github/tests/mix-with-tools-mev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ additional_services:
- apache
ethereum_metrics_exporter_enabled: true
snooper_enabled: true
mev_type: full
mev_type: flashbots
mev_params:
mev_relay_image: flashbots/mev-boost-relay:latest
persistent: True
2 changes: 1 addition & 1 deletion .github/tests/nimbus-mev.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
participants:
- el_type: geth
cl_type: nimbus
mev_type: full
mev_type: flashbots
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ v_max_mem -> vc_max_mem
### Global flags
```
global_client_log_level -> global_log_level
mev_type: full -> mev_type: flashbots # new rename as of 3 May 2024
```

To help you with the transition, we have added a script that will automatically update your `yaml` file to the new format. You can run the following command to update your network_params.yaml file:
Expand Down Expand Up @@ -665,7 +666,8 @@ persistent: false
# Supports three valeus
# Default: "null" - no mev boost, mev builder, mev flood or relays are spun up
# "mock" - mock-builder & mev-boost are spun up
# "full" - mev-boost, relays, flooder and builder are all 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/)
# We have seen instances of multibuilder instances failing to start mev-relay-api with non zero epochs
mev_type: null
Expand Down Expand Up @@ -841,7 +843,7 @@ participants:
- el_type: besu
cl_type: prysm
count: 2
mev_type: full
mev_type: flashbots
network_params:
deneb_fork_epoch: 1
additional_services: []
Expand Down
148 changes: 107 additions & 41 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ 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")
mev_boost = import_module("./src/mev/mev_boost/mev_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")
mev_flood = import_module("./src/mev/mev_flood/mev_flood_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(
"./src/mev/mev-rs/mev_builder/mev_builder_launcher.star"
)
flashbots_mev_boost = import_module(
"./src/mev/flashbots/mev_boost/mev_boost_launcher.star"
)
flashbots_mev_relay = import_module(
"./src/mev/flashbots/mev_relay/mev_relay_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(
"./src/mev/mev_custom_flood/mev_custom_flood_launcher.star"
"./src/mev/flashbots/mev_custom_flood/mev_custom_flood_launcher.star"
)
broadcaster = import_module("./src/broadcaster/broadcaster.star")
assertoor = import_module("./src/assertoor/assertoor_launcher.star")
Expand All @@ -49,8 +58,6 @@ FIRST_NODE_FINALIZATION_FACT = "cl-boot-finalization-fact"
HTTP_PORT_ID_FOR_FACT = "http"

MEV_BOOST_SHOULD_CHECK_RELAY = True
MOCK_MEV_TYPE = "mock"
FULL_MEV_TYPE = "full"
PATH_TO_PARSED_BEACON_STATE = "/genesis/output/parsedBeaconState.json"


Expand Down Expand Up @@ -92,6 +99,18 @@ def run(plan, args={}):

plan.print("Read the prometheus, grafana templates")

if args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE:
plan.print("Generating mev-rs builder config file")
mev_rs__builder_config_file = mev_rs_mev_builder.new_builder_config(
plan,
constants.MEV_RS_MEV_TYPE,
network_params.network,
constants.VALIDATING_REWARDS_ACCOUNT,
network_params.preregistered_validator_keys_mnemonic,
args_with_right_defaults.mev_params.mev_builder_extra_data,
global_node_selectors,
)

plan.print(
"Launching participant network with {0} participants and the following network params {1}".format(
num_participants, network_params
Expand Down Expand Up @@ -179,7 +198,7 @@ def run(plan, args={}):
# otherwise dummy relays spinup if chosen
elif (
args_with_right_defaults.mev_type
and args_with_right_defaults.mev_type == MOCK_MEV_TYPE
and args_with_right_defaults.mev_type == constants.MOCK_MEV_TYPE
):
el_uri = "{0}:{1}".format(
all_el_contexts[0].ip_addr,
Expand All @@ -197,13 +216,14 @@ def run(plan, args={}):
global_node_selectors,
)
mev_endpoints.append(endpoint)
elif (
args_with_right_defaults.mev_type
and args_with_right_defaults.mev_type == FULL_MEV_TYPE
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
):
builder_uri = "http://{0}:{1}".format(
all_el_contexts[-1].ip_addr, all_el_contexts[-1].rpc_port_num
)
beacon_uri = all_cl_contexts[-1].beacon_http_url
beacon_uris = ",".join(
["{0}".format(context.beacon_http_url) for context in all_cl_contexts]
)
Expand Down Expand Up @@ -232,17 +252,30 @@ def run(plan, args={}):
timeout="20m",
service_name=first_client_beacon_name,
)
endpoint = mev_relay.launch_mev_relay(
plan,
mev_params,
network_params.network_id,
beacon_uris,
genesis_validators_root,
builder_uri,
network_params.seconds_per_slot,
persistent,
global_node_selectors,
)
if args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE:
endpoint = flashbots_mev_relay.launch_mev_relay(
plan,
mev_params,
network_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")

mev_flood.spam_in_background(
plan,
fuzz_target,
Expand All @@ -260,26 +293,59 @@ def run(plan, args={}):
index_str = shared_utils.zfill_custom(
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,
plan.print(
"args_with_right_defaults.participants[index].validator_count {0}".format(
args_with_right_defaults.participants[index].validator_count
)
)
if args_with_right_defaults.participants[index].validator_count != 0:
if (
args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE
or args_with_right_defaults.mev_type == constants.MOCK_MEV_TYPE
):
mev_boost_launcher = flashbots_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 = flashbots_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,
)
elif args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE:
plan.print("Launching mev-rs mev boost")
mev_boost_launcher = mev_rs_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_rs_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)

if len(args_with_right_defaults.additional_services) == 0:
Expand Down
2 changes: 2 additions & 0 deletions rename.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ replacements=(
vc_max_mem
global_client_log_level
global_log_level
full
flashbots
)

# Perform replacements
Expand Down
12 changes: 6 additions & 6 deletions src/cl/cl_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ def launch(
cl_launchers = {
constants.CL_TYPE.lighthouse: {
"launcher": lighthouse.new_lighthouse_launcher(
el_cl_data, jwt_file, network_params.network
el_cl_data, jwt_file, network_params
),
"launch_method": lighthouse.launch,
},
constants.CL_TYPE.lodestar: {
"launcher": lodestar.new_lodestar_launcher(
el_cl_data, jwt_file, network_params.network
el_cl_data, jwt_file, network_params
),
"launch_method": lodestar.launch,
},
constants.CL_TYPE.nimbus: {
"launcher": nimbus.new_nimbus_launcher(
el_cl_data,
jwt_file,
network_params.network,
network_params,
keymanager_file,
),
"launch_method": nimbus.launch,
Expand All @@ -61,7 +61,7 @@ def launch(
"launcher": prysm.new_prysm_launcher(
el_cl_data,
jwt_file,
network_params.network,
network_params,
prysm_password_relative_filepath,
prysm_password_artifact_uuid,
),
Expand All @@ -71,7 +71,7 @@ def launch(
"launcher": teku.new_teku_launcher(
el_cl_data,
jwt_file,
network_params.network,
network_params,
keymanager_file,
),
"launch_method": teku.launch,
Expand All @@ -80,7 +80,7 @@ def launch(
"launcher": grandine.new_grandine_launcher(
el_cl_data,
jwt_file,
network_params.network,
network_params,
),
"launch_method": grandine.launch,
},
Expand Down
4 changes: 2 additions & 2 deletions src/cl/grandine/grandine_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def get_beacon_config(
def new_grandine_launcher(
el_cl_genesis_data,
jwt_file,
network,
network_params,
):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
network=network,
network=network_params.network,
)
4 changes: 2 additions & 2 deletions src/cl/lighthouse/lighthouse_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,9 @@ def get_beacon_config(
)


def new_lighthouse_launcher(el_cl_genesis_data, jwt_file, network):
def new_lighthouse_launcher(el_cl_genesis_data, jwt_file, network_params):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
network=network,
network=network_params.network,
)
Loading

0 comments on commit 525a8fb

Please sign in to comment.