From ce825ed7fc9b95d88127fd8a163bfd3cdab02415 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Thu, 1 Dec 2022 13:38:15 -0800 Subject: [PATCH] fix: runtime: fix (*App).RegisterMoodules inconsistency in checking/memoizing appModule Fixes an inconsistency in checking for duplicates in ModuleManager's Modules[name] then also basicManager[name] in which memoization could happen for .Module[name] but fail after a duplicate check in basicManager[name]. This change instead only memoizes the AppModule after the duplicate checks have all cleared. Fixes #14006 --- runtime/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/app.go b/runtime/app.go index 26b4fa555f0e..75e412744b01 100644 --- a/runtime/app.go +++ b/runtime/app.go @@ -59,12 +59,12 @@ func (a *App) RegisterModules(modules ...module.AppModule) error { if _, ok := a.ModuleManager.Modules[name]; ok { return fmt.Errorf("AppModule named %q already exists", name) } - a.ModuleManager.Modules[name] = appModule if _, ok := a.basicManager[name]; ok { return fmt.Errorf("AppModuleBasic named %q already exists", name) } + a.ModuleManager.Modules[name] = appModule a.basicManager[name] = appModule appModule.RegisterInterfaces(a.interfaceRegistry) appModule.RegisterLegacyAminoCodec(a.amino)