EIPs Explained

EIP-7956 · Stagnant · Core · 2025-05-24

EIP-7956: Tx Ordering via Block-level Randomness

A stagnant proposal to make transaction order inside a block deterministic, sorting by each transaction hash XOR-ed with per-slot randomness, so builders can still choose which transactions to include but can no longer reorder them for sandwich and front-running MEV.

What problem does it solve?

Today the builder or proposer of a block can put transactions in any order it likes. That freedom is what makes sandwich attacks and classic front-running possible: a searcher sees your swap, places a buy just before it and a sell just after it, and the builder arranges the three in exactly that order.

EIP-7956 removes the freedom to reorder while leaving the freedom to select. Once a builder has picked its set of transactions, their order is fixed by a rule anyone can check, and that order cannot be predicted before the slot begins.

How it works

  • Slot randomness R: taken from the block's randao_reveal. The proposal depends on EIP-7998, which turns randao_reveal into a VRF output so the proposer cannot grind it and others cannot predict it before the slot.
  • Builder flow:
    1. Choose any subset of the mempool (by tip, policy or private deals). Fees still decide inclusion.
    2. Sort the chosen items by keccak(tx) XOR R ascending, with keccak(tx) as tie-breaker.
    3. Pack in that order until the next item would exceed the block gas limit; items that do not fit are skipped.
  • Bundles: for cross-account atomicity, users can sign a bundle of fully signed transactions starting with a fee-payment transaction. The bundle is sorted as one virtual transaction keyed by the hash of its children's concatenated signed RLP encodings, its gas is the sum of the children's gasLimit, and it is either included whole or skipped.
  • Consensus rule: a block whose transactions are not in the canonical order for its randomness is invalid. Fork choice is unchanged.
  • Deployment: new header fields randomness and txOrderingVersion, activated at a fork epoch followed by a transition window during which both legacy (version 0) and ordered (version 1) blocks are accepted.

Sample code

Canonical ordering a validator could check, in Python-style pseudocode:

from eth_utils import keccak

def sort_key(item_bytes: bytes, R: bytes):
    h = keccak(item_bytes)                       # signed RLP of tx, or concat of bundle children
    primary = bytes(a ^ b for a, b in zip(h, R)) # H(tx) XOR R
    return (primary, h)                          # secondary key breaks ties

def build_block(candidates, R, gas_limit):
    ordered = sorted(candidates, key=lambda it: sort_key(it.raw, R))
    body, used = [], 0
    for it in ordered:
        if used + it.gas_cost > gas_limit:       # fit-or-skip
            continue
        body.append(it)
        used += it.gas_cost
    return body

def is_valid_order(block_items, R):
    keys = [sort_key(it.raw, R) for it in block_items]
    return keys == sorted(keys)

Things to know

  • Status: Stagnant. It is not scheduled for any upgrade, and it depends on the Draft EIP-7998.
  • It targets reorder-based MEV only. Back-running, latency races and censorship remain; builders still decide which transactions get in.
  • Parts of the spec are not fully consistent (for example, R is taken as 32 bytes while the header field is described as 16 bytes, and the rationale mentions mixing RANDAO with a separate VRF output). Treat details as unsettled.
  • Users can still try to grind their own transaction hash (for example by changing calldata or nonce-independent fields and re-signing) to land in a better position; the spec argues this is limited because R is unknown until the slot.
  • Typed transaction encodings from EIP-2718 are hashed exactly as they appear in the block, including signatures.

#mev #transaction-ordering #randomness #consensus #core

Details

Authors
Aryaethn (@aryaethn)
Status
Stagnant
Type
Standards Track / Core
Created
2025-05-24
Requires

Machine-readable: Markdown · JSON