Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add migrations registering #19370

Merged
merged 14 commits into from
Feb 9, 2024
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i
* (crypto | x/auth) [#14372](https://github.com/cosmos/cosmos-sdk/pull/18194) Key checks on signatures antehandle.
* (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding

### Deprecated

* (simapp) [#19146](https://github.com/cosmos/cosmos-sdk/pull/19146) Replace `--v` CLI option with `--validator-count`/`-n`.

### Bug Fixes

* (baseapp) [#19338](https://github.com/cosmos/cosmos-sdk/pull/19338) Set HeaderInfo in context when calling `setState`.
Expand Down Expand Up @@ -144,6 +140,11 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i

* (server) [#18303](https://github.com/cosmos/cosmos-sdk/pull/18303) `appd export` has moved with other genesis commands, use `appd genesis export` instead.

### Deprecated

* (simapp) [#19146](https://github.com/cosmos/cosmos-sdk/pull/19146) Replace `--v` CLI option with `--validator-count`/`-n`.
* (module) [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Depcreate ` module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServicecs` instead from Core API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in "HasServicecs". It should be "HasServices".

- use `appmodule.HasMigrations` and `appmodule.HasServicecs` instead from Core API.
+ use `appmodule.HasMigrations` and `appmodule.HasServices` instead from Core API.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
* (module) [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Depcreate ` module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServicecs` instead from Core API.
* (module) [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Depcreate ` module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServices` instead from Core API.


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in "Depcreate". It should be "Deprecate".

- Depcreate ` module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServicecs` instead from Core API.
+ Deprecate `module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServices` instead from Core API.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
### Deprecated
* (simapp) [#19146](https://github.com/cosmos/cosmos-sdk/pull/19146) Replace `--v` CLI option with `--validator-count`/`-n`.
* (module) [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Depcreate ` module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServicecs` instead from Core API.
### Deprecated
* (simapp) [#19146](https://github.com/cosmos/cosmos-sdk/pull/19146) Replace `--v` CLI option with `--validator-count`/`-n`.
* (module) [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Deprecate `module.Configurator`, use `appmodule.HasMigrations` and `appmodule.HasServices` instead from Core API.

## [v0.50.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.3) - 2023-01-15

### Features
Expand Down
92 changes: 46 additions & 46 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,45 @@ Note, always read the **SimApp** section for more information on application wir

## [Unreleased]

### Unordered Transactions
### SimApp

In this section we describe the changes made in Cosmos SDK' SimApp.
**These changes are directly applicable to your application wiring.**

#### AnteHandlers

The GasConsumptionDecorator and IncreaseSequenceDecorator have been merged with the SigVerificationDecorator, so you'll
need to remove them both from your app.go code, they will yield to unresolvable symbols when compiling.

#### Client (`root.go`)

The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.).
This is part of the work of abstracting the SDK from the global bech32 config.

This means the address codecs must be provided in the `client.Context` in the application client (usually `root.go`).

```diff
clientCtx = clientCtx.
+ WithAddressCodec(addressCodec).
+ WithValidatorAddressCodec(validatorAddressCodec).
+ WithConsensusAddressCodec(consensusAddressCodec)
```
Comment on lines +25 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code snippet provided for updating the client.Context with address codecs is helpful. However, ensure that the snippet is placed in the correct context within the documentation and that it's clear to developers where and how to implement these changes in their applications.

+ Ensure this snippet is accompanied by a clear explanation of where to implement these changes in the application code.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
```diff
clientCtx = clientCtx.
+ WithAddressCodec(addressCodec).
+ WithValidatorAddressCodec(validatorAddressCodec).
+ WithConsensusAddressCodec(consensusAddressCodec)
```
clientCtx = clientCtx.
WithAddressCodec(addressCodec).
WithValidatorAddressCodec(validatorAddressCodec).
WithConsensusAddressCodec(consensusAddressCodec)


**When using `depinject` / `app v2`, the client codecs can be provided directly from application config.**

Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a legacy app.

### Core

`appmodule.Environment` interface was introduced to fetch different services from the application. This can be used as an alternative to using `sdk.UnwrapContext(ctx)` to fetch the services. It needs to be passed into a module at instantiation.

Circuit Breaker is used as an example.

```go
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey]), nil), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
```
Comment on lines +42 to +44
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example provided for using the appmodule.Environment interface with the CircuitKeeper is valuable. Recommend adding more examples or a detailed explanation to help developers understand how to implement this interface across different modules and services.

+ Consider adding additional examples or a more detailed guide on implementing the `appmodule.Environment` interface across various modules.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
```go
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey]), nil), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
```
```go
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey]), nil), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())

</details>
<!-- suggestion_end -->

<!-- This is an auto-generated comment by CodeRabbit -->


#### Unordered Transactions

The Cosmos SDK now supports unordered transactions. This means that transactions
can be executed in any order and doesn't require the client to deal with or manage
Expand Down Expand Up @@ -80,57 +118,19 @@ used as a TTL for the transaction and is used to provide replay protection. See
[ADR-070](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-070-unordered-transactions.md)
for more details.

### Params

* Params migrations were removed. It is required to migrate to 0.50 prior to upgrading to v0.51.

### SimApp

In this section we describe the changes made in Cosmos SDK' SimApp.
**These changes are directly applicable to your application wiring.**

#### AnteHandlers

The GasConsumptionDecorator and IncreaseSequenceDecorator have been merged with the SigVerificationDecorator, so you'll
need to remove them both from your app.go code, they will yield to unresolvable symbols when compiling.

#### Client (`root.go`)

The `client` package has been refactored to make use of the address codecs (address, validator address, consensus address, etc.).
This is part of the work of abstracting the SDK from the global bech32 config.

This means the address codecs must be provided in the `client.Context` in the application client (usually `root.go`).

```diff
clientCtx = clientCtx.
+ WithAddressCodec(addressCodec).
+ WithValidatorAddressCodec(validatorAddressCodec).
+ WithConsensusAddressCodec(consensusAddressCodec)
```

**When using `depinject` / `app v2`, the client codecs can be provided directly from application config.**

Refer to SimApp `root_v2.go` and `root.go` for an example with an app v2 and a legacy app.

#### Dependency Injection

<!-- explain app_config.go changes -->

### Core
### Modules

`appmodule.Environment` interface was introduced to fetch different services from the application. This can be used as an alternative to using `sdk.UnwrapContext(ctx)` to fetch the services. It needs to be passed into a module at instantiation.
#### `**all**`

Circuit Breaker is used as an example.
##### Params

```go
app.CircuitKeeper = circuitkeeper.NewKeeper(runtime.NewEnvironment((keys[circuittypes.StoreKey]), nil), appCodec, authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AuthKeeper.AddressCodec())
```
Old module migrations have been removed. It is required to migrate to v0.50 prior to upgrading to v0.51 for not missing any module migrations.

### Modules
##### Core API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify the requirement for migrating to v0.50 before upgrading to v0.51 to ensure developers understand the importance of completing module migrations in the correct order. Providing additional resources or guidance on this process could be beneficial.

+ Add more detailed instructions or resources to assist developers with the migration process from v0.50 to v0.51.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
##### Core API
##### Core API
Add more detailed instructions or resources to assist developers with the migration process from v0.50 to v0.51.


#### `**all**`
Core API has been introduces for modules in v0.47. With the deprecation of `sdk.Context`, we strongly recommend to use the `cosmossdk.io/core/appmodule` interfaces for the modules. This will allow the modules to work out of the box with server/v2 and baseapp, as well as limit their dependencies on the SDK.

##### Dependency Injection
##### Dependency Injection
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlight the significance of updating imports for dependency injection functions and ensure that developers are aware of the changes to cosmossdk.io/depinject/appconfig. Providing examples of updated imports could help clarify the required changes.

+ Include examples of updated imports for dependency injection functions to guide developers through the migration process.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
##### Dependency Injection
##### Dependency Injection
Include examples of updated imports for dependency injection functions to guide developers through the migration process.


Previously `cosmossdk.io/core` held functions `Invoke`, `Provide` and `Register` were moved to `cosmossdk.io/depinject/appconfig`.
All modules using dependency injection must update their imports.
Expand Down
3 changes: 2 additions & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [#18379](https://github.com/cosmos/cosmos-sdk/pull/18379) Add branch service.
* [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit.
* [#19041](https://github.com/cosmos/cosmos-sdk/pull/19041) Add `appmodule.Environment` interface to fetch different services
* [#19370](https://github.com/cosmos/cosmos-sdk/pull/19370) Add `appmodule.Migrations` interface to handle migrations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entry for PR #19370 lacks a brief description of what the appmodule.Migrations interface does or its impact. Consider adding a concise explanation to provide more context to the reader.


### API Breaking
### API Breaking Changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL in the entry for PR #18861 has a typo: httpes should be https.

- * [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.
+ * [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
### API Breaking Changes
### API Breaking Changes
* [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.

The entry for PR #19041 under "API Breaking Changes" is duplicated. It's already mentioned under "Features". Consider removing the duplicate or clarifying if there are distinct aspects of the PR that belong to both categories.


* [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` to `x/tx`.
* [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.
Expand Down
16 changes: 16 additions & 0 deletions core/appmodule/migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package appmodule
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing package documentation.

+ // Package appmodule provides interfaces and structures for managing application modules.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
package appmodule
// Package appmodule provides interfaces and structures for managing application modules.
package appmodule


import "context"

type MigrationRegistrar interface {
// Register registers an in-place store migration for a module. The
// handler is a migration script to perform in-place migrations from version
// `fromVersion` to version `fromVersion+1`.
//
// EACH TIME a module's ConsensusVersion increments, a new migration MUST
// be registered using this function. If a migration handler is missing for
// a particular function, the upgrade logic (see RunMigrations function)
// will panic. If the ConsensusVersion bump does not introduce any store
// changes, then a no-op function must be registered here.
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error
Comment on lines +5 to +15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MigrationRegistrar interface documentation should clarify the expected behavior when fromVersion is not sequential.

+ // It is the caller's responsibility to ensure migrations are registered in a sequential manner without gaps.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
type MigrationRegistrar interface {
// Register registers an in-place store migration for a module. The
// handler is a migration script to perform in-place migrations from version
// `fromVersion` to version `fromVersion+1`.
//
// EACH TIME a module's ConsensusVersion increments, a new migration MUST
// be registered using this function. If a migration handler is missing for
// a particular function, the upgrade logic (see RunMigrations function)
// will panic. If the ConsensusVersion bump does not introduce any store
// changes, then a no-op function must be registered here.
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error
type MigrationRegistrar interface {
// Register registers an in-place store migration for a module. The
// handler is a migration script to perform in-place migrations from version
// `fromVersion` to version `fromVersion+1`.
//
// EACH TIME a module's ConsensusVersion increments, a new migration MUST
// be registered using this function. If a migration handler is missing for
// a particular function, the upgrade logic (see RunMigrations function)
// will panic. If the ConsensusVersion bump does not introduce any store
// changes, then a no-op function must be registered here.
// It is the caller's responsibility to ensure migrations are registered in a sequential manner without gaps.
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error

}
26 changes: 17 additions & 9 deletions core/appmodule/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,12 @@ type HasServices interface {
RegisterServices(grpc.ServiceRegistrar) error
}

// HasPrepareCheckState is an extension interface that contains information about the AppModule
// and PrepareCheckState.
type HasPrepareCheckState interface {
// HasMigrations is the extension interface that modules should implement to register migrations.
type HasMigrations interface {
AppModule
PrepareCheckState(context.Context) error
}

// HasPrecommit is an extension interface that contains information about the AppModule and Precommit.
type HasPrecommit interface {
AppModule
Precommit(context.Context) error
// RegisterMigrations registers the module's migrations with the app's migrator.
RegisterMigrations(MigrationRegistrar) error
}

// ResponsePreBlock represents the response from the PreBlock method.
Expand Down Expand Up @@ -86,3 +81,16 @@ type HasEndBlocker interface {
// a block.
EndBlock(context.Context) error
}

// HasPrepareCheckState is an extension interface that contains information about the AppModule
// and PrepareCheckState.
type HasPrepareCheckState interface {
AppModule
PrepareCheckState(context.Context) error
}

// HasPrecommit is an extension interface that contains information about the AppModule and Precommit.
type HasPrecommit interface {
AppModule
Precommit(context.Context) error
}
2 changes: 2 additions & 0 deletions docs/build/building-modules/13-upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Since these migrations are functions that need access to a Keeper's store, use a
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/x/bank/keeper/migrations.go
```

<!-- TODO v0.51: explain the new way with core -->

## Writing Migration Scripts

To define the functionality that takes place during an upgrade, write a migration script and place the functions in a `migrations/` directory. For example, to write migration scripts for the bank module, place the functions in `x/bank/migrations/`. Use the recommended naming convention for these functions. For example, `v2bank` is the script that migrates the package `x/bank/migrations/v2`:
Expand Down
2 changes: 2 additions & 0 deletions runtime/services/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func (a *autocliConfigurator) RegisterMigration(string, uint64, module.Migration
return nil
}

func (a *autocliConfigurator) Register(string, uint64, func(context.Context) error) error { return nil }

func (a *autocliConfigurator) RegisterService(sd *grpc.ServiceDesc, ss interface{}) {
if a.registryCache == nil {
a.registryCache, a.err = proto.MergedRegistry()
Expand Down
15 changes: 15 additions & 0 deletions types/module/configurator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package module

import (
"context"
"fmt"

"github.com/cosmos/gogoproto/grpc"
Expand All @@ -20,6 +21,8 @@ import (
// their services in the RegisterServices method. It is designed to eventually
// support module object capabilities isolation as described in
// https://github.com/cosmos/cosmos-sdk/issues/7093
// Deprecated: The Configurator is deprecated.
// Preferably use core services for registering msg/query server and migrations.
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecation of Configurator interface is not accompanied by an alternative implementation or migration path for existing users.

type Configurator interface {
grpc.Server

Expand All @@ -45,6 +48,10 @@ type Configurator interface {
// will panic. If the ConsensusVersion bump does not introduce any store
// changes, then a no-op function must be registered here.
RegisterMigration(moduleName string, fromVersion uint64, handler MigrationHandler) error

// Register registers an in-place store migration for a module.
// It permits to register modules migrations that have migrated to serverv2 but still be compatible with baseapp.
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error
Comment on lines +52 to +54
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Register method lacks documentation on how it differs from RegisterMigration and under what circumstances it should be used.

}

type configurator struct {
Expand Down Expand Up @@ -119,6 +126,14 @@ func (c *configurator) RegisterMigration(moduleName string, fromVersion uint64,
return nil
}

// Register implements the Configurator.Register method
// It permis to register modules migrations that have migrated to serverv2 but still be compatible with baseapp.
julienrbrt marked this conversation as resolved.
Show resolved Hide resolved
func (c *configurator) Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error {
return c.RegisterMigration(moduleName, fromVersion, func(sdkCtx sdk.Context) error {
return handler(sdkCtx)
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Register method's implementation directly calls RegisterMigration without adapting the context from context.Context to sdk.Context, potentially leading to confusion or misuse.


// runModuleMigrations runs all in-place store migrations for one given module from a
// version to another version.
func (c *configurator) runModuleMigrations(ctx sdk.Context, moduleName string, fromVersion, toVersion uint64) error {
Expand Down
7 changes: 7 additions & 0 deletions types/module/core_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ func (c coreAppModuleBasicAdaptor) RegisterServices(cfg Configurator) {
panic(err)
}
}

if module, ok := c.module.(appmodule.HasMigrations); ok {
err := module.RegisterMigrations(cfg)
if err != nil {
panic(err)
}
}
}

func (c coreAppModuleBasicAdaptor) IsOnePerModuleType() {}
Expand Down
7 changes: 7 additions & 0 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,13 @@ func (m *Manager) RegisterServices(cfg Configurator) error {
}
}

if module, ok := module.(appmodule.HasMigrations); ok {
err := module.RegisterMigrations(cfg)
if err != nil {
return err
}
}
facundomedica marked this conversation as resolved.
Show resolved Hide resolved

if cfg.Error() != nil {
return cfg.Error()
}
Expand Down
19 changes: 9 additions & 10 deletions x/auth/keeper/migrations.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/cosmos/gogoproto/grpc"
"context"

v5 "cosmossdk.io/x/auth/migrations/v5"
"cosmossdk.io/x/auth/types"
Expand All @@ -11,46 +11,45 @@ import (

// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper AccountKeeper
queryServer grpc.Server
keeper AccountKeeper
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper AccountKeeper, queryServer grpc.Server) Migrator {
return Migrator{keeper: keeper, queryServer: queryServer}
func NewMigrator(keeper AccountKeeper) Migrator {
return Migrator{keeper: keeper}
}

// Migrate1to2 migrates from version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
func (m Migrator) Migrate1to2(ctx context.Context) error {
return nil
}

// Migrate2to3 migrates from consensus version 2 to version 3. Specifically, for each account
// we index the account's ID to their address.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
func (m Migrator) Migrate2to3(ctx context.Context) error {
return nil
}

// Migrate3to4 migrates the x/auth module state from the consensus version 3 to
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
func (m Migrator) Migrate3to4(ctx context.Context) error {
return nil
}

// Migrate4To5 migrates the x/auth module state from the consensus version 4 to 5.
// It migrates the GlobalAccountNumber from being a protobuf defined value to a
// big-endian encoded uint64, it also migrates it to use a more canonical prefix.
func (m Migrator) Migrate4To5(ctx sdk.Context) error {
func (m Migrator) Migrate4To5(ctx context.Context) error {
return v5.Migrate(ctx, m.keeper.storeService, m.keeper.AccountNumber)
}

// V45_SetAccount implements V45_SetAccount
// set the account without map to accAddr to accNumber.
//
// NOTE: This is used for testing purposes only.
func (m Migrator) V45SetAccount(ctx sdk.Context, acc sdk.AccountI) error {
func (m Migrator) V45SetAccount(ctx context.Context, acc sdk.AccountI) error {
addr := acc.GetAddress()
store := m.keeper.storeService.OpenKVStore(ctx)

Expand Down
Loading
Loading