Skip to main content
EIP-2935 provides standardized access to historical block hashes through contract storage, enabling smart contracts to reliably access block hashes beyond the traditional 256-block limit.

Overview

What is EIP-2935?

EIP-2935 introduces a system contract that stores block hashes in contract storage, making them accessible to smart contracts for extended periods. This enables protocols requiring verifiable randomness, block-based logic, or historical verification.

Key Benefits

  • Extended History: Access up to 8192 block hashes (configurable)
  • Reliable Access: No longer limited to recent 256 blocks
  • Smart Contract Compatibility: Works with existing BLOCKHASH opcode
  • Verifiable Randomness: Enable protocols requiring historical entropy

Implementation Details

Block Hash Storage Mechanism

Cosmos EVM implements EIP-2935 by storing block hashes in a special system contract storage:

Configuration Parameter

The history_serve_window parameter controls how many historical block hashes are stored:
Parameter Details:
  • Type: uint64
  • Default: 8192 (source)
  • Range: Must be > 0, recommended ≤ 8192
  • Storage Impact: Higher values increase storage requirements linearly

Comparison with Ethereum

Similarities

  • Same storage contract address: 0x0aae40965e6800cd9b1f4b05ff21581047e3f91e
  • Same storage layout: Ring buffer using modulo arithmetic
  • Same opcode behavior: BLOCKHASH queries contract storage
  • Same gas costs: Standard SLOAD costs apply (2100 gas for cold access)

Differences

  • Configurable window: Cosmos EVM allows custom history_serve_window (vs fixed 8192 in Ethereum)
  • Instant activation: Available immediately on upgrade (not block-based activation)
  • No fork logic: Uses consensus parameter instead of fork activation
  • Performance tuning: Can be optimized per chain requirements
  • Traditional 256-block limit: Ethereum’s original BLOCKHASH opcode only provided access to the most recent 256 blocks; EIP-2935 extends this significantly

Usage in Smart Contracts

Basic Block Hash Access

Basic Block Hash Access

Verifiable Randomness Protocol

Verifiable Randomness Protocol

Block-Based State Transitions

Block-Based State Transitions

Configuration Examples

High Compatibility (Default)

Use Case: Full EIP-2935 compatibility for protocols requiring extended block history Storage: ~256KB additional storage (32 bytes × 8192 blocks) Performance: Standard performance, suitable for most chains

Performance Optimized

Use Case: Resource-constrained nodes or chains prioritizing performance Storage: ~32KB additional storage (32 bytes × 1024 blocks) Trade-off: Shorter historical access but better performance

Extended History

Use Case: Protocols requiring very long historical access Storage: ~512KB additional storage (32 bytes × 16384 blocks) Performance: Higher storage overhead but maximum compatibility

Technical Implementation

BLOCKHASH Opcode Behavior

Before EIP-2935:
After EIP-2935:

Storage Layout

The EIP-2935 system contract uses a simple storage mapping:
Example with history_serve_window = 8192:

Integration with EVM

The implementation integrates seamlessly with the EVM:
  1. Block Processing: Each new block stores its hash in the system contract
  2. BLOCKHASH Opcode: Modified to query contract storage for historical hashes
  3. Gas Costs: Uses standard SLOAD gas costs for historical access
  4. Compatibility: Maintains full backward compatibility

Comparison with Ethereum

Similarities

  • Same storage contract address: 0x0aae40965e6800cd9b1f4b05ff21581047e3f91e
  • Same storage layout: Ring buffer using modulo arithmetic
  • Same opcode behavior: BLOCKHASH queries contract storage
  • Same gas costs: Standard SLOAD costs apply

Differences

  • Configurable window: Cosmos EVM allows custom history_serve_window
  • Instant activation: Available immediately on upgrade (not block-based)
  • No fork logic: Uses consensus parameter instead of fork activation
  • Performance tuning: Can be optimized per chain requirements

References