Skip to main content

Overview

ForkId implements EIP-2124 fork identification for DevP2P network validation. It helps peers determine if they’re on compatible forks before exchanging data.

Type Definition

Fields:
  • hash - CRC32 checksum of genesis hash + fork block numbers
  • next - Block number of next known fork (0 if no upcoming forks)

Creating ForkId

from

Create from hash and next block number.
Validation:
  • hash must be exactly 4 bytes
  • next is required (use 0 for no upcoming forks)

Methods

toBytes

Encode to 12-byte binary format for DevP2P handshake.

matches

Check if two ForkIds are compatible per EIP-2124.

Compatibility Rules

Two ForkIds are compatible if:
  1. Identical - Same hash and next block
  2. Remote has no future forks - Same hash, remote next is 0
  3. Local has no future forks - Same hash, local next is 0
  4. Remote is ahead - Different hash but remote next >= local next

Ethereum Mainnet Fork History

DevP2P Handshake

ForkId is exchanged during the DevP2P status message:

See Also