From 1a5b64d13484cb7d8061ab2b4aeb7e94c5b25c3e Mon Sep 17 00:00:00 2001 From: yihuang Date: Fri, 2 Sep 2022 09:34:05 +0800 Subject: [PATCH] Change the fallback priority mechanism to be based on gas price (#1289) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change the fallback priority mechanism to be based on gas price * Update CHANGELOG.md Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Freddy Caceres --- CHANGELOG.md | 1 + app/ante/fee_checker.go | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 999e7ad99b..df407499a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (feemarket) [\#1165](https://github.com/evmos/ethermint/pull/1165) Add hint in specs about different gas terminology for gas in Cosmos and Ethereum. * (cli) [#1226](https://github.com/evmos/ethermint/pull/1226) Add custom app db backend flag. * (cli) [#1230](https://github.com/evmos/ethermint/pull/1230) Remove redundant positional height parameter from feemarket's query cli. +* (ante) [#1289](https://github.com/evmos/ethermint/pull/1289) Change the fallback tx priority mechanism to be based on gas price. * (test) [#1311](https://github.com/evmos/ethermint/pull/1311) add integration test for the rollback cmd ### Bug Fixes diff --git a/app/ante/fee_checker.go b/app/ante/fee_checker.go index ddda034519..7d9a9ea97d 100644 --- a/app/ante/fee_checker.go +++ b/app/ante/fee_checker.go @@ -116,17 +116,18 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.FeeTx) (sdk.Coi } } - priority := getTxPriority(feeCoins) + priority := getTxPriority(feeCoins, int64(gas)) return feeCoins, priority, nil } -// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the fee +// getTxPriority returns a naive tx priority based on the amount of the smallest denomination of the gas price // provided in a transaction. -func getTxPriority(fees sdk.Coins) int64 { +func getTxPriority(fees sdk.Coins, gas int64) int64 { var priority int64 for _, fee := range fees { - amt := fee.Amount.Quo(types.DefaultPriorityReduction) + gasPrice := fee.Amount.QuoRaw(gas) + amt := gasPrice.Quo(types.DefaultPriorityReduction) p := int64(math.MaxInt64) if amt.IsInt64() {