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

Errors fail to marshal properly in traces #23285

Closed
CMajeri opened this issue Jul 28, 2021 · 1 comment · Fixed by #23292
Closed

Errors fail to marshal properly in traces #23285

CMajeri opened this issue Jul 28, 2021 · 1 comment · Fixed by #23292

Comments

@CMajeri
Copy link

CMajeri commented Jul 28, 2021

System information

Geth version: master?
OS & Version: Windows/Linux/OSX
Commit hash : 2faf796

Expected behaviour

I was running the debug_traceBlock rpc, when I noticed the errors were not displaying properly.

"error": {}

Actual behaviour

When I expected to see something like

"error": "out of gas"

After some digging, it seems the issue is with the fact that "Error" is an error interface in

type StructLogRes struct {
	Pc      uint64             `json:"pc"`
	Op      string             `json:"op"`
	Gas     uint64             `json:"gas"`
	GasCost uint64             `json:"gasCost"`
	Depth   int                `json:"depth"`
	Error   error              `json:"error,omitempty"`
	Stack   *[]string          `json:"stack,omitempty"`
	Memory  *[]string          `json:"memory,omitempty"`
	Storage *map[string]string `json:"storage,omitempty"`
}

Instead of something more marshallable like a string.
Since this struct is only used to marshal to json, maybe setting Error to be of type string, and setting it to Error.Error() could work?

Steps to reproduce the behaviour

Trace any block that has an error in a smart contract.

@rjl493456442
Copy link
Member

@CMajeri Thanks for catching it! I have opened a PR to fix it. #23292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants