EIPs Explained

EIP-8 · Final · Networking · 2015-12-18

EIP-8: devp2p Forward Compatibility Requirements for Homestead

Made Ethereum's peer-to-peer protocols tolerant of newer versions and extra fields, so future network upgrades would not split old and new nodes.

What problem does it solve?

Ethereum nodes talk to each other over devp2p: a discovery protocol to find peers, an encrypted TCP transport (RLPx) and a "hello" handshake. In 2015 clients checked version numbers and packet layouts strictly. If a peer sent a higher version or one extra field, the connection was dropped.

That made every networking change a flag day: either everyone upgrades at once, or the network fragments. EIP-8 removed that trap by requiring clients to follow Postel's Law: "be conservative in what you do, be liberal in what you accept from others." It shipped with the Homestead upgrade (EIP-606).

How it works

The rules apply to three protocol layers:

  • devp2p wire protocol (hello packet). Ignore the peer's version number, send your own highest supported version, and ignore any extra list elements at the end.

  • RLPx discovery. Do not validate the ping version, ignore extra list elements and trailing data, and silently drop unknown packet types. The 1280-byte packet size limit stays.

  • RLPx TCP handshake. A new handshake encoding is introduced:

    • a 2-byte plaintext length prefix in front of the encrypted body,
    • the body encoded as an RLP list,
    • a version number (4) inside both auth and ack packets, replacing an unused flag,
    • removal of a redundant hash of the ephemeral key.

    Receivers ignore version mismatches, extra list elements and trailing bytes. During the transition, senders pad the auth body with 100 to 300 random bytes so new-format packets are distinguishable from the fixed-size old ones and are harder to fingerprint.

With these rules, a newer client can bump its version and append fields. An older node simply ignores what it does not understand and keeps talking with the old feature set.

Sample code

The new handshake layout, from the spec:

auth-vsn      = 4
auth-size     = size of enc-auth-body, big-endian 16-bit integer
auth-body     = rlp.list(sig, initiator-pubk, initiator-nonce, auth-vsn)
enc-auth-body = ecies.encrypt(recipient-pubk, auth-body, auth-size)
auth-packet   = auth-size || enc-auth-body

ack-body      = rlp.list(recipient-ephemeral-pubk, recipient-nonce, ack-vsn)
ack-packet    = ack-size || ecies.encrypt(initiator-pubk, ack-body, ack-size)

How a receiver can accept both the old and new formats (pseudocode):

packet = read(307, conn)          // old format has a fixed size
if decrypt(packet) {
    // legacy handshake
} else {
    size := bigEndianUint16(packet[:2])
    packet += read(size - 307 + 2, conn)
    if !decrypt(packet) { /* error */ }
    // EIP-8 handshake
}

The length prefix is also passed to ECIES as authenticated data, so it cannot be tampered with.

Things to know

  • This is a networking change, not a consensus change. It does not alter blocks or transactions, but all clients needed it to keep future upgrades smooth.
  • The plaintext size prefix was the most debated part, because it can help someone identify RLPx traffic. The spec argues that randomized padding limits that risk.
  • The EIP is backwards compatible: all valid version-4 packets are still accepted.
  • The spec includes test vectors for hello, ping, pong, findnode, neighbours and handshake packets. Client authors should run them.
  • The same "ignore what you don't know" principle is why later protocol versions could be rolled out gradually.

#networking #devp2p #rlpx #homestead

Details

Authors
Felix Lange <[email protected]>
Status
Final
Type
Standards Track / Networking
Created
2015-12-18
Required by

Machine-readable: Markdown · JSON