From fd70cfe87ad5dfeb1b0b75d49bba5e7ada694f80 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 14 May 2020 13:32:45 +0200 Subject: [PATCH] internal/ethapi: return revert reason for eth_call --- internal/ethapi/api.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index a572e4081c..15a06e541c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -861,6 +861,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo if evm.Cancelled() { return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout) } + return result, err } @@ -879,6 +880,13 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr if err != nil { return nil, err } + if result.Err != nil { + reason, err := abi.UnpackRevert(result.Revert()) + if err != nil { + return result.Return(), err + } + return result.Return(), errors.New(reason) + } return result.Return(), nil }