Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Change the fallback priority mechanism to be based on gas price #1289

Merged
merged 5 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,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) [#]() Change the fallback priority mechanism to be based on gas price.
fedekunze marked this conversation as resolved.
Show resolved Hide resolved

### Bug Fixes

Expand Down
9 changes: 5 additions & 4 deletions app/ante/fee_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down