eth/tracers/logger: use omitempty to reduce log bloat (#24547)

Makes the evm json output less verbose: omitting output of `memory` and `returndata` in case they are empty.
This commit is contained in:
Martin Holst Swende
2022-03-29 22:36:55 +02:00
committed by GitHub
parent b5a129ea24
commit 67c070c379
3 changed files with 42 additions and 9 deletions

View File

@ -66,10 +66,10 @@ type StructLog struct {
Op vm.OpCode `json:"op"`
Gas uint64 `json:"gas"`
GasCost uint64 `json:"gasCost"`
Memory []byte `json:"memory"`
Memory []byte `json:"memory,omitempty"`
MemorySize int `json:"memSize"`
Stack []uint256.Int `json:"stack"`
ReturnData []byte `json:"returnData"`
ReturnData []byte `json:"returnData,omitempty"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"`
RefundCounter uint64 `json:"refund"`
@ -82,8 +82,8 @@ type structLogMarshaling struct {
GasCost math.HexOrDecimal64
Memory hexutil.Bytes
ReturnData hexutil.Bytes
OpName string `json:"opName"` // adds call to OpName() in MarshalJSON
ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON
OpName string `json:"opName"` // adds call to OpName() in MarshalJSON
ErrorString string `json:"error,omitempty"` // adds call to ErrorString() in MarshalJSON
}
// OpName formats the operand name in a human-readable format.