erigon icon indicating copy to clipboard operation
erigon copied to clipboard

Slight difference in debug_traceBlockByHash output from Geth

Open quickchase opened this issue 3 years ago • 9 comments

System information

Erigon version: 2022.07.04-alpha

There's a slight difference in how Geth and Erigon return the data, erigon has an extra result key for some reason.

Expected behaviour

This is how Geth would return the result:

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": [
    {
      "result": {
        "type": "CALL",

Actual behaviour

This is how Erigon returns the result:

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": [
    {
      "type": "CALL",

Steps to reproduce the behaviour

{
  "jsonrpc": "2.0",
  "method": "debug_traceBlockByHash",
  "params": [
    "<blockHash>",
    { "tracer": "callTracer" }
  ],
  "id": 0
}

Edit: I got them backwards

quickchase avatar Aug 04 '22 14:08 quickchase

Can you also clarify how Erigon conveys the tracing error?

For geth, the trace struct may contain an error field, e.g.

[
  {"result": {"type": "CALL", ...}},
  {"result": {"type": "CALL", ...}},
  {"error": "execution timeout"}
]

Does Erigon return an empty struct in the event of any errors?

[
  {"type": "CALL", ...},
  {"type": "CALL", ...},
  {}
]

jiezhang avatar Aug 05 '22 00:08 jiezhang

Can you also clarify how Erigon conveys the tracing error?

For geth, the trace struct may contain an error field, e.g.

{
  {"result": {"type": "CALL", ...}},
  {"result": {"type": "CALL", ...}},
  {"error": "execution timeout"}
}

Does Erigon return an empty struct in the event of any errors?

{
  {"type": "CALL", ...},
  {"type": "CALL", ...},
  {}
}

@jiezhang

In case of error it looks like

{
  {"type": "CALL", ...},
  ,
  {"type": "CALL", ...},
  
}

There is not even a struct, only an empty item. You can try it with reducing the execution timeout (e.g 20ms).

b0l0k avatar Aug 18 '22 21:08 b0l0k

@vbouzon An "empty" item is not a valid JSON. Can you change it to {} or null? i.e.

[
  {"type": "CALL"},
  {},
  {"type": "CALL"}
]

or 
[
  {"type": "CALL"},
  null,
  {"type": "CALL"}
]

See https://go.dev/play/p/lJ8KyptxYp5

jiezhang avatar Aug 18 '22 21:08 jiezhang

I'm not maintainer of this project, It was comment as I had the same question two days ago.

For your information, an undefined item in array seems valid even it looks like bug: https://playcode.io/944108/

b0l0k avatar Aug 18 '22 21:08 b0l0k

Errors don't result in valid JSON with the erigon client, for example:

{"result":,"error":{"code":-32000,"message":"execution timeout"}}

@vbouzon your example is valid in golang, but this is not valid for the json spec. i.e. adding the above snippet into any online JSON validator will yield "invalid" result

If a maintainer of the project sees this, I second Jie's suggestion:

Can you change it to {} or null?

jaleel-salhi-cb avatar Aug 18 '22 21:08 jaleel-salhi-cb

I don't think that's a valid JSON in any programming language:

  • JS: https://playcode.io/944128
  • Golang: https://go.dev/play/p/lJ8KyptxYp5

jiezhang avatar Aug 18 '22 21:08 jiezhang

It’s invalid json because trace_ methods doing json streaming - means manual json assembling. Need to fix.

AskAlexSharov avatar Aug 19 '22 01:08 AskAlexSharov

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

github-actions[bot] avatar Oct 13 '22 04:10 github-actions[bot]

Commenting to keep this alive.

On Wed, Oct 12, 2022 at 9:02 PM github-actions[bot] < @.***> wrote:

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

— Reply to this email directly, view it on GitHub https://github.com/ledgerwatch/erigon/issues/4935#issuecomment-1276997073, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWUYCGGZOUQNIT5NUB75O3DWC6CWBANCNFSM55SZCAJQ . You are receiving this because you commented.Message ID: @.***>

jaleel-salhi-cb avatar Oct 13 '22 06:10 jaleel-salhi-cb

This issue is stale because it has been open for 40 days with no activity. Remove stale label or comment, or this will be closed in 7 days.

github-actions[bot] avatar Dec 09 '22 02:12 github-actions[bot]

@AskAlexSharov Any updates?

jiezhang avatar Dec 09 '22 02:12 jiezhang

The malformed JSON when method handler crashes still exists.

I was tracing block 5000097 ["0x4c4ba1",{"tracer":"callTracer"}] and the end of the output was: {"result":null,"error":{"code":-32000,"message":"method handler crashed"}}\n

The "correct" way to end that, which would be valid json would be: {"result":null,"error":{"code":-32000,"message":"method handler crashed"}}]}

In other words it did not finish the array and close the object (\n should be replaced with ]})

MysticRyuujin avatar Dec 16 '22 15:12 MysticRyuujin