Skip to content

Commit 02cea23

Browse files
eth: returned revert reason in traceTx (#21195)
* eth: returned revert reason in traceTx * eth: return result data
1 parent 413358a commit 02cea23

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎eth/api_tracer.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,15 @@ func (api *PrivateDebugAPI) traceTx(ctx context.Context, message core.Message, v
765765
// Depending on the tracer type, format and return the output
766766
switch tracer := tracer.(type) {
767767
case *vm.StructLogger:
768+
// If the result contains a revert reason, return it.
769+
returnVal := fmt.Sprintf("%x", result.Return())
770+
if len(result.Revert()) > 0 {
771+
returnVal = fmt.Sprintf("%x", result.Revert())
772+
}
768773
return &ethapi.ExecutionResult{
769774
Gas: result.UsedGas,
770775
Failed: result.Failed(),
771-
ReturnValue: fmt.Sprintf("%x", result.Return()),
776+
ReturnValue: returnVal,
772777
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
773778
}, nil
774779

0 commit comments

Comments
 (0)