refactor(simapp): remove public module basic manager#15958
Conversation
|
@julienrbrt lmk if you need help here, I have a deep hated passion for having to define this variable LOL |
Haha thanks, the biggest wonder is how to make it nice when you need to manually instantiate AppModuleBasic (for gov and genutil f.e), but I have an idea. |
|
Feels a bit like a hack but what do you think? |
| _ "cosmossdk.io/x/nft/module" // import for side-effects | ||
| _ "cosmossdk.io/x/upgrade" // import for side-effects | ||
| _ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects | ||
| _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" // import for side-effects |
There was a problem hiding this comment.
Yeah, because we do not import the module directl now that there is no app basic imports, we need these for app wiring.
Fortunately depinject has a descriptive error message and points which import is missing.
| } | ||
|
|
||
| initRootCmd(rootCmd, encodingConfig) | ||
| initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager) |
There was a problem hiding this comment.
Why do we need this tempApp and where is this coming from?
There was a problem hiding this comment.
The origin is not to use depinject for app v1 (as this means we do not show how to get those values for app v1 apps).
For app v2 app, we can just use depinject. I can remove it to clean it up, but then it does mean that when building with the app legacy flag, it will still use the app wiring config.
There was a problem hiding this comment.
One thing I can simply do is try to create a root.go and root_v2.go for both implementations. So we can simplify the example for those using depinject, where it is way cleaner.
There was a problem hiding this comment.
Done, for app v1 it does need to stay like this. app v2 is way cleaner :)
|
yeah this is kinda gross. I feel like it adds more complexity than it helps solve. What if the Appliation interface forces the app to expose what modules it supports? I think the thing that bugs me the most is the whole |
|
Yeah, the |
| for name, module := range manager.Modules { | ||
| if customBasicMod, ok := customModuleBasics[name]; ok { | ||
| moduleMap[name] = customBasicMod | ||
| continue | ||
| } | ||
|
|
||
| if basicMod, ok := module.(AppModuleBasic); ok { | ||
| moduleMap[name] = basicMod | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Iteration over map
| appConfig *appv1alpha1.Config | ||
| logger log.Logger | ||
| ModuleManager *module.Manager | ||
| BasicModuleManager module.BasicManager |
There was a problem hiding this comment.
Why does this need to be exported?
There was a problem hiding this comment.
I did that for parity with app v1, I won't do that anymore given I will create a second root.go for app v2 only 👍🏾
| } | ||
|
|
||
| initRootCmd(rootCmd, encodingConfig) | ||
| initRootCmd(rootCmd, encodingConfig, tempApp.BasicModuleManager) |
There was a problem hiding this comment.
Why do we need this tempApp and where is this coming from?
|
|
||
| if basicMod, ok := module.(AppModuleBasic); ok { | ||
| moduleMap[name] = basicMod | ||
| } |
There was a problem hiding this comment.
Can we use an app module basic adapter for core app modules?
There was a problem hiding this comment.
We can add a condition for that but we will still need this one.
In runtime, we can indeed directly use the adapter.
There was a problem hiding this comment.
Okay, after a few trials, the core app module adapter does not work. I will leave it out of this PR.
Done the following in SetupAppBuilder
app.basicManager[name] = basicMod
basicMod.RegisterInterfaces(inputs.InterfaceRegistry)
basicMod.RegisterLegacyAminoCodec(inputs.LegacyAmino)
basicMod := module.CoreAppModuleBasicAdaptor(name, mod)And the following in NewBasicManagerFromManager
if appModule, ok := module.(appmodule.AppModule); ok {
moduleMap[name] = CoreAppModuleBasicAdaptor(name, appModule)
continue
}Something to investigate in a follow-up.
Description
ref: #15304
PR to investigate how to get group genesis working nicely with app v1 and app v2. Currently,
InitGenesisutilizes the basic module manager, but we need an app module instantiated for creating an app module basic forappmodule.HasGenesis.This removes the need to define a list
AppModuleBasicin app.go and app_v2.go. Now it will infer it from the module manager.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!to the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!in the type prefix if API or client breaking change