erigontech / erigontech/silkworm
evmone does not notify tracers the last opcode `STOP`
- Dominant language
- C++
- Stars
- 318
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
The transaction [0xe7ff62b0af9e1adc95e861272b364099fe18e5c154a8ea58da5e6f9235ca6131](https://etherscan.io/tx/0xe7ff62b0af9e1adc95e861272b364099fe18e5c154a8ea58da5e6f9235ca6131) sends a message to the following code:
CODE: (size 62) `0x3634601f3734516003600f82166010830460014303400614156022576001360390505b3434826020347107222caeb29694719e804b24fb3ee5116a8a5af1`
```
PC:00 0x36 OP_CALLDATASIZE
PC:01 0x34 OP_CALLVALUE
PC:02 0x60 0x1f OP_PUSH1
PC:04 0x37 OP_CALLDATACOPY
PC:05 0x34 OP_CALLVALUE
PC:06 0x51 OP_MLOAD
PC:07 0x60 0x03 OP_PUSH1
PC:09 0x60 0x0f OP_PUSH1
PC:11 0x82 OP_DUP3
PC:12 0x16 OP_AND
PC:13 0x60 0x10 OP_PUSH1
PC:15 0x83 OP_DUP4
PC:16 0x04 OP_DIV
PC:17 0x60 01 OP_PUSH1
PC:19 0x43 OP_NUMBER
PC:20 0x03 OP_SUB
PC:21 0x40 OP_BLOCKHASH
PC:22 0x06 OP_MOD
PC:23 0x14 OP_EQ
PC:24 0x15 OP_ISZERO
PC:25 0x60 22 OP_PUSH1
PC:27 0x57 OP_JUMPI
0x600136039050
PC:34 0x5b OP_JUMPDEST
PC:35 0x34 OP_CALLVALUE
PC:36 0x34 OP_CALLVALUE
PC:37 0x82 OP_DUP3
PC:38 0x60 0x20 OP_PUSH1
PC:40 0x34 OP_CALLVALUE
PC:41 0x71 0x07222caeb29694719e804b24fb3ee5116a8a OP_PUSH18
PC:60 0x5a OP_GAS
PC:61 0xf1 OP_CALL
```
If we execute
```
{
"jsonrpc":"2.0",
"method":"trace_replayTransaction",
"params":[
"0xe7ff62b0af9e1adc95e861272b364099fe18e5c154a8ea58da5e6f9235ca6131",
["vmTrace"]
],
"id":1
}
```
the JSON output must contain for each opcode the stack delta into the 'ex.push' field.
In case of opcode CALL at PC 61, it is not possible to know and add this value because `Tracer::notify_instruction_start` is not called since the EVM checks whether the PC has exceeded the length of the original code [here]( https://github.com/erigontech/evmone/blob/390641fa86606188bcdc1993664949d6964bebab/lib/evmone/baseline_execution.cpp#L206).
Current JSON result
```
.....
{
"cost": 308317,
"ex": {
"mem": null,
"push": [],
"store": null,
"used": 307137
},
"idx": "10-30",
"op": "CALL",
"pc": 61,
"sub": {}
}
.....
```
Expected JSON result
```
.....
{
"cost": 308317,
"ex": {
"mem": null,
"push": [
"0x1"
],
"store": null,
"used": 307137
},
"idx": "10-30",
"op": "CALL",
"pc": 61,
"sub": {}
}
.....
```
For the same reason, if we execute
```
{
"jsonrpc":"2.0",
"method":"debug_traceTransaction",
"params":[
"0xe7ff62b0af9e1adc95e861272b364099fe18e5c154a8ea58da5e6f9235ca6131",
{"disableStorage": false,"disableMemory": false,"disableStack": false}
],
"id":1
}
```
we miss the last section for the padded `STOP` opcode at the end of execution again because such last `STOP` opcode is not notified to the tracer.
Current JSON result:
```
.....
[
.....
{
"depth": 2,
"gas": 302255,
"gasCost": 0,
"memory": [
"000088c2a0bf0000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000"
],
"op": "STOP",
"pc": 116,
"stack": [
"0x1",
"0x0",
"0x2",
"0x897"
]
}
]
.....
```
Expected JSON result:
```
.....
[
.....
{
"depth": 2,
"gas": 302255,
"gasCost": 0,
"memory": [
"000088c2a0bf0000000000000000000000000000000000000000000000000000",
"0000000000000000000000000000000000000000000000000000000000000000"
],
"op": "STOP",
"pc": 116,
"stack": [
"0x1",
"0x0",
"0x2",
"0x897"
]
},
{
"depth": 1,
"gas": 307137,
"gasCost": 0,
"memory": [
"0000000000000000000000000000000000000000000000000000000000000031",
"01089700161b6004dc3500000000000000000000000000000000000000000000"
],
"op": "STOP",
"pc": 62,
"stack": [
"0x31",
"0x3",
"0x1"
]
}
]
.....
```
Attached the related JSON output files:
[debug_traceTransaction-expected.json](https://github.com/user-attachments/files/18694947/debug_traceTransaction-expected.json)
[debug_traceTransaction-response.json](https://github.com/user-attachments/files/18694946/debug_traceTransaction-response.json)
[trace_replayTransaction-expected.json](https://github.com/user-attachments/files/18694944/trace_replayTransaction-expected.json)
[trace_replayTransaction-response.json](https://github.com/user-attachments/files/18694945/trace_replayTransaction-response.json)
Contributor guide
Assessment
This issue has not been assessed yet.