Skip to content

Commit

Permalink
fix: dont wait for epoch 1 and launch MEV before tx-fuzz (#210)
Browse files Browse the repository at this point in the history
I believe mev contract deployment breaks when tx-fuzz starts first as
transactions are reported as underpriced
  • Loading branch information
h4ck3rk3y authored Sep 20, 2023
1 parent 23628b2 commit 8b883af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 40 deletions.
64 changes: 28 additions & 36 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,39 @@ def run(plan, args = {}):
if not args_with_right_defaults.launch_additional_services:
return


mev_endpoints = []
# passed external relays get priority
# perhaps add mev_type External or remove this
if hasattr(participant, "builder_network_params") and participant.builder_network_params != None:
mev_endpoints = participant.builder_network_params.relay_end_points
# otherwise dummy relays spinup if chosen
elif args_with_right_defaults.mev_type and args_with_right_defaults.mev_type == MOCK_MEV_TYPE:
el_uri = "{0}:{1}".format(all_el_client_contexts[0].ip_addr, all_el_client_contexts[0].engine_rpc_port_num)
beacon_uri = "{0}:{1}".format(all_cl_client_contexts[0].ip_addr, all_cl_client_contexts[0].http_port_num)
jwt_secret = all_el_client_contexts[0].jwt_secret
endpoint = mock_mev_launcher_module.launch_mock_mev(plan, el_uri, beacon_uri, jwt_secret, args_with_right_defaults.global_client_log_level)
mev_endpoints.append(endpoint)
elif args_with_right_defaults.mev_type and args_with_right_defaults.mev_type == FULL_MEV_TYPE:
el_uri = "http://{0}:{1}".format(all_el_client_contexts[0].ip_addr, all_el_client_contexts[0].rpc_port_num)
builder_uri = "http://{0}:{1}".format(all_el_client_contexts[-1].ip_addr, all_el_client_contexts[-1].rpc_port_num)
beacon_uri = ["http://{0}:{1}".format(context.ip_addr, context.http_port_num) for context in all_cl_client_contexts][-1]
beacon_uris = beacon_uri
first_cl_client = all_cl_client_contexts[0]
first_client_beacon_name = first_cl_client.beacon_service_name
mev_flood_module.launch_mev_flood(plan, mev_params.mev_flood_image, el_uri, genesis_constants.PRE_FUNDED_ACCOUNTS)
endpoint = mev_relay_launcher_module.launch_mev_relay(plan, mev_params, network_params.network_id, beacon_uris, genesis_validators_root, builder_uri, network_params.seconds_per_slot, network_params.slots_per_epoch)
mev_flood_module.spam_in_background(plan, el_uri, mev_params.mev_flood_extra_args, mev_params.mev_flood_seconds_per_bundle, genesis_constants.PRE_FUNDED_ACCOUNTS)
if args_with_right_defaults.mev_params.launch_custom_flood:
mev_custom_flood_module.spam_in_background(plan, genesis_constants.PRE_FUNDED_ACCOUNTS[-1].private_key, genesis_constants.PRE_FUNDED_ACCOUNTS[0].address, el_uri)
mev_endpoints.append(endpoint)

plan.print("Launching transaction spammer")
tx_spammer_params = args_with_right_defaults.tx_spammer_params
transaction_spammer.launch_transaction_spammer(plan, genesis_constants.PRE_FUNDED_ACCOUNTS, all_el_client_contexts[0], tx_spammer_params)
plan.print("Succesfully launched transaction spammer")


plan.print("Launching Blob spammer")
blob_spammer.launch_blob_spammer(
plan,
Expand Down Expand Up @@ -141,42 +169,6 @@ def run(plan, args = {}):
)
output = struct(grafana_info = grafana_info)


mev_endpoints = []
# passed external relays get priority
# perhaps add mev_type External or remove this
if hasattr(participant, "builder_network_params") and participant.builder_network_params != None:
mev_endpoints = participant.builder_network_params.relay_end_points
# otherwise dummy relays spinup if chosen
elif args_with_right_defaults.mev_type and args_with_right_defaults.mev_type == MOCK_MEV_TYPE:
el_uri = "{0}:{1}".format(all_el_client_contexts[0].ip_addr, all_el_client_contexts[0].engine_rpc_port_num)
beacon_uri = "{0}:{1}".format(all_cl_client_contexts[0].ip_addr, all_cl_client_contexts[0].http_port_num)
jwt_secret = all_el_client_contexts[0].jwt_secret
endpoint = mock_mev_launcher_module.launch_mock_mev(plan, el_uri, beacon_uri, jwt_secret, args_with_right_defaults.global_client_log_level)
mev_endpoints.append(endpoint)
elif args_with_right_defaults.mev_type and args_with_right_defaults.mev_type == FULL_MEV_TYPE:
el_uri = "http://{0}:{1}".format(all_el_client_contexts[0].ip_addr, all_el_client_contexts[0].rpc_port_num)
builder_uri = "http://{0}:{1}".format(all_el_client_contexts[-1].ip_addr, all_el_client_contexts[-1].rpc_port_num)
beacon_uri = ["http://{0}:{1}".format(context.ip_addr, context.http_port_num) for context in all_cl_client_contexts][-1]
beacon_uris = beacon_uri
first_cl_client = all_cl_client_contexts[0]
first_client_beacon_name = first_cl_client.beacon_service_name
mev_flood_module.launch_mev_flood(plan, mev_params.mev_flood_image, el_uri, genesis_constants.PRE_FUNDED_ACCOUNTS)
epoch_recipe = GetHttpRequestRecipe(
endpoint = "/eth/v2/beacon/blocks/head",
port_id = HTTP_PORT_ID_FOR_FACT,
extract = {
"epoch": ".data.message.body.attestations[0].data.target.epoch"
}
)
plan.wait(recipe = epoch_recipe, field = "extract.epoch", assertion = ">=", target_value = str(network_params.capella_fork_epoch), timeout = "20m", service_name = first_client_beacon_name)
plan.print("epoch 2 reached, can begin mev stuff")
endpoint = mev_relay_launcher_module.launch_mev_relay(plan, mev_params, network_params.network_id, beacon_uris, genesis_validators_root, builder_uri, network_params.seconds_per_slot, network_params.slots_per_epoch)
mev_flood_module.spam_in_background(plan, el_uri, mev_params.mev_flood_extra_args, mev_params.mev_flood_seconds_per_bundle, genesis_constants.PRE_FUNDED_ACCOUNTS)
if args_with_right_defaults.mev_params.launch_custom_flood:
mev_custom_flood_module.spam_in_background(plan, genesis_constants.PRE_FUNDED_ACCOUNTS[-1].private_key, genesis_constants.PRE_FUNDED_ACCOUNTS[0].address, el_uri)
mev_endpoints.append(endpoint)

# spin up the mev boost contexts if some endpoints for relays have been passed
all_mevboost_contexts = []
if mev_endpoints:
Expand Down
5 changes: 1 addition & 4 deletions src/package_io/parse_input.star
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ def parse_input(plan, input_args):
if result.get("mev_type") in ("mock", "full"):
result = enrich_mev_extra_params(result, MEV_BOOST_SERVICE_NAME_PREFIX, FLASHBOTS_MEV_BOOST_PORT, result.get("mev_type"))

if result.get("mev_type") == "full" and result["network_params"]["capella_fork_epoch"] == 0:
fail("capella_fork_epoch needs to be set to a non-zero value when using full MEV, set it using network_params.capella_fork_epoch")

result["tx_spammer_params"] = get_default_tx_spammer_params()

return struct(
Expand Down Expand Up @@ -88,7 +85,7 @@ def parse_input(plan, input_args):

def get_default_mev_params():
return {
"mev_relay_image": "flashbots/mev-boost-relay",
"mev_relay_image": "flashbots/mev-boost-relay:latest",
# TODO replace with flashbots/builder when they publish an arm64 image as mentioned in flashbots/builder#105
"mev_builder_image": "ethpandaops/flashbots-builder:main",
"mev_boost_image": "flashbots/mev-boost",
Expand Down

0 comments on commit 8b883af

Please sign in to comment.