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

@ -21,16 +21,16 @@ func (s StructLog) MarshalJSON() ([]byte, error) {
Op vm.OpCode `json:"op"`
Gas math.HexOrDecimal64 `json:"gas"`
GasCost math.HexOrDecimal64 `json:"gasCost"`
Memory hexutil.Bytes `json:"memory"`
Memory hexutil.Bytes `json:"memory,omitempty"`
MemorySize int `json:"memSize"`
Stack []uint256.Int `json:"stack"`
ReturnData hexutil.Bytes `json:"returnData"`
ReturnData hexutil.Bytes `json:"returnData,omitempty"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth int `json:"depth"`
RefundCounter uint64 `json:"refund"`
Err error `json:"-"`
OpName string `json:"opName"`
ErrorString string `json:"error"`
ErrorString string `json:"error,omitempty"`
}
var enc StructLog
enc.Pc = s.Pc
@ -57,10 +57,10 @@ func (s *StructLog) UnmarshalJSON(input []byte) error {
Op *vm.OpCode `json:"op"`
Gas *math.HexOrDecimal64 `json:"gas"`
GasCost *math.HexOrDecimal64 `json:"gasCost"`
Memory *hexutil.Bytes `json:"memory"`
Memory *hexutil.Bytes `json:"memory,omitempty"`
MemorySize *int `json:"memSize"`
Stack []uint256.Int `json:"stack"`
ReturnData *hexutil.Bytes `json:"returnData"`
ReturnData *hexutil.Bytes `json:"returnData,omitempty"`
Storage map[common.Hash]common.Hash `json:"-"`
Depth *int `json:"depth"`
RefundCounter *uint64 `json:"refund"`