From 5e70498fe56e3acb02e6da42eadc0a58c64ef003 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 15:55:19 +0530 Subject: [PATCH 1/9] upgrade: add update minCommissionRate to validators --- app/upgrades.go | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/app/upgrades.go b/app/upgrades.go index 96c96b9a47..0152b3d74f 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/nft" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper" bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" leveragetypes "github.com/umee-network/umee/v3/x/leverage/types" @@ -30,7 +31,19 @@ func (app UmeeApp) RegisterUpgradeHandlers() { } ctx.Logger().Info("Upgrade handler execution finished, running migrations", "name", UpgradeV3_0Plan) - return app.mm.RunMigrations(ctx, app.configurator, fromVM) + vm, err := app.mm.RunMigrations(ctx, app.configurator, fromVM) + if err != nil { + return vm, err + } + + ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate to validators", "name", UpgradeV3_0Plan) + err = setMinimumCommissionRateToValidatros(app.StakingKeeper, ctx) + if err != nil { + return vm, sdkerrors.Wrapf( + err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", UpgradeV3_0Plan) + } + + return vm, err }) upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk() @@ -54,6 +67,29 @@ func (app UmeeApp) RegisterUpgradeHandlers() { } } +// setMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate whose commission rate is below the minimum commission rate. +func setMinimumCommissionRateToValidatros(keeper *stakingKeeper.Keeper, ctx sdk.Context) error { + validators := keeper.GetAllValidators(ctx) + + for _, validator := range validators { + params := keeper.GetParams(ctx) + if validator.Commission.Rate.GTE(params.MinCommissionRate) { + continue + } + + if err := keeper.BeforeValidatorModified(ctx, validator.GetOperator()); err != nil { + return err + } + + validator.Commission.Rate = params.MinCommissionRate + validator.Commission.UpdateTime = ctx.BlockTime() + + keeper.SetValidator(ctx, validator) + } + + return nil +} + // Sets up bech32ibc module by setting the native account prefix to "umee". // Failing to set the native prefix will cause a chain halt on init genesis or // in the firstBeginBlocker assertions. From 6cd2ab641530cf0ed2f33599fcfabab0e5c9fd7b Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 16:22:39 +0530 Subject: [PATCH 2/9] fix: fix the lint issue --- app/upgrades.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index 0152b3d74f..a4070772d4 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -36,11 +36,13 @@ func (app UmeeApp) RegisterUpgradeHandlers() { return vm, err } - ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate to validators", "name", UpgradeV3_0Plan) + ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate to validators", + "name", UpgradeV3_0Plan) err = setMinimumCommissionRateToValidatros(app.StakingKeeper, ctx) if err != nil { return vm, sdkerrors.Wrapf( - err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", UpgradeV3_0Plan) + err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", + UpgradeV3_0Plan) } return vm, err @@ -67,7 +69,8 @@ func (app UmeeApp) RegisterUpgradeHandlers() { } } -// setMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate whose commission rate is below the minimum commission rate. +// setMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate +// whose commission rate is below the minimum commission rate. func setMinimumCommissionRateToValidatros(keeper *stakingKeeper.Keeper, ctx sdk.Context) error { validators := keeper.GetAllValidators(ctx) From 98f98ee3fba5d3d164039a5e5659f6c36cb95916 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 16:55:57 +0530 Subject: [PATCH 3/9] address the pr comments --- app/upgrades.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index a4070772d4..f84a90c558 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -36,7 +36,7 @@ func (app UmeeApp) RegisterUpgradeHandlers() { return vm, err } - ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate to validators", + ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate of all validators", "name", UpgradeV3_0Plan) err = setMinimumCommissionRateToValidatros(app.StakingKeeper, ctx) if err != nil { @@ -72,10 +72,11 @@ func (app UmeeApp) RegisterUpgradeHandlers() { // setMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate // whose commission rate is below the minimum commission rate. func setMinimumCommissionRateToValidatros(keeper *stakingKeeper.Keeper, ctx sdk.Context) error { + params := keeper.GetParams(ctx) + validators := keeper.GetAllValidators(ctx) for _, validator := range validators { - params := keeper.GetParams(ctx) if validator.Commission.Rate.GTE(params.MinCommissionRate) { continue } From 732f2b8b773f5581c274e7dbe471ee24609346ee Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 16:59:59 +0530 Subject: [PATCH 4/9] chore: update the changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2aecf968e..f26413b9f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,6 +97,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ - [1319](https://github.com/umee-network/umee/pull/1319) Implemented MaxSupply. - [1331](https://github.com/umee-network/umee/pull/1331) Implemented MinCollateralLiquidity. - [1343](https://github.com/umee-network/umee/pull/1343) RepayBadDebt and Liquidate automatically clear blacklisted collateral. +- [1379](https://github.com/umee-network/umee/pull/1379) Add `mininumCommissionRate` update to all validators. ### Improvements From bda6c29ef05f7cabe727cdf1fb2b17f31d828f91 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 17:25:55 +0530 Subject: [PATCH 5/9] refactor: refactor the set minCommissionRate --- app/upgrades.go | 38 +++++++++-------------------- app/upgrades/min_commission.go | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 27 deletions(-) create mode 100644 app/upgrades/min_commission.go diff --git a/app/upgrades.go b/app/upgrades.go index f84a90c558..a2142531b0 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -9,9 +9,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/nft" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper" bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" + "github.com/umee-network/umee/v3/app/upgrades" leveragetypes "github.com/umee-network/umee/v3/x/leverage/types" oracletypes "github.com/umee-network/umee/v3/x/oracle/types" ) @@ -36,9 +36,18 @@ func (app UmeeApp) RegisterUpgradeHandlers() { return vm, err } + ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate param of staking module", + "name", UpgradeV3_0Plan) + minCommissionRate, err := upgrades.UpdateMinimumCommissionRateParam(ctx, app.StakingKeeper) + if err != nil { + return vm, sdkerrors.Wrapf( + err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate param of staking module", + UpgradeV3_0Plan) + } + ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate of all validators", "name", UpgradeV3_0Plan) - err = setMinimumCommissionRateToValidatros(app.StakingKeeper, ctx) + err = upgrades.SetMinimumCommissionRateToValidatros(ctx, app.StakingKeeper, minCommissionRate) if err != nil { return vm, sdkerrors.Wrapf( err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", @@ -69,31 +78,6 @@ func (app UmeeApp) RegisterUpgradeHandlers() { } } -// setMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate -// whose commission rate is below the minimum commission rate. -func setMinimumCommissionRateToValidatros(keeper *stakingKeeper.Keeper, ctx sdk.Context) error { - params := keeper.GetParams(ctx) - - validators := keeper.GetAllValidators(ctx) - - for _, validator := range validators { - if validator.Commission.Rate.GTE(params.MinCommissionRate) { - continue - } - - if err := keeper.BeforeValidatorModified(ctx, validator.GetOperator()); err != nil { - return err - } - - validator.Commission.Rate = params.MinCommissionRate - validator.Commission.UpdateTime = ctx.BlockTime() - - keeper.SetValidator(ctx, validator) - } - - return nil -} - // Sets up bech32ibc module by setting the native account prefix to "umee". // Failing to set the native prefix will cause a chain halt on init genesis or // in the firstBeginBlocker assertions. diff --git a/app/upgrades/min_commission.go b/app/upgrades/min_commission.go new file mode 100644 index 0000000000..1bd396b6f1 --- /dev/null +++ b/app/upgrades/min_commission.go @@ -0,0 +1,44 @@ +package upgrades + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" +) + +var ( + minCommissionRate = sdk.MustNewDecFromStr("0.05") +) + +// UpdateMinimumCommissionRateParam is update the minimum commission rate param of staking. +func UpdateMinimumCommissionRateParam(ctx sdk.Context, keeper *stakingKeeper.Keeper) (sdk.Dec, error) { + params := keeper.GetParams(ctx) + // update the minCommissionRate param + params.MinCommissionRate = minCommissionRate + + keeper.SetParams(ctx, params) + + return minCommissionRate, nil +} + +// SetMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate +// whose commission rate is below the minimum commission rate. +func SetMinimumCommissionRateToValidatros(ctx sdk.Context, keeper *stakingKeeper.Keeper, minCommissionRate sdk.Dec) error { + validators := keeper.GetAllValidators(ctx) + + for _, validator := range validators { + if validator.Commission.Rate.GTE(minCommissionRate) { + continue + } + + if err := keeper.BeforeValidatorModified(ctx, validator.GetOperator()); err != nil { + return err + } + + validator.Commission.Rate = minCommissionRate + validator.Commission.UpdateTime = ctx.BlockTime() + + keeper.SetValidator(ctx, validator) + } + + return nil +} From 668a10575a99d8976942f753ef47feb2744dc731 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 18:05:33 +0530 Subject: [PATCH 6/9] lint: fix the lint --- app/upgrades/min_commission.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/upgrades/min_commission.go b/app/upgrades/min_commission.go index 1bd396b6f1..75684919c9 100644 --- a/app/upgrades/min_commission.go +++ b/app/upgrades/min_commission.go @@ -22,7 +22,8 @@ func UpdateMinimumCommissionRateParam(ctx sdk.Context, keeper *stakingKeeper.Kee // SetMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate // whose commission rate is below the minimum commission rate. -func SetMinimumCommissionRateToValidatros(ctx sdk.Context, keeper *stakingKeeper.Keeper, minCommissionRate sdk.Dec) error { +func SetMinimumCommissionRateToValidatros( + ctx sdk.Context, keeper *stakingKeeper.Keeper, minCommissionRate sdk.Dec) error { validators := keeper.GetAllValidators(ctx) for _, validator := range validators { From 312cbe41b0c2086cdc5071b7d37a9acb9c6b0059 Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Wed, 14 Sep 2022 21:49:16 +0530 Subject: [PATCH 7/9] test: add tests to setMinCommissionRate --- app/upgrades/expected_types.go | 15 ++++ app/upgrades/min_commission.go | 23 +++--- app/upgrades/min_commission_test.go | 51 +++++++++++++ app/upgrades/test_util.go | 106 ++++++++++++++++++++++++++++ 4 files changed, 182 insertions(+), 13 deletions(-) create mode 100644 app/upgrades/expected_types.go create mode 100644 app/upgrades/min_commission_test.go create mode 100644 app/upgrades/test_util.go diff --git a/app/upgrades/expected_types.go b/app/upgrades/expected_types.go new file mode 100644 index 0000000000..53b430247d --- /dev/null +++ b/app/upgrades/expected_types.go @@ -0,0 +1,15 @@ +package upgrades + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +type StakingKeeper interface { + GetParams(ctx sdk.Context) types.Params + SetParams(ctx sdk.Context, params types.Params) + GetAllValidators(ctx sdk.Context) (validators []types.Validator) + BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) error + SetValidator(ctx sdk.Context, validator types.Validator) + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (types.Validator, bool) +} diff --git a/app/upgrades/min_commission.go b/app/upgrades/min_commission.go index 75684919c9..ecddf9600b 100644 --- a/app/upgrades/min_commission.go +++ b/app/upgrades/min_commission.go @@ -2,7 +2,6 @@ package upgrades import ( sdk "github.com/cosmos/cosmos-sdk/types" - stakingKeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" ) var ( @@ -10,7 +9,7 @@ var ( ) // UpdateMinimumCommissionRateParam is update the minimum commission rate param of staking. -func UpdateMinimumCommissionRateParam(ctx sdk.Context, keeper *stakingKeeper.Keeper) (sdk.Dec, error) { +func UpdateMinimumCommissionRateParam(ctx sdk.Context, keeper StakingKeeper) (sdk.Dec, error) { params := keeper.GetParams(ctx) // update the minCommissionRate param params.MinCommissionRate = minCommissionRate @@ -23,22 +22,20 @@ func UpdateMinimumCommissionRateParam(ctx sdk.Context, keeper *stakingKeeper.Kee // SetMinimumCommissionRateToValidatros is update the minimum commission rate to the validators rate // whose commission rate is below the minimum commission rate. func SetMinimumCommissionRateToValidatros( - ctx sdk.Context, keeper *stakingKeeper.Keeper, minCommissionRate sdk.Dec) error { + ctx sdk.Context, keeper StakingKeeper, minCommissionRate sdk.Dec) error { validators := keeper.GetAllValidators(ctx) for _, validator := range validators { - if validator.Commission.Rate.GTE(minCommissionRate) { - continue - } - - if err := keeper.BeforeValidatorModified(ctx, validator.GetOperator()); err != nil { - return err - } + if validator.Commission.Rate.IsNil() || validator.Commission.Rate.LT(minCommissionRate) { + if err := keeper.BeforeValidatorModified(ctx, validator.GetOperator()); err != nil { + return err + } - validator.Commission.Rate = minCommissionRate - validator.Commission.UpdateTime = ctx.BlockTime() + validator.Commission.Rate = minCommissionRate + validator.Commission.UpdateTime = ctx.BlockTime() - keeper.SetValidator(ctx, validator) + keeper.SetValidator(ctx, validator) + } } return nil diff --git a/app/upgrades/min_commission_test.go b/app/upgrades/min_commission_test.go new file mode 100644 index 0000000000..9e88a699a1 --- /dev/null +++ b/app/upgrades/min_commission_test.go @@ -0,0 +1,51 @@ +package upgrades + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestUpdateMinimumCommissionRateParam(t *testing.T) { + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil) + _, sk := GenerateRandomTestCase() + + // check default min commission rate + oldParams := sk.GetParams(ctx) + require.Equal(t, types.DefaultMinCommissionRate, oldParams.MinCommissionRate) + + // update the min commission rate + _, err := UpdateMinimumCommissionRateParam(ctx, &sk) + require.NoError(t, err) + + // get the updated params + updatedParams := sk.GetParams(ctx) + require.Equal(t, minCommissionRate, updatedParams.MinCommissionRate) +} + +func TestSetMinimumCommissionRateToValidatros(t *testing.T) { + ctx := sdk.NewContext(nil, tmproto.Header{}, false, nil) + valAddrs, sk := GenerateRandomTestCase() + + // update the min commission rate + minCommissionRate, err := UpdateMinimumCommissionRateParam(ctx, &sk) + require.NoError(t, err) + require.NotNil(t, minCommissionRate) + + // update min commisson rate to all validators + err = SetMinimumCommissionRateToValidatros(ctx, &sk, minCommissionRate) + require.NoError(t, err) + + // get the validator + validator, found := sk.GetValidator(ctx, valAddrs[0]) + require.True(t, found) + require.True(t, minCommissionRate.Equal(validator.Commission.Rate)) + + validator2, found := sk.GetValidator(ctx, valAddrs[1]) + require.True(t, found) + // validator2 commission rate should be greater than minCommissionRate + require.True(t, minCommissionRate.LT(validator2.Commission.Rate)) +} diff --git a/app/upgrades/test_util.go b/app/upgrades/test_util.go new file mode 100644 index 0000000000..c2ebb957c5 --- /dev/null +++ b/app/upgrades/test_util.go @@ -0,0 +1,106 @@ +package upgrades + +import ( + "crypto/rand" + "math/big" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +var ( + _ StakingKeeper = &MockStakingKeeper{} +) + +// MockStakingKeeper imlements the StakingKeeper interface. +type MockStakingKeeper struct { + validators []types.Validator + params types.Params +} + +// GetValidator implements StakingKeeper +func (m *MockStakingKeeper) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (types.Validator, bool) { + var ( + validator types.Validator + found bool + ) + + for _, v := range m.validators { + if v.GetOperator().Equals(addr) { + found = true + validator = v + break + } + } + + return validator, found +} + +// BeforeValidatorModified implements StakingKeeper +func (*MockStakingKeeper) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) error { + return nil +} + +// GetAllValidators implements StakingKeeper +func (m *MockStakingKeeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator) { + return m.validators +} + +// GetParams implements StakingKeeper +func (m *MockStakingKeeper) GetParams(ctx sdk.Context) types.Params { + return m.params +} + +// SetParams implements StakingKeeper +func (m *MockStakingKeeper) SetParams(ctx sdk.Context, params types.Params) { + m.params = params +} + +// SetValidator implements StakingKeeper +func (m *MockStakingKeeper) SetValidator(ctx sdk.Context, validator types.Validator) { + for index, v := range m.validators { + if v.GetOperator().Equals(validator.GetOperator()) { + m.validators[index] = validator + break + } + } +} + +// GenerateRandomTestCase +func GenerateRandomTestCase() ([]sdk.ValAddress, MockStakingKeeper) { + mockValidators := []types.Validator{} + + var valAddrs []sdk.ValAddress + randNum, _ := rand.Int(rand.Reader, big.NewInt(10000)) + numInputs := 10 + int((randNum.Int64() % 100)) + for i := 0; i < numInputs; i++ { + pubKey := secp256k1.GenPrivKey().PubKey() + valValAddr := sdk.ValAddress(pubKey.Address()) + mockValidator, _ := types.NewValidator(valValAddr, pubKey, types.Description{}) + mockValidators = append(mockValidators, mockValidator) + } + + // adding 0.01 to first validator + val := mockValidators[0] + val.Commission.Rate = sdk.MustNewDecFromStr("0.01") + mockValidators[0] = val + + // adding more then minimumCommissionRate to validator 2 + val = mockValidators[1] + val.Commission.Rate = types.DefaultMinCommissionRate.Add(sdk.MustNewDecFromStr("1")) + mockValidators[1] = val + + valAddrs = []sdk.ValAddress{mockValidators[0].GetOperator(), mockValidators[1].GetOperator()} + + stakingKeeper := NewMockStakingKeeper(mockValidators) + + return valAddrs, stakingKeeper +} + +func NewMockStakingKeeper(validatros []types.Validator) MockStakingKeeper { + return MockStakingKeeper{ + validators: validatros, + params: types.DefaultParams(), + } +} From f729369a19acfd223162fa805b7ecd52586fd861 Mon Sep 17 00:00:00 2001 From: toteki <63419657+toteki@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:56:58 -0700 Subject: [PATCH 8/9] typo batch --- app/upgrades.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/upgrades.go b/app/upgrades.go index a2142531b0..7695c5b5ba 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -36,21 +36,21 @@ func (app UmeeApp) RegisterUpgradeHandlers() { return vm, err } - ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate param of staking module", + ctx.Logger().Info("Upgrade handler execution finished, updating minimum commission rate param of staking module", "name", UpgradeV3_0Plan) minCommissionRate, err := upgrades.UpdateMinimumCommissionRateParam(ctx, app.StakingKeeper) if err != nil { return vm, sdkerrors.Wrapf( - err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate param of staking module", + err, "Calypso %q Upgrade: Unable to upgrade, failed to update minimum commission rate param of staking module", UpgradeV3_0Plan) } - ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate of all validators", + ctx.Logger().Info("Upgrade handler execution finished, updating minimum commission rate of all validators", "name", UpgradeV3_0Plan) err = upgrades.SetMinimumCommissionRateToValidatros(ctx, app.StakingKeeper, minCommissionRate) if err != nil { return vm, sdkerrors.Wrapf( - err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", + err, "Calypso %q Upgrade: Unable to upgrade, failed to update minimum commission rate for validators", UpgradeV3_0Plan) } From 4984dd394d102f67e2429efa6bd4e0d63beaa73c Mon Sep 17 00:00:00 2001 From: Sai Kumar Date: Thu, 15 Sep 2022 20:00:06 +0530 Subject: [PATCH 9/9] chore: move minCommissionStage files into upgrades/v3 --- app/upgrades.go | 6 +++--- app/upgrades/{ => v3}/expected_types.go | 2 +- app/upgrades/{ => v3}/min_commission.go | 2 +- app/upgrades/{ => v3}/min_commission_test.go | 2 +- app/upgrades/{test_util.go => v3/staking_util_test.go} | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) rename app/upgrades/{ => v3}/expected_types.go (96%) rename app/upgrades/{ => v3}/min_commission.go (98%) rename app/upgrades/{ => v3}/min_commission_test.go (98%) rename app/upgrades/{test_util.go => v3/staking_util_test.go} (99%) diff --git a/app/upgrades.go b/app/upgrades.go index a2142531b0..889cf236d8 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -11,7 +11,7 @@ import ( bech32ibckeeper "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/keeper" bech32ibctypes "github.com/osmosis-labs/bech32-ibc/x/bech32ibc/types" - "github.com/umee-network/umee/v3/app/upgrades" + v3upgrades "github.com/umee-network/umee/v3/app/upgrades/v3" leveragetypes "github.com/umee-network/umee/v3/x/leverage/types" oracletypes "github.com/umee-network/umee/v3/x/oracle/types" ) @@ -38,7 +38,7 @@ func (app UmeeApp) RegisterUpgradeHandlers() { ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate param of staking module", "name", UpgradeV3_0Plan) - minCommissionRate, err := upgrades.UpdateMinimumCommissionRateParam(ctx, app.StakingKeeper) + minCommissionRate, err := v3upgrades.UpdateMinimumCommissionRateParam(ctx, app.StakingKeeper) if err != nil { return vm, sdkerrors.Wrapf( err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate param of staking module", @@ -47,7 +47,7 @@ func (app UmeeApp) RegisterUpgradeHandlers() { ctx.Logger().Info("Upgrade handler execution finished, updatiing minimum commission rate of all validators", "name", UpgradeV3_0Plan) - err = upgrades.SetMinimumCommissionRateToValidatros(ctx, app.StakingKeeper, minCommissionRate) + err = v3upgrades.SetMinimumCommissionRateToValidatros(ctx, app.StakingKeeper, minCommissionRate) if err != nil { return vm, sdkerrors.Wrapf( err, "Calypso %q Upgrade: Unable to upgrade, failied to update minimum commission rate to validatos", diff --git a/app/upgrades/expected_types.go b/app/upgrades/v3/expected_types.go similarity index 96% rename from app/upgrades/expected_types.go rename to app/upgrades/v3/expected_types.go index 53b430247d..9526cc6038 100644 --- a/app/upgrades/expected_types.go +++ b/app/upgrades/v3/expected_types.go @@ -1,4 +1,4 @@ -package upgrades +package v3 import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/min_commission.go b/app/upgrades/v3/min_commission.go similarity index 98% rename from app/upgrades/min_commission.go rename to app/upgrades/v3/min_commission.go index ecddf9600b..7c4f479b8e 100644 --- a/app/upgrades/min_commission.go +++ b/app/upgrades/v3/min_commission.go @@ -1,4 +1,4 @@ -package upgrades +package v3 import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/app/upgrades/min_commission_test.go b/app/upgrades/v3/min_commission_test.go similarity index 98% rename from app/upgrades/min_commission_test.go rename to app/upgrades/v3/min_commission_test.go index 9e88a699a1..6aeefcbe15 100644 --- a/app/upgrades/min_commission_test.go +++ b/app/upgrades/v3/min_commission_test.go @@ -1,4 +1,4 @@ -package upgrades +package v3 import ( "testing" diff --git a/app/upgrades/test_util.go b/app/upgrades/v3/staking_util_test.go similarity index 99% rename from app/upgrades/test_util.go rename to app/upgrades/v3/staking_util_test.go index c2ebb957c5..039f69bf62 100644 --- a/app/upgrades/test_util.go +++ b/app/upgrades/v3/staking_util_test.go @@ -1,4 +1,4 @@ -package upgrades +package v3 import ( "crypto/rand"