Skip to content

Commit

Permalink
Handle callTracer undefined variable error
Browse files Browse the repository at this point in the history
  • Loading branch information
jenikd committed Aug 11, 2023
1 parent 01c83ce commit cd63cb0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"math/big"
"runtime"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -2175,8 +2176,20 @@ func (api *PublicDebugAPI) traceTx(ctx context.Context, message evmcore.Message,
}, nil

case *tracers.Tracer:
return tracer.GetResult()

result, err := tracer.GetResult()
if err != nil && result == nil {
// Only for tracer called callTracer
if config.Tracer != nil && strings.Compare(*config.Tracer, "callTracer") == 0 {
if strings.Contains(err.Error(), "cannot read property 'toString' of undefined") {
log.Debug("error when debug with callTracer", "err", err.Error())
callTracer, _ := tracers.New(*config.Tracer, txctx)
callTracer.CaptureStart(vmenv, message.From(), *message.To(), false, message.Data(), message.Gas(), message.Value())
callTracer.CaptureEnd([]byte{}, message.Gas(), time.Duration(0), fmt.Errorf("execution reverted"))
result, err = callTracer.GetResult()
}
}
}
return result, err
default:
panic(fmt.Sprintf("bad tracer type %T", tracer))
}
Expand Down

0 comments on commit cd63cb0

Please sign in to comment.