diff --git a/.github/workflows/buildtest.yaml b/.github/workflows/buildtest.yaml index f969c3b52..e8882e8d2 100644 --- a/.github/workflows/buildtest.yaml +++ b/.github/workflows/buildtest.yaml @@ -96,7 +96,7 @@ jobs: done - name: "Go vulnerability checks" - continue-on-error: false #temp-till we upgrade to v1.20 + continue-on-error: true run: make vulncheck - name: Upload coverage reports to Codecov with GitHub Action diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 19652beda..56a1f5c7f 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -28,6 +28,7 @@ const ( V010404beta0UpgradeName = "v1.4.4-beta.0" V010404beta1UpgradeName = "v1.4.4-beta.1" V010404beta5UpgradeName = "v1.4.4-beta.5" + V010404beta7UpgradeName = "v1.4.4-beta.7" ) // Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal diff --git a/app/upgrades/upgrades.go b/app/upgrades/upgrades.go index d295f2ddf..c56f42e9a 100644 --- a/app/upgrades/upgrades.go +++ b/app/upgrades/upgrades.go @@ -13,6 +13,7 @@ import ( "github.com/ingenuity-build/quicksilver/app/keepers" "github.com/ingenuity-build/quicksilver/utils/addressutils" + epochtypes "github.com/ingenuity-build/quicksilver/x/epochs/types" icstypes "github.com/ingenuity-build/quicksilver/x/interchainstaking/types" prtypes "github.com/ingenuity-build/quicksilver/x/participationrewards/types" ) @@ -30,6 +31,7 @@ func Upgrades() []Upgrade { {UpgradeName: V010404beta0UpgradeName, CreateUpgradeHandler: V010404beta0UpgradeHandler}, {UpgradeName: V010404beta1UpgradeName, CreateUpgradeHandler: NoOpHandler}, {UpgradeName: V010404beta5UpgradeName, CreateUpgradeHandler: V010404beta5UpgradeHandler}, + {UpgradeName: V010404beta7UpgradeName, CreateUpgradeHandler: V010404beta7UpgradeHandler}, } } @@ -337,6 +339,47 @@ func V010404beta5UpgradeHandler( } } +func V010404beta7UpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + appKeepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + const ( + thetaUnbondingPeriod = int64(172800) + uniUnbondingPeriod = int64(2419200) + osmoUnbondingPeriod = int64(86400) + regenUnbondingPeriod = int64(1814400) + epochDurations = int64(10800) + ) + + appKeepers.InterchainstakingKeeper.IterateRedelegationRecords(ctx, func(idx int64, key []byte, redelegation icstypes.RedelegationRecord) (stop bool) { + var UnbondingPeriod int64 + switch redelegation.ChainId { + case "theta-testnet-001": + UnbondingPeriod = thetaUnbondingPeriod + case "uni-6": + UnbondingPeriod = uniUnbondingPeriod + case "osmo-test-5": + UnbondingPeriod = osmoUnbondingPeriod + case "regen-redwood-1": + UnbondingPeriod = regenUnbondingPeriod + } + + epochInfo := appKeepers.EpochsKeeper.GetEpochInfo(ctx, epochtypes.EpochIdentifierEpoch) + + if UnbondingPeriod < (epochInfo.CurrentEpoch-redelegation.EpochNumber)*epochDurations { + appKeepers.InterchainstakingKeeper.Logger(ctx).Info("garbage collecting completed redelegations", "key", key, "completion", redelegation.CompletionTime) + appKeepers.InterchainstakingKeeper.DeleteRedelegationRecordByKey(ctx, append(icstypes.KeyPrefixRedelegationRecord, key...)) + } + + return false + }) + + return mm.RunMigrations(ctx, configurator, fromVM) + } +} + // func V010400UpgradeHandler( // mm *module.Manager, // configurator module.Configurator, diff --git a/app/upgrades_test.go b/app/upgrades_test.go index d98c9009f..ca2387b41 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -354,6 +354,66 @@ func (s *AppTestSuite) TestV010404beta0UpgradeHandler() { s.Require().True(zone.Is_118) } +func (s *AppTestSuite) TestV010404beta7UpgradeHandler() { + app := s.GetQuicksilverApp(s.chainA) + // osmosis zone + zone := icstypes.Zone{ + ConnectionId: "connection-77002", + ChainId: upgrades.OsmosisTestnetChainID, + AccountPrefix: "osmo", + LocalDenom: "uqosmo", + BaseDenom: "uosmo", + MultiSend: false, + LiquidityModule: true, + } + + ctx := s.chainA.GetContext() + s.GetQuicksilverApp(s.chainA).InterchainstakingKeeper.SetZone(s.chainA.GetContext(), &zone) + + rdRecord := icstypes.RedelegationRecord{ + ChainId: upgrades.OsmosisTestnetChainID, + EpochNumber: 4, + Source: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", + Destination: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", + Amount: 3000000, + CompletionTime: time.Time{}, + } + s.GetQuicksilverApp(s.chainA).InterchainstakingKeeper.SetRedelegationRecord(s.chainA.GetContext(), rdRecord) + + rdRecord = icstypes.RedelegationRecord{ + ChainId: upgrades.OsmosisTestnetChainID, + EpochNumber: 6, + Source: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", + Destination: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", + Amount: 3000000, + CompletionTime: time.Time{}, + } + s.GetQuicksilverApp(s.chainA).InterchainstakingKeeper.SetRedelegationRecord(s.chainA.GetContext(), rdRecord) + + rdRecord = icstypes.RedelegationRecord{ + ChainId: upgrades.OsmosisTestnetChainID, + EpochNumber: 34, + Source: "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", + Destination: "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", + Amount: 3000000, + CompletionTime: time.Time{}, + } + s.GetQuicksilverApp(s.chainA).InterchainstakingKeeper.SetRedelegationRecord(s.chainA.GetContext(), rdRecord) + + handler := upgrades.V010404beta7UpgradeHandler(app.mm, app.configurator, &app.AppKeepers) + _, err := handler(ctx, types.Plan{}, app.mm.GetVersionMap()) + s.Require().NoError(err) + + _, found := app.InterchainstakingKeeper.GetRedelegationRecord(ctx, upgrades.OsmosisTestnetChainID, "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", 4) + s.Require().False(found) + + _, found = app.InterchainstakingKeeper.GetRedelegationRecord(ctx, upgrades.OsmosisTestnetChainID, "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", 6) + s.Require().False(found) + + _, found = app.InterchainstakingKeeper.GetRedelegationRecord(ctx, upgrades.OsmosisTestnetChainID, "osmovaloper13eq5c99ym05jn02e78l8cac2fagzgdhh4294zk", "osmovaloper1zxavllftfx3a3y5ldfyze7jnu5uyuktsfx2jcc", 34) + s.Require().True(found) +} + // func (s *AppTestSuite) TestV010400rc6UpgradeHandler() { // app := s.GetQuicksilverApp(s.chainA) //