From 0dafc77620bd066e8c25320e0da6eb1cdc177fac Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 13 Jan 2025 15:42:42 +0800 Subject: [PATCH] fix(simapp/v2): add MigrateAccountNumberUnsafe for v050-to-v2 (#23335) --- simapp/upgrades.go | 2 +- simapp/v2/app_di.go | 6 +++++- simapp/v2/go.mod | 5 ++++- simapp/v2/go.sum | 4 ++-- simapp/v2/upgrades.go | 5 +++++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/simapp/upgrades.go b/simapp/upgrades.go index 392d3b46cf..a1f17529e1 100644 --- a/simapp/upgrades.go +++ b/simapp/upgrades.go @@ -19,7 +19,7 @@ import ( // // NOTE: This upgrade defines a reference implementation of what an upgrade // could look like when an application is migrating from Cosmos SDK version -// v0.59.x to v0.52.x. +// v0.50.x to v0.52.x. const UpgradeName = "v050-to-v052" func (app SimApp) RegisterUpgradeHandlers() { diff --git a/simapp/v2/app_di.go b/simapp/v2/app_di.go index 601d641ad0..4f32ffaf16 100644 --- a/simapp/v2/app_di.go +++ b/simapp/v2/app_di.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/std" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" _ "github.com/cosmos/cosmos-sdk/x/genutil" ) @@ -45,6 +46,7 @@ type SimApp[T transaction.Tx] struct { // others keepers are all in the app UpgradeKeeper *upgradekeeper.Keeper StakingKeeper *stakingkeeper.Keeper + AuthKeeper authkeeper.AccountKeeper } // AppConfig returns the default app config. @@ -151,7 +153,9 @@ func NewSimApp[T transaction.Tx]( &app.txConfig, &app.interfaceRegistry, &app.UpgradeKeeper, - &app.StakingKeeper) + &app.StakingKeeper, + &app.AuthKeeper, + ) if err := depinject.Inject(appConfig, outputs...); err != nil { return nil, err diff --git a/simapp/v2/go.mod b/simapp/v2/go.mod index 09e3548215..a52f4b1103 100644 --- a/simapp/v2/go.mod +++ b/simapp/v2/go.mod @@ -258,7 +258,10 @@ require ( // replace ( // // ) -replace cosmossdk.io/server/v2/cometbft => ../../server/v2/cometbft +replace ( + cosmossdk.io/server/v2/cometbft => ../../server/v2/cometbft + cosmossdk.io/x/staking => cosmossdk.io/x/staking v0.2.0-rc.1.0.20250109101855-4c6e34be28c1 +) // Below are the long-lived replace of the SimApp replace ( diff --git a/simapp/v2/go.sum b/simapp/v2/go.sum index a6ebd99eab..31cfe1e305 100644 --- a/simapp/v2/go.sum +++ b/simapp/v2/go.sum @@ -268,8 +268,8 @@ cosmossdk.io/x/protocolpool v0.2.0-rc.1 h1:BNtRCp/TStXYSW0uc5KJTtJoTVOCaF7/P6Smx cosmossdk.io/x/protocolpool v0.2.0-rc.1/go.mod h1:asoCc7jX1kMqaJ9sI1U67P2evXjVKXSngTgGinAXTZo= cosmossdk.io/x/slashing v0.2.0-rc.1 h1:RNAV5JN7nIuyDtGclPoN1iFl92Edu71ERl/OtFSS06I= cosmossdk.io/x/slashing v0.2.0-rc.1/go.mod h1:uICi76DI/iwfgPbETb8sVio6dEA4Q4sv4Vqj9cxn2zI= -cosmossdk.io/x/staking v0.2.0-rc.1 h1:AZRGddRuuTaLxxpBvC7/TR7Dmt0pjziXWk13dC1beIo= -cosmossdk.io/x/staking v0.2.0-rc.1/go.mod h1:7K4hgQ6tn0XLFb2BJ9oe8nEc4RkfQ4qHqgQy2b0kVNc= +cosmossdk.io/x/staking v0.2.0-rc.1.0.20250109101855-4c6e34be28c1 h1:/IEkm90NCAatqdKITvVumjsbnMRldOimcslNiQ0gJlg= +cosmossdk.io/x/staking v0.2.0-rc.1.0.20250109101855-4c6e34be28c1/go.mod h1:eb4WWz3WB8lryUutt5pPuevwgqMSGsh0iPgr0VZr2kc= cosmossdk.io/x/tx v1.0.0 h1:pUUKRvHiMUZC/MnO8v747k1lUEA1DfAq0j0y0Mqrz/o= cosmossdk.io/x/tx v1.0.0/go.mod h1:AXYJ47btzkcWuT1OtA3M44dv1iiYbKomtopHEbQGgH4= cosmossdk.io/x/upgrade v0.2.0-rc.1 h1:YO865mCFIsFyjzl1fOsOr7Hw2iVGJhTGwecUC3u0YBY= diff --git a/simapp/v2/upgrades.go b/simapp/v2/upgrades.go index 1cf3ad7c9b..105f0b1045 100644 --- a/simapp/v2/upgrades.go +++ b/simapp/v2/upgrades.go @@ -10,6 +10,8 @@ import ( epochstypes "cosmossdk.io/x/epochs/types" protocolpooltypes "cosmossdk.io/x/protocolpool/types" upgradetypes "cosmossdk.io/x/upgrade/types" + + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" ) // UpgradeName defines the on-chain upgrade name for the sample SimApp upgrade @@ -24,6 +26,9 @@ func (app *SimApp[T]) RegisterUpgradeHandlers() { app.UpgradeKeeper.SetUpgradeHandler( UpgradeName, func(ctx context.Context, _ upgradetypes.Plan, fromVM appmodule.VersionMap) (appmodule.VersionMap, error) { + if err := authkeeper.MigrateAccountNumberUnsafe(ctx, &app.AuthKeeper); err != nil { + return nil, err + } return app.ModuleManager().RunMigrations(ctx, fromVM) }, )