Skip to content

Commit ac178c9

Browse files
author
Everett Hildenbrandt
committed
evm, driver: #revert now generates an exception, and sets the statusCode
1 parent 124ab42 commit ac178c9

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

driver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ To do so, we'll extend sort `JSON` with some EVM specific syntax, and provide a
179179
syntax EthereumCommand ::= "#finishTx"
180180
// --------------------------------------
181181
rule <statusCode> _:ExceptionalStatusCode </statusCode> <k> #exception ~> #finishTx => #popCallStack ~> #popWorldState ... </k>
182-
rule <k> #revert ~> #finishTx => #popCallStack ~> #popWorldState ~> #refund GAVAIL ... </k> <gas> GAVAIL </gas>
182+
rule <statusCode> EVM_REVERT </statusCode> <k> #exception ~> #finishTx => #popCallStack ~> #popWorldState ~> #refund GAVAIL ... </k> <gas> GAVAIL </gas>
183183
184184
rule <statusCode> EVM_SUCCESS </statusCode>
185185
<k> #exception ~> #finishTx => #mkCodeDeposit ACCT ... </k>

evm.md

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

253253
```k
254254
syntax KItem ::= Exception
255-
syntax KItem ::= "#exception" StatusCode | "#end"
256-
syntax Exception ::= "#exception" | "#revert"
257-
// ---------------------------------------------
255+
syntax KItem ::= "#exception" StatusCode | "#end" | "#revert"
256+
syntax Exception ::= "#exception"
257+
// ---------------------------------
258258
rule <k> #end => #exception EVM_SUCCESS ... </k>
259+
rule <k> #revert => #exception EVM_REVERT ... </k>
259260
rule <k> #exception SC => #exception ... </k> <statusCode> _ => SC </statusCode>
260261
261262
rule <k> EX:Exception ~> (_:Int => .) ... </k>
@@ -269,8 +270,7 @@ Control Flow
269270
```k
270271
syntax KItem ::= "#?" K ":" K "?#"
271272
// ----------------------------------
272-
rule <k> #? B1 : _ ?# => B1 ... </k>
273-
rule <k> #revert ~> #? B1 : _ ?# => B1 ~> #revert ... </k>
273+
rule <k> #? B1 : _ ?# => B1 ... </k>
274274
rule <statusCode> SC </statusCode>
275275
<k> #exception ~> #? B1 : B2 ?# => #if isExceptionalStatusCode(SC) #then B2 #else B1 #fi ~> #exception ... </k>
276276
```
@@ -1446,7 +1446,8 @@ The various `CALL*` (and other inter-contract control flow) operations will be d
14461446
</k>
14471447
<output> _ => .WordStack </output>
14481448
1449-
rule <k> #revert ~> #return RETSTART RETWIDTH
1449+
rule <statusCode> EVM_REVERT </statusCode>
1450+
<k> #exception ~> #return RETSTART RETWIDTH
14501451
=> #popCallStack ~> #popWorldState
14511452
~> 0 ~> #push ~> #refund GAVAIL ~> #setLocalMem RETSTART RETWIDTH OUT
14521453
...
@@ -1606,7 +1607,8 @@ For each `CALL*` operation, we make a corresponding call to `#call` and a state-
16061607
// ---------------------------------------------------
16071608
rule <statusCode> _:ExceptionalStatusCode </statusCode>
16081609
<k> #exception ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> 0 ~> #push ... </k> <output> _ => .WordStack </output>
1609-
rule <k> #revert ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 ~> #push ... </k>
1610+
rule <statusCode> EVM_REVERT </statusCode>
1611+
<k> #exception ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 ~> #push ... </k>
16101612
<gas> GAVAIL </gas>
16111613
16121614
rule <statusCode> EVM_SUCCESS </statusCode>

0 commit comments

Comments
 (0)