Skip to content

Commit b100b3b

Browse files
dvushmetachris
andauthored
Replace dry run mode with a test relay (flashbots#421)
## 📝 Summary * removes dry run mode and validation from the rbuilder * adds a test_relay binary that is used to accept and validate submissions * removes optimistic mode validation feature ## 💡 Motivation and Context Dry run mode does not allow us to fully test submissions to the relays so here its replaced with separate service that implements relay API. Test builders does not need to point to real relays as test relays can server validator data itself. This improves robustness in the tests as production relays are not even mentioned in the test builder configs. ## ✅ I have completed the following steps: * [x] Run `make lint` * [x] Run `make test` * [x] Added tests (if applicable) --------- Co-authored-by: Chris Hager <[email protected]>
1 parent b81e74e commit b100b3b

23 files changed

+1017
-241
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/cargo
2+
/data
3+
/mev-test-contract/cache
4+
/mev-test-contract/out
5+
/target
6+
/scripts/benchmark-results.*
7+
/test/
8+
/integration_logs
9+
10+
# editors
11+
.code
12+
.idea
13+
.vscode

Cargo.lock

Lines changed: 40 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ members = [
1515
"crates/rbuilder/src/test_utils",
1616
"crates/rbuilder/src/telemetry/metrics_macros",
1717
"crates/eth-sparse-mpt",
18-
"crates/sysperf"
18+
"crates/sysperf",
19+
"crates/test-relay",
1920
]
20-
default-members = ["crates/rbuilder", "crates/reth-rbuilder"]
21+
default-members = ["crates/rbuilder", "crates/reth-rbuilder", "crates/test-relay"]
2122
resolver = "2"
2223

2324
# Like release, but with full debug symbols. Useful for e.g. `perf`.
@@ -130,16 +131,15 @@ alloy-signer-local = { version = "0.9.2" }
130131
alloy-rpc-client = { version = "0.9.2" }
131132
alloy-genesis = { version = "0.9.2" }
132133
alloy-trie = { version = "0.7" }
133-
134-
# op
135134
op-alloy-rpc-types = { version = "0.9.0", default-features = false }
136135
op-alloy-rpc-types-engine = { version = "0.9.0", default-features = false }
137136
op-alloy-rpc-jsonrpsee = { version = "0.9.0", default-features = false }
138137
op-alloy-network = { version = "0.9.0", default-features = false }
139138
op-alloy-consensus = { version = "0.9.0", default-features = false }
140139

141140
async-trait = { version = "0.1.83" }
142-
clap = { version = "4.4.3" }
141+
clap = { version = "4.4.3", features = ["derive", "env"] }
142+
clap_builder = { version = "4.5.19" }
143143
thiserror = { version = "1.0.64" }
144144
eyre = { version = "0.6.12" }
145145
jsonrpsee = { version = "0.24.4" }
@@ -152,17 +152,24 @@ serde = { version = "1.0.210" }
152152
serde_json = { version = "1.0.128" }
153153
serde_with = { version = "3.8.1" }
154154
secp256k1 = { version = "0.29" }
155-
clap_builder = { version = "4.5.19" }
156155
derive_more = { version = "1" }
157156
tokio-stream = "0.1.16"
158157
tokio-util = "0.7.12"
159158
url = "2.5.2"
159+
warp = "0.3.7"
160+
flate2 = "1.0.35"
161+
prometheus = "0.13.4"
162+
ctor = "0.2"
160163

161164
libc = { version = "0.2.161" }
162165
lazy_static = "1.4.0"
163166
tikv-jemallocator = { version = "0.6" }
164167
tracing = "0.1.37"
165168
metrics = { version = "0.24.1" }
169+
ahash = "0.8.6"
170+
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
166171

167172
eth-sparse-mpt = { path = "crates/eth-sparse-mpt" }
173+
rbuilder = { path = "crates/rbuilder" }
168174
sysperf = { path = "crates/sysperf" }
175+
metrics_macros = { path = "crates/rbuilder/src/telemetry/metrics_macros"}

Dockerfile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ ENV SCCACHE_DIR=/sccache
2525
#
2626
FROM base AS planner
2727
WORKDIR /app
28-
2928
COPY . .
30-
3129
RUN --mount=type=cache,target=/usr/local/cargo/registry \
3230
--mount=type=cache,target=/usr/local/cargo/git \
3331
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
@@ -38,28 +36,35 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry \
3836
#
3937
FROM base as builder
4038
WORKDIR /app
41-
# Default binary filename rbuilder
42-
# Alternatively can be set to "reth-rbuilder" - to have reth included in the binary
43-
ARG RBUILDER_BIN="rbuilder"
4439
COPY --from=planner /app/recipe.json recipe.json
45-
4640
RUN --mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
4741
cargo chef cook --release --recipe-path recipe.json
48-
4942
COPY . .
5043

44+
45+
FROM builder as rbuilder
46+
ARG RBUILDER_BIN="rbuilder"
5147
RUN --mount=type=cache,target=/usr/local/cargo/registry \
5248
--mount=type=cache,target=/usr/local/cargo/git \
5349
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
5450
cargo build --release --features="$FEATURES" --package=${RBUILDER_BIN}
5551

56-
#
57-
# Runtime container
58-
#
59-
FROM gcr.io/distroless/cc-debian12
60-
WORKDIR /app
52+
FROM builder as test-relay
53+
RUN --mount=type=cache,target=/usr/local/cargo/registry \
54+
--mount=type=cache,target=/usr/local/cargo/git \
55+
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
56+
cargo build --release --features="$FEATURES" --package=test-relay
6157

62-
ARG RBUILDER_BIN="rbuilder"
63-
COPY --from=builder /app/target/release/${RBUILDER_BIN} /app/rbuilder
6458

59+
60+
# Runtime container for rbuilder
61+
FROM gcr.io/distroless/cc-debian12 as rbuilder-runtime
62+
WORKDIR /app
63+
COPY --from=rbuilder /app/target/release/rbuilder /app/rbuilder
6564
ENTRYPOINT ["/app/rbuilder"]
65+
66+
# Runtime container for test-relay
67+
FROM gcr.io/distroless/cc-debian12 as test-relay-runtime
68+
WORKDIR /app
69+
COPY --from=test-relay /app/target/release/test-relay /app/test-relay
70+
ENTRYPOINT ["/app/test-relay"]

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ clean: ## Clean up
2727
build: ## Build (debug version)
2828
cargo build --features "$(FEATURES)"
2929

30-
.PHONY: docker-image
31-
docker-image: ## Build a rbuilder Docker image
32-
docker build --platform linux/amd64 --build-arg FEATURES="$(FEATURES)" . -t rbuilder
30+
.PHONY: docker-image-rubilder
31+
docker-image-rubilder: ## Build a rbuilder Docker image
32+
docker build --platform linux/amd64 --target rbuilder-runtime --build-arg FEATURES="$(FEATURES)" . -t rbuilder
33+
34+
.PHONY: docker-image-test-relay
35+
docker-image-test-relay: ## Build a test relay Docker image
36+
docker build --platform linux/amd64 --target test-relay-runtime --build-arg FEATURES="$(FEATURES)" . -t test-relay
3337

3438
##@ Dev
3539

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ To run rbuilder you need:
4040
* Source of bundles that sends `eth_sendBundle`, `mev_sendBundle`, `eth_sendRawTransaction` as JSON rpc calls. (`jsonrpc_server_port`)
4141
(by default rbuilder will take raw txs from the reth node mempool)
4242
* Relays so submit to (`relays`)
43-
* Alternatively it can submit to the block validation API if run in the dry run mode (`dry_run`, `dry_run_validation_url`)
4443

4544
A sample configuration for running Lighthouse and triggering payload events would be:
4645
```
@@ -78,6 +77,12 @@ rbuilder has a solid initial benchmarking setup (based on [Criterion.rs](https:/
7877
- Benchmarks are located in [`crates/rbuilder/benches`](./crates/rbuilder/benches/). We'd love to add more meaningful benchmarks there!
7978
- Let us know about further improvement ideas and additional relevant benchmarks.
8079

80+
### Testing with a fake relay
81+
82+
This repo includes a `test-relay` tool for testing live builders without submitting blocks to live production relays. This standalone binary implements the MEV-Boost Relay API required for builder to function. The test-relay only performs block validation and compares profits between builders who submit blocks to it, without actually sending blocks to the network.
83+
84+
The test relay exposes several Prometheus metrics about the blocks it received.
85+
8186
### End-to-end local testing
8287

8388
You can use [builder-playground](https://github.com/flashbots/builder-playground) to deploy a fully functional local setup for the builder ([Lighthouse](https://github.com/sigp/lighthouse) consensus client (proposer + validator) + [Reth](https://github.com/paradigmxyz/reth/) execution client + [MEV-Boost-Relay](https://github.com/flashbots/mev-boost-relay))) to test rbuilder.
@@ -200,7 +205,7 @@ Big shoutout to the [Reth](https://github.com/paradigmxyz/reth) team for buildin
200205

201206

202207
| Binary | Description |
203-
| --------------------------- | ----------------------------------------------------------------------------------------------------- |
208+
|-----------------------------|-------------------------------------------------------------------------------------------------------|
204209
| `rbuilder` | Live block builder |
205210
| `backtest-build-block` | Run backtests for a single block |
206211
| `backtest-build-range` | Run backtests for a range of block |
@@ -211,3 +216,4 @@ Big shoutout to the [Reth](https://github.com/paradigmxyz/reth) team for buildin
211216
| `debug-order-input` | Observe input of the bundles and transactions |
212217
| `debug-order-sim` | Observe simulation of the bundles and transactions |
213218
| `debug-slot-data-generator` | Shows new payload jobs coming from CL with attached data from relays. |
219+
| `test-relay` | Test MEV-boost relay that accepts blocks and validates them. |

config-live-example.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ extra_data = "⚡🤖"
2222

2323
blocklist_file_path = "./blocklist.json"
2424

25-
dry_run = true
26-
dry_run_validation_url = "http://localhost:8545"
27-
2825
ignore_cancellable_orders = true
2926

3027
# genesis_fork_version = "0x00112233"

config-optimism-local.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ jsonrpc_server_ip = "0.0.0.0"
1616
el_node_ipc_path = "/tmp/reth.ipc"
1717
extra_data = "⚡🤖"
1818

19-
dry_run = false
20-
dry_run_validation_url = "http://localhost:8545"
21-
2219
ignore_cancellable_orders = true
2320

2421
sbundle_mergeable_signers = []

crates/eth-sparse-mpt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ alloy-trie.workspace = true
3838
# test deps
3939
hash-db = { version = "0.15.2", optional = true }
4040
triehash = { version = "0.8.4", optional = true }
41-
flate2 = { version = "1.0.35", optional = true }
41+
flate2 = { workspace = true, optional = true }
4242
eyre = { workspace = true, optional = true}
4343

4444
[features]

crates/rbuilder/Cargo.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ csv = "1.2.2"
8585
zip = "0.6.6"
8686
atoi = "2.0.0"
8787
futures = "0.3.28"
88-
time = { version = "0.3.36", features = ["macros", "formatting", "parsing"] }
88+
time.workspace = true
8989
bigdecimal = "0.4.1"
9090
mempool-dumpster = "0.1.1"
9191
itertools = "0.11.0"
92-
clap = { workspace = true, features = ["derive", "env"] }
92+
clap.workspace = true
9393
priority-queue = "2.0.3"
9494
secp256k1 = { workspace = true, features = [
9595
"global-context",
9696
"rand-std",
9797
"recovery",
9898
] }
9999
rayon = "1.8.0"
100-
flate2 = "1.0.27"
100+
flate2.workspace = true
101101
# Version required by ethereum-consensus beacon-api-client
102102
mev-share-sse = { git = "https://github.com/paradigmxyz/mev-share-rs", rev = "9eb2b0138ab3202b9eb3af4b19c7b3bf40b0faa8", default-features = false }
103103
jsonrpsee = { version = "0.20.3", features = ["full"] }
@@ -106,13 +106,12 @@ beacon-api-client = { git = "https://github.com/ralexstokes/ethereum-consensus/"
106106
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus/", rev = "cf3c404043230559660810bc0c9d6d5a8498d819" }
107107
ssz_rs_derive = { git = "https://github.com/ralexstokes/ssz-rs.git", version = "0.9.0" }
108108
uuid = { version = "1.6.1", features = ["serde", "v5", "v4"] }
109-
prometheus = "0.13.4"
110-
hyper = { version = "1.3.1", features = ["server", "full"] }
111-
warp = "0.3.7"
109+
prometheus.workspace = true
110+
warp.workspace = true
112111
lazy_static.workspace = true
113-
ctor = "0.2"
112+
ctor.workspace = true
114113
toml = "0.8.8"
115-
ahash = "0.8.6"
114+
ahash.workspace = true
116115
rand = "0.8.5"
117116
lru = "0.12.1"
118117
humantime = "2.1.0"

crates/rbuilder/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ pub mod provider;
99
pub mod roothash;
1010
pub mod telemetry;
1111
pub mod utils;
12-
pub mod validation_api_client;

0 commit comments

Comments
 (0)