Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(x/auth/middleware)!: tx middleware to support pluggable feemarket module #11413

Merged
merged 30 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d4f51a2
Refactor tx middleware to support pluggable feemarket module
yihuang Mar 18, 2022
a6271d9
changelog
yihuang Mar 18, 2022
8a06c23
add overflow protection
yihuang Mar 18, 2022
3c0b971
reject non-empty auth extension options in legacy amino mode
yihuang Mar 21, 2022
62f4789
fix review suggestions
yihuang Mar 22, 2022
aabd04b
update changelog
yihuang Mar 22, 2022
5ef3bd4
Update x/auth/middleware/static_feemarket.go
yihuang Mar 22, 2022
6cd75ab
review suggestions
yihuang Mar 22, 2022
88df9fa
Merge remote-tracking branch 'fork/feemarket-step-1' into feemarket-s…
yihuang Mar 22, 2022
6e2468f
update changelog
yihuang Mar 22, 2022
a74ca39
make FeeMarket in TxHandlerOptions optional
yihuang Mar 22, 2022
a1f5911
Apply suggestions from code review
yihuang Mar 22, 2022
93f1396
remove extension options in AuthInfo
yihuang Mar 22, 2022
12b95d2
update changelog
yihuang Mar 22, 2022
e6e754c
Merge branch 'feemarket-step-1' of https://github.com/yihuang/cosmos-…
yihuang Mar 22, 2022
75ae1ee
fix extension option middleware unit tests
yihuang Mar 22, 2022
1c66c62
update comments
yihuang Mar 23, 2022
2585d45
Update x/auth/middleware/ext.go
yihuang Mar 25, 2022
21deb29
Merge branch 'master' into feemarket-step-1
yihuang Mar 25, 2022
78817e2
Update CHANGELOG.md
yihuang Mar 29, 2022
5b79cc8
remove FeeMarket interface
yihuang Mar 29, 2022
eb5dc95
Merge remote-tracking branch 'fork/feemarket-step-1' into feemarket-s…
yihuang Mar 29, 2022
ff1baa6
Merge remote-tracking branch 'origin/master' into feemarket-step-1
yihuang Mar 29, 2022
9a2bbed
Update CHANGELOG.md
yihuang Mar 29, 2022
14ce986
remove FeeMarket interface
yihuang Mar 29, 2022
a579692
Merge branch 'feemarket-step-1' of https://github.com/yihuang/cosmos-…
yihuang Mar 29, 2022
0b93914
unpack extension options Any's
yihuang Mar 29, 2022
1b36270
fix unit test
yihuang Mar 29, 2022
3fa9280
Merge branch 'master' into feemarket-step-1
yihuang Mar 29, 2022
3b76647
Merge branch 'master' into feemarket-step-1
amaury1093 Mar 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) authz `NewGrant` takes a new argument: block time, to correctly validate expire time.
* [\#10961](https://github.com/cosmos/cosmos-sdk/pull/10961) Support third-party modules to add extension snapshots to state-sync.
* [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code.
* (ante) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to support pluggable feemarket module. The API breakages: a) Removed `MempoolFeeMiddleware` and `TxPriorityMiddleware`, the functionalities are moved into `DeductFeeMiddleware`, b) Added a `FeeMarket` field to `HandlerOptions`, and a `FeeMarket` parameter to `DeductFeeMiddleware`, when set to `StaticFeeMarket{}`, it'll keep the existing behavior, c) Added an `extention_options` field to `AuthInfo` in `Tx`, d) Added a `NewAuthExtensionOptionsMiddleware` middleware to check the `extension_options` field.


### Client Breaking Changes
Expand Down
4 changes: 2 additions & 2 deletions api/cosmos/feegrant/v1beta1/feegrant.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/cosmos/feegrant/v1beta1/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

365 changes: 261 additions & 104 deletions api/cosmos/tx/v1beta1/tx.pulsar.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ message AuthInfo {
//
// Since: cosmos-sdk 0.46
Tip tip = 3;

// extension_options are arbitrary options that can be added by chains
// when the default options are not sufficient. If any of these are present
// and can't be handled, the transaction will be rejected
alexanderbez marked this conversation as resolved.
Show resolved Hide resolved
repeated google.protobuf.Any extension_options = 1023;
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
}

// SignerInfo describes the public key and signing mode of a single top-level
Expand Down
1 change: 1 addition & 0 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []strin
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer,
TxDecoder: txConfig.TxDecoder(),
FeeMarket: authmiddleware.StaticFeeMarket{},
})
if err != nil {
panic(err)
Expand Down
3 changes: 3 additions & 0 deletions types/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ var (
// ErrAppConfig defines an error occurred if min-gas-prices field in BaseConfig is empty.
ErrAppConfig = Register(RootCodespace, 40, "error in app.toml")

// ErrUnknownAuthExtensionOptions defines an error for unknown auth_info extension options.
ErrUnknownAuthExtensionOptions = Register(RootCodespace, 41, "unknown auth_info extension options")
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

// ErrPanic is only set when we recover from a panic, so we know to
// redact potentially sensitive system info
ErrPanic = errorsmod.ErrPanic
Expand Down
197 changes: 132 additions & 65 deletions types/tx/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions types/tx/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ func (t *Tx) FeeGranter() sdk.AccAddress {
return nil
}

// AuthExtensionOptions returns the AuthInfo's ExtensionOptions,
// implements the interface HasAuthExtensionOptionsTx.
func (t *Tx) AuthExtensionOptions() []*codectypes.Any {
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
return t.AuthInfo.ExtensionOptions
}

// UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method
func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
if t.Body != nil {
Expand Down
Loading