From 2049c4b82a674c9e92e9720fd52488fdbfb7e14b Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 04:19:05 +0000 Subject: [PATCH] chore(runtime): audit (backport #17035) (#17036) --- runtime/builder.go | 1 + runtime/events.go | 11 ++++------- runtime/module.go | 4 +++- runtime/services/autocli.go | 1 + runtime/types.go | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/runtime/builder.go b/runtime/builder.go index e340a9db7e..72bf965f70 100644 --- a/runtime/builder.go +++ b/runtime/builder.go @@ -38,6 +38,7 @@ func (a *AppBuilder) Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...fu a.app.BaseApp = bApp a.app.configurator = module.NewConfigurator(a.app.cdc, a.app.MsgServiceRouter(), a.app.GRPCQueryRouter()) + if err := a.app.ModuleManager.RegisterServices(a.app.configurator); err != nil { panic(err) } diff --git a/runtime/events.go b/runtime/events.go index 6fe70f1636..752dcae2bb 100644 --- a/runtime/events.go +++ b/runtime/events.go @@ -33,12 +33,12 @@ func NewEventManager(ctx context.Context) event.Manager { } // Emit emits an typed event that is defined in the protobuf file. -// In the future these events will be added to consensus +// In the future these events will be added to consensus. func (e Events) Emit(ctx context.Context, event protoiface.MessageV1) error { return e.EventManagerI.EmitTypedEvent(event) } -// EmitKV emits a key value pair event +// EmitKV emits a key value pair event. func (e Events) EmitKV(ctx context.Context, eventType string, attrs ...event.Attribute) error { attributes := make([]sdk.Attribute, 0, len(attrs)) @@ -46,15 +46,12 @@ func (e Events) EmitKV(ctx context.Context, eventType string, attrs ...event.Att attributes = append(attributes, sdk.NewAttribute(attr.Key, attr.Value)) } - events := sdk.Events{ - sdk.NewEvent(eventType, attributes...), - } - e.EventManagerI.EmitEvents(events) + e.EventManagerI.EmitEvents(sdk.Events{sdk.NewEvent(eventType, attributes...)}) return nil } // Emit emits an typed event that is defined in the protobuf file. -// In the future these events will be added to consensus +// In the future these events will be added to consensus. func (e Events) EmitNonConsensus(ctx context.Context, event protoiface.MessageV1) error { return e.EventManagerI.EmitTypedEvent(event) } diff --git a/runtime/module.go b/runtime/module.go index c9f576806f..e1783efc3c 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -94,7 +94,7 @@ func ProvideApp(interfaceRegistry codectypes.InterfaceRegistry) ( // At startup, check that all proto annotations are correct. if err := msgservice.ValidateProtoAnnotations(protoFiles); err != nil { - // Once we switch to using protoreflect-based antehandlers, we might + // Once we switch to using protoreflect-based ante handlers, we might // want to panic here instead of logging a warning. _, _ = fmt.Fprintln(os.Stderr, err.Error()) } @@ -178,10 +178,12 @@ func ProvideInterfaceRegistry(customGetSigners []signing.CustomGetSigner) (codec if err != nil { return nil, err } + err = interfaceRegistry.SigningContext().Validate() if err != nil { return nil, err } + return interfaceRegistry, nil } diff --git a/runtime/services/autocli.go b/runtime/services/autocli.go index e9f3f1a0e3..66c70b31e7 100644 --- a/runtime/services/autocli.go +++ b/runtime/services/autocli.go @@ -32,6 +32,7 @@ func NewAutoCLIQueryService(appModules map[string]interface{}) *AutoCLIQueryServ } // ExtractAutoCLIOptions extracts autocli ModuleOptions from the provided app modules. +// // Example Usage: // // ExtractAutoCLIOptions(ModuleManager.Modules) diff --git a/runtime/types.go b/runtime/types.go index a87ff89442..afde0e42d1 100644 --- a/runtime/types.go +++ b/runtime/types.go @@ -18,7 +18,7 @@ type AppI interface { Name() string // The application types codec. - // NOTE: This shoult be sealed before being returned. + // NOTE: This should NOT be sealed before being returned. LegacyAmino() *codec.LegacyAmino // Application updates every begin block.