From 6a8ad576e1f2bb6d8b8da84ae8021b5841a4d8c6 Mon Sep 17 00:00:00 2001 From: dudong2 Date: Wed, 15 Nov 2023 15:42:50 +0900 Subject: [PATCH] Revert blocking list feature from "feat: support blocking list of addresses in mempool and disable vesting messages in check tx mode (#327)" This reverts commit 1533fc13a5f9102e121fd70527c81039e1b738af. --- app/ante/ante.go | 19 ++++--------------- app/ante/block_address.go | 31 ------------------------------- app/ante/eip712.go | 3 +-- app/ante/handler_options.go | 7 ++----- 4 files changed, 7 insertions(+), 53 deletions(-) delete mode 100644 app/ante/block_address.go diff --git a/app/ante/ante.go b/app/ante/ante.go index eba724e72a..952f1298c8 100644 --- a/app/ante/ante.go +++ b/app/ante/ante.go @@ -46,17 +46,6 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { return nil, err } - blacklist := make(map[string]struct{}, len(options.Blacklist)) - for _, str := range options.Blacklist { - addr, err := sdk.AccAddressFromBech32(str) - if err != nil { - return nil, fmt.Errorf("invalid bech32 address: %s, err: %w", str, err) - } - - blacklist[string(addr)] = struct{}{} - } - blockAddressDecorator := NewBlockAddressesDecorator(blacklist) - return func( ctx sdk.Context, tx sdk.Tx, sim bool, ) (newCtx sdk.Context, err error) { @@ -84,13 +73,13 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { switch typeURL := opts[0].GetTypeUrl(); typeURL { case "/ethermint.evm.v1.ExtensionOptionsEthereumTx": // handle as *evmtypes.MsgEthereumTx - anteHandler = newEthAnteHandler(options, blockAddressDecorator) + anteHandler = newEthAnteHandler(options) case "/ethermint.types.v1.ExtensionOptionsWeb3Tx": // Deprecated: Handle as normal Cosmos SDK tx, except signature is checked for Legacy EIP712 representation - anteHandler = NewLegacyCosmosAnteHandlerEip712(options, blockAddressDecorator) + anteHandler = NewLegacyCosmosAnteHandlerEip712(options) case "/ethermint.types.v1.ExtensionOptionDynamicFeeTx": // cosmos-sdk tx with dynamic fee extension - anteHandler = newCosmosAnteHandler(options, blockAddressDecorator) + anteHandler = newCosmosAnteHandler(options) default: return ctx, errorsmod.Wrapf( errortypes.ErrUnknownExtensionOptions, @@ -105,7 +94,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { // handle as totally normal Cosmos SDK tx switch tx.(type) { case sdk.Tx: - anteHandler = newCosmosAnteHandler(options, blockAddressDecorator) + anteHandler = newCosmosAnteHandler(options) default: return ctx, errorsmod.Wrapf(errortypes.ErrUnknownRequest, "invalid transaction type: %T", tx) } diff --git a/app/ante/block_address.go b/app/ante/block_address.go deleted file mode 100644 index b703d4c649..0000000000 --- a/app/ante/block_address.go +++ /dev/null @@ -1,31 +0,0 @@ -package ante - -import ( - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// BlockAddressesDecorator block addresses from sending transactions -type BlockAddressesDecorator struct { - blacklist map[string]struct{} -} - -func NewBlockAddressesDecorator(blacklist map[string]struct{}) BlockAddressesDecorator { - return BlockAddressesDecorator{ - blacklist: blacklist, - } -} - -func (bad BlockAddressesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { - if ctx.IsCheckTx() { - for _, msg := range tx.GetMsgs() { - for _, signer := range msg.GetSigners() { - if _, ok := bad.blacklist[string(signer)]; ok { - return ctx, fmt.Errorf("signer is blocked: %s", signer.String()) - } - } - } - } - return next(ctx, tx, simulate) -} diff --git a/app/ante/eip712.go b/app/ante/eip712.go index 4abe939ffb..92d767ecb8 100644 --- a/app/ante/eip712.go +++ b/app/ante/eip712.go @@ -50,14 +50,13 @@ func init() { // Deprecated: NewLegacyCosmosAnteHandlerEip712 creates an AnteHandler to process legacy EIP-712 // transactions, as defined by the presence of an ExtensionOptionsWeb3Tx extension. -func NewLegacyCosmosAnteHandlerEip712(options HandlerOptions, extra sdk.AnteDecorator) sdk.AnteHandler { +func NewLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler { return sdk.ChainAnteDecorators( RejectMessagesDecorator{}, // reject MsgEthereumTxs // disable the Msg types that cannot be included on an authz.MsgExec msgs field NewAuthzLimiterDecorator(options.DisabledAuthzMsgs), authante.NewSetUpContextDecorator(), authante.NewValidateBasicDecorator(), - extra, authante.NewTxTimeoutHeightDecorator(), NewMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), authante.NewValidateMemoDecorator(options.AccountKeeper), diff --git a/app/ante/handler_options.go b/app/ante/handler_options.go index 27fc59635a..14d97e5e7d 100644 --- a/app/ante/handler_options.go +++ b/app/ante/handler_options.go @@ -45,7 +45,6 @@ type HandlerOptions struct { ExtensionOptionChecker ante.ExtensionOptionChecker TxFeeChecker ante.TxFeeChecker DisabledAuthzMsgs []string - Blacklist []string } func (options HandlerOptions) validate() error { @@ -67,13 +66,12 @@ func (options HandlerOptions) validate() error { return nil } -func newEthAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.AnteHandler { +func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler { return sdk.ChainAnteDecorators( NewEthSetUpContextDecorator(options.EvmKeeper), // outermost AnteDecorator. SetUpContext must be called first 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), NewCanTransferDecorator(options.EvmKeeper), @@ -84,7 +82,7 @@ func newEthAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.Ante ) } -func newCosmosAnteHandler(options HandlerOptions, extra sdk.AnteDecorator) sdk.AnteHandler { +func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler { return sdk.ChainAnteDecorators( RejectMessagesDecorator{}, // reject MsgEthereumTxs // disable the Msg types that cannot be included on an authz.MsgExec msgs field @@ -92,7 +90,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),