evm: update error format (#350)

* return geth error format

* fix format in gasestimate

* deal with other evm errors

* fix import

* fix lint

* add test

Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
Thomas Nguy
2021-07-28 15:50:05 +00:00
committed by GitHub
co-authored by Federico Kunze Küllmer
parent 695027cb2a
commit 63aa0de1e8
4 changed files with 92 additions and 17 deletions
+7 -10
View File
@@ -8,6 +8,10 @@ import (
"math/big"
"strings"
"github.com/ethereum/go-ethereum/core/vm"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/pkg/errors"
"github.com/spf13/viper"
"github.com/tendermint/tendermint/libs/log"
@@ -26,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/tharsis/ethermint/crypto/hd"
@@ -559,18 +562,12 @@ func (e *PublicAPI) doCall(
if err != nil {
return nil, err
}
if len(res.VmError) > 0 {
if res.VmError == vm.ErrExecutionReverted.Error() {
return nil, evmtypes.NewExecErrorWithReason(res.Ret)
}
return nil, errors.New(res.VmError)
}
if res.Failed() {
if res.VmError == vm.ErrExecutionReverted.Error() {
return nil, evmtypes.NewExecErrorWithReason(res.Ret)
if res.VmError != vm.ErrExecutionReverted.Error() {
return nil, status.Error(codes.Internal, res.VmError)
}
return nil, errors.New(res.VmError)
return nil, evmtypes.NewExecErrorWithReason(res.Ret)
}
return res, nil