Skip to content

Commit

Permalink
add + clarify comments (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttl33 authored Oct 17, 2023
1 parent 5deb9f6 commit f0f134c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions protocol/app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
}
Expand Down
7 changes: 4 additions & 3 deletions protocol/lib/ante/app_injected_msg_ante_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit f0f134c

Please sign in to comment.