Skip to content

Commit

Permalink
make FeeMarket in TxHandlerOptions optional
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Mar 22, 2022
1 parent 6e2468f commit a74ca39
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/architecture/adr-045-check-delivertx-middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* 20.08.2021: Initial draft.
* 07.12.2021: Update `tx.Handler` interface ([\#10693](https://github.com/cosmos/cosmos-sdk/pull/10693)).
* 22.03.2022: Update code snippets.

## Status

Expand Down
1 change: 0 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer,
TxDecoder: txConfig.TxDecoder(),
FeeMarket: authmiddleware.ValidatorTxFee{},
})
if err != nil {
panic(err)
Expand Down
9 changes: 7 additions & 2 deletions x/auth/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) {
sigGasConsumer = DefaultSigVerificationGasConsumer
}

var feeMarket = options.FeeMarket
if feeMarket == nil {
feeMarket = ValidatorTxFee{}
}

return ComposeMiddlewares(
NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter),
NewTxDecoderMiddleware(options.TxDecoder),
Expand All @@ -94,7 +99,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) {
// tx.
RejectExtensionOptionsMiddleware,
// Reject auth_info extension options that don't pass the criteria.
NewAuthExtensionOptionsMiddleware(options.FeeMarket.AllowAuthExtensionOption),
NewAuthExtensionOptionsMiddleware(feeMarket.AllowAuthExtensionOption),
ValidateBasicMiddleware,
TxTimeoutHeightMiddleware,
ValidateMemoMiddleware(options.AccountKeeper),
Expand All @@ -103,7 +108,7 @@ func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) {
// ComposeMiddlewares godoc for details.
// `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware,
// so their storage writes are not discarded when tx fails.
DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.FeeMarket),
DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, feeMarket),
SetPubKeyMiddleware(options.AccountKeeper),
ValidateSigCountMiddleware(options.AccountKeeper),
SigGasConsumeMiddleware(options.AccountKeeper, sigGasConsumer),
Expand Down
1 change: 0 additions & 1 deletion x/auth/middleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,6 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() {
}
},
TxDecoder: s.clientCtx.TxConfig.TxDecoder(),
FeeMarket: middleware.ValidatorTxFee{},
},
)
s.Require().NoError(err)
Expand Down
1 change: 0 additions & 1 deletion x/auth/middleware/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context {
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: middleware.DefaultSigVerificationGasConsumer,
TxDecoder: s.clientCtx.TxConfig.TxDecoder(),
FeeMarket: middleware.ValidatorTxFee{},
})
s.Require().NoError(err)
s.txHandler = txHandler
Expand Down

0 comments on commit a74ca39

Please sign in to comment.