The Physics of MEV: The Blockspace Auction
Why your transaction is being watched. A deep analysis of the Dark Forest, Proposer-Builder Separation (PBS), and the industrialization of arbitrage.
🎯 What You'll Learn
- Deconstruct the 'Dark Forest' mempool model
- Trace the MEV Supply Chain (User → Searcher → Builder → Validator)
- Calculate the math of a Sandwich Attack
- Analyze Proposer-Builder Separation (PBS)
- Evaluating Censorship Resistance in a Flashbots world
📚 Prerequisites
Before this lesson, you should understand:
Introduction
Blockchains promise transparency. But for a few milliseconds every 12 seconds, the most important market in the world is completely opaque.
This is the market for Transaction Ordering.
If I know you are about to buy $10M of ETH, I can buy it right before you and sell it to you at a higher price. This is risk-free profit. This value, extracted by reordering transactions, is called Maximal Extractable Value (MEV). It is the hidden tax that funds the entire validator industry.
Pro Version: See the full research: Antifragile MEV Infrastructure
The Dark Forest: The Public Mempool
The moment you broadcast a transaction, you enter the Dark Forest (a concept from Cixin Liu, adapted by Dan Robinson). Thousands of “Searcher” bots simulate your transaction in real-time.
- If you left money on the table (Arb), they take it.
- If you created slippage (Sandwich), they eat it.
- If you made a mistake (Liquidation), they kill you.
The Physics of the Sandwich
A Sandwich Attack is Atomic Volatility Creation.
- Victim Tx: “Buy 1000 ETH with 1% slippage.”
- Attacker Tx 1 (Frontrun): Buy ETH, pushing price up by 0.99%.
- Victim executes: Pushes price up another 0.01%.
- Attacker Tx 2 (Backrun): Sell ETH immediately.
Math: The victim pays for the attacker’s profit plus the attacker’s gas fees.
Pro Version: See the full research: Antifragile MEV Infrastructure
The Industrial Revolution: PBS (Proposer-Builder Separation)
In the old days (2020), miners ran the bots. It was chaotic. Today, the supply chain is specialized.
1. The Searcher (The Sniper)
- Role: Writes highly optimized Rust/C++ code to find specific MEV opportunities.
- Input: Public Mempool.
- Output: A “Bundle” (Ordered list of txs).
2. The Builder (The Factory)
- Role: Aggregates bundles from thousands of Searchers to build a full block.
- Input: Bundles.
- Output: A Block.
- Physics: They run massive simulations to find the combination of bundles that pays the highest total ETH.
3. The Proposer (The Validator)
- Role: The random ETH staker selected to propose the block.
- Input: Bids from Builders (“I will pay you 2.1 ETH to propose this block”).
- Output: Signing the block.
- Physics: They do nothing but auction off their “slot rights” to the highest bidder via MEV-Boost.
Pro Version: See the full research: Antifragile MEV Infrastructure
Code: Calculating an Arb
Here is the logic a simple arbitrage bot runs 10,000 times per second.
def check_arbitrage(token_in, amount_in, reserves_a, reserves_b):
# Calculate output from DEX A (Uniswap V2)
amount_out_a = get_amount_out(amount_in, reserves_a[0], reserves_a[1])
# Calculate output from DEX B (Sushiswap)
amount_out_b = get_amount_out(amount_out_a, reserves_b[1], reserves_b[0]) # Swap back
profit = amount_out_b - amount_in
gas_cost = ESTIMATED_GAS * GAS_PRICE
if profit > gas_cost:
print(f"ARB FOUND! Profit: {profit} wei")
execute_bundle()
The race is not about math. It is about Latency. Checkers run closer to the Builder’s server (often in the same AWS datacenter) win.
Pro Version: See the full research: Antifragile MEV Infrastructure
Deep Dive: The Censorship Risk
Because Builders construct 90% of blocks, they are central points of failure. If a major Builder decides to censor transactions from “Address X” (e.g., Tornado Cash), those transactions might be delayed.
The Defense:
- Censorship Resistance Lists (crLists): Proposals to force builders to include valid transactions.
- Encrypted Mempools: Builders can’t censor what they can’t see (until it’s too late).
Pro Version: See the full research: Antifragile MEV Infrastructure
Practice Exercises
Exercise 1: The Bribe (Beginner)
Scenario: You find a 1000 should you bid to the Validator to ensure your bundle gets included? (Hint: It’s an auction. What is the next highest bidder bidding?)
Exercise 2: Private Transactions (Intermediate)
Scenario: You want to swap $1M USDC. Task: Why should you send this via “Flashbots Protect” RPC instead of Infura/Alchemy? What is the trade-off in latency?
Exercise 3: Builder Centralization (Advanced)
Scenario: 3 Builders produce 80% of Ethereum blocks. Task: Analyze the impact on the network if these 3 builders collude to ignore a specific DeFi protocol.
Pro Version: See the full research: Antifragile MEV Infrastructure
Knowledge Check
- What is a Bundle?
- Why can’t you just broadcast a sandwich attack to the public mempool?
- Who pays the MEV reward ultimately?
- What is the role of the Relay in PBS?
- Is MEV solvable?
Answers
- An ordered group of transactions. “My Tx + Victim Tx + My Tx”. It executes atomically (all or nothing).
- You will be sandwiched. A generalized frontrunner bot will see your attack and attack you. You must use a private relay.
- The User. Through worse execution price (slippage) or higher gas fees (congestion).
- Trust. The Relay ensures the Builder pays the Validator and the Validator proposes the Builder’s block without stealing the MEV.
- No. MEV is fundamental to permissionless systems. You can only minimize it (fair ordering) or democratize it (distribute profits).
Pro Version: See the full research: Antifragile MEV Infrastructure
Summary
- MEV is inevitable. Wherever there is ordering, there is value.
- PBS industrializes it. It separates the “sophisticated work” (Building) from the “decentralized work” (Validating).
- The user pays. Use private RPCs to protect yourself.
Pro Version: See the full research: Antifragile MEV Infrastructure
Questions about this lesson? Working on related infrastructure?
Let's discuss