From a1ab4df6759fe0ff6904a09e3e6cd44e8ab0b8a3 Mon Sep 17 00:00:00 2001 From: Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com> Date: Wed, 5 Jul 2023 22:17:38 -0400 Subject: [PATCH 1/2] bringing rewards to zero in upgrade handler --- x/jklmint/keeper/mint.go | 11 ++++++--- x/jklmint/keeper/mint_test.go | 41 ++++++++++++++++++++++++++++++++++ x/jklmint/legacy/v210/store.go | 2 ++ 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/x/jklmint/keeper/mint.go b/x/jklmint/keeper/mint.go index c94766a2d..e2487ed2f 100644 --- a/x/jklmint/keeper/mint.go +++ b/x/jklmint/keeper/mint.go @@ -10,12 +10,17 @@ import ( ) func (k Keeper) BlockMint(ctx sdk.Context) { - mintTokens := sdk.NewDec(6_000_000) + tokensPerBlock := k.GetParams(ctx).TokensPerBlock + + mintTokens := sdk.NewDec(tokensPerBlock * 1_000_000) denom := k.GetParams(ctx).MintDenom - providerRatio := sdk.NewDec(4) + pRatio := k.GetParams(ctx).ProviderRatio + valRatio := 10 - pRatio + + providerRatio := sdk.NewDec(pRatio) providerRatio = providerRatio.QuoInt64(10) - validatorRatio := sdk.NewDec(6) + validatorRatio := sdk.NewDec(valRatio) validatorRatio = validatorRatio.QuoInt64(10) // get correct ratio diff --git a/x/jklmint/keeper/mint_test.go b/x/jklmint/keeper/mint_test.go index 52d4f5289..f0e0d7b56 100644 --- a/x/jklmint/keeper/mint_test.go +++ b/x/jklmint/keeper/mint_test.go @@ -37,3 +37,44 @@ func (suite *MintTestSuite) TestBlockMint() { suite.Require().Equal(sdk.NewInt(6_000_000), supplyAfter.Supply.AmountOf(denom)) // After BlockMint we now have exactly 3.6JKL in the fee collector account } + +func (suite *MintTestSuite) TestNoProviderBlockMint() { + suite.SetupTest() + app, ctx, k := suite.app, suite.ctx, suite.app.MintKeeper + + params := k.GetParams(ctx) + params.ProviderRatio = 0 + k.SetParams(ctx, params) + + denom := k.GetParams(ctx).MintDenom + + pr := k.GetParams(ctx).ProviderRatio + suite.Require().Equal(int64(0), pr) + + feeAccount := app.AccountKeeper.GetModuleAccount(ctx, authtypes.FeeCollectorName) + feeBalanceBefore, err := app.BankKeeper.Balance(sdk.WrapSDKContext(ctx), &types.QueryBalanceRequest{ + Address: feeAccount.GetAddress().String(), + Denom: denom, + }) + suite.Require().NoError(err) + suite.Require().Equal(sdk.ZeroInt(), feeBalanceBefore.Balance.Amount) + supplyBefore, err := app.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &types.QueryTotalSupplyRequest{}) + suite.Require().NoError(err) + suite.Require().True(supplyBefore.Supply.Empty()) + // We have now proved we started with nothing + + k.BlockMint(ctx) + + feeBalanceAfter, err := app.BankKeeper.Balance(sdk.WrapSDKContext(ctx), &types.QueryBalanceRequest{ + Address: feeAccount.GetAddress().String(), + Denom: denom, + }) + + suite.Require().NoError(err) + suite.Require().Equal(sdk.NewInt(6_000_000), feeBalanceAfter.Balance.Amount) + supplyAfter, err := app.BankKeeper.TotalSupply(sdk.WrapSDKContext(ctx), &types.QueryTotalSupplyRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(1, len(supplyAfter.Supply)) + suite.Require().Equal(sdk.NewInt(6_000_000), supplyAfter.Supply.AmountOf(denom)) + // After BlockMint we now have exactly 3.6JKL in the fee collector account +} diff --git a/x/jklmint/legacy/v210/store.go b/x/jklmint/legacy/v210/store.go index 828386b7c..ac64c0f26 100644 --- a/x/jklmint/legacy/v210/store.go +++ b/x/jklmint/legacy/v210/store.go @@ -15,6 +15,8 @@ func MigrateStore(ctx sdk.Context, paramsSubspace *paramstypes.Subspace) error { // Set the module params params := types.DefaultParams() + params.ProviderRatio = 0 + paramsSubspace.SetParamSet(ctx, ¶ms) return nil From fb6e8c41bd74cbc93cab12b9ae9a58f7d26f8a44 Mon Sep 17 00:00:00 2001 From: Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:19:58 -0400 Subject: [PATCH 2/2] fixing upgrade handler --- app/app.go | 2 +- app/upgrades/v210/upgrades.go | 2 +- x/jklmint/types/params.go | 4 ++-- x/storage/types/params.go | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 3c1f3e3b9..6c0980936 100644 --- a/app/app.go +++ b/app/app.go @@ -795,6 +795,7 @@ func NewJackalApp( ) app.mm.SetOrderEndBlockers( + upgradetypes.ModuleName, crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName, @@ -809,7 +810,6 @@ func NewJackalApp( authz.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, - upgradetypes.ModuleName, vestingtypes.ModuleName, // additional non simd modules ibctransfertypes.ModuleName, diff --git a/app/upgrades/v210/upgrades.go b/app/upgrades/v210/upgrades.go index c640f6a2d..c4d4921e9 100644 --- a/app/upgrades/v210/upgrades.go +++ b/app/upgrades/v210/upgrades.go @@ -33,7 +33,7 @@ func (u *Upgrade) Name() string { // Handler implements upgrades.Upgrade func (u *Upgrade) Handler() upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - fromVM[mintmoduletypes.ModuleName] = 3 + fromVM[mintmoduletypes.ModuleName] = 2 newVM, err := u.mm.RunMigrations(ctx, u.configurator, fromVM) if err != nil { diff --git a/x/jklmint/types/params.go b/x/jklmint/types/params.go index 34b56f181..a08ade295 100644 --- a/x/jklmint/types/params.go +++ b/x/jklmint/types/params.go @@ -57,7 +57,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } // Validate validates the set of params -func (p Params) Validate() error { +func (p *Params) Validate() error { err := validateMintDenom(p.MintDenom) if err != nil { return err @@ -76,7 +76,7 @@ func (p Params) Validate() error { } // String implements the Stringer interface. -func (p Params) String() string { +func (p *Params) String() string { out, _ := yaml.Marshal(p) return string(out) } diff --git a/x/storage/types/params.go b/x/storage/types/params.go index 936528812..a890c6559 100644 --- a/x/storage/types/params.go +++ b/x/storage/types/params.go @@ -155,12 +155,12 @@ func validatePricePerTbPerMonth(i interface{}) error { } // Validate validates the set of params -func (p Params) Validate() error { +func (p *Params) Validate() error { return nil } // String implements the Stringer interface. -func (p Params) String() string { +func (p *Params) String() string { out, _ := yaml.Marshal(p) return string(out) }