From 302d2a570e0f3a285e8fc1bf71047992074c3e46 Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 12 Jul 2023 07:21:21 +0000 Subject: [PATCH 1/3] eth/tracers: missing ReturnData in the logger tracer --- eth/tracers/logger/logger.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index c7f171c5bdf9..ff99c485a196 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -418,6 +418,7 @@ type StructLogRes struct { Depth int `json:"depth"` Error string `json:"error,omitempty"` Stack *[]string `json:"stack,omitempty"` + ReturnData *[]string `json:"returnData,omitempty"` Memory *[]string `json:"memory,omitempty"` Storage *map[string]string `json:"storage,omitempty"` RefundCounter uint64 `json:"refund,omitempty"` @@ -443,6 +444,13 @@ func formatLogs(logs []StructLog) []StructLogRes { } formatted[index].Stack = &stack } + if trace.ReturnData != nil { + rdata := make([]string, 0, (len(trace.ReturnData)+31)/32) + for i := 0; i+32 <= len(trace.ReturnData); i += 32 { + rdata = append(rdata, fmt.Sprintf("%x", trace.ReturnData[i:i+32])) + } + formatted[index].ReturnData = &rdata + } if trace.Memory != nil { memory := make([]string, 0, (len(trace.Memory)+31)/32) for i := 0; i+32 <= len(trace.Memory); i += 32 { From 7f7fa8940e1479c22ea5e7b6b873ea8fbe56f80a Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 12 Jul 2023 10:05:34 +0000 Subject: [PATCH 2/3] eth/tracers: return data as simple hex string --- eth/tracers/logger/logger.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index ff99c485a196..c7d74900330d 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -418,7 +418,7 @@ type StructLogRes struct { Depth int `json:"depth"` Error string `json:"error,omitempty"` Stack *[]string `json:"stack,omitempty"` - ReturnData *[]string `json:"returnData,omitempty"` + ReturnData string `json:"returnData,omitempty"` Memory *[]string `json:"memory,omitempty"` Storage *map[string]string `json:"storage,omitempty"` RefundCounter uint64 `json:"refund,omitempty"` @@ -445,11 +445,7 @@ func formatLogs(logs []StructLog) []StructLogRes { formatted[index].Stack = &stack } if trace.ReturnData != nil { - rdata := make([]string, 0, (len(trace.ReturnData)+31)/32) - for i := 0; i+32 <= len(trace.ReturnData); i += 32 { - rdata = append(rdata, fmt.Sprintf("%x", trace.ReturnData[i:i+32])) - } - formatted[index].ReturnData = &rdata + formatted[index].ReturnData = fmt.Sprintf("%x", trace.ReturnData) } if trace.Memory != nil { memory := make([]string, 0, (len(trace.Memory)+31)/32) From feaaa74763a3ac25945b5a363e5398a164040afb Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Wed, 12 Jul 2023 15:11:45 +0200 Subject: [PATCH 3/3] prefix 0x --- eth/tracers/logger/logger.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth/tracers/logger/logger.go b/eth/tracers/logger/logger.go index c7d74900330d..4c9b910a27f1 100644 --- a/eth/tracers/logger/logger.go +++ b/eth/tracers/logger/logger.go @@ -444,8 +444,8 @@ func formatLogs(logs []StructLog) []StructLogRes { } formatted[index].Stack = &stack } - if trace.ReturnData != nil { - formatted[index].ReturnData = fmt.Sprintf("%x", trace.ReturnData) + if trace.ReturnData != nil && len(trace.ReturnData) > 0 { + formatted[index].ReturnData = hexutil.Bytes(trace.ReturnData).String() } if trace.Memory != nil { memory := make([]string, 0, (len(trace.Memory)+31)/32)