diff --git a/app/ante/eth.go b/app/ante/eth.go index f2b62a896a..fad0aab1a4 100644 --- a/app/ante/eth.go +++ b/app/ante/eth.go @@ -65,6 +65,8 @@ func (esvd EthSigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, s err.Error(), ) } + + // set up the sender to the transaction field if not already msgEthTx.From = sender.Hex() } @@ -421,23 +423,18 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu baseFee := vbd.evmKeeper.GetBaseFee(ctx, ethCfg) for _, msg := range protoTx.GetMsgs() { + if err := msg.ValidateBasic(); err != nil { + return ctx, sdkerrors.Wrap(err, "msg basic validation failed") + } + msgEthTx, ok := msg.(*evmtypes.MsgEthereumTx) if !ok { return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid message type %T, expected %T", msg, (*evmtypes.MsgEthereumTx)(nil)) } - // Validate Size_ field, should be kept empty - if msgEthTx.Size_ != 0 { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "dirty tx size field %f, expected: 0", msgEthTx.Size_) - } - // Validate Hash field - expHash := msgEthTx.AsTransaction().Hash().Hex() - if msgEthTx.Hash != expHash { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid tx hash %s, expected: %s", msgEthTx.Hash, expHash) - } // Validate `From` field if msgEthTx.From != "" { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid From %s, expect empty string", msgEthTx.From) + return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid From %s, expect empty string", msgEthTx.From) } txGasLimit += msgEthTx.GetGas() @@ -482,6 +479,8 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu if len(sigs) > 0 { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "for eth tx Signatures should be empty") } + } else { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "invalid tx type %T, didn't implement interface protoTxProvider", tx) } return next(ctx, tx, simulate) diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 1b5e9fe1f7..85c3398981 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -165,6 +165,17 @@ func (msg MsgEthereumTx) ValidateBasic() error { } } + // Validate Size_ field, should be kept empty + if msg.Size_ != 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "tx size is deprecated") + } + + // Validate Hash field + txHash := msg.AsTransaction().Hash().Hex() + if msg.Hash != txHash { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid tx hash %s, expected: %s", msg.Hash, txHash) + } + txData, err := UnpackTxData(msg.Data) if err != nil { return sdkerrors.Wrap(err, "failed to unpack tx data")