diff --git a/CHANGELOG.md b/CHANGELOG.md index c2904dd5fa1..84f8fc1181b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (gaia) [#2442](https://github.com/cosmos/gaia/pull/2442) Bump [Interchain-Security](https://github.com/cosmos/interchain-security) to [v1.1.1](https://github.com/cosmos/interchain-security/tree/v1.1.1). ### State Machine Breaking +* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking. * (gaia) Bump Golang prerequisite from 1.18 to 1.20 see (https://go.dev/blog/go1.20) for details. * (feat!) [#2447] Update Global Fee's AnteHandler to check tx fees against the network min gas prices in DeliverTx mode. diff --git a/ante/ante.go b/ante/ante.go index 16c82eb6dd4..3adc9605fdb 100644 --- a/ante/ante.go +++ b/ante/ante.go @@ -13,13 +13,6 @@ import ( gaiafeeante "github.com/cosmos/gaia/v9/x/globalfee/ante" ) -// maxTotalBypassMinFeeMsgGasUsage is the allowed maximum gas usage -// for all the bypass msgs in a transactions. -// A transaction that contains only bypass message types and the gas usage does not -// exceed maxTotalBypassMinFeeMsgGasUsage can be accepted with a zero fee. -// For details, see gaiafeeante.NewFeeDecorator() -var maxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 - // HandlerOptions extend the SDK's AnteHandler options by requiring the IBC // channel keeper. type HandlerOptions struct { @@ -68,7 +61,7 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) { ante.NewValidateMemoDecorator(opts.AccountKeeper), ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper), NewGovPreventSpamDecorator(opts.Codec, opts.GovKeeper), - gaiafeeante.NewFeeDecorator(opts.BypassMinFeeMsgTypes, opts.GlobalFeeSubspace, opts.StakingSubspace, maxTotalBypassMinFeeMsgGasUsage), + gaiafeeante.NewFeeDecorator(opts.GlobalFeeSubspace, opts.StakingSubspace), ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper), ante.NewSetPubKeyDecorator(opts.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators ante.NewValidateSigCountDecorator(opts.AccountKeeper), diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 42172f01b1e..e2f17b2f6b5 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -1,44 +1,57 @@ # Protobuf Documentation - ## Table of Contents - [gaia/globalfee/v1beta1/query.proto](#gaia/globalfee/v1beta1/query.proto) - - [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest) - - [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse) + - [QueryParamsRequest](#gaia.globalfee.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#gaia.globalfee.v1beta1.QueryParamsResponse) - - [Query](#gaia.globalfee.v1beta1.Query) + - [Query](#gaia.globalfee.v1beta1.Query) - [gaia/globalfee/v1beta1/genesis.proto](#gaia/globalfee/v1beta1/genesis.proto) - - [GenesisState](#gaia.globalfee.v1beta1.GenesisState) - - [Params](#gaia.globalfee.v1beta1.Params) + - [GenesisState](#gaia.globalfee.v1beta1.GenesisState) + - [Params](#gaia.globalfee.v1beta1.Params) - [Scalar Value Types](#scalar-value-types) + +

Top

## gaia/globalfee/v1beta1/query.proto - -### QueryMinimumGasPricesRequest + + +### QueryParamsRequest QueryMinimumGasPricesRequest is the request type for the Query/MinimumGasPrices RPC method. - -### QueryMinimumGasPricesResponse + + + + + +### QueryParamsResponse QueryMinimumGasPricesResponse is the response type for the Query/MinimumGasPrices RPC method. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | | + + + + @@ -46,42 +59,57 @@ Query/MinimumGasPrices RPC method. + ### Query - Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `MinimumGasPrices` | [QueryMinimumGasPricesRequest](#gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest) | [QueryMinimumGasPricesResponse](#gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse) | | GET|/gaia/globalfee/v1beta1/minimum_gas_prices| +| `Params` | [QueryParamsRequest](#gaia.globalfee.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#gaia.globalfee.v1beta1.QueryParamsResponse) | | GET|/gaia/globalfee/v1beta1/params| + +

Top

## gaia/globalfee/v1beta1/genesis.proto + + ### GenesisState - GenesisState - initial state of module + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `params` | [Params](#gaia.globalfee.v1beta1.Params) | | Params of this module | + + + + + ### Params - Params defines the set of module parameters. + | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | Minimum stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see | +| `minimum_gas_prices` | [cosmos.base.v1beta1.DecCoin](#cosmos.base.v1beta1.DecCoin) | repeated | minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. When multiple coins are defined then they are accepted alternatively. The list must be sorted by denoms asc. No duplicate denoms or zero amount values allowed. For more information see https://docs.cosmos.network/main/modules/auth#concepts | +| `bypass_min_fee_msg_types` | [string](#string) | repeated | bypass_min_fee_msg_types defines a list of message type urls that are free of fee charge. | +| `max_total_bypass_min_fee_msg_gas_usage` | [uint64](#uint64) | | max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage allowed for a transaction containing only messages of types in bypass_min_fee_msg_types to bypass fee charge. | + + + + @@ -91,6 +119,8 @@ Params defines the set of module parameters. + + ## Scalar Value Types | .proto Type | Notes | C++ | Java | Python | Go | C# | PHP | Ruby | @@ -110,3 +140,4 @@ Params defines the set of module parameters. | bool | | bool | boolean | boolean | bool | bool | boolean | TrueClass/FalseClass | | string | A string must always contain UTF-8 encoded or 7-bit ASCII text. | string | String | str/unicode | string | string | string | String (UTF-8) | | bytes | May contain any arbitrary sequence of bytes. | string | ByteString | str | []byte | ByteString | string | String (ASCII-8BIT) | + diff --git a/go.mod b/go.mod index 773cb004a95..852ce3564fc 100644 --- a/go.mod +++ b/go.mod @@ -165,7 +165,7 @@ require ( github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/iancoleman/orderedmap v0.2.0 // indirect - github.com/imdario/mergo v0.3.13 // indirect + github.com/imdario/mergo v0.3.15 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jgautheron/goconst v1.5.1 // indirect @@ -284,7 +284,7 @@ require ( go.uber.org/goleak v1.1.12 // indirect go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.5.0 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect golang.org/x/exp/typeparams v0.0.0-20230224173230-c95f2b4c22f2 // indirect golang.org/x/mod v0.9.0 // indirect diff --git a/go.sum b/go.sum index 47938240eba..69de1126a4b 100644 --- a/go.sum +++ b/go.sum @@ -722,8 +722,8 @@ github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6 github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= -github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM= +github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= @@ -1407,8 +1407,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1913,7 +1913,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= diff --git a/proto/gaia/globalfee/v1beta1/genesis.proto b/proto/gaia/globalfee/v1beta1/genesis.proto index 39493b0c637..d83815a060a 100644 --- a/proto/gaia/globalfee/v1beta1/genesis.proto +++ b/proto/gaia/globalfee/v1beta1/genesis.proto @@ -17,7 +17,7 @@ message GenesisState { // Params defines the set of module parameters. message Params { - // Minimum stores the minimum gas price(s) for all TX on the chain. + // minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. // When multiple coins are defined then they are accepted alternatively. // The list must be sorted by denoms asc. No duplicate denoms or zero amount // values allowed. For more information see @@ -28,4 +28,15 @@ message Params { (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; + // bypass_min_fee_msg_types defines a list of message type urls + // that are free of fee charge. + repeated string bypass_min_fee_msg_types = 2 [ + (gogoproto.jsontag) = "bypass_min_fee_msg_types,omitempty", + (gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\"" + ]; + + // max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage + // allowed for a transaction containing only messages of types in bypass_min_fee_msg_types + // to bypass fee charge. + uint64 max_total_bypass_min_fee_msg_gas_usage = 3; } diff --git a/proto/gaia/globalfee/v1beta1/query.proto b/proto/gaia/globalfee/v1beta1/query.proto index 81f587c5bd5..43598286976 100644 --- a/proto/gaia/globalfee/v1beta1/query.proto +++ b/proto/gaia/globalfee/v1beta1/query.proto @@ -9,24 +9,27 @@ option go_package = "github.com/cosmos/gaia/x/globalfee/types"; // Query defines the gRPC querier service. service Query { - rpc MinimumGasPrices(QueryMinimumGasPricesRequest) - returns (QueryMinimumGasPricesResponse) { + rpc Params(QueryParamsRequest) + returns (QueryParamsResponse) { option (google.api.http).get = - "/gaia/globalfee/v1beta1/minimum_gas_prices"; + "/gaia/globalfee/v1beta1/params"; } } // QueryMinimumGasPricesRequest is the request type for the // Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesRequest {} +message QueryParamsRequest {} // QueryMinimumGasPricesResponse is the response type for the // Query/MinimumGasPrices RPC method. -message QueryMinimumGasPricesResponse { +message QueryParamsResponse { repeated cosmos.base.v1beta1.DecCoin minimum_gas_prices = 1 [ (gogoproto.nullable) = false, (gogoproto.jsontag) = "minimum_gas_prices,omitempty", (gogoproto.moretags) = "yaml:\"minimum_gas_prices\"", (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins" ]; + + repeated string bypass_min_fee_msg_types = 2 [(gogoproto.moretags) = "yaml:\"bypass_min_fee_msg_types\""]; + uint64 max_total_bypass_min_fee_msg_gas_usage = 3; } diff --git a/proto/scripts/protoc-doc-gen.sh b/proto/scripts/protoc-doc-gen.sh old mode 100644 new mode 100755 diff --git a/tests/e2e/e2e_bypassminfee_test.go b/tests/e2e/e2e_bypassminfee_test.go index ecc16c25c30..61be12f0b6a 100644 --- a/tests/e2e/e2e_bypassminfee_test.go +++ b/tests/e2e/e2e_bypassminfee_test.go @@ -2,21 +2,96 @@ package e2e import ( "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" ) -func (s *IntegrationTestSuite) testByPassMinFeeWithdrawReward() { +func (s *IntegrationTestSuite) testBypassMinFeeWithdrawReward(endpoint string) { + // submit gov prop to change bypass-msg param to MsgWithdrawDelegatorReward + submitterAddr := s.chainA.validators[0].keyInfo.GetAddress() + submitter := submitterAddr.String() + proposalCounter++ + s.govProposeNewBypassMsgs([]string{sdk.MsgTypeURL(&distributiontypes.MsgWithdrawDelegatorReward{})}, proposalCounter, submitter, standardFees.String()) + paidFeeAmt := math.LegacyMustNewDecFromStr(minGasPrice).Mul(math.LegacyNewDec(gas)).String() payee := s.chainA.validators[0].keyInfo.GetAddress() - // pass - s.T().Logf("bypass-msg with fee in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+uatomDenom, false) - // pass - s.T().Logf("bypass-msg with zero coin in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+uatomDenom, false) - // pass - s.T().Logf("bypass-msg with zero coin not in the denom of global fee, pass") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), "0"+photonDenom, false) - // fail - s.T().Logf("bypass-msg with non-zero coin not in the denom of global fee, fail") - s.execWithdrawAllRewards(s.chainA, 0, payee.String(), paidFeeAmt+photonDenom, true) + + testCases := []struct { + name string + fee string + changeMaxBypassGasUsage bool + expErr bool + }{ + { + "bypass-msg with fee in the denom of global fee, pass", + paidFeeAmt + uatomDenom, + false, + false, + }, + { + "bypass-msg with zero coin in the denom of global fee, pass", + "0" + uatomDenom, + false, + false, + }, + { + "bypass-msg with zero coin not in the denom of global fee, pass", + "0" + photonDenom, + false, + false, + }, + { + "bypass-msg with non-zero coin not in the denom of global fee, fail", + paidFeeAmt + photonDenom, + false, + true, + }, + { + "bypass-msg with zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, fail", + "0" + uatomDenom, + true, + true, + }, + { + "bypass-msg with non zero coin in the denom of global fee and maxTotalBypassMinFeeMsgGasUsage set to 1, pass", + paidFeeAmt + uatomDenom, + false, + false, + }, + } + + for _, tc := range testCases { + + if tc.changeMaxBypassGasUsage { + proposalCounter++ + // change MaxTotalBypassMinFeeMsgGasUsage through governance proposal from 1_000_0000 to 1 + s.govProposeNewMaxTotalBypassMinFeeMsgGasUsage(1, proposalCounter, submitter) + } + + // get delegator rewards + rewards, err := queryDelegatorTotalRewards(endpoint, payee.String()) + s.Require().NoError(err) + + // get delegator stake balance + oldBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) + + // withdraw rewards + s.Run(tc.name, func() { + s.execWithdrawAllRewards(s.chainA, 0, payee.String(), tc.fee, tc.expErr) + }) + + if !tc.expErr { + // get updated balance + incrBalance, err := getSpecificBalance(endpoint, payee.String(), stakeDenom) + s.Require().NoError(err) + + // compute sum of old balance and stake token rewards + oldBalancePlusReward := rewards.GetTotal().Add(sdk.NewDecCoinFromCoin(oldBalance)) + s.Require().Equal(oldBalancePlusReward[0].Denom, stakeDenom) + + // check updated balance got increased by at least oldBalancePlusReward + s.Require().True(sdk.NewDecCoinFromCoin(incrBalance).IsGTE(oldBalancePlusReward[0])) + } + } } diff --git a/tests/e2e/e2e_exec_test.go b/tests/e2e/e2e_exec_test.go index 791cd6ea9e0..6b007ef7c0b 100644 --- a/tests/e2e/e2e_exec_test.go +++ b/tests/e2e/e2e_exec_test.go @@ -310,7 +310,7 @@ func (s *IntegrationTestSuite) execBankSendBatch( return sucessBankSendCount } -func (s *IntegrationTestSuite) execWithdrawAllRewards(c *chain, valIdx int, payee, fees string, expectErr bool) { //nolint:unparam +func (s *IntegrationTestSuite) execWithdrawAllRewards(c *chain, valIdx int, payee, fees string, expectErr bool) { ctx, cancel := context.WithTimeout(context.Background(), time.Minute) defer cancel() @@ -367,6 +367,7 @@ func (s *IntegrationTestSuite) runGovExec(c *chain, valIdx int, submitterAddr, g generalFlags := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, submitterAddr), + fmt.Sprintf("--%s=%s", flags.FlagGas, "300000"), // default 200000 isn't enough fmt.Sprintf("--%s=%s", flags.FlagGasPrices, fees), fmt.Sprintf("--%s=%s", flags.FlagChainID, c.id), "--keyring-backend=test", diff --git a/tests/e2e/e2e_globalfee_proposal_test.go b/tests/e2e/e2e_globalfee_proposal_test.go index 6da9b4575db..232868cedca 100644 --- a/tests/e2e/e2e_globalfee_proposal_test.go +++ b/tests/e2e/e2e_globalfee_proposal_test.go @@ -46,3 +46,78 @@ func (s *IntegrationTestSuite) govProposeNewGlobalfee(newGlobalfee sdk.DecCoins, 5*time.Second, ) } + +func (s *IntegrationTestSuite) govProposeNewBypassMsgs(newBypassMsgs []string, proposalCounter int, submitter string, fees string) { //nolint:unparam + s.writeGovParamChangeProposalBypassMsgs(s.chainA, newBypassMsgs) + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + submitGovFlags := []string{"param-change", configFile(proposalBypassMsgFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + + // gov proposing new fees + s.T().Logf("Proposal number: %d", proposalCounter) + s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change bypass min fee msg types to %s", newBypassMsgs) + s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) + + // query the proposal status and new fee + s.Require().Eventually( + func() bool { + proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter) + s.Require().NoError(err) + return proposal.GetProposal().Status == gov.StatusPassed + }, + 15*time.Second, + 5*time.Second, + ) + + s.Require().Eventually( + func() bool { + bypassMsgs, err := queryBypassMsgs(chainAAPIEndpoint) + s.T().Logf("After gov new global fee proposal: %s", newBypassMsgs) + s.Require().NoError(err) + + // attention: if global fee is empty, when query globalfee, it shows empty rather than default ante.DefaultZeroGlobalFee() = 0uatom. + s.Require().Equal(newBypassMsgs, bypassMsgs) + return true + }, + 15*time.Second, + 5*time.Second, + ) +} + +func (s *IntegrationTestSuite) govProposeNewMaxTotalBypassMinFeeMsgGasUsage(newGas uint64, proposalCounter int, submitter string) { + s.writeGovParamChangeProposalMaxTotalBypass(s.chainA, newGas) + chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + submitGovFlags := []string{"param-change", configFile(proposalMaxTotalBypassFilename)} + depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()} + voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"} + + // gov proposing new max gas usage for bypass msgs + s.T().Logf("Proposal number: %d", proposalCounter) + s.T().Logf("Submitting, deposit and vote legacy Gov Proposal: change maxTotalBypassMinFeeMsgGasUsage to %d", newGas) + s.runGovProcess(chainAAPIEndpoint, submitter, proposalCounter, paramtypes.ProposalTypeChange, submitGovFlags, depositGovFlags, voteGovFlags, "vote", false) + + // query the proposal status and max gas usage for bypass msgs + s.Require().Eventually( + func() bool { + proposal, err := queryGovProposal(chainAAPIEndpoint, proposalCounter) + s.Require().NoError(err) + return proposal.GetProposal().Status == gov.StatusPassed + }, + 15*time.Second, + 5*time.Second, + ) + + s.Require().Eventually( + func() bool { + gas, err := queryMaxTotalBypassMinFeeMsgGasUsage(chainAAPIEndpoint) + s.T().Logf("After gov new global fee proposal: %d", gas) + s.Require().NoError(err) + + s.Require().Equal(newGas, gas) + return true + }, + 15*time.Second, + 5*time.Second, + ) +} diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 83e35e83c0d..9fad1f1c26b 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -50,20 +50,24 @@ const ( gaiaHomePath = "/home/nonroot/.gaia" photonDenom = "photon" uatomDenom = "uatom" + stakeDenom = "stake" initBalanceStr = "110000000000stake,100000000000000000photon,100000000000000000uatom" minGasPrice = "0.00001" // the test globalfee in genesis is the same as minGasPrice // global fee lower/higher than min_gas_price - initialGlobalFeeAmt = "0.00001" - lowGlobalFeesAmt = "0.000001" - highGlobalFeeAmt = "0.0001" - gas = 200000 - govProposalBlockBuffer = 35 - relayerAccountIndex = 0 - numberOfEvidences = 10 - slashingShares int64 = 10000 + initialGlobalFeeAmt = "0.00001" + lowGlobalFeesAmt = "0.000001" + highGlobalFeeAmt = "0.0001" + maxTotalBypassMinFeeMsgGasUsage = "1" + gas = 200000 + govProposalBlockBuffer = 35 + relayerAccountIndex = 0 + numberOfEvidences = 10 + slashingShares int64 = 10000 proposalGlobalFeeFilename = "proposal_globalfee.json" + proposalBypassMsgFilename = "proposal_bypass_msg.json" + proposalMaxTotalBypassFilename = "proposal_max_total_bypass.json" proposalCommunitySpendFilename = "proposal_community_spend.json" proposalAddConsumerChainFilename = "proposal_add_consumer.json" proposalRemoveConsumerChainFilename = "proposal_remove_consumer.json" @@ -162,7 +166,9 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.T().Log("tearing down e2e integration test suite...") - s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) + if runIBCTest { + s.Require().NoError(s.dkrPool.Purge(s.hermesResource)) + } for _, vr := range s.valResources { for _, r := range vr { @@ -635,6 +641,68 @@ func (s *IntegrationTestSuite) writeGovParamChangeProposalGlobalFees(c *chain, c s.Require().NoError(err) } +func (s *IntegrationTestSuite) writeGovParamChangeProposalBypassMsgs(c *chain, msgs []string) { + type ParamInfo struct { + Subspace string `json:"subspace"` + Key string `json:"key"` + Value []string `json:"value"` + } + + type ParamChangeMessage struct { + Title string `json:"title"` + Description string `json:"description"` + Changes []ParamInfo `json:"changes"` + Deposit string `json:"deposit"` + } + paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ + Title: "ChangeProposalBypassMsgs", + Description: "global fee change", + Changes: []ParamInfo{ + { + Subspace: "globalfee", + Key: "BypassMinFeeMsgTypes", + Value: msgs, + }, + }, + Deposit: "1000uatom", + }, "", " ") + s.Require().NoError(err) + + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalBypassMsgFilename), paramChangeProposalBody) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) writeGovParamChangeProposalMaxTotalBypass(c *chain, gas uint64) { + type ParamInfo struct { + Subspace string `json:"subspace"` + Key string `json:"key"` + Value string `json:"value"` + } + + type ParamChangeMessage struct { + Title string `json:"title"` + Description string `json:"description"` + Changes []ParamInfo `json:"changes"` + Deposit string `json:"deposit"` + } + paramChangeProposalBody, err := json.MarshalIndent(ParamChangeMessage{ + Title: "ChangeProposalMaxTotalBypass", + Description: "global fee change", + Changes: []ParamInfo{ + { + Subspace: "globalfee", + Key: "MaxTotalBypassMinFeeMsgGasUsage", + Value: strconv.FormatInt(int64(gas), 10), + }, + }, + Deposit: "1000uatom", + }, "", " ") + s.Require().NoError(err) + + err = writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalMaxTotalBypassFilename), paramChangeProposalBody) + s.Require().NoError(err) +} + func (s *IntegrationTestSuite) writeGovCommunitySpendProposal(c *chain, amount string, recipient string) { proposalCommSpend := &distrtypes.CommunityPoolSpendProposalWithDeposit{ Title: "Community Pool Spend", diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index f272d72434c..58cba8a906d 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -37,7 +37,8 @@ func (s *IntegrationTestSuite) TestByPassMinFee() { if !runBypassMinFeeTest { s.T().Skip() } - s.testByPassMinFeeWithdrawReward() + chainAPI := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp")) + s.testBypassMinFeeWithdrawReward(chainAPI) } func (s *IntegrationTestSuite) TestEncode() { diff --git a/tests/e2e/query.go b/tests/e2e/query.go index e2b7816814d..819feff91b4 100644 --- a/tests/e2e/query.go +++ b/tests/e2e/query.go @@ -17,7 +17,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - globalfee "github.com/cosmos/gaia/v9/x/globalfee/types" + "github.com/cosmos/gaia/v9/x/globalfee/types" ) func queryGaiaTx(endpoint, txHash string) error { @@ -74,18 +74,36 @@ func queryGaiaAllBalances(endpoint, addr string) (sdk.Coins, error) { return balancesResp.Balances, nil } -func queryGlobalFees(endpoint string) (amt sdk.DecCoins, err error) { - body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/minimum_gas_prices", endpoint)) +func queryGlobalFeeParams(endpoint string) (types.Params, error) { + body, err := httpGet(fmt.Sprintf("%s/gaia/globalfee/v1beta1/params", endpoint)) if err != nil { - return nil, fmt.Errorf("failed to execute HTTP request: %w", err) + return types.Params{}, fmt.Errorf("failed to execute HTTP request: %w", err) } - var fees globalfee.QueryMinimumGasPricesResponse - if err := cdc.UnmarshalJSON(body, &fees); err != nil { - return sdk.DecCoins{}, err + var params types.Params + if err := cdc.UnmarshalJSON(body, ¶ms); err != nil { + return types.Params{}, err } - return fees.MinimumGasPrices, nil + return params, nil +} + +func queryGlobalFees(endpoint string) (sdk.DecCoins, error) { + p, err := queryGlobalFeeParams(endpoint) + + return p.MinimumGasPrices, err +} + +func queryBypassMsgs(endpoint string) ([]string, error) { + p, err := queryGlobalFeeParams(endpoint) + + return p.BypassMinFeeMsgTypes, err +} + +func queryMaxTotalBypassMinFeeMsgGasUsage(endpoint string) (uint64, error) { + p, err := queryGlobalFeeParams(endpoint) + + return p.MaxTotalBypassMinFeeMsgGasUsage, err } func queryDelegation(endpoint string, validatorAddr string, delegatorAddr string) (stakingtypes.QueryDelegationResponse, error) { @@ -116,6 +134,21 @@ func queryDelegatorWithdrawalAddress(endpoint string, delegatorAddr string) (dis return res, nil } +func queryDelegatorTotalRewards(endpoint, delegatorAddr string) (disttypes.QueryDelegationTotalRewardsResponse, error) { + var res disttypes.QueryDelegationTotalRewardsResponse + + body, err := httpGet(fmt.Sprintf("%s/cosmos/distribution/v1beta1/delegators/%s/rewards", endpoint, delegatorAddr)) + if err != nil { + return res, err + } + + if err = cdc.UnmarshalJSON(body, &res); err != nil { + return res, err + } + + return res, nil +} + func queryGovProposal(endpoint string, proposalID int) (govtypes.QueryProposalResponse, error) { var govProposalResp govtypes.QueryProposalResponse diff --git a/x/globalfee/ante/antetest/fee_test.go b/x/globalfee/ante/antetest/fee_test.go index 2247cfb98c8..f7901369e79 100644 --- a/x/globalfee/ante/antetest/fee_test.go +++ b/x/globalfee/ante/antetest/fee_test.go @@ -24,7 +24,6 @@ func TestIntegrationTestSuite(t *testing.T) { func (s *IntegrationTestSuite) TestGetDefaultGlobalFees() { // set globalfees and min gas price feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, &globfeetypes.Params{}) - defaultGlobalFees, err := feeDecorator.DefaultZeroGlobalFee(s.ctx) s.Require().NoError(err) s.Require().Greater(len(defaultGlobalFees), 0) @@ -51,252 +50,248 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { medFeeAmt := sdk.NewInt(med.MulInt64(int64(2) * denominator).RoundInt64()) lowFeeAmt := sdk.NewInt(low.MulInt64(int64(2) * denominator).RoundInt64()) - globalfeeParamsEmpty := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{}} + globalfeeParamsEmpty := []sdk.DecCoin{} minGasPriceEmpty := []sdk.DecCoin{} - globalfeeParams0 := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{ + globalfeeParams0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("photon", sdk.NewDec(0)), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), - }} - globalfeeParamsContain0 := &globfeetypes.Params{MinimumGasPrices: []sdk.DecCoin{ + } + globalfeeParamsContain0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("photon", med), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), - }} + } minGasPrice0 := []sdk.DecCoin{ sdk.NewDecCoinFromDec("stake", sdk.NewDec(0)), sdk.NewDecCoinFromDec("uatom", sdk.NewDec(0)), } - globalfeeParamsHigh := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("uatom", high), - }, + globalfeeParamsHigh := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("uatom", high), } minGasPrice := []sdk.DecCoin{ sdk.NewDecCoinFromDec("uatom", med), sdk.NewDecCoinFromDec("stake", med), } - globalfeeParamsLow := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("uatom", low), - }, + globalfeeParamsLow := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("uatom", low), } // global fee must be sorted in denom - globalfeeParamsNewDenom := &globfeetypes.Params{ - MinimumGasPrices: []sdk.DecCoin{ - sdk.NewDecCoinFromDec("photon", high), - sdk.NewDecCoinFromDec("quark", high), - }, + globalfeeParamsNewDenom := []sdk.DecCoin{ + sdk.NewDecCoinFromDec("photon", high), + sdk.NewDecCoinFromDec("quark", high), } + testCases := map[string]struct { - minGasPrice []sdk.DecCoin - globalFeeParams *globfeetypes.Params - gasPrice sdk.Coins - gasLimit sdk.Gas - txMsg sdk.Msg - txCheck bool - expErr bool + minGasPrice []sdk.DecCoin + globalFee []sdk.DecCoin + gasPrice sdk.Coins + gasLimit sdk.Gas + txMsg sdk.Msg + txCheck bool + expErr bool }{ // test fees // empty min_gas_price or empty global fee "empty min_gas_price, nonempty global fee, fee higher/equal than global_fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsHigh, + // sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()) + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, nonempty global fee, fee lower than global_fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "nonempty min_gas_price with defaultGlobalFee denom, empty global fee, fee higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsEmpty, // default 0uatom - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsEmpty, // default 0uatom + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "nonempty min_gas_price with defaultGlobalFee denom, empty global fee, fee lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "empty min_gas_price, empty global fee, empty fee": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.Coins{}, - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.Coins{}, + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // zero min_gas_price or zero global fee "zero min_gas_price, zero global fee, zero fee in global fee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt()), sdk.NewCoin("photon", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt()), sdk.NewCoin("photon", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, zero global fee, empty fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.Coins{}, - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.Coins{}, + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // zero global fee "zero min_gas_price, zero global fee, zero fee not in globalfee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, zero global fee, zero fees one in, one not in globalfee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParams0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParams0, gasPrice: sdk.NewCoins( sdk.NewCoin("stake", sdk.ZeroInt()), sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), + gasLimit: testGasLimit, txMsg: testdata.NewTestMsg(addr1), txCheck: true, expErr: false, }, // zero min_gas_price and empty global fee "zero min_gas_price, empty global fee, zero fee in min_gas_price_denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, zero fee not in min_gas_price denom, not in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), - gasLimit: testdata.NewTestGasLimit(), - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, zero fee in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, nonzero fee in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "zero min_gas_price, empty global fee, nonzero fee not in defaultZeroGlobalFee denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsEmpty, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsEmpty, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // empty min_gas_price, zero global fee "empty min_gas_price, zero global fee, zero fee in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, zero fee not in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, nonzero fee in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "empty min_gas_price, zero global fee, nonzero fee not in global fee denom": { - minGasPrice: minGasPriceEmpty, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPriceEmpty, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // zero min_gas_price, nonzero global fee "zero min_gas_price, nonzero global fee, fee is higher than global fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, // nonzero min_gas_price, nonzero global fee "fee higher/equal than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "fee lower than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "fee with one denom higher/equal, one denom lower than globalfee and min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("quark", highFeeAmt)), @@ -306,73 +301,73 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee > min_gas_price, fee higher/equal than min_gas_price, lower than globalfee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsHigh, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsHigh, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "globalfee < min_gas_price, fee higher/equal than globalfee and lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // nonzero min_gas_price, zero global fee "nonzero min_gas_price, zero global fee, fee is in global fee denom and lower than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "nonzero min_gas_price, zero global fee, fee is in global fee denom and higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", medFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "nonzero min_gas_price, zero global fee, fee is in min_gas_price denom which is not in global fee default, but higher/equal than min_gas_price": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParams0, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParams0, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, // fee denom tests "min_gas_price denom is not subset of global fee denom , fee paying in global fee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "min_gas_price denom is not subset of global fee denom, fee paying in min_gas_price denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsNewDenom, - gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsNewDenom, + gasPrice: sdk.NewCoins(sdk.NewCoin("stake", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "fees contain denom not in globalfee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, gasPrice: sdk.NewCoins( sdk.NewCoin("uatom", highFeeAmt), sdk.NewCoin("quark", highFeeAmt)), @@ -382,8 +377,8 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: true, }, "fees contain denom not in globalfee with zero amount": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt), sdk.NewCoin("quark", sdk.ZeroInt())), gasLimit: testGasLimit, @@ -397,17 +392,17 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { // if the user includes any fee at all in the non-zero denom, it must be higher than that non-zero fee // unlikely we will ever see zero and non-zero together but technically possible "globalfee contains zero coin and non-zero coin, fee is lower than the nonzero coin": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "globalfee contains zero coin, fee contains zero coins of the same denom and a lower fee of the other denom in global fee": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("uatom", sdk.ZeroInt())), @@ -417,17 +412,17 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: true, }, "globalfee contains zero coin, fee is empty": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.Coins{}, - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.Coins{}, + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "globalfee contains zero coin, fee contains lower fee of zero coins's denom, globalfee also contains nonzero coin,fee contains higher fee of nonzero coins's denom, ": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", lowFeeAmt), sdk.NewCoin("uatom", highFeeAmt)), @@ -437,8 +432,8 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee contains zero coin, fee is all zero coins but in global fee's denom": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, gasPrice: sdk.NewCoins( sdk.NewCoin("photon", sdk.ZeroInt()), sdk.NewCoin("uatom", sdk.ZeroInt()), @@ -449,163 +444,170 @@ func (s *IntegrationTestSuite) TestGlobalFeeMinimumGasFeeAnteHandler() { expErr: false, }, "globalfee contains zero coin, fee is higher than the nonzero coin": { - minGasPrice: minGasPrice0, - globalFeeParams: globalfeeParamsContain0, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice0, + globalFee: globalfeeParamsContain0, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgRecvPacket": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgTimeout": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgTimeout( + // todo check here ibcchanneltypes.Packet{}, 1, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg type: ibc.core.channel.v1.MsgTimeoutOnClose": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 2, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "bypass msg gas usage exceeds maxTotalBypassMinFeeMsgGasUsage": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: 2 * testMaxTotalBypassMinFeeMsgGasUsage, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: 2 * globfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage, txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 2, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: true, }, "bypass msg gas usage equals to maxTotalBypassMinFeeMsgGasUsage": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: globfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage, txMsg: ibcchanneltypes.NewMsgTimeout( ibcchanneltypes.Packet{}, 3, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, zero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", sdk.ZeroInt())), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", sdk.ZeroInt())), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, nonzero fee in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type ibc, nonzero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: true, }, "msg type ibc, empty fee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.Coins{}, - gasLimit: testGasLimit, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.Coins{}, + gasLimit: testGasLimit, txMsg: ibcchanneltypes.NewMsgRecvPacket( ibcchanneltypes.Packet{}, nil, ibcclienttypes.Height{}, ""), txCheck: true, expErr: false, }, "msg type non-ibc, nonzero fee in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: false, }, "msg type non-ibc, empty fee": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.Coins{}, - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.Coins{}, + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "msg type non-ibc, nonzero fee not in globalfee denom": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: true, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("photon", highFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: true, + expErr: true, }, "disable checkTx: min_gas_price is medium, global fee is low, tx fee is low": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: false, - expErr: false, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", lowFeeAmt)), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: false, + expErr: false, }, "disable checkTx: min_gas_price is medium, global fee is low, tx is zero": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: false, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("uatom", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: false, + expErr: true, }, "disable checkTx: min_gas_price is low, global fee is low, tx fee's denom is not in global fees denoms set": { - minGasPrice: minGasPrice, - globalFeeParams: globalfeeParamsLow, - gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), - gasLimit: testGasLimit, - txMsg: testdata.NewTestMsg(addr1), - txCheck: false, - expErr: true, + minGasPrice: minGasPrice, + globalFee: globalfeeParamsLow, + gasPrice: sdk.NewCoins(sdk.NewCoin("quark", sdk.ZeroInt())), + gasLimit: testGasLimit, + txMsg: testdata.NewTestMsg(addr1), + txCheck: false, + expErr: true, }, } + + globalfeeParams := &globfeetypes.Params{ + BypassMinFeeMsgTypes: globfeetypes.DefaultBypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: globfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage, + } for name, tc := range testCases { s.Run(name, func() { // set globalfees and min gas price - _, antehandler := s.SetupTestGlobalFeeStoreAndMinGasPrice(tc.minGasPrice, tc.globalFeeParams) + globalfeeParams.MinimumGasPrices = tc.globalFee + _, antehandler := s.SetupTestGlobalFeeStoreAndMinGasPrice(tc.minGasPrice, globalfeeParams) // set fee decorator to ante handler @@ -702,9 +704,12 @@ func (s *IntegrationTestSuite) TestGetMinGasPrice() { } func (s *IntegrationTestSuite) TestContainsOnlyBypassMinFeeMsgs() { - // set globalfees and min gas price - feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, &globfeetypes.Params{}) - + // set globalfees params and min gas price + globalfeeParams := &globfeetypes.Params{ + BypassMinFeeMsgTypes: globfeetypes.DefaultBypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: globfeetypes.DefaultmaxTotalBypassMinFeeMsgGasUsage, + } + feeDecorator, _ := s.SetupTestGlobalFeeStoreAndMinGasPrice([]sdk.DecCoin{}, globalfeeParams) testCases := []struct { name string msgs []sdk.Msg @@ -750,7 +755,7 @@ func (s *IntegrationTestSuite) TestContainsOnlyBypassMinFeeMsgs() { for _, tc := range testCases { s.Run(tc.name, func() { - res := feeDecorator.ContainsOnlyBypassMinFeeMsgs(tc.msgs) + res := feeDecorator.ContainsOnlyBypassMinFeeMsgs(s.ctx, tc.msgs) s.Require().True(tc.expPass == res) }) } diff --git a/x/globalfee/ante/antetest/fee_test_setup.go b/x/globalfee/ante/antetest/fee_test_setup.go index c1508126a63..e8ed50b13e9 100644 --- a/x/globalfee/ante/antetest/fee_test_setup.go +++ b/x/globalfee/ante/antetest/fee_test_setup.go @@ -33,10 +33,7 @@ type IntegrationTestSuite struct { txBuilder client.TxBuilder } -var ( - testBondDenom = "uatom" - testMaxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 -) +var testBondDenom = "uatom" func (s *IntegrationTestSuite) SetupTest() { app := gaiahelpers.Setup(s.T()) @@ -65,7 +62,7 @@ func (s *IntegrationTestSuite) SetupTestGlobalFeeStoreAndMinGasPrice(minGasPrice stakingSubspace := s.SetupTestStakingSubspace(stakingParam) // build fee decorator - feeDecorator := gaiafeeante.NewFeeDecorator(gaiaapp.GetDefaultBypassFeeMessages(), subspace, stakingSubspace, uint64(1_000_000)) + feeDecorator := gaiafeeante.NewFeeDecorator(subspace, stakingSubspace) // chain fee decorator to antehandler antehandler := sdk.ChainAnteDecorators(feeDecorator) diff --git a/x/globalfee/ante/fee.go b/x/globalfee/ante/fee.go index 88c6ab31ef6..071cc0eee78 100644 --- a/x/globalfee/ante/fee.go +++ b/x/globalfee/ante/fee.go @@ -28,13 +28,11 @@ import ( var _ sdk.AnteDecorator = FeeDecorator{} type FeeDecorator struct { - BypassMinFeeMsgTypes []string - GlobalMinFee globalfee.ParamSource - StakingSubspace paramtypes.Subspace - MaxTotalBypassMinFeeMsgGasUsage uint64 + GlobalMinFee globalfee.ParamSource + StakingSubspace paramtypes.Subspace } -func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace paramtypes.Subspace, maxTotalBypassMinFeeMsgGasUsage uint64) FeeDecorator { +func NewFeeDecorator(globalfeeSubspace, stakingSubspace paramtypes.Subspace) FeeDecorator { if !globalfeeSubspace.HasKeyTable() { panic("global fee paramspace was not set up via module") } @@ -44,10 +42,8 @@ func NewFeeDecorator(bypassMsgTypes []string, globalfeeSubspace, stakingSubspace } return FeeDecorator{ - BypassMinFeeMsgTypes: bypassMsgTypes, - GlobalMinFee: globalfeeSubspace, - StakingSubspace: stakingSubspace, - MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, + GlobalMinFee: globalfeeSubspace, + StakingSubspace: stakingSubspace, } } @@ -107,9 +103,11 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne // - the total gas limit per message does not exceed MaxTotalBypassMinFeeMsgGasUsage, // i.e., totalGas <= MaxTotalBypassMinFeeMsgGasUsage // Otherwise, minimum fees and global fees are checked to prevent spam. - doesNotExceedMaxGasUsage := gas <= mfd.MaxTotalBypassMinFeeMsgGasUsage - allBypassMsgs := mfd.ContainsOnlyBypassMinFeeMsgs(msgs) + maxTotalBypassMinFeeMsgGasUsage := mfd.GetMaxTotalBypassMinFeeMsgGasUsage(ctx) + doesNotExceedMaxGasUsage := gas <= maxTotalBypassMinFeeMsgGasUsage + allBypassMsgs := mfd.ContainsOnlyBypassMinFeeMsgs(ctx, msgs) allowedToBypassMinFee := allBypassMsgs && doesNotExceedMaxGasUsage + if allowedToBypassMinFee { return next(ctx, tx, simulate) } @@ -143,7 +141,7 @@ func (mfd FeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, ne if !feeCoinsNonZeroDenom.IsAnyGTE(nonZeroCoinFeesReq) { errMsg := fmt.Sprintf("Insufficient fees; got: %s required: %s", feeCoins.String(), feeRequired.String()) if allBypassMsgs && !doesNotExceedMaxGasUsage { - errMsg = fmt.Sprintf("Insufficient fees; bypass-min-fee-msg-types with gas consumption %v exceeds the maximum allowed gas value of %v.", gas, mfd.MaxTotalBypassMinFeeMsgGasUsage) + errMsg = fmt.Sprintf("Insufficient fees; bypass-min-fee-msg-types with gas consumption %v exceeds the maximum allowed gas value of %v.", gas, maxTotalBypassMinFeeMsgGasUsage) } return ctx, sdkerrors.Wrap(sdkerrors.ErrInsufficientFee, errMsg) @@ -220,21 +218,18 @@ func (mfd FeeDecorator) DefaultZeroGlobalFee(ctx sdk.Context) ([]sdk.DecCoin, er return []sdk.DecCoin{sdk.NewDecCoinFromDec(bondDenom, sdk.NewDec(0))}, nil } -func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) string { - var bondDenom string - +func (mfd FeeDecorator) getBondDenom(ctx sdk.Context) (bondDenom string) { if mfd.StakingSubspace.Has(ctx, stakingtypes.KeyBondDenom) { mfd.StakingSubspace.Get(ctx, stakingtypes.KeyBondDenom, &bondDenom) } - return bondDenom + return } -// ContainsOnlyBypassMinFeeMsgs returns true if all the given msgs type are listed -// in the BypassMinFeeMsgTypes of the FeeDecorator. -func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(msgs []sdk.Msg) bool { +func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(ctx sdk.Context, msgs []sdk.Msg) bool { + bypassMsgTypes := mfd.GetBypassMsgTypes(ctx) for _, msg := range msgs { - if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), mfd.BypassMinFeeMsgTypes) { + if tmstrings.StringInSlice(sdk.MsgTypeURL(msg), bypassMsgTypes) { continue } return false @@ -243,7 +238,22 @@ func (mfd FeeDecorator) ContainsOnlyBypassMinFeeMsgs(msgs []sdk.Msg) bool { return true } -// GetMinGasPrice returns the validator's minimum gas prices +func (mfd FeeDecorator) GetBypassMsgTypes(ctx sdk.Context) (res []string) { + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &res) + } + return +} + +func (mfd FeeDecorator) GetMaxTotalBypassMinFeeMsgGasUsage(ctx sdk.Context) (res uint64) { + if mfd.GlobalMinFee.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + mfd.GlobalMinFee.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &res) + } + + return +} + +// GetMinGasPrice returns a nodes's local minimum gas prices // fees given a gas limit func GetMinGasPrice(ctx sdk.Context, gasLimit int64) sdk.Coins { minGasPrices := ctx.MinGasPrices() diff --git a/x/globalfee/client/cli/query.go b/x/globalfee/client/cli/query.go index be6894a9d5c..4215d2ccfdb 100644 --- a/x/globalfee/client/cli/query.go +++ b/x/globalfee/client/cli/query.go @@ -17,18 +17,17 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } queryCmd.AddCommand( - GetCmdShowMinimumGasPrices(), + GetCmdShowGlobalFeeParams(), ) return queryCmd } -func GetCmdShowMinimumGasPrices() *cobra.Command { +func GetCmdShowGlobalFeeParams() *cobra.Command { cmd := &cobra.Command{ - Use: "minimum-gas-prices", - Short: "Show minimum gas prices", - Long: "Show all minimum gas prices", - Aliases: []string{"min"}, - Args: cobra.ExactArgs(0), + Use: "params", + Short: "Show globalfee params", + Long: "Show globalfee requirement: minimum_gas_prices, bypass_min_fee_msg_types, max_total_bypass_minFee_msg_gas_usage", + Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -36,7 +35,7 @@ func GetCmdShowMinimumGasPrices() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.MinimumGasPrices(cmd.Context(), &types.QueryMinimumGasPricesRequest{}) + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) if err != nil { return err } diff --git a/x/globalfee/genesis_test.go b/x/globalfee/genesis_test.go index 02f90ce538a..b27f207f60e 100644 --- a/x/globalfee/genesis_test.go +++ b/x/globalfee/genesis_test.go @@ -23,7 +23,9 @@ import ( func TestDefaultGenesis(t *testing.T) { encCfg := simapp.MakeTestEncodingConfig() gotJSON := AppModuleBasic{}.DefaultGenesis(encCfg.Marshaler) - assert.JSONEq(t, `{"params":{"minimum_gas_prices":[]}}`, string(gotJSON), string(gotJSON)) + assert.JSONEq(t, + `{"params":{"minimum_gas_prices":[],"bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket","/ibc.core.channel.v1.MsgAcknowledgement","/ibc.core.client.v1.MsgUpdateClient","/ibc.core.channel.v1.MsgTimeout","/ibc.core.channel.v1.MsgTimeoutOnClose"], "max_total_bypass_min_fee_msg_gas_usage":"1000000"}}`, + string(gotJSON), string(gotJSON)) } func TestValidateGenesis(t *testing.T) { @@ -33,13 +35,24 @@ func TestValidateGenesis(t *testing.T) { expErr bool }{ "all good": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, + expErr: false, }, "empty minimum": { - src: `{"params":{"minimum_gas_prices":[]}}`, + src: `{"params":{"minimum_gas_prices":[], "bypass_min_fee_msg_types":[]}}`, + expErr: false, + }, + "minimum and bypass not set": { + src: `{"params":{}}`, + expErr: false, }, "minimum not set": { - src: `{"params":{}}`, + src: `{"params":{"bypass_min_fee_msg_types":[]}}`, + expErr: false, + }, + "bypass not set": { + src: `{"params":{"minimum_gas_prices":[]}}`, + expErr: false, }, "zero amount allowed": { src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"0"}]}}`, @@ -57,6 +70,10 @@ func TestValidateGenesis(t *testing.T) { src: `{"params":{"minimum_gas_prices":[{"denom":"ZLX", "amount":"1"},{"denom":"ALX", "amount":"2"}]}}`, expErr: true, }, + "empty bypass msg types not allowed": { + src: `{"params":{"bypass_min_fee_msg_types":[""]}}`, + expErr: true, + }, "sorted denoms is allowed": { src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"},{"denom":"ZLX", "amount":"2"}]}}`, expErr: false, @@ -80,17 +97,32 @@ func TestInitExportGenesis(t *testing.T) { exp types.GenesisState }{ "single fee": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}]}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)))}}, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket"]}}`, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1))), + BypassMinFeeMsgTypes: []string{"/ibc.core.channel.v1.MsgRecvPacket"}, + }, + }, }, "multiple fee options": { - src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}]}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), - sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3)))}}, + src: `{"params":{"minimum_gas_prices":[{"denom":"ALX", "amount":"1"}, {"denom":"BLX", "amount":"0.001"}], "bypass_min_fee_msg_types":["/ibc.core.channel.v1.MsgRecvPacket","/ibc.core.channel.v1.MsgTimeoutOnClose"]}}`, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.NewDecCoins(sdk.NewDecCoin("ALX", sdk.NewInt(1)), + sdk.NewDecCoinFromDec("BLX", sdk.NewDecWithPrec(1, 3))), + BypassMinFeeMsgTypes: []string{"/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgTimeoutOnClose"}, + }, + }, }, "no fee set": { src: `{"params":{}}`, - exp: types.GenesisState{Params: types.Params{MinimumGasPrices: sdk.DecCoins{}}}, + exp: types.GenesisState{ + Params: types.Params{ + MinimumGasPrices: sdk.DecCoins{}, + BypassMinFeeMsgTypes: []string{}, + }, + }, }, } for name, spec := range specs { diff --git a/x/globalfee/querier.go b/x/globalfee/querier.go index 23a06c28600..7187239c679 100644 --- a/x/globalfee/querier.go +++ b/x/globalfee/querier.go @@ -25,13 +25,25 @@ func NewGrpcQuerier(paramSource ParamSource) GrpcQuerier { } // MinimumGasPrices return minimum gas prices -func (g GrpcQuerier) MinimumGasPrices(stdCtx context.Context, _ *types.QueryMinimumGasPricesRequest) (*types.QueryMinimumGasPricesResponse, error) { +func (g GrpcQuerier) Params(stdCtx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { var minGasPrices sdk.DecCoins + var bypassMinFeeMsgTypes []string + var maxTotalBypassMinFeeMsgGasUsage uint64 ctx := sdk.UnwrapSDKContext(stdCtx) + // todo: if return err if not exist? if g.paramSource.Has(ctx, types.ParamStoreKeyMinGasPrices) { g.paramSource.Get(ctx, types.ParamStoreKeyMinGasPrices, &minGasPrices) } - return &types.QueryMinimumGasPricesResponse{ - MinimumGasPrices: minGasPrices, + if g.paramSource.Has(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes) { + g.paramSource.Get(ctx, types.ParamStoreKeyBypassMinFeeMsgTypes, &bypassMinFeeMsgTypes) + } + if g.paramSource.Has(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage) { + g.paramSource.Get(ctx, types.ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &maxTotalBypassMinFeeMsgGasUsage) + } + + return &types.QueryParamsResponse{ + MinimumGasPrices: minGasPrices, + BypassMinFeeMsgTypes: bypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: maxTotalBypassMinFeeMsgGasUsage, }, nil } diff --git a/x/globalfee/querier_test.go b/x/globalfee/querier_test.go index bed110300da..0b86a3bdc21 100644 --- a/x/globalfee/querier_test.go +++ b/x/globalfee/querier_test.go @@ -47,7 +47,7 @@ func TestQueryMinimumGasPrices(t *testing.T) { ctx, _, subspace := setupTestStore(t) spec.setupStore(ctx, subspace) q := NewGrpcQuerier(subspace) - gotResp, gotErr := q.MinimumGasPrices(sdk.WrapSDKContext(ctx), nil) + gotResp, gotErr := q.Params(sdk.WrapSDKContext(ctx), nil) require.NoError(t, gotErr) require.NotNil(t, gotResp) assert.Equal(t, spec.expMin, gotResp.MinimumGasPrices) diff --git a/x/globalfee/types/genesis.pb.go b/x/globalfee/types/genesis.pb.go index bde069af626..1e9188ad464 100644 --- a/x/globalfee/types/genesis.pb.go +++ b/x/globalfee/types/genesis.pb.go @@ -73,12 +73,19 @@ func (m *GenesisState) GetParams() Params { // Params defines the set of module parameters. type Params struct { - // Minimum stores the minimum gas price(s) for all TX on the chain. + // minimum_gas_prices stores the minimum gas price(s) for all TX on the chain. // When multiple coins are defined then they are accepted alternatively. // The list must be sorted by denoms asc. No duplicate denoms or zero amount // values allowed. For more information see // https://docs.cosmos.network/main/modules/auth#concepts MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` + // bypass_min_fee_msg_types defines a list of message type urls + // that are free of fee charge. + BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` + // max_total_bypass_min_fee_msg_gas_usage defines the total maximum gas usage + // allowed for a transaction containing only messages of types in bypass_min_fee_msg_types + // to bypass fee charge. + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_min_fee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_min_fee_msg_gas_usage,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -121,6 +128,20 @@ func (m *Params) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoi return nil } +func (m *Params) GetBypassMinFeeMsgTypes() []string { + if m != nil { + return m.BypassMinFeeMsgTypes + } + return nil +} + +func (m *Params) GetMaxTotalBypassMinFeeMsgGasUsage() uint64 { + if m != nil { + return m.MaxTotalBypassMinFeeMsgGasUsage + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "gaia.globalfee.v1beta1.GenesisState") proto.RegisterType((*Params)(nil), "gaia.globalfee.v1beta1.Params") @@ -131,28 +152,34 @@ func init() { } var fileDescriptor_015b3e8b7a7c65c5 = []byte{ - // 325 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0x31, 0x4b, 0x03, 0x31, - 0x14, 0xc7, 0x2f, 0x08, 0x1d, 0xae, 0x0e, 0xe5, 0x10, 0xa9, 0xa5, 0xe4, 0xe4, 0x70, 0x28, 0xa8, - 0x09, 0xad, 0x9b, 0xe3, 0x29, 0x74, 0x2d, 0x75, 0x73, 0xa9, 0xb9, 0x33, 0xc6, 0x60, 0x73, 0x09, - 0x4d, 0x2a, 0xf6, 0x5b, 0xf8, 0x39, 0xfc, 0x0c, 0xee, 0x76, 0xec, 0xe8, 0x54, 0xe5, 0x6e, 0x73, - 0xf4, 0x13, 0xc8, 0x25, 0x67, 0x2b, 0x9c, 0x53, 0x02, 0xef, 0xf7, 0x7e, 0xff, 0xc7, 0x7b, 0xfe, - 0x11, 0x23, 0x9c, 0x60, 0x36, 0x95, 0x09, 0x99, 0xde, 0x51, 0x8a, 0x1f, 0xfb, 0x09, 0x35, 0xa4, - 0x8f, 0x19, 0xcd, 0xa8, 0xe6, 0x1a, 0xa9, 0x99, 0x34, 0x32, 0xd8, 0x2f, 0x29, 0xb4, 0xa1, 0x50, - 0x45, 0x75, 0xf6, 0x98, 0x64, 0xd2, 0x22, 0xb8, 0xfc, 0x39, 0xba, 0x03, 0x53, 0xa9, 0x85, 0xd4, - 0x38, 0x21, 0x7a, 0x2b, 0x4c, 0x25, 0xcf, 0x5c, 0x3d, 0xba, 0xf1, 0x77, 0x87, 0x4e, 0x7f, 0x65, - 0x88, 0xa1, 0xc1, 0xc8, 0x6f, 0x28, 0x32, 0x23, 0x42, 0xb7, 0xc1, 0x21, 0xe8, 0x35, 0x07, 0x10, - 0xfd, 0x1f, 0x87, 0x46, 0x96, 0x8a, 0xdb, 0xcb, 0x75, 0xe8, 0x7d, 0xad, 0xc3, 0x96, 0xeb, 0x3a, - 0x91, 0x82, 0x1b, 0x2a, 0x94, 0x59, 0x8c, 0x2b, 0x4f, 0xf4, 0x06, 0xfc, 0x86, 0x83, 0x83, 0x57, - 0xe0, 0x07, 0x82, 0x67, 0x5c, 0xcc, 0xc5, 0x84, 0x11, 0x3d, 0x51, 0x33, 0x9e, 0xd2, 0x32, 0x69, - 0xa7, 0xd7, 0x1c, 0x74, 0x91, 0x1b, 0x15, 0x95, 0xa3, 0x6e, 0x62, 0x2e, 0x69, 0x7a, 0x21, 0x79, - 0x16, 0xab, 0x2a, 0xa7, 0x5b, 0xef, 0xdf, 0x66, 0x7e, 0xaf, 0xc3, 0x83, 0x05, 0x11, 0xd3, 0xf3, - 0xa8, 0x4e, 0x45, 0x2f, 0x1f, 0xe1, 0x31, 0xe3, 0xe6, 0x7e, 0x9e, 0xa0, 0x54, 0x0a, 0x5c, 0xed, - 0xc5, 0x3d, 0xa7, 0xfa, 0xf6, 0x01, 0x9b, 0x85, 0xa2, 0xfa, 0x37, 0x50, 0x8f, 0x5b, 0x95, 0x63, - 0x48, 0xf4, 0xc8, 0x1a, 0xe2, 0x78, 0x99, 0x43, 0xb0, 0xca, 0x21, 0xf8, 0xcc, 0x21, 0x78, 0x2e, - 0xa0, 0xb7, 0x2a, 0xa0, 0xf7, 0x5e, 0x40, 0xef, 0xba, 0x57, 0x17, 0xdb, 0x5b, 0x3e, 0xfd, 0xb9, - 0xa6, 0xd5, 0x27, 0x0d, 0xbb, 0xf6, 0xb3, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0x6d, 0x01, - 0xcd, 0xec, 0x01, 0x00, 0x00, + // 428 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x4d, 0x6e, 0xd3, 0x40, + 0x14, 0xc7, 0x33, 0x04, 0x45, 0xc2, 0x65, 0x51, 0x59, 0x15, 0x32, 0x55, 0x35, 0x8e, 0x2c, 0x84, + 0x2c, 0x01, 0x63, 0xb5, 0xec, 0x58, 0x1a, 0x44, 0xc4, 0xa2, 0x22, 0x0a, 0x65, 0xc3, 0x66, 0x78, + 0x36, 0xd3, 0x61, 0x44, 0xc6, 0x63, 0xe5, 0x4d, 0x50, 0xb2, 0xe4, 0x06, 0x1c, 0x80, 0x13, 0x70, + 0x06, 0x0e, 0xd0, 0x65, 0x97, 0xac, 0x0c, 0x4a, 0x76, 0x5d, 0x72, 0x02, 0x34, 0x1e, 0xd3, 0x52, + 0xa5, 0x59, 0xd9, 0xf2, 0xfb, 0xfd, 0x3f, 0xfc, 0xf4, 0x82, 0x07, 0x12, 0x14, 0x64, 0x72, 0x6a, + 0x0a, 0x98, 0x9e, 0x0a, 0x91, 0x7d, 0x3e, 0x2c, 0x84, 0x85, 0xc3, 0x4c, 0x8a, 0x4a, 0xa0, 0x42, + 0x56, 0xcf, 0x8c, 0x35, 0xe1, 0x3d, 0x47, 0xb1, 0x4b, 0x8a, 0x75, 0xd4, 0xfe, 0x9e, 0x34, 0xd2, + 0xb4, 0x48, 0xe6, 0xde, 0x3c, 0xbd, 0x4f, 0x4b, 0x83, 0xda, 0x60, 0x56, 0x00, 0x5e, 0x19, 0x96, + 0x46, 0x55, 0x7e, 0x9e, 0xbc, 0x0f, 0xee, 0x8e, 0xbc, 0xfd, 0x1b, 0x0b, 0x56, 0x84, 0xe3, 0x60, + 0x50, 0xc3, 0x0c, 0x34, 0x46, 0x64, 0x48, 0xd2, 0x9d, 0x23, 0xca, 0x6e, 0x8e, 0x63, 0xe3, 0x96, + 0xca, 0xa3, 0xb3, 0x26, 0xee, 0x5d, 0x34, 0xf1, 0xae, 0x57, 0x3d, 0x36, 0x5a, 0x59, 0xa1, 0x6b, + 0xbb, 0x9c, 0x74, 0x3e, 0xc9, 0xb7, 0x7e, 0x30, 0xf0, 0x70, 0xf8, 0x83, 0x04, 0xa1, 0x56, 0x95, + 0xd2, 0x73, 0xcd, 0x25, 0x20, 0xaf, 0x67, 0xaa, 0x14, 0x2e, 0xa9, 0x9f, 0xee, 0x1c, 0x1d, 0x30, + 0x5f, 0x95, 0xb9, 0xaa, 0x97, 0x31, 0x2f, 0x44, 0xf9, 0xdc, 0xa8, 0x2a, 0xaf, 0xbb, 0x9c, 0x83, + 0x4d, 0xfd, 0x55, 0xe6, 0x9f, 0x26, 0xbe, 0xbf, 0x04, 0x3d, 0x7d, 0x96, 0x6c, 0x52, 0xc9, 0xf7, + 0x5f, 0xf1, 0x23, 0xa9, 0xec, 0xc7, 0x79, 0xc1, 0x4a, 0xa3, 0xb3, 0x6e, 0x2f, 0xfe, 0xf1, 0x04, + 0x3f, 0x7c, 0xca, 0xec, 0xb2, 0x16, 0xf8, 0x2f, 0x10, 0x27, 0xbb, 0x9d, 0xc7, 0x08, 0x70, 0xdc, + 0x3a, 0x84, 0x5f, 0x48, 0x10, 0x15, 0xcb, 0x1a, 0x10, 0xb9, 0x56, 0x15, 0x3f, 0x15, 0x82, 0x6b, + 0x94, 0xbc, 0xd5, 0x45, 0xb7, 0x86, 0xfd, 0xf4, 0x4e, 0xfe, 0xea, 0xa2, 0x89, 0x93, 0x6d, 0xcc, + 0xb5, 0xa2, 0xb1, 0x2f, 0xba, 0x8d, 0x4d, 0x26, 0x7b, 0x7e, 0x74, 0xac, 0xaa, 0x97, 0x42, 0x1c, + 0xa3, 0x3c, 0x71, 0x9f, 0xc3, 0xd7, 0xc1, 0x43, 0x0d, 0x0b, 0x6e, 0x8d, 0x85, 0x29, 0xbf, 0x41, + 0xec, 0x7e, 0x78, 0x8e, 0x20, 0x45, 0xd4, 0x1f, 0x92, 0xf4, 0xf6, 0x24, 0xd6, 0xb0, 0x38, 0x71, + 0x70, 0x7e, 0xdd, 0x6d, 0x04, 0xf8, 0xd6, 0x61, 0x79, 0x7e, 0xb6, 0xa2, 0xe4, 0x7c, 0x45, 0xc9, + 0xef, 0x15, 0x25, 0x5f, 0xd7, 0xb4, 0x77, 0xbe, 0xa6, 0xbd, 0x9f, 0x6b, 0xda, 0x7b, 0x97, 0x6e, + 0x6e, 0xab, 0x3d, 0xd0, 0xc5, 0x7f, 0x27, 0xda, 0x76, 0x2d, 0x06, 0xed, 0x2d, 0x3d, 0xfd, 0x1b, + 0x00, 0x00, 0xff, 0xff, 0x90, 0xb9, 0xb2, 0x8a, 0xc1, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -208,6 +235,20 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + i-- + dAtA[i] = 0x18 + } + if len(m.BypassMinFeeMsgTypes) > 0 { + for iNdEx := len(m.BypassMinFeeMsgTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BypassMinFeeMsgTypes[iNdEx]) + copy(dAtA[i:], m.BypassMinFeeMsgTypes[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.BypassMinFeeMsgTypes[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.MinimumGasPrices) > 0 { for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { { @@ -259,6 +300,15 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.BypassMinFeeMsgTypes) > 0 { + for _, s := range m.BypassMinFeeMsgTypes { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + n += 1 + sovGenesis(uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + } return n } @@ -414,6 +464,57 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BypassMinFeeMsgTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BypassMinFeeMsgTypes = append(m.BypassMinFeeMsgTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTotalBypassMinFeeMsgGasUsage", wireType) + } + m.MaxTotalBypassMinFeeMsgGasUsage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTotalBypassMinFeeMsgGasUsage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/globalfee/types/params.go b/x/globalfee/types/params.go index 7161b2c3e6f..07e67a983fc 100644 --- a/x/globalfee/types/params.go +++ b/x/globalfee/types/params.go @@ -2,18 +2,47 @@ package types import ( "fmt" + "strings" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types" + ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types" ) -// ParamStoreKeyMinGasPrices store key -var ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") +var ( + // ParamStoreKeyMinGasPrices store key + ParamStoreKeyMinGasPrices = []byte("MinimumGasPricesParam") + ParamStoreKeyBypassMinFeeMsgTypes = []byte("BypassMinFeeMsgTypes") + ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage = []byte("MaxTotalBypassMinFeeMsgGasUsage") + + // DefaultMinGasPrices is set at runtime to the staking token with zero amount i.e. "0uatom" + // see DefaultZeroGlobalFee method in gaia/x/globalfee/ante/fee.go. + DefaultMinGasPrices = sdk.DecCoins{} + DefaultBypassMinFeeMsgTypes = []string{ + sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}), + sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}), + sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}), + } + + // maxTotalBypassMinFeeMsgGasUsage is the allowed maximum gas usage + // for all the bypass msgs in a transactions. + // A transaction that contains only bypass message types and the gas usage does not + // exceed maxTotalBypassMinFeeMsgGasUsage can be accepted with a zero fee. + // For details, see gaiafeeante.NewFeeDecorator() + DefaultmaxTotalBypassMinFeeMsgGasUsage uint64 = 1_000_000 +) // DefaultParams returns default parameters func DefaultParams() Params { - return Params{MinimumGasPrices: sdk.DecCoins{}} + return Params{ + MinimumGasPrices: DefaultMinGasPrices, + BypassMinFeeMsgTypes: DefaultBypassMinFeeMsgTypes, + MaxTotalBypassMinFeeMsgGasUsage: DefaultmaxTotalBypassMinFeeMsgGasUsage, + } } func ParamKeyTable() paramtypes.KeyTable { @@ -22,7 +51,15 @@ func ParamKeyTable() paramtypes.KeyTable { // ValidateBasic performs basic validation. func (p Params) ValidateBasic() error { - return validateMinimumGasPrices(p.MinimumGasPrices) + if err := validateMinimumGasPrices(p.MinimumGasPrices); err != nil { + return err + } + + if err := validateBypassMinFeeMsgTypes(p.BypassMinFeeMsgTypes); err != nil { + return err + } + + return validateMaxTotalBypassMinFeeMsgGasUsage(p.MaxTotalBypassMinFeeMsgGasUsage) } // ParamSetPairs returns the parameter set pairs. @@ -31,10 +68,15 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair( ParamStoreKeyMinGasPrices, &p.MinimumGasPrices, validateMinimumGasPrices, ), + paramtypes.NewParamSetPair( + ParamStoreKeyBypassMinFeeMsgTypes, &p.BypassMinFeeMsgTypes, validateBypassMinFeeMsgTypes, + ), + paramtypes.NewParamSetPair( + ParamStoreKeyMaxTotalBypassMinFeeMsgGasUsage, &p.MaxTotalBypassMinFeeMsgGasUsage, validateMaxTotalBypassMinFeeMsgGasUsage, + ), } } -// this requires the fee non-negative func validateMinimumGasPrices(i interface{}) error { v, ok := i.(sdk.DecCoins) if !ok { @@ -45,6 +87,37 @@ func validateMinimumGasPrices(i interface{}) error { return dec.Validate() } +type BypassMinFeeMsgTypes []string + +// validateBypassMinFeeMsgTypes checks that bypass msg types aren't empty +func validateBypassMinFeeMsgTypes(i interface{}) error { + bypassMinFeeMsgTypes, ok := i.([]string) + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected []sdk.Msg", i) + } + + for _, msgType := range bypassMinFeeMsgTypes { + if msgType == "" { + return fmt.Errorf("invalid empty bypass msg type") + } + + if !strings.HasPrefix(msgType, sdk.MsgTypeURL(nil)) { + return fmt.Errorf("invalid bypass msg type name %s", msgType) + } + } + + return nil +} + +func validateMaxTotalBypassMinFeeMsgGasUsage(i interface{}) error { + _, ok := i.(uint64) + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "type: %T, expected uint64", i) + } + + return nil +} + type DecCoins sdk.DecCoins // Validate checks that the DecCoins are sorted, have nonnegtive amount, with a valid and unique diff --git a/x/globalfee/types/params_test.go b/x/globalfee/types/params_test.go index ba53a7f1f7f..b2c2931674a 100644 --- a/x/globalfee/types/params_test.go +++ b/x/globalfee/types/params_test.go @@ -10,11 +10,13 @@ import ( func TestDefaultParams(t *testing.T) { p := DefaultParams() require.EqualValues(t, p.MinimumGasPrices, sdk.DecCoins{}) + require.EqualValues(t, p.BypassMinFeeMsgTypes, DefaultBypassMinFeeMsgTypes) + require.EqualValues(t, p.MaxTotalBypassMinFeeMsgGasUsage, DefaultmaxTotalBypassMinFeeMsgGasUsage) } -func Test_validateParams(t *testing.T) { +func Test_validateMinGasPrices(t *testing.T) { tests := map[string]struct { - coins interface{} // not sdk.DeCoins, but Decoins defined in glboalfee + coins interface{} expectErr bool }{ "DefaultParams, pass": { @@ -71,3 +73,84 @@ func Test_validateParams(t *testing.T) { }) } } + +func Test_validateBypassMinFeeMsgTypes(t *testing.T) { + tests := map[string]struct { + msgTypes interface{} + expectErr bool + }{ + "DefaultParams, pass": { + DefaultParams().BypassMinFeeMsgTypes, + false, + }, + "wrong msg type should make conversion fail, fail": { + []int{0, 1, 2, 3}, + true, + }, + "empty msg types, pass": { + []string{}, + false, + }, + "empty msg type, fail": { + []string{""}, + true, + }, + "invalid msg type name, fail": { + []string{"ibc.core.channel.v1.MsgRecvPacket"}, + true, + }, + "mixed valid and invalid msgs, fail": { + []string{ + "/ibc.core.channel.v1.MsgRecvPacket", + "", + }, + true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := validateBypassMinFeeMsgTypes(test.msgTypes) + if test.expectErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} + +func Test_validateMaxTotalBypassMinFeeMsgGasUsage(t *testing.T) { + tests := map[string]struct { + msgTypes interface{} + expectErr bool + }{ + "DefaultParams, pass": { + DefaultParams().MaxTotalBypassMinFeeMsgGasUsage, + false, + }, + "zero value, pass": { + uint64(0), + false, + }, + "negative value, fail": { + -1, + true, + }, + "invalid type, fail": { + "5", + true, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + err := validateMaxTotalBypassMinFeeMsgGasUsage(test.msgTypes) + if test.expectErr { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/globalfee/types/query.pb.go b/x/globalfee/types/query.pb.go index 569b6975be4..054f0c41b4b 100644 --- a/x/globalfee/types/query.pb.go +++ b/x/globalfee/types/query.pb.go @@ -33,21 +33,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryMinimumGasPricesRequest is the request type for the // Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesRequest struct { +type QueryParamsRequest struct { } -func (m *QueryMinimumGasPricesRequest) Reset() { *m = QueryMinimumGasPricesRequest{} } -func (m *QueryMinimumGasPricesRequest) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesRequest) ProtoMessage() {} -func (*QueryMinimumGasPricesRequest) Descriptor() ([]byte, []int) { +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_12a736cede25d10a, []int{0} } -func (m *QueryMinimumGasPricesRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -57,36 +57,38 @@ func (m *QueryMinimumGasPricesRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *QueryMinimumGasPricesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesRequest.Merge(m, src) +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) } -func (m *QueryMinimumGasPricesRequest) XXX_Size() int { +func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesRequest.DiscardUnknown(m) +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo // QueryMinimumGasPricesResponse is the response type for the // Query/MinimumGasPrices RPC method. -type QueryMinimumGasPricesResponse struct { - MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` +type QueryParamsResponse struct { + MinimumGasPrices github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=minimum_gas_prices,json=minimumGasPrices,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"minimum_gas_prices,omitempty" yaml:"minimum_gas_prices"` + BypassMinFeeMsgTypes []string `protobuf:"bytes,2,rep,name=bypass_min_fee_msg_types,json=bypassMinFeeMsgTypes,proto3" json:"bypass_min_fee_msg_types,omitempty" yaml:"bypass_min_fee_msg_types"` + MaxTotalBypassMinFeeMsgGasUsage uint64 `protobuf:"varint,3,opt,name=max_total_bypass_min_fee_msg_gas_usage,json=maxTotalBypassMinFeeMsgGasUsage,proto3" json:"max_total_bypass_min_fee_msg_gas_usage,omitempty"` } -func (m *QueryMinimumGasPricesResponse) Reset() { *m = QueryMinimumGasPricesResponse{} } -func (m *QueryMinimumGasPricesResponse) String() string { return proto.CompactTextString(m) } -func (*QueryMinimumGasPricesResponse) ProtoMessage() {} -func (*QueryMinimumGasPricesResponse) Descriptor() ([]byte, []int) { +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_12a736cede25d10a, []int{1} } -func (m *QueryMinimumGasPricesResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryMinimumGasPricesResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -96,28 +98,42 @@ func (m *QueryMinimumGasPricesResponse) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *QueryMinimumGasPricesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryMinimumGasPricesResponse.Merge(m, src) +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) } -func (m *QueryMinimumGasPricesResponse) XXX_Size() int { +func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } -func (m *QueryMinimumGasPricesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryMinimumGasPricesResponse.DiscardUnknown(m) +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryMinimumGasPricesResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo -func (m *QueryMinimumGasPricesResponse) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { +func (m *QueryParamsResponse) GetMinimumGasPrices() github_com_cosmos_cosmos_sdk_types.DecCoins { if m != nil { return m.MinimumGasPrices } return nil } +func (m *QueryParamsResponse) GetBypassMinFeeMsgTypes() []string { + if m != nil { + return m.BypassMinFeeMsgTypes + } + return nil +} + +func (m *QueryParamsResponse) GetMaxTotalBypassMinFeeMsgGasUsage() uint64 { + if m != nil { + return m.MaxTotalBypassMinFeeMsgGasUsage + } + return 0 +} + func init() { - proto.RegisterType((*QueryMinimumGasPricesRequest)(nil), "gaia.globalfee.v1beta1.QueryMinimumGasPricesRequest") - proto.RegisterType((*QueryMinimumGasPricesResponse)(nil), "gaia.globalfee.v1beta1.QueryMinimumGasPricesResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "gaia.globalfee.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "gaia.globalfee.v1beta1.QueryParamsResponse") } func init() { @@ -125,31 +141,37 @@ func init() { } var fileDescriptor_12a736cede25d10a = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xb1, 0x4f, 0xdb, 0x40, - 0x14, 0xc6, 0x7d, 0xad, 0xda, 0xc1, 0x5d, 0x22, 0xab, 0xaa, 0xda, 0xc8, 0x3d, 0x57, 0x9e, 0xa2, - 0x36, 0xbd, 0x53, 0xd2, 0x76, 0xe9, 0x98, 0x56, 0x62, 0x42, 0x82, 0x8c, 0x2c, 0xd1, 0xd9, 0x1c, - 0xc7, 0x09, 0x9f, 0x9f, 0x93, 0x3b, 0x23, 0xbc, 0xf2, 0x17, 0x20, 0xf1, 0x5f, 0xb0, 0xb2, 0xc2, - 0x9e, 0x31, 0x12, 0x0b, 0x93, 0x41, 0x09, 0x13, 0x23, 0x7f, 0x01, 0xb2, 0x9d, 0x00, 0x8a, 0x09, - 0x12, 0x93, 0x2d, 0x7d, 0xbf, 0xf7, 0x3e, 0x7d, 0xdf, 0x3d, 0xdb, 0x17, 0x4c, 0x32, 0x2a, 0x22, - 0x08, 0x58, 0xb4, 0xc3, 0x39, 0xdd, 0xef, 0x04, 0xdc, 0xb0, 0x0e, 0x1d, 0xa6, 0x7c, 0x94, 0x91, - 0x64, 0x04, 0x06, 0x9c, 0x4f, 0x05, 0x43, 0x1e, 0x18, 0x32, 0x67, 0x9a, 0x1f, 0x05, 0x08, 0x28, - 0x11, 0x5a, 0xfc, 0x55, 0x74, 0xd3, 0x15, 0x00, 0x22, 0xe2, 0x94, 0x25, 0x92, 0xb2, 0x38, 0x06, - 0xc3, 0x8c, 0x84, 0x58, 0xcf, 0x55, 0x1c, 0x82, 0x56, 0xa0, 0x69, 0xc0, 0xf4, 0xa3, 0x59, 0x08, - 0x32, 0xae, 0x74, 0x1f, 0xdb, 0xee, 0x66, 0x61, 0xbd, 0x2e, 0x63, 0xa9, 0x52, 0xb5, 0xc6, 0xf4, - 0xc6, 0x48, 0x86, 0x5c, 0xf7, 0xf9, 0x30, 0xe5, 0xda, 0xf8, 0x39, 0xb2, 0xbf, 0xae, 0x00, 0x74, - 0x02, 0xb1, 0xe6, 0xce, 0x19, 0xb2, 0x1d, 0x55, 0x89, 0x03, 0xc1, 0xf4, 0x20, 0x29, 0xe5, 0xcf, - 0xe8, 0xdb, 0xdb, 0xd6, 0x87, 0xae, 0x4b, 0x2a, 0x7f, 0x52, 0xf8, 0x2f, 0x82, 0x90, 0xff, 0x3c, - 0xfc, 0x07, 0x32, 0xee, 0x25, 0xe3, 0xdc, 0xb3, 0x6e, 0x73, 0xcf, 0xad, 0xcf, 0xb7, 0x41, 0x49, - 0xc3, 0x55, 0x62, 0xb2, 0xbb, 0xdc, 0xfb, 0x92, 0x31, 0x15, 0xfd, 0xf5, 0xeb, 0x94, 0x7f, 0x72, - 0xe5, 0xfd, 0x10, 0xd2, 0xec, 0xa6, 0x01, 0x09, 0x41, 0xd1, 0x79, 0xd8, 0xea, 0xf3, 0x53, 0x6f, - 0xef, 0x51, 0x93, 0x25, 0x5c, 0x2f, 0x0c, 0x75, 0xbf, 0xa1, 0x96, 0x62, 0x74, 0xcf, 0x91, 0xfd, - 0xae, 0x0c, 0xe8, 0x9c, 0x22, 0xbb, 0xb1, 0x9c, 0xd2, 0xf9, 0x4d, 0x9e, 0x7f, 0x0c, 0xf2, 0x52, - 0x6b, 0xcd, 0x3f, 0xaf, 0x9c, 0xaa, 0xaa, 0xf4, 0xbb, 0x87, 0x17, 0x37, 0xc7, 0x6f, 0xda, 0xce, - 0x77, 0xba, 0xe2, 0x4a, 0xea, 0x0d, 0xf4, 0x7a, 0xe3, 0x29, 0x46, 0x93, 0x29, 0x46, 0xd7, 0x53, - 0x8c, 0x8e, 0x66, 0xd8, 0x9a, 0xcc, 0xb0, 0x75, 0x39, 0xc3, 0xd6, 0x56, 0xab, 0x5e, 0x4c, 0xb9, - 0xf6, 0xe0, 0xc9, 0xe2, 0xb2, 0x9e, 0xe0, 0x7d, 0x79, 0x0b, 0xbf, 0xee, 0x03, 0x00, 0x00, 0xff, - 0xff, 0x73, 0x0d, 0xf8, 0x43, 0x9d, 0x02, 0x00, 0x00, + // 465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xbf, 0x6e, 0xd4, 0x40, + 0x10, 0xc6, 0xcf, 0x39, 0x88, 0x84, 0x69, 0xd0, 0x72, 0x42, 0xc7, 0xe9, 0x64, 0x9f, 0x8c, 0x14, + 0x9d, 0x08, 0xec, 0x2a, 0xa1, 0xa3, 0x34, 0x88, 0x54, 0x11, 0xe1, 0x14, 0x1a, 0x28, 0xac, 0xb1, + 0xd9, 0x2c, 0x2b, 0xbc, 0x7f, 0x72, 0xb3, 0x46, 0xe7, 0x36, 0x1d, 0x1d, 0x52, 0xde, 0x82, 0x67, + 0xe0, 0x01, 0x52, 0x46, 0xa2, 0xa1, 0x3a, 0xd0, 0x1d, 0x15, 0x65, 0x9e, 0x00, 0xd9, 0xbe, 0x00, + 0x91, 0x13, 0x29, 0x95, 0xad, 0x9d, 0xdf, 0x7c, 0xdf, 0xce, 0x7e, 0xe3, 0x47, 0x02, 0x24, 0x30, + 0x91, 0x9b, 0x14, 0xf2, 0x03, 0xce, 0xd9, 0xc7, 0xad, 0x94, 0x3b, 0xd8, 0x62, 0x87, 0x05, 0x9f, + 0x96, 0xd4, 0x4e, 0x8d, 0x33, 0xe4, 0x5e, 0xc5, 0xd0, 0xbf, 0x0c, 0x5d, 0x31, 0x83, 0x9e, 0x30, + 0xc2, 0xd4, 0x08, 0xab, 0xfe, 0x1a, 0x7a, 0x30, 0x14, 0xc6, 0x88, 0x9c, 0x33, 0xb0, 0x92, 0x81, + 0xd6, 0xc6, 0x81, 0x93, 0x46, 0xe3, 0xaa, 0x1a, 0x64, 0x06, 0x95, 0x41, 0x96, 0x02, 0xfe, 0x33, + 0xcb, 0x8c, 0xd4, 0x4d, 0x3d, 0xea, 0xf9, 0xe4, 0x55, 0x65, 0xbd, 0x07, 0x53, 0x50, 0x38, 0xe1, + 0x87, 0x05, 0x47, 0x17, 0x1d, 0x75, 0xfd, 0xbb, 0x17, 0x8e, 0xd1, 0x1a, 0x8d, 0x9c, 0x7c, 0xf5, + 0x7c, 0xa2, 0xa4, 0x96, 0xaa, 0x50, 0x89, 0x00, 0x4c, 0xec, 0x54, 0x66, 0x1c, 0xfb, 0xde, 0xa8, + 0x3b, 0xbe, 0xbd, 0x3d, 0xa4, 0x8d, 0x17, 0xad, 0xbc, 0xce, 0x2f, 0x4d, 0x9f, 0xf3, 0xec, 0x99, + 0x91, 0x3a, 0xb6, 0x27, 0xf3, 0xb0, 0xf3, 0x7b, 0x1e, 0x0e, 0xdb, 0xfd, 0x8f, 0x8c, 0x92, 0x8e, + 0x2b, 0xeb, 0xca, 0xb3, 0x79, 0x78, 0xbf, 0x04, 0x95, 0x3f, 0x8d, 0xda, 0x54, 0xf4, 0xe5, 0x47, + 0xb8, 0x29, 0xa4, 0x7b, 0x5f, 0xa4, 0x34, 0x33, 0x8a, 0xad, 0x06, 0x6b, 0x3e, 0x8f, 0xf1, 0xdd, + 0x07, 0xe6, 0x4a, 0xcb, 0xf1, 0xdc, 0x10, 0x27, 0x77, 0x56, 0x1a, 0x3b, 0x80, 0x7b, 0xb5, 0x02, + 0x79, 0xeb, 0xf7, 0xd3, 0xd2, 0x02, 0x62, 0xa2, 0xa4, 0x4e, 0x0e, 0x38, 0x4f, 0x14, 0x8a, 0xa4, + 0x6e, 0xeb, 0xaf, 0x8d, 0xba, 0xe3, 0x5b, 0xf1, 0x83, 0xb3, 0x79, 0x18, 0x36, 0x37, 0xb8, 0x8a, + 0x8c, 0x26, 0xbd, 0xa6, 0xb4, 0x2b, 0xf5, 0x0b, 0xce, 0x77, 0x51, 0xec, 0x57, 0xc7, 0xe4, 0xa5, + 0xbf, 0xa1, 0x60, 0x96, 0x38, 0xe3, 0x20, 0x4f, 0x2e, 0x69, 0xae, 0x26, 0x29, 0x10, 0x04, 0xef, + 0x77, 0x47, 0xde, 0xf8, 0xc6, 0x24, 0x54, 0x30, 0xdb, 0xaf, 0xe0, 0xf8, 0xa2, 0xda, 0x0e, 0xe0, + 0xeb, 0x0a, 0xdb, 0x3e, 0xf6, 0xfc, 0x9b, 0x75, 0x08, 0xe4, 0x93, 0xe7, 0xaf, 0x37, 0x49, 0x90, + 0x87, 0xf4, 0xf2, 0xe5, 0xa0, 0xed, 0x14, 0x07, 0x9b, 0xd7, 0x62, 0x9b, 0x68, 0xa3, 0x8d, 0xa3, + 0x6f, 0xbf, 0x8e, 0xd7, 0x46, 0x24, 0x60, 0x57, 0x6c, 0xa8, 0xad, 0xf9, 0x38, 0x3e, 0x59, 0x04, + 0xde, 0xe9, 0x22, 0xf0, 0x7e, 0x2e, 0x02, 0xef, 0xf3, 0x32, 0xe8, 0x9c, 0x2e, 0x83, 0xce, 0xf7, + 0x65, 0xd0, 0x79, 0x33, 0x6e, 0x87, 0x53, 0x4b, 0xcd, 0xfe, 0x13, 0xab, 0x5f, 0x30, 0x5d, 0xaf, + 0x77, 0xef, 0xc9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xcc, 0x5c, 0xb6, 0x1a, 0x0d, 0x03, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -164,7 +186,7 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -175,9 +197,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasPricesRequest, opts ...grpc.CallOption) (*QueryMinimumGasPricesResponse, error) { - out := new(QueryMinimumGasPricesResponse) - err := c.cc.Invoke(ctx, "/gaia.globalfee.v1beta1.Query/MinimumGasPrices", in, out, opts...) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/gaia.globalfee.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -186,35 +208,35 @@ func (c *queryClient) MinimumGasPrices(ctx context.Context, in *QueryMinimumGasP // QueryServer is the server API for Query service. type QueryServer interface { - MinimumGasPrices(context.Context, *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) MinimumGasPrices(ctx context.Context, req *QueryMinimumGasPricesRequest) (*QueryMinimumGasPricesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method MinimumGasPrices not implemented") +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_MinimumGasPrices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryMinimumGasPricesRequest) +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).MinimumGasPrices(ctx, in) + return srv.(QueryServer).Params(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/gaia.globalfee.v1beta1.Query/MinimumGasPrices", + FullMethod: "/gaia.globalfee.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).MinimumGasPrices(ctx, req.(*QueryMinimumGasPricesRequest)) + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) } return interceptor(ctx, in, info, handler) } @@ -224,15 +246,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "MinimumGasPrices", - Handler: _Query_MinimumGasPrices_Handler, + MethodName: "Params", + Handler: _Query_Params_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "gaia/globalfee/v1beta1/query.proto", } -func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -242,12 +264,12 @@ func (m *QueryMinimumGasPricesRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -255,7 +277,7 @@ func (m *QueryMinimumGasPricesRequest) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -265,16 +287,30 @@ func (m *QueryMinimumGasPricesResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryMinimumGasPricesResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryMinimumGasPricesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + i-- + dAtA[i] = 0x18 + } + if len(m.BypassMinFeeMsgTypes) > 0 { + for iNdEx := len(m.BypassMinFeeMsgTypes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BypassMinFeeMsgTypes[iNdEx]) + copy(dAtA[i:], m.BypassMinFeeMsgTypes[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.BypassMinFeeMsgTypes[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.MinimumGasPrices) > 0 { for iNdEx := len(m.MinimumGasPrices) - 1; iNdEx >= 0; iNdEx-- { { @@ -303,7 +339,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryMinimumGasPricesRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -312,7 +348,7 @@ func (m *QueryMinimumGasPricesRequest) Size() (n int) { return n } -func (m *QueryMinimumGasPricesResponse) Size() (n int) { +func (m *QueryParamsResponse) Size() (n int) { if m == nil { return 0 } @@ -324,6 +360,15 @@ func (m *QueryMinimumGasPricesResponse) Size() (n int) { n += 1 + l + sovQuery(uint64(l)) } } + if len(m.BypassMinFeeMsgTypes) > 0 { + for _, s := range m.BypassMinFeeMsgTypes { + l = len(s) + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.MaxTotalBypassMinFeeMsgGasUsage != 0 { + n += 1 + sovQuery(uint64(m.MaxTotalBypassMinFeeMsgGasUsage)) + } return n } @@ -333,7 +378,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -356,10 +401,10 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -383,7 +428,7 @@ func (m *QueryMinimumGasPricesRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -406,10 +451,10 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryMinimumGasPricesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -446,6 +491,57 @@ func (m *QueryMinimumGasPricesResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BypassMinFeeMsgTypes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BypassMinFeeMsgTypes = append(m.BypassMinFeeMsgTypes, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTotalBypassMinFeeMsgGasUsage", wireType) + } + m.MaxTotalBypassMinFeeMsgGasUsage = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTotalBypassMinFeeMsgGasUsage |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/globalfee/types/query.pb.gw.go b/x/globalfee/types/query.pb.gw.go index 0e33d9df1a5..5a24a95a0ca 100644 --- a/x/globalfee/types/query.pb.gw.go +++ b/x/globalfee/types/query.pb.gw.go @@ -33,20 +33,20 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := client.MinimumGasPrices(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryMinimumGasPricesRequest +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := server.MinimumGasPrices(ctx, &protoReq) + msg, err := server.Params(ctx, &protoReq) return msg, metadata, err } @@ -57,7 +57,7 @@ func local_request_Query_MinimumGasPrices_0(ctx context.Context, marshaler runti // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -68,7 +68,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -76,7 +76,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -121,7 +121,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_MinimumGasPrices_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -130,14 +130,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_MinimumGasPrices_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_MinimumGasPrices_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -145,9 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_MinimumGasPrices_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"gaia", "globalfee", "v1beta1", "minimum_gas_prices"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"gaia", "globalfee", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_MinimumGasPrices_0 = runtime.ForwardResponseMessage + forward_Query_Params_0 = runtime.ForwardResponseMessage )