whitestork logo
  • whitestork logo
  • Services
    Managed DevOpsCloud Consulting Cloud MigrationCloud Native ApplicationCloud Managed ServicesSoftware DevelopmentUX/UI DesignAWS Well-Architected Framework ReviewsGenAI Solutions
  • Expertise
    Solution ArchitectingServerless ComputingCloud SecurityData Analytics
  • Resources
    Case StudiesBlogsAWS Assessments
  • About
    Who We ArePrivacy Policy
Ensuring High Availability in Kubernetes Clusters: Best Practices and Implementation Guide

Ensuring High Availability in Kubernetes Clusters: Best Practices and Implementation Guide

High availability (HA) is essential for modern applications to ensure uninterrupted service and mini...
Fast Search with PostgreSQL: GIN Index

Fast Search with PostgreSQL: GIN Index

Searching in a large table housing billions of rows can be challenging, particularly when querying f...
TALK
TO US
& LET’S MAKE GREAT THINGS HAPPEN
logo
Services
  • Managed DevOps
  • Cloud Consulting
  • Cloud Migration
  • Cloud Native Application
  • Cloud Managed Services
  • Software Development
  • UX/UI Design
  • AWS Well-Architected Framework Reviews
  • GenAI Solutions
Expertise
  • Solution Architecting
  • Serverless Computing
  • Cloud Security
  • Data Analytics
Resources
  • Case Studies
  • Blogs
  • AWS Assessments
About
  • Who We Are
  • Privacy Policy
Get in touch
    • Beirut, Lebanon
    • Downtown, Azarieh A2-1
    • [email protected]
    Ali Youssef
    Ali Youssef| 2024-04-26

    Unraveling the Complex World of Maximal Extractable Value (MEV) And FlashBots

    Unraveling the Complex World of Maximal Extractable Value (MEV) And FlashBots

    Introduction

    The concept of Maximal Extractable Value (MEV) has become a pivotal yet complex topic in the blockchain community. Originally known as Miner Extractable Value in the context of Proof-of-Work (PoW) blockchains, MEV extends to validators in Proof-of-Stake (PoS) systems, reflecting its broader applicability beyond just mining operations.

    mev-mainmev.webp


     

    What is MEV?

    MEV represents the maximum value a block producer (miner or validator) can extract from transaction ordering within a block, in addition to standard block rewards and gas fees. This capability arises from their unique position to add, remove, or rearrange transactions unilaterally.


     

    The Role of Block Producers

    In the blockchain ecosystem, miners and validators are the linchpins securing the network and confirming transactions. Their autonomy in transaction management allows them to manipulate transaction ordering for personal gain, often leading to scenarios where regular users face disadvantages due to inflated transaction fees or delayed processing.


     

    A Real-World Example

    Consider an arbitrage opportunity on a decentralized exchange like Curve. A bot detects this opportunity and submits a transaction with a $50 transaction fee. The block producer can either execute this transaction themselves or kickstart a Priority Gas Auction (PGA), where other bots bid higher fees to capture the arbitrage. This bidding war and the potential profit form the essence of MEV.


     

    The Discovery and Recognition of MEV

    MEV’s roots trace back to 2014 when an analyst coder, Pmcgoohan, first identified the issue. However, it wasn’t until the publication of “Flash Boys 2.0” in 2019 and subsequent influential articles in 2020 that MEV gained widespread recognition as a critical challenge in Ethereum and other blockchain ecosystems.


     

    Types of MEV

    MEV manifests in various forms, including:

    1. Front-running: Where bots pre-empt a known pending transaction.
    2. DEX Arbitrage: Exploiting price differences across exchanges.
    3. Sandwich Attacks: Placing orders before and after a known transaction.
    4. Back-Running: Following a target transaction in the execution queue.
    5. Liquidations: Capitalizing on liquidating over-collateralized loans.
    6. Time-Bandit Attacks: Reordering past blocks for profit.
    7. NFT MEV: Exploiting opportunities in the NFT marketplace.


     

    The Impact of MEV

    MEV not only causes network congestion and elevates gas prices but also challenges the principles of neutrality, transparency, and security in blockchain networks. It introduces a level of unpredictability and potential for exploitation that can undermine the integrity of the blockchain.


     

    Comparative Analysis with Traditional Finance

    Drawing parallels with traditional financial systems, MEV resembles high-frequency trading, where traders exploit time and speed advantages. This comparison sheds light on the universality of such strategies across financial platforms.


     

    Solutions to MEV

    Solutions to MEV fall into two categories:

    1. Offensive Approaches: These include Front-running as a Service (FaaS) and MEV Auctions, aiming to extract and democratize MEV.
    2. Defensive Approaches: Also known as MEV Minimization, these solutions focus on preventing MEV through innovative protocols and network designs.


     

    Flashbots: A Solution to the MEV Puzzle

    Flashbots emerged as a response to the inherent flaws in the Ethereum transaction system, particularly during high-traffic events like major NFT drops. Understanding these flaws and Flashbots’ role is crucial in grasping the full picture of MEV.


     

    Ethereum’s Transaction System and its Flaws

    During a significant NFT drop, the transaction process typically involves:

    1. Sending a transaction to a smart contract for minting, which then enters the public transaction mempool.
    2. The transaction is prioritized based on the provided max priority fee and max fee, assuming the implementation of EIP-1559.
    3. The transaction’s fate depends on whether the max fee can accommodate a surge in network traffic.


     

    Issues with the Ethereum Transaction System

    1. Transparency of the Public Mempool: The visibility of transactions allows malicious actors to front-run by duplicating transactions with higher fees.
    2. Gas Price Dependence: Bidders face challenges in expressing granular order preferences due to reliance on gas prices.
    3. All-Pay Auction Nature: Failed bids revert on the chain, consuming block space and leading to under-priced bids due to execution risks.


     

    Flashbots’ Architecture and Mechanism

    To mitigate these issues, Flashbots uses a unique architecture consisting of:

    1. Searchers: Monitor the chain and send transaction bundles to relayers.
    2. Relayers: Validate and forward bundles to miners.
    3. Miners: Accept and process bundles to produce a block.

    Searchers’ Role:

    Searchers create transaction bundles and send them to Flashbots relayers for pre-trade privacy, ensuring that transactions aren’t exposed to front-running risks in the public mempool. They can also incentivize miners through direct ETH transfers or set gas prices, effectively acting as a ‘bribe’.

    Relayers’ Function:

    Relayers play a crucial role in validating and routing Flashbots bundles to miners. They may offer additional services like bundle merging and execution, allowing searchers to focus on their transaction types. Trust in relayers is vital, as they can view the contents of transaction bundles.

    Miners’ Involvement:

    Miners, running a modified mev-geth client, prioritize these bundles, influenced by the incentives provided. This client diverges from the traditional geth client, which orders transactions primarily by gas price.


     

    MEV-Boost: Bridging the Present and Future of MEV Mitigation

    Understanding MEV-Boost is essential to grasp the evolving landscape of MEV solutions, particularly in the context of Ethereum’s shift to Proof of Stake (PoS). MEV-Boost can be seen as an iteration of the original Flashbots auction, paving the way for a full in-protocol implementation of Proposer/Builder Separation (PBS).

    mev-mainmevboost.png

    Mev Boost


     


     

    What is MEV-Boost?

    MEV-Boost extends the Flashbots approach for PoS Ethereum. It acts as an intermediate step towards achieving full in-protocol PBS, offering block-building functionality that would otherwise be unavailable until the completion of PBS.


     

    The Current State of Flashbots Auction

    Flashbots provides a private transaction pool (mev-relay) and a sealed bid blockspace auction mechanism (mev-geth), enabling miners to outsource optimal block construction. This system involves:

    1. Searchers: Monitoring the chain state and sending transaction bundles to relayers.
    2. Relayers: Receiving bundles from searchers, validating them, and forwarding them to miners.
    3. Miners/Block Producers: Running mev-geth, evaluating bundles using a sealed-bid auction, and producing the most profitable block.


     

    The Role of Proposer/Builder Separation (PBS)

    PBS was proposed to mitigate the centralization risks posed by uncontrolled MEV extraction. In this model, the block proposer outsources block creation to a market of block builders, who provide complete blocks along with a fee for the proposer. This separation is designed to ensure trust and efficiency, reducing the technical burden on proposers and preventing extraction of transactions without paying the fee.


     

    MEV-Boost Architecture and Functionality

    MEV-Boost, compatible with PoS Ethereum, implements PBS’s design goals in a semi-trusted manner. The architecture includes:

    1. Block Builders: Aggregating bundles and transactions into block templates.
    2. Relay: Receiving block templates, and verifying their validity.
    3. MEV-Boost Middleware: Handling communication with relays, profit-switching logic, and fallback mechanisms.


     

    The Link Between PBS and MEV-Boost

    MEV-Boost acts as a prototype for a block-building market, providing proposer logic and middleware absent in PoS Ethereum. It’s a crucial step towards the protocol’s longer-term goals, such as stateless Ethereum and the favored sharding proposal (Danksharding).


     

    Conclusion

    In summary, the emergence and evolution of Maximal Extractable Value (MEV) illustrate a critical intersection between blockchain technology and strategic economic behavior. Solutions such as Flashbots and MEV-Boost represent pivotal advancements in addressing the complexities of MEV. These tools not only enhance transaction equity and security within Ethereum’s blockchain but also signify a progressive step towards a more transparent and decentralized blockchain ecosystem. As the blockchain landscape continues to mature, the innovations and strategies embodied in Flashbots and MEV-Boost will be instrumental in shaping its path toward greater fairness and resilience.


     

    References

    • https://ethereum.org/en/developers/docs/mev/
    • https://docs.flashbots.net/
    • https://docs.alchemy.com/docs/how-to-send-a-private-transaction-on-ethereum?
    • https://docs.chainstack.com/operations/ethereum/mev-api#example
    • https://writings.flashbots.net/beginners-guide-mevboost
    • https://medium.com/@ItsCuzzo/understanding-flashbots-61cf030a1563
    Share

    More to read