Skip to main content
Kofi Finance
Kofi Finance
View all authors

Transaction Shuffling and MEV on Aptos

· 5 min read
Kofi Finance
Kofi Finance

Transaction lifecycle on Aptos

edited 2025-02-21

On Aptos, transactions follow a structured lifecycle to achieve finality. Initially, transactions are submitted to full nodes, which propagate them to validator nodes. Within the consensus layer—powered by AptosBFT—transactions are collected into a proposed block and reordered using a pre-execution shuffling mechanism to balance the load and enhance fairness. Once consensus is reached among validators, the agreed-upon block, containing the shuffled transaction order and cryptographic proofs, is finalized. The execution engine then processes these transactions, leveraging Block-STM for parallel execution, and updates the ledger, achieving rapid finality with robust security. This design integrates shuffling within consensus to determine the transaction order, followed by efficient execution and ledger confirmation.

Pre-Execution Shuffling

In between consensus and execution, Aptos uses a pre-execution shuffling mechanism to order transactions. This mechanism is used to:

  • Balance the Load: Prevent a burst of transactions from the same sender or of the same type.

As noted in AIP-68:

"...This (Long block latency) is expected to happen in this particular situation where spikes of conflicting/sequential transactions from a popular module (smart contract) dominates the traffic"

How transaction shuffling works on Aptos

Example 1

Transaction Shuffling on Aptos

The diagram above illustrates how transaction shuffling works in practice. Let's break it down:

  1. Original Transaction Order:

    • The top row shows transactions in their original order (0-9)
    • Transactions of the same sender have the same letter
    • Transactions of the same use case (smart contract) have the same color
    • Each circle represents a transaction, with numbers indicating their original position
  2. Shuffled Transaction Order:

    • The bottom row shows transactions after shuffling
    • The numbers below show their new positions
    • With sender_spread_factor = 1, transactions from the same sender are spread apart
    • Notice how green "A" transactions that were originally clustered are now distributed
  3. Shuffling Parameters:

    • sender_spread_factor = 1: Spreads transactions from the same sender
    • platform_use_case_spread_factor = 0: No additional delay for platform transactions
    • user_use_case_spread_factor = 0: No additional delay for user transactions
  4. Result:

    • Transactions from sender A (green) are spread out evenly
    • Transactions from sender B (blue) and C (orange) maintain relative ordering
    • Each transaction is shifted by 1 slot relative to others from the same sender

Example 2

Transaction Shuffling on Aptos

Let's analyze this diagram which shows a more complex shuffling scenario:

  1. Original Transaction Order:

    • Similar to Example 1, transactions are shown with sender (letter) and use case (color)
  2. Shuffling Parameters:

    • sender_spread_factor = 2: Spreads transactions from the same sender further apart
    • platform_use_case_spread_factor = 0: No additional delay for platform transactions
    • user_use_case_spread_factor = 1: Slight delay for user transactions
  3. Key Effects:

    • "Same context transactions are spaced by 1" - Transactions with the same use case maintain a minimum spacing
    • "Same sender transactions are spread by at least 2 slots" - Due to sender_spread_factor
    • "Both spreads are applied independently" - The transaction will be delayed by whichever spread factor results in a longer delay
    • Some sender spreads "could not be fulfilled" due to competing constraints

This example demonstrates how multiple spread factors interact and sometimes compete, leading to a complex but deterministic reordering that balances various constraints.

More examples can be found in test cases in the Aptos codebase

Live Parameters

The current live parameters for the transaction shuffler are:

ParameterValueEffect
sender_spread_factor32Spreads transactions from the same sender, with potential saturation
platform_use_case_spread_factor0No delay for platform transactions, prioritizing system operations
user_use_case_spread_factor4Spaces out user transactions to prevent dominance in order

Code

pub fn default_for_genesis() -> Self {
TransactionShufflerType::UseCaseAware {
sender_spread_factor: 32,
platform_use_case_spread_factor: 0,
user_use_case_spread_factor: 4,
}
}

Implications for MEV Strategies

Aptos's transaction shuffling mechanism fundamentally alters the landscape for Maximum Extractable Value (MEV) strategies by introducing dynamic, consensus-driven reordering before execution, building on an initial gas-based queue. This design imposes significant challenges for MEV extractors:

  • Reduced Predictability in Ordering: Transactions enter the consensus phase with an initial order based on gas prices, reflecting submitter priority. However, the UseCaseAware shuffler, with parameters like sender_spread_factor (32) and user_use_case_spread_factor (4), then disperses these transactions across the block based on sender and use-case constraints. This interplay transforms the predictable gas-based sequence into a complex, volume-dependent order, making it harder for MEV actors to anticipate final positions.

  • Disrupted Concentration and Fairness: While gas offers a starting advantage, shuffling prevents bursts of related transactions (e.g., multiple trades from one sender), diluting opportunities for MEV tactics like front-running or arbitrage. This fosters a more equitable market by reducing the dominance of high-gas bidders who might otherwise cluster transactions for profit.

    The shuffling process—integrated into the AptosBFT consensus layer—begins with a gas-prioritized queue, then applies use-case prioritization (e.g., spacing user transactions by 4 slots) and sender-specific spreads (e.g., up to 32 slots). This layered approach, backed by a priority queue system, evolves transaction ordering beyond simple gas auctions. For instance, a bot attempting to front-run a large decentralized exchange trade with a high gas bid might still lose its edge if shuffling spreads its transaction apart from the target. While this enhances fairness and load balancing, it may slightly delay time-sensitive trades initially favored by gas, a trade-off for resilience.

MEV strategies must now adapt, potentially shifting from exploiting gas-driven order to analyzing shuffle patterns across blocks. As MEV techniques advance, Aptos's tunable shuffling parameters, layered atop gas prioritization, will be key to sustaining an equitable ecosystem, indirectly bolstering network integrity by curbing manipulative reorderings.

Predictive MEV on Aptos

· 5 min read
Kofi Finance
Kofi Finance

Maximal Extractable Value (MEV) has become a crucial concept in the blockchain world, with implications that are particularly relevant for emerging networks like Aptos. As the blockchain ecosystem evolves, understanding MEV is essential to exploring resilient and innovative infrastructure on platforms that are shaping the future — and Aptos is at the forefront.

Understanding MEV

Maximal Extractable Value refers to the maximum value that can be extracted from block production beyond standard block rewards and gas fees. This potential is realized when block producers — whether they are miners or validators — manipulate the ordering, inclusion, or exclusion of transactions in a block to secure additional profit.

Originally coined as "Miner Extractable Value" in 2014 by a pseudonymous trader, this concept predicted that miners could leverage transaction ordering for gain. It was later formalized in the seminal 2019 research paper "Flash Boys 2.0," which drew parallels between blockchain transaction manipulation and the practices of high-frequency trading in traditional finance.

A brief timeline for the evolution of MEV

In essence, MEV is extracted through the reordering of transactions within a block, and the methodology of said has evolved over time. Let's take a look at its evolution.

  1. Miner Bribing (2015-2022): In the early days of Ethereum's Proof of Work era, users could attempt to influence miners to include or order their transactions in specific ways. This was often done through smart contracts that offered additional rewards to miners for favorable transaction placement.

  2. Gas fee reordering (ordering not guaranteed) (2015-2021): Miners typically ordered transactions based on gas fees, with higher-fee transactions getting priority. Users could increase their gas price to improve their chances of earlier inclusion, though this didn't guarantee a specific order.

  3. Priority fee reordering (ordering not guaranteed) (2021-present): Introduced with EIP-1559 in August 2021, the priority fee allowed users to directly incentivize miners (later validators) to include their transactions. While higher priority fees increased the likelihood of quicker inclusion, they still didn't guarantee a specific order.

  4. Flashbots / Bundling (2020-present): Flashbots introduced a more sophisticated approach to MEV extraction. It allowed users to submit bundles of transactions with specific ordering requirements, providing a more reliable method for transaction ordering and MEV extraction.

  5. MEV on Solana: JITO (2022-present): As MEV concepts expanded beyond Ethereum, other blockchains like Solana developed their own MEV solutions. JITO on Solana represents an adaptation of MEV extraction techniques to Solana's unique blockchain architecture and consensus mechanism.

  6. MEV on Aptos: ???

Aptos Architecture and MEV Potential

The architectural design of Aptos, particularly its BFT consensus mechanism and Block-STM parallel execution engine, introduces significant challenges and changes to how MEV (Maximal Extractable Value) can be extracted. These design choices fundamentally alter the landscape of MEV extraction compared to traditional blockchain architectures.

AptosBFT Consensus and MEV

Aptos uses AptosBFT, a consensus algorithm based on HotStuff, which implements a round-by-round consensus and block chaining mechanism according to Chorus One's analysis. This approach has several implications for MEV:

  1. Faster Finality: AptosBFT's design allows for quicker transaction finality ~0.9s, potentially reducing the window of opportunity for MEV extraction.

  2. Validator Rotation: The consensus mechanism rotates proposers (aka validator leaders), making it more challenging for a single entity to consistently control transaction ordering.

Block-STM Parallel Execution and MEV

The Block-STM parallel execution engine introduces a paradigm shift in how transactions are processed, significantly impacting MEV extraction:

  1. Dynamic Reordering: The engine may reorder transactions across one or more blocks to optimize concurrency—meaning that the order of transactions might change dynamically between blocks, as explained in the Aptos whitepaper. MEV extractors will need to adapt their strategies to account for both sender-aware and use-case-aware shuffling, potentially reducing the effectiveness of certain MEV extraction techniques that rely on precise transaction ordering.

  2. Conflict-Induced re-execution: When conflicts occur, transactions may be re-executed, altering the state that subsequent transactions interact with and potentially invalidating MEV extraction strategies.

  3. Ripple Effect: When a transaction aborts due to a conflict, all higher transactions in the block are scheduled for re-validation. This cascading effect introduces further unpredictability in the final transaction order and state.

Why MEV Matters for Aptos

Understanding and proactively managing MEV is critical for ensuring the success and integrity of the Aptos ecosystem:

As we continue our exploration into MEV infrastructure on Aptos, future discussions will dive into tailored strategies, potential challenges, and innovative solutions to ensure a secure and efficient blockchain environment.