Skip to content

Evm block hash history contract#5426

Open
mpapierski wants to merge 2 commits into
casper-network:feat-evmfrom
mpapierski:evm-block-hash-history-contract
Open

Evm block hash history contract#5426
mpapierski wants to merge 2 commits into
casper-network:feat-evmfrom
mpapierski:evm-block-hash-history-contract

Conversation

@mpapierski

Copy link
Copy Markdown
Collaborator

Summary

This PR adds EIP-2935 block hash history support for Prague-mode Casper EVM.

It installs the standard EIP-2935 block-hash-history predeploy and updates it once per block with the parent Casper block hash. This gives EVM contracts the expected Prague system-contract interface while keeping the existing BLOCKHASH opcode behavior unchanged.

The important Casper-specific semantic is:

stored block hash := parent Casper block hash

So the interface matches EIP-2935, but the stored values are Casper block hashes, not Ethereum L1 execution block hashes.

What Changed

  • Added EIP-2935 constants under casper_types::evm:

    • standard predeploy address
    • exact 83-byte runtime bytecode
    • code-hash helper
  • Generalized Prague EVM predeploy setup so genesis and protocol upgrade install both:

  • Preserved the existing idempotent predeploy behavior:

    • create missing entries
    • repair missing or empty code hashes
    • repair missing bytecode
    • reject conflicting non-empty code or bytecode
  • Added a pre-block EIP-2935 system call:

    • skipped at block height 0
    • runs after the EIP-4788 update
    • runs before user transactions
    • fails block execution if the system call does not succeed
  • Updated EVM documentation to mark EIP-2935 as implemented and clarify that BLOCKHASH remains separate.

Semantics

For each non-genesis Prague EVM block, Casper calls the EIP-2935 contract with the parent Casper block hash as calldata. The contract stores that hash in the standard 8191-slot history ring buffer.

Contracts can then call the EIP-2935 predeploy at:

0x0000F90827F1C53a10cb7A02335B175320002935

to retrieve recent stored Casper block hashes through the standard EIP-2935 lookup interface.

This does not change the BLOCKHASH opcode. BLOCKHASH still uses Casper’s existing node-supplied block hash provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant