From 02cea2330d6b4822b43a7fbaeacc12ddc8e8b1db Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 26 Jun 2020 10:19:31 +0000 Subject: [PATCH] eth: returned revert reason in traceTx (#21195) * eth: returned revert reason in traceTx * eth: return result data --- eth/api_tracer.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/eth/api_tracer.go b/eth/api_tracer.go index 68a61bea0..125c6fd70 100644 --- a/eth/api_tracer.go +++ b/eth/api_tracer.go @@ -765,10 +765,15 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v // Depending on the tracer type, format and return the output switch tracer := tracer.(type) { case *vm.StructLogger: + // If the result contains a revert reason, return it. + returnVal := fmt.Sprintf("%x", result.Return()) + if len(result.Revert()) > 0 { + returnVal = fmt.Sprintf("%x", result.Revert()) + } return ðapi.ExecutionResult{ Gas: result.UsedGas, Failed: result.Failed(), - ReturnValue: fmt.Sprintf("%x", result.Return()), + ReturnValue: returnVal, StructLogs: ethapi.FormatLogs(tracer.StructLogs()), }, nil