Skip to content

Commit b6c389e

Browse files
ehildenbrv-jenkins
authored andcommitted
EIP 1884 - SELFBALANCE and repricing (#608)
* evm.md: EIP-1884: Repricing for trie-size-dependent opcodes * evm: update Fee Schedule documentation * tests/failing.{llvm,ocaml}: remove now passing tests
1 parent a694c56 commit b6c389e

File tree

3 files changed

+35
-258
lines changed

3 files changed

+35
-258
lines changed

evm.md

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -998,12 +998,19 @@ These operators make queries about the current execution state.
998998
rule <k> NUMBER => NUMB ~> #push ... </k> <number> NUMB </number>
999999
rule <k> DIFFICULTY => DIFF ~> #push ... </k> <difficulty> DIFF </difficulty>
10001000
1001-
syntax NullStackOp ::= "ADDRESS" | "ORIGIN" | "CALLER" | "CALLVALUE"
1002-
// --------------------------------------------------------------------
1003-
rule <k> ADDRESS => ACCT ~> #push ... </k> <id> ACCT </id>
1004-
rule <k> ORIGIN => ORG ~> #push ... </k> <origin> ORG </origin>
1005-
rule <k> CALLER => CL ~> #push ... </k> <caller> CL </caller>
1006-
rule <k> CALLVALUE => CV ~> #push ... </k> <callValue> CV </callValue>
1001+
syntax NullStackOp ::= "ADDRESS" | "ORIGIN" | "CALLER" | "CALLVALUE" | "SELFBALANCE"
1002+
// ------------------------------------------------------------------------------------
1003+
rule <k> ADDRESS => ACCT ~> #push ... </k> <id> ACCT </id>
1004+
rule <k> ORIGIN => ORG ~> #push ... </k> <origin> ORG </origin>
1005+
rule <k> CALLER => CL ~> #push ... </k> <caller> CL </caller>
1006+
rule <k> CALLVALUE => CV ~> #push ... </k> <callValue> CV </callValue>
1007+
rule <k> SELFBALANCE => BAL ~> #push ... </k>
1008+
<id> ACCT </id>
1009+
<account>
1010+
<acctID> ACCT </acctID>
1011+
<balance> BAL </balance>
1012+
...
1013+
</account>
10071014
10081015
syntax NullStackOp ::= "MSIZE" | "CODESIZE"
10091016
// -------------------------------------------
@@ -2039,6 +2046,7 @@ The intrinsic gas calculation mirrors the style of the YellowPaper (appendix H).
20392046
rule <k> #gasExec(SCHED, MOD _ _) => Glow < SCHED > ... </k>
20402047
rule <k> #gasExec(SCHED, SMOD _ _) => Glow < SCHED > ... </k>
20412048
rule <k> #gasExec(SCHED, SIGNEXTEND _ _) => Glow < SCHED > ... </k>
2049+
rule <k> #gasExec(SCHED, SELFBALANCE) => Glow < SCHED > ... </k>
20422050
20432051
// Wmid
20442052
rule <k> #gasExec(SCHED, ADDMOD _ _ _) => Gmid < SCHED > ... </k>
@@ -2229,15 +2237,16 @@ There are several helpers for calculating gas (most of them also specified in th
22292237
rule #adjustedExpLength(N) => 1 +Int #adjustedExpLength(N /Int 2) requires N >Int 1
22302238
```
22312239

2232-
Fee Schedule from C++ Implementation
2233-
------------------------------------
2240+
Fee Schedule
2241+
------------
22342242

2243+
The `Schedule` determines the constants/modes of operation for each hard fork.
2244+
There are `ScheduleFlag`s and `ScheduleConstant`s.
22352245

2236-
### From the C++ Implementation
2246+
- A `ScheduleFlag` is a boolean value determining whether a certain feature is turned on.
2247+
- A `ScheduleConst` is an `Int` parameter which is used during EVM execution.
22372248

2238-
The [C++ Implementation of EVM](https://github.com/ethereum/cpp-ethereum) specifies several different "profiles" for how the VM works.
2239-
Here we provide each protocol from the C++ implementation, as the YellowPaper does not contain all the different profiles.
2240-
Specify which profile by passing in the argument `-cSCHEDULE=<FEE_SCHEDULE>` when calling `krun` (the available `<FEE_SCHEDULE>` are supplied here).
2249+
### Schedule Flags
22412250

22422251
A `ScheduleFlag` is a boolean determined by the fee schedule; applying a `ScheduleFlag` to a `Schedule` yields whether the flag is set or not.
22432252

@@ -2247,8 +2256,8 @@ A `ScheduleFlag` is a boolean determined by the fee schedule; applying a `Schedu
22472256
22482257
syntax ScheduleFlag ::= "Gselfdestructnewaccount" | "Gstaticcalldepth" | "Gemptyisnonexistent" | "Gzerovaluenewaccountgas"
22492258
| "Ghasrevert" | "Ghasreturndata" | "Ghasstaticcall" | "Ghasshift"
2250-
| "Ghasdirtysstore" | "Ghascreate2" | "Ghasextcodehash"
2251-
// ------------------------------------------------------------------------------------------
2259+
| "Ghasdirtysstore" | "Ghascreate2" | "Ghasextcodehash" | "Ghasselfbalance"
2260+
// ------------------------------------------------------------------------------------------------------------------
22522261
```
22532262

22542263
### Schedule Constants
@@ -2340,6 +2349,7 @@ A `ScheduleConst` is a constant determined by the fee schedule.
23402349
rule Ghasdirtysstore << DEFAULT >> => false
23412350
rule Ghascreate2 << DEFAULT >> => false
23422351
rule Ghasextcodehash << DEFAULT >> => false
2352+
rule Ghasselfbalance << DEFAULT >> => false
23432353
```
23442354

23452355
### Frontier Schedule
@@ -2457,15 +2467,21 @@ A `ScheduleConst` is a constant determined by the fee schedule.
24572467
rule Gecpairconst < ISTANBUL > => 45000
24582468
rule Gecpaircoeff < ISTANBUL > => 34000
24592469
rule Gtxdatanonzero < ISTANBUL > => 16
2470+
rule Gsload < ISTANBUL > => 800
2471+
rule Gbalance < ISTANBUL > => 700
24602472
rule SCHEDCONST < ISTANBUL > => SCHEDCONST < PETERSBURG >
24612473
requires notBool ( SCHEDCONST ==K Gecadd
24622474
orBool SCHEDCONST ==K Gecmul
24632475
orBool SCHEDCONST ==K Gecpairconst
24642476
orBool SCHEDCONST ==K Gecpaircoeff
24652477
orBool SCHEDCONST ==K Gtxdatanonzero
2478+
orBool SCHEDCONST ==K Gsload
2479+
orBool SCHEDCONST ==K Gbalance
24662480
)
24672481
2468-
rule SCHEDFLAG << ISTANBUL >> => SCHEDFLAG << PETERSBURG >>
2482+
rule Ghasselfbalance << ISTANBUL >> => true
2483+
rule SCHEDFLAG << ISTANBUL >> => SCHEDFLAG << PETERSBURG >>
2484+
requires notBool ( SCHEDFLAG ==K Ghasselfbalance )
24692485
```
24702486

24712487
EVM Program Representations
@@ -2532,15 +2548,16 @@ After interpreting the strings representing programs as a `WordStack`, it should
25322548
rule #dasmOpCode( 58, _ ) => GASPRICE
25332549
rule #dasmOpCode( 59, _ ) => EXTCODESIZE
25342550
rule #dasmOpCode( 60, _ ) => EXTCODECOPY
2535-
rule #dasmOpCode( 61, SCHED ) => RETURNDATASIZE requires Ghasreturndata << SCHED >>
2536-
rule #dasmOpCode( 62, SCHED ) => RETURNDATACOPY requires Ghasreturndata << SCHED >>
2537-
rule #dasmOpCode( 63, SCHED ) => EXTCODEHASH requires Ghasextcodehash << SCHED >>
2551+
rule #dasmOpCode( 61, SCHED ) => RETURNDATASIZE requires Ghasreturndata << SCHED >>
2552+
rule #dasmOpCode( 62, SCHED ) => RETURNDATACOPY requires Ghasreturndata << SCHED >>
2553+
rule #dasmOpCode( 63, SCHED ) => EXTCODEHASH requires Ghasextcodehash << SCHED >>
25382554
rule #dasmOpCode( 64, _ ) => BLOCKHASH
25392555
rule #dasmOpCode( 65, _ ) => COINBASE
25402556
rule #dasmOpCode( 66, _ ) => TIMESTAMP
25412557
rule #dasmOpCode( 67, _ ) => NUMBER
25422558
rule #dasmOpCode( 68, _ ) => DIFFICULTY
25432559
rule #dasmOpCode( 69, _ ) => GASLIMIT
2560+
rule #dasmOpCode( 71, SCHED ) => SELFBALANCE requires Ghasselfbalance << SCHED >>
25442561
rule #dasmOpCode( 80, _ ) => POP
25452562
rule #dasmOpCode( 81, _ ) => MLOAD
25462563
rule #dasmOpCode( 82, _ ) => MSTORE

0 commit comments

Comments
 (0)