EIP-6122 · Final · Networking · 2022-12-13
EIP-6122: Forkid checks based on timestamps
Extends the p2p fork identifier (forkid) so it covers forks scheduled by timestamp, which every execution-layer upgrade since the Merge uses, letting nodes keep dropping misconfigured peers.
What problem does it solve?
EIP-2124 gave every node a compact fork identifier (forkid) that it announces during the devp2p handshake. Peers compare forkids to quickly drop nodes that are on another network or are missing an upgrade. The original design assumed forks activate at block numbers.
After the Merge (EIP-3675) the consensus layer schedules upgrades by slot, which is a measure of time. To activate at the same moment on both layers, execution-layer forks (starting with Shanghai) are scheduled by timestamp. EIP-6122 updates the forkid rules so timestamp-based forks are included too.
How it works
The forkid is still the pair (FORK_HASH, FORK_NEXT):
FORK_HASH: an IEEE CRC32 checksum over the genesis hash followed by every fork activation point that has already passed, in ascending order. Each activation point is auint64in big-endian, whether it is a block number or a timestamp. Several forks at the same point are checksummed once; rules active at genesis do not count as forks.FORK_NEXT: the block number or timestamp of the next known fork, or0if none. There is no need to say which kind it is.
Two extra rules make mixing the two kinds safe:
- Timestamp forks must be scheduled at or after all block-number forks (on mainnet and private networks).
- When validating a remote forkid, an implementation filters forks by block number first, then by timestamp.
Since block numbers (millions) and Unix timestamps (over a billion) occupy different ranges, the single ordered list works in practice.
Sample code
Computing a FORK_HASH incrementally (Python):
import zlib
def fork_hash(genesis_hash: bytes, passed_forks: list[int]) -> str:
"""passed_forks: block numbers then timestamps, ascending, deduplicated."""
crc = zlib.crc32(genesis_hash)
for point in passed_forks:
crc = zlib.crc32(point.to_bytes(8, "big"), crc)
return f"0x{crc:08x}"
# Example from the spec: Homestead (block 1150000) plus a fictional
# timestamp fork at 1668000000 on top of mainnet genesis gives 0xcb37b2ee.
mainnet_genesis = bytes.fromhex(
"d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")
print(fork_hash(mainnet_genesis, [1150000, 1668000000]))
On the wire, the forkid travels in the eth protocol Status message and in the ENR eth entry as [fork_hash, fork_next], exactly as in EIP-2124.
Things to know
- Status is Final, and it is implemented by execution clients; it was needed from Shanghai onward.
- By design, nodes that do not apply this change are disconnected once the first timestamp-based fork passes. That is the point of forkid.
- If you run a private network, keep all timestamp forks after all block forks or forkid checks may misbehave.
- The spec's test vectors use a fictional configuration (merge split at block 18,000,000 and a fork at 1,668,000,000); they are not the real mainnet schedule.