EIPs Explained

EIP-2976 · Final · Networking · 2020-09-13

EIP-2976: Typed Transactions over Gossip

Defines how typed transactions and receipts (EIP-2718) are carried over the devp2p eth protocol, so new transaction types can be gossiped without a protocol version bump.

What problem does it solve?

EIP-2718 introduced the typed transaction envelope: a transaction can be TransactionType || TransactionPayload instead of a plain RLP list. That changed how blocks commit to transactions and receipts, but by itself it said nothing about the peer-to-peer network. If nodes cannot pass typed transactions to each other, nobody can get one into a block.

EIP-2976 updates the eth devp2p wire protocol so typed transactions and receipts can travel between peers. It does so once, generically, so that later types (access lists, 1559 fee transactions, blobs…) do not each require a new protocol version.

How it works

  • Wherever the protocol carried a transaction, it now carries either a legacy transaction (RLP list [nonce, gasPrice, gasLimit, to, value, data, v, r, s]) or a typed transaction (opaque bytes type || payload, type 0x00–0x7f).
  • Receipts follow the same pattern: legacy RLP list, or type || receiptPayload.
  • Affected messages: Transactions, BlockBodies, NewBlock, NewPooledTransactionIds, GetPooledTransactions, PooledTransactions, and Receipts.
  • Transaction identifiers are keccak256 of the typed bytes, or of the RLP for legacy transactions.
  • The protocol layer does not understand payloads. Each new type's EIP defines its payload; the wire format stays the same.

Peer rules:

  • Unknown TransactionType or a payload invalid for its type: the receiver should disconnect the sender.
  • Nodes must not send a new type before its activation fork, and may disconnect peers that do so well before the fork.

The changes apply retroactively to all eth protocol versions rather than introducing a new one.

Sample code

Telling legacy and typed transactions apart on the wire (TypeScript):

import { decodeRlp, getBytes, keccak256 } from "ethers";

function classify(raw: string) {
  const bytes = getBytes(raw);
  const first = bytes[0];
  if (first >= 0xc0) {
    // RLP list prefix: legacy transaction
    return { kind: "legacy", fields: decodeRlp(raw), hash: keccak256(bytes) };
  }
  if (first <= 0x7f) {
    // EIP-2718 envelope: type byte + opaque payload
    return { kind: "typed", type: first, hash: keccak256(bytes) };
  }
  throw new Error("invalid transaction encoding");
}

Message shapes (pseudo-RLP):

Transactions (0x02):        [tx_0, tx_1, ...]            ; tx = legacy list | typed bytes
BlockBodies  (0x06):        [[txList, uncleList], ...]
Receipts     (0x10):        [[receipt_0, receipt_1, ...], ...]

Things to know

  • Status: Final. Every transaction type in use today, including EIP-2930 access-list and EIP-1559 fee-market transactions, travels the network under these rules.
  • Disconnecting on unknown types protects against spam disguised as "maybe a future type". The spec advises relaxing this only for trusted peers.
  • Later protocol versions built on this. For example, eth/68 (EIP-5793) adds the transaction type to transaction announcements.
  • Legacy transactions remain fully supported.

#networking #devp2p #transactions #typed-transactions

Details

Authors
Micah Zoltu (@MicahZoltu)
Status
Final
Type
Standards Track / Networking
Created
2020-09-13
Requires

Machine-readable: Markdown · JSON