From a031f9abcad3eb0a22258a6f485cecc61af94737 Mon Sep 17 00:00:00 2001 From: i-norden Date: Tue, 1 Mar 2022 08:20:49 -0600 Subject: [PATCH] fixes --- app/ante/ante.go | 2 +- app/ante/eth.go | 5 +++-- app/app.go | 45 +++++++++++++++++++++++++++++++++++-------- x/evm/keeper/utils.go | 2 +- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/app/ante/ante.go b/app/ante/ante.go index bb051744..54d89b15 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -11,9 +11,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" - authante "github.com/cosmos/cosmos-sdk/x/auth/ante" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authante "github.com/tharsis/ethermint/x/auth/ante" channelkeeper "github.com/cosmos/ibc-go/modules/core/04-channel/keeper" ibcante "github.com/cosmos/ibc-go/modules/core/ante" diff --git a/app/ante/eth.go b/app/ante/eth.go index 6043f0e4..8b5d35ac 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -4,9 +4,10 @@ import ( "errors" "math/big" + authante "github.com/tharsis/ethermint/x/auth/ante" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/palantir/stacktrace" ethermint "github.com/tharsis/ethermint/types" @@ -28,7 +29,7 @@ type EVMKeeper interface { GetParams(ctx sdk.Context) evmtypes.Params WithContext(ctx sdk.Context) ResetRefundTransient(ctx sdk.Context) - NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.Tracer) *vm.EVM + NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.EVMLogger) *vm.EVM GetCodeHash(addr common.Address) common.Hash } diff --git a/app/app.go b/app/app.go index d9553ff7..335c0cb6 100644 --- a/app/app.go +++ b/app/app.go @@ -3,6 +3,8 @@ package app import ( "encoding/json" + "github.com/cosmos/cosmos-sdk/server" + "github.com/cosmos/cosmos-sdk/db" types2 "github.com/cosmos/cosmos-sdk/store/types" types3 "github.com/cosmos/cosmos-sdk/store/v2" @@ -101,7 +103,6 @@ import ( // unnamed import of statik for swagger UI support _ "github.com/tharsis/ethermint/client/docs/statik" - "github.com/tharsis/ethermint/app/ante" srvflags "github.com/tharsis/ethermint/server/flags" ethermint "github.com/tharsis/ethermint/types" @@ -614,13 +615,8 @@ func NewEthermintApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) - // use Ethermint's custom AnteHandler - app.SetTxHandler( - ante.NewAnteHandler( - app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper, - encodingConfig.TxConfig.SignModeHandler(), - ), - ) + // TODO: use Ethermint's custom AnteHandler + app.setTxHandler(encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))) app.SetEndBlocker(app.EndBlocker) @@ -630,6 +626,39 @@ func NewEthermintApp( return app } +func (app *EthermintApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []string) { + indexEvents := map[string]struct{}{} + for _, e := range indexEventsStr { + indexEvents[e] = struct{}{} + } + // need to sub in custom tx handler + /* + app.SetTxHandler( + ante.NewAnteHandler( + app.AccountKeeper, app.BankKeeper, app.EvmKeeper, app.FeeGrantKeeper, app.IBCKeeper.ChannelKeeper, + encodingConfig.TxConfig.SignModeHandler(), + ), + ) + */ + txHandler, err := middleware.NewDefaultTxHandler(middleware.TxHandlerOptions{ + Debug: app.Trace(), + IndexEvents: indexEvents, + LegacyRouter: app.legacyRouter, + MsgServiceRouter: app.msgSvcRouter, + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + FeegrantKeeper: app.FeeGrantKeeper, + SignModeHandler: txConfig.SignModeHandler(), + SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, + TxDecoder: txConfig.TxDecoder(), + }) + if err != nil { + panic(err) + } + + app.SetTxHandler(txHandler) +} + // Name returns the name of the App func (app *EthermintApp) Name() string { return app.BaseApp.Name() } diff --git a/x/evm/keeper/utils.go b/x/evm/keeper/utils.go index 807458dc..fc9ff524 100644 --- a/x/evm/keeper/utils.go +++ b/x/evm/keeper/utils.go @@ -3,8 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - authante "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/palantir/stacktrace" + authante "github.com/tharsis/ethermint/x/auth/ante" evmtypes "github.com/tharsis/ethermint/x/evm/types"