Skip to content

Commit bfd4a58

Browse files
author
Everett Hildenbrandt
committed
evm, driver, evm-node: #revert generates an exception, sets statusCode
1 parent 55447fc commit bfd4a58

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
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> EVMC_REVERT </statusCode> <k> #exception ~> #finishTx => #popCallStack ~> #popWorldState ~> #refund GAVAIL ... </k> <gas> GAVAIL </gas>
183183
184184
rule <statusCode> EVMC_SUCCESS </statusCode>
185185
<k> #exception ~> #finishTx => #mkCodeDeposit ACCT ... </k>

evm-node.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ Because the same account may be loaded more than once, implementations of this i
189189
rule <statusCode> _:ExceptionalStatuscode </statusCode>
190190
<k> #exception ~> #endVM => #popCallStack ~> #popWorldState ~> 0 </k>
191191
<output> _ => .WordStack </output>
192-
rule <k> #revert ~> #endVM => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 </k>
193-
<gas> GAVAIL </gas>
192+
193+
rule <statusCode> EVMC_REVERT </statusCode>
194+
<k> #exception ~> #endVM => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 </k>
195+
<gas> GAVAIL </gas>
194196
195197
rule <statusCode> EVMC_SUCCESS </statusCode>
196198
<k> #exception ~> #endVM => #popCallStack ~> #dropWorldState ~> #refund GAVAIL ~> 1 </k>

evm.md

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

252252
```k
253253
syntax KItem ::= Exception
254-
syntax KItem ::= "#exception" StatusCode | "#end"
255-
syntax Exception ::= "#exception" | "#revert"
256-
// ---------------------------------------------
254+
syntax KItem ::= "#exception" StatusCode | "#end" | "#revert"
255+
syntax Exception ::= "#exception"
256+
// ---------------------------------
257257
rule <k> #end => #exception EVMC_SUCCESS ... </k>
258+
rule <k> #revert => #exception EVMC_REVERT ... </k>
258259
rule <k> #exception SC => #exception ... </k> <statusCode> _ => SC </statusCode>
259260
260261
rule <k> EX:Exception ~> (_:Int => .) ... </k>
@@ -268,8 +269,7 @@ Control Flow
268269
```k
269270
syntax KItem ::= "#?" K ":" K "?#"
270271
// ----------------------------------
271-
rule <k> #? B1 : _ ?# => B1 ... </k>
272-
rule <k> #revert ~> #? B1 : _ ?# => B1 ~> #revert ... </k>
272+
rule <k> #? B1 : _ ?# => B1 ... </k>
273273
rule <statusCode> SC </statusCode>
274274
<k> #exception ~> #? B1 : B2 ?# => #if isExceptionalStatusCode(SC) #then B2 #else B1 #fi ~> #exception ... </k>
275275
```
@@ -1445,7 +1445,8 @@ The various `CALL*` (and other inter-contract control flow) operations will be d
14451445
</k>
14461446
<output> _ => .WordStack </output>
14471447
1448-
rule <k> #revert ~> #return RETSTART RETWIDTH
1448+
rule <statusCode> EVMC_REVERT </statusCode>
1449+
<k> #exception ~> #return RETSTART RETWIDTH
14491450
=> #popCallStack ~> #popWorldState
14501451
~> 0 ~> #push ~> #refund GAVAIL ~> #setLocalMem RETSTART RETWIDTH OUT
14511452
...
@@ -1605,7 +1606,8 @@ For each `CALL*` operation, we make a corresponding call to `#call` and a state-
16051606
// ---------------------------------------------------
16061607
rule <statusCode> _:ExceptionalStatusCode </statusCode>
16071608
<k> #exception ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> 0 ~> #push ... </k> <output> _ => .WordStack </output>
1608-
rule <k> #revert ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 ~> #push ... </k>
1609+
rule <statusCode> EVMC_REVERT </statusCode>
1610+
<k> #exception ~> #codeDeposit _ => #popCallStack ~> #popWorldState ~> #refund GAVAIL ~> 0 ~> #push ... </k>
16091611
<gas> GAVAIL </gas>
16101612
16111613
rule <statusCode> EVMC_SUCCESS </statusCode>

0 commit comments

Comments
 (0)