Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
cherry pick #1174
Browse files Browse the repository at this point in the history
  • Loading branch information
danburck authored and fedekunze committed Aug 3, 2022
1 parent c1656ad commit 38c6958
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions x/evm/keeper/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions x/evm/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
2 changes: 1 addition & 1 deletion x/evm/types/msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38c6958

Please sign in to comment.