Skip to content

Commit

Permalink
refactor consensus version and migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
lacsomot committed Oct 30, 2024
1 parent 3c6a39c commit b3e83b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
10 changes: 4 additions & 6 deletions x/multi-staking/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ func NewMigrator(keeper *stakingkeeper.Keeper, legacySubspace exported.Subspace)
}
}

// Migrate1to2 migrates multi-staking state from consensus version 1 to 2. (sdk46 to sdk47)
// Migrate1to2 migrates multi-staking state from consensus version 1 to 2. (sdk46 to sdk50)
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return m.stkm.Migrate3to4(ctx)
}

// Migrate2to3 migrates multi-staking state from consensus version 2 to 3. (sdk47 to sdk50)
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
if err := m.stkm.Migrate3to4(ctx); err != nil {
return err
}
return m.stkm.Migrate4to5(ctx)
}
5 changes: 1 addition & 4 deletions x/multi-staking/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err := cfg.RegisterMigration(multistakingtypes.ModuleName, 1, m.Migrate1to2); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", stakingtypes.ModuleName, err))
}
if err := cfg.RegisterMigration(multistakingtypes.ModuleName, 2, m.Migrate2to3); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", stakingtypes.ModuleName, err))
}
}

// InitGenesis initial genesis state for multi-staking module
Expand Down Expand Up @@ -203,7 +200,7 @@ func (am AppModule) StakingAppModule() staking.AppModule {
}

// ConsensusVersion return module consensus version
func (AppModule) ConsensusVersion() uint64 { return 3 }
func (AppModule) ConsensusVersion() uint64 { return 2 }

// IsAppModule implements the appmodule.AppModule interface.
func (am AppModule) IsAppModule() {}
Expand Down

0 comments on commit b3e83b6

Please sign in to comment.