Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evmone does not notify tracers the last opcode STOP #2701

Open
Sixtysixter opened this issue Feb 6, 2025 · 0 comments
Open

evmone does not notify tracers the last opcode STOP #2701

Sixtysixter opened this issue Feb 6, 2025 · 0 comments
Assignees

Comments

@Sixtysixter
Copy link
Contributor

Sixtysixter commented Feb 6, 2025

The transaction 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.

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
debug_traceTransaction-response.json
trace_replayTransaction-expected.json
trace_replayTransaction-response.json

@Sixtysixter Sixtysixter self-assigned this Feb 6, 2025
@canepat canepat added the bug label Feb 13, 2025
@canepat canepat changed the title EVM does not notify tracers the last opcode STOP evmone does not notify tracers the last opcode STOP Feb 13, 2025
@Sixtysixter Sixtysixter assigned chfast and unassigned Sixtysixter Feb 13, 2025
@VBulikov VBulikov removed the bug label Feb 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants