Commit ccd9cb5
authored
feat: add parallel builder (#219)
## 📝 Summary
This PR introduces a new building algorithm which parallelizes the
process of building blocks. In particular, it moves the largely
sequential process of processing orders, resolving conflicts, and
building blocks into modular and parallel process. Each of these
components now runs in parallel, allowing for continuous intake of
orderflow, flexible resolution of conflicts, and building blocks with
the latest flow and best conflict resolution results. It is a
significant architecture change.
See
[run_parallel_builder](https://github.com/flashbots/rbuilder/blob/parallel-builder/crates/rbuilder/src/building/builders/parallel_builder/mod.rs#L180)
for a good code entry point and the
[readme.md](https://github.com/flashbots/rbuilder/blob/parallel-builder/crates/rbuilder/src/building/builders/parallel_builder/readme.md)
for more architecture details.
Key Changes:
- Introduced a new parallel_builder module, replacing the
merging_builder. This adds several components for orderflow intake,
conflict identification, conflict resolution, and merging of resolved
conflicts.
- Added a simulation cache to optimize repeated simulations of similar
order sequences.
- Updated the builder configuration to use the new Parallel Builder
instead of the Merging Builder.
- Implemented backtest functionality for the Parallel Builder.
## 💡 Motivation and Context
- Concurrency driven efficiency improvements: running significant
processes in parallel is more efficient, and should lead to better
blocks. Processes aren't sequential, so they aren't blocked on each
other anymore.
- Reuses previous work: Instead of repeating conflict resolution, we are
able to reuse old resolved conflict results.
- Better conflict management: We can prioritize "fast" conflict
resolution tasks to get results for a conflict group to the building
assembler fast, but then also queue "slow" tasks (like evolutionary
algorithms) which might produce better results but are slower.
## Testing
Finally, I've added a range of tests to the new algorithm. I further
have tested it extensively on a local node using mempool txs.
- ---
## ✅ I have completed the following steps:
* [✅ ] Run `make lint`
* [✅ ] Run `make test`
* [ ✅] Added tests (if applicable)1 parent 3159c3f commit ccd9cb5
File tree
23 files changed
+3486
-891
lines changed- crates/rbuilder
- src
- building/builders
- merging_builder
- parallel_builder
- live_builder
- order_input
- primitives
23 files changed
+3486
-891
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
| 61 | + | |
| 62 | + | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
128 | 131 | | |
129 | 132 | | |
130 | 133 | | |
| |||
Lines changed: 0 additions & 174 deletions
This file was deleted.
0 commit comments