Skip to content

Commit

Permalink
reflect no mo
Browse files Browse the repository at this point in the history
  • Loading branch information
spoo-bar committed Oct 9, 2023
1 parent 0b21325 commit 5139235
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
12 changes: 4 additions & 8 deletions x/rewards/keeper/min_cons_fee.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package keeper

import (
"reflect"
"strings"
"math"

sdk "github.com/cosmos/cosmos-sdk/types"

Expand All @@ -17,22 +16,19 @@ func (k Keeper) UpdateMinConsensusFee(ctx sdk.Context, inflationRewards sdk.Coin
k.Logger(ctx).Info("Minimum consensus fee update skipped: inflation rewards are zero")
return
}

inflationRewardsAmt := sdk.NewDecFromInt(inflationRewards.Amount)

blockGasLimit := ctx.BlockGasMeter().Limit()
if strings.Contains(reflect.TypeOf(ctx.BlockGasMeter()).String(), "infiniteGasMeter") { // Because thisss https://github.com/cosmos/cosmos-sdk/pull/9651
blockGasLimit = 0
}

blockGasLimitAsDec := pkg.NewDecFromUint64(blockGasLimit)
if blockGasLimitAsDec.IsZero() {
if blockGasLimit == math.MaxUint64 { // Because thisss https://github.com/cosmos/cosmos-sdk/pull/9651
k.Logger(ctx).Info("Minimum consensus fee update skipped: block gas limit is not set")
return
}

txFeeRebateRatio := k.TxFeeRebateRatio(ctx)

// Calculate
blockGasLimitAsDec := pkg.NewDecFromUint64(blockGasLimit)
feeAmt := calculateMinConsensusFeeAmt(inflationRewardsAmt, blockGasLimitAsDec, txFeeRebateRatio)
if feeAmt.IsZero() || feeAmt.IsNegative() {
k.Logger(ctx).Info("Minimum consensus fee update skipped: calculated amount is zero or bellow zero")
Expand Down
5 changes: 2 additions & 3 deletions x/rewards/keeper/tracking.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package keeper

import (
"reflect"
"strings"
"math"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -22,7 +21,7 @@ func (k Keeper) TrackFeeRebatesRewards(ctx sdk.Context, rewards sdk.Coins) {
// TrackInflationRewards creates a new inflation reward record for the current block.
func (k Keeper) TrackInflationRewards(ctx sdk.Context, rewards sdk.Coin) {
blockGasLimit := ctx.BlockGasMeter().Limit()
if strings.Contains(reflect.TypeOf(ctx.BlockGasMeter()).String(), "infiniteGasMeter") { // Because thisss https://github.com/cosmos/cosmos-sdk/pull/9651
if ctx.BlockGasMeter().Limit() == math.MaxUint64 { // Because thisss https://github.com/cosmos/cosmos-sdk/pull/9651
blockGasLimit = 0
}

Expand Down

0 comments on commit 5139235

Please sign in to comment.