diff --git a/x/evm/keeper/integration_test.go b/x/evm/keeper/integration_test.go index cc65dcbebb..96aa1c803d 100644 --- a/x/evm/keeper/integration_test.go +++ b/x/evm/keeper/integration_test.go @@ -255,8 +255,6 @@ func prepareEthTx(priv *ethsecp256k1.PrivKey, msgEthereumTx *evmtypes.MsgEthereu err = msgEthereumTx.Sign(s.ethSigner, tests.NewSigner(priv)) s.Require().NoError(err) - // A valid msg should have empty `From` - msgEthereumTx.From = "" err = txBuilder.SetMsgs(msgEthereumTx) s.Require().NoError(err) diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 8bd40f5f4c..ba2f64ecc1 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -171,6 +171,11 @@ func (msg MsgEthereumTx) ValidateBasic() error { return sdkerrors.Wrap(err, "failed to unpack tx data") } + // prevent txs with 0 gas to fill up the mempool + if txData.GetGas() == 0 { + return sdkerrors.Wrap(ErrInvalidGasLimit, "gas limit must not be zero") + } + return txData.Validate() } diff --git a/x/evm/types/msg_test.go b/x/evm/types/msg_test.go index 7fe6f3c91f..5556592d19 100644 --- a/x/evm/types/msg_test.go +++ b/x/evm/types/msg_test.go @@ -375,7 +375,7 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_ValidateBasic() { for i, tc := range testCases { to := common.HexToAddress(tc.from) - tx := types.NewTx(tc.chainID, 1, &to, tc.amount, 1000, tc.gasPrice, tc.gasFeeCap, tc.gasTipCap, nil, tc.accessList) + tx := types.NewTx(tc.chainID, 1, &to, tc.amount, tc.gasLimit, tc.gasPrice, tc.gasFeeCap, tc.gasTipCap, nil, tc.accessList) tx.From = tc.from // apply nil assignment here to test ValidateBasic function instead of NewTx