Skip to content

Commit 124ab42

Browse files
author
Everett Hildenbrandt
committed
evm, driver, analysis: #end now generates an exception, and sets the statusCode cell
1 parent 3c08079 commit 124ab42

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ We'll need to make summaries of the state which collect information about how mu
4343
4444
syntax KItem ::= "#endSummary"
4545
// ------------------------------
46-
rule <k> (#end => .) ~> #endSummary ... </k>
46+
rule <statusCode> EVM_SUCCESS </statusCode> <k> (#exception => .) ~> #endSummary ... </k>
4747
rule <k> #endSummary => . ... </k> <pc> PCOUNT </pc> <gas> GAVAIL </gas> <memoryUsed> MEMUSED </memoryUsed>
4848
<analysis> ... "blocks" |-> (ListItem({ PCOUNT1 | GAVAIL1 | MEMUSED1 } => { PCOUNT1 ==> PCOUNT | GAVAIL1 -Int GAVAIL | MEMUSED -Int MEMUSED1 }) REST) ... </analysis>
4949
```

driver.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
8383
8484
syntax EthereumCommand ::= "flush"
8585
// ----------------------------------
86-
rule <mode> EXECMODE </mode> <k> #end ~> flush => #finalizeTx(EXECMODE ==K VMTESTS) ... </k>
86+
rule <mode> EXECMODE </mode> <statusCode> EVM_SUCCESS </statusCode> <k> #exception ~> flush => #finalizeTx(EXECMODE ==K VMTESTS) ... </k>
8787
rule <mode> EXECMODE </mode> <statusCode> _:ExceptionalStatusCode </statusCode> <k> #exception ~> flush => #finalizeTx(EXECMODE ==K VMTESTS) ~> #exception ... </k>
8888
```
8989

@@ -181,7 +181,8 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
181181
rule <statusCode> _:ExceptionalStatusCode </statusCode> <k> #exception ~> #finishTx => #popCallStack ~> #popWorldState ... </k>
182182
rule <k> #revert ~> #finishTx => #popCallStack ~> #popWorldState ~> #refund GAVAIL ... </k> <gas> GAVAIL </gas>
183183
184-
rule <k> #end ~> #finishTx => #mkCodeDeposit ACCT ... </k>
184+
rule <statusCode> EVM_SUCCESS </statusCode>
185+
<k> #exception ~> #finishTx => #mkCodeDeposit ACCT ... </k>
185186
<id> ACCT </id>
186187
<txPending> ListItem(TXID:Int) ... </txPending>
187188
<message>
@@ -190,7 +191,8 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
190191
...
191192
</message>
192193
193-
rule <k> #end ~> #finishTx => #popCallStack ~> #dropWorldState ~> #refund GAVAIL ... </k>
194+
rule <statusCode> EVM_SUCCESS </statusCode>
195+
<k> #exception ~> #finishTx => #popCallStack ~> #dropWorldState ~> #refund GAVAIL ... </k>
194196
<id> ACCT </id>
195197
<gas> GAVAIL </gas>
196198
<txPending> ListItem(TXID:Int) ... </txPending>

evm.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ Control Flow
252252

253253
```k
254254
syntax KItem ::= Exception
255-
syntax KItem ::= "#exception" StatusCode
256-
syntax Exception ::= "#exception" | "#end" | "#revert"
257-
// ------------------------------------------------------
258-
rule <k> #exception SC => #exception ... </k>
259-
<statusCode> _ => SC </statusCode>
255+
syntax KItem ::= "#exception" StatusCode | "#end"
256+
syntax Exception ::= "#exception" | "#revert"
257+
// ---------------------------------------------
258+
rule <k> #end => #exception EVM_SUCCESS ... </k>
259+
rule <k> #exception SC => #exception ... </k> <statusCode> _ => SC </statusCode>
260260
261261
rule <k> EX:Exception ~> (_:Int => .) ... </k>
262262
rule <k> EX:Exception ~> (_:OpCode => .) ... </k>
@@ -271,7 +271,6 @@ Control Flow
271271
// ----------------------------------
272272
rule <k> #? B1 : _ ?# => B1 ... </k>
273273
rule <k> #revert ~> #? B1 : _ ?# => B1 ~> #revert ... </k>
274-
rule <k> #end ~> #? B1 : _ ?# => B1 ~> #end ... </k>
275274
rule <statusCode> SC </statusCode>
276275
<k> #exception ~> #? B1 : B2 ?# => #if isExceptionalStatusCode(SC) #then B2 #else B1 #fi ~> #exception ... </k>
277276
```
@@ -1455,7 +1454,8 @@ The various `CALL*` (and other inter-contract control flow) operations will be d
14551454
<output> OUT </output>
14561455
<gas> GAVAIL </gas>
14571456
1458-
rule <k> #end ~> #return RETSTART RETWIDTH
1457+
rule <statusCode> EVM_SUCCESS </statusCode>
1458+
<k> #exception ~> #return RETSTART RETWIDTH
14591459
=> #popCallStack ~> #dropWorldState
14601460
~> 1 ~> #push ~> #refund GAVAIL ~> #setLocalMem RETSTART RETWIDTH OUT
14611461
...
@@ -1609,7 +1609,8 @@ For each `CALL*` operation, we make a corresponding call to `#call` and a state-
16091609
rule <k> #revert ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 ~> #push ... </k>
16101610
<gas> GAVAIL </gas>
16111611
1612-
rule <k> #end ~> #codeDeposit ACCT => #mkCodeDeposit ACCT ... </k>
1612+
rule <statusCode> EVM_SUCCESS </statusCode>
1613+
<k> #exception ~> #codeDeposit ACCT => #mkCodeDeposit ACCT ... </k>
16131614
16141615
rule <k> #mkCodeDeposit ACCT
16151616
=> Gcodedeposit < SCHED > *Int #sizeWordStack(OUT) ~> #deductGas

tests/interactive/gas-analysis/sumTo10.evm.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
.WordStack
2525
</output>
2626
<statusCode>
27-
.StatusCode
27+
EVM_SUCCESS
2828
</statusCode>
2929
<callStack>
3030
.List

0 commit comments

Comments
 (0)