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
hash- CRC32 checksum of genesis hash + fork block numbersnext- Block number of next known fork (0 if no upcoming forks)
Creating ForkId
from
Create from hash and next block number.hashmust be exactly 4 bytesnextis 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:- Identical - Same hash and next block
- Remote has no future forks - Same hash, remote next is 0
- Local has no future forks - Same hash, local next is 0
- Remote is ahead - Different hash but remote next >= local next
Ethereum Mainnet Fork History
DevP2P Handshake
ForkId is exchanged during the DevP2Pstatus message:

