@@ -102,7 +102,7 @@ func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) { //nolint:
102102 k .foundSuggestionGasPrice (ctx )
103103}
104104
105- func (k Keeper ) foundSuggestionGasPrice (ctx sdk.Context ) {
105+ func (k * Keeper ) foundSuggestionGasPrice (ctx sdk.Context ) {
106106 logger := k .Logger (ctx )
107107 var maxBlockGas uint64
108108 if b := ctx .ConsensusParams ().Block ; b != nil {
@@ -153,30 +153,37 @@ func (k Keeper) foundSuggestionGasPrice(ctx sdk.Context) {
153153 }
154154 }
155155 }
156- } else {
157- // ignore multisig case now
158- if fee , ok := memTx .(sdk.FeeTx ); ok {
159- if len (sigs ) == 1 {
160- signer := sdk .AccAddress (sigs [0 ].PubKey .Address ()).String ()
161-
162- if _ , exists := txnInfoMap [signer ]; ! exists {
163- txnInfoMap [signer ] = make ([]* txnInfo , 0 , 16 )
164- }
165-
166- evmGasPrice , err := utilCosmosDemonGasPriceToEvmDemonGasPrice (fee .GetFee ())
167-
168- if err == nil {
169- txnInfoMap [signer ] = append (txnInfoMap [signer ], & txnInfo {
170- gasPrice : evmGasPrice ,
171- gasLimit : utilCosmosDemonGasLimitToEvmDemonGasLimit (fee .GetGas ()),
172- nonce : sigs [0 ].Sequence ,
173- sender : signer ,
174- })
175- }
176- }
177- } else {
178- logger .Error ("unknown type of memTx: " , "type" , reflect .TypeOf (memTx ))
179- }
156+ // ignore cosmos txn case now
157+ // } else {
158+ // // ignore multisig case now
159+ // if fee, ok := memTx.(sdk.FeeTx); ok {
160+ // feeCoins := fee.GetFee()
161+ // if len(feeCoins) != 0 {
162+ // if len(sigs) == 1 {
163+ // signer := sdk.AccAddress(sigs[0].PubKey.Address()).String()
164+
165+ // if _, exists := txnInfoMap[signer]; !exists {
166+ // txnInfoMap[signer] = make([]*txnInfo, 0, 16)
167+ // }
168+
169+ // gasPrice := sdk.NewDecCoinsFromCoins(fee.GetFee()...).QuoDec(math.LegacyNewDec(int64(fee.GetGas())))
170+
171+ // evmGasPrice, err := utilCosmosDemonGasPriceToEvmDemonGasPrice(gasPrice)
172+ // evmGasLimit := utilCosmosDemonGasLimitToEvmDemonGasLimit(fee.GetGas())
173+
174+ // if err == nil {
175+ // txnInfoMap[signer] = append(txnInfoMap[signer], &txnInfo{
176+ // gasPrice: evmGasPrice,
177+ // gasLimit: evmGasLimit,
178+ // nonce: sigs[0].Sequence,
179+ // sender: signer,
180+ // })
181+ // }
182+ // }
183+ // }
184+ // } else {
185+ // logger.Error("unknown type of memTx: ", "type", reflect.TypeOf(memTx))
186+ // }
180187 }
181188
182189 iterator = iterator .Next ()
@@ -246,13 +253,12 @@ func (k Keeper) foundSuggestionGasPrice(ctx sdk.Context) {
246253 }
247254}
248255
249- func utilCosmosDemonGasPriceToEvmDemonGasPrice (gasGroup sdk.Coins ) (* big.Int , error ) {
256+ func utilCosmosDemonGasPriceToEvmDemonGasPrice (gasGroup sdk.DecCoins ) (* big.Int , error ) {
250257 gasPrice := big .NewInt (0 )
251258 for _ , coin := range gasGroup {
252259 if coin .Denom == GasDenom {
253- thisGasPrice := big .NewInt (0 ).SetUint64 (coin .Amount .Uint64 ())
254- thisGasPrice = thisGasPrice .Mul (thisGasPrice , big .NewInt (0 ).SetInt64 (GasDenomConversionMultiplier ))
255- gasPrice = gasPrice .Add (gasPrice , thisGasPrice )
260+ thisGasPrice := coin .Amount .MulRoundUp (sdk .NewDec (GasDenomConversionMultiplier ))
261+ gasPrice = gasPrice .Add (gasPrice , thisGasPrice .TruncateInt ().BigInt ())
256262 } else {
257263 return big .NewInt (0 ), fmt .Errorf ("invalid denom: %s" , coin .Denom )
258264 }
0 commit comments