Skip to content

Commit de95c61

Browse files
authored
feat: add rbuilder remove old geth builder - flashbots (ethereum#786)
Signed-off-by: Barnabas Busa <[email protected]>
1 parent cab694a commit de95c61

File tree

16 files changed

+273
-71
lines changed

16 files changed

+273
-71
lines changed

.github/tests/mev-pectra.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
participants:
2+
- el_type: reth
3+
cl_type: teku
4+
additional_services:
5+
- dora
6+
- tx_spammer
7+
mev_type: flashbots
8+
9+
mev_params:
10+
mev_relay_image: jtraglia/mev-boost-relay:electra
11+
mev_boost_image: jtraglia/mev-boost:electra
12+
mev_builder_image: ethpandaops/rbuilder:develop-1b578f5
13+
mev_builder_cl_image: ethpandaops/lighthouse:pawan-electra-alpha7-0dd215c
14+
15+
network_params:
16+
electra_fork_epoch: 1

.github/tests/mev.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ additional_services:
66
- tx_spammer
77
- blob_spammer
88
- custom_flood
9-
- el_forkmon
9+
- goomy_blob
1010
- beacon_metrics_gazer
1111
- dora
1212
- prometheus_grafana
13-
mev_params:
14-
mev_relay_image: flashbots/mev-boost-relay:latest
1513
network_params:
16-
seconds_per_slot: 3
14+
seconds_per_slot: 6

main.star

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ mev_rs_mev_relay = import_module("./src/mev/mev-rs/mev_relay/mev_relay_launcher.
4141
mev_rs_mev_builder = import_module(
4242
"./src/mev/mev-rs/mev_builder/mev_builder_launcher.star"
4343
)
44+
flashbots_mev_rbuilder = import_module(
45+
"./src/mev/flashbots/mev_builder/mev_builder_launcher.star"
46+
)
47+
4448
flashbots_mev_boost = import_module(
4549
"./src/mev/flashbots/mev_boost/mev_boost_launcher.star"
4650
)
@@ -119,7 +123,7 @@ def run(plan, args={}):
119123

120124
if args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE:
121125
plan.print("Generating mev-rs builder config file")
122-
mev_rs__builder_config_file = mev_rs_mev_builder.new_builder_config(
126+
mev_rs_builder_config_file = mev_rs_mev_builder.new_builder_config(
123127
plan,
124128
constants.MEV_RS_MEV_TYPE,
125129
network_params.network,
@@ -128,6 +132,18 @@ def run(plan, args={}):
128132
args_with_right_defaults.mev_params.mev_builder_extra_data,
129133
global_node_selectors,
130134
)
135+
elif args_with_right_defaults.mev_type == constants.FLASHBOTS_MEV_TYPE:
136+
plan.print("Generating flashbots builder config file")
137+
flashbots_builder_config_file = flashbots_mev_rbuilder.new_builder_config(
138+
plan,
139+
constants.FLASHBOTS_MEV_TYPE,
140+
network_params,
141+
constants.VALIDATING_REWARDS_ACCOUNT,
142+
network_params.preregistered_validator_keys_mnemonic,
143+
args_with_right_defaults.mev_params.mev_builder_extra_data,
144+
enumerate(args_with_right_defaults.participants),
145+
global_node_selectors,
146+
)
131147

132148
plan.print(
133149
"Launching participant network with {0} participants and the following network params {1}".format(
@@ -156,6 +172,7 @@ def run(plan, args={}):
156172
args_with_right_defaults.checkpoint_sync_enabled,
157173
args_with_right_defaults.checkpoint_sync_url,
158174
args_with_right_defaults.port_publisher,
175+
args_with_right_defaults.mev_type,
159176
)
160177

161178
plan.print(
@@ -248,7 +265,7 @@ def run(plan, args={}):
248265
or args_with_right_defaults.mev_type == constants.MEV_RS_MEV_TYPE
249266
or args_with_right_defaults.mev_type == constants.COMMIT_BOOST_MEV_TYPE
250267
):
251-
builder_uri = "http://{0}:{1}".format(
268+
blocksim_uri = "http://{0}:{1}".format(
252269
all_el_contexts[-1].ip_addr, all_el_contexts[-1].rpc_port_num
253270
)
254271
beacon_uri = all_cl_contexts[-1].beacon_http_url
@@ -290,7 +307,7 @@ def run(plan, args={}):
290307
network_id,
291308
beacon_uris,
292309
genesis_validators_root,
293-
builder_uri,
310+
blocksim_uri,
294311
network_params.seconds_per_slot,
295312
persistent,
296313
global_node_selectors,
@@ -349,7 +366,7 @@ def run(plan, args={}):
349366
plan,
350367
mev_boost_launcher,
351368
mev_boost_service_name,
352-
network_id,
369+
final_genesis_timestamp,
353370
mev_params.mev_boost_image,
354371
mev_params.mev_boost_args,
355372
global_node_selectors,

src/el/el_launcher.star

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ def launch(
2424
network_id,
2525
num_participants,
2626
port_publisher,
27+
mev_builder_type,
2728
):
2829
el_launchers = {
2930
constants.EL_TYPE.geth: {
@@ -75,7 +76,7 @@ def launch(
7576
el_cl_data,
7677
jwt_file,
7778
network_params.network,
78-
builder=True,
79+
builder_type=mev_builder_type,
7980
),
8081
"launch_method": reth.launch,
8182
},

src/el/reth/reth_launcher.star

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,23 @@ el_shared = import_module("../el_shared.star")
66
node_metrics = import_module("../../node_metrics_info.star")
77
constants = import_module("../../package_io/constants.star")
88
mev_rs_builder = import_module("../../mev/mev-rs/mev_builder/mev_builder_launcher.star")
9+
lighthouse = import_module("../../cl/lighthouse/lighthouse_launcher.star")
10+
flashbots_rbuilder = import_module(
11+
"../../mev/flashbots/mev_builder/mev_builder_launcher.star"
12+
)
913

1014
RPC_PORT_NUM = 8545
1115
WS_PORT_NUM = 8546
1216
DISCOVERY_PORT_NUM = 30303
1317
ENGINE_RPC_PORT_NUM = 8551
1418
METRICS_PORT_NUM = 9001
15-
19+
RBUILDER_PORT_NUM = 8645
1620
# Paths
1721
METRICS_PATH = "/metrics"
1822

1923
# The dirpath of the execution data directory on the client container
2024
EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER = "/data/reth/execution-data"
2125

22-
ENTRYPOINT_ARGS = ["sh", "-c"]
2326

2427
VERBOSITY_LEVELS = {
2528
constants.GLOBAL_LOG_LEVEL.error: "v",
@@ -132,10 +135,16 @@ def get_config(
132135
constants.WS_PORT_ID: WS_PORT_NUM,
133136
constants.METRICS_PORT_ID: METRICS_PORT_NUM,
134137
}
138+
139+
if launcher.builder_type == "flashbots":
140+
used_port_assignments[constants.RBUILDER_PORT_ID] = RBUILDER_PORT_NUM
141+
135142
used_ports = shared_utils.get_port_specs(used_port_assignments)
136143

137144
cmd = [
138-
"/usr/local/bin/mev build" if launcher.builder else "reth",
145+
"{0}".format(
146+
"/usr/local/bin/mev" if launcher.builder_type == "mev-rs" else "reth"
147+
),
139148
"node",
140149
"-{0}".format(log_level),
141150
"--datadir=" + EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER,
@@ -150,7 +159,9 @@ def get_config(
150159
"--http.corsdomain=*",
151160
# WARNING: The admin info endpoint is enabled so that we can easily get ENR/enode, which means
152161
# that users should NOT store private information in these Kurtosis nodes!
153-
"--http.api=admin,net,eth,web3,debug,trace",
162+
"--http.api=admin,net,eth,web3,debug,trace{0}".format(
163+
",flashbots" if launcher.builder_type == "flashbots" else ""
164+
),
154165
"--ws",
155166
"--ws.addr=0.0.0.0",
156167
"--ws.port={0}".format(WS_PORT_NUM),
@@ -191,8 +202,6 @@ def get_config(
191202
# this is a repeated<proto type>, we convert it into Starlark
192203
cmd.extend([param for param in participant.el_extra_params])
193204

194-
cmd_str = " ".join(cmd)
195-
196205
files = {
197206
constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: launcher.el_cl_genesis_data.files_artifact_uuid,
198207
constants.JWT_MOUNTPOINT_ON_CLIENTS: launcher.jwt_file,
@@ -207,20 +216,48 @@ def get_config(
207216
constants.EL_TYPE.reth + "_volume_size"
208217
],
209218
)
210-
211-
if launcher.builder:
219+
cmd_str = " ".join(cmd)
220+
env_vars = {
221+
"RETH_CMD": cmd_str,
222+
}
223+
entrypoint_args = ["sh", "-c"]
224+
env_vars = env_vars | participant.el_extra_env_vars
225+
image = participant.el_image
226+
rbuilder_cmd = []
227+
if launcher.builder_type == "mev-rs":
212228
files[
213229
mev_rs_builder.MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE
214230
] = mev_rs_builder.MEV_BUILDER_FILES_ARTIFACT_NAME
231+
elif launcher.builder_type == "flashbots":
232+
cl_client_name = service_name.split("-")[4]
233+
cmd.append("--engine.legacy")
234+
cmd_str = " ".join(cmd)
235+
files[
236+
flashbots_rbuilder.MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE
237+
] = flashbots_rbuilder.MEV_BUILDER_FILES_ARTIFACT_NAME
238+
env_vars["RETH_CMD"] = cmd_str
239+
env_vars.update(
240+
{
241+
"RBUILDER_CONFIG": flashbots_rbuilder.MEV_FILE_PATH_ON_CONTAINER,
242+
"CL_ENDPOINT": "http://cl-{0}-{1}-{2}:{3}".format(
243+
participant_index + 1,
244+
cl_client_name,
245+
constants.EL_TYPE.reth_builder,
246+
lighthouse.BEACON_HTTP_PORT_NUM,
247+
),
248+
}
249+
)
250+
image = constants.DEFAULT_FLASHBOTS_BUILDER_IMAGE
251+
cmd_str = "./app/entrypoint.sh"
252+
entrypoint_args = []
215253

216-
env_vars = participant.el_extra_env_vars
217254
config_args = {
218-
"image": participant.el_image,
255+
"image": image,
219256
"ports": used_ports,
220257
"public_ports": public_ports,
221258
"cmd": [cmd_str],
222259
"files": files,
223-
"entrypoint": ENTRYPOINT_ARGS,
260+
"entrypoint": entrypoint_args,
224261
"private_ip_address_placeholder": constants.PRIVATE_IP_ADDRESS_PLACEHOLDER,
225262
"env_vars": env_vars,
226263
"labels": shared_utils.label_maker(
@@ -246,10 +283,10 @@ def get_config(
246283
return ServiceConfig(**config_args)
247284

248285

249-
def new_reth_launcher(el_cl_genesis_data, jwt_file, network, builder=False):
286+
def new_reth_launcher(el_cl_genesis_data, jwt_file, network, builder_type=False):
250287
return struct(
251288
el_cl_genesis_data=el_cl_genesis_data,
252289
jwt_file=jwt_file,
253290
network=network,
254-
builder=builder,
291+
builder_type=builder_type,
255292
)

src/mev/flashbots/mev_boost/mev_boost_launcher.star

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
shared_utils = import_module("../../../shared_utils/shared_utils.star")
22
mev_boost_context_module = import_module("../mev_boost/mev_boost_context.star")
33
input_parser = import_module("../../../package_io/input_parser.star")
4+
constants = import_module("../../../package_io/constants.star")
45

56
FLASHBOTS_MEV_BOOST_PROTOCOL = "TCP"
67

@@ -27,14 +28,14 @@ def launch(
2728
plan,
2829
mev_boost_launcher,
2930
service_name,
30-
network_id,
31+
genesis_timestamp,
3132
mev_boost_image,
3233
mev_boost_args,
3334
global_node_selectors,
3435
):
3536
config = get_config(
3637
mev_boost_launcher,
37-
network_id,
38+
genesis_timestamp,
3839
mev_boost_image,
3940
mev_boost_args,
4041
global_node_selectors,
@@ -49,7 +50,7 @@ def launch(
4950

5051
def get_config(
5152
mev_boost_launcher,
52-
network_id,
53+
genesis_timestamp,
5354
mev_boost_image,
5455
mev_boost_args,
5556
node_selectors,
@@ -61,13 +62,9 @@ def get_config(
6162
ports=USED_PORTS,
6263
cmd=command,
6364
env_vars={
64-
# TODO(maybe) remove the hardcoding
65-
# This is set to match this file https://github.com/ethpandaops/ethereum-package/blob/main/static_files/genesis-generation-config/cl/config.yaml.tmpl#L11
66-
# latest-notes
67-
# does this need genesis time to be set as well
68-
"GENESIS_FORK_VERSION": "0x10000038",
65+
"GENESIS_FORK_VERSION": constants.GENESIS_FORK_VERSION,
66+
"GENESIS_TIMESTAMP": "{0}".format(genesis_timestamp),
6967
"BOOST_LISTEN_ADDR": "0.0.0.0:{0}".format(input_parser.MEV_BOOST_PORT),
70-
# maybe this is breaking; this isn't verifyign the bid and not sending it to the validator
7168
"SKIP_RELAY_SIGNATURE_CHECK": "1",
7269
"RELAYS": mev_boost_launcher.relay_end_points[0],
7370
},
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
shared_utils = import_module("../../../shared_utils/shared_utils.star")
2+
input_parser = import_module("../../../package_io/input_parser.star")
3+
static_files = import_module("../../../static_files/static_files.star")
4+
constants = import_module("../../../package_io/constants.star")
5+
flashbots_relay = import_module("../mev_relay/mev_relay_launcher.star")
6+
lighthouse = import_module("../../../cl/lighthouse/lighthouse_launcher.star")
7+
# MEV Builder flags
8+
9+
MEV_BUILDER_CONFIG_FILENAME = "config.toml"
10+
MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE = "/config/"
11+
MEV_BUILDER_FILES_ARTIFACT_NAME = "mev-rbuilder-config"
12+
MEV_FILE_PATH_ON_CONTAINER = (
13+
MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE + MEV_BUILDER_CONFIG_FILENAME
14+
)
15+
16+
17+
def new_builder_config(
18+
plan,
19+
service_name,
20+
network_params,
21+
fee_recipient,
22+
mnemonic,
23+
extra_data,
24+
participants,
25+
global_node_selectors,
26+
):
27+
num_of_participants = shared_utils.zfill_custom(
28+
len(participants), len(str(len(participants)))
29+
)
30+
builder_template_data = new_builder_config_template_data(
31+
network_params,
32+
constants.DEFAULT_MEV_PUBKEY,
33+
constants.DEFAULT_MEV_SECRET_KEY[2:], # drop the 0x prefix
34+
mnemonic,
35+
fee_recipient,
36+
extra_data,
37+
num_of_participants,
38+
)
39+
flashbots_builder_config_template = read_file(
40+
static_files.FLASHBOTS_RBUILDER_CONFIG_FILEPATH
41+
)
42+
43+
template_and_data = shared_utils.new_template_and_data(
44+
flashbots_builder_config_template, builder_template_data
45+
)
46+
47+
template_and_data_by_rel_dest_filepath = {}
48+
template_and_data_by_rel_dest_filepath[
49+
MEV_BUILDER_CONFIG_FILENAME
50+
] = template_and_data
51+
52+
config_files_artifact_name = plan.render_templates(
53+
template_and_data_by_rel_dest_filepath, MEV_BUILDER_FILES_ARTIFACT_NAME
54+
)
55+
56+
config_file_path = shared_utils.path_join(
57+
MEV_BUILDER_MOUNT_DIRPATH_ON_SERVICE, MEV_BUILDER_CONFIG_FILENAME
58+
)
59+
60+
return config_files_artifact_name
61+
62+
63+
def new_builder_config_template_data(
64+
network_params,
65+
pubkey,
66+
secret,
67+
mnemonic,
68+
fee_recipient,
69+
extra_data,
70+
num_of_participants,
71+
):
72+
return {
73+
"Network": network_params.network
74+
if network_params.network in constants.PUBLIC_NETWORKS
75+
else "/network-configs/genesis.json",
76+
"DataDir": "/data/reth/execution-data",
77+
"CLEndpoint": "http://cl-{0}-{1}-{2}:{3}".format(
78+
num_of_participants,
79+
constants.CL_TYPE.lighthouse,
80+
constants.EL_TYPE.reth_builder,
81+
lighthouse.BEACON_HTTP_PORT_NUM,
82+
),
83+
"GenesisForkVersion": constants.GENESIS_FORK_VERSION,
84+
"Relay": "mev-relay-api",
85+
"RelayPort": flashbots_relay.MEV_RELAY_ENDPOINT_PORT,
86+
"PublicKey": pubkey,
87+
"SecretKey": secret,
88+
"Mnemonic": mnemonic,
89+
"FeeRecipient": fee_recipient,
90+
"ExtraData": extra_data,
91+
}

0 commit comments

Comments
 (0)