EIPs Explained

EIP-5793 · Final · Networking · 2022-10-18

EIP-5793: eth/68 - Add tx type to tx announcement

The eth/68 wire protocol version: transaction announcements now carry each transaction's type and size, so nodes can decide what to fetch before downloading large blob transactions.

What problem does it solve?

Ethereum nodes gossip pending transactions to each other. Since eth/65, a node can announce just the hashes of transactions it has (NewPooledTransactionHashes), and peers request the full bodies they are missing.

With EIP-4844 came blob transactions, which are far larger than ordinary ones. If a node only sees a hash, it cannot tell a 100-byte transfer from a blob-carrying transaction until it has already downloaded it. That makes bandwidth hard to control and opens room for amplification attacks.

EIP-5793 adds just enough metadata to the announcement for a node to make that decision up front.

How it works

It defines protocol version eth/68 and changes one message, NewPooledTransactionHashes (0x08):

eth/67: [hash_0: B_32, hash_1: B_32, ...]
eth/68: [types: B, [size_0: P, size_1: P, ...], [hash_0: B_32, hash_1: B_32, ...]]
  • types is a byte string where byte i is the EIP-2718 type of transaction i (e.g. 0x02 for EIP-1559, 0x03 for blob).
  • size_i is the encoded size of transaction i.
  • The hash list is unchanged.

Note that types is packed as a single byte array rather than an RLP list. Early implementations did it that way and it was kept to avoid extra work.

With this information a node can, for example, never accept blob transactions by push, fetch them only on demand, throttle peers that announce oversized transactions, or skip types it does not support.

Sample code

RLP shape of an eth/68 announcement for three transactions (pseudocode):

import rlp

types  = bytes([0x02, 0x03, 0x00])           # EIP-1559, blob, legacy
sizes  = [180, 131_590, 110]                  # encoded sizes in bytes
hashes = [h0, h1, h2]                         # 32-byte transaction hashes

msg = rlp.encode([types, sizes, hashes])      # payload of message 0x08

# Receiver side
types, sizes, hashes = rlp.decode(msg)
want = [h for t, s, h in zip(types, sizes, hashes)
        if t != 0x03 or wants_blobs()]        # decide what to request
send_get_pooled_transactions(want)

Things to know

  • Status: Final. It is a networking change only: no hard fork and no consensus change. Nodes negotiate the protocol version, so eth/67 and eth/68 peers could coexist during rollout.
  • Receivers should check that the transactions they eventually fetch match the announced type and size; a mismatch is a sign of a misbehaving peer.
  • A later version, eth/69, builds on eth/68 with changes around history expiry and receipts.

#networking #devp2p #mempool #eth68 #blobs

Details

Authors
Marius van der Wijden (@MariusVanDerWijden)
Status
Final
Type
Standards Track / Networking
Created
2022-10-18
Requires
Required by

Machine-readable: Markdown · JSON