Skip to content

Commit d9b0b8d

Browse files
anvacarurv-jenkins
authored andcommitted
EIP 2200 - SSTORE/SLOAD net-metered stores (#594)
* evm.md: fail the current frame if gas <= gas stipend * evm.md: fix typo * evm.md: use Gcallstipend, add Ghasdirtysstore * cleanup eip 2200 * evm: formatting * evm: rename Gsstorestipend => Ghassstorestipend * tests/{failing,slow}.{llvm,ocaml}: update slow/failing lists * tests/{failing,slow}.ocaml: remove uneeded files
1 parent b6c389e commit d9b0b8d

File tree

5 files changed

+32
-1263
lines changed

5 files changed

+32
-1263
lines changed

evm.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,14 +1914,21 @@ The intrinsic gas calculation mirrors the style of the YellowPaper (appendix H).
19141914
// ----------------------------------------------------
19151915
rule <k> #gasExec(SCHED, SSTORE INDEX NEW) => Csstore(SCHED, NEW, #lookup(STORAGE, INDEX), #lookup(ORIGSTORAGE, INDEX)) ... </k>
19161916
<id> ACCT </id>
1917+
<gas> GAVAIL </gas>
19171918
<account>
19181919
<acctID> ACCT </acctID>
19191920
<storage> STORAGE </storage>
19201921
<origStorage> ORIGSTORAGE </origStorage>
19211922
...
19221923
</account>
19231924
<refund> R => R +Int Rsstore(SCHED, NEW, #lookup(STORAGE, INDEX), #lookup(ORIGSTORAGE, INDEX)) </refund>
1924-
<schedule> SCHED </schedule>
1925+
requires notBool Ghassstorestipend << SCHED >>
1926+
orBool notBool GAVAIL <=Int Gcallstipend < SCHED >
1927+
1928+
rule <k> #gasExec(SCHED, SSTORE _ _ ) => #end EVMC_OUT_OF_GAS ... </k>
1929+
<gas> GAVAIL </gas>
1930+
requires Ghassstorestipend << SCHED >>
1931+
andBool GAVAIL <=Int Gcallstipend <ISTANBUL>
19251932
19261933
rule <k> #gasExec(SCHED, EXP W0 0) => Gexp < SCHED > ... </k>
19271934
rule <k> #gasExec(SCHED, EXP W0 W1) => Gexp < SCHED > +Int (Gexpbyte < SCHED > *Int (1 +Int (log256Int(W1)))) ... </k> requires W1 =/=Int 0
@@ -2254,10 +2261,11 @@ A `ScheduleFlag` is a boolean determined by the fee schedule; applying a `Schedu
22542261
syntax Bool ::= ScheduleFlag "<<" Schedule ">>" [function, functional]
22552262
// ----------------------------------------------------------------------
22562263
2257-
syntax ScheduleFlag ::= "Gselfdestructnewaccount" | "Gstaticcalldepth" | "Gemptyisnonexistent" | "Gzerovaluenewaccountgas"
2258-
| "Ghasrevert" | "Ghasreturndata" | "Ghasstaticcall" | "Ghasshift"
2259-
| "Ghasdirtysstore" | "Ghascreate2" | "Ghasextcodehash" | "Ghasselfbalance"
2260-
// ------------------------------------------------------------------------------------------------------------------
2264+
syntax ScheduleFlag ::= "Gselfdestructnewaccount" | "Gstaticcalldepth" | "Gemptyisnonexistent" | "Gzerovaluenewaccountgas"
2265+
| "Ghasrevert" | "Ghasreturndata" | "Ghasstaticcall" | "Ghasshift"
2266+
| "Ghasdirtysstore" | "Ghascreate2" | "Ghasextcodehash" | "Ghasselfbalance"
2267+
| "Gsstorestipend" | "Ghassstorestipend"
2268+
// -----------------------------------------------------------------------
22612269
```
22622270

22632271
### Schedule Constants
@@ -2347,6 +2355,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
23472355
rule Ghasstaticcall << DEFAULT >> => false
23482356
rule Ghasshift << DEFAULT >> => false
23492357
rule Ghasdirtysstore << DEFAULT >> => false
2358+
rule Ghassstorestipend << DEFAULT >> => false
23502359
rule Ghascreate2 << DEFAULT >> => false
23512360
rule Ghasextcodehash << DEFAULT >> => false
23522361
rule Ghasselfbalance << DEFAULT >> => false
@@ -2479,9 +2488,14 @@ A `ScheduleConst` is a constant determined by the fee schedule.
24792488
orBool SCHEDCONST ==K Gbalance
24802489
)
24812490
2482-
rule Ghasselfbalance << ISTANBUL >> => true
2483-
rule SCHEDFLAG << ISTANBUL >> => SCHEDFLAG << PETERSBURG >>
2484-
requires notBool ( SCHEDFLAG ==K Ghasselfbalance )
2491+
rule Ghasselfbalance << ISTANBUL >> => true
2492+
rule Ghasdirtysstore << ISTANBUL >> => true
2493+
rule Ghassstorestipend << ISTANBUL >> => true
2494+
rule SCHEDFLAG << ISTANBUL >> => SCHEDFLAG << PETERSBURG >>
2495+
requires notBool ( SCHEDFLAG ==K Ghasselfbalance
2496+
orBool SCHEDFLAG ==K Ghasdirtysstore
2497+
orBool SCHEDFLAG ==K Ghassstorestipend
2498+
)
24852499
```
24862500

24872501
EVM Program Representations

0 commit comments

Comments
 (0)