Skip to content

Commit a11f28d

Browse files
authored
EIP-2935: Serve historical block hashes from state (#2749)
* fix typos in Makefile * define Prague schedule * update execution-spec-tests/failing.llvm * set Prague as the default schedule for testing * update expected output * implement eip-2935 * Update cli.py * Update test_gst_to_kore.py * update expected output * update expected output * fix typos
1 parent 12289cb commit a11f28d

File tree

3 files changed

+115
-1162
lines changed

3 files changed

+115
-1162
lines changed

kevm-pyk/src/kevm_pyk/kproj/evm-semantics/evm.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ Terminates validation successfully when all conditions are met or when blob vali
835835
```k
836836
syntax EthereumCommand ::= "#startBlock"
837837
// ----------------------------------------
838-
rule <k> #startBlock => #validateBlockBlobs 0 TXS ~> #executeBeaconRoots ... </k>
838+
rule <k> #startBlock => #validateBlockBlobs 0 TXS ~> #executeBeaconRoots ~> #executeBlockHashHistory ... </k>
839839
<gasUsed> _ => 0 </gasUsed>
840840
<blobGasUsed> _ => 0 </blobGasUsed>
841841
<log> _ => .List </log>
@@ -939,6 +939,30 @@ Read more about EIP-4788 here [https://eips.ethereum.org/EIPS/eip-4788](https://
939939
rule <k> #executeBeaconRoots => .K ... </k> [owise]
940940
```
941941

942+
If `block.timestamp >= PRAGUE_FORK_TIMESTAMP`:
943+
Before executing any transaction, the `HISTORY_STORAGE_ADDRESS` (`0x0000F90827F1C53a10cb7A02335B175320002935`) storage is modified as following:
944+
- Set the storage value at `(block.number-1) % HISTORY_SERVE_WINDOW` to be ` block.parent.hash`
945+
where `HISTORY_SERVE_WINDOW == 8191`.
946+
947+
Read more about EIP-2935 here [https://eips.ethereum.org/EIPS/eip-2935](https://eips.ethereum.org/EIPS/eip-2935).
948+
949+
```k
950+
syntax EthereumCommand ::= "#executeBlockHashHistory" [symbol(#executeBlockHashHistory)]
951+
// ----------------------------------------------------------------------------------------
952+
rule <k> #executeBlockHashHistory => .K ... </k>
953+
<schedule> SCHED </schedule>
954+
<previousHash> HP </previousHash>
955+
<number> BN </number>
956+
<account>
957+
<acctID> 21693734551179282564423033930679318143314229 </acctID>
958+
<storage> M:Map => M [((BN -Int 1) modInt 8191) <- HP] </storage>
959+
...
960+
</account>
961+
requires Ghashistory << SCHED >>
962+
963+
rule <k> #executeBlockHashHistory => .K ... </k> [owise]
964+
```
965+
942966
EVM Programs
943967
============
944968

kevm-pyk/src/kevm_pyk/kproj/evm-semantics/schedule.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ module SCHEDULE
3030
| "Ghasrejectedfirstbyte" | "Ghasprevrandao" | "Ghasmaxinitcodesize" | "Ghaspushzero"
3131
| "Ghaswarmcoinbase" | "Ghaswithdrawals" | "Ghastransient" | "Ghasmcopy"
3232
| "Ghasbeaconroot" | "Ghaseip6780" | "Ghasblobbasefee" | "Ghasblobhash"
33-
| "Ghasrequests"
34-
// --------------------------------------
33+
| "Ghasrequests" | "Ghashistory"
34+
// -----------------------------------------------------------------
3535
```
3636

3737
### Schedule Constants
@@ -163,6 +163,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
163163
rule [GhasbeaconrootDefault]: Ghasbeaconroot << DEFAULT >> => false
164164
rule [Ghaseip6780Default]: Ghaseip6780 << DEFAULT >> => false
165165
rule [GhasblobhashDefault]: Ghasblobhash << DEFAULT >> => false
166+
rule [GhashistoryDefault]: Ghashistory << DEFAULT >> => false
166167
rule [GhasrequestsDefault]: Ghasrequests << DEFAULT >> => false
167168
```
168169

@@ -442,8 +443,10 @@ A `ScheduleConst` is a constant determined by the fee schedule.
442443
rule [SCHEDCONSTPrague]: SCHEDCONST < PRAGUE > => SCHEDCONST < CANCUN >
443444
444445
rule [GhasrequestsPrague]: Ghasrequests << PRAGUE >> => true
446+
rule [GhashistoryPrague]: Ghashistory << PRAGUE >> => true
445447
rule [SCHEDFLAGPrague]: SCHEDFLAG << PRAGUE >> => SCHEDFLAG << CANCUN >>
446-
requires notBool ( SCHEDFLAG ==K Ghasrequests )
448+
requires notBool ( SCHEDFLAG ==K Ghasrequests
449+
orBool SCHEDFLAG ==K Ghashistory )
447450
```
448451

449452
```k

0 commit comments

Comments
 (0)