ethereum-optimism / op-geth

GNU Lesser General Public License v3.0
255 stars 653 forks source link

`debug_traceBlockByNumber` and `debug_traceTransaction` returns incorrect data #248

Closed MRabenda closed 2 weeks ago

MRabenda commented 4 months ago

System information

op-node v1.5.1 op-geth v1.101308.0,

Expected behaviour

Should have a proper response not an error

Actual behaviour

[
  {
    "method": "debug_traceBlockByNumber",
    "params": [
        "0x660473A",
        {
            "tracer": "flatCallTracer"
        }
    ],
    "id": 0,
    "jsonrpc": "2.0"
  }
]

Is returning an error

[
    {
        "jsonrpc": "2.0",
        "id": 0,
        "error": {
            "code": -32000,
            "message": "unrecognized call frame type: STOP"
        }
    }
]

When I switch to callTracer I can find in the trace list

            {
                "txHash": "0xa47277b3d92384e70906bed705723a15c91d9f0fff2fc602824d14ea201801c1",
                "result": {
                    "from": "0x0000000000000000000000000000000000000000",
                    "gas": "0x0",
                    "gasUsed": "0x520c",
                    "input": "0x",
                    "type": "STOP"
                }
            }
0xmariniere commented 4 months ago

@sbvegan FYI

sbvegan commented 4 months ago

Reproducing

I was able to reproduce the same behavior, but I'm not familiar with tracing. My first note is that, op-geth will be very close to geth, see https://op-geth.optimism.io/. In the geth docs I'm only seeing callTracer and not flatCallTracer. We're flagging this internally.

Actual Behavior - flatCallTracer

Request:

soyboy@soyboys-MacBook-Air ~ % curl -X POST \
--data '[
  {
    "jsonrpc": "2.0",
    "method": "debug_traceBlockByNumber",
    "params": [
      "0x660473A",
      {
        "tracer": "flatCallTracer"
      }
    ],
    "id": 0
  }
]' \
-H "Content-Type: application/json" \
<internal-developer-rpc-endpoint> | jq

Response:

[
  {
    "jsonrpc": "2.0",
    "error": {
      "code": -32000,
      "message": "unrecognized call frame type: STOP"
    },
    "id": 0
  }
]

Actual Behavior - callTracer

Request:

curl -X POST \
--data '[
  {
    "jsonrpc": "2.0",
    "method": "debug_traceBlockByNumber",
    "params": [
      "0x660473A",
      {
        "tracer": "callTracer"
      }
    ],
    "id": 0
  }
]' \
-H "Content-Type: application/json" \
<internal-developer-rpc-endpoint> | jq

Response:

[
  {
    "jsonrpc": "2.0",
    "result": [
      {
        "result": {
          "calls": [
            {
              "from": "0x4200000000000000000000000000000000000015",
              "gas": "0xe9a0d",
              "gasUsed": "0x6af8",
              "input": "0x015d8eb900000000000000000000000000000000000000000000000000000000010e36800000000000000000000000000000000000000000000000000000000064b467e700000000000000000000000000000000000000000000000000000003584922358bb001d5a5f8872522e82ed02f58008f78d434eedd0a5e9745b2a74bf2f94a2a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f3298500000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0",
              "to": "0xc0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d3c0d30015",
              "type": "DELEGATECALL",
              "value": "0x0"
            }
          ],
          "from": "0xdeaddeaddeaddeaddeaddeaddeaddeaddead0001",
          "gas": "0xf4240",
          "gasUsed": "0xc539",
          "input": "0x015d8eb900000000000000000000000000000000000000000000000000000000010e36800000000000000000000000000000000000000000000000000000000064b467e700000000000000000000000000000000000000000000000000000003584922358bb001d5a5f8872522e82ed02f58008f78d434eedd0a5e9745b2a74bf2f94a2a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000006887246668a3b87f54deb3b94ba47a6f63f3298500000000000000000000000000000000000000000000000000000000000000bc00000000000000000000000000000000000000000000000000000000000a6fe0",
          "to": "0x4200000000000000000000000000000000000015",
          "type": "CALL",
          "value": "0x0"
        },
        "txHash": "0x53c37d6a4bff2e8adec4f681caf0a5f50af9946cfcc37545f86821237b150573"
      },
      {
        "result": {
          "from": "0x0000000000000000000000000000000000000000",
          "gas": "0x0",
          "gasUsed": "0x520c",
          "input": "0x",
          "type": "STOP"
        },
        "txHash": "0xa47277b3d92384e70906bed705723a15c91d9f0fff2fc602824d14ea201801c1"
      },
      // omitted the rest of the response 
    ],
    "id": 0
  }
]
sbvegan commented 4 months ago

I cannot find flatCallTracer https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-debug#traceconfig. Where did you find this tracer configuration option?

MRabenda commented 4 months ago

Hey @sbvegan - for reference that tracer was introduced in Geth 1.12.0 - https://github.com/ethereum/go-ethereum/releases/tag/v1.12.0 (in release notes you can find - https://github.com/ethereum/go-ethereum/pull/27304) and is supported by Optimism as of now

https://ethereum.org/pl/developers/docs/evm/opcodes <- STOP opcode should not be returned by flatCallTracer

achmand commented 4 months ago

@sbvegan yeah seems like they did not add this in their documentation but as @MRabenda pointed out; it is indeed supported by geth.

Any updates on this?

MRabenda commented 4 months ago

@sbvegan we did additional investigation and issue is deeper, not in flatCallTracer. Please try to execute

{  
    "method": "debug_traceTransaction",                                   
    "params": [
        "0xa47277b3d92384e70906bed705723a15c91d9f0fff2fc602824d14ea201801c1",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 0,
    "jsonrpc": "2.0"
  }

As a response you will get

  {
    "jsonrpc": "2.0",
    "id": 0,
    "result": {
        "from": "0x0000000000000000000000000000000000000000",
        "gas": "0x0",
        "gasUsed": "0x520c",
        "input": "0x",
        "type": "STOP"
    }
}

And probably this is core issue here As a response you will get

sbvegan commented 4 months ago

Yep I got the same response, I'll work on getting this in front of a client engineer:

Reproducing

curl -X POST \                 
--data '[
  {  
    "method": "debug_traceTransaction",                                   
    "params": [                      
        "0xa47277b3d92384e70906bed705723a15c91d9f0fff2fc602824d14ea201801c1",
        {
            "tracer": "callTracer"
        }
    ],
    "id": 0,
    "jsonrpc": "2.0"
  }
]' \
-H "Content-Type: application/json" \
<internal-endpoint> | jq

# response

[
  {
    "jsonrpc": "2.0",
    "result": {
      "from": "0x0000000000000000000000000000000000000000",
      "gas": "0x0",
      "gasUsed": "0x520c",
      "input": "0x",
      "type": "STOP"
    },
    "id": 0
  }
]
MRabenda commented 2 weeks ago

It was solved by https://github.com/ethereum-optimism/op-geth/pull/265/files