From f0f134c7a78b58070847511ef6090a1d968828ed Mon Sep 17 00:00:00 2001 From: ttl33 <19664986+ttl33@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:56:24 -0700 Subject: [PATCH] add + clarify comments (#495) --- protocol/app/ante.go | 14 ++++++++++++++ protocol/lib/ante/app_injected_msg_ante_wrapper.go | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/protocol/app/ante.go b/protocol/app/ante.go index cd410e0959..3751acb07b 100644 --- a/protocol/app/ante.go +++ b/protocol/app/ante.go @@ -74,13 +74,18 @@ func newAnteDecoratorChain(options HandlerOptions) []sdk.AnteDecorator { ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first ), ), + // Set `FreeInfiniteGasMeter` for app-injected messages, and clob transactions. customante.NewFreeInfiniteGasDecorator(), + ante.NewExtensionOptionsDecorator(options.ExtensionOptionChecker), customante.NewValidateMsgTypeDecorator(), + + // Note: app-injected messages are not signed on purpose. libante.NewAppInjectedMsgAnteWrapper( ante.NewValidateBasicDecorator(), ), + ante.NewTxTimeoutHeightDecorator(), ante.NewValidateMemoDecorator(options.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(options.AccountKeeper), @@ -98,21 +103,30 @@ func newAnteDecoratorChain(options HandlerOptions) []sdk.AnteDecorator { ), // SetPubKeyDecorator must be called before all signature verification decorators + // Note: app-injected messages are not signed on purpose. libante.NewAppInjectedMsgAnteWrapper( ante.NewSetPubKeyDecorator(options.AccountKeeper), ), + ante.NewValidateSigCountDecorator(options.AccountKeeper), + + // Note: app-injected messages don't require Gas fees. libante.NewAppInjectedMsgAnteWrapper( ante.NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), ), + + // Note: app-injected messages are not signed on purpose. libante.NewAppInjectedMsgAnteWrapper( customante.NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), ), + + // Note: app-injected messages, and short-term clob txs don't have sequence numbers on purpose. libante.NewAppInjectedMsgAnteWrapper( clobante.NewShortTermSingleMsgClobTxAnteWrapper( ante.NewIncrementSequenceDecorator(options.AccountKeeper), ), ), + clobante.NewRateLimitDecorator(options.ClobKeeper), clobante.NewClobDecorator(options.ClobKeeper), } diff --git a/protocol/lib/ante/app_injected_msg_ante_wrapper.go b/protocol/lib/ante/app_injected_msg_ante_wrapper.go index 984bcebb72..368d977f68 100644 --- a/protocol/lib/ante/app_injected_msg_ante_wrapper.go +++ b/protocol/lib/ante/app_injected_msg_ante_wrapper.go @@ -27,9 +27,10 @@ func (imaw AppInjectedMsgAnteWrapper) AnteHandle( simulate bool, next sdk.AnteHandler, ) (sdk.Context, error) { - // "App-injected message" tx is skipped, because such tx is not signed on purpose. - // If a tx is not signed, signature related functions like `GetSigners` will fail - // with "empty address string is not allowed" error. + // "App-injected message" tx must skip certain AnteHandlers. + // For example, "App-injected message" tx is not signed on purpose and if a tx is not signed, + // signature related functions like `GetSigners` will fail due to signer field being empty. + // Therefore, we skip the AnteHandlers that require the tx to be signed. if IsSingleAppInjectedMsg(tx.GetMsgs()) { return next(ctx, tx, simulate) }