EIP-210 Blockhash reconstruction (Blockhash refactoring)

No call decision · EVM & execution · EIP status Stagnant · created 2017-02-10

Changes how the BLOCKHASH operation is handled, moving it from a mechanism where clients separately remember block hashes to a dedicated contract stored in state, simplifying implementation and greatly extending the range of past blocks that can be queried.

Why it is needed

Handling the BLOCKHASH operation required clients to separately remember the header hashes of recent blocks. This information does not belong to the Merkle state tree, yet it was treated as 'implied state' needed for protocol behavior, which complicated client implementations and made the protocol specification messier. In addition, the traditional approach limited the range of past blocks that could be queried, making it hard to construct proofs referencing distant past blocks, which led to inefficiency when light clients performed their initial sync. This EIP aims to solve both problems at once by moving block hashes entirely into the storage of a dedicated contract stored in state.

What changes

Today

After EIP-210

Who is affected

In depth

Background and purpose of the proposal

Handling the BLOCKHASH operation required clients to separately track block header history, which was treated as 'implied state' not belonging to the state tree, complicating both the protocol specification and client implementations. This EIP aims to eliminate this complexity and make the protocol 'purer' by moving block hashes into the storage of a dedicated contract stored in state. As a side benefit, it greatly extends the range of blocks that can be queried, creating direct links between distant blocks and making light clients' initial sync far more efficient.

Parameters and special addresses

CONSTANTINOPLE_FORK_BLKNUM is TBD (undetermined), indicating the block number at which this EIP activates. SUPER_USER is 2**160-2 (0xff..fe in hex), a special address representing a protocol-only sender rather than a normal account. BLOCKHASH_CONTRACT_ADDR is 0xf0 (240), the address of the dedicated contract where block hashes are stored.

Deploying the contract at the fork

At the block where block.number equals CONSTANTINOPLE_FORK_BLKNUM, before processing transactions, the protocol itself sets the code at address 0xf0 to BLOCKHASH_CONTRACT_CODE. This is code injected at the protocol level at the fork, not through an ordinary deployment transaction.

Calling to record the hash at every block

After CONSTANTINOPLE_FORK_BLKNUM, in every block, before transactions are processed, a call is executed with SENDER=SUPER_USER, GAS=1000000, TO=BLOCKHASH_CONTRACT_ADDR, VALUE=0, DATA=that block's prevhash (32 bytes). The contract code only performs the recording logic when msg.sender is SUPER_USER, starting from block.number-1 and storing the remainder of division by 256 at position offset+remainder. If the remainder is nonzero, it stops; if zero, it moves to the quotient and repeats, increasing offset by 256 each time. This staged storage approach efficiently retains even distant past blocks.

Change to the BLOCKHASH operator's behavior

From CONSTANTINOPLE_FORK_BLKNUM + 256 onward, the BLOCKHASH opcode no longer has the client look up header history directly; instead it returns the result of a call (not a transaction) to BLOCKHASH_CONTRACT_ADDR with the calling account as SENDER and the block number to query (a 32-byte integer) as DATA. The contract checks whether the given block number is less than the current block, then walks back through the stored levels to find and return the hash, returning 0 if the conditions are not met.

Gas cost changes

After CONSTANTINOPLE_FORK_BLKNUM, the gas cost of BLOCKHASH rises from 20 to 800, because looking up the hash now goes through a contract call and storage lookup instead of a simple memory access, increasing the processing cost.

Current status

This EIP's status is Stagnant and the CONSTANTINOPLE_FORK_BLKNUM value remains TBD, so it has never been included or activated in the actual Constantinople hard fork or any later fork. No separate fork-inclusion decision has been confirmed in call records either.

Original EIP · ← EIPs