Flashbots And MEVs: A Beginner’s Guide

By BlockSense

Earning a living through mining blocks in the Ethereum blockchain has become increasingly common. By simply playing with the order of transactions and proposing a block, miners can earn the block reward as well as the corresponding block gas fees. The different forms of value that can be derived from transaction ordering by whoever is producing the block in the Ethereum network is termed as Miner Extractable Value (MEV).

The competition to earn MEVs is starting to create problems in the Ethereum blockchain. In an attempt to earn as much MEV as possible, miners employ tactics such as Frontrunning and Backrunning. Though technically legal, these techniques are not appreciable in the blockchain world as they create huge congestion in the network.

In an attempt to solve these crises, a research group backed by Paradigm known as Flashbots has emerged. The motive of this organization is to provide infrastructure for others to be able to extract MEV for themselves. In this piece, we will cover their proposals in detail. Before we get into discussing these technicalities, let us get a quick view of the problems emerging from MEVs in the first place.

A Breakdown Of The MEV Crisis

When Ethereum first began gaining traction, their core insight was to grant developers a new frontier of permissionless apps by using flexible smart contracts. Though this has been largely effective, the MEV crisis has emerged as a novel risk. Below are some of the current problems associated with MEVs.

Forking Attacks

The term MEV was first coined in early 2019 by Phil Daian as part of a research paper titled Flash boys: Frontrunning, Transaction Reordering, and Consensus Instability in Decentralized Exchanges. The paper discussed in detail two forking attacks that a high competition for MEV may bring about.

Undercutting Attack

Deemed as a present threat in Ethereum, undercutting attacks have always been associated with blockchains offering block rewards.

In an undercutting attack, an attacker forks an existing chain by leaving wealthier transactions out in its new block. This is in an attempt to lure dishonest miners to join the fork. Rather than following the longest chain that emerges first, miners break ties by choosing the chain that leaves out the most fees. As miners continue to undercut one other, the system is rendered unstable, reducing predicted income for legitimate miners.

Time Bandit Attack

Unlike undercutting attacks, time-bandit attacks are a new type of exploit that directly uses MEV as a strategy. Similar to a 51% attack, the objective of a time-bandit attack is to rewrite Ethereum history and reverse transactions on the blockchain.

In such an attack, miners reorganize past blocks to exploit MEV. For example, if you found very lucrative MEV opportunities in the last blocks, you can put up a proposal to rewrite Ethereum’s history to make a profit from the past opportunity. A reward is then offered to the miner that executes this attack as an incentive.

MEV Exploit Strategies

There are a few strategies miners and DEXs adopt to capture as much MEV as possible. Exchanges may use arbitrage bots in this scenario. These are computer programs that compare coin prices across exchanges to make automated trades that take advantage of price discrepancies. By reordering the transactions, inserting their own transactions, or censoring other people’s transactions, miners are able to capture some profit. Oftentimes prices between different DEXs will get out of equilibrium as well. With arbitrage, you can capitalize on this opportunity. However, as the single party that can order the transactions, miners are the ones that decide who is able to capture it.

Below are some of the strategies they employ.

Frontrunning

Also known as Priority Gas Auctions (PGAs), frontrunning is a technique in which bots can quote a price higher than another pending transaction in an attempt to get their transaction mined first. They can then insert a higher transaction fee for placing the order, while the trader who initiated the transaction is forced to pay the price that they didn’t see coming. The profit, which can stretch up to millions of dollars worth of ETH, goes into the pocket of the trader.

This can be better understood with an example:

Alice is a user that initiates a transaction to buy 1000 shares from a company, setting the gas price for this transaction as P1. Bob notices this pending transaction and decides to front-run it by creating his transaction to buy the same shares but with a higher gas price P2. As the gas price of Bob’s transaction was greater, that transaction gets executed first, causing the value of the shares to go up considerably. Alice is forced to then pay more than she intended, while Bob can make a profit.

Backrunning

Backrunning is a technique that does the opposite of frontrunning. Here, the objective is to have a transaction next in line right after a transaction that would benefit you. Traders quote a price slightly lower than another pending transaction in an attempt to get their transaction mined directly afterwards. An example where this may be desirable is having a liquidation transaction immediately following an oracle price update.

Below is an example that can be used to understand this better:

Alice is a user that observes a pending transaction (Transaction A) which may update the oracle price on execution. However, she wants to make sure that her transaction (Transaction B) is only accepted immediately after Transaction A is executed. To achieve this, she can set the gas price for Transaction B as slightly less than the target transaction which is Transaction A so that the chance of her transaction being approved afterward increases. She can further increase her chances by “spamming” with multiple transactions identical to Transaction B in the hopes that one of them is selected successfully.

Discussing The Damage

Research organization Flashbots argues that the competition for MEVs can result in colossal damage to both users of the blockchain and Ethereum itself.

By using the techniques discussed above either individually or in combination (in the case of sandwich attacks), arbitrage bots can manipulate someone into paying much more than they intended. In the end, MEV levies an invisible tax on the user- reaching thousands of dollars in some cases.

However, this does not only affect users of a blockchain. MEVs are contributing to network congestion, chain congestion, and arbitrarily high gas fees all across Ethereum. At a protocol level, MEV creates an issue of consensus stability as well. If MEV becomes larger than the block rewards, miners gain an incentive to reorder transactions in previous blocks for profit instead of continuing with honest mining.

Moreover, the blockchain may even experience a centralization of power within particular traders and miners. This could prove disastrous for Ethereum in the long run, putting the core values of blockchain in jeopardy.

Flashbots As A Solution

The research organization Flashbots recognizes these problems and promises to contribute by providing potentially effective solutions. Their main objective is to “propose a permissionless, transparent, and fair ecosystem for MEV extraction to preserve the ideals of Ethereum”. Let us discuss the first two phases of their plan in further detail below.

Illuminate The Dark Forest

The first step in mitigating the MEV crisis is understanding the current circumstances of the blockchain. The most effective way to achieve this is by quantifying the impact of MEVs and displaying it publicly. For this purpose, Flashbots has built MEV-Inspect or MEV-I for short. MEV-Inspect scans Ethereum blocks, allowing visualization of MEV metrics over time.

In addition to this, Flashbots has built an online dashboard displaying their findings in real-time. MEV-Explore tracks the latest MEV transactions on Ethereum, depicting information categorized by protocol, type, and role.

Democratize Extraction

The current trend of MEV extraction points to a situation where one day the power accumulates to a select few traders or miners. This eventual centralization is highly undesirable for not only Ethereum but any blockchain built on the foundations of decentralization and scalability.

To combat this, Flashbots has created a proof of concept titled MEV-Geth. Acting as an upgrade to the Go-Ethereum client, MEV-Geth functions as a “sealed-bid block space auction mechanism for communicating transaction order preference”. This works to eliminate the problems of chain and network congestion brought about by excessive Frontrunning and Backrunning.

How Flashbots Solve The MEV Crisis

The problem with current state of our system has to do with transparency of the network. When a user sends his transaction to a regular transaction pool, the contents of his request are visible to everyone before the transaction is included in a block. Anyone can view this pending transaction and carry out a frontrunning or sandwich attack on it- the dire effects of which have been discussed in detail previously.

The solution to this problem proposed by Flashbots is to withhold the content of a transaction from miners until is mined in a block. If you use the MEV-Geth proof of concept, your transactions get routed privately to the miners and get directly included on the chain. In this way, Flashbots hopes to disincentivize bad behaviour like stealing a profitable strategy.

Moving Forward

The unfavourable effect brought forth by MEVs continues to gain recognition globally, with many believing the MEV crisis capable of providing serious risk to Ethereum’s future. Some users have even gone so far as to say that MEV has the power to kill the Ethereum network.

So far, it seems as if the efforts of Flashbots have been fruitful. Within a few weeks of the organization going live, over 58% of the Ethereum network hashrate was mining on flashbots. Though it is still too early to say how effective their proposed solutions are, they have managed to succeed in bringing to light just how severe the MEV crisis may be in the long run.

References

https://research.paradigm.xyz/MEV

https://github.com/flashbots/pm

We exist to improve the quality of smart contract audit for protocols to ensure safety from bad actors. Powered by Xord. Website: https://blockapex.io/