Slight difference in debug_traceBlockByHash output from Geth
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
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", ...},
{}
]
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).
@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
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/
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?
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
It’s invalid json because trace_ methods doing json streaming - means manual json assembling. Need to fix.
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.
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: @.***>
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.
@AskAlexSharov Any updates?
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 ]})