---
eip: 2124
label: EIP-2124
title: Fork identifier for chain compatibility checks
status: Final
type: Standards Track
category: Networking
created: 2019-05-03
official: https://eips.ethereum.org/EIPS/eip-2124
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2124.md
canonical: https://eips.huatuo.xyz/eip-2124/
lang: en
tldr: Defines the fork ID, a 4-byte checksum of the genesis and past forks plus the next fork block, so nodes can tell in one exchange whether a peer is on a compatible chain.
tags: [networking, p2p, devp2p, forks, discovery]
---

# EIP-2124: Fork identifier for chain compatibility checks

> Currently nodes in the Ethereum network try to find each other by establishing random connections to remote machines "looking" like an Ethereum node (public networks, private networks, test networks, etc), hoping that they found a useful peer (same genesis, same forks).

**TL;DR:** Defines the fork ID, a 4-byte checksum of the genesis and past forks plus the next fork block, so nodes can tell in one exchange whether a peer is on a compatible chain.

## What problem does it solve?

Many public and private Ethereum networks share the same peer-to-peer infrastructure. Before this EIP, the only way to know if a peer was on your chain was to open a TCP connection, do the RLPx crypto handshake and then the `eth` handshake. That is expensive, and it still could not tell Ethereum from Ethereum Classic, which share a genesis.

There is a second problem: after a hard fork, nodes that did not upgrade keep hanging on to good peers, wasting slots and bandwidth. On testnets they could linger for months.

EIP-2124 defines a compact **fork identifier** that summarizes a chain's genesis and fork history, plus rules for deciding from it whether to connect.

## How it works

Each node computes two values:

- **`FORK_HASH`**: IEEE CRC32 of the genesis hash followed by every fork block number that has already passed, each as a big-endian `uint64`, in ascending order. Forks at the same block are counted once; rules active from genesis do not count as forks.
- **`FORK_NEXT`**: the block number of the next known fork, or `0` if none.

The fork ID is `RLP([FORK_HASH, FORK_NEXT])`. It is cross-validated, not just compared:

1. **Same hash:** connect, unless the remote announces a next fork that we have already passed locally.
2. **Remote hash is one of our earlier states** and its next fork matches our next fork after that: connect (remote is syncing).
3. **Remote hash is a later state** we can reach with our known future forks: connect (we are syncing).
4. Otherwise **reject**.

CRC32 is used because it fits 4 bytes, uses all input, and is available everywhere. A cryptographic hash would add nothing since peers can lie anyway. The small size matters because node records ([EIP-778](/eip-778/)) have only 300 bytes in total.

## Sample code

Computing mainnet's early fork hashes in Python, matching the spec's values:

```python
import struct, zlib

genesis = bytes.fromhex(
    "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3")

h = zlib.crc32(genesis)
print(hex(h))                                   # 0xfc64ec04  (Frontier)
h = zlib.crc32(struct.pack(">Q", 1_150_000), h)
print(hex(h))                                   # 0x97c2c34c  (Homestead)
h = zlib.crc32(struct.pack(">Q", 1_920_000), h)
print(hex(h))                                   # 0x91d1f948  (DAO fork)
```

RLP encoding examples from the spec: `{Hash: 0, Next: 0}` encodes to `c6840000000080`, and `{Hash: 0xdeadbeef, Next: 0xbaddcafe}` to `ca84deadbeef84baddcafe`.

## Things to know

- **Status: Final.** It is used in the `eth/64` handshake ([EIP-2364](/eip-2364/)) and later `eth` protocol versions, and in discovery records. The reference implementation is go-ethereum's `core/forkid` package.
- The spec deliberately does not handle clean separation of three-way splits at the same block.
- Peers advertise only one future fork, because future forks can be postponed; hashing them in would split the network prematurely.
- Since the Shanghai upgrade, forks are scheduled by timestamp rather than block number. [EIP-6122](/eip-6122/) extends the fork ID to handle timestamp-based forks.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2124
