EIP-2364 · Final · Networking · 2019-11-08
EIP-2364: eth/64: forkid-extended protocol handshake
Introduced the eth/64 wire protocol, which adds the EIP-2124 fork identifier to the Status handshake so nodes on incompatible chains or fork rules disconnect before wasting work on each other.
What problem does it solve?
When two Ethereum nodes connect, they need to know quickly whether they are even on the same chain. Before eth/64 the handshake only compared the network ID and genesis hash. Two nodes could share a genesis yet disagree about which upgrades (forks) have activated, for example a node that missed a hard-fork release. They would only find out later, after exchanging headers and blocks and running expensive validation, and meanwhile the incompatible peer occupied a scarce peer slot.
EIP-2124 defined a compact fork identifier (forkid) that summarises "genesis + every fork already passed + the next scheduled fork". But it did not say where nodes should exchange it. EIP-2364 puts it into the eth protocol handshake.
How it works
- A new protocol version,
eth/64, is advertised as a devp2p capability. Because devp2p can run several versions of a sub-protocol side by side,eth/63could keep running for peers that had not upgraded. No hard fork was needed. - The
Status (0x00)message gains one trailing field:- old:
[protocolVersion, networkId, td, bestHash, genesisHash] - new:
[protocolVersion, networkId, td, bestHash, genesisHash, forkid]
- old:
forkidis[forkHash, forkNext]: a 4-byte CRC32 checksum over the genesis hash and past fork block numbers, plus the number of the next known fork (0 if none). How to compute and compare it is defined entirely in EIP-2124.- Both peers must send the updated
Statusfirst, validate the remoteforkid, and disconnect if they detect an incompatibility.
The genesisHash field was deliberately kept even though forkHash already commits to it, because crawlers and other tools used it to group nodes by network.
EIP-2124 also suggests advertising the forkid in node discovery (ENR). That filters peers even earlier, but discovery data can be stale and not every node uses UDP discovery, so the handshake check remains the authoritative one.
Sample code
RLP structure of the eth/64 Status message (pseudocode):
status = [
64, # protocolVersion
network_id, # e.g. 1 for mainnet
total_difficulty,
best_hash, # 32 bytes
genesis_hash, # 32 bytes
[fork_hash, fork_next], # forkid: 4-byte CRC32, uint64 next fork (0 = none)
]
send(msg_code=0x00, payload=rlp.encode(status))
remote = rlp.decode(recv_status())
if not forkid_compatible(local_forkid, remote[5]): # rules from EIP-2124
disconnect(reason="incompatible fork")
Things to know
- Status: Final. It is a networking change only; it does not touch consensus.
eth/64itself has long been superseded by later versions, starting witheth/65(EIP-2464, transaction announcements) andeth/66(EIP-2481, request IDs). Those later versions keep theforkidfield inStatus.- Test vectors for computing fork IDs live in EIP-2124, not here.
- If you run a private network, every node must agree on the fork schedule in its chain config, otherwise their fork IDs will differ and they will refuse to peer.