diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index 83b2862c2b..db2e211f67 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -20,6 +20,7 @@ import ( corestoretypes "cosmossdk.io/core/store" "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -40,6 +41,7 @@ type Keeper struct { transientKey storetypes.StoreKey // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority sdk.AccAddress + maxGas sdkmath.Int } // NewKeeper generates new fee market module keeper @@ -54,12 +56,16 @@ func NewKeeper( panic(err) } + maxValue := new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(sdkmath.MaxBitLen), nil), big.NewInt(1)) + maxInt := sdkmath.NewIntFromBigInt(maxValue) + return Keeper{ cdc: cdc, storeService: storeService, storeKey: storeKey, authority: authority, transientKey: transientKey, + maxGas: maxInt, } } diff --git a/x/feemarket/keeper/params.go b/x/feemarket/keeper/params.go index eab87a3945..6cd70faeb9 100644 --- a/x/feemarket/keeper/params.go +++ b/x/feemarket/keeper/params.go @@ -71,7 +71,11 @@ func (k Keeper) GetBaseFee(ctx sdk.Context) *big.Int { // SetBaseFee set's the base fee in the store func (k Keeper) SetBaseFee(ctx sdk.Context, baseFee *big.Int) { params := k.GetParams(ctx) - params.BaseFee = sdkmath.NewIntFromBigInt(baseFee) + if baseFee.BitLen() > sdkmath.MaxBitLen { + params.BaseFee = k.maxGas + } else { + params.BaseFee = sdkmath.NewIntFromBigInt(baseFee) + } err := k.SetParams(ctx, params) if err != nil { return