You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrations need to register legacy interfaces. To not pollute the real interfaceRegistry, we should clone a separate interfaceRegistry for migrations only.
Problem Definition
Here's an example:
In v042, the supply was stored in state as an interface SupplyI:
To do so, we needed to register SupplyI in the interfaceRegistry
In v043, we now store the supply indexed by denom (Index supply by denom #7092). We removed the SupplyI interface, and also removed it from the interfaceRegistry.
However, to perform in-place store migrations from 0.42 to 0.43, we still need to register SupplyI inside an interfaceRegistry, just to be able to perform the migration.
Proposal
Three proposals:
1. Keep one unique interfaceRegistry like now, and register legacy interfaces on it
This is the approach taken in #8998. In the (AppModule) RegisterInterfaces, we also register legacy interfaces.
+ simple - polluting the current interfaceRegistry with legacy interfaces
2. Clone the interfaceRegistry inside each keeper
Each keeper has a Migrator struct, which could receive a reference to the interfaceRegistry, clone it, and register legacy interfaces on that clones interfaceRegistry.
+ simple (maybe slightly less than 1/, but still okay) - we are cloning N interfaceRegistries for migrations - docs for module developers
3. Clone the interfaceRegistry once, and use this same instance for all migrations
An idea could be for the configurator to hold a migrationsInterfaceRegistry, which is a clone of the real interfaceRegistry. Also, when each module calls RegisterMigration, we can allow it to register legacy interfaces:
+ no cloning of N interfaceRegistries, no polluting the real interfaceRegistry - makes code a bit harder to understand - refactoring (possibly with breaking changes)
For Admin Use
Not duplicate issue
Appropriate labels applied
Appropriate contributors tagged
Contributor assigned/self-assigned
The text was updated successfully, but these errors were encountered:
Summary
Migrations need to register legacy interfaces. To not pollute the real interfaceRegistry, we should clone a separate interfaceRegistry for migrations only.
Problem Definition
Here's an example:
SupplyI
:cosmos-sdk/x/bank/keeper/keeper.go
Line 174 in 7648bfc
To do so, we needed to register
SupplyI
in the interfaceRegistrySupplyI
interface, and also removed it from the interfaceRegistry.However, to perform in-place store migrations from 0.42 to 0.43, we still need to register
SupplyI
inside an interfaceRegistry, just to be able to perform the migration.Proposal
Three proposals:
1. Keep one unique interfaceRegistry like now, and register legacy interfaces on it
This is the approach taken in #8998. In the
(AppModule) RegisterInterfaces
, we also register legacy interfaces.+
simple-
polluting the current interfaceRegistry with legacy interfaces2. Clone the interfaceRegistry inside each keeper
Each keeper has a
Migrator
struct, which could receive a reference to the interfaceRegistry, clone it, and register legacy interfaces on that clones interfaceRegistry.+
simple (maybe slightly less than 1/, but still okay)-
we are cloningN
interfaceRegistries for migrations-
docs for module developers3. Clone the interfaceRegistry once, and use this same instance for all migrations
An idea could be for the configurator to hold a
migrationsInterfaceRegistry
, which is a clone of the realinterfaceRegistry
. Also, when each module callsRegisterMigration
, we can allow it to register legacy interfaces:+
no cloning ofN
interfaceRegistries, no polluting the real interfaceRegistry-
makes code a bit harder to understand-
refactoring (possibly with breaking changes)For Admin Use
The text was updated successfully, but these errors were encountered: