diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b6cdf6651b..6bdfcb3388a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#1857](https://github.com/osmosis-labs/osmosis/pull/1857) x/mint rename GetLastHalvenEpochNum to GetLastReductionEpochNum * [#2394](https://github.com/osmosis-labs/osmosis/pull/2394) Remove unused interface methods from expected keepers of each module * [#2390](https://github.com/osmosis-labs/osmosis/pull/2390) x/mint remove unused mintCoins parameter from AfterDistributeMintedCoin +* [#2418](https://github.com/osmosis-labs/osmosis/pull/2418) x/mint remove SetInitialSupplyOffsetDuringMigration from keeper * [#2417](https://github.com/osmosis-labs/osmosis/pull/2417) x/mint unexport keeper `SetLastReductionEpochNum`, `getLastReductionEpochNum`, `CreateDeveloperVestingModuleAccount`, and `MintCoins` ### Features diff --git a/app/upgrades/v7/upgrades.go b/app/upgrades/v7/upgrades.go index 5cf0b72674e..5dbc6cb5169 100644 --- a/app/upgrades/v7/upgrades.go +++ b/app/upgrades/v7/upgrades.go @@ -54,10 +54,12 @@ func CreateUpgradeHandler( } keepers.SuperfluidKeeper.AddNewSuperfluidAsset(ctx, superfluidAsset) - // Set the supply offset from the developer vesting account - if err := keepers.MintKeeper.SetInitialSupplyOffsetDuringMigration(ctx); err != nil { - panic(err) - } + // N.B.: This is left for historic reasons. + // After the v7 upgrade, there was no need for this function anymore so it was removed. + // // Set the supply offset from the developer vesting account + // if err := keepers.MintKeeper.SetInitialSupplyOffsetDuringMigration(ctx); err != nil { + // panic(err) + // } return newVM, err } diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index 0cdf008e51e..6ef4decd2a2 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -75,23 +75,6 @@ func NewKeeper( } } -// SetInitialSupplyOffsetDuringMigration sets the supply offset based on the balance of the -// developer vesting module account. CreateDeveloperVestingModuleAccount must be called -// prior to calling this method. That is, developer vesting module account must exist when -// SetInitialSupplyOffsetDuringMigration is called. Also, SetInitialSupplyOffsetDuringMigration -// should only be called one time during the initial migration to v7. This is done so because -// we would like to ensure that unvested developer tokens are not returned as part of the supply -// queries. The method returns an error if current height in ctx is greater than the v7 upgrade height. -func (k Keeper) SetInitialSupplyOffsetDuringMigration(ctx sdk.Context) error { - if !k.accountKeeper.HasAccount(ctx, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) { - return sdkerrors.Wrapf(types.ErrModuleDoesnotExist, "%s vesting module account doesnot exist", types.DeveloperVestingModuleAcctName) - } - - moduleAccBalance := k.bankKeeper.GetBalance(ctx, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), k.GetParams(ctx).MintDenom) - k.bankKeeper.AddSupplyOffset(ctx, moduleAccBalance.Denom, moduleAccBalance.Amount.Neg()) - return nil -} - // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index 638a82dc90f..b28fe977fc0 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -311,57 +311,6 @@ func (suite *KeeperTestSuite) TestCreateDeveloperVestingModuleAccount() { } } -func (suite *KeeperTestSuite) TestSetInitialSupplyOffsetDuringMigration() { - testcases := map[string]struct { - blockHeight int64 - isDeveloperModuleAccountCreated bool - - expectedError error - }{ - "valid call": { - blockHeight: 1, - isDeveloperModuleAccountCreated: true, - }, - "dev vesting module account does not exist": { - blockHeight: 1, - expectedError: sdkerrors.Wrapf(types.ErrModuleDoesnotExist, "%s vesting module account doesnot exist", types.DeveloperVestingModuleAcctName), - }, - } - - for name, tc := range testcases { - suite.Run(name, func() { - suite.setupDeveloperVestingModuleAccountTest(tc.blockHeight, tc.isDeveloperModuleAccountCreated) - ctx := suite.Ctx - bankKeeper := suite.App.BankKeeper - mintKeeper := suite.App.MintKeeper - - // in order to ensure the offset is correctly calculated, we need to mint the supply + 1 - // this is because a negative supply offset will always return zero - // by setting this to the supply + 1, we ensure we are correctly calculating the offset by keeping it delta positive - suite.MintCoins(sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(keeper.DeveloperVestingAmount+1)))) - - supplyWithOffsetBefore := bankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom) - supplyOffsetBefore := bankKeeper.GetSupplyOffset(ctx, sdk.DefaultBondDenom) - - // Test - actualError := mintKeeper.SetInitialSupplyOffsetDuringMigration(ctx) - - if tc.expectedError != nil { - suite.Require().Error(actualError) - suite.Require().ErrorIs(actualError, tc.expectedError) - - suite.Require().Equal(supplyWithOffsetBefore.Amount, bankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount) - suite.Require().Equal(supplyOffsetBefore, bankKeeper.GetSupplyOffset(ctx, sdk.DefaultBondDenom)) - return - } - suite.Require().NoError(actualError) - - suite.Require().Equal(supplyWithOffsetBefore.Amount.Sub(sdk.NewInt(keeper.DeveloperVestingAmount)), bankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount) - suite.Require().Equal(supplyOffsetBefore.Sub(sdk.NewInt(keeper.DeveloperVestingAmount)), bankKeeper.GetSupplyOffset(ctx, sdk.DefaultBondDenom)) - }) - } -} - // TestDistributeToModule tests that distribution from mint module to another module helper // function is working as expected. func (suite *KeeperTestSuite) TestDistributeToModule() {