EIPs Explained

EIP-7801 · Draft · Networking · 2024-10-30

EIP-7801: etha - Sharded Blocks Subprotocol

Proposes a new devp2p subprotocol, etha, in which each node advertises with a 10-bit bitmask which slices of chain history it stores, so history can be sharded across nodes after EIP-4444 pruning.

What problem does it solve?

With EIP-4444 history expiry, execution clients may drop old block bodies and receipts. Some nodes will still keep and serve them, but a node looking for, say, block 5,000,000 has no cheap way to know which peers have it. It must connect and ask, wasting bandwidth on peers that answer "don't have it".

EIP-7801 lets nodes split history into fixed-size segments, keep only some of them, and announce up front which ones they hold. If enough nodes each keep a share, the network as a whole still holds all of history while each node stores much less.

How it works

  • History is cut into spans of 106,496 blocks. Ten spans make a range of 1,064,960 blocks, and the pattern repeats for every range.
  • Each node picks a 10-bit blockBitmask. Bit i set means "I store span i of every range". Both sizes are multiples of 8,192, the maximum block count of an Era1 archive file, so spans map cleanly onto Era1 files.
  • The etha handshake is the eth/69 (EIP-7642) status message plus the bitmask: [version, networkid, blockhash, genesis, forkid, blockBitmask].
  • etha supports four eth/69 messages with identical semantics: GetBlockBodies (0x05), BlockBodies (0x06), GetReceipts (0x0f), Receipts (0x10).
  • Node behavior:
    • MAY set at least one bit at startup and backfill that span.
    • MUST keep the spans it advertises, including future spans as the chain grows.
    • Retention aims to cover at least 10 % of history (one bit).
  • Running as a separate subprotocol means eth itself is untouched, and peers are not flooded with history requests over eth for data they do not have.

An alternative is sketched: deriving or encoding the bitmask in the node's ENR so it is visible before connecting, at the cost of authentication and reliability.

Sample code

Which span bit covers a given block, and does a peer have it (pseudocode):

SPAN = 106_496
RANGE = 1_064_960  # 10 spans

def span_bit(block_number: int) -> int:
    return (block_number % RANGE) // SPAN   # 0..9

def peer_has_block(peer_bitmask: int, block_number: int) -> bool:
    return (peer_bitmask >> span_bit(block_number)) & 1 == 1

# A peer storing spans 0 and 7:
mask = (1 << 0) | (1 << 7)
print(span_bit(5_000_000), peer_has_block(mask, 5_000_000))

Things to know

  • Status: Draft. No hard fork is needed; it is purely a networking change, but clients must implement the new subprotocol.
  • Availability is probabilistic. With each node storing 10 %, the chance that none of n random peers has a given span is about 0.9^n: roughly 7 % for 25 peers and 3.4 % for 32. This only holds if many nodes participate, so default-on adoption by clients would likely be needed.
  • Storage still grows over time, but each node grows at about 10 % of the full-history rate.
  • The spec does not define which bit a node should choose; a poor or skewed choice across the network would leave some spans under-replicated.

#networking #devp2p #history-expiry #p2p

Details

Authors
Ahmad Bitar (@smartprogrammer93) <[email protected]>, Giulio Rebuffo (@Giulio2002), Gary Schulte (@garyschulte) <[email protected]>
Status
Draft
Type
Standards Track / Networking
Created
2024-10-30
Requires

Machine-readable: Markdown · JSON