-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow whitelisted tx fee tokens based on conversion rate to OSMO (#394)
* in progress * in progress * in progress * update proto genesis basetokens -> basetoken * passed txfees test * working! * address @antstalepresh review * remove unnecessary file * Update app/ante.go * Apply comment suggestions from code review Co-authored-by: Dev Ojha <[email protected]> * comments from @ValarDragon review * delete REST folder * panic in initgenesis * Update x/txfees/module.go Co-authored-by: Dev Ojha <[email protected]> * remove memkey * remove old mempoolfeedecorator * stuff happened * switch to table driven tests * mempool decorator tests * register legacy amino codec * fix lint * add readme stub * improve lint * Update x/txfees/keeper/feedecorator.go Co-authored-by: Dev Ojha <[email protected]> * Update x/txfees/keeper/feedecorator.go * Bump go mod versions * Fix keeper for main updates Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: ValarDragon <[email protected]>
- Loading branch information
1 parent
44460ef
commit 2a240fa
Showing
36 changed files
with
4,447 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package app | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/signing" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
|
||
ante "github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
|
||
txfeeskeeper "github.com/osmosis-labs/osmosis/x/txfees/keeper" | ||
txfeestypes "github.com/osmosis-labs/osmosis/x/txfees/types" | ||
) | ||
|
||
// Link to default ante handler used by cosmos sdk: | ||
// https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/ante.go#L41 | ||
func NewAnteHandler( | ||
ak ante.AccountKeeper, bankKeeper authtypes.BankKeeper, | ||
txFeesKeeper txfeeskeeper.Keeper, spotPriceCalculator txfeestypes.SpotPriceCalculator, | ||
sigGasConsumer ante.SignatureVerificationGasConsumer, | ||
signModeHandler signing.SignModeHandler, | ||
) sdk.AnteHandler { | ||
return sdk.ChainAnteDecorators( | ||
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first | ||
ante.NewRejectExtensionOptionsDecorator(), | ||
// Use Mempool Fee Decorator from our txfees module instead of default one from auth | ||
// https://github.com/cosmos/cosmos-sdk/blob/master/x/auth/middleware/fee.go#L34 | ||
txfeeskeeper.NewMempoolFeeDecorator(txFeesKeeper), | ||
ante.NewValidateBasicDecorator(), | ||
ante.TxTimeoutHeightDecorator{}, | ||
ante.NewValidateMemoDecorator(ak), | ||
ante.NewConsumeGasForTxSizeDecorator(ak), | ||
ante.NewRejectFeeGranterDecorator(), | ||
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators | ||
ante.NewValidateSigCountDecorator(ak), | ||
ante.NewDeductFeeDecorator(ak, bankKeeper), | ||
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer), | ||
ante.NewSigVerificationDecorator(ak, signModeHandler), | ||
ante.NewIncrementSequenceDecorator(ak), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
package osmosis.txfees.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types"; | ||
|
||
// FeeToken is a struct that specifies a coin denom, and pool ID pair. | ||
// This marks the token as eligible for use as a tx fee asset in Osmosis. | ||
// Its price in osmo is derived through looking at the provided pool ID. | ||
// The pool ID must have osmo as one of its assets. | ||
message FeeToken { | ||
option (gogoproto.equal) = true; | ||
|
||
string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; | ||
uint64 poolID = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
syntax = "proto3"; | ||
package osmosis.txfees.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "osmosis/txfees/v1beta1/feetoken.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types"; | ||
|
||
// GenesisState defines the txfees module's genesis state. | ||
message GenesisState { | ||
string basedenom = 1; | ||
repeated FeeToken feetokens = 2 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
syntax = "proto3"; | ||
package osmosis.txfees.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "osmosis/txfees/v1beta1/feetoken.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types"; | ||
|
||
// UpdateFeeTokenProposal is a gov Content type for adding a new whitelisted fee | ||
// token. It must specify a denom along with gamm pool ID to use as a spot price | ||
// calculator. It can be used to add a new denom to the whitelist It can also be | ||
// used to update the Pool to associate with the denom. If Pool ID is set to 0, | ||
// it will remove the denom from the whitelisted set. | ||
message UpdateFeeTokenProposal { | ||
option (gogoproto.equal) = true; | ||
option (gogoproto.goproto_getters) = false; | ||
option (gogoproto.goproto_stringer) = false; | ||
|
||
string title = 1 [ (gogoproto.moretags) = "yaml:\"title\"" ]; | ||
string description = 2 [ (gogoproto.moretags) = "yaml:\"description\"" ]; | ||
FeeToken feetoken = 3 [ | ||
(gogoproto.moretags) = "yaml:\"fee_token\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
syntax = "proto3"; | ||
package osmosis.txfees.v1beta1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "google/protobuf/duration.proto"; | ||
|
||
import "osmosis/txfees/v1beta1/feetoken.proto"; | ||
|
||
option go_package = "github.com/osmosis-labs/osmosis/x/txfees/types"; | ||
|
||
service Query { | ||
// FeeTokens returns a list of all the whitelisted fee tokens and their | ||
// corresponding pools It does not include the BaseDenom, which has its own | ||
// query endpoint | ||
rpc FeeTokens(QueryFeeTokensRequest) returns (QueryFeeTokensResponse) { | ||
option (google.api.http).get = "/osmosis/txfees/v1beta1/fee_tokens"; | ||
} | ||
|
||
rpc DenomPoolId(QueryDenomPoolIdRequest) returns (QueryDenomPoolIdResponse) { | ||
option (google.api.http).get = | ||
"/osmosis/txfees/v1beta1/denom_pool_id/{denom}"; | ||
} | ||
|
||
rpc BaseDenom(QueryBaseDenomRequest) returns (QueryBaseDenomResponse) { | ||
option (google.api.http).get = "/osmosis/txfees/v1beta1/base_denom"; | ||
} | ||
} | ||
|
||
message QueryFeeTokensRequest {} | ||
message QueryFeeTokensResponse { | ||
|
||
repeated FeeToken fee_tokens = 1 [ | ||
(gogoproto.moretags) = "yaml:\"fee_tokens\"", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
message QueryDenomPoolIdRequest { | ||
string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ]; | ||
} | ||
message QueryDenomPoolIdResponse { | ||
uint64 poolID = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; | ||
} | ||
|
||
message QueryBaseDenomRequest {} | ||
message QueryBaseDenomResponse { | ||
string base_denom = 1 [ (gogoproto.moretags) = "yaml:\"base_denom\"" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Txfees | ||
|
||
This module allows validators to define their min gas price is a single "base denom", but then allows users to define their tx fees in any whitelisted fee token. It does this by converting the whitelisted fee token to its equivalent value in base denom fee, using a "Spot Price calculator" (such as the gamm keeper). |
Oops, something went wrong.