Skip to content

EIP-2935: Serve historical block hashes from state #2749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 8, 2025
26 changes: 25 additions & 1 deletion kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ Terminates validation successfully when all conditions are met or when blob vali
```k
syntax EthereumCommand ::= "#startBlock"
// ----------------------------------------
rule <k> #startBlock => #validateBlockBlobs 0 TXS ~> #executeBeaconRoots ... </k>
rule <k> #startBlock => #validateBlockBlobs 0 TXS ~> #executeBeaconRoots ~> #executeBlockHashHistory ... </k>
<gasUsed> _ => 0 </gasUsed>
<blobGasUsed> _ => 0 </blobGasUsed>
<log> _ => .List </log>
Expand Down Expand Up @@ -939,6 +939,30 @@ Read more about EIP-4788 here [https://eips.ethereum.org/EIPS/eip-4788](https://
rule <k> #executeBeaconRoots => .K ... </k> [owise]
```

If `block.timestamp >= PRAGUE_FORK_TIMESTAMP`:
Before executing any transaction, the `HISTORY_STORAGE_ADDRESS` (`0x0000F90827F1C53a10cb7A02335B175320002935`) storage is modified as following:
- Set the storage value at `(block.number-1) % HISTORY_SERVE_WINDOW` to be ` block.parent.hash`
where `HISTORY_SERVE_WINDOW == 8191`.

Read more about EIP-2935 here [https://eips.ethereum.org/EIPS/eip-2935](https://eips.ethereum.org/EIPS/eip-2935).

```k
syntax EthereumCommand ::= "#executeBlockHashHistory" [symbol(#executeBlockHashHistory)]
// ----------------------------------------------------------------------------------------
rule <k> #executeBlockHashHistory => .K ... </k>
<schedule> SCHED </schedule>
<previousHash> HP </previousHash>
<number> BN </number>
<account>
<acctID> 21693734551179282564423033930679318143314229 </acctID>
<storage> M:Map => M [((BN -Int 1) modInt 8191) <- HP] </storage>
...
</account>
requires Ghashistory << SCHED >>

rule <k> #executeBlockHashHistory => .K ... </k> [owise]
```

EVM Programs
============

Expand Down
9 changes: 6 additions & 3 deletions kevm-pyk/src/kevm_pyk/kproj/evm-semantics/schedule.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ module SCHEDULE
| "Ghasrejectedfirstbyte" | "Ghasprevrandao" | "Ghasmaxinitcodesize" | "Ghaspushzero"
| "Ghaswarmcoinbase" | "Ghaswithdrawals" | "Ghastransient" | "Ghasmcopy"
| "Ghasbeaconroot" | "Ghaseip6780" | "Ghasblobbasefee" | "Ghasblobhash"
| "Ghasrequests"
// --------------------------------------
| "Ghasrequests" | "Ghashistory"
// -----------------------------------------------------------------
```

### Schedule Constants
Expand Down Expand Up @@ -163,6 +163,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
rule [GhasbeaconrootDefault]: Ghasbeaconroot << DEFAULT >> => false
rule [Ghaseip6780Default]: Ghaseip6780 << DEFAULT >> => false
rule [GhasblobhashDefault]: Ghasblobhash << DEFAULT >> => false
rule [GhashistoryDefault]: Ghashistory << DEFAULT >> => false
rule [GhasrequestsDefault]: Ghasrequests << DEFAULT >> => false
```

Expand Down Expand Up @@ -442,8 +443,10 @@ A `ScheduleConst` is a constant determined by the fee schedule.
rule [SCHEDCONSTPrague]: SCHEDCONST < PRAGUE > => SCHEDCONST < CANCUN >

rule [GhasrequestsPrague]: Ghasrequests << PRAGUE >> => true
rule [GhashistoryPrague]: Ghashistory << PRAGUE >> => true
rule [SCHEDFLAGPrague]: SCHEDFLAG << PRAGUE >> => SCHEDFLAG << CANCUN >>
requires notBool ( SCHEDFLAG ==K Ghasrequests )
requires notBool ( SCHEDFLAG ==K Ghasrequests
orBool SCHEDFLAG ==K Ghashistory )
```

```k
Expand Down
Loading