@@ -15,43 +15,23 @@ import (
15
15
16
16
var (
17
17
_ sdk.AnteDecorator = EthMinGasPriceDecorator {}
18
- _ sdk.AnteDecorator = EthMempoolFeeDecorator {}
19
18
)
20
19
21
20
// EthMinGasPriceDecorator will check if the transaction's fee is at least as large
22
21
// as the MinGasPrices param. If fee is too low, decorator returns error and tx
23
22
// is rejected. This applies to both CheckTx and DeliverTx and regardless
24
- // if London hard fork or fee market params (EIP-1559) are enabled.
23
+ // fee market params (EIP-1559) are enabled.
25
24
// If fee is high enough, then call next AnteHandler
26
25
type EthMinGasPriceDecorator struct {
27
26
AppKeepers
28
27
}
29
28
30
- // EthMempoolFeeDecorator will check if the transaction's effective fee is at
31
- // least as large as the local validator's minimum gasFee (defined in validator
32
- // config).
33
- // If fee is too low, decorator returns error and tx is rejected from mempool.
34
- // Note this only applies when ctx.CheckTx = true
35
- // If fee is high enough or not CheckTx, then call next AnteHandler
36
- // CONTRACT: Tx must implement FeeTx to use MempoolFeeDecorator
37
- type EthMempoolFeeDecorator struct {
38
- AppKeepers
39
- }
40
-
41
29
// NewEthMinGasPriceDecorator creates a new MinGasPriceDecorator instance used only for
42
30
// Ethereum transactions.
43
31
func NewEthMinGasPriceDecorator (k AppKeepers ) EthMinGasPriceDecorator {
44
32
return EthMinGasPriceDecorator {AppKeepers : k }
45
33
}
46
34
47
- // NewEthMempoolFeeDecorator creates a new NewEthMempoolFeeDecorator instance used only for
48
- // Ethereum transactions.
49
- func NewEthMempoolFeeDecorator (k AppKeepers ) EthMempoolFeeDecorator {
50
- return EthMempoolFeeDecorator {
51
- AppKeepers : k ,
52
- }
53
- }
54
-
55
35
// AnteHandle ensures that the effective fee from the transaction is greater than the
56
36
// minimum global fee, which is defined by the MinGasPrice (parameter) * GasLimit (tx argument).
57
37
func (empd EthMinGasPriceDecorator ) AnteHandle (
@@ -67,9 +47,7 @@ func (empd EthMinGasPriceDecorator) AnteHandle(
67
47
return next (ctx , tx , simulate )
68
48
}
69
49
70
- chainCfg := evmParams .GetChainConfig ()
71
- ethCfg := chainCfg .EthereumConfig (empd .EvmKeeper .EthChainID (ctx ))
72
- baseFee := empd .EvmKeeper .GetBaseFee (ctx , ethCfg )
50
+ baseFee := empd .EvmKeeper .GetBaseFee (ctx )
73
51
74
52
for _ , msg := range tx .GetMsgs () {
75
53
ethMsg , ok := msg .(* evm.MsgEthereumTx )
@@ -117,47 +95,3 @@ func (empd EthMinGasPriceDecorator) AnteHandle(
117
95
118
96
return next (ctx , tx , simulate )
119
97
}
120
-
121
- // AnteHandle ensures that the provided fees meet a minimum threshold for the validator.
122
- // This check only for local mempool purposes, and thus it is only run on (Re)CheckTx.
123
- // The logic is also skipped if the London hard fork and EIP-1559 are enabled.
124
- func (mfd EthMempoolFeeDecorator ) AnteHandle (
125
- ctx sdk.Context , tx sdk.Tx , simulate bool , next sdk.AnteHandler ,
126
- ) (newCtx sdk.Context , err error ) {
127
- if ! ctx .IsCheckTx () || simulate {
128
- return next (ctx , tx , simulate )
129
- }
130
- evmParams := mfd .EvmKeeper .GetParams (ctx )
131
- chainCfg := evmParams .GetChainConfig ()
132
- ethCfg := chainCfg .EthereumConfig (mfd .EvmKeeper .EthChainID (ctx ))
133
-
134
- baseFee := mfd .EvmKeeper .GetBaseFee (ctx , ethCfg )
135
- // skip check as the London hard fork and EIP-1559 are enabled
136
- if baseFee != nil {
137
- return next (ctx , tx , simulate )
138
- }
139
-
140
- evmDenom := evmParams .GetEvmDenom ()
141
- minGasPrice := ctx .MinGasPrices ().AmountOf (evmDenom )
142
-
143
- for _ , msg := range tx .GetMsgs () {
144
- ethMsg , ok := msg .(* evm.MsgEthereumTx )
145
- if ! ok {
146
- return ctx , errors .Wrapf (errortypes .ErrUnknownRequest , "invalid message type %T, expected %T" , msg , (* evm .MsgEthereumTx )(nil ))
147
- }
148
-
149
- fee := sdk .NewDecFromBigInt (ethMsg .GetFee ())
150
- gasLimit := sdk .NewDecFromBigInt (new (big.Int ).SetUint64 (ethMsg .GetGas ()))
151
- requiredFee := minGasPrice .Mul (gasLimit )
152
-
153
- if fee .LT (requiredFee ) {
154
- return ctx , errors .Wrapf (
155
- errortypes .ErrInsufficientFee ,
156
- "insufficient fee; got: %s required: %s" ,
157
- fee , requiredFee ,
158
- )
159
- }
160
- }
161
-
162
- return next (ctx , tx , simulate )
163
- }
0 commit comments