From 5139235b38589d81c0deb58f0c11c73c9dfcbd23 Mon Sep 17 00:00:00 2001 From: Spoorthi Satheesha <9302666+spoo-bar@users.noreply.github.com> Date: Mon, 9 Oct 2023 17:50:32 +0530 Subject: [PATCH] reflect no mo --- x/rewards/keeper/min_cons_fee.go | 12 ++++-------- x/rewards/keeper/tracking.go | 5 ++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/x/rewards/keeper/min_cons_fee.go b/x/rewards/keeper/min_cons_fee.go index a55f8b27..128c707a 100644 --- a/x/rewards/keeper/min_cons_fee.go +++ b/x/rewards/keeper/min_cons_fee.go @@ -1,8 +1,7 @@ package keeper import ( - "reflect" - "strings" + "math" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,15 +16,11 @@ 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 } @@ -33,6 +28,7 @@ func (k Keeper) UpdateMinConsensusFee(ctx sdk.Context, inflationRewards sdk.Coin 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") diff --git a/x/rewards/keeper/tracking.go b/x/rewards/keeper/tracking.go index 31bf2df3..1f9f2849 100644 --- a/x/rewards/keeper/tracking.go +++ b/x/rewards/keeper/tracking.go @@ -1,8 +1,7 @@ package keeper import ( - "reflect" - "strings" + "math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -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 }