feat(bundles): Support backrun bundles execution #32
Conversation
8c7ab63 to
9273c95
Compare
dvush
left a comment
There was a problem hiding this comment.
I like that this implementation is simple to understand and it solves the problem of mempool replacements in an elegant way.
There are couple of things that I wanted to point out as possible issues.
| // Pre-compute total fees and sort bundles (descending) | ||
| let mut bundles_with_fees: Vec<_> = backrun_bundles | ||
| .into_iter() | ||
| .map(|bundle| { | ||
| let total_fee: u128 = bundle | ||
| .backrun_txs | ||
| .iter() | ||
| .map(|tx| tx.effective_tip_per_gas(base_fee).unwrap_or(0)) | ||
| .sum(); | ||
| (bundle, total_fee) | ||
| }) | ||
| .collect(); | ||
| bundles_with_fees.sort_by(|a, b| b.1.cmp(&a.1)); |
There was a problem hiding this comment.
Lets move this logic into the backrun store and outside of the main build loop. It'll:
- Make merging upstream changes easier in the future (less of a diff to this file)
- Less change of delaying building
There was a problem hiding this comment.
One reason i decided to do it here is that i i think backrun insertion should be as fast as possible to remove any possible delays for finding backrun bundles
But i guess maybe this kind of sorting is super fast such that the latency is negligible
There was a problem hiding this comment.
One reason i decided to do it here is that i i think backrun insertion should be as fast as possible to remove any possible delays for finding backrun bundles
If this code adds noticeable overhead, I would rather us slow down the backrun RPC over the build loop (as this would impact the rest of the chain).
There was a problem hiding this comment.
oh, one thing is that
tx.effective_tip_per_gas(base_fee) must be computed at execution time.
During insertion we only have max_priority_fee_per_gas which is not the actual tip during execution.
What im thinking is that
- we could sort by
max_priority_fee_per_gasduring insertion - but at execution time, will still need to compute tx.effective_tip_per_gas(base_fee) again for validation (bundles priority fee >= target tx priority fee)
what do you think?
8511b39 to
1ac6dca
Compare
| } | ||
|
|
||
| pending_results.push((backrun_tx, result, state)); | ||
| pending_results.push((backrun_tx.clone(), consensus_tx, result, state)); |
There was a problem hiding this comment.
I think we maybe able to remove a bunch of the clones in this codepath, but happy to do that as a followup.
Summary
base_sendBackrunBundleRPC endpoint and in-memory store to enable backrun transactions to execute immediately after their target transactions during block building.✅ I have completed the following steps:
make lintmake test