Research Summary - Flash Boys 2.0

TLDR:

  • Researchers studied the proliferation of various types of arbitrage bots on decentralized exchanges (DEX), and modeled their effects. They found that such bots compete for optimal gas prices resulting in Price Gas Auctions (PGAs) and under specific conditions can reach cooperative Nash equilibria. They also illustrated how Miner Extractable Value (MEV) is a consensus-level security threat to the Ethereum blockchain, particularly where high ordering optimization fees are present.

Citation

  • Daian, Phillip, Goldfeder, Steven, Kell, Tyler, Li, Yunqi, Zhao, Xueyuan, Bentov, Iddo, Breidenbach, Lorenz, Juels, Ari (2019). “Flash Boys 2.0: Frontrunning, Transaction Reordering, and Consensus Instability in Decentralized Exchanges”. arXiv:1904.05234v1.

Link

Core Research Question

  • In what ways are arbitrage bots used to make a profit and what risks do they pose to Ethereum smart contracts?

Background

  • Ethereum is a distributed computing protocol that uses a consensus-based blockchain.
  • Mining is the search for the correct solution to a constantly changing encryption problem, which results in a relatively consistent rate of discovery of new blocks on the blockchain.
  • Miners receive compensation for their computing power spent (block rewards). They signal valid transactions by including them in the blocks that they mine and broadcast. Generally transactions that bid higher gas prices are prioritized by miners as that represents a transaction fee paid by the user and a revenue for the miner.
  • Gas is the unit of measure of computational cost for Ethereum smart contracts.
  • Transaction Fees are the financial cost to users for calling smart contract functions paid to miners. They are usually denominated in terms of an amount of Gwei (a fraction of ETH) and are a result of the gas cost of transactions and the current miner-set gas price.
  • Forks are divergences in blockchain code or state information. Hard forks are explicit changes proposed to the code of the blockchain itself. Soft forks are divergences in state information included in the blocks that are mined. Reorganizations are instances when nodes adjust their current determination of block ordering based on an updated global consensus.
  • A Decentralized Exchange (DEX) is a peer-to-peer smart contract system deployed on a blockchain such as Ethereum. Exchange operations are carried out automatically when users call smart contract functions.
  • Arbitrage is the act of profiting off of a price differential of an asset in two or more different markets. Arbitrage Bots are automated tools used to identify and execute arbitrage trades without requiring the intervention of a human being.
  • Miner Extractable Value (MEV) is the profit that miners can obtain via manipulation of transactions when mining blocks. Normally miners are compensated simply via transaction fees and block rewards with no additional MEV. To obtain MEV, miners can insert, omit, reorder, or replace transactions on a blockchain for the purpose of frontrunning or otherwise exploiting vulnerabilities in DEXes.
  • Pure revenue opportunities are a type of DEX arbitrage where multiple transactions are sent in one block so that they all execute together (called atomicity).
  • Priority Gas Auctions (PGAs) are instances where arbitrage bots bid against each other to submit a transaction (essentially frontrunning competition), driving up transaction fees.
  • Ordering optimization fees (OO fees) are when a miner can profit from how it chooses to order transactions mined in the next block (eg. PGAs). Miners can reorder transactions or even add transactions in the stack to profit directly from an opportunity.
  • Fee-based forking attacks are instances where OO fees exceed block rewards and incentivize miners to manipulate consensus a soft fork the current blockchain state reordering transactions in their favor.
  • Time Bandit Attacks are instances where an actor could rewind the blockchain to a particular block height and use the MEV to financially justify a profitable 51% attack, even potentially leveraging the ability to borrow computing power for a short time.

Summary

  • DEXes have a vulnerability. Traders can front run orders by reading trade transactions and placing their own copies of the trade at higher transaction fees.
  • Miners are integral to the security and functionality of the Ethereum blockchain but they can also manipulate transactions to obtain Miner Extractable Value (MEV) as a supplement to transaction fees and block rewards.
  • Arbitrage bots have grown increasingly prevalent and competitive on DEXes. The researchers studied the proliferation of such arbitrage bots, including the emergence of priority gas auctions (PGAs) on DEXes.
  • They focused on a few types of DEX design flaw: pure revenue opportunities, Price Gas Auctions (PGA), Miner Extractable Value (MEV), fee-based forking attacks, and Time-Bandit Attacks.
  • They explored the incentives and profitability conditions for various different SGA strategies and formally model bot PGA behavior and identify a game-theoretic cooperative equilibrium, validating their model with empirical measurements.
  • They show that PGAs and MEV pose risks to Ethereum security at the consensus layer and that ordering optimization fees can incentivize fee-based forking attacks.

Method

  • In this paper the researchers first provide background information and definitions, and then go on to outline different examples of frontrunning, arbitrage, and high-frequency automated DEX trading.
  • The researchers make use of dissecting example scenarios to illustrate proposed models and theorems.
  • Additionally they outline the structure of an experiment they conduct on data collection for the purpose of measuring certain bot activities. They forked Go-Ethereum to enter a transaction to the mempool, deployed 6 nodes, and then observed whenever a transaction was relayed over the course of 9 months. They then filtered the transactions by a list of suspected arbitrage bots based on accounts engaging in pure revenue transactions and taking into account higher than normal gas values (PGAs).
  • Next, they developed analytical scripts to aggregate and process this data and calculate strategy and latency trends. They present data and analysis on arbitrage bot performance, specifically with a focus on PGAs. They even launched their own bot to verify their assumptions about profitability.
  • They then proceed to present a formal model for PGAs, by defining an “advantage” metric to judge the effectiveness of arb strategies. The model has the following properties: 1) continuous time, 2) imperfect information conditions, 3) transaction costs for both auction winners and losers, 4) a probabilistic time termination case, 5) rate limited bids, 6) minimum bids, 7) and minimum bid increments.
  • They defined a function for the strategies used by each player as well as payoff functions for those strategies and simulated the resulting game.
  • The researchers then went on to dissect various types of MEV via a combination of real and theoretical examples. They also parsed and tagged the data collected in previous steps to identify examples of ordering optimization fees and other measurable types of MEV to provide some statistics on the size and prevalence of such risks in Ethereum.
  • Finally, they outlined some attack vectors such as time bandit attacks and fee-based forking attacks that could compromise the security of the Ethereum blockchain. They measured OO fees on DEXes as a method of estimating this risk.

Results

  • Arbitrage Bots
    • This graph shows the measurements performed by the research team to estimate the size of the Ethereum arbitrage market.
    • They also performed subsequent investigation and found revenues were best denominated in ETH terms due to liquidity and volatility concerns with other assets.
    • The researchers identified that after initial market development there was a buzz of activity with over 1k daily trades for 10-100 ETH, eventually maturing into a more consistent distribution for 1-10 ETH in daily arbitrage. They also went on to calculate the expected daily profit of one of these arb bots before most DEXes were live as 0.32 ETH/day.
    • The researchers noted that the majority of arb bots joined the market after the release of their public blog sparking a thriving bot economy.
    • They also identified the existence of oligopolistic pure revenue markets. They identified that single bots often dominated the market in profit making.
  • PGAs & Competitive Bidding
    • The researchers looked at PGAs with competitive bidding and identified a spike around zero profit. Despite the fact that many PGA opportunities are zero profit there are still enough non-zero opportunities to generate some revenue for bot owners.
    • The researchers noted a decrease in gas used as bots optimized over time.
    • They also empirically observed that players are continually reducing their latency which validated their model prediction that players with lower latency have an advantage.
  • PGA Strategies
    • Blind Raising: The researchers’ model predicted that non-adaptive strategies like blind-bidding can outperform in an imperfect information environment by allowing bids to be published faster.
    • Counterbidding: Reactive counter bidding can outperform blind raising under certain conditions.
    • Cooperative strategy: Though perfect cooperation is not seen by virtue of the fact that this is a PGA, some degree of cooperation is optimal to avoid completely diminishing profitability. For example, the researchers discovered that in their observed PGAs, players converged on a 12.5% minimum bid raise.

  • Miner Extractable Value and Security
    • The researchers measured OO fees to estimate risk of MEV attack vectors. About 3.6% of the blocks observed by the researchers contained at least one pure revenue arbitrage transaction. They highlight a few notable examples of such transactions. They still found that OO fees account for a small % of total ordering fees.

Discussion & Key Takeaways

  • Arbitrage Bots: These bots have grown more proliferated since 2017 and once launched, bots tend to get more optimized in their gas expenditure.
  • PGA Strategies: Bots can utilize many different strategies for optimizing profits. In imperfect information environments, blind-raising can be more opiimal than adaptive bidding strategies. Under a different set of conditions, reactive counter bidding can be more optimal for making profits.
  • Nash Equilibria: The researchers showed that arb bots do engage in some uncoordinated cooperation or gas price increments to maintain profitability of the PGA market and that under PGA conditions, some Nash equilibria do exist for cooperative strategies (though such behavior is not perfectly cooperative).
  • Miner Extractable Value and Security
    • MEV: The researchers make clear that it is their conclusion that MEV poses a system risk to the security of the Ethereum blockchain.
    • Undercutting attacks: The researchers define an example attack incentivized by OO fees when miners can “steal” arbitrage trade opportunities by taking the transactions themselves. They go on to state that undercutting attacks represent a present threat in Ethereum and one that will grow with the success of smart contracts that attract OO fees.
    • Time-bandit attacks: Another form of MEV they go on to outline as a potential risk for Ethereum is time-bandit attacks.

Implications & Follow-ups

  • This paper helps to define and illustrate some examples of MEV as well as showcasing how MEV presents a security risk to the Ethereum blockchain.
  • This paper is valuable because previous transaction ordering analyses have been overly broad and as such they have not yielded concrete security strategies. The work of these researchers focuses on smart contract frontrunning and actually attempts to size this economy and could be used to formalize an understanding of protocol attacks.
  • The researchers state that their findings are particularly interesting for two reasons: 1) that they identify a specific difference in the consensus layer between smart contracts and other more simple payment protocols and 2) because their analysis of PGA strategies highlights how the specifics of a protocol structure impact the game theoretic equilibria and as such the security properties.
  • The researchers posed some questions that the community could further answer:
    • Preliminary experiments showed that bot transactions were relatively well distributed across mining pools, though the naive assumption would be for more collusion with miners to emerge. The researchers ask if there are incentives to avoid collusion, such as optics risk.
    • Additionally, they ask if PGAs are positive or negative sum games and how their model could be improved.
    • They also ask if DEX-style vulnerabilities may also be at play in centralized exchanges, just with lower visibility.
    • They ask what techniques might be used to measure CEX trading activity, what financial incentives do CEXes create for DEX malfeasance, what other insights their data on DEX arb behavior could yield, how much larger the arb economy iis than what they visualized, and whether someone could more accurately estimate the amount of MEV on Ethereum today.
  • They also identified some implementation limitations of the research work:
    1. a transaction may be replaced before reaching the measurement nodes.
    2. the time-slicing method for identifying PGAs may erroneously group unrelated activity
    3. some bots not included in the researchers’ whitelists might’ve been missed
    4. pure revenue opportunities are identified by parsing transaction logs but only from a limited subset of popular DEXes
  • The research team identified an opportunity for future work in determining how time-bandit attackers would compete against each other like arb bots in PGAs.
  • Another problem they flag for future work is to estimate the potential impact of time-bandit attacks because any on-chain actions in the past could contribute to the amount of MEV.

Applicability

  • The researchers released a front-end web portal, frontrun.me which can be used to monitor real-time data on PGAs.
  • This work is potentially applicable to determining the security risk of DEX transactions across the board on the Ethereum blockchain.
  • Additionally, the PGA strategies outlined in this paper can be used to inform future game theoretic design standards for DEXes, frontrunning protections, and Ethereum mining more broadly.
  • PGAs are pertinent to the usability of the Ethereum blockchain as well as these types of activity drive up gas cost, potentially pricing out normal consumer-level user actions.
  • Time-bandit attacks impact the degree of confirmation required before ecosystem participants consider transactions to truly be ‘final’.
  • This paper served as the foundation for the continuing work that can be seen on flashbots here
8 Likes

Can highlight the difference between Bitcoin and Ethereum in this kind of arbitrage opportunity:

  • Ordering optimization for miners to take profit by reordering transactions is only possible in Ethereum but not in Bitcoin. Because all transactions in a block are executed atomically in Bitcoin.
2 Likes

The http://frontrun.me/ website seems to be broken now QQ

1 Like

That’s a great point, Tina. In Ethereum, tx ordering often greatly affects arbitrage opportunities at the block level and it is something that has become more relevant today after the advent of flash loans.

It would be fascinating to research whether Ethereum miners receive out-of-band payments (that is, P2P payments outside of block rewards) to facilitate the work of arbitrageurs via transaction ordering. I personally haven’t come across any empirical research on this topic.

3 Likes

Thanks for your response:) is there an example of the out of band payment you mentioned?

3 Likes

I haven’t seen any empirical evidence of that particular payment type, just anecdotes at this point. I’m sure if you deconstruct a large enough sample of blocks you’ll likely see profitable arb transactions at the top that did not pay exorbitant gas prices. That might be indicative of this type of relationship between miners and funds.

2 Likes

This is actually I think an important area of research, but very hard to collect data on, similar to layer 2 p2p transactions. Game theory says miners will extract value as they see fit where risks and transaction costs and barriers to entry do not make such extractions ultimately unprofitable. If there exists an arbitrage between miners and traders, funds, or other empowered actors better able to underwrite the risks or costs of these extractions, then it is reasonable to assume such opportunities will eventually be taken advantage of on average. Whether any deals are struck out of band for further prioritization of these transactions, though interesting, may be impossible to track. You might be able to make some guesses based on pattern breaks where txns are prioritized despite lower gas payments.

2 Likes

There’s also a social contract at play. Time-bandit attacks would directly affect miners’ ability to engage with arbitrageurs because it would set a precedent of competition. The moment a pool structures a time-bandit, funds would likely disengage because of the real risk of pools manipulating arbitrageurs to give them order flow. I suspect this is the main reason we don’t see these attacks in the wild.

On the point of collecting data: there are 2 ways of potentially measuring the predominance of such payments (if they do occur in the form of crypto). The first is to cluster pool addresses and track inflows from arbitrageurs (addresses at the top of the block) into the mining cluster over a long period of time. The second is via opportunity cost. By accepting a transaction with a lower gas price, how much do miners leave on the table?

Needless to say, @Vishesh is completely right on the difficulty involved with both approaches and it will ultimately be hard to paint an accurate picture of this trend.

2 Likes