From bb2418bf73595c0f264759c4f75369099a626fc8 Mon Sep 17 00:00:00 2001 From: yihuang Date: Thu, 14 Sep 2023 17:14:31 +0800 Subject: [PATCH] Problem: performance regression because of un-cached sender recovery (#350) Solution: - re-order ante handlers, use cached from address --- app/ante/handler_options.go | 4 ++-- x/evm/types/msg.go | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 27fc59635a..1b0bcee134 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -73,9 +73,9 @@ func newEthAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.Ante NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice NewEthValidateBasicDecorator(options.EvmKeeper), - extra, NewEthSigVerificationDecorator(options.EvmKeeper), NewEthAccountVerificationDecorator(options.AccountKeeper, options.EvmKeeper), + extra, NewCanTransferDecorator(options.EvmKeeper), NewEthGasConsumeDecorator(options.EvmKeeper, options.MaxTxGasWanted), NewEthIncrementSenderSequenceDecorator(options.AccountKeeper), // innermost AnteDecorator. @@ -92,7 +92,6 @@ func newCosmosAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.A ante.NewSetUpContextDecorator(), ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), ante.NewValidateBasicDecorator(), - extra, ante.NewTxTimeoutHeightDecorator(), NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), ante.NewValidateMemoDecorator(options.AccountKeeper), @@ -103,6 +102,7 @@ func newCosmosAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.A ante.NewValidateSigCountDecorator(options.AccountKeeper), ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), ante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + extra, ante.NewIncrementSequenceDecorator(options.AccountKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), NewGasWantedDecorator(options.EvmKeeper, options.FeeMarketKeeper), diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 71164c593e..3d29b595d2 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -225,6 +225,10 @@ func (msg *MsgEthereumTx) GetMsgs() []sdk.Msg { // // NOTE: This method panics if 'Sign' hasn't been called first. func (msg *MsgEthereumTx) GetSigners() []sdk.AccAddress { + if len(msg.From) > 0 { + return []sdk.AccAddress{common.HexToAddress(msg.From).Bytes()} + } + data, err := UnpackTxData(msg.Data) if err != nil { panic(err)