Skip to content

Commit 5b9a3a0

Browse files
dwightguthehildenb
authored andcommitted
StatusCode for node (#399)
* deps/plugin: update submodule * network: StatusCode2String * evm-node: pass status code to vmResult * evm-node: fix name of field * network: fix typos * network: formatting
1 parent 8b73f8e commit 5b9a3a0

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

evm-node.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ Because the same account may be loaded more than once, implementations of this i
214214
- `extractConfig` takes a final configuration after rewriting and extracts a `vmResult` from it in order to abstract away configuration structure from the postprocessing done by the blockchain-k-plugin.
215215

216216
```{.k .node}
217-
syntax KItem ::= vmResult ( return: String , gas: Int , refund: Int , status: Int , selfdestruct: List , logs: List , AccountsCell , touched: List )
217+
syntax KItem ::= vmResult ( return: String , gas: Int , refund: Int , status: Int , selfdestruct: List , logs: List , AccountsCell , touched: List , statusCode: String )
218218
syntax KItem ::= extractConfig() [function, symbol]
219219
// ---------------------------------------------------
220-
rule [[ extractConfig() => vmResult(#unparseByteStack(OUT), GAVAIL, REFUND, STATUS, Set2List(SD), LOGS, <accounts> ACCTS </accounts>, Set2List(TOUCHED)) ]]
220+
rule [[ extractConfig() => vmResult(#unparseByteStack(OUT), GAVAIL, REFUND, STATUS, Set2List(SD), LOGS, <accounts> ACCTS </accounts>, Set2List(TOUCHED), StatusCode2String(STATUSCODE)) ]]
221221
<output> OUT </output>
222222
<gas> GAVAIL </gas>
223223
<refund> REFUND </refund>
@@ -226,6 +226,7 @@ Because the same account may be loaded more than once, implementations of this i
226226
<log> LOGS </log>
227227
<accounts> ACCTS </accounts>
228228
<touchedAccounts> TOUCHED </touchedAccounts>
229+
<statusCode> STATUSCODE </statusCode>
229230
```
230231

231232
- `contractBytes` takes the contents of the `<code>` cell and returns its binary representation as a String.

network.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ It will incrementally build up to supporting the entire [EVM-C API].
66

77
```k
88
module NETWORK
9+
imports STRING-SYNTAX
10+
11+
syntax String ::= StatusCode2String(StatusCode) [function]
12+
// ----------------------------------------------------------
913
```
1014

1115
EVM Status Codes
@@ -41,6 +45,18 @@ The following codes all indicate that the VM ended execution with an exception,
4145
| "EVMC_INVALID_MEMORY_ACCESS"
4246
| "EVMC_STATIC_MODE_VIOLATION"
4347
| "EVMC_PRECOMPILE_FAILURE"
48+
// ----------------------------------------------------------
49+
rule StatusCode2String(EVMC_FAILURE) => "EVMC_FAILURE"
50+
rule StatusCode2String(EVMC_INVALID_INSTRUCTION) => "EVMC_INVALID_INSTRUCTION"
51+
rule StatusCode2String(EVMC_UNDEFINED_INSTRUCTION) => "EVMC_UNDEFINED_INSTRUCTION"
52+
rule StatusCode2String(EVMC_OUT_OF_GAS) => "EVMC_OUT_OF_GAS"
53+
rule StatusCode2String(EVMC_BAD_JUMP_DESTINATION) => "EVMC_BAD_JUMP_DESTINATION"
54+
rule StatusCode2String(EVMC_STACK_OVERFLOW) => "EVMC_STACK_OVERFLOW"
55+
rule StatusCode2String(EVMC_STACK_UNDERFLOW) => "EVMC_STACK_UNDERFLOW"
56+
rule StatusCode2String(EVMC_CALL_DEPTH_EXCEEDED) => "EVMC_CALL_DEPTH_EXCEEDED"
57+
rule StatusCode2String(EVMC_INVALID_MEMORY_ACCESS) => "EVMC_INVALID_MEMORY_ACCESS"
58+
rule StatusCode2String(EVMC_STATIC_MODE_VIOLATION) => "EVMC_STATIC_MODE_VIOLATION"
59+
rule StatusCode2String(EVMC_PRECOMPILE_FAILURE) => "EVMC_PRECOMPILE_FAILURE"
4460
```
4561

4662
### Ending Codes
@@ -54,6 +70,9 @@ These additional status codes indicate that execution has ended in some non-exce
5470
syntax EndStatusCode ::= ExceptionalStatusCode
5571
| "EVMC_SUCCESS"
5672
| "EVMC_REVERT"
73+
// --------------------------------------
74+
rule StatusCode2String(EVMC_SUCCESS) => "EVMC_SUCCESS"
75+
rule StatusCode2String(EVMC_REVERT) => "EVMC_REVERT"
5776
```
5877

5978
### Other Codes
@@ -69,6 +88,10 @@ The following codes indicate other non-execution errors with the VM.
6988
| "EVMC_REJECTED"
7089
| "EVMC_INTERNAL_ERROR"
7190
| ".StatusCode"
91+
// -----------------------------------
92+
rule StatusCode2String(EVMC_REJECTED) => "EVMC_REJECTED"
93+
rule StatusCode2String(EVMC_INTERNAL_ERROR) => "EVMC_INTERNAL_ERROR"
94+
rule StatusCode2String(.StatusCode) => ""
7295
```
7396

7497
Client/Network Codes
@@ -83,6 +106,9 @@ These are not present in the [EVM-C API].
83106
```k
84107
syntax ExceptionalStatusCode ::= "EVMC_ACCOUNT_ALREADY_EXISTS"
85108
| "EVMC_BALANCE_UNDERFLOW"
109+
// ---------------------------------------------------------
110+
rule StatusCode2String(EVMC_ACCOUNT_ALREADY_EXISTS) => "EVMC_ACCOUNT_ALREADY_EXISTS"
111+
rule StatusCode2String(EVMC_BALANCE_UNDERFLOW) => "EVMC_BALANCE_UNDERFLOW"
86112
```
87113

88114
```k

0 commit comments

Comments
 (0)