@@ -25,6 +25,7 @@ import (
25
25
"github.com/cosmos/cosmos-sdk/x/auth/ante"
26
26
"github.com/cosmos/cosmos-sdk/x/auth/signing"
27
27
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
28
+ "github.com/ethereum/go-ethereum/core/txpool"
28
29
)
29
30
30
31
var (
@@ -88,6 +89,42 @@ func (msg MsgEthereumTx) ValidateBasic() error {
88
89
return errorsmod .Wrapf (errortypes .ErrInvalidRequest , "raw transaction is required" )
89
90
}
90
91
92
+ tx := msg .Raw .Transaction
93
+
94
+ // validate the transaction
95
+ // Transactions can't be negative. This may never happen using RLP decoded
96
+ // transactions but may occur for transactions created using the RPC.
97
+ if tx .Value ().Sign () < 0 {
98
+ return txpool .ErrNegativeValue
99
+ }
100
+ // Sanity check for extremely large numbers (supported by RLP or RPC)
101
+ if tx .GasFeeCap ().BitLen () > 256 {
102
+ return core .ErrFeeCapVeryHigh
103
+ }
104
+ if tx .GasTipCap ().BitLen () > 256 {
105
+ return core .ErrTipVeryHigh
106
+ }
107
+ if tx .GasTipCap ().Sign () < 0 {
108
+ return fmt .Errorf ("%w: gas tip cap %v, minimum needed 0" , txpool .ErrTxGasPriceTooLow , tx .GasTipCap ())
109
+ }
110
+ // Ensure gasFeeCap is greater than or equal to gasTipCap
111
+ if tx .GasFeeCapIntCmp (tx .GasTipCap ()) < 0 {
112
+ return core .ErrTipAboveFeeCap
113
+ }
114
+
115
+ intrGas , err := core .IntrinsicGas (tx .Data (), tx .AccessList (), tx .SetCodeAuthorizations (), tx .To () == nil , true , true , true )
116
+ if err != nil {
117
+ return err
118
+ }
119
+ if tx .Gas () < intrGas {
120
+ return fmt .Errorf ("%w: gas %v, minimum needed %v" , core .ErrIntrinsicGas , tx .Gas (), intrGas )
121
+ }
122
+
123
+ if tx .Type () == ethtypes .SetCodeTxType {
124
+ if len (tx .SetCodeAuthorizations ()) == 0 {
125
+ return fmt .Errorf ("set code tx must have at least one authorization tuple" )
126
+ }
127
+ }
91
128
return nil
92
129
}
93
130
@@ -151,7 +188,9 @@ func (msg MsgEthereumTx) GetFee() *big.Int {
151
188
152
189
// GetEffectiveFee returns the fee for dynamic fee tx
153
190
func (msg MsgEthereumTx ) GetEffectiveFee (baseFee * big.Int ) * big.Int {
154
- return new (big.Int ).Add (msg .Raw .EffectiveGasTipValue (baseFee ), baseFee )
191
+ i := new (big.Int ).SetUint64 (msg .Raw .Gas ())
192
+ effectiveGasPrice := new (big.Int ).Add (msg .Raw .EffectiveGasTipValue (baseFee ), baseFee )
193
+ return i .Mul (i , effectiveGasPrice )
155
194
}
156
195
157
196
// GetFrom loads the ethereum sender address from the sigcache and returns an
0 commit comments