EIPs Explained

EIP-2464 · Final · Networking · 2020-01-13

EIP-2464: eth/65: transaction announcements and retrievals

Introduced eth/65, which lets nodes announce new transactions by hash and fetch only the ones they lack, cutting the bandwidth wasted on gossiping the same transactions to every peer.

What problem does it solve?

For blocks, the eth wire protocol already had two ways to propagate: send the full block to a small (square root) number of peers, and only announce its hash to the rest. Transactions had no such split. Up to eth/64, a node could only push complete transactions with the Transactions (0x02) message, so to reach every corner of the network it had to send each transaction to all of its peers. With N peers, the same transaction crossed each connection, wasting bandwidth N times over.

Connecting to a new peer was worse: the two nodes had no way to tell which pending transactions the other already had, so they exchanged their entire pools, which the spec estimates at tens to hundreds of MB.

How it works

EIP-2464 adds three messages and bumps the protocol to eth/65:

Message Code Payload Purpose
NewPooledTransactionHashes 0x08 list of 32-byte hashes "I have these pending transactions"
GetPooledTransactions 0x09 list of 32-byte hashes "Send me these from your pool"
PooledTransactions 0x0a list of transactions Reply to a GetPooledTransactions request

The flow is: announce hashes to most peers, let each peer request only what it is missing, then answer with the full transactions. Full broadcast can be limited to a small subset of peers, as is already done for blocks. Syncing pools with a new peer drops to roughly len(pool) × 32 bytes.

Key rules:

  • Only transactions in the pool (not yet in a block) are announced or served. Nodes never read the database to answer, which avoids a cheap denial-of-service vector.
  • There is no protocol-level cap on list length beyond the 10 MB devp2p packet limit, but the spec suggests about 4096 hashes per announcement and 256 per request.
  • Replies keep the request order and may skip unavailable items, so the requester can tell which hashes to retry (everything after the last returned one) and which to treat as unavailable (gaps before it).
  • A separate reply message (rather than reusing 0x02) makes it easy to match responses to requests.

Sample code

Message shapes in RLP-style pseudocode:

NewPooledTransactionHashes (0x08): [txhash_0: B_32, txhash_1: B_32, ...]
GetPooledTransactions      (0x09): [txhash_0: B_32, txhash_1: B_32, ...]
PooledTransactions         (0x0a): [tx_0, tx_1, ...]   # same order as requested, gaps allowed

A simplified handler for incoming announcements:

def on_new_pooled_hashes(peer, hashes):
    missing = [h for h in hashes if h not in txpool and h not in in_flight]
    for chunk in batches(missing, 256):           # suggested request size
        in_flight.update(chunk)
        peer.send(GetPooledTransactions(chunk))

def on_pooled_transactions(peer, requested, txs):
    for tx in txs:
        txpool.add(tx)
    # hashes after the last returned tx can be re-requested;
    # gaps before it are treated as unavailable

Things to know

  • This is a networking change only. It does not touch consensus and needed no hard fork; devp2p runs several eth versions side by side, so upgraded and old clients kept talking over eth/64.
  • Later versions build on it: eth/66 added request IDs, and eth/68 added transaction types and sizes to the hash announcements.
  • A peer may announce a transaction and later fail to serve it if it was included in a block in the meantime; this is not a protocol violation.

#networking #devp2p #mempool #transactions #protocol

Details

Authors
Péter Szilágyi <[email protected]>, Péter Szilágyi (@karalabe), Gary Rong <[email protected]>, Tim Beiko (@timbeiko)
Status
Final
Type
Standards Track / Networking
Created
2020-01-13
Requires
Required by

Machine-readable: Markdown · JSON