From 92bee6b03756c6edc07d59194333218dec08d918 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Fri, 15 May 2020 10:06:23 +0200 Subject: [PATCH] internal/ethapi: check if require reason can be unpacked --- accounts/abi/bind/backends/simulated.go | 4 ++-- internal/ethapi/api.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 90c74ce7a6..a74dad67ed 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -361,7 +361,7 @@ func (b *SimulatedBackend) CallContract(ctx context.Context, call ethereum.CallM return nil, err } // If the result contains a revert reason, unpack and return it. - if res.Err != nil { + if res.Err != nil && len(res.Revert()) > 0 { reason, err := abi.UnpackRevert(res.Revert()) if err != nil { return nil, err @@ -382,7 +382,7 @@ func (b *SimulatedBackend) PendingCallContract(ctx context.Context, call ethereu return nil, err } // If the result contains a revert reason, unpack and return it. - if res.Err != nil { + if res.Err != nil && len(res.Revert()) > 0 { reason, err := abi.UnpackRevert(res.Revert()) if err != nil { return nil, err diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 2034f75eea..e49e2e136a 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -862,7 +862,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout) } // If the result contains a revert reason, unpack and return it. - if result.Err != nil { + if result.Err != nil && len(result.Revert()) > 0 { reason, err := abi.UnpackRevert(result.Revert()) if err != nil { return nil, err