builder
builder copied to clipboard
miner: fix mev gas price calc when bundle replaces mempool tx
📝 Summary
Currently, if a bundle includes a transaction that has the same sender and nonce as a transaction in the mempool (i.e. attempting to replace a mempool transaction with a bundle transaction), the gas fees from the bundle transaction will not be counted towards the bundle's value. ~~This PR compares transaction hashes instead of transaction nonces when checking if a bundle transaction is present in the mempool.~~ This PR allows for replacing a mempool transaction with a bundle transaction (and having its value counted towards the bundle value) when the effective gas price of the bundle transaction is larger than the gas price of the mempool transaction.
Motivation
There are cases when a searcher may want to re-use a nonce from a mempool transaction in a bundle. For example, a searcher may want to privately replace a pending transaction or move a PGA to a bundle auction.
Variations
Another approach would be to only count the gas fees if the bundle transaction's effective gas price (coinbaseDiff + gasFees) / gasUsed
is greater than N% (configured price bump) larger than the mempool transaction's gas price. This would closely follow the replacement logic of the mempool.
https://github.com/flashbots/builder/blob/8caba1f96ff5adf5647356d231a3dcab8a74fbac/core/tx_list.go#L293-L296
This would avoid allowing "cheap" cancellations/replacements.
Implications
~~This could incentivize searchers to include replaced transactions in their bundles.~~ Possible solution: 947f59a2200cbe062d2334dbeef837732db90c4c
- [x] I have seen and agree to
CONTRIBUTING.md