Blockchains depend on consensus being reached between miners or validators in order to run. The process by which this is achieved depends on the consensus mechanism used by the chain, but the idea is the same — to ensure that a majority agree on the validity of each new block to be added to the chain.
For each new block, however, a single miner or validator is responsible for “building” the block. This consists of reviewing the network’s pending transactions that have yet to be processed, deciding which transactions to include in the block and determining the order in which they’re executed. The proposed block is then broadcast to be either confirmed or rejected by the other nodes in the network.
This responsibility results in a potentially very lucrative opportunity for the block proposer, on top of the standard mining rewards. Via the use of bots, a miner/validator can take advantage of the order of other users’ pending transactions. The term used for the additional potential income earned in this way is Miner (or Maximal) Extractable Value, or MEV, and was coined in the paper Flashboys 2.0.
MEV can be captured in various ways, including:
- Frontrunning
Pending transactions are scanned for profitable trades, such as arbitrage opportunities, facilitating liquidations, or the minting of rare NFTs. The original transaction is then cloned and submitted first. - Backrunning
Taking advantage of the effects of a transaction, for example, a large DEX trade, the price impact of which can be picked up as an arbitrage opportunity. - Sandwich attacks
Large DEX trades can be both frontrun (buying an asset in order to inflate the price) and, after the original transaction buys that same asset, further increasing its price, the trade can then be backrun (reselling the asset at the higher price).
It is important to note that most MEV is not actually captured by miners/validators but by independent users, known as “searchers”, who are willing to pay higher gas fees to miners in order to have their transactions included at a specific point in the block to capture MEV. Searchers are able to identify MEV opportunities by scanning the mempool — the blockchain’s publicly visible list of submitted, pending transactions.
A future in which miners may choose to dedicate more resources to capturing MEV could lead to problems of consensus (reorganising already mined blocks to extract missed MEV) and put decentralisation at risk (if miners/validators pool resources in order to boost MEV extraction via economies of scale).
Flashbots is working on “mitigating the negative externalities of current MEV extraction techniques and avoiding the existential risks MEV could cause”. Flashbots aims to facilitate responsible MEV extraction whilst at the same time offering protection to users of DeFi.
Transactions that may be vulnerable to MEV-based manipulation can be sent via Flashbots to be wrapped into ‘bundles’. These bundles are then sent directly to miners, bypassing the mempool of pending transactions, along with a slightly elevated transaction fee. In this way, users' transactions are protected and miners are encouraged not to take MEV extractions to their extremes.