From 3aff993fcb586241366532d50d605194a9146ca4 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Thu, 1 Dec 2022 14:18:58 -0800 Subject: [PATCH] fix: runtime: fix (*App).RegisterMoodules inconsistency in checking/memoizing appModule (#14128) 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 26b4fa555f..75e412744b 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)