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

Type of error field in structlog logger differs from geth, alloy #12085

Closed
einar-polygon opened this issue Sep 24, 2024 · 2 comments · Fixed by #12086
Closed

Type of error field in structlog logger differs from geth, alloy #12085

einar-polygon opened this issue Sep 24, 2024 · 2 comments · Fixed by #12086
Assignees

Comments

@einar-polygon
Copy link
Contributor

System information

Commit hash: c293883

Expected behaviour

The field error should probably be logged as a string to be compatible with Geth, Alloy.

Actual behaviour

The field error is logged as an object containing a string.

Steps to reproduce the behaviour

I don't know of a tx_id on a public chain, whose logs contains the error field, but here is the command I used to confirm this issue:

curl $RPC \                                                                                        
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"debug_traceTransaction","params":[tx_id, {"disableStack": true, "disableMemory": true, "disableStorage": true} ], "id":1,"jsonrpc":"2.0"}'  | jq | rg "error" -C 16

Source

l.stream.WriteMore()
l.stream.WriteObjectField("error")
l.stream.WriteObjectStart()
l.stream.WriteObjectEnd()

Suggested fix

diff --git a/eth/tracers/logger/json_stream.go b/eth/tracers/logger/json_stream.go
index 5b616e81e7..60b8443b65 100644
--- a/eth/tracers/logger/json_stream.go
+++ b/eth/tracers/logger/json_stream.go
@@ -127,9 +127,9 @@ func (l *JsonStreamLogger) CaptureState(pc uint64, op vm.OpCode, gas, cost uint6
        if err != nil {
                l.stream.WriteMore()
                l.stream.WriteObjectField("error")
-               l.stream.WriteObjectStart()
-               l.stream.WriteObjectEnd()
-               //l.stream.WriteString(err.Error())
+               // l.stream.WriteObjectStart()
+               // l.stream.WriteObjectEnd()
+               l.stream.WriteString(err.Error())
        }
        if !l.cfg.DisableStack {
                l.stream.WriteMore()
@AskAlexSharov
Copy link
Collaborator

tnx. pr: #12089

@einar-polygon
Copy link
Contributor Author

@AlexeyAkhunov seems to be the original committer of those lines so tagging him. Perhaps he knows something I don't about why the line was already there, but commented out (//l.stream.WriteString(err.Error())).

@VBulikov VBulikov closed this as completed Oct 4, 2024
@VBulikov VBulikov reopened this Oct 4, 2024
@VBulikov VBulikov closed this as completed Oct 4, 2024
taratorio added a commit that referenced this issue Oct 8, 2024
…2089) (#12241)

cherry-pick #12089 into E2

#12085

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
yperbasis pushed a commit that referenced this issue Oct 24, 2024
…2089) (#12241)

cherry-pick #12089 into E2

#12085

Co-authored-by: Alex Sharov <AskAlexSharov@gmail.com>
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

Successfully merging a pull request may close this issue.

3 participants