From ff70e420bbaa345332eeff09ca100f4902313a73 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 16 Oct 2020 10:33:42 +0200 Subject: [PATCH 1/2] core/vm: marshall returnData as hexstring in trace logs --- core/vm/gen_structlog.go | 8 ++++---- core/vm/logger.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/vm/gen_structlog.go b/core/vm/gen_structlog.go index ac1a9070c897..326d35ad9e56 100644 --- a/core/vm/gen_structlog.go +++ b/core/vm/gen_structlog.go @@ -24,7 +24,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) { MemorySize int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` ReturnStack []math.HexOrDecimal64 `json:"returnStack"` - ReturnData []byte `json:"returnData"` + ReturnData string `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` @@ -51,7 +51,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) { enc.ReturnStack[k] = math.HexOrDecimal64(v) } } - enc.ReturnData = s.ReturnData + enc.ReturnData = string(s.ReturnData) enc.Storage = s.Storage enc.Depth = s.Depth enc.RefundCounter = s.RefundCounter @@ -72,7 +72,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error { MemorySize *int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` ReturnStack []math.HexOrDecimal64 `json:"returnStack"` - ReturnData []byte `json:"returnData"` + ReturnData *string `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth *int `json:"depth"` RefundCounter *uint64 `json:"refund"` @@ -113,7 +113,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error { } } if dec.ReturnData != nil { - s.ReturnData = dec.ReturnData + s.ReturnData = hexutil.Bytes(*dec.ReturnData) } if dec.Storage != nil { s.Storage = dec.Storage diff --git a/core/vm/logger.go b/core/vm/logger.go index e1d7c67ef177..bbf1b63d52ce 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -68,7 +68,7 @@ type StructLog struct { MemorySize int `json:"memSize"` Stack []*big.Int `json:"stack"` ReturnStack []uint32 `json:"returnStack"` - ReturnData []byte `json:"returnData"` + ReturnData hexutil.Bytes `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` @@ -82,6 +82,7 @@ type structLogMarshaling struct { Gas math.HexOrDecimal64 GasCost math.HexOrDecimal64 Memory hexutil.Bytes + ReturnData string OpName string `json:"opName"` // adds call to OpName() in MarshalJSON ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON } From f68849af525327968a3db831f24c54a373c3d2cc Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 16 Oct 2020 10:47:28 +0200 Subject: [PATCH 2/2] core/vm: marshall returnData as hexstring in trace logs --- core/vm/gen_structlog.go | 8 ++++---- core/vm/logger.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/vm/gen_structlog.go b/core/vm/gen_structlog.go index 326d35ad9e56..44da014de919 100644 --- a/core/vm/gen_structlog.go +++ b/core/vm/gen_structlog.go @@ -24,7 +24,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) { MemorySize int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` ReturnStack []math.HexOrDecimal64 `json:"returnStack"` - ReturnData string `json:"returnData"` + ReturnData hexutil.Bytes `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` @@ -51,7 +51,7 @@ func (s StructLog) MarshalJSON() ([]byte, error) { enc.ReturnStack[k] = math.HexOrDecimal64(v) } } - enc.ReturnData = string(s.ReturnData) + enc.ReturnData = s.ReturnData enc.Storage = s.Storage enc.Depth = s.Depth enc.RefundCounter = s.RefundCounter @@ -72,7 +72,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error { MemorySize *int `json:"memSize"` Stack []*math.HexOrDecimal256 `json:"stack"` ReturnStack []math.HexOrDecimal64 `json:"returnStack"` - ReturnData *string `json:"returnData"` + ReturnData *hexutil.Bytes `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth *int `json:"depth"` RefundCounter *uint64 `json:"refund"` @@ -113,7 +113,7 @@ func (s *StructLog) UnmarshalJSON(input []byte) error { } } if dec.ReturnData != nil { - s.ReturnData = hexutil.Bytes(*dec.ReturnData) + s.ReturnData = *dec.ReturnData } if dec.Storage != nil { s.Storage = dec.Storage diff --git a/core/vm/logger.go b/core/vm/logger.go index bbf1b63d52ce..a8598d3c052a 100644 --- a/core/vm/logger.go +++ b/core/vm/logger.go @@ -68,7 +68,7 @@ type StructLog struct { MemorySize int `json:"memSize"` Stack []*big.Int `json:"stack"` ReturnStack []uint32 `json:"returnStack"` - ReturnData hexutil.Bytes `json:"returnData"` + ReturnData []byte `json:"returnData"` Storage map[common.Hash]common.Hash `json:"-"` Depth int `json:"depth"` RefundCounter uint64 `json:"refund"` @@ -82,7 +82,7 @@ type structLogMarshaling struct { Gas math.HexOrDecimal64 GasCost math.HexOrDecimal64 Memory hexutil.Bytes - ReturnData string + ReturnData hexutil.Bytes OpName string `json:"opName"` // adds call to OpName() in MarshalJSON ErrorString string `json:"error"` // adds call to ErrorString() in MarshalJSON }