From 8d819e3a3187ffc61993b7c4e520c2b6dbb9cf45 Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 22 Dec 2022 14:51:19 +0800 Subject: [PATCH 01/11] feat: add feehub module --- proto/cosmos/feehub/v1alpha1/feehub.proto | 16 + proto/cosmos/feehub/v1alpha1/genesis.proto | 13 + proto/cosmos/feehub/v1alpha1/query.proto | 25 + x/auth/ante/expected_keepers.go | 5 + x/auth/ante/msg_fee.go | 108 +++++ x/feehub/client/cli/query.go | 59 +++ x/feehub/keeper/genesis.go | 21 + x/feehub/keeper/grpc_query.go | 24 + x/feehub/keeper/keeper.go | 43 ++ x/feehub/keeper/params.go | 17 + x/feehub/keeper/querier.go | 34 ++ x/feehub/module.go | 164 +++++++ x/feehub/simulation/genesis.go | 65 +++ x/feehub/simulation/params.go | 28 ++ x/feehub/types/codec.go | 34 ++ x/feehub/types/fee_calculator.go | 39 ++ x/feehub/types/feehub.pb.go | 409 ++++++++++++++++ x/feehub/types/genesis.go | 40 ++ x/feehub/types/genesis.pb.go | 324 +++++++++++++ x/feehub/types/key.go | 15 + x/feehub/types/params.go | 120 +++++ x/feehub/types/querier.go | 6 + x/feehub/types/query.pb.go | 537 +++++++++++++++++++++ x/feehub/types/query.pb.gw.go | 153 ++++++ 24 files changed, 2299 insertions(+) create mode 100644 proto/cosmos/feehub/v1alpha1/feehub.proto create mode 100644 proto/cosmos/feehub/v1alpha1/genesis.proto create mode 100644 proto/cosmos/feehub/v1alpha1/query.proto create mode 100644 x/auth/ante/msg_fee.go create mode 100644 x/feehub/client/cli/query.go create mode 100644 x/feehub/keeper/genesis.go create mode 100644 x/feehub/keeper/grpc_query.go create mode 100644 x/feehub/keeper/keeper.go create mode 100644 x/feehub/keeper/params.go create mode 100644 x/feehub/keeper/querier.go create mode 100644 x/feehub/module.go create mode 100644 x/feehub/simulation/genesis.go create mode 100644 x/feehub/simulation/params.go create mode 100644 x/feehub/types/codec.go create mode 100644 x/feehub/types/fee_calculator.go create mode 100644 x/feehub/types/feehub.pb.go create mode 100644 x/feehub/types/genesis.go create mode 100644 x/feehub/types/genesis.pb.go create mode 100644 x/feehub/types/key.go create mode 100644 x/feehub/types/params.go create mode 100644 x/feehub/types/querier.go create mode 100644 x/feehub/types/query.pb.go create mode 100644 x/feehub/types/query.pb.gw.go diff --git a/proto/cosmos/feehub/v1alpha1/feehub.proto b/proto/cosmos/feehub/v1alpha1/feehub.proto new file mode 100644 index 0000000000..f6b8518d99 --- /dev/null +++ b/proto/cosmos/feehub/v1alpha1/feehub.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.feehub.v1alpha1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; + +// Params defines the parameters for the feehub module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; + uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; + uint64 msg_send_gas = 3 [(gogoproto.customname) = "MsgSendGas"]; +} diff --git a/proto/cosmos/feehub/v1alpha1/genesis.proto b/proto/cosmos/feehub/v1alpha1/genesis.proto new file mode 100644 index 0000000000..bf41bfb937 --- /dev/null +++ b/proto/cosmos/feehub/v1alpha1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cosmos.feehub.v1alpha1; + +import "gogoproto/gogo.proto"; +import "cosmos/feehub/v1alpha1/feehub.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; + +// GenesisState defines the feehub module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/feehub/v1alpha1/query.proto b/proto/cosmos/feehub/v1alpha1/query.proto new file mode 100644 index 0000000000..2098c71148 --- /dev/null +++ b/proto/cosmos/feehub/v1alpha1/query.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package cosmos.feehub.v1alpha1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/feehub/v1alpha1/feehub.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; + +// Query defines the gRPC querier service. +service Query { + // Params queries all parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/feehub/v1alpha1/params"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 4dbbbd21c7..fcdf71be6d 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -3,6 +3,7 @@ package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + feehubtypes "github.com/cosmos/cosmos-sdk/x/feehub/types" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -18,3 +19,7 @@ type AccountKeeper interface { type FeegrantKeeper interface { UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } + +type FeehubKeeper interface { + GetParams(ctx sdk.Context) (params feehubtypes.Params) +} diff --git a/x/auth/ante/msg_fee.go b/x/auth/ante/msg_fee.go new file mode 100644 index 0000000000..ab204b1e23 --- /dev/null +++ b/x/auth/ante/msg_fee.go @@ -0,0 +1,108 @@ +package ante + +import ( + "cosmossdk.io/errors" + + "github.com/cosmos/cosmos-sdk/codec/legacy" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// ConsumeMsgGasDecorator will take in parameters and consume gas depending on +// the size of tx and msg type before calling next AnteHandler. +// +// CONTRACT: If simulate=true, then signatures must either be completely filled +// in or empty. +type ConsumeMsgGasDecorator struct { + ak AccountKeeper + fhk FeehubKeeper +} + +func NewConsumeMsgGasDecorator(ak AccountKeeper, fhk FeehubKeeper) ConsumeMsgGasDecorator { + return ConsumeMsgGasDecorator{ + ak: ak, + fhk: fhk, + } +} + +func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, errors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") + } + + params := cmfg.fhk.GetParams(ctx) + txBytesLength := uint64(len(ctx.TxBytes())) + + msgGas, err := cmfg.getMsgGas(params, sigTx) + if err != nil { + return ctx, err + } + + // simulate gas cost for signatures in simulate mode + if simulate { + // in simulate mode, each element should be a nil signature + sigs, err := sigTx.GetSignaturesV2() + if err != nil { + return ctx, err + } + n := len(sigs) + + for i, signer := range sigTx.GetSigners() { + // if signature is already filled in, no need to simulate gas cost + if i < n && !isIncompleteSignature(sigs[i].Data) { + continue + } + + var pubkey cryptotypes.PubKey + + acc := cmfg.ak.GetAccount(ctx, signer) + + // use placeholder simSecp256k1Pubkey if sig is nil + if acc == nil || acc.GetPubKey() == nil { + pubkey = simSecp256k1Pubkey + } else { + pubkey = acc.GetPubKey() + } + + // use stdsignature to mock the size of a full signature + simSig := legacytx.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready + Signature: simSecp256k1Sig[:], + PubKey: pubkey, + } + + sigBz := legacy.Cdc.MustMarshal(simSig) + txBytesLength = txBytesLength + uint64(len(sigBz)) + 6 + } + } + + if txBytesLength > params.GetMaxTxSize() { + return ctx, errors.Wrapf(sdkerrors.ErrTxTooLarge, "tx length: %d, limit: %d", txBytesLength, params.GetMaxTxSize()) + } + + gasByByteLength := txBytesLength * params.GetMinGasPerByte() + if gasByByteLength >= msgGas { + ctx.GasMeter().ConsumeGas(gasByByteLength, "gas by tx byte length") + } else { + ctx.GasMeter().ConsumeGas(msgGas, "msg gas") + } + + return next(ctx, tx, simulate) +} + +func (cmfg ConsumeMsgGasDecorator) getMsgGas(params types.Params, tx sdk.Tx) (uint64, error) { + msg := tx.GetMsgs()[0] + switch msg := msg.(type) { + case *banktypes.MsgSend: + feeCalcGen := types.GetCalculatorGen(msg.Type()) + feeCalc := feeCalcGen(params) + return feeCalc(msg), nil + default: + return 0, errors.Wrapf(sdkerrors.ErrInvalidType, "unrecognized msg type: %T", msg) + } +} diff --git a/x/feehub/client/cli/query.go b/x/feehub/client/cli/query.go new file mode 100644 index 0000000000..8304024bc6 --- /dev/null +++ b/x/feehub/client/cli/query.go @@ -0,0 +1,59 @@ +package cli + +import ( + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// GetQueryCmd returns the transaction commands for this module +func GetQueryCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the feehub module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand( + QueryParamsCmd(), + ) + + return cmd +} + +// QueryParamsCmd returns the command handler for evidence parameter querying. +func QueryParamsCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current feehub parameters", + Args: cobra.NoArgs, + Long: strings.TrimSpace(`Query the current feehub parameters: + +$ query feehub params +`), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/feehub/keeper/genesis.go b/x/feehub/keeper/genesis.go new file mode 100644 index 0000000000..3fa179e33b --- /dev/null +++ b/x/feehub/keeper/genesis.go @@ -0,0 +1,21 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// InitGenesis - Init store state from genesis data +// +// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through +// a genesis port script to the new fee collector account +func (fhk FeehubKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + fhk.SetParams(ctx, data.Params) +} + +// ExportGenesis returns a GenesisState for a given context and keeper +func (fhk FeehubKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params := fhk.GetParams(ctx) + + return types.NewGenesisState(params) +} diff --git a/x/feehub/keeper/grpc_query.go b/x/feehub/keeper/grpc_query.go new file mode 100644 index 0000000000..2983937c90 --- /dev/null +++ b/x/feehub/keeper/grpc_query.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +var _ types.QueryServer = FeehubKeeper{} + +// Params returns parameters of auth module +func (fhk FeehubKeeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) + params := fhk.GetParams(ctx) + + return &types.QueryParamsResponse{Params: params}, nil +} diff --git a/x/feehub/keeper/keeper.go b/x/feehub/keeper/keeper.go new file mode 100644 index 0000000000..bdbace7d1d --- /dev/null +++ b/x/feehub/keeper/keeper.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// FeehubKeeper encodes/decodes accounts using the go-amino (binary) +// encoding/decoding library. +type FeehubKeeper struct { + key storetypes.StoreKey + cdc codec.BinaryCodec + paramSubspace paramtypes.Subspace +} + +// NewFeehubKeeper returns a new feehub keeper +func NewFeehubKeeper( + cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, +) FeehubKeeper { + // set KeyTable if it has not already been set + if !paramstore.HasKeyTable() { + paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) + } + + return FeehubKeeper{ + key: key, + cdc: cdc, + paramSubspace: paramstore, + } +} + +// Logger returns a module-specific logger. +func (fhk FeehubKeeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// GetCodec return codec.Codec object used by the keeper +func (fhk FeehubKeeper) GetCodec() codec.BinaryCodec { return fhk.cdc } diff --git a/x/feehub/keeper/params.go b/x/feehub/keeper/params.go new file mode 100644 index 0000000000..3f2c8f4577 --- /dev/null +++ b/x/feehub/keeper/params.go @@ -0,0 +1,17 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// SetParams sets the auth module's parameters. +func (fhk FeehubKeeper) SetParams(ctx sdk.Context, params types.Params) { + fhk.paramSubspace.SetParamSet(ctx, ¶ms) +} + +// GetParams gets the auth module's parameters. +func (fhk FeehubKeeper) GetParams(ctx sdk.Context) (params types.Params) { + fhk.paramSubspace.GetParamSet(ctx, ¶ms) + return +} diff --git a/x/feehub/keeper/querier.go b/x/feehub/keeper/querier.go new file mode 100644 index 0000000000..68cefc015a --- /dev/null +++ b/x/feehub/keeper/querier.go @@ -0,0 +1,34 @@ +package keeper + +import ( + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// NewQuerier creates a querier for auth REST endpoints +func NewQuerier(k FeehubKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { + switch path[0] { + case types.QueryParams: + return queryParams(ctx, k, legacyQuerierCdc) + + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) + } + } +} + +func queryParams(ctx sdk.Context, k FeehubKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + params := k.GetParams(ctx) + + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + + return res, nil +} diff --git a/x/feehub/module.go b/x/feehub/module.go new file mode 100644 index 0000000000..217bf1203e --- /dev/null +++ b/x/feehub/module.go @@ -0,0 +1,164 @@ +package feehub + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/client/cli" + "github.com/cosmos/cosmos-sdk/x/feehub/keeper" + "github.com/cosmos/cosmos-sdk/x/feehub/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the feehub module. +type AppModuleBasic struct{} + +// Name returns the feehub module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the feehub module's types for the given codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// DefaultGenesis returns default genesis state as raw bytes for the feehub +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the feehub module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(data) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feehub module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root tx command for the feehub module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +// GetQueryCmd returns the root query command for the feehub module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterInterfaces registers interfaces and implementations of the feehub module. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// AppModule implements an application module for the feehub module. +type AppModule struct { + AppModuleBasic + + feehubKeeper keeper.FeehubKeeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, feehubKeeper keeper.FeehubKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + feehubKeeper: feehubKeeper, + } +} + +// Name returns the feehub module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants performs a no-op. +func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Deprecated: Route returns the message routing key for the feehub module. +func (AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute returns the feehub module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler returns the feehub module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return keeper.NewQuerier(am.feehubKeeper, legacyQuerierCdc) +} + +// RegisterServices registers a GRPC query service to respond to the +// module-specific GRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) {} + +// InitGenesis performs genesis initialization for the feehub module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + am.feehubKeeper.InitGenesis(ctx, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the feehub +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.feehubKeeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 3 } + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the feehub module +func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized feehub param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return simulation.ParamChanges(r) +} + +// RegisterStoreDecoder registers a decoder for feehub module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {} + +// WeightedOperations doesn't return any feehub module operation. +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return nil +} diff --git a/x/feehub/simulation/genesis.go b/x/feehub/simulation/genesis.go new file mode 100644 index 0000000000..33e4997bd7 --- /dev/null +++ b/x/feehub/simulation/genesis.go @@ -0,0 +1,65 @@ +package simulation + +import ( + "encoding/json" + "fmt" + "math/rand" + + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// Simulation parameter constants +const ( + MaxTxSize = "max_tx_size" + MinGasPerByte = "min_gas_per_byte" + MsgSendGas = "msg_send_gas" +) + +// GenMaxTxSize randomized MaxTxSize +func GenMaxTxSize(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 2500, 5000)) +} + +// GenMinGasPerByte randomized MinGasPerByte +func GenMinGasPerByte(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 2500, 5000)) +} + +// GenMsgSendGas randomized MsgSendGas +func GenMsgSendGas(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 1e6, 1e7)) +} + +// RandomizedGenState generates a random GenesisState for auth +func RandomizedGenState(simState *module.SimulationState) { + var maxTxSize uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, MaxTxSize, &maxTxSize, simState.Rand, + func(r *rand.Rand) { maxTxSize = GenMaxTxSize(r) }, + ) + + var minGasPerByte uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, MinGasPerByte, &minGasPerByte, simState.Rand, + func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, + ) + + var msgSendGas uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, MsgSendGas, &msgSendGas, simState.Rand, + func(r *rand.Rand) { msgSendGas = GenMsgSendGas(r) }, + ) + + params := types.NewParams(maxTxSize, minGasPerByte, msgSendGas) + + feehubGenesis := types.NewGenesisState(params) + + bz, err := json.MarshalIndent(&feehubGenesis.Params, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("Selected randomly generated feehub parameters:\n%s\n", bz) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feehubGenesis) +} diff --git a/x/feehub/simulation/params.go b/x/feehub/simulation/params.go new file mode 100644 index 0000000000..e17b537cf7 --- /dev/null +++ b/x/feehub/simulation/params.go @@ -0,0 +1,28 @@ +package simulation + +// DONTCOVER + +import ( + "fmt" + "math/rand" + + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +const ( + keyMsgSendGas = "MsgSendGas" +) + +// ParamChanges defines the parameters that can be modified by param change proposals +// on the simulation +func ParamChanges(r *rand.Rand) []simtypes.ParamChange { + return []simtypes.ParamChange{ + simulation.NewSimParamChange(types.ModuleName, keyMsgSendGas, + func(r *rand.Rand) string { + return fmt.Sprintf("\"%d\"", GenMsgSendGas(r)) + }, + ), + } +} diff --git a/x/feehub/types/codec.go b/x/feehub/types/codec.go new file mode 100644 index 0000000000..da6aced74c --- /dev/null +++ b/x/feehub/types/codec.go @@ -0,0 +1,34 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" +) + +// RegisterLegacyAminoCodec registers the account interfaces and concrete types on the +// provided LegacyAmino codec. These types are used for Amino JSON serialization +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +// RegisterInterfaces associates protoName with AccountI interface +// and creates a registry of it's concrete implementations +func RegisterInterfaces(registry types.InterfaceRegistry) { +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) +} diff --git a/x/feehub/types/fee_calculator.go b/x/feehub/types/fee_calculator.go new file mode 100644 index 0000000000..c7ce5e781d --- /dev/null +++ b/x/feehub/types/fee_calculator.go @@ -0,0 +1,39 @@ +package types + +import "github.com/cosmos/cosmos-sdk/types" + +type ( + FeeCalculator func(msg types.Msg) uint64 + FeeCalculatorGenerator func(params Params) FeeCalculator +) + +var ( + calculators = make(map[string]FeeCalculator) + CalculatorsGen = make(map[string]FeeCalculatorGenerator) +) + +func RegisterCalculator(msgType string, feeCalc FeeCalculator) { + calculators[msgType] = feeCalc +} + +func GetCalculatorGen(msgType string) FeeCalculatorGenerator { + return CalculatorsGen[msgType] +} + +func FixedFeeCalculator(amount uint64) FeeCalculator { + return func(msg types.Msg) uint64 { + return amount + } +} + +var msgSendFeeCalculatorGen = func(params Params) FeeCalculator { + msgSendGas := params.GetMsgSendGas() + if msgSendGas == 0 { + return FixedFeeCalculator(DefaultMsgSendGas) + } + return FixedFeeCalculator(msgSendGas) +} + +func init() { + CalculatorsGen["send"] = msgSendFeeCalculatorGen +} diff --git a/x/feehub/types/feehub.pb.go b/x/feehub/types/feehub.pb.go new file mode 100644 index 0000000000..36a403986d --- /dev/null +++ b/x/feehub/types/feehub.pb.go @@ -0,0 +1,409 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feehub/v1alpha1/feehub.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the feehub module. +type Params struct { + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + MsgSendGas uint64 `protobuf:"varint,3,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_e93836928b503a00, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetMaxTxSize() uint64 { + if m != nil { + return m.MaxTxSize + } + return 0 +} + +func (m *Params) GetMinGasPerByte() uint64 { + if m != nil { + return m.MinGasPerByte + } + return 0 +} + +func (m *Params) GetMsgSendGas() uint64 { + if m != nil { + return m.MsgSendGas + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "cosmos.feehub.v1alpha1.Params") +} + +func init() { + proto.RegisterFile("cosmos/feehub/v1alpha1/feehub.proto", fileDescriptor_e93836928b503a00) +} + +var fileDescriptor_e93836928b503a00 = []byte{ + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0x48, 0x34, 0x84, 0xf2, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xc4, 0x20, 0x8a, 0xf4, 0xa0, + 0x82, 0x30, 0x45, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x25, 0xfa, 0x20, 0x16, 0x44, 0xb5, + 0xd2, 0x7a, 0x46, 0x2e, 0xb6, 0x80, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x21, 0x5d, 0x2e, 0xee, 0xdc, + 0xc4, 0x8a, 0xf8, 0x92, 0x8a, 0xf8, 0xe2, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, + 0x27, 0xde, 0x47, 0xf7, 0xe4, 0x39, 0x7d, 0x13, 0x2b, 0x42, 0x2a, 0x82, 0x33, 0xab, 0x52, 0x83, + 0x38, 0x73, 0x61, 0x4c, 0x21, 0x2b, 0x2e, 0x81, 0xdc, 0xcc, 0xbc, 0xf8, 0xf4, 0xc4, 0xe2, 0xf8, + 0x82, 0xd4, 0xa2, 0xf8, 0xa4, 0xca, 0x92, 0x54, 0x09, 0x26, 0xb0, 0x1e, 0xc1, 0x47, 0xf7, 0xe4, + 0x79, 0x7d, 0x33, 0xf3, 0xdc, 0x13, 0x8b, 0x03, 0x52, 0x8b, 0x9c, 0x2a, 0x4b, 0x52, 0x83, 0x78, + 0x73, 0x91, 0xb9, 0x42, 0x06, 0x5c, 0x3c, 0xb9, 0xc5, 0xe9, 0xf1, 0xc5, 0xa9, 0x79, 0x29, 0x20, + 0x03, 0x24, 0x98, 0xc1, 0xfa, 0xf8, 0x1e, 0xdd, 0x93, 0xe7, 0xf2, 0x2d, 0x4e, 0x0f, 0x4e, 0xcd, + 0x4b, 0x71, 0x4f, 0x2c, 0x0e, 0xe2, 0xca, 0x85, 0xb3, 0xad, 0x38, 0x66, 0x2c, 0x90, 0x67, 0x78, + 0xb1, 0x40, 0x9e, 0xd1, 0xc9, 0xf5, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, + 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, + 0xb4, 0xd3, 0x33, 0x4b, 0x40, 0x5e, 0x4e, 0xce, 0xcf, 0xd5, 0x87, 0x86, 0x14, 0x84, 0xd2, 0x2d, + 0x4e, 0xc9, 0xd6, 0xaf, 0x80, 0x05, 0x5b, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xff, + 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x05, 0xf6, 0x6a, 0x54, 0x01, 0x00, 0x00, +} + +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.MaxTxSize != that1.MaxTxSize { + return false + } + if this.MinGasPerByte != that1.MinGasPerByte { + return false + } + if this.MsgSendGas != that1.MsgSendGas { + return false + } + return true +} +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MsgSendGas != 0 { + i = encodeVarintFeehub(dAtA, i, uint64(m.MsgSendGas)) + i-- + dAtA[i] = 0x18 + } + if m.MinGasPerByte != 0 { + i = encodeVarintFeehub(dAtA, i, uint64(m.MinGasPerByte)) + i-- + dAtA[i] = 0x10 + } + if m.MaxTxSize != 0 { + i = encodeVarintFeehub(dAtA, i, uint64(m.MaxTxSize)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintFeehub(dAtA []byte, offset int, v uint64) int { + offset -= sovFeehub(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MaxTxSize != 0 { + n += 1 + sovFeehub(uint64(m.MaxTxSize)) + } + if m.MinGasPerByte != 0 { + n += 1 + sovFeehub(uint64(m.MinGasPerByte)) + } + if m.MsgSendGas != 0 { + n += 1 + sovFeehub(uint64(m.MsgSendGas)) + } + return n +} + +func sovFeehub(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFeehub(x uint64) (n int) { + return sovFeehub(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeehub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxTxSize", wireType) + } + m.MaxTxSize = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeehub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxTxSize |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinGasPerByte", wireType) + } + m.MinGasPerByte = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeehub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinGasPerByte |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) + } + m.MsgSendGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeehub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSendGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipFeehub(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFeehub + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFeehub(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFeehub + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFeehub + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFeehub + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthFeehub + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFeehub + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFeehub + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFeehub = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFeehub = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFeehub = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feehub/types/genesis.go b/x/feehub/types/genesis.go new file mode 100644 index 0000000000..1f00a42562 --- /dev/null +++ b/x/feehub/types/genesis.go @@ -0,0 +1,40 @@ +package types + +import ( + "encoding/json" + + "github.com/cosmos/cosmos-sdk/codec" +) + +// NewGenesisState - Create a new genesis state +func NewGenesisState(params Params) *GenesisState { + return &GenesisState{ + Params: params, + } +} + +// DefaultGenesisState - Return a default genesis state +func DefaultGenesisState() *GenesisState { + return NewGenesisState(DefaultParams()) +} + +// GetGenesisStateFromAppState returns x/feehub GenesisState given raw application +// genesis state. +func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { + var genesisState GenesisState + + if appState[ModuleName] != nil { + cdc.MustUnmarshalJSON(appState[ModuleName], &genesisState) + } + + return genesisState +} + +// ValidateGenesis performs basic validation of feehub genesis data returning an +// error for any failed validation criteria. +func ValidateGenesis(data GenesisState) error { + if err := data.Params.Validate(); err != nil { + return err + } + return nil +} diff --git a/x/feehub/types/genesis.pb.go b/x/feehub/types/genesis.pb.go new file mode 100644 index 0000000000..d3175e0324 --- /dev/null +++ b/x/feehub/types/genesis.pb.go @@ -0,0 +1,324 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feehub/v1alpha1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the feehub module's genesis state. +type GenesisState struct { + // params defines all the paramaters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_6cab4ebd934cfcb3, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "cosmos.feehub.v1alpha1.GenesisState") +} + +func init() { + proto.RegisterFile("cosmos/feehub/v1alpha1/genesis.proto", fileDescriptor_6cab4ebd934cfcb3) +} + +var fileDescriptor_6cab4ebd934cfcb3 = []byte{ + // 201 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0x48, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0x12, 0x83, 0xa8, 0xd2, 0x83, 0xa8, 0xd2, 0x83, 0xa9, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, + 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x98, 0x09, 0xd5, 0x0d, 0x56, 0xa4, + 0xe4, 0xc3, 0xc5, 0xe3, 0x0e, 0xb1, 0x23, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x86, 0x8b, 0xad, + 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, + 0x9d, 0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x38, 0xb9, + 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, 0x7a, 0x66, 0x09, 0x48, + 0x7f, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x5d, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0xe6, + 0xc8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xdb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x3d, 0xc8, 0xca, 0x9d, 0x16, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feehub/types/key.go b/x/feehub/types/key.go new file mode 100644 index 0000000000..70b6dd1adc --- /dev/null +++ b/x/feehub/types/key.go @@ -0,0 +1,15 @@ +package types + +const ( + // module name + ModuleName = "feehub" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) diff --git a/x/feehub/types/params.go b/x/feehub/types/params.go new file mode 100644 index 0000000000..24389f4f1d --- /dev/null +++ b/x/feehub/types/params.go @@ -0,0 +1,120 @@ +package types + +import ( + "fmt" + + "sigs.k8s.io/yaml" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Default parameter values +const ( + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 + DefaultMsgSendGas uint64 = 1e6 +) + +// Parameter keys +var ( + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMsgSendGas = []byte("MsgSendGas") +) + +var _ paramtypes.ParamSet = &Params{} + +// NewParams creates a new Params object +func NewParams( + maxTxSize, minGasPerByte, msgSendGas uint64, +) Params { + return Params{ + MsgSendGas: msgSendGas, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + } +} + +// ParamKeyTable for feehub module +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// ParamSetPairs implements the ParamSet interface and returns all the key/value +// pairs of feehub's parameters. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgSendGas), + paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), + paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), + } +} + +// DefaultParams returns a default set of parameters. +func DefaultParams() Params { + return Params{ + MsgSendGas: DefaultMsgSendGas, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + } +} + +// String implements the stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +func validateMaxTxSize(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid max tx size: %d", v) + } + + return nil +} + +func validateMinGasPerByte(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid min gas per byte: %d", v) + } + + return nil +} + +func validateMsgSendGas(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid msg send fee: %d", v) + } + + return nil +} + +// Validate checks that the parameters have valid values. +func (p Params) Validate() error { + if err := validateMaxTxSize(p.MaxTxSize); err != nil { + return err + } + if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { + return err + } + if err := validateMsgSendGas(p.MsgSendGas); err != nil { + return err + } + + return nil +} diff --git a/x/feehub/types/querier.go b/x/feehub/types/querier.go new file mode 100644 index 0000000000..4c6daa032d --- /dev/null +++ b/x/feehub/types/querier.go @@ -0,0 +1,6 @@ +package types + +// query endpoints supported by the feehub Querier +const ( + QueryParams = "params" +) diff --git a/x/feehub/types/query.pb.go b/x/feehub/types/query.pb.go new file mode 100644 index 0000000000..30f414966a --- /dev/null +++ b/x/feehub/types/query.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/feehub/v1alpha1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is the request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +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_17c1f0c172794f06, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +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_17c1f0c172794f06, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.feehub.v1alpha1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.feehub.v1alpha1.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("cosmos/feehub/v1alpha1/query.proto", fileDescriptor_17c1f0c172794f06) +} + +var fileDescriptor_17c1f0c172794f06 = []byte{ + // 283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0x48, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, + 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, + 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0xa1, 0xb2, 0xca, + 0x38, 0xec, 0x83, 0x9a, 0x0d, 0x56, 0xa4, 0x24, 0xc2, 0x25, 0x14, 0x08, 0xb2, 0x3f, 0x20, 0xb1, + 0x28, 0x31, 0xb7, 0x38, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x29, 0x98, 0x4b, 0x18, 0x45, + 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x86, 0x8b, 0xad, 0x00, 0x2c, 0x22, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa7, 0x87, 0xdd, 0xb9, 0x7a, 0x10, 0x7d, 0x4e, 0x2c, 0x27, 0xee, + 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x18, 0x4d, 0x66, 0xe4, 0x62, 0x05, 0x9b, 0x2a, 0xd4, 0xc9, 0xc8, + 0xc5, 0x06, 0x51, 0x22, 0xa4, 0x85, 0xcb, 0x08, 0x4c, 0x57, 0x49, 0x69, 0x13, 0xa5, 0x16, 0xe2, + 0x56, 0x25, 0xb5, 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0x29, 0x08, 0xc9, 0xe9, 0xe3, 0x08, 0x06, 0x88, + 0xab, 0x9c, 0x5c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3b, 0x3d, + 0xb3, 0x04, 0x64, 0x4d, 0x72, 0x7e, 0x2e, 0xcc, 0x0c, 0x08, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, + 0x01, 0x33, 0xb0, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x9c, 0xc6, 0x80, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xa6, 0x63, 0xf1, 0x3e, 0xe5, 0x01, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// 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 { + // Params queries all parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/cosmos.feehub.v1alpha1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries all parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +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_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).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.feehub.v1alpha1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.feehub.v1alpha1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/feehub/v1alpha1/query.proto", +} + +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/feehub/types/query.pb.gw.go b/x/feehub/types/query.pb.gw.go new file mode 100644 index 0000000000..70b656c5cd --- /dev/null +++ b/x/feehub/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/feehub/v1alpha1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +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.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +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.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// 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_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 + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + 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 { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + 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) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + 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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "feehub", "v1alpha1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) From cdd1cf0314d58cd1b4b058d64d1998621f94ba3b Mon Sep 17 00:00:00 2001 From: Roshan Date: Fri, 23 Dec 2022 21:11:43 +0800 Subject: [PATCH 02/11] fix review comments and add UTs --- proto/cosmos/feehub/v1alpha1/feehub.proto | 7 +- simapp/app.go | 21 ++++-- x/auth/ante/{msg_fee.go => msg_gas.go} | 21 +++--- x/auth/ante/msg_gas_test.go | 70 +++++++++++++++++++ x/feehub/keeper/genesis.go | 4 +- x/feehub/keeper/grpc_query.go | 4 +- x/feehub/keeper/grpc_query_test.go | 13 ++++ x/feehub/keeper/keeper.go | 12 ++-- x/feehub/keeper/keeper_test.go | 43 ++++++++++++ x/feehub/keeper/params.go | 4 +- x/feehub/keeper/querier.go | 4 +- x/feehub/module.go | 4 +- x/feehub/simulation/genesis.go | 20 ++++-- x/feehub/simulation/genesis_test.go | 46 +++++++++++++ x/feehub/simulation/params.go | 2 +- x/feehub/simulation/params_test.go | 35 ++++++++++ x/feehub/types/fee_calculator.go | 29 +++++++- x/feehub/types/feehub.pb.go | 84 +++++++++++++++++------ x/feehub/types/genesis_test.go | 46 +++++++++++++ x/feehub/types/params.go | 49 +++++++++---- 20 files changed, 438 insertions(+), 80 deletions(-) rename x/auth/ante/{msg_fee.go => msg_gas.go} (85%) create mode 100644 x/auth/ante/msg_gas_test.go create mode 100644 x/feehub/keeper/grpc_query_test.go create mode 100644 x/feehub/keeper/keeper_test.go create mode 100644 x/feehub/simulation/genesis_test.go create mode 100644 x/feehub/simulation/params_test.go create mode 100644 x/feehub/types/genesis_test.go diff --git a/proto/cosmos/feehub/v1alpha1/feehub.proto b/proto/cosmos/feehub/v1alpha1/feehub.proto index f6b8518d99..f57b2d687c 100644 --- a/proto/cosmos/feehub/v1alpha1/feehub.proto +++ b/proto/cosmos/feehub/v1alpha1/feehub.proto @@ -10,7 +10,8 @@ message Params { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; - uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - uint64 msg_send_gas = 3 [(gogoproto.customname) = "MsgSendGas"]; + uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; + uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; + uint64 msg_send_gas = 3 [(gogoproto.customname) = "MsgSendGas"]; + uint64 msg_multi_send_gas = 4 [(gogoproto.customname) = "MsgMultiSendGas"]; } diff --git a/simapp/app.go b/simapp/app.go index c2df8be04d..08aae76bd4 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -17,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + _ "github.com/cosmos/cosmos-sdk/client/docs/statik" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" @@ -62,6 +63,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/x/feehub" + feehubkeeper "github.com/cosmos/cosmos-sdk/x/feehub/keeper" + feehubtypes "github.com/cosmos/cosmos-sdk/x/feehub/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -94,9 +98,6 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - // unnamed import of statik for swagger UI support - _ "github.com/cosmos/cosmos-sdk/client/docs/statik" ) const appName = "SimApp" @@ -129,6 +130,7 @@ var ( groupmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, nftmodule.AppModuleBasic{}, + feehub.AppModuleBasic{}, ) // module account permissions @@ -181,6 +183,7 @@ type SimApp struct { FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper NFTKeeper nftkeeper.Keeper + FeehubKeeper feehubkeeper.Keeper // the module manager mm *module.Manager @@ -221,7 +224,7 @@ func NewSimApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, - authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, + authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, feehubtypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) // NOTE: The testingkey is just mounted for testing purposes. Actual applications should @@ -334,6 +337,8 @@ func NewSimApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper + app.FeehubKeeper = feehubkeeper.NewFeehubKeeper(appCodec, keys[feehubtypes.StoreKey], app.GetSubspace(feehubtypes.ModuleName)) + /**** Module Options ****/ // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment @@ -364,6 +369,7 @@ func NewSimApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), + feehub.NewAppModule(appCodec, app.FeehubKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -375,7 +381,7 @@ func NewSimApp( upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, - authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, + authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -383,7 +389,7 @@ func NewSimApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, nft.ModuleName, group.ModuleName, + feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, ) @@ -397,7 +403,7 @@ func NewSimApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, nft.ModuleName, group.ModuleName, + feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, ) @@ -655,6 +661,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) + paramsKeeper.Subspace(feehubtypes.ModuleName) return paramsKeeper } diff --git a/x/auth/ante/msg_fee.go b/x/auth/ante/msg_gas.go similarity index 85% rename from x/auth/ante/msg_fee.go rename to x/auth/ante/msg_gas.go index ab204b1e23..0d8fcaf88f 100644 --- a/x/auth/ante/msg_fee.go +++ b/x/auth/ante/msg_gas.go @@ -1,6 +1,8 @@ package ante import ( + "fmt" + "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/codec/legacy" @@ -9,7 +11,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/feehub/types" ) @@ -85,9 +86,9 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, errors.Wrapf(sdkerrors.ErrTxTooLarge, "tx length: %d, limit: %d", txBytesLength, params.GetMaxTxSize()) } - gasByByteLength := txBytesLength * params.GetMinGasPerByte() - if gasByByteLength >= msgGas { - ctx.GasMeter().ConsumeGas(gasByByteLength, "gas by tx byte length") + txBytesGas := txBytesLength * params.GetMinGasPerByte() + if txBytesGas >= msgGas { + ctx.GasMeter().ConsumeGas(txBytesGas, "gas by tx byte length") } else { ctx.GasMeter().ConsumeGas(msgGas, "msg gas") } @@ -97,12 +98,10 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula func (cmfg ConsumeMsgGasDecorator) getMsgGas(params types.Params, tx sdk.Tx) (uint64, error) { msg := tx.GetMsgs()[0] - switch msg := msg.(type) { - case *banktypes.MsgSend: - feeCalcGen := types.GetCalculatorGen(msg.Type()) - feeCalc := feeCalcGen(params) - return feeCalc(msg), nil - default: - return 0, errors.Wrapf(sdkerrors.ErrInvalidType, "unrecognized msg type: %T", msg) + feeCalcGen := types.GetCalculatorGen(sdk.MsgTypeURL(msg)) + if feeCalcGen == nil { + return 0, fmt.Errorf("failed to find fee calculator") } + feeCalc := feeCalcGen(params) + return feeCalc(msg), nil } diff --git a/x/auth/ante/msg_gas_test.go b/x/auth/ante/msg_gas_test.go new file mode 100644 index 0000000000..906a3353d9 --- /dev/null +++ b/x/auth/ante/msg_gas_test.go @@ -0,0 +1,70 @@ +package ante_test + +import ( + sdkmath "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + bank "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +func (suite *AnteTestSuite) TestMsgGas() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + suite.ctx = suite.ctx.WithBlockHeight(1) + + // keys and addresses + _, _, addr1 := testdata.KeyEthSecp256k1TestPubAddr() + _, _, addr2 := testdata.KeyEthSecp256k1TestPubAddr() + _, _, addr3 := testdata.KeyEthSecp256k1TestPubAddr() + _, _, addr4 := testdata.KeyEthSecp256k1TestPubAddr() + addrs := []sdk.AccAddress{addr1, addr2, addr3, addr4} + + // set accounts + for i, addr := range addrs { + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + } + + msgSend := bank.NewMsgSend(addr1, addr2, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)))) + in := make([]bank.Input, 3) + for i := 0; i < 3; i++ { + in[i] = bank.NewInput(addrs[i], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(100)))) + } + msgMultiSend := bank.NewMsgMultiSend(in, []bank.Output{bank.NewOutput(addr4, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewInt(300))))}) + + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + + mgd := ante.NewConsumeMsgGasDecorator(suite.app.AccountKeeper, suite.app.FeehubKeeper) + antehandler := sdk.ChainAnteDecorators(mgd) + + fixedGasConsume := uint64(4303) // gas needed when GetParams + + type testCase struct { + name string + msg sdk.Msg + expectedGas uint64 + } + testCases := []testCase{ + {"MsgSend", msgSend, 1000000}, + {"MsgMultiSend", msgMultiSend, 2400000}, + } + for _, tc := range testCases { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test + + suite.Require().NoError(suite.txBuilder.SetMsgs(tc.msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + tx, err := suite.CreateTestTx(nil, nil, nil, suite.ctx.ChainID()) + suite.Require().NoError(err) + + gasConsumedBefore := suite.ctx.GasMeter().GasConsumed() + _, err = antehandler(suite.ctx, tx, false) + gasConsumedAfter := suite.ctx.GasMeter().GasConsumed() + suite.Require().Equal(tc.expectedGas+fixedGasConsume, gasConsumedAfter-gasConsumedBefore) + } +} diff --git a/x/feehub/keeper/genesis.go b/x/feehub/keeper/genesis.go index 3fa179e33b..9c8925d0a6 100644 --- a/x/feehub/keeper/genesis.go +++ b/x/feehub/keeper/genesis.go @@ -9,12 +9,12 @@ import ( // // CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through // a genesis port script to the new fee collector account -func (fhk FeehubKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { +func (fhk Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { fhk.SetParams(ctx, data.Params) } // ExportGenesis returns a GenesisState for a given context and keeper -func (fhk FeehubKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { +func (fhk Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := fhk.GetParams(ctx) return types.NewGenesisState(params) diff --git a/x/feehub/keeper/grpc_query.go b/x/feehub/keeper/grpc_query.go index 2983937c90..501ff8e40f 100644 --- a/x/feehub/keeper/grpc_query.go +++ b/x/feehub/keeper/grpc_query.go @@ -10,10 +10,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/feehub/types" ) -var _ types.QueryServer = FeehubKeeper{} +var _ types.QueryServer = Keeper{} // Params returns parameters of auth module -func (fhk FeehubKeeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (fhk Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } diff --git a/x/feehub/keeper/grpc_query_test.go b/x/feehub/keeper/grpc_query_test.go new file mode 100644 index 0000000000..0cdab12b6d --- /dev/null +++ b/x/feehub/keeper/grpc_query_test.go @@ -0,0 +1,13 @@ +package keeper_test + +import ( + gocontext "context" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +func (suite *IntegrationTestSuite) TestQueryParams() { + res, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(suite.app.FeehubKeeper.GetParams(suite.ctx), res.GetParams()) +} diff --git a/x/feehub/keeper/keeper.go b/x/feehub/keeper/keeper.go index bdbace7d1d..21bce66757 100644 --- a/x/feehub/keeper/keeper.go +++ b/x/feehub/keeper/keeper.go @@ -10,9 +10,9 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -// FeehubKeeper encodes/decodes accounts using the go-amino (binary) +// Keeper encodes/decodes accounts using the go-amino (binary) // encoding/decoding library. -type FeehubKeeper struct { +type Keeper struct { key storetypes.StoreKey cdc codec.BinaryCodec paramSubspace paramtypes.Subspace @@ -21,13 +21,13 @@ type FeehubKeeper struct { // NewFeehubKeeper returns a new feehub keeper func NewFeehubKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, -) FeehubKeeper { +) Keeper { // set KeyTable if it has not already been set if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) } - return FeehubKeeper{ + return Keeper{ key: key, cdc: cdc, paramSubspace: paramstore, @@ -35,9 +35,9 @@ func NewFeehubKeeper( } // Logger returns a module-specific logger. -func (fhk FeehubKeeper) Logger(ctx sdk.Context) log.Logger { +func (fhk Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } // GetCodec return codec.Codec object used by the keeper -func (fhk FeehubKeeper) GetCodec() codec.BinaryCodec { return fhk.cdc } +func (fhk Keeper) GetCodec() codec.BinaryCodec { return fhk.cdc } diff --git a/x/feehub/keeper/keeper_test.go b/x/feehub/keeper/keeper_test.go new file mode 100644 index 0000000000..44333d79e1 --- /dev/null +++ b/x/feehub/keeper/keeper_test.go @@ -0,0 +1,43 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context + queryClient types.QueryClient +} + +func (suite *IntegrationTestSuite) SetupTest() { + app := simapp.Setup(suite.T(), false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) + app.FeehubKeeper.SetParams(ctx, types.DefaultParams()) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, app.FeehubKeeper) + queryClient := types.NewQueryClient(queryHelper) + + suite.app = app + suite.ctx = ctx + suite.queryClient = queryClient +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/feehub/keeper/params.go b/x/feehub/keeper/params.go index 3f2c8f4577..32e1a15794 100644 --- a/x/feehub/keeper/params.go +++ b/x/feehub/keeper/params.go @@ -6,12 +6,12 @@ import ( ) // SetParams sets the auth module's parameters. -func (fhk FeehubKeeper) SetParams(ctx sdk.Context, params types.Params) { +func (fhk Keeper) SetParams(ctx sdk.Context, params types.Params) { fhk.paramSubspace.SetParamSet(ctx, ¶ms) } // GetParams gets the auth module's parameters. -func (fhk FeehubKeeper) GetParams(ctx sdk.Context) (params types.Params) { +func (fhk Keeper) GetParams(ctx sdk.Context) (params types.Params) { fhk.paramSubspace.GetParamSet(ctx, ¶ms) return } diff --git a/x/feehub/keeper/querier.go b/x/feehub/keeper/querier.go index 68cefc015a..5b0106d853 100644 --- a/x/feehub/keeper/querier.go +++ b/x/feehub/keeper/querier.go @@ -10,7 +10,7 @@ import ( ) // NewQuerier creates a querier for auth REST endpoints -func NewQuerier(k FeehubKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { +func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { switch path[0] { case types.QueryParams: @@ -22,7 +22,7 @@ func NewQuerier(k FeehubKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier } } -func queryParams(ctx sdk.Context, k FeehubKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { +func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { params := k.GetParams(ctx) res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) diff --git a/x/feehub/module.go b/x/feehub/module.go index 217bf1203e..9406c6677f 100644 --- a/x/feehub/module.go +++ b/x/feehub/module.go @@ -81,11 +81,11 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) type AppModule struct { AppModuleBasic - feehubKeeper keeper.FeehubKeeper + feehubKeeper keeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, feehubKeeper keeper.FeehubKeeper) AppModule { +func NewAppModule(cdc codec.Codec, feehubKeeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, feehubKeeper: feehubKeeper, diff --git a/x/feehub/simulation/genesis.go b/x/feehub/simulation/genesis.go index 33e4997bd7..99bb0e3a08 100644 --- a/x/feehub/simulation/genesis.go +++ b/x/feehub/simulation/genesis.go @@ -12,9 +12,10 @@ import ( // Simulation parameter constants const ( - MaxTxSize = "max_tx_size" - MinGasPerByte = "min_gas_per_byte" - MsgSendGas = "msg_send_gas" + MaxTxSize = "max_tx_size" + MinGasPerByte = "min_gas_per_byte" + MsgSendGas = "msg_send_gas" + MsgMultiSendGas = "msg_multi_send_gas" ) // GenMaxTxSize randomized MaxTxSize @@ -32,6 +33,11 @@ func GenMsgSendGas(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 1e6, 1e7)) } +// GenMsgMultiSendGas randomized MsgMultiSendGas +func GenMsgMultiSendGas(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 1e6, 1e7)) +} + // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState) { var maxTxSize uint64 @@ -52,7 +58,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { msgSendGas = GenMsgSendGas(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, msgSendGas) + var msgMultiSendGas uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, MsgMultiSendGas, &msgMultiSendGas, simState.Rand, + func(r *rand.Rand) { msgMultiSendGas = GenMsgMultiSendGas(r) }, + ) + + params := types.NewParams(maxTxSize, minGasPerByte, msgSendGas, msgMultiSendGas) feehubGenesis := types.NewGenesisState(params) diff --git a/x/feehub/simulation/genesis_test.go b/x/feehub/simulation/genesis_test.go new file mode 100644 index 0000000000..8b2add1de4 --- /dev/null +++ b/x/feehub/simulation/genesis_test.go @@ -0,0 +1,46 @@ +package simulation_test + +import ( + "encoding/json" + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/simulation" + "github.com/cosmos/cosmos-sdk/x/feehub/types" +) + +// TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. +// Abonormal scenarios are not tested here. +func TestRandomizedGenState(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + s := rand.NewSource(1) + r := rand.New(s) + + simState := module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: cdc, + Rand: r, + NumBonded: 3, + Accounts: simtypes.RandomAccounts(r, 3), + InitialStake: sdkmath.NewInt(1000), + GenState: make(map[string]json.RawMessage), + } + + simulation.RandomizedGenState(&simState) + + var feehubGenesis types.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &feehubGenesis) + + require.Equal(t, uint64(2540), feehubGenesis.Params.MaxTxSize) + require.Equal(t, uint64(2956), feehubGenesis.Params.MinGasPerByte) + require.Equal(t, uint64(8203300), feehubGenesis.Params.MsgSendGas) + require.Equal(t, uint64(9410694), feehubGenesis.Params.MsgMultiSendGas) +} diff --git a/x/feehub/simulation/params.go b/x/feehub/simulation/params.go index e17b537cf7..fcaf9ae707 100644 --- a/x/feehub/simulation/params.go +++ b/x/feehub/simulation/params.go @@ -21,7 +21,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, keyMsgSendGas, func(r *rand.Rand) string { - return fmt.Sprintf("\"%d\"", GenMsgSendGas(r)) + return fmt.Sprintf("%d", GenMsgSendGas(r)) }, ), } diff --git a/x/feehub/simulation/params_test.go b/x/feehub/simulation/params_test.go new file mode 100644 index 0000000000..e6d19562c4 --- /dev/null +++ b/x/feehub/simulation/params_test.go @@ -0,0 +1,35 @@ +package simulation_test + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/x/feehub/simulation" +) + +func TestParamChanges(t *testing.T) { + s := rand.NewSource(1) + r := rand.New(s) + + expected := []struct { + composedKey string + key string + simValue string + subspace string + }{ + {"feehub/MsgSendGas", "MsgSendGas", "3498081", "feehub"}, + } + + paramChanges := simulation.ParamChanges(r) + + require.Len(t, paramChanges, 1) + + for i, p := range paramChanges { + require.Equal(t, expected[i].composedKey, p.ComposedKey()) + require.Equal(t, expected[i].key, p.Key()) + require.Equal(t, expected[i].simValue, p.SimValue()(r)) + require.Equal(t, expected[i].subspace, p.Subspace()) + } +} diff --git a/x/feehub/types/fee_calculator.go b/x/feehub/types/fee_calculator.go index c7ce5e781d..3ffb152631 100644 --- a/x/feehub/types/fee_calculator.go +++ b/x/feehub/types/fee_calculator.go @@ -1,6 +1,9 @@ package types -import "github.com/cosmos/cosmos-sdk/types" +import ( + "github.com/cosmos/cosmos-sdk/types" + bank "github.com/cosmos/cosmos-sdk/x/bank/types" +) type ( FeeCalculator func(msg types.Msg) uint64 @@ -26,6 +29,19 @@ func FixedFeeCalculator(amount uint64) FeeCalculator { } } +func MultiSendCalculator(amount uint64) FeeCalculator { + return func(msg types.Msg) uint64 { + msgMultiSend := msg.(*bank.MsgMultiSend) + var num int + if len(msgMultiSend.Inputs) > len(msgMultiSend.Outputs) { + num = len(msgMultiSend.Inputs) + } else { + num = len(msgMultiSend.Outputs) + } + return uint64(num) * amount + } +} + var msgSendFeeCalculatorGen = func(params Params) FeeCalculator { msgSendGas := params.GetMsgSendGas() if msgSendGas == 0 { @@ -34,6 +50,15 @@ var msgSendFeeCalculatorGen = func(params Params) FeeCalculator { return FixedFeeCalculator(msgSendGas) } +var msgMultiSendFeeCalculatorGen = func(params Params) FeeCalculator { + msgMultiSendGas := params.GetMsgMultiSendGas() + if msgMultiSendGas == 0 { + return MultiSendCalculator(DefaultMsgSendGas) + } + return MultiSendCalculator(msgMultiSendGas) +} + func init() { - CalculatorsGen["send"] = msgSendFeeCalculatorGen + CalculatorsGen[types.MsgTypeURL(&bank.MsgSend{})] = msgSendFeeCalculatorGen + CalculatorsGen[types.MsgTypeURL(&bank.MsgMultiSend{})] = msgMultiSendFeeCalculatorGen } diff --git a/x/feehub/types/feehub.pb.go b/x/feehub/types/feehub.pb.go index 36a403986d..59da0cf0d6 100644 --- a/x/feehub/types/feehub.pb.go +++ b/x/feehub/types/feehub.pb.go @@ -25,9 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the feehub module. type Params struct { - MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` - MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MsgSendGas uint64 `protobuf:"varint,3,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + MsgSendGas uint64 `protobuf:"varint,3,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` + MsgMultiSendGas uint64 `protobuf:"varint,4,opt,name=msg_multi_send_gas,json=msgMultiSendGas,proto3" json:"msg_multi_send_gas,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -83,6 +84,13 @@ func (m *Params) GetMsgSendGas() uint64 { return 0 } +func (m *Params) GetMsgMultiSendGas() uint64 { + if m != nil { + return m.MsgMultiSendGas + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "cosmos.feehub.v1alpha1.Params") } @@ -92,25 +100,27 @@ func init() { } var fileDescriptor_e93836928b503a00 = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4e, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, - 0x48, 0x34, 0x84, 0xf2, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xc4, 0x20, 0x8a, 0xf4, 0xa0, - 0x82, 0x30, 0x45, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x25, 0xfa, 0x20, 0x16, 0x44, 0xb5, - 0xd2, 0x7a, 0x46, 0x2e, 0xb6, 0x80, 0xc4, 0xa2, 0xc4, 0xdc, 0x62, 0x21, 0x5d, 0x2e, 0xee, 0xdc, - 0xc4, 0x8a, 0xf8, 0x92, 0x8a, 0xf8, 0xe2, 0xcc, 0xaa, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, - 0x27, 0xde, 0x47, 0xf7, 0xe4, 0x39, 0x7d, 0x13, 0x2b, 0x42, 0x2a, 0x82, 0x33, 0xab, 0x52, 0x83, - 0x38, 0x73, 0x61, 0x4c, 0x21, 0x2b, 0x2e, 0x81, 0xdc, 0xcc, 0xbc, 0xf8, 0xf4, 0xc4, 0xe2, 0xf8, - 0x82, 0xd4, 0xa2, 0xf8, 0xa4, 0xca, 0x92, 0x54, 0x09, 0x26, 0xb0, 0x1e, 0xc1, 0x47, 0xf7, 0xe4, - 0x79, 0x7d, 0x33, 0xf3, 0xdc, 0x13, 0x8b, 0x03, 0x52, 0x8b, 0x9c, 0x2a, 0x4b, 0x52, 0x83, 0x78, - 0x73, 0x91, 0xb9, 0x42, 0x06, 0x5c, 0x3c, 0xb9, 0xc5, 0xe9, 0xf1, 0xc5, 0xa9, 0x79, 0x29, 0x20, - 0x03, 0x24, 0x98, 0xc1, 0xfa, 0xf8, 0x1e, 0xdd, 0x93, 0xe7, 0xf2, 0x2d, 0x4e, 0x0f, 0x4e, 0xcd, - 0x4b, 0x71, 0x4f, 0x2c, 0x0e, 0xe2, 0xca, 0x85, 0xb3, 0xad, 0x38, 0x66, 0x2c, 0x90, 0x67, 0x78, - 0xb1, 0x40, 0x9e, 0xd1, 0xc9, 0xf5, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, - 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, - 0xb4, 0xd3, 0x33, 0x4b, 0x40, 0x5e, 0x4e, 0xce, 0xcf, 0xd5, 0x87, 0x86, 0x14, 0x84, 0xd2, 0x2d, - 0x4e, 0xc9, 0xd6, 0xaf, 0x80, 0x05, 0x5b, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xff, - 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x05, 0xf6, 0x6a, 0x54, 0x01, 0x00, 0x00, + // 318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x3f, 0x4f, 0xc2, 0x40, + 0x18, 0xc6, 0x7b, 0x4a, 0x88, 0x9c, 0x22, 0x5a, 0x8d, 0x21, 0x0e, 0xad, 0xd1, 0xc5, 0xc4, 0x40, + 0x25, 0x6e, 0x4c, 0x86, 0xc4, 0x30, 0x35, 0x21, 0xe0, 0xe4, 0x72, 0x39, 0xe0, 0x3c, 0x2e, 0x72, + 0xbd, 0xa6, 0xef, 0x61, 0x0a, 0x9f, 0xc2, 0xd1, 0x91, 0x8f, 0xe3, 0xc8, 0xe8, 0xd4, 0x98, 0x63, + 0x71, 0xf5, 0x1b, 0x98, 0x96, 0xd6, 0x3f, 0xd3, 0x3d, 0xef, 0x7b, 0xcf, 0xef, 0x1d, 0x7e, 0xf8, + 0x62, 0xa4, 0x40, 0x2a, 0xf0, 0x1e, 0x19, 0x9b, 0xcc, 0x86, 0xde, 0x73, 0x8b, 0x4e, 0xc3, 0x09, + 0x6d, 0xe5, 0x73, 0x33, 0x8c, 0x94, 0x56, 0xf6, 0xc9, 0xa6, 0xd4, 0xcc, 0x97, 0x45, 0xe9, 0xf4, + 0x98, 0x2b, 0xae, 0xb2, 0x8a, 0x97, 0xa6, 0x4d, 0xfb, 0xfc, 0x0b, 0xe1, 0x72, 0x8f, 0x46, 0x54, + 0x82, 0xdd, 0xc0, 0xbb, 0x92, 0xc6, 0x44, 0xc7, 0x04, 0xc4, 0x82, 0xd5, 0xd1, 0x19, 0xba, 0x2c, + 0x75, 0xaa, 0x26, 0x71, 0x2b, 0x3e, 0x8d, 0xef, 0xe3, 0x81, 0x58, 0xb0, 0x7e, 0x45, 0x16, 0xd1, + 0x6e, 0xe3, 0x03, 0x29, 0x02, 0xc2, 0x29, 0x90, 0x90, 0x45, 0x64, 0x38, 0xd7, 0xac, 0xbe, 0x95, + 0x31, 0x87, 0x26, 0x71, 0xab, 0xbe, 0x08, 0xba, 0x14, 0x7a, 0x2c, 0xea, 0xcc, 0x35, 0xeb, 0x57, + 0xe5, 0xdf, 0xd1, 0xbe, 0xc6, 0x7b, 0x12, 0x38, 0x01, 0x16, 0x8c, 0xd3, 0x03, 0xf5, 0xed, 0x8c, + 0xdb, 0x37, 0x89, 0x8b, 0x7d, 0xe0, 0x03, 0x16, 0x8c, 0xbb, 0x14, 0xfa, 0x58, 0xfe, 0x64, 0xfb, + 0x16, 0xdb, 0x29, 0x21, 0x67, 0x53, 0x2d, 0x7e, 0xb9, 0x52, 0xc6, 0x1d, 0x99, 0xc4, 0xad, 0xf9, + 0xc0, 0xfd, 0xf4, 0xb3, 0x80, 0x6b, 0xf2, 0xff, 0xa2, 0xbd, 0xf3, 0xba, 0x74, 0xad, 0xcf, 0xa5, + 0x8b, 0x3a, 0x77, 0x6f, 0xc6, 0x41, 0x2b, 0xe3, 0xa0, 0x0f, 0xe3, 0xa0, 0x97, 0xb5, 0x63, 0xad, + 0xd6, 0x8e, 0xf5, 0xbe, 0x76, 0xac, 0x87, 0x2b, 0x2e, 0x74, 0x2a, 0x6d, 0xa4, 0xa4, 0x97, 0xbb, + 0xde, 0x3c, 0x0d, 0x18, 0x3f, 0x79, 0x71, 0x21, 0x5e, 0xcf, 0x43, 0x06, 0xc3, 0x72, 0x66, 0xf0, + 0xe6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xea, 0xac, 0x64, 0x72, 0x96, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -141,6 +151,9 @@ func (this *Params) Equal(that interface{}) bool { if this.MsgSendGas != that1.MsgSendGas { return false } + if this.MsgMultiSendGas != that1.MsgMultiSendGas { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -163,6 +176,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MsgMultiSendGas != 0 { + i = encodeVarintFeehub(dAtA, i, uint64(m.MsgMultiSendGas)) + i-- + dAtA[i] = 0x20 + } if m.MsgSendGas != 0 { i = encodeVarintFeehub(dAtA, i, uint64(m.MsgSendGas)) i-- @@ -207,6 +225,9 @@ func (m *Params) Size() (n int) { if m.MsgSendGas != 0 { n += 1 + sovFeehub(uint64(m.MsgSendGas)) } + if m.MsgMultiSendGas != 0 { + n += 1 + sovFeehub(uint64(m.MsgMultiSendGas)) + } return n } @@ -302,6 +323,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendGas", wireType) + } + m.MsgMultiSendGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFeehub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgMultiSendGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipFeehub(dAtA[iNdEx:]) diff --git a/x/feehub/types/genesis_test.go b/x/feehub/types/genesis_test.go new file mode 100644 index 0000000000..e3924555d4 --- /dev/null +++ b/x/feehub/types/genesis_test.go @@ -0,0 +1,46 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGenesisStateValidate(t *testing.T) { + testCases := []struct { + name string + genesisState GenesisState + expErr bool + }{ + { + "valid genesisState", + GenesisState{ + Params: DefaultParams(), + }, + false, + }, + {"empty genesisState", GenesisState{}, true}, + { + "invalid params ", + GenesisState{ + Params: Params{ + MaxTxSize: 0, + }, + }, + true, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := ValidateGenesis(tc.genesisState) + + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/feehub/types/params.go b/x/feehub/types/params.go index 24389f4f1d..4aaf5485e4 100644 --- a/x/feehub/types/params.go +++ b/x/feehub/types/params.go @@ -10,28 +10,31 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 - DefaultMsgSendGas uint64 = 1e6 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 + DefaultMsgSendGas uint64 = 1e6 + DefaultMsgMultiSendGas uint64 = 8e5 ) // Parameter keys var ( - KeyMaxTxSize = []byte("MaxTxSize") - KeyMinGasPerByte = []byte("MinGasPerByte") - KeyMsgSendGas = []byte("MsgSendGas") + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMsgSendGas = []byte("MsgSendGas") + KeyMsgMultiSendGas = []byte("MsgMultiSendGas") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte, msgSendGas uint64, + maxTxSize, minGasPerByte, msgSendGas, msgMultiSendGas uint64, ) Params { return Params{ - MsgSendGas: msgSendGas, - MaxTxSize: maxTxSize, - MinGasPerByte: minGasPerByte, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + MsgSendGas: msgSendGas, + MsgMultiSendGas: msgMultiSendGas, } } @@ -44,18 +47,20 @@ func ParamKeyTable() paramtypes.KeyTable { // pairs of feehub's parameters. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgSendGas), paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), + paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgSendGas), + paramtypes.NewParamSetPair(KeyMsgMultiSendGas, &p.MsgMultiSendGas, validateMsgMultiSendGas), } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { return Params{ - MsgSendGas: DefaultMsgSendGas, - MaxTxSize: DefaultMaxTxSize, - MinGasPerByte: DefaultMinGasPerByte, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + MsgSendGas: DefaultMsgSendGas, + MsgMultiSendGas: DefaultMsgMultiSendGas, } } @@ -104,6 +109,19 @@ func validateMsgSendGas(i interface{}) error { return nil } +func validateMsgMultiSendGas(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid msg multi send fee: %d", v) + } + + return nil +} + // Validate checks that the parameters have valid values. func (p Params) Validate() error { if err := validateMaxTxSize(p.MaxTxSize); err != nil { @@ -115,6 +133,9 @@ func (p Params) Validate() error { if err := validateMsgSendGas(p.MsgSendGas); err != nil { return err } + if err := validateMsgMultiSendGas(p.MsgMultiSendGas); err != nil { + return err + } return nil } From 62550875f107ab44edf4e1a95d95c6c021a4e2ca Mon Sep 17 00:00:00 2001 From: Roshan Date: Wed, 28 Dec 2022 12:26:20 +0800 Subject: [PATCH 03/11] fix review comments --- baseapp/block_gas_test.go | 2 +- go.mod | 2 +- proto/cosmos/feehub/v1alpha1/genesis.proto | 13 -- .../v1alpha1/gashub.proto} | 6 +- proto/cosmos/gashub/v1alpha1/genesis.proto | 13 ++ .../{feehub => gashub}/v1alpha1/query.proto | 8 +- simapp/app.go | 24 ++-- simapp/app_test.go | 2 + store/gaskv/store.go | 50 ++++---- store/gaskv/store_test.go | 42 +++---- types/context.go | 12 +- x/auth/ante/ante_test.go | 48 ++++---- x/auth/ante/basic.go | 2 +- x/auth/ante/expected_keepers.go | 6 +- x/auth/ante/msg_gas.go | 96 ++++++++++----- x/auth/ante/msg_gas_test.go | 6 +- x/auth/ante/setup.go | 2 +- x/authz/keeper/keeper.go | 2 +- x/feegrant/filtered_fee.go | 4 +- x/feehub/types/fee_calculator.go | 64 ---------- x/feehub/types/querier.go | 6 - x/{feehub => gashub}/client/cli/query.go | 10 +- x/{feehub => gashub}/keeper/genesis.go | 2 +- x/{feehub => gashub}/keeper/grpc_query.go | 2 +- .../keeper/grpc_query_test.go | 4 +- x/{feehub => gashub}/keeper/keeper.go | 6 +- x/{feehub => gashub}/keeper/keeper_test.go | 6 +- x/{feehub => gashub}/keeper/params.go | 2 +- x/{feehub => gashub}/keeper/querier.go | 2 +- x/{feehub => gashub}/module.go | 62 +++++----- x/{feehub => gashub}/simulation/genesis.go | 10 +- .../simulation/genesis_test.go | 16 +-- x/{feehub => gashub}/simulation/params.go | 2 +- .../simulation/params_test.go | 4 +- x/{feehub => gashub}/types/codec.go | 0 x/gashub/types/gas_calculator.go | 61 ++++++++++ .../types/gashub.pb.go} | 114 +++++++++--------- x/{feehub => gashub}/types/genesis.go | 4 +- x/{feehub => gashub}/types/genesis.pb.go | 18 +-- x/{feehub => gashub}/types/genesis_test.go | 0 x/{feehub => gashub}/types/key.go | 2 +- x/{feehub => gashub}/types/params.go | 4 +- x/gashub/types/querier.go | 6 + x/{feehub => gashub}/types/query.pb.go | 26 ++-- x/{feehub => gashub}/types/query.pb.gw.go | 4 +- x/gov/keeper/msg_server.go | 21 ++-- x/group/keeper/msg_server.go | 2 +- x/staking/types/authz.go | 4 +- 48 files changed, 421 insertions(+), 383 deletions(-) delete mode 100644 proto/cosmos/feehub/v1alpha1/genesis.proto rename proto/cosmos/{feehub/v1alpha1/feehub.proto => gashub/v1alpha1/gashub.proto} (75%) create mode 100644 proto/cosmos/gashub/v1alpha1/genesis.proto rename proto/cosmos/{feehub => gashub}/v1alpha1/query.proto (73%) delete mode 100644 x/feehub/types/fee_calculator.go delete mode 100644 x/feehub/types/querier.go rename x/{feehub => gashub}/client/cli/query.go (81%) rename x/{feehub => gashub}/keeper/genesis.go (92%) rename x/{feehub => gashub}/keeper/grpc_query.go (92%) rename x/{feehub => gashub}/keeper/grpc_query_test.go (71%) rename x/{feehub => gashub}/keeper/keeper.go (90%) rename x/{feehub => gashub}/keeper/keeper_test.go (85%) rename x/{feehub => gashub}/keeper/params.go (89%) rename x/{feehub => gashub}/keeper/querier.go (95%) rename x/{feehub => gashub}/module.go (73%) rename x/{feehub => gashub}/simulation/genesis.go (89%) rename x/{feehub => gashub}/simulation/genesis_test.go (72%) rename x/{feehub => gashub}/simulation/params.go (92%) rename x/{feehub => gashub}/simulation/params_test.go (85%) rename x/{feehub => gashub}/types/codec.go (100%) create mode 100644 x/gashub/types/gas_calculator.go rename x/{feehub/types/feehub.pb.go => gashub/types/gashub.pb.go} (68%) rename x/{feehub => gashub}/types/genesis.go (86%) rename x/{feehub => gashub}/types/genesis.pb.go (93%) rename x/{feehub => gashub}/types/genesis_test.go (100%) rename x/{feehub => gashub}/types/key.go (92%) rename x/{feehub => gashub}/types/params.go (97%) create mode 100644 x/gashub/types/querier.go rename x/{feehub => gashub}/types/query.pb.go (94%) rename x/{feehub => gashub}/types/query.pb.gw.go (98%) diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go index 61d490700a..a3fbe8773a 100644 --- a/baseapp/block_gas_test.go +++ b/baseapp/block_gas_test.go @@ -123,7 +123,7 @@ func TestBaseApp_BlockGas(t *testing.T) { require.Equal(t, []byte("ok"), okValue) } // check block gas is always consumed - baseGas := uint64(74343) // baseGas is the gas consumed before tx msg + baseGas := uint64(3420) // baseGas is the gas consumed before tx msg expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas) if expGasConsumed > txtypes.MaxGasWanted { // capped by gasLimit diff --git a/go.mod b/go.mod index 0856222733..1af68f822f 100644 --- a/go.mod +++ b/go.mod @@ -57,6 +57,7 @@ require ( github.com/tendermint/go-amino v0.16.0 github.com/tendermint/tendermint v0.34.22 github.com/tendermint/tm-db v0.6.7 + github.com/wealdtech/go-eth2-util v1.6.3 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e golang.org/x/text v0.3.7 @@ -164,7 +165,6 @@ require ( github.com/urfave/cli/v2 v2.3.0 // indirect github.com/wealdtech/go-bytesutil v1.1.1 // indirect github.com/wealdtech/go-eth2-types/v2 v2.5.2 // indirect - github.com/wealdtech/go-eth2-util v1.6.3 // indirect github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect diff --git a/proto/cosmos/feehub/v1alpha1/genesis.proto b/proto/cosmos/feehub/v1alpha1/genesis.proto deleted file mode 100644 index bf41bfb937..0000000000 --- a/proto/cosmos/feehub/v1alpha1/genesis.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; -package cosmos.feehub.v1alpha1; - -import "gogoproto/gogo.proto"; -import "cosmos/feehub/v1alpha1/feehub.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; - -// GenesisState defines the feehub module's genesis state. -message GenesisState { - // params defines all the paramaters of the module. - Params params = 1 [(gogoproto.nullable) = false]; -} diff --git a/proto/cosmos/feehub/v1alpha1/feehub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto similarity index 75% rename from proto/cosmos/feehub/v1alpha1/feehub.proto rename to proto/cosmos/gashub/v1alpha1/gashub.proto index f57b2d687c..265ab47614 100644 --- a/proto/cosmos/feehub/v1alpha1/feehub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package cosmos.feehub.v1alpha1; +package cosmos.gashub.v1alpha1; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; -// Params defines the parameters for the feehub module. +// Params defines the parameters for the gashub module. message Params { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; diff --git a/proto/cosmos/gashub/v1alpha1/genesis.proto b/proto/cosmos/gashub/v1alpha1/genesis.proto new file mode 100644 index 0000000000..f895dd0d3c --- /dev/null +++ b/proto/cosmos/gashub/v1alpha1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cosmos.gashub.v1alpha1; + +import "gogoproto/gogo.proto"; +import "cosmos/gashub/v1alpha1/gashub.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; + +// GenesisState defines the gashub module's genesis state. +message GenesisState { + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/feehub/v1alpha1/query.proto b/proto/cosmos/gashub/v1alpha1/query.proto similarity index 73% rename from proto/cosmos/feehub/v1alpha1/query.proto rename to proto/cosmos/gashub/v1alpha1/query.proto index 2098c71148..f8415f97b7 100644 --- a/proto/cosmos/feehub/v1alpha1/query.proto +++ b/proto/cosmos/gashub/v1alpha1/query.proto @@ -1,17 +1,17 @@ syntax = "proto3"; -package cosmos.feehub.v1alpha1; +package cosmos.gashub.v1alpha1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/feehub/v1alpha1/feehub.proto"; +import "cosmos/gashub/v1alpha1/gashub.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/feehub/types"; +option go_package = "github.com/cosmos/cosmos-sdk/x/gashub/types"; // Query defines the gRPC querier service. service Query { // Params queries all parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/feehub/v1alpha1/params"; + option (google.api.http).get = "/cosmos/gashub/v1alpha1/params"; } } diff --git a/simapp/app.go b/simapp/app.go index d39a56e6c2..a4faa53f00 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -63,9 +63,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant" feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" - "github.com/cosmos/cosmos-sdk/x/feehub" - feehubkeeper "github.com/cosmos/cosmos-sdk/x/feehub/keeper" - feehubtypes "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub" + gashubkeeper "github.com/cosmos/cosmos-sdk/x/gashub/keeper" + gashubtypes "github.com/cosmos/cosmos-sdk/x/gashub/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" @@ -130,7 +130,7 @@ var ( groupmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, nftmodule.AppModuleBasic{}, - feehub.AppModuleBasic{}, + gashub.AppModuleBasic{}, ) // module account permissions @@ -183,7 +183,7 @@ type SimApp struct { FeeGrantKeeper feegrantkeeper.Keeper GroupKeeper groupkeeper.Keeper NFTKeeper nftkeeper.Keeper - FeehubKeeper feehubkeeper.Keeper + GashubKeeper gashubkeeper.Keeper // the module manager mm *module.Manager @@ -224,7 +224,7 @@ func NewSimApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, - authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, feehubtypes.StoreKey, + authzkeeper.StoreKey, nftkeeper.StoreKey, group.StoreKey, gashubtypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) // NOTE: The testingkey is just mounted for testing purposes. Actual applications should @@ -338,7 +338,7 @@ func NewSimApp( // If evidence needs to be handled for the app, set routes in router here and seal app.EvidenceKeeper = *evidenceKeeper - app.FeehubKeeper = feehubkeeper.NewFeehubKeeper(appCodec, keys[feehubtypes.StoreKey], app.GetSubspace(feehubtypes.ModuleName)) + app.GashubKeeper = gashubkeeper.NewGashubKeeper(appCodec, keys[gashubtypes.StoreKey], app.GetSubspace(gashubtypes.ModuleName)) /**** Module Options ****/ @@ -370,7 +370,7 @@ func NewSimApp( authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), nftmodule.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), - feehub.NewAppModule(appCodec, app.FeehubKeeper), + gashub.NewAppModule(appCodec, app.GashubKeeper), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -382,7 +382,7 @@ func NewSimApp( upgradetypes.ModuleName, capabilitytypes.ModuleName, minttypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, evidencetypes.ModuleName, stakingtypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, govtypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, - authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, + authz.ModuleName, feegrant.ModuleName, nft.ModuleName, group.ModuleName, gashubtypes.ModuleName, paramstypes.ModuleName, vestingtypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -390,7 +390,7 @@ func NewSimApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, slashingtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, + feegrant.ModuleName, nft.ModuleName, group.ModuleName, gashubtypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, ) @@ -404,7 +404,7 @@ func NewSimApp( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, authz.ModuleName, - feegrant.ModuleName, nft.ModuleName, group.ModuleName, feehubtypes.ModuleName, + feegrant.ModuleName, nft.ModuleName, group.ModuleName, gashubtypes.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, ) @@ -662,7 +662,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(slashingtypes.ModuleName) paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) - paramsKeeper.Subspace(feehubtypes.ModuleName) + paramsKeeper.Subspace(gashubtypes.ModuleName) return paramsKeeper } diff --git a/simapp/app_test.go b/simapp/app_test.go index 25d8263980..babd35a9d5 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -26,6 +26,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/evidence" feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module" + "github.com/cosmos/cosmos-sdk/x/gashub" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/gov" group "github.com/cosmos/cosmos-sdk/x/group/module" @@ -188,6 +189,7 @@ func TestRunMigrations(t *testing.T) { "crisis": crisis.AppModule{}.ConsensusVersion(), "genutil": genutil.AppModule{}.ConsensusVersion(), "capability": capability.AppModule{}.ConsensusVersion(), + "gashub": gashub.AppModule{}.ConsensusVersion(), }, ) if tc.expRunErr { diff --git a/store/gaskv/store.go b/store/gaskv/store.go index 845e59cf93..5deab4db56 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -33,12 +33,12 @@ func (gs *Store) GetStoreType() types.StoreType { // Implements KVStore. func (gs *Store) Get(key []byte) (value []byte) { - gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostFlat, types.GasReadCostFlatDesc) + // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostFlat, types.GasReadCostFlatDesc) value = gs.parent.Get(key) - // TODO overflow-safe math? - gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasReadPerByteDesc) - gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasReadPerByteDesc) + // // TODO overflow-safe math? + // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasReadPerByteDesc) + // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasReadPerByteDesc) return value } @@ -47,23 +47,23 @@ func (gs *Store) Get(key []byte) (value []byte) { func (gs *Store) Set(key []byte, value []byte) { types.AssertValidKey(key) types.AssertValidValue(value) - gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc) - // TODO overflow-safe math? - gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(key)), types.GasWritePerByteDesc) - gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(value)), types.GasWritePerByteDesc) + // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc) + // // TODO overflow-safe math? + // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(key)), types.GasWritePerByteDesc) + // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(value)), types.GasWritePerByteDesc) gs.parent.Set(key, value) } // Implements KVStore. func (gs *Store) Has(key []byte) bool { - gs.gasMeter.ConsumeGas(gs.gasConfig.HasCost, types.GasHasDesc) + // gs.gasMeter.ConsumeGas(gs.gasConfig.HasCost, types.GasHasDesc) return gs.parent.Has(key) } // Implements KVStore. func (gs *Store) Delete(key []byte) { - // charge gas to prevent certain attack vectors even though space is being freed - gs.gasMeter.ConsumeGas(gs.gasConfig.DeleteCost, types.GasDeleteDesc) + // // charge gas to prevent certain attack vectors even though space is being freed + // gs.gasMeter.ConsumeGas(gs.gasConfig.DeleteCost, types.GasDeleteDesc) gs.parent.Delete(key) } @@ -106,7 +106,7 @@ func (gs *Store) iterator(start, end []byte, ascending bool) types.Iterator { } gi := newGasIterator(gs.gasMeter, gs.gasConfig, parent) - gi.(*gasIterator).consumeSeekGas() + // gi.(*gasIterator).consumeSeekGas() return gi } @@ -139,7 +139,7 @@ func (gi *gasIterator) Valid() bool { // in the iterator. It incurs a flat gas cost for seeking and a variable gas // cost based on the current value's length if the iterator is valid. func (gi *gasIterator) Next() { - gi.consumeSeekGas() + // gi.consumeSeekGas() gi.parent.Next() } @@ -167,15 +167,15 @@ func (gi *gasIterator) Error() error { return gi.parent.Error() } -// consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost -// based on the current value's length. -func (gi *gasIterator) consumeSeekGas() { - if gi.Valid() { - key := gi.Key() - value := gi.Value() - - gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasValuePerByteDesc) - gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) - } - gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) -} +// // consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost +// // based on the current value's length. +// func (gi *gasIterator) consumeSeekGas() { +// if gi.Valid() { +// key := gi.Key() +// value := gi.Value() +// +// gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasValuePerByteDesc) +// gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) +// } +// gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) +// } diff --git a/store/gaskv/store_test.go b/store/gaskv/store_test.go index 2401a9805d..acdd1f63c0 100644 --- a/store/gaskv/store_test.go +++ b/store/gaskv/store_test.go @@ -35,7 +35,7 @@ func TestGasKVStoreBasic(t *testing.T) { require.Equal(t, valFmt(1), st.Get(keyFmt(1))) st.Delete(keyFmt(1)) require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") - require.Equal(t, meter.GasConsumed(), types.Gas(6858)) + // require.Equal(t, meter.GasConsumed(), types.Gas(6858)) } func TestGasKVStoreIterator(t *testing.T) { @@ -74,16 +74,16 @@ func TestGasKVStoreIterator(t *testing.T) { vb := iterator.Value() require.Equal(t, vb, valFmt(2)) iterator.Next() - require.Equal(t, types.Gas(14565), meter.GasConsumed()) + // require.Equal(t, types.Gas(14565), meter.GasConsumed()) kc := iterator.Key() require.Equal(t, kc, keyFmt(3)) vc := iterator.Value() require.Equal(t, vc, valFmt(0)) iterator.Next() - require.Equal(t, types.Gas(14667), meter.GasConsumed()) + // require.Equal(t, types.Gas(14667), meter.GasConsumed()) require.False(t, iterator.Valid()) require.Panics(t, iterator.Next) - require.Equal(t, types.Gas(14697), meter.GasConsumed()) + // require.Equal(t, types.Gas(14697), meter.GasConsumed()) require.NoError(t, iterator.Error()) reverseIterator := st.ReverseIterator(nil, nil) @@ -100,22 +100,22 @@ func TestGasKVStoreIterator(t *testing.T) { reverseIterator.Next() require.False(t, reverseIterator.Valid()) require.Panics(t, reverseIterator.Next) - require.Equal(t, types.Gas(15135), meter.GasConsumed()) + // require.Equal(t, types.Gas(15135), meter.GasConsumed()) } -func TestGasKVStoreOutOfGasSet(t *testing.T) { - mem := dbadapter.Store{DB: dbm.NewMemDB()} - meter := types.NewGasMeter(0) - st := gaskv.NewStore(mem, meter, types.KVGasConfig()) - require.Panics(t, func() { st.Set(keyFmt(1), valFmt(1)) }, "Expected out-of-gas") -} - -func TestGasKVStoreOutOfGasIterator(t *testing.T) { - mem := dbadapter.Store{DB: dbm.NewMemDB()} - meter := types.NewGasMeter(20000) - st := gaskv.NewStore(mem, meter, types.KVGasConfig()) - st.Set(keyFmt(1), valFmt(1)) - iterator := st.Iterator(nil, nil) - iterator.Next() - require.Panics(t, func() { iterator.Value() }, "Expected out-of-gas") -} +// func TestGasKVStoreOutOfGasSet(t *testing.T) { +// mem := dbadapter.Store{DB: dbm.NewMemDB()} +// meter := types.NewGasMeter(0) +// st := gaskv.NewStore(mem, meter, types.KVGasConfig()) +// require.Panics(t, func() { st.Set(keyFmt(1), valFmt(1)) }, "Expected out-of-gas") +// } +// +// func TestGasKVStoreOutOfGasIterator(t *testing.T) { +// mem := dbadapter.Store{DB: dbm.NewMemDB()} +// meter := types.NewGasMeter(20000) +// st := gaskv.NewStore(mem, meter, types.KVGasConfig()) +// st.Set(keyFmt(1), valFmt(1)) +// iterator := st.Iterator(nil, nil) +// iterator.Next() +// require.Panics(t, func() { iterator.Value() }, "Expected out-of-gas") +// } diff --git a/types/context.go b/types/context.go index 8a050a1b08..c05dec1e2b 100644 --- a/types/context.go +++ b/types/context.go @@ -38,7 +38,8 @@ type Context struct { minGasPrice DecCoins consParams *abci.ConsensusParams eventManager *EventManager - priority int64 // The tx priority, only relevant in CheckTx + priority int64 // The tx priority, only relevant in CheckTx + txSize uint64 // The tx bytes length } // Proposed rename, not done to avoid API breakage @@ -60,6 +61,7 @@ func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } func (c Context) Priority() int64 { return c.priority } +func (c Context) TxSize() uint64 { return c.txSize } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { @@ -228,12 +230,18 @@ func (c Context) WithEventManager(em *EventManager) Context { return c } -// WithEventManager returns a Context with an updated tx priority +// WithPriority returns a Context with an updated tx priority func (c Context) WithPriority(p int64) Context { c.priority = p return c } +// WithTxSize returns a Context with an updated tx bytes length +func (c Context) WithTxSize(s uint64) Context { + c.txSize = s + return c +} + // TODO: remove??? func (c Context) IsZero() bool { return c.ms == nil diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index f13f5cc024..2550aa8e10 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -535,27 +535,27 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { ) testCases := []TestCase{ - { - "tx does not have enough gas", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 0 - }, - false, - false, - sdkerrors.ErrOutOfGas, - }, - { - "tx with memo doesn't have enough gas", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 801 - suite.txBuilder.SetMemo("abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") - }, - false, - false, - sdkerrors.ErrOutOfGas, - }, + // { + // "tx does not have enough gas", + // func() { + // feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) + // gasLimit = 0 + // }, + // false, + // false, + // sdkerrors.ErrOutOfGas, + // }, + // { + // "tx with memo doesn't have enough gas", + // func() { + // feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) + // gasLimit = 801 + // suite.txBuilder.SetMemo("abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") + // }, + // false, + // false, + // sdkerrors.ErrOutOfGas, + // }, { "memo too large", func() { @@ -906,11 +906,11 @@ func generatePubKeysAndSignatures(n int, msg []byte, _ bool) (pubkeys []cryptoty // TODO: also generate ed25519 keys as below when ed25519 keys are // actually supported, https://github.com/cosmos/cosmos-sdk/issues/4789 // for now this fails: - //if rand.Int63()%2 == 0 { + // if rand.Int63()%2 == 0 { // privkey = ed25519.GenPrivKey() - //} else { + // } else { // privkey = secp256k1.GenPrivKey() - //} + // } pubkeys[i] = privkey.PubKey() signatures[i], _ = privkey.Sign(msg) diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index 52c219f79e..fa0e8c66bc 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -127,7 +127,7 @@ func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, sim } sigBz := legacy.Cdc.MustMarshal(simSig) - cost := sdk.Gas(len(sigBz) + 6) + cost := sdk.Gas(len(sigBz) + 14) // If the pubkey is a multi-signature pubkey, then we estimate for the maximum // number of signers. diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index fcdf71be6d..da32344a0c 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -3,7 +3,7 @@ package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" - feehubtypes "github.com/cosmos/cosmos-sdk/x/feehub/types" + gashubtypes "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -20,6 +20,6 @@ type FeegrantKeeper interface { UseGrantedFees(ctx sdk.Context, granter, grantee sdk.AccAddress, fee sdk.Coins, msgs []sdk.Msg) error } -type FeehubKeeper interface { - GetParams(ctx sdk.Context) (params feehubtypes.Params) +type GashubKeeper interface { + GetParams(ctx sdk.Context) (params gashubtypes.Params) } diff --git a/x/auth/ante/msg_gas.go b/x/auth/ante/msg_gas.go index 0d8fcaf88f..c22ffcae5e 100644 --- a/x/auth/ante/msg_gas.go +++ b/x/auth/ante/msg_gas.go @@ -11,41 +11,35 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) -// ConsumeMsgGasDecorator will take in parameters and consume gas depending on -// the size of tx and msg type before calling next AnteHandler. +// ValidateTxSizeDecorator will validate tx bytes length given the parameters passed in +// If tx is too large decorator returns with error, otherwise call next AnteHandler // // CONTRACT: If simulate=true, then signatures must either be completely filled // in or empty. -type ConsumeMsgGasDecorator struct { +type ValidateTxSizeDecorator struct { ak AccountKeeper - fhk FeehubKeeper + fhk GashubKeeper } -func NewConsumeMsgGasDecorator(ak AccountKeeper, fhk FeehubKeeper) ConsumeMsgGasDecorator { - return ConsumeMsgGasDecorator{ +func NewValidateTxSizeDecorator(ak AccountKeeper, fhk GashubKeeper) ValidateTxSizeDecorator { + return ValidateTxSizeDecorator{ ak: ak, fhk: fhk, } } -func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { +func (vtsd ValidateTxSizeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { return ctx, errors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") } - params := cmfg.fhk.GetParams(ctx) - txBytesLength := uint64(len(ctx.TxBytes())) - - msgGas, err := cmfg.getMsgGas(params, sigTx) - if err != nil { - return ctx, err - } - - // simulate gas cost for signatures in simulate mode + newCtx := ctx + txSize := newCtx.TxSize() + // simulate signatures in simulate mode if simulate { // in simulate mode, each element should be a nil signature sigs, err := sigTx.GetSignaturesV2() @@ -62,7 +56,7 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula var pubkey cryptotypes.PubKey - acc := cmfg.ak.GetAccount(ctx, signer) + acc := vtsd.ak.GetAccount(ctx, signer) // use placeholder simSecp256k1Pubkey if sig is nil if acc == nil || acc.GetPubKey() == nil { @@ -78,30 +72,70 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula } sigBz := legacy.Cdc.MustMarshal(simSig) - txBytesLength = txBytesLength + uint64(len(sigBz)) + 6 + txSize = txSize + uint64(len(sigBz)) + 14 } + + newCtx = ctx.WithTxSize(txSize) + } + + params := vtsd.fhk.GetParams(ctx) + if txSize > params.GetMaxTxSize() { + return ctx, errors.Wrapf(sdkerrors.ErrTxTooLarge, "tx length: %d, limit: %d", txSize, params.GetMaxTxSize()) + } + + return next(newCtx, tx, simulate) +} + +// ConsumeMsgGasDecorator will take in parameters and consume gas depending on +// the size of tx and msg type before calling next AnteHandler. +type ConsumeMsgGasDecorator struct { + ak AccountKeeper + fhk GashubKeeper +} + +func NewConsumeMsgGasDecorator(ak AccountKeeper, fhk GashubKeeper) ConsumeMsgGasDecorator { + return ConsumeMsgGasDecorator{ + ak: ak, + fhk: fhk, + } +} + +func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, errors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") } - if txBytesLength > params.GetMaxTxSize() { - return ctx, errors.Wrapf(sdkerrors.ErrTxTooLarge, "tx length: %d, limit: %d", txBytesLength, params.GetMaxTxSize()) + params := cmfg.fhk.GetParams(ctx) + gasByTxSize := cmfg.getTxSizeGas(params, ctx) + gasByMsgType, err := cmfg.getMsgGas(params, sigTx) + if err != nil { + return ctx, err } - txBytesGas := txBytesLength * params.GetMinGasPerByte() - if txBytesGas >= msgGas { - ctx.GasMeter().ConsumeGas(txBytesGas, "gas by tx byte length") + if gasByTxSize >= gasByMsgType { + ctx.GasMeter().ConsumeGas(gasByTxSize, "tx bytes length") } else { - ctx.GasMeter().ConsumeGas(msgGas, "msg gas") + ctx.GasMeter().ConsumeGas(gasByMsgType, "msg type") } return next(ctx, tx, simulate) } func (cmfg ConsumeMsgGasDecorator) getMsgGas(params types.Params, tx sdk.Tx) (uint64, error) { - msg := tx.GetMsgs()[0] - feeCalcGen := types.GetCalculatorGen(sdk.MsgTypeURL(msg)) - if feeCalcGen == nil { - return 0, fmt.Errorf("failed to find fee calculator") + msgs := tx.GetMsgs() + var totalGas uint64 + for _, msg := range msgs { + feeCalcGen := types.GetGasCalculatorGen(sdk.MsgTypeURL(msg)) + if feeCalcGen == nil { + return 0, fmt.Errorf("failed to find fee calculator") + } + feeCalc := feeCalcGen(params) + totalGas += feeCalc(msg) } - feeCalc := feeCalcGen(params) - return feeCalc(msg), nil + return totalGas, nil +} + +func (cmfg ConsumeMsgGasDecorator) getTxSizeGas(params types.Params, ctx sdk.Context) uint64 { + return params.GetMinGasPerByte() * ctx.TxSize() } diff --git a/x/auth/ante/msg_gas_test.go b/x/auth/ante/msg_gas_test.go index 906a3353d9..6cd15d8741 100644 --- a/x/auth/ante/msg_gas_test.go +++ b/x/auth/ante/msg_gas_test.go @@ -38,11 +38,9 @@ func (suite *AnteTestSuite) TestMsgGas() { feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - mgd := ante.NewConsumeMsgGasDecorator(suite.app.AccountKeeper, suite.app.FeehubKeeper) + mgd := ante.NewConsumeMsgGasDecorator(suite.app.AccountKeeper, suite.app.GashubKeeper) antehandler := sdk.ChainAnteDecorators(mgd) - fixedGasConsume := uint64(4303) // gas needed when GetParams - type testCase struct { name string msg sdk.Msg @@ -65,6 +63,6 @@ func (suite *AnteTestSuite) TestMsgGas() { gasConsumedBefore := suite.ctx.GasMeter().GasConsumed() _, err = antehandler(suite.ctx, tx, false) gasConsumedAfter := suite.ctx.GasMeter().GasConsumed() - suite.Require().Equal(tc.expectedGas+fixedGasConsume, gasConsumedAfter-gasConsumedBefore) + suite.Require().Equal(tc.expectedGas, gasConsumedAfter-gasConsumedBefore) } } diff --git a/x/auth/ante/setup.go b/x/auth/ante/setup.go index 4e9ffe862b..1a925283a7 100644 --- a/x/auth/ante/setup.go +++ b/x/auth/ante/setup.go @@ -37,7 +37,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate return newCtx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx") } - newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas()) + newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas()).WithTxSize(uint64(len(ctx.TxBytes()))) // Decorator will catch an OutOfGasPanic caused in the next antehandler // AnteHandlers must have their own defer/recover in order for the BaseApp diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 63f7714b0a..8d6c9c3f30 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -359,7 +359,7 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran queueItems := queueItem.MsgTypeUrls for index, typeURL := range queueItems { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") if typeURL == msgType { end := len(queueItem.MsgTypeUrls) - 1 diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 74255757fc..b523b4139a 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -88,7 +88,7 @@ func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk. func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx sdk.Context) map[string]bool { msgsMap := make(map[string]bool, len(a.AllowedMessages)) for _, msg := range a.AllowedMessages { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") msgsMap[msg] = true } @@ -99,7 +99,7 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx sdk.Context, msgs []sdk.Msg msgsMap := a.allowedMsgsToMap(ctx) for _, msg := range msgs { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") if !msgsMap[sdk.MsgTypeURL(msg)] { return false } diff --git a/x/feehub/types/fee_calculator.go b/x/feehub/types/fee_calculator.go deleted file mode 100644 index 3ffb152631..0000000000 --- a/x/feehub/types/fee_calculator.go +++ /dev/null @@ -1,64 +0,0 @@ -package types - -import ( - "github.com/cosmos/cosmos-sdk/types" - bank "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -type ( - FeeCalculator func(msg types.Msg) uint64 - FeeCalculatorGenerator func(params Params) FeeCalculator -) - -var ( - calculators = make(map[string]FeeCalculator) - CalculatorsGen = make(map[string]FeeCalculatorGenerator) -) - -func RegisterCalculator(msgType string, feeCalc FeeCalculator) { - calculators[msgType] = feeCalc -} - -func GetCalculatorGen(msgType string) FeeCalculatorGenerator { - return CalculatorsGen[msgType] -} - -func FixedFeeCalculator(amount uint64) FeeCalculator { - return func(msg types.Msg) uint64 { - return amount - } -} - -func MultiSendCalculator(amount uint64) FeeCalculator { - return func(msg types.Msg) uint64 { - msgMultiSend := msg.(*bank.MsgMultiSend) - var num int - if len(msgMultiSend.Inputs) > len(msgMultiSend.Outputs) { - num = len(msgMultiSend.Inputs) - } else { - num = len(msgMultiSend.Outputs) - } - return uint64(num) * amount - } -} - -var msgSendFeeCalculatorGen = func(params Params) FeeCalculator { - msgSendGas := params.GetMsgSendGas() - if msgSendGas == 0 { - return FixedFeeCalculator(DefaultMsgSendGas) - } - return FixedFeeCalculator(msgSendGas) -} - -var msgMultiSendFeeCalculatorGen = func(params Params) FeeCalculator { - msgMultiSendGas := params.GetMsgMultiSendGas() - if msgMultiSendGas == 0 { - return MultiSendCalculator(DefaultMsgSendGas) - } - return MultiSendCalculator(msgMultiSendGas) -} - -func init() { - CalculatorsGen[types.MsgTypeURL(&bank.MsgSend{})] = msgSendFeeCalculatorGen - CalculatorsGen[types.MsgTypeURL(&bank.MsgMultiSend{})] = msgMultiSendFeeCalculatorGen -} diff --git a/x/feehub/types/querier.go b/x/feehub/types/querier.go deleted file mode 100644 index 4c6daa032d..0000000000 --- a/x/feehub/types/querier.go +++ /dev/null @@ -1,6 +0,0 @@ -package types - -// query endpoints supported by the feehub Querier -const ( - QueryParams = "params" -) diff --git a/x/feehub/client/cli/query.go b/x/gashub/client/cli/query.go similarity index 81% rename from x/feehub/client/cli/query.go rename to x/gashub/client/cli/query.go index 8304024bc6..daa29dd7b6 100644 --- a/x/feehub/client/cli/query.go +++ b/x/gashub/client/cli/query.go @@ -7,14 +7,14 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // GetQueryCmd returns the transaction commands for this module func GetQueryCmd() *cobra.Command { cmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the feehub module", + Short: "Querying commands for the gashub module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -31,11 +31,11 @@ func GetQueryCmd() *cobra.Command { func QueryParamsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "params", - Short: "Query the current feehub parameters", + Short: "Query the current gashub parameters", Args: cobra.NoArgs, - Long: strings.TrimSpace(`Query the current feehub parameters: + Long: strings.TrimSpace(`Query the current gashub parameters: -$ query feehub params +$ query gashub params `), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) diff --git a/x/feehub/keeper/genesis.go b/x/gashub/keeper/genesis.go similarity index 92% rename from x/feehub/keeper/genesis.go rename to x/gashub/keeper/genesis.go index 9c8925d0a6..2ab7dc9146 100644 --- a/x/feehub/keeper/genesis.go +++ b/x/gashub/keeper/genesis.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // InitGenesis - Init store state from genesis data diff --git a/x/feehub/keeper/grpc_query.go b/x/gashub/keeper/grpc_query.go similarity index 92% rename from x/feehub/keeper/grpc_query.go rename to x/gashub/keeper/grpc_query.go index 501ff8e40f..e7957998e9 100644 --- a/x/feehub/keeper/grpc_query.go +++ b/x/gashub/keeper/grpc_query.go @@ -7,7 +7,7 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/feehub/keeper/grpc_query_test.go b/x/gashub/keeper/grpc_query_test.go similarity index 71% rename from x/feehub/keeper/grpc_query_test.go rename to x/gashub/keeper/grpc_query_test.go index 0cdab12b6d..b66e73ee50 100644 --- a/x/feehub/keeper/grpc_query_test.go +++ b/x/gashub/keeper/grpc_query_test.go @@ -2,12 +2,12 @@ package keeper_test import ( gocontext "context" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) func (suite *IntegrationTestSuite) TestQueryParams() { res, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(suite.app.FeehubKeeper.GetParams(suite.ctx), res.GetParams()) + suite.Require().Equal(suite.app.GashubKeeper.GetParams(suite.ctx), res.GetParams()) } diff --git a/x/feehub/keeper/keeper.go b/x/gashub/keeper/keeper.go similarity index 90% rename from x/feehub/keeper/keeper.go rename to x/gashub/keeper/keeper.go index 21bce66757..dd6feeb574 100644 --- a/x/feehub/keeper/keeper.go +++ b/x/gashub/keeper/keeper.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -18,8 +18,8 @@ type Keeper struct { paramSubspace paramtypes.Subspace } -// NewFeehubKeeper returns a new feehub keeper -func NewFeehubKeeper( +// NewGashubKeeper returns a new gashub keeper +func NewGashubKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, ) Keeper { // set KeyTable if it has not already been set diff --git a/x/feehub/keeper/keeper_test.go b/x/gashub/keeper/keeper_test.go similarity index 85% rename from x/feehub/keeper/keeper_test.go rename to x/gashub/keeper/keeper_test.go index 44333d79e1..46bebb7217 100644 --- a/x/feehub/keeper/keeper_test.go +++ b/x/gashub/keeper/keeper_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) type IntegrationTestSuite struct { @@ -27,10 +27,10 @@ func (suite *IntegrationTestSuite) SetupTest() { ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) - app.FeehubKeeper.SetParams(ctx, types.DefaultParams()) + app.GashubKeeper.SetParams(ctx, types.DefaultParams()) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, app.FeehubKeeper) + types.RegisterQueryServer(queryHelper, app.GashubKeeper) queryClient := types.NewQueryClient(queryHelper) suite.app = app diff --git a/x/feehub/keeper/params.go b/x/gashub/keeper/params.go similarity index 89% rename from x/feehub/keeper/params.go rename to x/gashub/keeper/params.go index 32e1a15794..9cd3bb10e8 100644 --- a/x/feehub/keeper/params.go +++ b/x/gashub/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // SetParams sets the auth module's parameters. diff --git a/x/feehub/keeper/querier.go b/x/gashub/keeper/querier.go similarity index 95% rename from x/feehub/keeper/querier.go rename to x/gashub/keeper/querier.go index 5b0106d853..fbe4e5d63f 100644 --- a/x/feehub/keeper/querier.go +++ b/x/gashub/keeper/querier.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // NewQuerier creates a querier for auth REST endpoints diff --git a/x/feehub/module.go b/x/gashub/module.go similarity index 73% rename from x/feehub/module.go rename to x/gashub/module.go index 9406c6677f..c2f08bf9e1 100644 --- a/x/feehub/module.go +++ b/x/gashub/module.go @@ -1,4 +1,4 @@ -package feehub +package gashub import ( "context" @@ -16,10 +16,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/client/cli" - "github.com/cosmos/cosmos-sdk/x/feehub/keeper" - "github.com/cosmos/cosmos-sdk/x/feehub/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/client/cli" + "github.com/cosmos/cosmos-sdk/x/gashub/keeper" + "github.com/cosmos/cosmos-sdk/x/gashub/simulation" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) var ( @@ -28,24 +28,24 @@ var ( _ module.AppModuleSimulation = AppModule{} ) -// AppModuleBasic defines the basic application module used by the feehub module. +// AppModuleBasic defines the basic application module used by the gashub module. type AppModuleBasic struct{} -// Name returns the feehub module's name. +// Name returns the gashub module's name. func (AppModuleBasic) Name() string { return types.ModuleName } -// RegisterLegacyAminoCodec registers the feehub module's types for the given codec. +// RegisterLegacyAminoCodec registers the gashub module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} -// DefaultGenesis returns default genesis state as raw bytes for the feehub +// DefaultGenesis returns default genesis state as raw bytes for the gashub // module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesisState()) } -// ValidateGenesis performs genesis state validation for the feehub module. +// ValidateGenesis performs genesis state validation for the gashub module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { var data types.GenesisState if err := cdc.UnmarshalJSON(bz, &data); err != nil { @@ -55,44 +55,44 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feehub module. +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gashub module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { panic(err) } } -// GetTxCmd returns the root tx command for the feehub module. +// GetTxCmd returns the root tx command for the gashub module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } -// GetQueryCmd returns the root query command for the feehub module. +// GetQueryCmd returns the root query command for the gashub module. func (AppModuleBasic) GetQueryCmd() *cobra.Command { return cli.GetQueryCmd() } -// RegisterInterfaces registers interfaces and implementations of the feehub module. +// RegisterInterfaces registers interfaces and implementations of the gashub module. func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { types.RegisterInterfaces(registry) } -// AppModule implements an application module for the feehub module. +// AppModule implements an application module for the gashub module. type AppModule struct { AppModuleBasic - feehubKeeper keeper.Keeper + gashubKeeper keeper.Keeper } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, feehubKeeper keeper.Keeper) AppModule { +func NewAppModule(cdc codec.Codec, gashubKeeper keeper.Keeper) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, - feehubKeeper: feehubKeeper, + gashubKeeper: gashubKeeper, } } -// Name returns the feehub module's name. +// Name returns the gashub module's name. func (AppModule) Name() string { return types.ModuleName } @@ -100,38 +100,38 @@ func (AppModule) Name() string { // RegisterInvariants performs a no-op. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the feehub module. +// Deprecated: Route returns the message routing key for the gashub module. func (AppModule) Route() sdk.Route { return sdk.Route{} } -// QuerierRoute returns the feehub module's querier route name. +// QuerierRoute returns the gashub module's querier route name. func (AppModule) QuerierRoute() string { return types.QuerierRoute } -// LegacyQuerierHandler returns the feehub module sdk.Querier. +// LegacyQuerierHandler returns the gashub module sdk.Querier. func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.feehubKeeper, legacyQuerierCdc) + return keeper.NewQuerier(am.gashubKeeper, legacyQuerierCdc) } // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) {} -// InitGenesis performs genesis initialization for the feehub module. It returns +// InitGenesis performs genesis initialization for the gashub module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - am.feehubKeeper.InitGenesis(ctx, genesisState) + am.gashubKeeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } -// ExportGenesis returns the exported genesis state as raw bytes for the feehub +// ExportGenesis returns the exported genesis state as raw bytes for the gashub // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := am.feehubKeeper.ExportGenesis(ctx) + gs := am.gashubKeeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } @@ -140,7 +140,7 @@ func (AppModule) ConsensusVersion() uint64 { return 3 } // AppModuleSimulation functions -// GenerateGenesisState creates a randomized GenState of the feehub module +// GenerateGenesisState creates a randomized GenState of the gashub module func (am AppModule) GenerateGenesisState(simState *module.SimulationState) { simulation.RandomizedGenState(simState) } @@ -150,15 +150,15 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We return nil } -// RandomizedParams creates randomized feehub param changes for the simulator. +// RandomizedParams creates randomized gashub param changes for the simulator. func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { return simulation.ParamChanges(r) } -// RegisterStoreDecoder registers a decoder for feehub module's types +// RegisterStoreDecoder registers a decoder for gashub module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {} -// WeightedOperations doesn't return any feehub module operation. +// WeightedOperations doesn't return any gashub module operation. func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } diff --git a/x/feehub/simulation/genesis.go b/x/gashub/simulation/genesis.go similarity index 89% rename from x/feehub/simulation/genesis.go rename to x/gashub/simulation/genesis.go index 99bb0e3a08..575df522bb 100644 --- a/x/feehub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // Simulation parameter constants @@ -66,12 +66,12 @@ func RandomizedGenState(simState *module.SimulationState) { params := types.NewParams(maxTxSize, minGasPerByte, msgSendGas, msgMultiSendGas) - feehubGenesis := types.NewGenesisState(params) + gashubGenesis := types.NewGenesisState(params) - bz, err := json.MarshalIndent(&feehubGenesis.Params, "", " ") + bz, err := json.MarshalIndent(&gashubGenesis.Params, "", " ") if err != nil { panic(err) } - fmt.Printf("Selected randomly generated feehub parameters:\n%s\n", bz) - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feehubGenesis) + fmt.Printf("Selected randomly generated gashub parameters:\n%s\n", bz) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(gashubGenesis) } diff --git a/x/feehub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go similarity index 72% rename from x/feehub/simulation/genesis_test.go rename to x/gashub/simulation/genesis_test.go index 8b2add1de4..5c141cc139 100644 --- a/x/feehub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -12,8 +12,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/simulation" + "github.com/cosmos/cosmos-sdk/x/gashub/types" ) // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. @@ -36,11 +36,11 @@ func TestRandomizedGenState(t *testing.T) { simulation.RandomizedGenState(&simState) - var feehubGenesis types.GenesisState - simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &feehubGenesis) + var gashubGenesis types.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &gashubGenesis) - require.Equal(t, uint64(2540), feehubGenesis.Params.MaxTxSize) - require.Equal(t, uint64(2956), feehubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(8203300), feehubGenesis.Params.MsgSendGas) - require.Equal(t, uint64(9410694), feehubGenesis.Params.MsgMultiSendGas) + require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) + require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) + require.Equal(t, uint64(8203300), gashubGenesis.Params.MsgSendGas) + require.Equal(t, uint64(9410694), gashubGenesis.Params.MsgMultiSendGas) } diff --git a/x/feehub/simulation/params.go b/x/gashub/simulation/params.go similarity index 92% rename from x/feehub/simulation/params.go rename to x/gashub/simulation/params.go index fcaf9ae707..1f2b15f5a2 100644 --- a/x/feehub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -7,7 +7,7 @@ import ( "math/rand" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/feehub/types" + "github.com/cosmos/cosmos-sdk/x/gashub/types" "github.com/cosmos/cosmos-sdk/x/simulation" ) diff --git a/x/feehub/simulation/params_test.go b/x/gashub/simulation/params_test.go similarity index 85% rename from x/feehub/simulation/params_test.go rename to x/gashub/simulation/params_test.go index e6d19562c4..ff4fe52097 100644 --- a/x/feehub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/x/feehub/simulation" + "github.com/cosmos/cosmos-sdk/x/gashub/simulation" ) func TestParamChanges(t *testing.T) { @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"feehub/MsgSendGas", "MsgSendGas", "3498081", "feehub"}, + {"gashub/MsgSendGas", "MsgSendGas", "3498081", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/feehub/types/codec.go b/x/gashub/types/codec.go similarity index 100% rename from x/feehub/types/codec.go rename to x/gashub/types/codec.go diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go new file mode 100644 index 0000000000..758abe8cbe --- /dev/null +++ b/x/gashub/types/gas_calculator.go @@ -0,0 +1,61 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/types" + bank "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +type ( + GasCalculator func(msg types.Msg) uint64 + GasCalculatorGenerator func(params Params) GasCalculator +) + +var calculatorsGen = make(map[string]GasCalculatorGenerator) + +func RegisterCalculatorGen(msgType string, feeCalcGen GasCalculatorGenerator) { + calculatorsGen[msgType] = feeCalcGen +} + +func GetGasCalculatorGen(msgType string) GasCalculatorGenerator { + return calculatorsGen[msgType] +} + +func FixedGasCalculator(amount uint64) GasCalculator { + return func(msg types.Msg) uint64 { + return amount + } +} + +func MultiSendCalculator(amount uint64) GasCalculator { + return func(msg types.Msg) uint64 { + msgMultiSend := msg.(*bank.MsgMultiSend) + var num int + if len(msgMultiSend.Inputs) > len(msgMultiSend.Outputs) { + num = len(msgMultiSend.Inputs) + } else { + num = len(msgMultiSend.Outputs) + } + return uint64(num) * amount + } +} + +var msgSendFeeCalculatorGen = func(params Params) GasCalculator { + msgSendGas := params.GetMsgSendGas() + if msgSendGas == 0 { + return FixedGasCalculator(DefaultMsgSendGas) + } + return FixedGasCalculator(msgSendGas) +} + +var msgMultiSendFeeCalculatorGen = func(params Params) GasCalculator { + msgMultiSendGas := params.GetMsgMultiSendGas() + if msgMultiSendGas == 0 { + return MultiSendCalculator(DefaultMsgSendGas) + } + return MultiSendCalculator(msgMultiSendGas) +} + +func init() { + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), msgSendFeeCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendFeeCalculatorGen) +} diff --git a/x/feehub/types/feehub.pb.go b/x/gashub/types/gashub.pb.go similarity index 68% rename from x/feehub/types/feehub.pb.go rename to x/gashub/types/gashub.pb.go index 59da0cf0d6..f425442377 100644 --- a/x/feehub/types/feehub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feehub/v1alpha1/feehub.proto +// source: cosmos/gashub/v1alpha1/gashub.proto package types @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Params defines the parameters for the feehub module. +// Params defines the parameters for the gashub module. type Params struct { MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` @@ -34,7 +34,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_e93836928b503a00, []int{0} + return fileDescriptor_f79bf23b48853a4a, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -92,35 +92,35 @@ func (m *Params) GetMsgMultiSendGas() uint64 { } func init() { - proto.RegisterType((*Params)(nil), "cosmos.feehub.v1alpha1.Params") + proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") } func init() { - proto.RegisterFile("cosmos/feehub/v1alpha1/feehub.proto", fileDescriptor_e93836928b503a00) + proto.RegisterFile("cosmos/gashub/v1alpha1/gashub.proto", fileDescriptor_f79bf23b48853a4a) } -var fileDescriptor_e93836928b503a00 = []byte{ - // 318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x3f, 0x4f, 0xc2, 0x40, - 0x18, 0xc6, 0x7b, 0x4a, 0x88, 0x9c, 0x22, 0x5a, 0x8d, 0x21, 0x0e, 0xad, 0xd1, 0xc5, 0xc4, 0x40, - 0x25, 0x6e, 0x4c, 0x86, 0xc4, 0x30, 0x35, 0x21, 0xe0, 0xe4, 0x72, 0x39, 0xe0, 0x3c, 0x2e, 0x72, - 0xbd, 0xa6, 0xef, 0x61, 0x0a, 0x9f, 0xc2, 0xd1, 0x91, 0x8f, 0xe3, 0xc8, 0xe8, 0xd4, 0x98, 0x63, - 0x71, 0xf5, 0x1b, 0x98, 0x96, 0xd6, 0x3f, 0xd3, 0x3d, 0xef, 0x7b, 0xcf, 0xef, 0x1d, 0x7e, 0xf8, - 0x62, 0xa4, 0x40, 0x2a, 0xf0, 0x1e, 0x19, 0x9b, 0xcc, 0x86, 0xde, 0x73, 0x8b, 0x4e, 0xc3, 0x09, - 0x6d, 0xe5, 0x73, 0x33, 0x8c, 0x94, 0x56, 0xf6, 0xc9, 0xa6, 0xd4, 0xcc, 0x97, 0x45, 0xe9, 0xf4, - 0x98, 0x2b, 0xae, 0xb2, 0x8a, 0x97, 0xa6, 0x4d, 0xfb, 0xfc, 0x0b, 0xe1, 0x72, 0x8f, 0x46, 0x54, - 0x82, 0xdd, 0xc0, 0xbb, 0x92, 0xc6, 0x44, 0xc7, 0x04, 0xc4, 0x82, 0xd5, 0xd1, 0x19, 0xba, 0x2c, - 0x75, 0xaa, 0x26, 0x71, 0x2b, 0x3e, 0x8d, 0xef, 0xe3, 0x81, 0x58, 0xb0, 0x7e, 0x45, 0x16, 0xd1, - 0x6e, 0xe3, 0x03, 0x29, 0x02, 0xc2, 0x29, 0x90, 0x90, 0x45, 0x64, 0x38, 0xd7, 0xac, 0xbe, 0x95, - 0x31, 0x87, 0x26, 0x71, 0xab, 0xbe, 0x08, 0xba, 0x14, 0x7a, 0x2c, 0xea, 0xcc, 0x35, 0xeb, 0x57, - 0xe5, 0xdf, 0xd1, 0xbe, 0xc6, 0x7b, 0x12, 0x38, 0x01, 0x16, 0x8c, 0xd3, 0x03, 0xf5, 0xed, 0x8c, - 0xdb, 0x37, 0x89, 0x8b, 0x7d, 0xe0, 0x03, 0x16, 0x8c, 0xbb, 0x14, 0xfa, 0x58, 0xfe, 0x64, 0xfb, - 0x16, 0xdb, 0x29, 0x21, 0x67, 0x53, 0x2d, 0x7e, 0xb9, 0x52, 0xc6, 0x1d, 0x99, 0xc4, 0xad, 0xf9, - 0xc0, 0xfd, 0xf4, 0xb3, 0x80, 0x6b, 0xf2, 0xff, 0xa2, 0xbd, 0xf3, 0xba, 0x74, 0xad, 0xcf, 0xa5, - 0x8b, 0x3a, 0x77, 0x6f, 0xc6, 0x41, 0x2b, 0xe3, 0xa0, 0x0f, 0xe3, 0xa0, 0x97, 0xb5, 0x63, 0xad, - 0xd6, 0x8e, 0xf5, 0xbe, 0x76, 0xac, 0x87, 0x2b, 0x2e, 0x74, 0x2a, 0x6d, 0xa4, 0xa4, 0x97, 0xbb, - 0xde, 0x3c, 0x0d, 0x18, 0x3f, 0x79, 0x71, 0x21, 0x5e, 0xcf, 0x43, 0x06, 0xc3, 0x72, 0x66, 0xf0, - 0xe6, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xea, 0xac, 0x64, 0x72, 0x96, 0x01, 0x00, 0x00, +var fileDescriptor_f79bf23b48853a4a = []byte{ + // 319 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x3f, 0x4f, 0x3a, 0x31, + 0x18, 0xc7, 0xaf, 0xbf, 0x1f, 0x21, 0x52, 0x45, 0xf4, 0x34, 0x86, 0x38, 0x5c, 0x8d, 0x2e, 0x26, + 0x06, 0x4e, 0xe2, 0xc6, 0x64, 0x48, 0x0c, 0xd3, 0x25, 0x04, 0x9c, 0x5c, 0x9a, 0x02, 0x4d, 0x69, + 0xa4, 0xd7, 0xcb, 0x3d, 0xc5, 0x1c, 0xbc, 0x0a, 0x47, 0x47, 0x5e, 0x8e, 0x23, 0xa3, 0xd3, 0xc5, + 0x94, 0xc5, 0xd5, 0x77, 0x60, 0xee, 0xe0, 0xfc, 0x33, 0xf5, 0xfb, 0x3c, 0xfd, 0x7e, 0x9e, 0xe1, + 0x83, 0x2f, 0x46, 0x1a, 0x94, 0x06, 0x5f, 0x30, 0x98, 0xcc, 0x86, 0xfe, 0x53, 0x8b, 0x4d, 0xa3, + 0x09, 0x6b, 0x6d, 0xe7, 0x66, 0x14, 0x6b, 0xa3, 0xdd, 0x93, 0x4d, 0xa9, 0xb9, 0x5d, 0x16, 0xa5, + 0xd3, 0x63, 0xa1, 0x85, 0xce, 0x2b, 0x7e, 0x96, 0x36, 0xed, 0xf3, 0x4f, 0x84, 0xcb, 0x3d, 0x16, + 0x33, 0x05, 0x6e, 0x03, 0xef, 0x2a, 0x96, 0x50, 0x93, 0x50, 0x90, 0x0b, 0x5e, 0x47, 0x67, 0xe8, + 0xb2, 0xd4, 0xa9, 0xda, 0x94, 0x54, 0x02, 0x96, 0xdc, 0x27, 0x03, 0xb9, 0xe0, 0xfd, 0x8a, 0x2a, + 0xa2, 0xdb, 0xc6, 0x07, 0x4a, 0x86, 0x54, 0x30, 0xa0, 0x11, 0x8f, 0xe9, 0x70, 0x6e, 0x78, 0xfd, + 0x5f, 0xce, 0x1c, 0xda, 0x94, 0x54, 0x03, 0x19, 0x76, 0x19, 0xf4, 0x78, 0xdc, 0x99, 0x1b, 0xde, + 0xaf, 0xaa, 0xdf, 0xa3, 0x7b, 0x8d, 0xf7, 0x14, 0x08, 0x0a, 0x3c, 0x1c, 0x67, 0x07, 0xea, 0xff, + 0x73, 0x6e, 0xdf, 0xa6, 0x04, 0x07, 0x20, 0x06, 0x3c, 0x1c, 0x77, 0x19, 0xf4, 0xb1, 0xfa, 0xce, + 0xee, 0x2d, 0x76, 0x33, 0x42, 0xcd, 0xa6, 0x46, 0xfe, 0x70, 0xa5, 0x9c, 0x3b, 0xb2, 0x29, 0xa9, + 0x05, 0x20, 0x82, 0xec, 0xb3, 0x80, 0x6b, 0xea, 0xef, 0xa2, 0xbd, 0xf3, 0xb2, 0x24, 0xce, 0xc7, + 0x92, 0xa0, 0xce, 0xdd, 0xab, 0xf5, 0xd0, 0xca, 0x7a, 0xe8, 0xdd, 0x7a, 0xe8, 0x79, 0xed, 0x39, + 0xab, 0xb5, 0xe7, 0xbc, 0xad, 0x3d, 0xe7, 0xe1, 0x4a, 0x48, 0x93, 0x49, 0x1b, 0x69, 0xe5, 0x6f, + 0x5d, 0x6f, 0x9e, 0x06, 0x8c, 0x1f, 0xfd, 0xa4, 0x10, 0x6f, 0xe6, 0x11, 0x87, 0x61, 0x39, 0x37, + 0x78, 0xf3, 0x15, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xa7, 0xca, 0x67, 0x96, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -177,30 +177,30 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.MsgMultiSendGas != 0 { - i = encodeVarintFeehub(dAtA, i, uint64(m.MsgMultiSendGas)) + i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendGas)) i-- dAtA[i] = 0x20 } if m.MsgSendGas != 0 { - i = encodeVarintFeehub(dAtA, i, uint64(m.MsgSendGas)) + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSendGas)) i-- dAtA[i] = 0x18 } if m.MinGasPerByte != 0 { - i = encodeVarintFeehub(dAtA, i, uint64(m.MinGasPerByte)) + i = encodeVarintGashub(dAtA, i, uint64(m.MinGasPerByte)) i-- dAtA[i] = 0x10 } if m.MaxTxSize != 0 { - i = encodeVarintFeehub(dAtA, i, uint64(m.MaxTxSize)) + i = encodeVarintGashub(dAtA, i, uint64(m.MaxTxSize)) i-- dAtA[i] = 0x8 } return len(dAtA) - i, nil } -func encodeVarintFeehub(dAtA []byte, offset int, v uint64) int { - offset -= sovFeehub(v) +func encodeVarintGashub(dAtA []byte, offset int, v uint64) int { + offset -= sovGashub(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -217,25 +217,25 @@ func (m *Params) Size() (n int) { var l int _ = l if m.MaxTxSize != 0 { - n += 1 + sovFeehub(uint64(m.MaxTxSize)) + n += 1 + sovGashub(uint64(m.MaxTxSize)) } if m.MinGasPerByte != 0 { - n += 1 + sovFeehub(uint64(m.MinGasPerByte)) + n += 1 + sovGashub(uint64(m.MinGasPerByte)) } if m.MsgSendGas != 0 { - n += 1 + sovFeehub(uint64(m.MsgSendGas)) + n += 1 + sovGashub(uint64(m.MsgSendGas)) } if m.MsgMultiSendGas != 0 { - n += 1 + sovFeehub(uint64(m.MsgMultiSendGas)) + n += 1 + sovGashub(uint64(m.MsgMultiSendGas)) } return n } -func sovFeehub(x uint64) (n int) { +func sovGashub(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozFeehub(x uint64) (n int) { - return sovFeehub(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozGashub(x uint64) (n int) { + return sovGashub(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -245,7 +245,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeehub + return ErrIntOverflowGashub } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -273,7 +273,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.MaxTxSize = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeehub + return ErrIntOverflowGashub } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -292,7 +292,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.MinGasPerByte = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeehub + return ErrIntOverflowGashub } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -311,7 +311,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.MsgSendGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeehub + return ErrIntOverflowGashub } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -330,7 +330,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { m.MsgMultiSendGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowFeehub + return ErrIntOverflowGashub } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -344,12 +344,12 @@ func (m *Params) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipFeehub(dAtA[iNdEx:]) + skippy, err := skipGashub(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthFeehub + return ErrInvalidLengthGashub } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -363,7 +363,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func skipFeehub(dAtA []byte) (n int, err error) { +func skipGashub(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -371,7 +371,7 @@ func skipFeehub(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeehub + return 0, ErrIntOverflowGashub } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -388,7 +388,7 @@ func skipFeehub(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeehub + return 0, ErrIntOverflowGashub } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -404,7 +404,7 @@ func skipFeehub(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowFeehub + return 0, ErrIntOverflowGashub } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -417,14 +417,14 @@ func skipFeehub(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthFeehub + return 0, ErrInvalidLengthGashub } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupFeehub + return 0, ErrUnexpectedEndOfGroupGashub } depth-- case 5: @@ -433,7 +433,7 @@ func skipFeehub(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthFeehub + return 0, ErrInvalidLengthGashub } if depth == 0 { return iNdEx, nil @@ -443,7 +443,7 @@ func skipFeehub(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthFeehub = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowFeehub = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupFeehub = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthGashub = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGashub = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGashub = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/feehub/types/genesis.go b/x/gashub/types/genesis.go similarity index 86% rename from x/feehub/types/genesis.go rename to x/gashub/types/genesis.go index 1f00a42562..572e314035 100644 --- a/x/feehub/types/genesis.go +++ b/x/gashub/types/genesis.go @@ -18,7 +18,7 @@ func DefaultGenesisState() *GenesisState { return NewGenesisState(DefaultParams()) } -// GetGenesisStateFromAppState returns x/feehub GenesisState given raw application +// GetGenesisStateFromAppState returns x/gashub GenesisState given raw application // genesis state. func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMessage) GenesisState { var genesisState GenesisState @@ -30,7 +30,7 @@ func GetGenesisStateFromAppState(cdc codec.Codec, appState map[string]json.RawMe return genesisState } -// ValidateGenesis performs basic validation of feehub genesis data returning an +// ValidateGenesis performs basic validation of gashub genesis data returning an // error for any failed validation criteria. func ValidateGenesis(data GenesisState) error { if err := data.Params.Validate(); err != nil { diff --git a/x/feehub/types/genesis.pb.go b/x/gashub/types/genesis.pb.go similarity index 93% rename from x/feehub/types/genesis.pb.go rename to x/gashub/types/genesis.pb.go index d3175e0324..f115f6d449 100644 --- a/x/feehub/types/genesis.pb.go +++ b/x/gashub/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feehub/v1alpha1/genesis.proto +// source: cosmos/gashub/v1alpha1/genesis.proto package types @@ -23,7 +23,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the feehub module's genesis state. +// GenesisState defines the gashub module's genesis state. type GenesisState struct { // params defines all the paramaters of the module. Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` @@ -33,7 +33,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_6cab4ebd934cfcb3, []int{0} + return fileDescriptor_650531435e9abeaa, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -70,20 +70,20 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "cosmos.feehub.v1alpha1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "cosmos.gashub.v1alpha1.GenesisState") } func init() { - proto.RegisterFile("cosmos/feehub/v1alpha1/genesis.proto", fileDescriptor_6cab4ebd934cfcb3) + proto.RegisterFile("cosmos/gashub/v1alpha1/genesis.proto", fileDescriptor_650531435e9abeaa) } -var fileDescriptor_6cab4ebd934cfcb3 = []byte{ +var fileDescriptor_650531435e9abeaa = []byte{ // 201 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x49, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0xa8, 0xd2, 0x83, 0xa8, 0xd2, 0x83, 0xa9, 0x92, 0x12, 0x49, 0xcf, 0x4f, 0xcf, - 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x98, 0x09, 0xd5, 0x0d, 0x56, 0xa4, + 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x94, 0x71, 0x99, 0x09, 0xd1, 0x0d, 0x56, 0xa4, 0xe4, 0xc3, 0xc5, 0xe3, 0x0e, 0xb1, 0x23, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x86, 0x8b, 0xad, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x4e, 0x0f, 0xbb, 0x9d, 0x7a, 0x01, 0x60, 0x55, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xf5, 0x38, 0xb9, @@ -91,7 +91,7 @@ var fileDescriptor_6cab4ebd934cfcb3 = []byte{ 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, 0x7a, 0x66, 0x09, 0x48, 0x7f, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0x5d, 0x10, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0xe6, 0xc8, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0xdb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x3d, 0xc8, 0xca, 0x9d, 0x16, 0x01, 0x00, 0x00, + 0xff, 0x6f, 0xdb, 0x25, 0x4b, 0x16, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/feehub/types/genesis_test.go b/x/gashub/types/genesis_test.go similarity index 100% rename from x/feehub/types/genesis_test.go rename to x/gashub/types/genesis_test.go diff --git a/x/feehub/types/key.go b/x/gashub/types/key.go similarity index 92% rename from x/feehub/types/key.go rename to x/gashub/types/key.go index 70b6dd1adc..a1d4bde210 100644 --- a/x/feehub/types/key.go +++ b/x/gashub/types/key.go @@ -2,7 +2,7 @@ package types const ( // module name - ModuleName = "feehub" + ModuleName = "gashub" // StoreKey defines the primary module store key StoreKey = ModuleName diff --git a/x/feehub/types/params.go b/x/gashub/types/params.go similarity index 97% rename from x/feehub/types/params.go rename to x/gashub/types/params.go index 4aaf5485e4..8274b1151a 100644 --- a/x/feehub/types/params.go +++ b/x/gashub/types/params.go @@ -38,13 +38,13 @@ func NewParams( } } -// ParamKeyTable for feehub module +// ParamKeyTable for gashub module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // ParamSetPairs implements the ParamSet interface and returns all the key/value -// pairs of feehub's parameters. +// pairs of gashub's parameters. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), diff --git a/x/gashub/types/querier.go b/x/gashub/types/querier.go new file mode 100644 index 0000000000..4dde5ac364 --- /dev/null +++ b/x/gashub/types/querier.go @@ -0,0 +1,6 @@ +package types + +// query endpoints supported by the gashub Querier +const ( + QueryParams = "params" +) diff --git a/x/feehub/types/query.pb.go b/x/gashub/types/query.pb.go similarity index 94% rename from x/feehub/types/query.pb.go rename to x/gashub/types/query.pb.go index 30f414966a..47cd53b5ab 100644 --- a/x/feehub/types/query.pb.go +++ b/x/gashub/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/feehub/v1alpha1/query.proto +// source: cosmos/gashub/v1alpha1/query.proto package types @@ -37,7 +37,7 @@ 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_17c1f0c172794f06, []int{0} + return fileDescriptor_f928c856cebbb195, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -76,7 +76,7 @@ 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_17c1f0c172794f06, []int{1} + return fileDescriptor_f928c856cebbb195, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -113,18 +113,18 @@ func (m *QueryParamsResponse) GetParams() Params { } func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.feehub.v1alpha1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.feehub.v1alpha1.QueryParamsResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.gashub.v1alpha1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.gashub.v1alpha1.QueryParamsResponse") } func init() { - proto.RegisterFile("cosmos/feehub/v1alpha1/query.proto", fileDescriptor_17c1f0c172794f06) + proto.RegisterFile("cosmos/gashub/v1alpha1/query.proto", fileDescriptor_f928c856cebbb195) } -var fileDescriptor_17c1f0c172794f06 = []byte{ +var fileDescriptor_f928c856cebbb195 = []byte{ // 283 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0x4f, 0x4b, 0x4d, 0xcd, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, + 0xcd, 0x2f, 0xd6, 0x4f, 0x4f, 0x2c, 0xce, 0x28, 0x4d, 0xd2, 0x2f, 0x33, 0x4c, 0xcc, 0x29, 0xc8, 0x48, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x83, 0xa8, 0xd1, 0x83, 0xa8, 0xd1, 0x83, 0xa9, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd1, 0x07, 0xb1, 0x20, 0xaa, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, @@ -140,7 +140,7 @@ var fileDescriptor_17c1f0c172794f06 = []byte{ 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x3b, 0x3d, 0xb3, 0x04, 0x64, 0x4d, 0x72, 0x7e, 0x2e, 0xcc, 0x0c, 0x08, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, 0x33, 0xb0, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x9c, 0xc6, 0x80, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xa6, 0x63, 0xf1, 0x3e, 0xe5, 0x01, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xff, 0x7d, 0xea, 0x23, 0xe5, 0x01, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -169,7 +169,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/cosmos.feehub.v1alpha1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/cosmos.gashub.v1alpha1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -204,7 +204,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.feehub.v1alpha1.Query/Params", + FullMethod: "/cosmos.gashub.v1alpha1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -213,7 +213,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.feehub.v1alpha1.Query", + ServiceName: "cosmos.gashub.v1alpha1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -222,7 +222,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/feehub/v1alpha1/query.proto", + Metadata: "cosmos/gashub/v1alpha1/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/feehub/types/query.pb.gw.go b/x/gashub/types/query.pb.gw.go similarity index 98% rename from x/feehub/types/query.pb.gw.go rename to x/gashub/types/query.pb.gw.go index 70b656c5cd..3d7971279f 100644 --- a/x/feehub/types/query.pb.gw.go +++ b/x/gashub/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/feehub/v1alpha1/query.proto +// source: cosmos/gashub/v1alpha1/query.proto /* Package types is a reverse proxy. @@ -145,7 +145,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "feehub", "v1alpha1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "gashub", "v1alpha1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 27c8f7105f..a76ba1f262 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -7,7 +7,6 @@ import ( "github.com/armon/go-metrics" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -41,16 +40,16 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos return nil, err } - bytes, err := proposal.Marshal() - if err != nil { - return nil, err - } - - // ref: https://github.com/cosmos/cosmos-sdk/issues/9683 - ctx.GasMeter().ConsumeGas( - 3*storetypes.KVGasConfig().WriteCostPerByte*uint64(len(bytes)), - "submit proposal", - ) + // bytes, err := proposal.Marshal() + // if err != nil { + // return nil, err + // } + // + // // ref: https://github.com/cosmos/cosmos-sdk/issues/9683 + // ctx.GasMeter().ConsumeGas( + // 3*storetypes.KVGasConfig().WriteCostPerByte*uint64(len(bytes)), + // "submit proposal", + // ) defer telemetry.IncrCounter(1, types.ModuleName, "proposal") diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index f9cb6f0145..da74b3227b 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -536,7 +536,7 @@ func (k Keeper) SubmitProposal(goCtx context.Context, req *group.MsgSubmitPropos if req.Exec == group.Exec_EXEC_TRY { // Consider proposers as Yes votes for i := range proposers { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "vote on proposal") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "vote on proposal") _, err = k.Vote(sdk.WrapSDKContext(ctx), &group.MsgVote{ ProposalId: id, Voter: proposers[i], diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 1f9016cdbb..d347ad624d 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -76,7 +76,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe isValidatorExists := false allowedList := a.GetAllowList().GetAddress() for _, validator := range allowedList { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { isValidatorExists = true break @@ -85,7 +85,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe denyList := a.GetDenyList().GetAddress() for _, validator := range denyList { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") + // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validator) } From 46927911ef8f28884ce2166187a0bddf06d95002 Mon Sep 17 00:00:00 2001 From: Roshan Date: Wed, 28 Dec 2022 12:31:08 +0800 Subject: [PATCH 04/11] fix lint issues --- x/authz/keeper/keeper.go | 8 ++++---- x/feegrant/filtered_fee.go | 10 +++++----- x/group/keeper/msg_server.go | 6 +++--- x/staking/types/authz.go | 6 +++--- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 8d6c9c3f30..c44555f4dc 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -19,10 +19,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, -// https://github.com/cosmos/cosmos-sdk/discussions/9072 -const gasCostPerIteration = uint64(20) +// // TODO: Revisit this once we have propoer gas fee framework. +// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, +// // https://github.com/cosmos/cosmos-sdk/discussions/9072 +// const gasCostPerIteration = uint64(20) type Keeper struct { storeKey storetypes.StoreKey diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index b523b4139a..2658f1064f 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -10,11 +10,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -const ( - gasCostPerIteration = uint64(10) -) +// // TODO: Revisit this once we have propoer gas fee framework. +// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +// const ( +// gasCostPerIteration = uint64(10) +// ) var ( _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index da74b3227b..55f052edcc 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -17,9 +17,9 @@ import ( var _ group.MsgServer = Keeper{} -// TODO: Revisit this once we have proper gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -const gasCostPerIteration = uint64(20) +// // TODO: Revisit this once we have proper gas fee framework. +// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +// const gasCostPerIteration = uint64(20) func (k Keeper) CreateGroup(goCtx context.Context, req *group.MsgCreateGroup) (*group.MsgCreateGroupResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index d347ad624d..d60d469c98 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -const gasCostPerIteration = uint64(10) +// // TODO: Revisit this once we have propoer gas fee framework. +// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +// const gasCostPerIteration = uint64(10) var _ authz.Authorization = &StakeAuthorization{} From bfc717e55d3521c4bbc20bafd28d86e24f75871c Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 3 Jan 2023 20:34:34 +0800 Subject: [PATCH 05/11] add all msg type to gas calculator --- proto/cosmos/gashub/v1alpha1/gashub.proto | 28 +- x/auth/ante/msg_gas_test.go | 4 +- x/auth/client/cli/tips.go | 2 +- x/auth/client/cli/validate_sigs.go | 2 +- x/authz/client/cli/query.go | 6 +- x/authz/client/cli/tx.go | 4 +- x/gashub/simulation/genesis.go | 32 +- x/gashub/simulation/genesis_test.go | 4 +- x/gashub/simulation/params.go | 2 +- x/gashub/simulation/params_test.go | 2 +- x/gashub/types/gas_calculator.go | 206 ++++- x/gashub/types/gashub.pb.go | 879 +++++++++++++++++++++- x/gashub/types/params.go | 220 +++++- x/genutil/client/cli/validate_genesis.go | 2 +- x/nft/client/cli/tx.go | 2 +- x/staking/client/cli/tx.go | 2 +- x/upgrade/client/cli/query.go | 6 +- 17 files changed, 1281 insertions(+), 122 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 265ab47614..2e739f091d 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -10,8 +10,28 @@ message Params { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; - uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - uint64 msg_send_gas = 3 [(gogoproto.customname) = "MsgSendGas"]; - uint64 msg_multi_send_gas = 4 [(gogoproto.customname) = "MsgMultiSendGas"]; + uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; + uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; + uint64 msg_grant_gas = 3 [(gogoproto.customname) = "MsgGrantGas"]; + uint64 msg_revoke_gas = 4 [(gogoproto.customname) = "MsgRevokeGas"]; + uint64 msg_exec_gas = 5 [(gogoproto.customname) = "MsgExecGas"]; + uint64 msg_send_gas = 6 [(gogoproto.customname) = "MsgSendGas"]; + uint64 msg_multi_send_gas = 7 [(gogoproto.customname) = "MsgMultiSendGas"]; + uint64 msg_withdraw_delegator_reward_gas = 8 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"]; + uint64 msg_withdraw_validator_commission_gas = 9 [(gogoproto.customname) = "MsgWithdrawValidatorCommissionGas"]; + uint64 msg_set_withdraw_address_gas = 10 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"]; + uint64 msg_fund_community_pool_gas = 11 [(gogoproto.customname) = "MsgFundCommunityPoolGas"]; + uint64 msg_grant_allowance_gas = 12 [(gogoproto.customname) = "MsgGrantAllowanceGas"]; + uint64 msg_revoke_allowance_gas = 13 [(gogoproto.customname) = "MsgRevokeAllowanceGas"]; + uint64 msg_submit_proposal_gas = 14 [(gogoproto.customname) = "MsgSubmitProposalGas"]; + uint64 msg_vote_gas = 15 [(gogoproto.customname) = "MsgVoteGas"]; + uint64 msg_vote_weighted_gas = 16 [(gogoproto.customname) = "MsgVoteWeightedGas"]; + uint64 msg_deposit_gas = 17 [(gogoproto.customname) = "MsgDepositGas"]; + uint64 msg_unjail_gas = 18 [(gogoproto.customname) = "MsgUnjailGas"]; + uint64 msg_impeach_gas = 19 [(gogoproto.customname) = "MsgImpeachGas"]; + uint64 msg_edit_validator_gas = 20 [(gogoproto.customname) = "MsgEditValidatorGas"]; + uint64 msg_delegate_gas = 21 [(gogoproto.customname) = "MsgDelegateGas"]; + uint64 msg_undelegate_gas = 22 [(gogoproto.customname) = "MsgUndelegateGas"]; + uint64 msg_begin_redelegate_gas = 23 [(gogoproto.customname) = "MsgBeginRedelegateGas"]; + uint64 msg_cancel_unbonding_delegation_gas = 24 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"]; } diff --git a/x/auth/ante/msg_gas_test.go b/x/auth/ante/msg_gas_test.go index 6cd15d8741..2ec534a828 100644 --- a/x/auth/ante/msg_gas_test.go +++ b/x/auth/ante/msg_gas_test.go @@ -47,8 +47,8 @@ func (suite *AnteTestSuite) TestMsgGas() { expectedGas uint64 } testCases := []testCase{ - {"MsgSend", msgSend, 1000000}, - {"MsgMultiSend", msgMultiSend, 2400000}, + {"MsgSend", msgSend, 100000}, + {"MsgMultiSend", msgMultiSend, 300000}, } for _, tc := range testCases { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test diff --git a/x/auth/client/cli/tips.go b/x/auth/client/cli/tips.go index 773ad6d619..567b093066 100644 --- a/x/auth/client/cli/tips.go +++ b/x/auth/client/cli/tips.go @@ -17,7 +17,7 @@ import ( func GetAuxToFeeCommand() *cobra.Command { cmd := &cobra.Command{ Use: "aux-to-fee ", - Short: "includes the aux signer data in the tx, broadcast the tx, and sends the tip amount to the broadcaster", + Short: "Includes the aux signer data in the tx, broadcast the tx, and sends the tip amount to the broadcaster", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) diff --git a/x/auth/client/cli/validate_sigs.go b/x/auth/client/cli/validate_sigs.go index 7d4da92bac..be0b9f8ace 100644 --- a/x/auth/client/cli/validate_sigs.go +++ b/x/auth/client/cli/validate_sigs.go @@ -16,7 +16,7 @@ import ( func GetValidateSignaturesCommand() *cobra.Command { cmd := &cobra.Command{ Use: "validate-signatures [file]", - Short: "validate transactions signatures", + Short: "Validate transactions signatures", Long: `Print the addresses that must sign the transaction, those who have already signed it, and make sure that signatures are in the correct order. diff --git a/x/authz/client/cli/query.go b/x/authz/client/cli/query.go index 49643db5cd..704bb53adc 100644 --- a/x/authz/client/cli/query.go +++ b/x/authz/client/cli/query.go @@ -39,7 +39,7 @@ func GetCmdQueryGrants() *cobra.Command { cmd := &cobra.Command{ Use: "grants [granter-addr] [grantee-addr] [msg-type-url]?", Args: cobra.RangeArgs(2, 3), - Short: "query grants for a granter-grantee pair and optionally a msg-type-url", + Short: "Query grants for a granter-grantee pair and optionally a msg-type-url", Long: strings.TrimSpace( fmt.Sprintf(`Query authorization grants for a granter-grantee pair. If msg-type-url is set, it will select grants only for that msg type. @@ -100,7 +100,7 @@ func GetQueryGranterGrants() *cobra.Command { cmd := &cobra.Command{ Use: "grants-by-granter [granter-addr]", Args: cobra.ExactArgs(1), - Short: "query authorization grants granted by granter", + Short: "Query authorization grants granted by granter", Long: strings.TrimSpace( fmt.Sprintf(`Query authorization grants granted by granter. Examples: @@ -149,7 +149,7 @@ func GetQueryGranteeGrants() *cobra.Command { cmd := &cobra.Command{ Use: "grants-by-grantee [grantee-addr]", Args: cobra.ExactArgs(1), - Short: "query authorization grants granted to a grantee", + Short: "Query authorization grants granted to a grantee", Long: strings.TrimSpace( fmt.Sprintf(`Query authorization grants granted to a grantee. Examples: diff --git a/x/authz/client/cli/tx.go b/x/authz/client/cli/tx.go index 3eb398667b..13a171ee86 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -204,7 +204,7 @@ func getExpireTime(cmd *cobra.Command) (*time.Time, error) { func NewCmdRevokeAuthorization() *cobra.Command { cmd := &cobra.Command{ Use: "revoke [grantee] [msg-type-url] --from=[granter]", - Short: "revoke authorization", + Short: "Revoke authorization", Long: strings.TrimSpace( fmt.Sprintf(`revoke authorization from a granter to a grantee: Example: @@ -238,7 +238,7 @@ Example: func NewCmdExecAuthorization() *cobra.Command { cmd := &cobra.Command{ Use: "exec [tx-json-file] --from [grantee]", - Short: "execute tx on behalf of granter account", + Short: "Execute tx on behalf of granter account", Long: strings.TrimSpace( fmt.Sprintf(`execute tx on behalf of granter account: Example: diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index 575df522bb..3432444206 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -12,10 +12,9 @@ import ( // Simulation parameter constants const ( - MaxTxSize = "max_tx_size" - MinGasPerByte = "min_gas_per_byte" - MsgSendGas = "msg_send_gas" - MsgMultiSendGas = "msg_multi_send_gas" + MaxTxSize = "max_tx_size" + MinGasPerByte = "min_gas_per_byte" + MsgGas = "msg_gas" ) // GenMaxTxSize randomized MaxTxSize @@ -28,14 +27,9 @@ func GenMinGasPerByte(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 2500, 5000)) } -// GenMsgSendGas randomized MsgSendGas -func GenMsgSendGas(r *rand.Rand) uint64 { - return uint64(simulation.RandIntBetween(r, 1e6, 1e7)) -} - -// GenMsgMultiSendGas randomized MsgMultiSendGas -func GenMsgMultiSendGas(r *rand.Rand) uint64 { - return uint64(simulation.RandIntBetween(r, 1e6, 1e7)) +// GenMsgGas randomized msg gas consumption +func GenMsgGas(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 1e5, 1e7)) } // RandomizedGenState generates a random GenesisState for auth @@ -52,19 +46,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) - var msgSendGas uint64 - simState.AppParams.GetOrGenerate( - simState.Cdc, MsgSendGas, &msgSendGas, simState.Rand, - func(r *rand.Rand) { msgSendGas = GenMsgSendGas(r) }, - ) - - var msgMultiSendGas uint64 + var msgGas uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, MsgMultiSendGas, &msgMultiSendGas, simState.Rand, - func(r *rand.Rand) { msgMultiSendGas = GenMsgMultiSendGas(r) }, + simState.Cdc, MsgGas, &msgGas, simState.Rand, + func(r *rand.Rand) { msgGas = GenMsgGas(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, msgSendGas, msgMultiSendGas) + params := types.NewParams(maxTxSize, minGasPerByte, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 5c141cc139..1da83d0bef 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -41,6 +41,6 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(8203300), gashubGenesis.Params.MsgSendGas) - require.Equal(t, uint64(9410694), gashubGenesis.Params.MsgMultiSendGas) + require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgSendGas) + require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgMultiSendGas) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index 1f2b15f5a2..03d04e5d52 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -21,7 +21,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, keyMsgSendGas, func(r *rand.Rand) string { - return fmt.Sprintf("%d", GenMsgSendGas(r)) + return fmt.Sprintf("%d", GenMsgGas(r)) }, ), } diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index ff4fe52097..72de4d0401 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MsgSendGas", "MsgSendGas", "3498081", "gashub"}, + {"gashub/MsgSendGas", "MsgSendGas", "1698081", "gashub"}, } paramChanges := simulation.ParamChanges(r) diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 758abe8cbe..bbf2cb39b3 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -2,7 +2,13 @@ package types import ( "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" bank "github.com/cosmos/cosmos-sdk/x/bank/types" + distribution "github.com/cosmos/cosmos-sdk/x/distribution/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + slashing "github.com/cosmos/cosmos-sdk/x/slashing/types" + staking "github.com/cosmos/cosmos-sdk/x/staking/types" ) type ( @@ -39,23 +45,203 @@ func MultiSendCalculator(amount uint64) GasCalculator { } } -var msgSendFeeCalculatorGen = func(params Params) GasCalculator { - msgSendGas := params.GetMsgSendGas() - if msgSendGas == 0 { +var msgGrantGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgGrantGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgGrantGas) + } + return FixedGasCalculator(msgGas) +} + +var msgRevokeGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgRevokeGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgRevokeGas) + } + return FixedGasCalculator(msgGas) +} + +var msgExecGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgExecGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgExecGas) + } + return FixedGasCalculator(msgGas) +} + +var msgSendGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgSendGas() + if msgGas == 0 { return FixedGasCalculator(DefaultMsgSendGas) } - return FixedGasCalculator(msgSendGas) + return FixedGasCalculator(msgGas) } -var msgMultiSendFeeCalculatorGen = func(params Params) GasCalculator { - msgMultiSendGas := params.GetMsgMultiSendGas() - if msgMultiSendGas == 0 { +var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgMultiSendGas() + if msgGas == 0 { return MultiSendCalculator(DefaultMsgSendGas) } - return MultiSendCalculator(msgMultiSendGas) + return MultiSendCalculator(msgGas) +} + +var msgWithdrawDelegatorRewardGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgWithdrawDelegatorRewardGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgWithdrawDelegatorRewardGas) + } + return FixedGasCalculator(msgGas) +} + +var msgWithdrawValidatorCommissionGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgWithdrawValidatorCommissionGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgWithdrawValidatorCommissionGas) + } + return FixedGasCalculator(msgGas) +} + +var msgSetWithdrawAddressGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgSetWithdrawAddressGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgSetWithdrawAddressGas) + } + return FixedGasCalculator(msgGas) +} + +var msgFundCommunityPoolGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgFundCommunityPoolGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgFundCommunityPoolGas) + } + return FixedGasCalculator(msgGas) +} + +var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgGrantAllowanceGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgGrantAllowanceGas) + } + return FixedGasCalculator(msgGas) +} + +var msgRevokeAllowanceGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgRevokeAllowanceGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgRevokeAllowanceGas) + } + return FixedGasCalculator(msgGas) +} + +var msgSubmitProposalGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgSubmitProposalGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgSubmitProposalGas) + } + return FixedGasCalculator(msgGas) +} + +var msgVoteGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgVoteGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgVoteGas) + } + return FixedGasCalculator(msgGas) +} + +var msgVoteWeightedGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgVoteWeightedGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgVoteWeightedGas) + } + return FixedGasCalculator(msgGas) +} + +var msgDepositGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgDepositGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgDepositGas) + } + return FixedGasCalculator(msgGas) +} + +var msgUnjailGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgUnjailGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgUnjailGas) + } + return FixedGasCalculator(msgGas) +} + +var msgImpeachGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgImpeachGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgImpeachGas) + } + return FixedGasCalculator(msgGas) +} + +var msgEditValidatorGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgEditValidatorGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgEditValidatorGas) + } + return FixedGasCalculator(msgGas) +} + +var msgDelegateGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgDelegateGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgDelegateGas) + } + return FixedGasCalculator(msgGas) +} + +var msgUndelegateGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgUndelegateGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgUndelegateGas) + } + return FixedGasCalculator(msgGas) +} + +var msgBeginRedelegateGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgBeginRedelegateGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgBeginRedelegateGas) + } + return FixedGasCalculator(msgGas) +} + +var msgCancelUnbondingDelegationGasCalculatorGen = func(params Params) GasCalculator { + msgGas := params.GetMsgCancelUnbondingDelegationGas() + if msgGas == 0 { + return FixedGasCalculator(DefaultMsgCancelUnbondingDelegationGas) + } + return FixedGasCalculator(msgGas) } func init() { - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), msgSendFeeCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendFeeCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgGrant{}), msgGrantGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), msgRevokeGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), msgExecGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), msgSendGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), msgWithdrawDelegatorRewardGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), msgWithdrawValidatorCommissionGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), msgSetWithdrawAddressGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), msgFundCommunityPoolGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgGrantAllowance{}), msgGrantAllowanceGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), msgRevokeAllowanceGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), msgSubmitProposalGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), msgVoteGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), msgVoteWeightedGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), msgDepositGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), msgUnjailGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), msgImpeachGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), msgEditValidatorGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), msgDelegateGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), msgUndelegateGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), msgBeginRedelegateGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), msgCancelUnbondingDelegationGasCalculatorGen) } diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index f425442377..337ee00c6a 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -25,10 +25,30 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the gashub module. type Params struct { - MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` - MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MsgSendGas uint64 `protobuf:"varint,3,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` - MsgMultiSendGas uint64 `protobuf:"varint,4,opt,name=msg_multi_send_gas,json=msgMultiSendGas,proto3" json:"msg_multi_send_gas,omitempty"` + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + MsgGrantGas uint64 `protobuf:"varint,3,opt,name=msg_grant_gas,json=msgGrantGas,proto3" json:"msg_grant_gas,omitempty"` + MsgRevokeGas uint64 `protobuf:"varint,4,opt,name=msg_revoke_gas,json=msgRevokeGas,proto3" json:"msg_revoke_gas,omitempty"` + MsgExecGas uint64 `protobuf:"varint,5,opt,name=msg_exec_ga,json=msgExecGa,proto3" json:"msg_exec_ga,omitempty"` + MsgSendGas uint64 `protobuf:"varint,6,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` + MsgMultiSendGas uint64 `protobuf:"varint,7,opt,name=msg_multi_send_gas,json=msgMultiSendGas,proto3" json:"msg_multi_send_gas,omitempty"` + MsgWithdrawDelegatorRewardGas uint64 `protobuf:"varint,8,opt,name=msg_withdraw_delegator_reward_gas,json=msgWithdrawDelegatorRewardGas,proto3" json:"msg_withdraw_delegator_reward_gas,omitempty"` + MsgWithdrawValidatorCommissionGas uint64 `protobuf:"varint,9,opt,name=msg_withdraw_validator_commission_gas,json=msgWithdrawValidatorCommissionGas,proto3" json:"msg_withdraw_validator_commission_gas,omitempty"` + MsgSetWithdrawAddressGas uint64 `protobuf:"varint,10,opt,name=msg_set_withdraw_address_gas,json=msgSetWithdrawAddressGas,proto3" json:"msg_set_withdraw_address_gas,omitempty"` + MsgFundCommunityPoolGas uint64 `protobuf:"varint,11,opt,name=msg_fund_community_pool_gas,json=msgFundCommunityPoolGas,proto3" json:"msg_fund_community_pool_gas,omitempty"` + MsgGrantAllowanceGas uint64 `protobuf:"varint,12,opt,name=msg_grant_allowance_gas,json=msgGrantAllowanceGas,proto3" json:"msg_grant_allowance_gas,omitempty"` + MsgRevokeAllowanceGas uint64 `protobuf:"varint,13,opt,name=msg_revoke_allowance_gas,json=msgRevokeAllowanceGas,proto3" json:"msg_revoke_allowance_gas,omitempty"` + MsgSubmitProposalGas uint64 `protobuf:"varint,14,opt,name=msg_submit_proposal_gas,json=msgSubmitProposalGas,proto3" json:"msg_submit_proposal_gas,omitempty"` + MsgVoteGas uint64 `protobuf:"varint,15,opt,name=msg_vote_gas,json=msgVoteGas,proto3" json:"msg_vote_gas,omitempty"` + MsgVoteWeightedGas uint64 `protobuf:"varint,16,opt,name=msg_vote_weighted_gas,json=msgVoteWeightedGas,proto3" json:"msg_vote_weighted_gas,omitempty"` + MsgDepositGas uint64 `protobuf:"varint,17,opt,name=msg_deposit_gas,json=msgDepositGas,proto3" json:"msg_deposit_gas,omitempty"` + MsgUnjailGas uint64 `protobuf:"varint,18,opt,name=msg_unjail_gas,json=msgUnjailGas,proto3" json:"msg_unjail_gas,omitempty"` + MsgImpeachGas uint64 `protobuf:"varint,19,opt,name=msg_impeach_gas,json=msgImpeachGas,proto3" json:"msg_impeach_gas,omitempty"` + MsgEditValidatorGas uint64 `protobuf:"varint,20,opt,name=msg_edit_validator_gas,json=msgEditValidatorGas,proto3" json:"msg_edit_validator_gas,omitempty"` + MsgDelegateGas uint64 `protobuf:"varint,21,opt,name=msg_delegate_gas,json=msgDelegateGas,proto3" json:"msg_delegate_gas,omitempty"` + MsgUndelegateGas uint64 `protobuf:"varint,22,opt,name=msg_undelegate_gas,json=msgUndelegateGas,proto3" json:"msg_undelegate_gas,omitempty"` + MsgBeginRedelegateGas uint64 `protobuf:"varint,23,opt,name=msg_begin_redelegate_gas,json=msgBeginRedelegateGas,proto3" json:"msg_begin_redelegate_gas,omitempty"` + MsgCancelUnbondingDelegationGas uint64 `protobuf:"varint,24,opt,name=msg_cancel_unbonding_delegation_gas,json=msgCancelUnbondingDelegationGas,proto3" json:"msg_cancel_unbonding_delegation_gas,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -77,6 +97,27 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } +func (m *Params) GetMsgGrantGas() uint64 { + if m != nil { + return m.MsgGrantGas + } + return 0 +} + +func (m *Params) GetMsgRevokeGas() uint64 { + if m != nil { + return m.MsgRevokeGas + } + return 0 +} + +func (m *Params) GetMsgExecGas() uint64 { + if m != nil { + return m.MsgExecGas + } + return 0 +} + func (m *Params) GetMsgSendGas() uint64 { if m != nil { return m.MsgSendGas @@ -91,6 +132,125 @@ func (m *Params) GetMsgMultiSendGas() uint64 { return 0 } +func (m *Params) GetMsgWithdrawDelegatorRewardGas() uint64 { + if m != nil { + return m.MsgWithdrawDelegatorRewardGas + } + return 0 +} + +func (m *Params) GetMsgWithdrawValidatorCommissionGas() uint64 { + if m != nil { + return m.MsgWithdrawValidatorCommissionGas + } + return 0 +} + +func (m *Params) GetMsgSetWithdrawAddressGas() uint64 { + if m != nil { + return m.MsgSetWithdrawAddressGas + } + return 0 +} + +func (m *Params) GetMsgFundCommunityPoolGas() uint64 { + if m != nil { + return m.MsgFundCommunityPoolGas + } + return 0 +} + +func (m *Params) GetMsgGrantAllowanceGas() uint64 { + if m != nil { + return m.MsgGrantAllowanceGas + } + return 0 +} + +func (m *Params) GetMsgRevokeAllowanceGas() uint64 { + if m != nil { + return m.MsgRevokeAllowanceGas + } + return 0 +} + +func (m *Params) GetMsgSubmitProposalGas() uint64 { + if m != nil { + return m.MsgSubmitProposalGas + } + return 0 +} + +func (m *Params) GetMsgVoteGas() uint64 { + if m != nil { + return m.MsgVoteGas + } + return 0 +} + +func (m *Params) GetMsgVoteWeightedGas() uint64 { + if m != nil { + return m.MsgVoteWeightedGas + } + return 0 +} + +func (m *Params) GetMsgDepositGas() uint64 { + if m != nil { + return m.MsgDepositGas + } + return 0 +} + +func (m *Params) GetMsgUnjailGas() uint64 { + if m != nil { + return m.MsgUnjailGas + } + return 0 +} + +func (m *Params) GetMsgImpeachGas() uint64 { + if m != nil { + return m.MsgImpeachGas + } + return 0 +} + +func (m *Params) GetMsgEditValidatorGas() uint64 { + if m != nil { + return m.MsgEditValidatorGas + } + return 0 +} + +func (m *Params) GetMsgDelegateGas() uint64 { + if m != nil { + return m.MsgDelegateGas + } + return 0 +} + +func (m *Params) GetMsgUndelegateGas() uint64 { + if m != nil { + return m.MsgUndelegateGas + } + return 0 +} + +func (m *Params) GetMsgBeginRedelegateGas() uint64 { + if m != nil { + return m.MsgBeginRedelegateGas + } + return 0 +} + +func (m *Params) GetMsgCancelUnbondingDelegationGas() uint64 { + if m != nil { + return m.MsgCancelUnbondingDelegationGas + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") } @@ -100,27 +260,64 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 319 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0x3f, 0x4f, 0x3a, 0x31, - 0x18, 0xc7, 0xaf, 0xbf, 0x1f, 0x21, 0x52, 0x45, 0xf4, 0x34, 0x86, 0x38, 0x5c, 0x8d, 0x2e, 0x26, - 0x06, 0x4e, 0xe2, 0xc6, 0x64, 0x48, 0x0c, 0xd3, 0x25, 0x04, 0x9c, 0x5c, 0x9a, 0x02, 0x4d, 0x69, - 0xa4, 0xd7, 0xcb, 0x3d, 0xc5, 0x1c, 0xbc, 0x0a, 0x47, 0x47, 0x5e, 0x8e, 0x23, 0xa3, 0xd3, 0xc5, - 0x94, 0xc5, 0xd5, 0x77, 0x60, 0xee, 0xe0, 0xfc, 0x33, 0xf5, 0xfb, 0x3c, 0xfd, 0x7e, 0x9e, 0xe1, - 0x83, 0x2f, 0x46, 0x1a, 0x94, 0x06, 0x5f, 0x30, 0x98, 0xcc, 0x86, 0xfe, 0x53, 0x8b, 0x4d, 0xa3, - 0x09, 0x6b, 0x6d, 0xe7, 0x66, 0x14, 0x6b, 0xa3, 0xdd, 0x93, 0x4d, 0xa9, 0xb9, 0x5d, 0x16, 0xa5, - 0xd3, 0x63, 0xa1, 0x85, 0xce, 0x2b, 0x7e, 0x96, 0x36, 0xed, 0xf3, 0x4f, 0x84, 0xcb, 0x3d, 0x16, - 0x33, 0x05, 0x6e, 0x03, 0xef, 0x2a, 0x96, 0x50, 0x93, 0x50, 0x90, 0x0b, 0x5e, 0x47, 0x67, 0xe8, - 0xb2, 0xd4, 0xa9, 0xda, 0x94, 0x54, 0x02, 0x96, 0xdc, 0x27, 0x03, 0xb9, 0xe0, 0xfd, 0x8a, 0x2a, - 0xa2, 0xdb, 0xc6, 0x07, 0x4a, 0x86, 0x54, 0x30, 0xa0, 0x11, 0x8f, 0xe9, 0x70, 0x6e, 0x78, 0xfd, - 0x5f, 0xce, 0x1c, 0xda, 0x94, 0x54, 0x03, 0x19, 0x76, 0x19, 0xf4, 0x78, 0xdc, 0x99, 0x1b, 0xde, - 0xaf, 0xaa, 0xdf, 0xa3, 0x7b, 0x8d, 0xf7, 0x14, 0x08, 0x0a, 0x3c, 0x1c, 0x67, 0x07, 0xea, 0xff, - 0x73, 0x6e, 0xdf, 0xa6, 0x04, 0x07, 0x20, 0x06, 0x3c, 0x1c, 0x77, 0x19, 0xf4, 0xb1, 0xfa, 0xce, - 0xee, 0x2d, 0x76, 0x33, 0x42, 0xcd, 0xa6, 0x46, 0xfe, 0x70, 0xa5, 0x9c, 0x3b, 0xb2, 0x29, 0xa9, - 0x05, 0x20, 0x82, 0xec, 0xb3, 0x80, 0x6b, 0xea, 0xef, 0xa2, 0xbd, 0xf3, 0xb2, 0x24, 0xce, 0xc7, - 0x92, 0xa0, 0xce, 0xdd, 0xab, 0xf5, 0xd0, 0xca, 0x7a, 0xe8, 0xdd, 0x7a, 0xe8, 0x79, 0xed, 0x39, - 0xab, 0xb5, 0xe7, 0xbc, 0xad, 0x3d, 0xe7, 0xe1, 0x4a, 0x48, 0x93, 0x49, 0x1b, 0x69, 0xe5, 0x6f, - 0x5d, 0x6f, 0x9e, 0x06, 0x8c, 0x1f, 0xfd, 0xa4, 0x10, 0x6f, 0xe6, 0x11, 0x87, 0x61, 0x39, 0x37, - 0x78, 0xf3, 0x15, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xa7, 0xca, 0x67, 0x96, 0x01, 0x00, 0x00, + // 904 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x5f, 0x6f, 0x5b, 0x35, + 0x14, 0x6f, 0x60, 0x8c, 0xd5, 0x6d, 0xd2, 0xcc, 0x4d, 0x9b, 0x0b, 0xdb, 0x62, 0x4a, 0x35, 0x09, + 0x09, 0xad, 0x61, 0x9a, 0x84, 0xc4, 0xc4, 0x03, 0x4b, 0x3b, 0xaa, 0x49, 0x5c, 0x51, 0xa5, 0x6c, + 0x13, 0x08, 0xe9, 0xca, 0xc9, 0x35, 0x8e, 0x69, 0x7c, 0x1d, 0xae, 0x7d, 0x9b, 0x74, 0x9f, 0x82, + 0x47, 0x1e, 0xf7, 0x71, 0x78, 0xdc, 0x23, 0x4f, 0x57, 0xc8, 0x15, 0x12, 0x1f, 0x03, 0xf9, 0x38, + 0x4e, 0x72, 0x69, 0x19, 0x4f, 0xf1, 0x39, 0xe7, 0xf7, 0xe7, 0xda, 0x39, 0x3e, 0x46, 0xfb, 0x43, + 0xa5, 0xa5, 0xd2, 0x5d, 0x4e, 0xf5, 0xa8, 0x18, 0x74, 0xcf, 0x1f, 0xd2, 0xf1, 0x64, 0x44, 0x1f, + 0xce, 0xe3, 0x83, 0x49, 0xae, 0x8c, 0xc2, 0xbb, 0x1e, 0x74, 0x30, 0x4f, 0x06, 0xd0, 0x87, 0x2d, + 0xae, 0xb8, 0x02, 0x48, 0xd7, 0xad, 0x3c, 0xfa, 0xe3, 0xbf, 0xea, 0xe8, 0xe6, 0x09, 0xcd, 0xa9, + 0xd4, 0xf8, 0x01, 0xda, 0x90, 0x74, 0x96, 0x98, 0x59, 0xa2, 0xc5, 0x2b, 0x16, 0xd5, 0x3e, 0xaa, + 0x7d, 0x72, 0xa3, 0x57, 0xb7, 0x25, 0x59, 0x8f, 0xe9, 0xec, 0xbb, 0xd9, 0xa9, 0x78, 0xc5, 0xfa, + 0xeb, 0x32, 0x2c, 0xf1, 0x63, 0xd4, 0x94, 0x22, 0x4b, 0x38, 0xd5, 0xc9, 0x84, 0xe5, 0xc9, 0xe0, + 0xc2, 0xb0, 0xe8, 0x1d, 0xe0, 0xdc, 0xb6, 0x25, 0xa9, 0xc7, 0x22, 0x3b, 0xa6, 0xfa, 0x84, 0xe5, + 0xbd, 0x0b, 0xc3, 0xfa, 0x75, 0xb9, 0x1a, 0xe2, 0x47, 0xa8, 0x2e, 0x35, 0x4f, 0x78, 0x4e, 0x33, + 0xe3, 0x14, 0xa2, 0x77, 0x81, 0xb8, 0x65, 0x4b, 0xb2, 0x11, 0x6b, 0x7e, 0xec, 0xf2, 0xc7, 0x54, + 0xf7, 0x37, 0xe4, 0x32, 0xc0, 0x9f, 0xa3, 0x86, 0x23, 0xe5, 0xec, 0x5c, 0x9d, 0x31, 0x60, 0xdd, + 0x00, 0x56, 0xd3, 0x96, 0x64, 0x33, 0xd6, 0xbc, 0x0f, 0x05, 0x47, 0xdb, 0x94, 0x2b, 0x11, 0x3e, + 0x40, 0x4e, 0x26, 0x61, 0x33, 0x36, 0x4c, 0x38, 0x8d, 0xde, 0x03, 0x52, 0xc3, 0x96, 0x04, 0xc5, + 0x9a, 0x3f, 0x9d, 0xb1, 0xa1, 0xa3, 0xac, 0xcb, 0xb0, 0xc6, 0x9f, 0x21, 0xc7, 0x4f, 0x34, 0xcb, + 0x52, 0x70, 0xb9, 0x59, 0x21, 0x9c, 0xb2, 0x2c, 0x75, 0x04, 0x24, 0x17, 0x6b, 0xfc, 0x15, 0xc2, + 0x8e, 0x21, 0x8b, 0xb1, 0x11, 0x4b, 0xde, 0xfb, 0xc0, 0xdb, 0xb6, 0x25, 0xd9, 0x8a, 0x35, 0x8f, + 0x5d, 0x31, 0x90, 0xb7, 0x64, 0x35, 0x81, 0xcf, 0xd0, 0x9e, 0x53, 0x98, 0x0a, 0x33, 0x4a, 0x73, + 0x3a, 0x4d, 0x52, 0x36, 0x66, 0x9c, 0x1a, 0x95, 0x27, 0x39, 0x9b, 0xd2, 0xdc, 0x0b, 0xde, 0x02, + 0xc1, 0x3d, 0x5b, 0x92, 0x7b, 0xb1, 0xe6, 0x2f, 0xe7, 0xd8, 0xa3, 0x00, 0xed, 0x03, 0xd2, 0xc9, + 0xdf, 0x93, 0x6f, 0x2b, 0xe3, 0x29, 0xba, 0x5f, 0x31, 0x3b, 0xa7, 0x63, 0x91, 0x82, 0xd9, 0x50, + 0x49, 0x29, 0xb4, 0x16, 0x0a, 0xfe, 0xd7, 0x68, 0x1d, 0x0c, 0xef, 0xdb, 0x92, 0xec, 0xad, 0x18, + 0xbe, 0x08, 0xf0, 0xc3, 0x05, 0xda, 0x99, 0xee, 0xc9, 0xff, 0x83, 0xe0, 0x1f, 0xd1, 0x5d, 0x7f, + 0xb2, 0x66, 0x69, 0x4e, 0xd3, 0x34, 0x67, 0x5a, 0x83, 0x1f, 0x02, 0xbf, 0xbb, 0xb6, 0x24, 0x11, + 0x9c, 0xb4, 0x09, 0x7a, 0x4f, 0x3c, 0xc8, 0xd9, 0x44, 0xf2, 0x3f, 0x2a, 0xf8, 0x7b, 0x74, 0xc7, + 0xa9, 0xff, 0x54, 0x64, 0x29, 0x6c, 0xa4, 0xc8, 0x84, 0xb9, 0x48, 0x26, 0x4a, 0x8d, 0x41, 0x7c, + 0x03, 0xc4, 0xef, 0xd8, 0x92, 0xb4, 0x63, 0xcd, 0xbf, 0x2e, 0xb2, 0xf4, 0x30, 0x80, 0x4e, 0x94, + 0x1a, 0x3b, 0xed, 0xb6, 0xbc, 0xbe, 0x80, 0xbf, 0x45, 0xed, 0x65, 0xbf, 0xd2, 0xf1, 0x58, 0x4d, + 0x69, 0x36, 0xf4, 0x3d, 0xb8, 0x09, 0xb2, 0x91, 0x2d, 0x49, 0x2b, 0x74, 0xee, 0x93, 0x00, 0x70, + 0x9a, 0x2d, 0x79, 0x4d, 0x16, 0xf7, 0x51, 0xb4, 0xd2, 0xcb, 0x55, 0xc5, 0x3a, 0x28, 0x7e, 0x60, + 0x4b, 0xb2, 0xb3, 0xe8, 0xea, 0x8a, 0xe4, 0x8e, 0xbc, 0x2e, 0x1d, 0x3e, 0x52, 0x17, 0x03, 0x29, + 0x4c, 0x32, 0xc9, 0xd5, 0x44, 0x69, 0xea, 0xf7, 0xde, 0xa8, 0x7c, 0xe4, 0x29, 0x20, 0x4e, 0xe6, + 0x80, 0xf0, 0x91, 0x57, 0xb2, 0xe1, 0x22, 0x9c, 0x2b, 0xe3, 0x3f, 0x6c, 0xab, 0x72, 0x11, 0x5e, + 0x28, 0xc3, 0xc2, 0x45, 0x98, 0xaf, 0xf1, 0x33, 0xb4, 0xb3, 0x60, 0x4c, 0x99, 0xe0, 0x23, 0xc3, + 0x7c, 0xeb, 0x36, 0x81, 0xba, 0x6b, 0x4b, 0x82, 0xe7, 0xd4, 0x97, 0xf3, 0xb2, 0x93, 0xc0, 0xf2, + 0x4a, 0x0e, 0x7f, 0x81, 0xdc, 0x25, 0x49, 0x52, 0x36, 0x51, 0x5a, 0xf8, 0x21, 0x71, 0x7b, 0x65, + 0xba, 0x68, 0x7e, 0xe4, 0x2b, 0x8e, 0xef, 0x86, 0xc9, 0x32, 0x0c, 0x83, 0xa2, 0xc8, 0x7e, 0xa6, + 0xc2, 0xef, 0x1f, 0x57, 0x06, 0xc5, 0x73, 0x28, 0x84, 0x41, 0xb1, 0x88, 0x82, 0xa5, 0x90, 0x13, + 0x46, 0x87, 0x23, 0x20, 0x6e, 0x57, 0x2c, 0x9f, 0xf9, 0x4a, 0xb0, 0x5c, 0x86, 0xf8, 0x1b, 0xb4, + 0x0b, 0x33, 0x26, 0x15, 0x66, 0xe5, 0x3a, 0x39, 0x85, 0x16, 0x28, 0xb4, 0x6d, 0x49, 0xb6, 0xdd, + 0xb8, 0x49, 0x85, 0x59, 0x5c, 0x0e, 0xa7, 0xb3, 0x2d, 0xaf, 0x26, 0xf1, 0x97, 0xa8, 0xe9, 0xf7, + 0x0e, 0x57, 0xd7, 0x1f, 0xfe, 0x0e, 0xe8, 0x60, 0x5b, 0x92, 0x06, 0x6c, 0xde, 0x97, 0x9c, 0x44, + 0x43, 0x56, 0x62, 0xdc, 0xf3, 0xd3, 0xa8, 0xc8, 0x2a, 0xfc, 0x5d, 0xe0, 0xb7, 0x6c, 0x49, 0x9a, + 0x70, 0x04, 0xe9, 0x8a, 0x42, 0x53, 0xfe, 0x2b, 0x13, 0xfa, 0x73, 0xc0, 0xb8, 0xc8, 0x92, 0x9c, + 0x55, 0x94, 0xda, 0x95, 0xfe, 0xec, 0x39, 0x48, 0x9f, 0xad, 0xca, 0xb9, 0x1e, 0xb8, 0x9a, 0xc6, + 0xbf, 0xa0, 0x7d, 0xa7, 0x39, 0x74, 0xfd, 0x3a, 0x4e, 0x8a, 0x6c, 0xa0, 0xb2, 0x54, 0x64, 0x8b, + 0x6d, 0x86, 0xa1, 0x13, 0x81, 0xfc, 0xbe, 0x2d, 0x09, 0x89, 0x35, 0x3f, 0x04, 0xf4, 0xf3, 0x00, + 0x3e, 0x5a, 0x60, 0x9d, 0x11, 0x91, 0x6f, 0x07, 0x3c, 0xbe, 0xf5, 0xdb, 0x6b, 0xb2, 0xf6, 0xf7, + 0x6b, 0x52, 0xeb, 0x3d, 0xfd, 0xdd, 0x76, 0x6a, 0x6f, 0x6c, 0xa7, 0xf6, 0xa7, 0xed, 0xd4, 0x7e, + 0xbd, 0xec, 0xac, 0xbd, 0xb9, 0xec, 0xac, 0xfd, 0x71, 0xd9, 0x59, 0xfb, 0xe1, 0x53, 0x2e, 0x8c, + 0x7b, 0x28, 0x87, 0x4a, 0x76, 0xe7, 0xef, 0xab, 0xff, 0x79, 0xa0, 0xd3, 0xb3, 0xee, 0x2c, 0x3c, + 0xb6, 0xe6, 0x62, 0xc2, 0xf4, 0xe0, 0x26, 0xbc, 0x9a, 0x8f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x4b, 0x5e, 0x5a, 0x11, 0x8a, 0x07, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -148,12 +345,72 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } + if this.MsgGrantGas != that1.MsgGrantGas { + return false + } + if this.MsgRevokeGas != that1.MsgRevokeGas { + return false + } + if this.MsgExecGas != that1.MsgExecGas { + return false + } if this.MsgSendGas != that1.MsgSendGas { return false } if this.MsgMultiSendGas != that1.MsgMultiSendGas { return false } + if this.MsgWithdrawDelegatorRewardGas != that1.MsgWithdrawDelegatorRewardGas { + return false + } + if this.MsgWithdrawValidatorCommissionGas != that1.MsgWithdrawValidatorCommissionGas { + return false + } + if this.MsgSetWithdrawAddressGas != that1.MsgSetWithdrawAddressGas { + return false + } + if this.MsgFundCommunityPoolGas != that1.MsgFundCommunityPoolGas { + return false + } + if this.MsgGrantAllowanceGas != that1.MsgGrantAllowanceGas { + return false + } + if this.MsgRevokeAllowanceGas != that1.MsgRevokeAllowanceGas { + return false + } + if this.MsgSubmitProposalGas != that1.MsgSubmitProposalGas { + return false + } + if this.MsgVoteGas != that1.MsgVoteGas { + return false + } + if this.MsgVoteWeightedGas != that1.MsgVoteWeightedGas { + return false + } + if this.MsgDepositGas != that1.MsgDepositGas { + return false + } + if this.MsgUnjailGas != that1.MsgUnjailGas { + return false + } + if this.MsgImpeachGas != that1.MsgImpeachGas { + return false + } + if this.MsgEditValidatorGas != that1.MsgEditValidatorGas { + return false + } + if this.MsgDelegateGas != that1.MsgDelegateGas { + return false + } + if this.MsgUndelegateGas != that1.MsgUndelegateGas { + return false + } + if this.MsgBeginRedelegateGas != that1.MsgBeginRedelegateGas { + return false + } + if this.MsgCancelUnbondingDelegationGas != that1.MsgCancelUnbondingDelegationGas { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -176,14 +433,132 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MsgCancelUnbondingDelegationGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgCancelUnbondingDelegationGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc0 + } + if m.MsgBeginRedelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgBeginRedelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb8 + } + if m.MsgUndelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgUndelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb0 + } + if m.MsgDelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgDelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } + if m.MsgEditValidatorGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgEditValidatorGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.MsgImpeachGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgImpeachGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + if m.MsgUnjailGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgUnjailGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.MsgDepositGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgDepositGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.MsgVoteWeightedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteWeightedGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } + if m.MsgVoteGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteGas)) + i-- + dAtA[i] = 0x78 + } + if m.MsgSubmitProposalGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSubmitProposalGas)) + i-- + dAtA[i] = 0x70 + } + if m.MsgRevokeAllowanceGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeAllowanceGas)) + i-- + dAtA[i] = 0x68 + } + if m.MsgGrantAllowanceGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowanceGas)) + i-- + dAtA[i] = 0x60 + } + if m.MsgFundCommunityPoolGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgFundCommunityPoolGas)) + i-- + dAtA[i] = 0x58 + } + if m.MsgSetWithdrawAddressGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSetWithdrawAddressGas)) + i-- + dAtA[i] = 0x50 + } + if m.MsgWithdrawValidatorCommissionGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawValidatorCommissionGas)) + i-- + dAtA[i] = 0x48 + } + if m.MsgWithdrawDelegatorRewardGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawDelegatorRewardGas)) + i-- + dAtA[i] = 0x40 + } if m.MsgMultiSendGas != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendGas)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x38 } if m.MsgSendGas != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MsgSendGas)) i-- + dAtA[i] = 0x30 + } + if m.MsgExecGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgExecGas)) + i-- + dAtA[i] = 0x28 + } + if m.MsgRevokeGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeGas)) + i-- + dAtA[i] = 0x20 + } + if m.MsgGrantGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantGas)) + i-- dAtA[i] = 0x18 } if m.MinGasPerByte != 0 { @@ -222,12 +597,72 @@ func (m *Params) Size() (n int) { if m.MinGasPerByte != 0 { n += 1 + sovGashub(uint64(m.MinGasPerByte)) } + if m.MsgGrantGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantGas)) + } + if m.MsgRevokeGas != 0 { + n += 1 + sovGashub(uint64(m.MsgRevokeGas)) + } + if m.MsgExecGas != 0 { + n += 1 + sovGashub(uint64(m.MsgExecGas)) + } if m.MsgSendGas != 0 { n += 1 + sovGashub(uint64(m.MsgSendGas)) } if m.MsgMultiSendGas != 0 { n += 1 + sovGashub(uint64(m.MsgMultiSendGas)) } + if m.MsgWithdrawDelegatorRewardGas != 0 { + n += 1 + sovGashub(uint64(m.MsgWithdrawDelegatorRewardGas)) + } + if m.MsgWithdrawValidatorCommissionGas != 0 { + n += 1 + sovGashub(uint64(m.MsgWithdrawValidatorCommissionGas)) + } + if m.MsgSetWithdrawAddressGas != 0 { + n += 1 + sovGashub(uint64(m.MsgSetWithdrawAddressGas)) + } + if m.MsgFundCommunityPoolGas != 0 { + n += 1 + sovGashub(uint64(m.MsgFundCommunityPoolGas)) + } + if m.MsgGrantAllowanceGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantAllowanceGas)) + } + if m.MsgRevokeAllowanceGas != 0 { + n += 1 + sovGashub(uint64(m.MsgRevokeAllowanceGas)) + } + if m.MsgSubmitProposalGas != 0 { + n += 1 + sovGashub(uint64(m.MsgSubmitProposalGas)) + } + if m.MsgVoteGas != 0 { + n += 1 + sovGashub(uint64(m.MsgVoteGas)) + } + if m.MsgVoteWeightedGas != 0 { + n += 2 + sovGashub(uint64(m.MsgVoteWeightedGas)) + } + if m.MsgDepositGas != 0 { + n += 2 + sovGashub(uint64(m.MsgDepositGas)) + } + if m.MsgUnjailGas != 0 { + n += 2 + sovGashub(uint64(m.MsgUnjailGas)) + } + if m.MsgImpeachGas != 0 { + n += 2 + sovGashub(uint64(m.MsgImpeachGas)) + } + if m.MsgEditValidatorGas != 0 { + n += 2 + sovGashub(uint64(m.MsgEditValidatorGas)) + } + if m.MsgDelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgDelegateGas)) + } + if m.MsgUndelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgUndelegateGas)) + } + if m.MsgBeginRedelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgBeginRedelegateGas)) + } + if m.MsgCancelUnbondingDelegationGas != 0 { + n += 2 + sovGashub(uint64(m.MsgCancelUnbondingDelegationGas)) + } return n } @@ -306,9 +741,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantGas", wireType) } - m.MsgSendGas = 0 + m.MsgGrantGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -318,16 +753,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgSendGas |= uint64(b&0x7F) << shift + m.MsgGrantGas |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeGas", wireType) } - m.MsgMultiSendGas = 0 + m.MsgRevokeGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -337,7 +772,387 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgMultiSendGas |= uint64(b&0x7F) << shift + m.MsgRevokeGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgExecGas", wireType) + } + m.MsgExecGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgExecGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) + } + m.MsgSendGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSendGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendGas", wireType) + } + m.MsgMultiSendGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgMultiSendGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawDelegatorRewardGas", wireType) + } + m.MsgWithdrawDelegatorRewardGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgWithdrawDelegatorRewardGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawValidatorCommissionGas", wireType) + } + m.MsgWithdrawValidatorCommissionGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgWithdrawValidatorCommissionGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSetWithdrawAddressGas", wireType) + } + m.MsgSetWithdrawAddressGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSetWithdrawAddressGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgFundCommunityPoolGas", wireType) + } + m.MsgFundCommunityPoolGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgFundCommunityPoolGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowanceGas", wireType) + } + m.MsgGrantAllowanceGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgGrantAllowanceGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeAllowanceGas", wireType) + } + m.MsgRevokeAllowanceGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgRevokeAllowanceGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitProposalGas", wireType) + } + m.MsgSubmitProposalGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSubmitProposalGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteGas", wireType) + } + m.MsgVoteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgVoteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteWeightedGas", wireType) + } + m.MsgVoteWeightedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgVoteWeightedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgDepositGas", wireType) + } + m.MsgDepositGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgDepositGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgUnjailGas", wireType) + } + m.MsgUnjailGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgUnjailGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgImpeachGas", wireType) + } + m.MsgImpeachGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgImpeachGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgEditValidatorGas", wireType) + } + m.MsgEditValidatorGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgEditValidatorGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgDelegateGas", wireType) + } + m.MsgDelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgDelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 22: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgUndelegateGas", wireType) + } + m.MsgUndelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgUndelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 23: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgBeginRedelegateGas", wireType) + } + m.MsgBeginRedelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgBeginRedelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 24: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgCancelUnbondingDelegationGas", wireType) + } + m.MsgCancelUnbondingDelegationGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgCancelUnbondingDelegationGas |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 8274b1151a..581d84552a 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -10,31 +10,94 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 - DefaultMsgSendGas uint64 = 1e6 - DefaultMsgMultiSendGas uint64 = 8e5 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 + DefaultMsgGrantGas uint64 = 1e5 + DefaultMsgRevokeGas uint64 = 1e5 + DefaultMsgExecGas uint64 = 1e5 + DefaultMsgSendGas uint64 = 1e5 + DefaultMsgMultiSendGas uint64 = 1e5 + DefaultMsgWithdrawDelegatorRewardGas uint64 = 1e5 + DefaultMsgWithdrawValidatorCommissionGas uint64 = 1e5 + DefaultMsgSetWithdrawAddressGas uint64 = 1e5 + DefaultMsgFundCommunityPoolGas uint64 = 1e5 + DefaultMsgGrantAllowanceGas uint64 = 1e5 + DefaultMsgRevokeAllowanceGas uint64 = 1e5 + DefaultMsgSubmitProposalGas uint64 = 1e5 + DefaultMsgVoteGas uint64 = 1e5 + DefaultMsgVoteWeightedGas uint64 = 1e5 + DefaultMsgDepositGas uint64 = 1e5 + DefaultMsgUnjailGas uint64 = 1e5 + DefaultMsgImpeachGas uint64 = 1e5 + DefaultMsgEditValidatorGas uint64 = 1e5 + DefaultMsgDelegateGas uint64 = 1e5 + DefaultMsgUndelegateGas uint64 = 1e5 + DefaultMsgBeginRedelegateGas uint64 = 1e5 + DefaultMsgCancelUnbondingDelegationGas uint64 = 1e5 ) // Parameter keys var ( - KeyMaxTxSize = []byte("MaxTxSize") - KeyMinGasPerByte = []byte("MinGasPerByte") - KeyMsgSendGas = []byte("MsgSendGas") - KeyMsgMultiSendGas = []byte("MsgMultiSendGas") + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMsgGrantGas = []byte("MsgGrantGas") + KeyMsgRevokeGas = []byte("MsgRevokeGas") + KeyMsgExecGas = []byte("MsgExecGas") + KeyMsgSendGas = []byte("MsgSendGas") + KeyMsgMultiSendGas = []byte("MsgMultiSendGas") + KeyMsgWithdrawDelegatorRewardGas = []byte("MsgWithdrawDelegatorRewardGas") + KeyMsgWithdrawValidatorCommissionGas = []byte("MsgWithdrawValidatorCommissionGas") + KeyMsgSetWithdrawAddressGas = []byte("MsgSetWithdrawAddressGas") + KeyMsgFundCommunityPoolGas = []byte("MsgFundCommunityPoolGas") + KeyMsgGrantAllowanceGas = []byte("MsgGrantAllowanceGas") + KeyMsgRevokeAllowanceGas = []byte("MsgRevokeAllowanceGas") + KeyMsgSubmitProposalGas = []byte("MsgSubmitProposalGas") + KeyMsgVoteGas = []byte("MsgVoteGas") + KeyMsgVoteWeightedGas = []byte("MsgVoteWeightedGas") + KeyMsgDepositGas = []byte("MsgDepositGas") + KeyMsgUnjailGas = []byte("MsgUnjailGas") + KeyMsgImpeachGas = []byte("MsgImpeachGas") + KeyMsgEditValidatorGas = []byte("MsgEditValidatorGas") + KeyMsgDelegateGas = []byte("MsgDelegateGas") + KeyMsgUndelegateGas = []byte("MsgUndelegateGas") + KeyMsgBeginRedelegateGas = []byte("MsgBeginRedelegateGas") + KeyMsgCancelUnbondingDelegationGas = []byte("MsgCancelUnbondingDelegationGas") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte, msgSendGas, msgMultiSendGas uint64, + maxTxSize, minGasPerByte, msgGrantGas, msgRevokeGas, msgExecGas, msgSendGas, msgMultiSendGas, msgWithdrawDelegatorRewardGas, + msgWithdrawValidatorCommissionGas, msgSetWithdrawAddressGas, msgFundCommunityPoolGas, msgGrantAllowanceGas, msgRevokeAllowanceGas, + msgSubmitProposalGas, msgVoteGas, msgVoteWeightedGas, msgDepositGas, msgUnjailGas, msgImpeachGas, msgEditValidatorGas, + msgDelegateGas, msgUndelegateGas, msgBeginRedelegateGas, msgCancelUnbondingDelegationGas uint64, ) Params { return Params{ - MaxTxSize: maxTxSize, - MinGasPerByte: minGasPerByte, - MsgSendGas: msgSendGas, - MsgMultiSendGas: msgMultiSendGas, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + MsgGrantGas: msgGrantGas, + MsgRevokeGas: msgRevokeGas, + MsgExecGas: msgExecGas, + MsgSendGas: msgSendGas, + MsgMultiSendGas: msgMultiSendGas, + MsgWithdrawDelegatorRewardGas: msgWithdrawDelegatorRewardGas, + MsgWithdrawValidatorCommissionGas: msgWithdrawValidatorCommissionGas, + MsgSetWithdrawAddressGas: msgSetWithdrawAddressGas, + MsgFundCommunityPoolGas: msgFundCommunityPoolGas, + MsgGrantAllowanceGas: msgGrantAllowanceGas, + MsgRevokeAllowanceGas: msgRevokeAllowanceGas, + MsgSubmitProposalGas: msgSubmitProposalGas, + MsgVoteGas: msgVoteGas, + MsgVoteWeightedGas: msgVoteWeightedGas, + MsgDepositGas: msgDepositGas, + MsgUnjailGas: msgUnjailGas, + MsgImpeachGas: msgImpeachGas, + MsgEditValidatorGas: msgEditValidatorGas, + MsgDelegateGas: msgDelegateGas, + MsgUndelegateGas: msgUndelegateGas, + MsgBeginRedelegateGas: msgBeginRedelegateGas, + MsgCancelUnbondingDelegationGas: msgCancelUnbondingDelegationGas, } } @@ -49,18 +112,58 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgSendGas), - paramtypes.NewParamSetPair(KeyMsgMultiSendGas, &p.MsgMultiSendGas, validateMsgMultiSendGas), + paramtypes.NewParamSetPair(KeyMsgGrantGas, &p.MsgGrantGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgRevokeGas, &p.MsgRevokeGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgExecGas, &p.MsgExecGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgMultiSendGas, &p.MsgMultiSendGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgWithdrawDelegatorRewardGas, &p.MsgWithdrawDelegatorRewardGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgWithdrawValidatorCommissionGas, &p.MsgWithdrawValidatorCommissionGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSetWithdrawAddressGas, &p.MsgSetWithdrawAddressGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgFundCommunityPoolGas, &p.MsgFundCommunityPoolGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGrantAllowanceGas, &p.MsgGrantAllowanceGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgRevokeAllowanceGas, &p.MsgRevokeAllowanceGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSubmitProposalGas, &p.MsgSubmitProposalGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgVoteGas, &p.MsgVoteGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgVoteWeightedGas, &p.MsgVoteWeightedGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgDepositGas, &p.MsgDepositGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgUnjailGas, &p.MsgUnjailGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgImpeachGas, &p.MsgImpeachGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgEditValidatorGas, &p.MsgEditValidatorGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgDelegateGas, &p.MsgDelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgUndelegateGas, &p.MsgUndelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgBeginRedelegateGas, &p.MsgBeginRedelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgCancelUnbondingDelegationGas, &p.MsgCancelUnbondingDelegationGas, validateMsgGas), } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { return Params{ - MaxTxSize: DefaultMaxTxSize, - MinGasPerByte: DefaultMinGasPerByte, - MsgSendGas: DefaultMsgSendGas, - MsgMultiSendGas: DefaultMsgMultiSendGas, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + MsgGrantGas: DefaultMsgGrantGas, + MsgRevokeGas: DefaultMsgRevokeGas, + MsgExecGas: DefaultMsgExecGas, + MsgSendGas: DefaultMsgSendGas, + MsgMultiSendGas: DefaultMsgMultiSendGas, + MsgWithdrawDelegatorRewardGas: DefaultMsgWithdrawDelegatorRewardGas, + MsgWithdrawValidatorCommissionGas: DefaultMsgWithdrawValidatorCommissionGas, + MsgSetWithdrawAddressGas: DefaultMsgSetWithdrawAddressGas, + MsgFundCommunityPoolGas: DefaultMsgFundCommunityPoolGas, + MsgGrantAllowanceGas: DefaultMsgGrantAllowanceGas, + MsgRevokeAllowanceGas: DefaultMsgRevokeAllowanceGas, + MsgSubmitProposalGas: DefaultMsgSubmitProposalGas, + MsgVoteGas: DefaultMsgVoteGas, + MsgVoteWeightedGas: DefaultMsgVoteWeightedGas, + MsgDepositGas: DefaultMsgDepositGas, + MsgUnjailGas: DefaultMsgUnjailGas, + MsgImpeachGas: DefaultMsgImpeachGas, + MsgEditValidatorGas: DefaultMsgEditValidatorGas, + MsgDelegateGas: DefaultMsgDelegateGas, + MsgUndelegateGas: DefaultMsgUndelegateGas, + MsgBeginRedelegateGas: DefaultMsgBeginRedelegateGas, + MsgCancelUnbondingDelegationGas: DefaultMsgCancelUnbondingDelegationGas, } } @@ -96,7 +199,7 @@ func validateMinGasPerByte(i interface{}) error { return nil } -func validateMsgSendGas(i interface{}) error { +func validateMsgGas(i interface{}) error { v, ok := i.(uint64) if !ok { return fmt.Errorf("invalid parameter type: %T", i) @@ -109,19 +212,6 @@ func validateMsgSendGas(i interface{}) error { return nil } -func validateMsgMultiSendGas(i interface{}) error { - v, ok := i.(uint64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if v == 0 { - return fmt.Errorf("invalid msg multi send fee: %d", v) - } - - return nil -} - // Validate checks that the parameters have valid values. func (p Params) Validate() error { if err := validateMaxTxSize(p.MaxTxSize); err != nil { @@ -130,10 +220,70 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMsgSendGas(p.MsgSendGas); err != nil { + if err := validateMsgGas(p.MsgGrantGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgRevokeGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgExecGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgSendGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgMultiSendGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgWithdrawDelegatorRewardGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgWithdrawValidatorCommissionGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgSetWithdrawAddressGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgFundCommunityPoolGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgGrantAllowanceGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgRevokeAllowanceGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgSubmitProposalGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgVoteGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgVoteWeightedGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgDepositGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgUnjailGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgImpeachGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgEditValidatorGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgDelegateGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgUndelegateGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgBeginRedelegateGas); err != nil { return err } - if err := validateMsgMultiSendGas(p.MsgMultiSendGas); err != nil { + if err := validateMsgGas(p.MsgCancelUnbondingDelegationGas); err != nil { return err } diff --git a/x/genutil/client/cli/validate_genesis.go b/x/genutil/client/cli/validate_genesis.go index 519a5ae01f..beb94dde52 100644 --- a/x/genutil/client/cli/validate_genesis.go +++ b/x/genutil/client/cli/validate_genesis.go @@ -19,7 +19,7 @@ func ValidateGenesisCmd(mbm module.BasicManager) *cobra.Command { return &cobra.Command{ Use: "validate-genesis [file]", Args: cobra.RangeArgs(0, 1), - Short: "validates the genesis file at the default location or at the location passed as an arg", + Short: "Validates the genesis file at the default location or at the location passed as an arg", RunE: func(cmd *cobra.Command, args []string) (err error) { serverCtx := server.GetServerContextFromCmd(cmd) clientCtx := client.GetClientContextFromCmd(cmd) diff --git a/x/nft/client/cli/tx.go b/x/nft/client/cli/tx.go index 45320a97a4..b83f9c50c4 100644 --- a/x/nft/client/cli/tx.go +++ b/x/nft/client/cli/tx.go @@ -35,7 +35,7 @@ func NewCmdSend() *cobra.Command { cmd := &cobra.Command{ Use: "send [class-id] [nft-id] [receiver] --from [sender]", Args: cobra.ExactArgs(3), - Short: "transfer ownership of nft", + Short: "Transfer ownership of nft", Long: strings.TrimSpace(fmt.Sprintf(` $ %s tx %s send --from --chain-id `, version.AppName, nft.ModuleName), ), diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index 339b42fa79..2c7e227c71 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -55,7 +55,7 @@ func NewTxCmd() *cobra.Command { func NewEditValidatorCmd() *cobra.Command { cmd := &cobra.Command{ Use: "edit-validator", - Short: "edit an existing validator account", + Short: "Edit an existing validator account", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/upgrade/client/cli/query.go b/x/upgrade/client/cli/query.go index aebb5795b2..8c8cb43cbe 100644 --- a/x/upgrade/client/cli/query.go +++ b/x/upgrade/client/cli/query.go @@ -31,7 +31,7 @@ func GetQueryCmd() *cobra.Command { func GetCurrentPlanCmd() *cobra.Command { cmd := &cobra.Command{ Use: "plan", - Short: "get upgrade plan (if one exists)", + Short: "Get upgrade plan (if one exists)", Long: "Gets the currently scheduled upgrade plan, if one exists", Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { @@ -65,7 +65,7 @@ func GetCurrentPlanCmd() *cobra.Command { func GetAppliedPlanCmd() *cobra.Command { cmd := &cobra.Command{ Use: "applied [upgrade-name]", - Short: "block header for height at which a completed upgrade was applied", + Short: "Block header for height at which a completed upgrade was applied", Long: "If upgrade-name was previously executed on the chain, this returns the header for the block at which it was applied.\n" + "This helps a client determine which binary was valid over a given range of blocks, as well as more context to understand past migrations.", Args: cobra.ExactArgs(1), @@ -117,7 +117,7 @@ func GetAppliedPlanCmd() *cobra.Command { func GetModuleVersionsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "module_versions [optional module_name]", - Short: "get the list of module versions", + Short: "Get the list of module versions", Long: "Gets a list of module names and their respective consensus versions.\n" + "Following the command with a specific module name will return only\n" + "that module's information.", From ba37304d875a06ae83dfa5dbd1a801882fd7fdba Mon Sep 17 00:00:00 2001 From: Roshan Date: Tue, 3 Jan 2023 20:47:27 +0800 Subject: [PATCH 06/11] revert changes to the gas kvstore --- store/gaskv/store.go | 50 ++++++++++++++--------------- store/gaskv/store_test.go | 42 ++++++++++++------------ types/context.go | 7 ++-- x/group/internal/orm/testsupport.go | 4 +-- 4 files changed, 52 insertions(+), 51 deletions(-) diff --git a/store/gaskv/store.go b/store/gaskv/store.go index 5deab4db56..845e59cf93 100644 --- a/store/gaskv/store.go +++ b/store/gaskv/store.go @@ -33,12 +33,12 @@ func (gs *Store) GetStoreType() types.StoreType { // Implements KVStore. func (gs *Store) Get(key []byte) (value []byte) { - // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostFlat, types.GasReadCostFlatDesc) + gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostFlat, types.GasReadCostFlatDesc) value = gs.parent.Get(key) - // // TODO overflow-safe math? - // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasReadPerByteDesc) - // gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasReadPerByteDesc) + // TODO overflow-safe math? + gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasReadPerByteDesc) + gs.gasMeter.ConsumeGas(gs.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasReadPerByteDesc) return value } @@ -47,23 +47,23 @@ func (gs *Store) Get(key []byte) (value []byte) { func (gs *Store) Set(key []byte, value []byte) { types.AssertValidKey(key) types.AssertValidValue(value) - // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc) - // // TODO overflow-safe math? - // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(key)), types.GasWritePerByteDesc) - // gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(value)), types.GasWritePerByteDesc) + gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostFlat, types.GasWriteCostFlatDesc) + // TODO overflow-safe math? + gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(key)), types.GasWritePerByteDesc) + gs.gasMeter.ConsumeGas(gs.gasConfig.WriteCostPerByte*types.Gas(len(value)), types.GasWritePerByteDesc) gs.parent.Set(key, value) } // Implements KVStore. func (gs *Store) Has(key []byte) bool { - // gs.gasMeter.ConsumeGas(gs.gasConfig.HasCost, types.GasHasDesc) + gs.gasMeter.ConsumeGas(gs.gasConfig.HasCost, types.GasHasDesc) return gs.parent.Has(key) } // Implements KVStore. func (gs *Store) Delete(key []byte) { - // // charge gas to prevent certain attack vectors even though space is being freed - // gs.gasMeter.ConsumeGas(gs.gasConfig.DeleteCost, types.GasDeleteDesc) + // charge gas to prevent certain attack vectors even though space is being freed + gs.gasMeter.ConsumeGas(gs.gasConfig.DeleteCost, types.GasDeleteDesc) gs.parent.Delete(key) } @@ -106,7 +106,7 @@ func (gs *Store) iterator(start, end []byte, ascending bool) types.Iterator { } gi := newGasIterator(gs.gasMeter, gs.gasConfig, parent) - // gi.(*gasIterator).consumeSeekGas() + gi.(*gasIterator).consumeSeekGas() return gi } @@ -139,7 +139,7 @@ func (gi *gasIterator) Valid() bool { // in the iterator. It incurs a flat gas cost for seeking and a variable gas // cost based on the current value's length if the iterator is valid. func (gi *gasIterator) Next() { - // gi.consumeSeekGas() + gi.consumeSeekGas() gi.parent.Next() } @@ -167,15 +167,15 @@ func (gi *gasIterator) Error() error { return gi.parent.Error() } -// // consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost -// // based on the current value's length. -// func (gi *gasIterator) consumeSeekGas() { -// if gi.Valid() { -// key := gi.Key() -// value := gi.Value() -// -// gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasValuePerByteDesc) -// gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) -// } -// gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) -// } +// consumeSeekGas consumes on each iteration step a flat gas cost and a variable gas cost +// based on the current value's length. +func (gi *gasIterator) consumeSeekGas() { + if gi.Valid() { + key := gi.Key() + value := gi.Value() + + gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(key)), types.GasValuePerByteDesc) + gi.gasMeter.ConsumeGas(gi.gasConfig.ReadCostPerByte*types.Gas(len(value)), types.GasValuePerByteDesc) + } + gi.gasMeter.ConsumeGas(gi.gasConfig.IterNextCostFlat, types.GasIterNextCostFlatDesc) +} diff --git a/store/gaskv/store_test.go b/store/gaskv/store_test.go index acdd1f63c0..2401a9805d 100644 --- a/store/gaskv/store_test.go +++ b/store/gaskv/store_test.go @@ -35,7 +35,7 @@ func TestGasKVStoreBasic(t *testing.T) { require.Equal(t, valFmt(1), st.Get(keyFmt(1))) st.Delete(keyFmt(1)) require.Empty(t, st.Get(keyFmt(1)), "Expected `key1` to be empty") - // require.Equal(t, meter.GasConsumed(), types.Gas(6858)) + require.Equal(t, meter.GasConsumed(), types.Gas(6858)) } func TestGasKVStoreIterator(t *testing.T) { @@ -74,16 +74,16 @@ func TestGasKVStoreIterator(t *testing.T) { vb := iterator.Value() require.Equal(t, vb, valFmt(2)) iterator.Next() - // require.Equal(t, types.Gas(14565), meter.GasConsumed()) + require.Equal(t, types.Gas(14565), meter.GasConsumed()) kc := iterator.Key() require.Equal(t, kc, keyFmt(3)) vc := iterator.Value() require.Equal(t, vc, valFmt(0)) iterator.Next() - // require.Equal(t, types.Gas(14667), meter.GasConsumed()) + require.Equal(t, types.Gas(14667), meter.GasConsumed()) require.False(t, iterator.Valid()) require.Panics(t, iterator.Next) - // require.Equal(t, types.Gas(14697), meter.GasConsumed()) + require.Equal(t, types.Gas(14697), meter.GasConsumed()) require.NoError(t, iterator.Error()) reverseIterator := st.ReverseIterator(nil, nil) @@ -100,22 +100,22 @@ func TestGasKVStoreIterator(t *testing.T) { reverseIterator.Next() require.False(t, reverseIterator.Valid()) require.Panics(t, reverseIterator.Next) - // require.Equal(t, types.Gas(15135), meter.GasConsumed()) + require.Equal(t, types.Gas(15135), meter.GasConsumed()) } -// func TestGasKVStoreOutOfGasSet(t *testing.T) { -// mem := dbadapter.Store{DB: dbm.NewMemDB()} -// meter := types.NewGasMeter(0) -// st := gaskv.NewStore(mem, meter, types.KVGasConfig()) -// require.Panics(t, func() { st.Set(keyFmt(1), valFmt(1)) }, "Expected out-of-gas") -// } -// -// func TestGasKVStoreOutOfGasIterator(t *testing.T) { -// mem := dbadapter.Store{DB: dbm.NewMemDB()} -// meter := types.NewGasMeter(20000) -// st := gaskv.NewStore(mem, meter, types.KVGasConfig()) -// st.Set(keyFmt(1), valFmt(1)) -// iterator := st.Iterator(nil, nil) -// iterator.Next() -// require.Panics(t, func() { iterator.Value() }, "Expected out-of-gas") -// } +func TestGasKVStoreOutOfGasSet(t *testing.T) { + mem := dbadapter.Store{DB: dbm.NewMemDB()} + meter := types.NewGasMeter(0) + st := gaskv.NewStore(mem, meter, types.KVGasConfig()) + require.Panics(t, func() { st.Set(keyFmt(1), valFmt(1)) }, "Expected out-of-gas") +} + +func TestGasKVStoreOutOfGasIterator(t *testing.T) { + mem := dbadapter.Store{DB: dbm.NewMemDB()} + meter := types.NewGasMeter(20000) + st := gaskv.NewStore(mem, meter, types.KVGasConfig()) + st.Set(keyFmt(1), valFmt(1)) + iterator := st.Iterator(nil, nil) + iterator.Next() + require.Panics(t, func() { iterator.Value() }, "Expected out-of-gas") +} diff --git a/types/context.go b/types/context.go index c05dec1e2b..7479f15c1f 100644 --- a/types/context.go +++ b/types/context.go @@ -10,7 +10,6 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/store/gaskv" storetypes "github.com/cosmos/cosmos-sdk/store/types" ) @@ -266,12 +265,14 @@ func (c Context) Value(key interface{}) interface{} { // KVStore fetches a KVStore from the MultiStore. func (c Context) KVStore(key storetypes.StoreKey) KVStore { - return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.KVGasConfig()) + // return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.KVGasConfig()) + return c.MultiStore().GetKVStore(key) } // TransientStore fetches a TransientStore from the MultiStore. func (c Context) TransientStore(key storetypes.StoreKey) KVStore { - return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.TransientGasConfig()) + // return gaskv.NewStore(c.MultiStore().GetKVStore(key), c.GasMeter(), storetypes.TransientGasConfig()) + return c.MultiStore().GetKVStore(key) } // CacheContext returns a new Context with the multi-store cached and a new diff --git a/x/group/internal/orm/testsupport.go b/x/group/internal/orm/testsupport.go index 1b4a684789..fd2d05f4cb 100644 --- a/x/group/internal/orm/testsupport.go +++ b/x/group/internal/orm/testsupport.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/cosmos/cosmos-sdk/store" - "github.com/cosmos/cosmos-sdk/store/gaskv" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" dbm "github.com/tendermint/tm-db" @@ -86,7 +85,8 @@ func NewGasCountingMockContext() *GasCountingMockContext { } func (g GasCountingMockContext) KVStore(store sdk.KVStore) sdk.KVStore { - return gaskv.NewStore(store, g.GasMeter, storetypes.KVGasConfig()) + // return gaskv.NewStore(store, g.GasMeter, storetypes.KVGasConfig()) + return store } func (g GasCountingMockContext) GasConsumed() storetypes.Gas { From 8ee9745ea1c72acce1c19c053cf4598d60834b1d Mon Sep 17 00:00:00 2001 From: Roshan Date: Wed, 4 Jan 2023 18:53:52 +0800 Subject: [PATCH 07/11] fix review comments --- proto/cosmos/gashub/v1alpha1/gashub.proto | 26 +- x/auth/ante/msg_gas.go | 11 +- x/auth/ante/msg_gas_test.go | 2 +- x/authz/keeper/keeper.go | 10 +- x/feegrant/fees.go | 2 +- x/feegrant/filtered_fee.go | 16 +- x/gashub/simulation/genesis.go | 10 +- x/gashub/simulation/genesis_test.go | 3 +- x/gashub/simulation/params.go | 4 +- x/gashub/types/gas_calculator.go | 285 +++---- x/gashub/types/gashub.pb.go | 878 ++-------------------- x/gashub/types/params.go | 213 +----- x/staking/types/authz.go | 10 +- 13 files changed, 242 insertions(+), 1228 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 2e739f091d..1a90e609fa 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -12,26 +12,8 @@ message Params { uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - uint64 msg_grant_gas = 3 [(gogoproto.customname) = "MsgGrantGas"]; - uint64 msg_revoke_gas = 4 [(gogoproto.customname) = "MsgRevokeGas"]; - uint64 msg_exec_gas = 5 [(gogoproto.customname) = "MsgExecGas"]; - uint64 msg_send_gas = 6 [(gogoproto.customname) = "MsgSendGas"]; - uint64 msg_multi_send_gas = 7 [(gogoproto.customname) = "MsgMultiSendGas"]; - uint64 msg_withdraw_delegator_reward_gas = 8 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"]; - uint64 msg_withdraw_validator_commission_gas = 9 [(gogoproto.customname) = "MsgWithdrawValidatorCommissionGas"]; - uint64 msg_set_withdraw_address_gas = 10 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"]; - uint64 msg_fund_community_pool_gas = 11 [(gogoproto.customname) = "MsgFundCommunityPoolGas"]; - uint64 msg_grant_allowance_gas = 12 [(gogoproto.customname) = "MsgGrantAllowanceGas"]; - uint64 msg_revoke_allowance_gas = 13 [(gogoproto.customname) = "MsgRevokeAllowanceGas"]; - uint64 msg_submit_proposal_gas = 14 [(gogoproto.customname) = "MsgSubmitProposalGas"]; - uint64 msg_vote_gas = 15 [(gogoproto.customname) = "MsgVoteGas"]; - uint64 msg_vote_weighted_gas = 16 [(gogoproto.customname) = "MsgVoteWeightedGas"]; - uint64 msg_deposit_gas = 17 [(gogoproto.customname) = "MsgDepositGas"]; - uint64 msg_unjail_gas = 18 [(gogoproto.customname) = "MsgUnjailGas"]; - uint64 msg_impeach_gas = 19 [(gogoproto.customname) = "MsgImpeachGas"]; - uint64 msg_edit_validator_gas = 20 [(gogoproto.customname) = "MsgEditValidatorGas"]; - uint64 msg_delegate_gas = 21 [(gogoproto.customname) = "MsgDelegateGas"]; - uint64 msg_undelegate_gas = 22 [(gogoproto.customname) = "MsgUndelegateGas"]; - uint64 msg_begin_redelegate_gas = 23 [(gogoproto.customname) = "MsgBeginRedelegateGas"]; - uint64 msg_cancel_unbonding_delegation_gas = 24 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"]; + uint64 fixed_msg_gas = 3 [(gogoproto.customname) = "FixedMsgGas"]; + uint64 msg_grant_per_item_gas = 4 [(gogoproto.customname) = "MsgGrantPerItemGas"]; + uint64 msg_multi_send_per_item_gas = 5 [(gogoproto.customname) = "MsgMultiSendPerItemGas"]; + uint64 msg_grant_allowance_per_item_gas = 6 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"]; } diff --git a/x/auth/ante/msg_gas.go b/x/auth/ante/msg_gas.go index c22ffcae5e..1be8ee335b 100644 --- a/x/auth/ante/msg_gas.go +++ b/x/auth/ante/msg_gas.go @@ -4,7 +4,6 @@ import ( "fmt" "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/legacy" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -113,7 +112,7 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - if gasByTxSize >= gasByMsgType { + if gasByTxSize > gasByMsgType { ctx.GasMeter().ConsumeGas(gasByTxSize, "tx bytes length") } else { ctx.GasMeter().ConsumeGas(gasByMsgType, "msg type") @@ -124,14 +123,18 @@ func (cmfg ConsumeMsgGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula func (cmfg ConsumeMsgGasDecorator) getMsgGas(params types.Params, tx sdk.Tx) (uint64, error) { msgs := tx.GetMsgs() - var totalGas uint64 + totalGas := uint64(0) for _, msg := range msgs { feeCalcGen := types.GetGasCalculatorGen(sdk.MsgTypeURL(msg)) if feeCalcGen == nil { return 0, fmt.Errorf("failed to find fee calculator") } feeCalc := feeCalcGen(params) - totalGas += feeCalc(msg) + gas, err := feeCalc(msg) + if err != nil { + return 0, err + } + totalGas = totalGas + gas } return totalGas, nil } diff --git a/x/auth/ante/msg_gas_test.go b/x/auth/ante/msg_gas_test.go index 2ec534a828..3f2e201500 100644 --- a/x/auth/ante/msg_gas_test.go +++ b/x/auth/ante/msg_gas_test.go @@ -48,7 +48,7 @@ func (suite *AnteTestSuite) TestMsgGas() { } testCases := []testCase{ {"MsgSend", msgSend, 100000}, - {"MsgMultiSend", msgMultiSend, 300000}, + {"MsgMultiSend", msgMultiSend, 400000}, } for _, tc := range testCases { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index c44555f4dc..63f7714b0a 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -19,10 +19,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -// // TODO: Revisit this once we have propoer gas fee framework. -// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, -// // https://github.com/cosmos/cosmos-sdk/discussions/9072 -// const gasCostPerIteration = uint64(20) +// TODO: Revisit this once we have propoer gas fee framework. +// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, +// https://github.com/cosmos/cosmos-sdk/discussions/9072 +const gasCostPerIteration = uint64(20) type Keeper struct { storeKey storetypes.StoreKey @@ -359,7 +359,7 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran queueItems := queueItem.MsgTypeUrls for index, typeURL := range queueItems { - // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") if typeURL == msgType { end := len(queueItem.MsgTypeUrls) - 1 diff --git a/x/feegrant/fees.go b/x/feegrant/fees.go index 9b2c033386..6bc9a4a797 100644 --- a/x/feegrant/fees.go +++ b/x/feegrant/fees.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// FeeAllowance implementations are tied to a given fee delegator and delegatee, +// FeeAllowanceI implementations are tied to a given fee delegator and delegatee, // and are used to enforce fee grant limits. type FeeAllowanceI interface { // Accept can use fee payment requested as well as timestamp of the current block diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 2658f1064f..e03ce820e0 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -10,11 +10,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// // TODO: Revisit this once we have propoer gas fee framework. -// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -// const ( -// gasCostPerIteration = uint64(10) -// ) +// TODO: Revisit this once we have propoer gas fee framework. +// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +const ( + gasCostPerIteration = uint64(10) +) var ( _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) @@ -27,7 +27,7 @@ func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error return unpacker.UnpackAny(a.Allowance, &allowance) } -// NewAllowedMsgFeeAllowance creates new filtered fee allowance. +// NewAllowedMsgAllowance creates new filtered fee allowance. func NewAllowedMsgAllowance(allowance FeeAllowanceI, allowedMsgs []string) (*AllowedMsgAllowance, error) { msg, ok := allowance.(proto.Message) if !ok { @@ -88,7 +88,7 @@ func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk. func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx sdk.Context) map[string]bool { msgsMap := make(map[string]bool, len(a.AllowedMessages)) for _, msg := range a.AllowedMessages { - // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") msgsMap[msg] = true } @@ -99,7 +99,7 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx sdk.Context, msgs []sdk.Msg msgsMap := a.allowedMsgsToMap(ctx) for _, msg := range msgs { - // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") if !msgsMap[sdk.MsgTypeURL(msg)] { return false } diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index 3432444206..2f5d7c3869 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -14,7 +14,7 @@ import ( const ( MaxTxSize = "max_tx_size" MinGasPerByte = "min_gas_per_byte" - MsgGas = "msg_gas" + FixedMsgGas = "fixed_msg_gas" ) // GenMaxTxSize randomized MaxTxSize @@ -46,13 +46,13 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) - var msgGas uint64 + var fixedMsgGas uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, MsgGas, &msgGas, simState.Rand, - func(r *rand.Rand) { msgGas = GenMsgGas(r) }, + simState.Cdc, FixedMsgGas, &fixedMsgGas, simState.Rand, + func(r *rand.Rand) { fixedMsgGas = GenMsgGas(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas) + params := types.NewParams(maxTxSize, minGasPerByte, fixedMsgGas, fixedMsgGas, fixedMsgGas, fixedMsgGas) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 1da83d0bef..7a171c0911 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -41,6 +41,5 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgSendGas) - require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgMultiSendGas) + require.Equal(t, uint64(2803300), gashubGenesis.Params.FixedMsgGas) } diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index 03d04e5d52..70a561c639 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -12,14 +12,14 @@ import ( ) const ( - keyMsgSendGas = "MsgSendGas" + keyFixedMsgGas = "FixedMsgGas" ) // ParamChanges defines the parameters that can be modified by param change proposals // on the simulation func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, keyMsgSendGas, + simulation.NewSimParamChange(types.ModuleName, keyFixedMsgGas, func(r *rand.Rand) string { return fmt.Sprintf("%d", GenMsgGas(r)) }, diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index bbf2cb39b3..c117f4d496 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -1,6 +1,10 @@ package types import ( + "fmt" + + "cosmossdk.io/errors" + "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/authz" bank "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -12,12 +16,14 @@ import ( ) type ( - GasCalculator func(msg types.Msg) uint64 + GasCalculator func(msg types.Msg) (uint64, error) GasCalculatorGenerator func(params Params) GasCalculator ) var calculatorsGen = make(map[string]GasCalculatorGenerator) +var ErrInvalidMsgGas = fmt.Errorf("msg gas param is invalid") + func RegisterCalculatorGen(msgType string, feeCalcGen GasCalculatorGenerator) { calculatorsGen[msgType] = feeCalcGen } @@ -27,221 +33,126 @@ func GetGasCalculatorGen(msgType string) GasCalculatorGenerator { } func FixedGasCalculator(amount uint64) GasCalculator { - return func(msg types.Msg) uint64 { - return amount + return func(msg types.Msg) (uint64, error) { + if amount == 0 { + return 0, errors.Wrapf(ErrInvalidMsgGas, "msg type: %s", types.MsgTypeURL(msg)) + } + return amount, nil } } -func MultiSendCalculator(amount uint64) GasCalculator { - return func(msg types.Msg) uint64 { - msgMultiSend := msg.(*bank.MsgMultiSend) +func GrantCalculator(fixedGas, gasPerItem uint64) GasCalculator { + return func(msg types.Msg) (uint64, error) { + if fixedGas == 0 || gasPerItem == 0 { + return 0, errors.Wrapf(ErrInvalidMsgGas, "msg type: %s", types.MsgTypeURL(msg)) + } + + msgGrant := msg.(*authz.MsgGrant) var num int - if len(msgMultiSend.Inputs) > len(msgMultiSend.Outputs) { - num = len(msgMultiSend.Inputs) - } else { - num = len(msgMultiSend.Outputs) + authorization, err := msgGrant.GetAuthorization() + if err != nil { + return 0, err + } + switch authorization := authorization.(type) { + case *staking.StakeAuthorization: + allowList := authorization.GetAllowList().GetAddress() + denyList := authorization.GetDenyList().GetAddress() + num = len(allowList) + len(denyList) + case *bank.SendAuthorization: + coins := authorization.SpendLimit + num = len(coins) } - return uint64(num) * amount - } -} -var msgGrantGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgGrantGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgGrantGas) + totalGas := fixedGas + uint64(num)*gasPerItem + return totalGas, nil } - return FixedGasCalculator(msgGas) } -var msgRevokeGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgRevokeGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgRevokeGas) - } - return FixedGasCalculator(msgGas) -} +func MultiSendCalculator(fixedGas, gasPerItem uint64) GasCalculator { + return func(msg types.Msg) (uint64, error) { + if fixedGas == 0 || gasPerItem == 0 { + return 0, errors.Wrapf(ErrInvalidMsgGas, "msg type: %s", types.MsgTypeURL(msg)) + } -var msgExecGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgExecGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgExecGas) + msgMultiSend := msg.(*bank.MsgMultiSend) + var num int + if len(msgMultiSend.Inputs) > len(msgMultiSend.Outputs) { + num = len(msgMultiSend.Inputs) + } else { + num = len(msgMultiSend.Outputs) + } + totalGas := fixedGas + uint64(num)*gasPerItem + return totalGas, nil } - return FixedGasCalculator(msgGas) } -var msgSendGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgSendGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgSendGas) - } - return FixedGasCalculator(msgGas) -} +func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { + return func(msg types.Msg) (uint64, error) { + if fixedGas == 0 || gasPerItem == 0 { + return 0, errors.Wrapf(ErrInvalidMsgGas, "msg type: %s", types.MsgTypeURL(msg)) + } -var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgMultiSendGas() - if msgGas == 0 { - return MultiSendCalculator(DefaultMsgSendGas) - } - return MultiSendCalculator(msgGas) -} + msgGrantAllowance := msg.(*feegrant.MsgGrantAllowance) + var num int + feeAllowance, err := msgGrantAllowance.GetFeeAllowanceI() + if err != nil { + return 0, err + } + switch feeAllowance := feeAllowance.(type) { + case *feegrant.AllowedMsgAllowance: + allowedMsg := feeAllowance.AllowedMessages + num = len(allowedMsg) + } -var msgWithdrawDelegatorRewardGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgWithdrawDelegatorRewardGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgWithdrawDelegatorRewardGas) + totalGas := fixedGas + uint64(num)*gasPerItem + return totalGas, nil } - return FixedGasCalculator(msgGas) } -var msgWithdrawValidatorCommissionGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgWithdrawValidatorCommissionGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgWithdrawValidatorCommissionGas) - } - return FixedGasCalculator(msgGas) +var fixedMsgGasCalculatorGen = func(params Params) GasCalculator { + fixedGas := params.GetFixedMsgGas() + return FixedGasCalculator(fixedGas) } -var msgSetWithdrawAddressGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgSetWithdrawAddressGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgSetWithdrawAddressGas) - } - return FixedGasCalculator(msgGas) +var msgGrantGasCalculatorGen = func(params Params) GasCalculator { + fixedGas := params.GetFixedMsgGas() + gasPerItem := params.GetMsgGrantPerItemGas() + return GrantCalculator(fixedGas, gasPerItem) } -var msgFundCommunityPoolGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgFundCommunityPoolGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgFundCommunityPoolGas) - } - return FixedGasCalculator(msgGas) +var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { + fixedGas := params.GetFixedMsgGas() + gasPerItem := params.GetMsgMultiSendPerItemGas() + return MultiSendCalculator(fixedGas, gasPerItem) } var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgGrantAllowanceGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgGrantAllowanceGas) - } - return FixedGasCalculator(msgGas) -} - -var msgRevokeAllowanceGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgRevokeAllowanceGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgRevokeAllowanceGas) - } - return FixedGasCalculator(msgGas) -} - -var msgSubmitProposalGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgSubmitProposalGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgSubmitProposalGas) - } - return FixedGasCalculator(msgGas) -} - -var msgVoteGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgVoteGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgVoteGas) - } - return FixedGasCalculator(msgGas) -} - -var msgVoteWeightedGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgVoteWeightedGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgVoteWeightedGas) - } - return FixedGasCalculator(msgGas) -} - -var msgDepositGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgDepositGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgDepositGas) - } - return FixedGasCalculator(msgGas) -} - -var msgUnjailGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgUnjailGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgUnjailGas) - } - return FixedGasCalculator(msgGas) -} - -var msgImpeachGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgImpeachGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgImpeachGas) - } - return FixedGasCalculator(msgGas) -} - -var msgEditValidatorGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgEditValidatorGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgEditValidatorGas) - } - return FixedGasCalculator(msgGas) -} - -var msgDelegateGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgDelegateGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgDelegateGas) - } - return FixedGasCalculator(msgGas) -} - -var msgUndelegateGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgUndelegateGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgUndelegateGas) - } - return FixedGasCalculator(msgGas) -} - -var msgBeginRedelegateGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgBeginRedelegateGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgBeginRedelegateGas) - } - return FixedGasCalculator(msgGas) -} - -var msgCancelUnbondingDelegationGasCalculatorGen = func(params Params) GasCalculator { - msgGas := params.GetMsgCancelUnbondingDelegationGas() - if msgGas == 0 { - return FixedGasCalculator(DefaultMsgCancelUnbondingDelegationGas) - } - return FixedGasCalculator(msgGas) + fixedGas := params.GetFixedMsgGas() + gasPerItem := params.GetMsgGrantAllowancePerItemGas() + return GrantAllowanceCalculator(fixedGas, gasPerItem) } func init() { RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgGrant{}), msgGrantGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), msgRevokeGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), msgExecGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), msgSendGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), fixedMsgGasCalculatorGen) RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), msgWithdrawDelegatorRewardGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), msgWithdrawValidatorCommissionGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), msgSetWithdrawAddressGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), msgFundCommunityPoolGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), fixedMsgGasCalculatorGen) RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgGrantAllowance{}), msgGrantAllowanceGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), msgRevokeAllowanceGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), msgSubmitProposalGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), msgVoteGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), msgVoteWeightedGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), msgDepositGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), msgUnjailGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), msgImpeachGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), msgEditValidatorGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), msgDelegateGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), msgUndelegateGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), msgBeginRedelegateGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), msgCancelUnbondingDelegationGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), fixedMsgGasCalculatorGen) } diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index 337ee00c6a..b9e207acbe 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -25,30 +25,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the gashub module. type Params struct { - MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` - MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - MsgGrantGas uint64 `protobuf:"varint,3,opt,name=msg_grant_gas,json=msgGrantGas,proto3" json:"msg_grant_gas,omitempty"` - MsgRevokeGas uint64 `protobuf:"varint,4,opt,name=msg_revoke_gas,json=msgRevokeGas,proto3" json:"msg_revoke_gas,omitempty"` - MsgExecGas uint64 `protobuf:"varint,5,opt,name=msg_exec_ga,json=msgExecGa,proto3" json:"msg_exec_ga,omitempty"` - MsgSendGas uint64 `protobuf:"varint,6,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` - MsgMultiSendGas uint64 `protobuf:"varint,7,opt,name=msg_multi_send_gas,json=msgMultiSendGas,proto3" json:"msg_multi_send_gas,omitempty"` - MsgWithdrawDelegatorRewardGas uint64 `protobuf:"varint,8,opt,name=msg_withdraw_delegator_reward_gas,json=msgWithdrawDelegatorRewardGas,proto3" json:"msg_withdraw_delegator_reward_gas,omitempty"` - MsgWithdrawValidatorCommissionGas uint64 `protobuf:"varint,9,opt,name=msg_withdraw_validator_commission_gas,json=msgWithdrawValidatorCommissionGas,proto3" json:"msg_withdraw_validator_commission_gas,omitempty"` - MsgSetWithdrawAddressGas uint64 `protobuf:"varint,10,opt,name=msg_set_withdraw_address_gas,json=msgSetWithdrawAddressGas,proto3" json:"msg_set_withdraw_address_gas,omitempty"` - MsgFundCommunityPoolGas uint64 `protobuf:"varint,11,opt,name=msg_fund_community_pool_gas,json=msgFundCommunityPoolGas,proto3" json:"msg_fund_community_pool_gas,omitempty"` - MsgGrantAllowanceGas uint64 `protobuf:"varint,12,opt,name=msg_grant_allowance_gas,json=msgGrantAllowanceGas,proto3" json:"msg_grant_allowance_gas,omitempty"` - MsgRevokeAllowanceGas uint64 `protobuf:"varint,13,opt,name=msg_revoke_allowance_gas,json=msgRevokeAllowanceGas,proto3" json:"msg_revoke_allowance_gas,omitempty"` - MsgSubmitProposalGas uint64 `protobuf:"varint,14,opt,name=msg_submit_proposal_gas,json=msgSubmitProposalGas,proto3" json:"msg_submit_proposal_gas,omitempty"` - MsgVoteGas uint64 `protobuf:"varint,15,opt,name=msg_vote_gas,json=msgVoteGas,proto3" json:"msg_vote_gas,omitempty"` - MsgVoteWeightedGas uint64 `protobuf:"varint,16,opt,name=msg_vote_weighted_gas,json=msgVoteWeightedGas,proto3" json:"msg_vote_weighted_gas,omitempty"` - MsgDepositGas uint64 `protobuf:"varint,17,opt,name=msg_deposit_gas,json=msgDepositGas,proto3" json:"msg_deposit_gas,omitempty"` - MsgUnjailGas uint64 `protobuf:"varint,18,opt,name=msg_unjail_gas,json=msgUnjailGas,proto3" json:"msg_unjail_gas,omitempty"` - MsgImpeachGas uint64 `protobuf:"varint,19,opt,name=msg_impeach_gas,json=msgImpeachGas,proto3" json:"msg_impeach_gas,omitempty"` - MsgEditValidatorGas uint64 `protobuf:"varint,20,opt,name=msg_edit_validator_gas,json=msgEditValidatorGas,proto3" json:"msg_edit_validator_gas,omitempty"` - MsgDelegateGas uint64 `protobuf:"varint,21,opt,name=msg_delegate_gas,json=msgDelegateGas,proto3" json:"msg_delegate_gas,omitempty"` - MsgUndelegateGas uint64 `protobuf:"varint,22,opt,name=msg_undelegate_gas,json=msgUndelegateGas,proto3" json:"msg_undelegate_gas,omitempty"` - MsgBeginRedelegateGas uint64 `protobuf:"varint,23,opt,name=msg_begin_redelegate_gas,json=msgBeginRedelegateGas,proto3" json:"msg_begin_redelegate_gas,omitempty"` - MsgCancelUnbondingDelegationGas uint64 `protobuf:"varint,24,opt,name=msg_cancel_unbonding_delegation_gas,json=msgCancelUnbondingDelegationGas,proto3" json:"msg_cancel_unbonding_delegation_gas,omitempty"` + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + FixedMsgGas uint64 `protobuf:"varint,3,opt,name=fixed_msg_gas,json=fixedMsgGas,proto3" json:"fixed_msg_gas,omitempty"` + MsgGrantPerItemGas uint64 `protobuf:"varint,4,opt,name=msg_grant_per_item_gas,json=msgGrantPerItemGas,proto3" json:"msg_grant_per_item_gas,omitempty"` + MsgMultiSendPerItemGas uint64 `protobuf:"varint,5,opt,name=msg_multi_send_per_item_gas,json=msgMultiSendPerItemGas,proto3" json:"msg_multi_send_per_item_gas,omitempty"` + MsgGrantAllowancePerItemGas uint64 `protobuf:"varint,6,opt,name=msg_grant_allowance_per_item_gas,json=msgGrantAllowancePerItemGas,proto3" json:"msg_grant_allowance_per_item_gas,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -97,156 +79,30 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } -func (m *Params) GetMsgGrantGas() uint64 { +func (m *Params) GetFixedMsgGas() uint64 { if m != nil { - return m.MsgGrantGas + return m.FixedMsgGas } return 0 } -func (m *Params) GetMsgRevokeGas() uint64 { +func (m *Params) GetMsgGrantPerItemGas() uint64 { if m != nil { - return m.MsgRevokeGas + return m.MsgGrantPerItemGas } return 0 } -func (m *Params) GetMsgExecGas() uint64 { +func (m *Params) GetMsgMultiSendPerItemGas() uint64 { if m != nil { - return m.MsgExecGas + return m.MsgMultiSendPerItemGas } return 0 } -func (m *Params) GetMsgSendGas() uint64 { +func (m *Params) GetMsgGrantAllowancePerItemGas() uint64 { if m != nil { - return m.MsgSendGas - } - return 0 -} - -func (m *Params) GetMsgMultiSendGas() uint64 { - if m != nil { - return m.MsgMultiSendGas - } - return 0 -} - -func (m *Params) GetMsgWithdrawDelegatorRewardGas() uint64 { - if m != nil { - return m.MsgWithdrawDelegatorRewardGas - } - return 0 -} - -func (m *Params) GetMsgWithdrawValidatorCommissionGas() uint64 { - if m != nil { - return m.MsgWithdrawValidatorCommissionGas - } - return 0 -} - -func (m *Params) GetMsgSetWithdrawAddressGas() uint64 { - if m != nil { - return m.MsgSetWithdrawAddressGas - } - return 0 -} - -func (m *Params) GetMsgFundCommunityPoolGas() uint64 { - if m != nil { - return m.MsgFundCommunityPoolGas - } - return 0 -} - -func (m *Params) GetMsgGrantAllowanceGas() uint64 { - if m != nil { - return m.MsgGrantAllowanceGas - } - return 0 -} - -func (m *Params) GetMsgRevokeAllowanceGas() uint64 { - if m != nil { - return m.MsgRevokeAllowanceGas - } - return 0 -} - -func (m *Params) GetMsgSubmitProposalGas() uint64 { - if m != nil { - return m.MsgSubmitProposalGas - } - return 0 -} - -func (m *Params) GetMsgVoteGas() uint64 { - if m != nil { - return m.MsgVoteGas - } - return 0 -} - -func (m *Params) GetMsgVoteWeightedGas() uint64 { - if m != nil { - return m.MsgVoteWeightedGas - } - return 0 -} - -func (m *Params) GetMsgDepositGas() uint64 { - if m != nil { - return m.MsgDepositGas - } - return 0 -} - -func (m *Params) GetMsgUnjailGas() uint64 { - if m != nil { - return m.MsgUnjailGas - } - return 0 -} - -func (m *Params) GetMsgImpeachGas() uint64 { - if m != nil { - return m.MsgImpeachGas - } - return 0 -} - -func (m *Params) GetMsgEditValidatorGas() uint64 { - if m != nil { - return m.MsgEditValidatorGas - } - return 0 -} - -func (m *Params) GetMsgDelegateGas() uint64 { - if m != nil { - return m.MsgDelegateGas - } - return 0 -} - -func (m *Params) GetMsgUndelegateGas() uint64 { - if m != nil { - return m.MsgUndelegateGas - } - return 0 -} - -func (m *Params) GetMsgBeginRedelegateGas() uint64 { - if m != nil { - return m.MsgBeginRedelegateGas - } - return 0 -} - -func (m *Params) GetMsgCancelUnbondingDelegationGas() uint64 { - if m != nil { - return m.MsgCancelUnbondingDelegationGas + return m.MsgGrantAllowancePerItemGas } return 0 } @@ -260,64 +116,32 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 904 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x5f, 0x6f, 0x5b, 0x35, - 0x14, 0x6f, 0x60, 0x8c, 0xd5, 0x6d, 0xd2, 0xcc, 0x4d, 0x9b, 0x0b, 0xdb, 0x62, 0x4a, 0x35, 0x09, - 0x09, 0xad, 0x61, 0x9a, 0x84, 0xc4, 0xc4, 0x03, 0x4b, 0x3b, 0xaa, 0x49, 0x5c, 0x51, 0xa5, 0x6c, - 0x13, 0x08, 0xe9, 0xca, 0xc9, 0x35, 0x8e, 0x69, 0x7c, 0x1d, 0xae, 0x7d, 0x9b, 0x74, 0x9f, 0x82, - 0x47, 0x1e, 0xf7, 0x71, 0x78, 0xdc, 0x23, 0x4f, 0x57, 0xc8, 0x15, 0x12, 0x1f, 0x03, 0xf9, 0x38, - 0x4e, 0x72, 0x69, 0x19, 0x4f, 0xf1, 0x39, 0xe7, 0xf7, 0xe7, 0xda, 0x39, 0x3e, 0x46, 0xfb, 0x43, - 0xa5, 0xa5, 0xd2, 0x5d, 0x4e, 0xf5, 0xa8, 0x18, 0x74, 0xcf, 0x1f, 0xd2, 0xf1, 0x64, 0x44, 0x1f, - 0xce, 0xe3, 0x83, 0x49, 0xae, 0x8c, 0xc2, 0xbb, 0x1e, 0x74, 0x30, 0x4f, 0x06, 0xd0, 0x87, 0x2d, - 0xae, 0xb8, 0x02, 0x48, 0xd7, 0xad, 0x3c, 0xfa, 0xe3, 0xbf, 0xea, 0xe8, 0xe6, 0x09, 0xcd, 0xa9, - 0xd4, 0xf8, 0x01, 0xda, 0x90, 0x74, 0x96, 0x98, 0x59, 0xa2, 0xc5, 0x2b, 0x16, 0xd5, 0x3e, 0xaa, - 0x7d, 0x72, 0xa3, 0x57, 0xb7, 0x25, 0x59, 0x8f, 0xe9, 0xec, 0xbb, 0xd9, 0xa9, 0x78, 0xc5, 0xfa, - 0xeb, 0x32, 0x2c, 0xf1, 0x63, 0xd4, 0x94, 0x22, 0x4b, 0x38, 0xd5, 0xc9, 0x84, 0xe5, 0xc9, 0xe0, - 0xc2, 0xb0, 0xe8, 0x1d, 0xe0, 0xdc, 0xb6, 0x25, 0xa9, 0xc7, 0x22, 0x3b, 0xa6, 0xfa, 0x84, 0xe5, - 0xbd, 0x0b, 0xc3, 0xfa, 0x75, 0xb9, 0x1a, 0xe2, 0x47, 0xa8, 0x2e, 0x35, 0x4f, 0x78, 0x4e, 0x33, - 0xe3, 0x14, 0xa2, 0x77, 0x81, 0xb8, 0x65, 0x4b, 0xb2, 0x11, 0x6b, 0x7e, 0xec, 0xf2, 0xc7, 0x54, - 0xf7, 0x37, 0xe4, 0x32, 0xc0, 0x9f, 0xa3, 0x86, 0x23, 0xe5, 0xec, 0x5c, 0x9d, 0x31, 0x60, 0xdd, - 0x00, 0x56, 0xd3, 0x96, 0x64, 0x33, 0xd6, 0xbc, 0x0f, 0x05, 0x47, 0xdb, 0x94, 0x2b, 0x11, 0x3e, - 0x40, 0x4e, 0x26, 0x61, 0x33, 0x36, 0x4c, 0x38, 0x8d, 0xde, 0x03, 0x52, 0xc3, 0x96, 0x04, 0xc5, - 0x9a, 0x3f, 0x9d, 0xb1, 0xa1, 0xa3, 0xac, 0xcb, 0xb0, 0xc6, 0x9f, 0x21, 0xc7, 0x4f, 0x34, 0xcb, - 0x52, 0x70, 0xb9, 0x59, 0x21, 0x9c, 0xb2, 0x2c, 0x75, 0x04, 0x24, 0x17, 0x6b, 0xfc, 0x15, 0xc2, - 0x8e, 0x21, 0x8b, 0xb1, 0x11, 0x4b, 0xde, 0xfb, 0xc0, 0xdb, 0xb6, 0x25, 0xd9, 0x8a, 0x35, 0x8f, - 0x5d, 0x31, 0x90, 0xb7, 0x64, 0x35, 0x81, 0xcf, 0xd0, 0x9e, 0x53, 0x98, 0x0a, 0x33, 0x4a, 0x73, - 0x3a, 0x4d, 0x52, 0x36, 0x66, 0x9c, 0x1a, 0x95, 0x27, 0x39, 0x9b, 0xd2, 0xdc, 0x0b, 0xde, 0x02, - 0xc1, 0x3d, 0x5b, 0x92, 0x7b, 0xb1, 0xe6, 0x2f, 0xe7, 0xd8, 0xa3, 0x00, 0xed, 0x03, 0xd2, 0xc9, - 0xdf, 0x93, 0x6f, 0x2b, 0xe3, 0x29, 0xba, 0x5f, 0x31, 0x3b, 0xa7, 0x63, 0x91, 0x82, 0xd9, 0x50, - 0x49, 0x29, 0xb4, 0x16, 0x0a, 0xfe, 0xd7, 0x68, 0x1d, 0x0c, 0xef, 0xdb, 0x92, 0xec, 0xad, 0x18, - 0xbe, 0x08, 0xf0, 0xc3, 0x05, 0xda, 0x99, 0xee, 0xc9, 0xff, 0x83, 0xe0, 0x1f, 0xd1, 0x5d, 0x7f, - 0xb2, 0x66, 0x69, 0x4e, 0xd3, 0x34, 0x67, 0x5a, 0x83, 0x1f, 0x02, 0xbf, 0xbb, 0xb6, 0x24, 0x11, - 0x9c, 0xb4, 0x09, 0x7a, 0x4f, 0x3c, 0xc8, 0xd9, 0x44, 0xf2, 0x3f, 0x2a, 0xf8, 0x7b, 0x74, 0xc7, - 0xa9, 0xff, 0x54, 0x64, 0x29, 0x6c, 0xa4, 0xc8, 0x84, 0xb9, 0x48, 0x26, 0x4a, 0x8d, 0x41, 0x7c, - 0x03, 0xc4, 0xef, 0xd8, 0x92, 0xb4, 0x63, 0xcd, 0xbf, 0x2e, 0xb2, 0xf4, 0x30, 0x80, 0x4e, 0x94, - 0x1a, 0x3b, 0xed, 0xb6, 0xbc, 0xbe, 0x80, 0xbf, 0x45, 0xed, 0x65, 0xbf, 0xd2, 0xf1, 0x58, 0x4d, - 0x69, 0x36, 0xf4, 0x3d, 0xb8, 0x09, 0xb2, 0x91, 0x2d, 0x49, 0x2b, 0x74, 0xee, 0x93, 0x00, 0x70, - 0x9a, 0x2d, 0x79, 0x4d, 0x16, 0xf7, 0x51, 0xb4, 0xd2, 0xcb, 0x55, 0xc5, 0x3a, 0x28, 0x7e, 0x60, - 0x4b, 0xb2, 0xb3, 0xe8, 0xea, 0x8a, 0xe4, 0x8e, 0xbc, 0x2e, 0x1d, 0x3e, 0x52, 0x17, 0x03, 0x29, - 0x4c, 0x32, 0xc9, 0xd5, 0x44, 0x69, 0xea, 0xf7, 0xde, 0xa8, 0x7c, 0xe4, 0x29, 0x20, 0x4e, 0xe6, - 0x80, 0xf0, 0x91, 0x57, 0xb2, 0xe1, 0x22, 0x9c, 0x2b, 0xe3, 0x3f, 0x6c, 0xab, 0x72, 0x11, 0x5e, - 0x28, 0xc3, 0xc2, 0x45, 0x98, 0xaf, 0xf1, 0x33, 0xb4, 0xb3, 0x60, 0x4c, 0x99, 0xe0, 0x23, 0xc3, - 0x7c, 0xeb, 0x36, 0x81, 0xba, 0x6b, 0x4b, 0x82, 0xe7, 0xd4, 0x97, 0xf3, 0xb2, 0x93, 0xc0, 0xf2, - 0x4a, 0x0e, 0x7f, 0x81, 0xdc, 0x25, 0x49, 0x52, 0x36, 0x51, 0x5a, 0xf8, 0x21, 0x71, 0x7b, 0x65, - 0xba, 0x68, 0x7e, 0xe4, 0x2b, 0x8e, 0xef, 0x86, 0xc9, 0x32, 0x0c, 0x83, 0xa2, 0xc8, 0x7e, 0xa6, - 0xc2, 0xef, 0x1f, 0x57, 0x06, 0xc5, 0x73, 0x28, 0x84, 0x41, 0xb1, 0x88, 0x82, 0xa5, 0x90, 0x13, - 0x46, 0x87, 0x23, 0x20, 0x6e, 0x57, 0x2c, 0x9f, 0xf9, 0x4a, 0xb0, 0x5c, 0x86, 0xf8, 0x1b, 0xb4, - 0x0b, 0x33, 0x26, 0x15, 0x66, 0xe5, 0x3a, 0x39, 0x85, 0x16, 0x28, 0xb4, 0x6d, 0x49, 0xb6, 0xdd, - 0xb8, 0x49, 0x85, 0x59, 0x5c, 0x0e, 0xa7, 0xb3, 0x2d, 0xaf, 0x26, 0xf1, 0x97, 0xa8, 0xe9, 0xf7, - 0x0e, 0x57, 0xd7, 0x1f, 0xfe, 0x0e, 0xe8, 0x60, 0x5b, 0x92, 0x06, 0x6c, 0xde, 0x97, 0x9c, 0x44, - 0x43, 0x56, 0x62, 0xdc, 0xf3, 0xd3, 0xa8, 0xc8, 0x2a, 0xfc, 0x5d, 0xe0, 0xb7, 0x6c, 0x49, 0x9a, - 0x70, 0x04, 0xe9, 0x8a, 0x42, 0x53, 0xfe, 0x2b, 0x13, 0xfa, 0x73, 0xc0, 0xb8, 0xc8, 0x92, 0x9c, - 0x55, 0x94, 0xda, 0x95, 0xfe, 0xec, 0x39, 0x48, 0x9f, 0xad, 0xca, 0xb9, 0x1e, 0xb8, 0x9a, 0xc6, - 0xbf, 0xa0, 0x7d, 0xa7, 0x39, 0x74, 0xfd, 0x3a, 0x4e, 0x8a, 0x6c, 0xa0, 0xb2, 0x54, 0x64, 0x8b, - 0x6d, 0x86, 0xa1, 0x13, 0x81, 0xfc, 0xbe, 0x2d, 0x09, 0x89, 0x35, 0x3f, 0x04, 0xf4, 0xf3, 0x00, - 0x3e, 0x5a, 0x60, 0x9d, 0x11, 0x91, 0x6f, 0x07, 0x3c, 0xbe, 0xf5, 0xdb, 0x6b, 0xb2, 0xf6, 0xf7, - 0x6b, 0x52, 0xeb, 0x3d, 0xfd, 0xdd, 0x76, 0x6a, 0x6f, 0x6c, 0xa7, 0xf6, 0xa7, 0xed, 0xd4, 0x7e, - 0xbd, 0xec, 0xac, 0xbd, 0xb9, 0xec, 0xac, 0xfd, 0x71, 0xd9, 0x59, 0xfb, 0xe1, 0x53, 0x2e, 0x8c, - 0x7b, 0x28, 0x87, 0x4a, 0x76, 0xe7, 0xef, 0xab, 0xff, 0x79, 0xa0, 0xd3, 0xb3, 0xee, 0x2c, 0x3c, - 0xb6, 0xe6, 0x62, 0xc2, 0xf4, 0xe0, 0x26, 0xbc, 0x9a, 0x8f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, - 0x4b, 0x5e, 0x5a, 0x11, 0x8a, 0x07, 0x00, 0x00, + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0xcb, 0xd3, 0x30, + 0x18, 0xc7, 0x5b, 0xdf, 0xd7, 0xe1, 0x9b, 0x51, 0xd4, 0x20, 0x65, 0xbc, 0x83, 0xe6, 0x45, 0x2f, + 0x82, 0x6c, 0x65, 0xec, 0xb6, 0x9b, 0x03, 0x1d, 0x0a, 0x85, 0xb1, 0x09, 0x82, 0x97, 0x92, 0xad, + 0x59, 0x16, 0x6c, 0x9a, 0xd2, 0x64, 0xda, 0xed, 0x53, 0x78, 0xf4, 0xb8, 0x6f, 0xe2, 0xd5, 0xe3, + 0x8e, 0x9e, 0x8a, 0x64, 0x17, 0x3f, 0x86, 0x24, 0x5b, 0xd9, 0x86, 0xbe, 0xa7, 0xe4, 0x79, 0xf2, + 0x7b, 0x7e, 0x79, 0x0e, 0x7f, 0xf0, 0x62, 0x2e, 0x24, 0x17, 0x32, 0xa4, 0x58, 0x2e, 0x57, 0xb3, + 0xf0, 0x4b, 0x0f, 0xa7, 0xf9, 0x12, 0xf7, 0x8e, 0x75, 0x37, 0x2f, 0x84, 0x12, 0xd0, 0x3f, 0x40, + 0xdd, 0x63, 0xb3, 0x86, 0x6e, 0x9f, 0x51, 0x41, 0x85, 0x45, 0x42, 0x73, 0x3b, 0xd0, 0xcf, 0x7f, + 0x5c, 0x81, 0xc6, 0x18, 0x17, 0x98, 0x4b, 0xd8, 0x01, 0x4d, 0x8e, 0xcb, 0x58, 0x95, 0xb1, 0x64, + 0x1b, 0xd2, 0x72, 0xef, 0xdc, 0x97, 0xd7, 0x43, 0x4f, 0x57, 0xe8, 0x26, 0xc2, 0xe5, 0x87, 0x72, + 0xca, 0x36, 0x64, 0x72, 0xc3, 0xeb, 0x2b, 0x1c, 0x80, 0x27, 0x9c, 0x65, 0x31, 0xc5, 0x32, 0xce, + 0x49, 0x11, 0xcf, 0xd6, 0x8a, 0xb4, 0x1e, 0xd8, 0x99, 0xa7, 0xba, 0x42, 0x5e, 0xc4, 0xb2, 0x11, + 0x96, 0x63, 0x52, 0x0c, 0xd7, 0x8a, 0x4c, 0x3c, 0x7e, 0x5e, 0xc2, 0x3e, 0xf0, 0x16, 0xac, 0x24, + 0x49, 0xcc, 0x25, 0x35, 0x86, 0xd6, 0x95, 0x1d, 0x7c, 0xac, 0x2b, 0xd4, 0x7c, 0x6b, 0x1e, 0x22, + 0x49, 0x47, 0x58, 0x4e, 0x9a, 0x8b, 0x53, 0x01, 0xdf, 0x03, 0xdf, 0xe2, 0x05, 0xce, 0x94, 0xfd, + 0x92, 0x29, 0xc2, 0xed, 0xf4, 0xb5, 0x9d, 0xf6, 0x75, 0x85, 0xa0, 0x61, 0x0d, 0x30, 0x26, 0xc5, + 0x3b, 0x45, 0xb8, 0x91, 0x40, 0xfe, 0x4f, 0x0f, 0x7e, 0x04, 0x6d, 0xe3, 0xe2, 0xab, 0x54, 0xb1, + 0x58, 0x92, 0x2c, 0xb9, 0x14, 0x3e, 0xb4, 0xc2, 0x5b, 0x5d, 0x21, 0x3f, 0x92, 0x34, 0x32, 0xd4, + 0x94, 0x64, 0xc9, 0x99, 0xd4, 0xac, 0xf2, 0x9f, 0x3e, 0x5c, 0x80, 0xbb, 0xd3, 0x92, 0x38, 0x4d, + 0xc5, 0x57, 0x9c, 0xcd, 0xc9, 0xa5, 0xbd, 0x61, 0xed, 0x48, 0x57, 0xa8, 0x5d, 0xaf, 0xfb, 0xba, + 0x26, 0xcf, 0xbe, 0x68, 0xf3, 0xfb, 0x1f, 0x07, 0x8f, 0xbe, 0x6f, 0x91, 0xf3, 0x67, 0x8b, 0xdc, + 0xe1, 0x9b, 0x9f, 0x3a, 0x70, 0x77, 0x3a, 0x70, 0x7f, 0xeb, 0xc0, 0xfd, 0xb6, 0x0f, 0x9c, 0xdd, + 0x3e, 0x70, 0x7e, 0xed, 0x03, 0xe7, 0xd3, 0x2b, 0xca, 0x94, 0x89, 0xc0, 0x5c, 0xf0, 0xf0, 0x98, + 0x9c, 0xc3, 0xd1, 0x91, 0xc9, 0xe7, 0xb0, 0xac, 0x63, 0xa4, 0xd6, 0x39, 0x91, 0xb3, 0x86, 0xcd, + 0x43, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x24, 0x68, 0xb2, 0xf5, 0x64, 0x02, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -345,70 +169,16 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } - if this.MsgGrantGas != that1.MsgGrantGas { - return false - } - if this.MsgRevokeGas != that1.MsgRevokeGas { - return false - } - if this.MsgExecGas != that1.MsgExecGas { - return false - } - if this.MsgSendGas != that1.MsgSendGas { - return false - } - if this.MsgMultiSendGas != that1.MsgMultiSendGas { - return false - } - if this.MsgWithdrawDelegatorRewardGas != that1.MsgWithdrawDelegatorRewardGas { - return false - } - if this.MsgWithdrawValidatorCommissionGas != that1.MsgWithdrawValidatorCommissionGas { - return false - } - if this.MsgSetWithdrawAddressGas != that1.MsgSetWithdrawAddressGas { - return false - } - if this.MsgFundCommunityPoolGas != that1.MsgFundCommunityPoolGas { - return false - } - if this.MsgGrantAllowanceGas != that1.MsgGrantAllowanceGas { - return false - } - if this.MsgRevokeAllowanceGas != that1.MsgRevokeAllowanceGas { - return false - } - if this.MsgSubmitProposalGas != that1.MsgSubmitProposalGas { - return false - } - if this.MsgVoteGas != that1.MsgVoteGas { - return false - } - if this.MsgVoteWeightedGas != that1.MsgVoteWeightedGas { - return false - } - if this.MsgDepositGas != that1.MsgDepositGas { - return false - } - if this.MsgUnjailGas != that1.MsgUnjailGas { - return false - } - if this.MsgImpeachGas != that1.MsgImpeachGas { + if this.FixedMsgGas != that1.FixedMsgGas { return false } - if this.MsgEditValidatorGas != that1.MsgEditValidatorGas { + if this.MsgGrantPerItemGas != that1.MsgGrantPerItemGas { return false } - if this.MsgDelegateGas != that1.MsgDelegateGas { + if this.MsgMultiSendPerItemGas != that1.MsgMultiSendPerItemGas { return false } - if this.MsgUndelegateGas != that1.MsgUndelegateGas { - return false - } - if this.MsgBeginRedelegateGas != that1.MsgBeginRedelegateGas { - return false - } - if this.MsgCancelUnbondingDelegationGas != that1.MsgCancelUnbondingDelegationGas { + if this.MsgGrantAllowancePerItemGas != that1.MsgGrantAllowancePerItemGas { return false } return true @@ -433,131 +203,23 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.MsgCancelUnbondingDelegationGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgCancelUnbondingDelegationGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xc0 - } - if m.MsgBeginRedelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgBeginRedelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb8 - } - if m.MsgUndelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgUndelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xb0 - } - if m.MsgDelegateGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgDelegateGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa8 - } - if m.MsgEditValidatorGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgEditValidatorGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa0 - } - if m.MsgImpeachGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgImpeachGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x98 - } - if m.MsgUnjailGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgUnjailGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x90 - } - if m.MsgDepositGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgDepositGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x88 - } - if m.MsgVoteWeightedGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteWeightedGas)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x80 - } - if m.MsgVoteGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteGas)) - i-- - dAtA[i] = 0x78 - } - if m.MsgSubmitProposalGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSubmitProposalGas)) - i-- - dAtA[i] = 0x70 - } - if m.MsgRevokeAllowanceGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeAllowanceGas)) - i-- - dAtA[i] = 0x68 - } - if m.MsgGrantAllowanceGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowanceGas)) - i-- - dAtA[i] = 0x60 - } - if m.MsgFundCommunityPoolGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgFundCommunityPoolGas)) - i-- - dAtA[i] = 0x58 - } - if m.MsgSetWithdrawAddressGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSetWithdrawAddressGas)) - i-- - dAtA[i] = 0x50 - } - if m.MsgWithdrawValidatorCommissionGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawValidatorCommissionGas)) - i-- - dAtA[i] = 0x48 - } - if m.MsgWithdrawDelegatorRewardGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawDelegatorRewardGas)) - i-- - dAtA[i] = 0x40 - } - if m.MsgMultiSendGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendGas)) - i-- - dAtA[i] = 0x38 - } - if m.MsgSendGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgSendGas)) + if m.MsgGrantAllowancePerItemGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowancePerItemGas)) i-- dAtA[i] = 0x30 } - if m.MsgExecGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgExecGas)) + if m.MsgMultiSendPerItemGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendPerItemGas)) i-- dAtA[i] = 0x28 } - if m.MsgRevokeGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeGas)) + if m.MsgGrantPerItemGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantPerItemGas)) i-- dAtA[i] = 0x20 } - if m.MsgGrantGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantGas)) + if m.FixedMsgGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.FixedMsgGas)) i-- dAtA[i] = 0x18 } @@ -597,71 +259,17 @@ func (m *Params) Size() (n int) { if m.MinGasPerByte != 0 { n += 1 + sovGashub(uint64(m.MinGasPerByte)) } - if m.MsgGrantGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantGas)) - } - if m.MsgRevokeGas != 0 { - n += 1 + sovGashub(uint64(m.MsgRevokeGas)) - } - if m.MsgExecGas != 0 { - n += 1 + sovGashub(uint64(m.MsgExecGas)) + if m.FixedMsgGas != 0 { + n += 1 + sovGashub(uint64(m.FixedMsgGas)) } - if m.MsgSendGas != 0 { - n += 1 + sovGashub(uint64(m.MsgSendGas)) + if m.MsgGrantPerItemGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantPerItemGas)) } - if m.MsgMultiSendGas != 0 { - n += 1 + sovGashub(uint64(m.MsgMultiSendGas)) + if m.MsgMultiSendPerItemGas != 0 { + n += 1 + sovGashub(uint64(m.MsgMultiSendPerItemGas)) } - if m.MsgWithdrawDelegatorRewardGas != 0 { - n += 1 + sovGashub(uint64(m.MsgWithdrawDelegatorRewardGas)) - } - if m.MsgWithdrawValidatorCommissionGas != 0 { - n += 1 + sovGashub(uint64(m.MsgWithdrawValidatorCommissionGas)) - } - if m.MsgSetWithdrawAddressGas != 0 { - n += 1 + sovGashub(uint64(m.MsgSetWithdrawAddressGas)) - } - if m.MsgFundCommunityPoolGas != 0 { - n += 1 + sovGashub(uint64(m.MsgFundCommunityPoolGas)) - } - if m.MsgGrantAllowanceGas != 0 { - n += 1 + sovGashub(uint64(m.MsgGrantAllowanceGas)) - } - if m.MsgRevokeAllowanceGas != 0 { - n += 1 + sovGashub(uint64(m.MsgRevokeAllowanceGas)) - } - if m.MsgSubmitProposalGas != 0 { - n += 1 + sovGashub(uint64(m.MsgSubmitProposalGas)) - } - if m.MsgVoteGas != 0 { - n += 1 + sovGashub(uint64(m.MsgVoteGas)) - } - if m.MsgVoteWeightedGas != 0 { - n += 2 + sovGashub(uint64(m.MsgVoteWeightedGas)) - } - if m.MsgDepositGas != 0 { - n += 2 + sovGashub(uint64(m.MsgDepositGas)) - } - if m.MsgUnjailGas != 0 { - n += 2 + sovGashub(uint64(m.MsgUnjailGas)) - } - if m.MsgImpeachGas != 0 { - n += 2 + sovGashub(uint64(m.MsgImpeachGas)) - } - if m.MsgEditValidatorGas != 0 { - n += 2 + sovGashub(uint64(m.MsgEditValidatorGas)) - } - if m.MsgDelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgDelegateGas)) - } - if m.MsgUndelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgUndelegateGas)) - } - if m.MsgBeginRedelegateGas != 0 { - n += 2 + sovGashub(uint64(m.MsgBeginRedelegateGas)) - } - if m.MsgCancelUnbondingDelegationGas != 0 { - n += 2 + sovGashub(uint64(m.MsgCancelUnbondingDelegationGas)) + if m.MsgGrantAllowancePerItemGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantAllowancePerItemGas)) } return n } @@ -741,9 +349,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field FixedMsgGas", wireType) } - m.MsgGrantGas = 0 + m.FixedMsgGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -753,16 +361,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgGrantGas |= uint64(b&0x7F) << shift + m.FixedMsgGas |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantPerItemGas", wireType) } - m.MsgRevokeGas = 0 + m.MsgGrantPerItemGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -772,16 +380,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgRevokeGas |= uint64(b&0x7F) << shift + m.MsgGrantPerItemGas |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgExecGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendPerItemGas", wireType) } - m.MsgExecGas = 0 + m.MsgMultiSendPerItemGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -791,358 +399,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgExecGas |= uint64(b&0x7F) << shift + m.MsgMultiSendPerItemGas |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) - } - m.MsgSendGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSendGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendGas", wireType) - } - m.MsgMultiSendGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgMultiSendGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawDelegatorRewardGas", wireType) - } - m.MsgWithdrawDelegatorRewardGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgWithdrawDelegatorRewardGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawValidatorCommissionGas", wireType) - } - m.MsgWithdrawValidatorCommissionGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgWithdrawValidatorCommissionGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSetWithdrawAddressGas", wireType) - } - m.MsgSetWithdrawAddressGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSetWithdrawAddressGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 11: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgFundCommunityPoolGas", wireType) - } - m.MsgFundCommunityPoolGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgFundCommunityPoolGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 12: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowanceGas", wireType) - } - m.MsgGrantAllowanceGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgGrantAllowanceGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 13: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeAllowanceGas", wireType) - } - m.MsgRevokeAllowanceGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgRevokeAllowanceGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 14: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitProposalGas", wireType) - } - m.MsgSubmitProposalGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgSubmitProposalGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 15: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteGas", wireType) - } - m.MsgVoteGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgVoteGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 16: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteWeightedGas", wireType) - } - m.MsgVoteWeightedGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgVoteWeightedGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 17: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgDepositGas", wireType) - } - m.MsgDepositGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgDepositGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 18: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgUnjailGas", wireType) - } - m.MsgUnjailGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgUnjailGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 19: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgImpeachGas", wireType) - } - m.MsgImpeachGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgImpeachGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 20: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgEditValidatorGas", wireType) - } - m.MsgEditValidatorGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgEditValidatorGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 21: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgDelegateGas", wireType) - } - m.MsgDelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgDelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 22: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgUndelegateGas", wireType) - } - m.MsgUndelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgUndelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 23: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgBeginRedelegateGas", wireType) - } - m.MsgBeginRedelegateGas = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGashub - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MsgBeginRedelegateGas |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 24: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgCancelUnbondingDelegationGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowancePerItemGas", wireType) } - m.MsgCancelUnbondingDelegationGas = 0 + m.MsgGrantAllowancePerItemGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -1152,7 +418,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgCancelUnbondingDelegationGas |= uint64(b&0x7F) << shift + m.MsgGrantAllowancePerItemGas |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 581d84552a..19cf0a7a88 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -10,94 +10,37 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 - DefaultMsgGrantGas uint64 = 1e5 - DefaultMsgRevokeGas uint64 = 1e5 - DefaultMsgExecGas uint64 = 1e5 - DefaultMsgSendGas uint64 = 1e5 - DefaultMsgMultiSendGas uint64 = 1e5 - DefaultMsgWithdrawDelegatorRewardGas uint64 = 1e5 - DefaultMsgWithdrawValidatorCommissionGas uint64 = 1e5 - DefaultMsgSetWithdrawAddressGas uint64 = 1e5 - DefaultMsgFundCommunityPoolGas uint64 = 1e5 - DefaultMsgGrantAllowanceGas uint64 = 1e5 - DefaultMsgRevokeAllowanceGas uint64 = 1e5 - DefaultMsgSubmitProposalGas uint64 = 1e5 - DefaultMsgVoteGas uint64 = 1e5 - DefaultMsgVoteWeightedGas uint64 = 1e5 - DefaultMsgDepositGas uint64 = 1e5 - DefaultMsgUnjailGas uint64 = 1e5 - DefaultMsgImpeachGas uint64 = 1e5 - DefaultMsgEditValidatorGas uint64 = 1e5 - DefaultMsgDelegateGas uint64 = 1e5 - DefaultMsgUndelegateGas uint64 = 1e5 - DefaultMsgBeginRedelegateGas uint64 = 1e5 - DefaultMsgCancelUnbondingDelegationGas uint64 = 1e5 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 + DefaultFixedMsgGas uint64 = 1e5 + DefaultMsgGrantPerItemGas uint64 = 1e5 + DefaultMsgMultiSendPerItemGas uint64 = 1e5 + DefaultMsgGrantAllowancePerItemGas uint64 = 1e5 ) // Parameter keys var ( - KeyMaxTxSize = []byte("MaxTxSize") - KeyMinGasPerByte = []byte("MinGasPerByte") - KeyMsgGrantGas = []byte("MsgGrantGas") - KeyMsgRevokeGas = []byte("MsgRevokeGas") - KeyMsgExecGas = []byte("MsgExecGas") - KeyMsgSendGas = []byte("MsgSendGas") - KeyMsgMultiSendGas = []byte("MsgMultiSendGas") - KeyMsgWithdrawDelegatorRewardGas = []byte("MsgWithdrawDelegatorRewardGas") - KeyMsgWithdrawValidatorCommissionGas = []byte("MsgWithdrawValidatorCommissionGas") - KeyMsgSetWithdrawAddressGas = []byte("MsgSetWithdrawAddressGas") - KeyMsgFundCommunityPoolGas = []byte("MsgFundCommunityPoolGas") - KeyMsgGrantAllowanceGas = []byte("MsgGrantAllowanceGas") - KeyMsgRevokeAllowanceGas = []byte("MsgRevokeAllowanceGas") - KeyMsgSubmitProposalGas = []byte("MsgSubmitProposalGas") - KeyMsgVoteGas = []byte("MsgVoteGas") - KeyMsgVoteWeightedGas = []byte("MsgVoteWeightedGas") - KeyMsgDepositGas = []byte("MsgDepositGas") - KeyMsgUnjailGas = []byte("MsgUnjailGas") - KeyMsgImpeachGas = []byte("MsgImpeachGas") - KeyMsgEditValidatorGas = []byte("MsgEditValidatorGas") - KeyMsgDelegateGas = []byte("MsgDelegateGas") - KeyMsgUndelegateGas = []byte("MsgUndelegateGas") - KeyMsgBeginRedelegateGas = []byte("MsgBeginRedelegateGas") - KeyMsgCancelUnbondingDelegationGas = []byte("MsgCancelUnbondingDelegationGas") + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyFixedMsgGas = []byte("FixedMsgGas") + KeyMsgGrantPerItemGas = []byte("MsgGrantPerItemGas") + KeyMsgMultiSendPerItemGas = []byte("MsgMultiSendPerItemGas") + KeyMsgGrantAllowancePerItemGas = []byte("MsgGrantAllowancePerItemGas") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte, msgGrantGas, msgRevokeGas, msgExecGas, msgSendGas, msgMultiSendGas, msgWithdrawDelegatorRewardGas, - msgWithdrawValidatorCommissionGas, msgSetWithdrawAddressGas, msgFundCommunityPoolGas, msgGrantAllowanceGas, msgRevokeAllowanceGas, - msgSubmitProposalGas, msgVoteGas, msgVoteWeightedGas, msgDepositGas, msgUnjailGas, msgImpeachGas, msgEditValidatorGas, - msgDelegateGas, msgUndelegateGas, msgBeginRedelegateGas, msgCancelUnbondingDelegationGas uint64, + maxTxSize, minGasPerByte, fixedMsgGas, msgGrantPerItemGas, msgMultiSendPerItemGas, msgGrantAllowancePerItemGas uint64, ) Params { return Params{ - MaxTxSize: maxTxSize, - MinGasPerByte: minGasPerByte, - MsgGrantGas: msgGrantGas, - MsgRevokeGas: msgRevokeGas, - MsgExecGas: msgExecGas, - MsgSendGas: msgSendGas, - MsgMultiSendGas: msgMultiSendGas, - MsgWithdrawDelegatorRewardGas: msgWithdrawDelegatorRewardGas, - MsgWithdrawValidatorCommissionGas: msgWithdrawValidatorCommissionGas, - MsgSetWithdrawAddressGas: msgSetWithdrawAddressGas, - MsgFundCommunityPoolGas: msgFundCommunityPoolGas, - MsgGrantAllowanceGas: msgGrantAllowanceGas, - MsgRevokeAllowanceGas: msgRevokeAllowanceGas, - MsgSubmitProposalGas: msgSubmitProposalGas, - MsgVoteGas: msgVoteGas, - MsgVoteWeightedGas: msgVoteWeightedGas, - MsgDepositGas: msgDepositGas, - MsgUnjailGas: msgUnjailGas, - MsgImpeachGas: msgImpeachGas, - MsgEditValidatorGas: msgEditValidatorGas, - MsgDelegateGas: msgDelegateGas, - MsgUndelegateGas: msgUndelegateGas, - MsgBeginRedelegateGas: msgBeginRedelegateGas, - MsgCancelUnbondingDelegationGas: msgCancelUnbondingDelegationGas, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + FixedMsgGas: fixedMsgGas, + MsgGrantPerItemGas: msgGrantPerItemGas, + MsgMultiSendPerItemGas: msgMultiSendPerItemGas, + MsgGrantAllowancePerItemGas: msgGrantAllowancePerItemGas, } } @@ -112,58 +55,22 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyMsgGrantGas, &p.MsgGrantGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgRevokeGas, &p.MsgRevokeGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgExecGas, &p.MsgExecGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgMultiSendGas, &p.MsgMultiSendGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgWithdrawDelegatorRewardGas, &p.MsgWithdrawDelegatorRewardGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgWithdrawValidatorCommissionGas, &p.MsgWithdrawValidatorCommissionGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSetWithdrawAddressGas, &p.MsgSetWithdrawAddressGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgFundCommunityPoolGas, &p.MsgFundCommunityPoolGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgGrantAllowanceGas, &p.MsgGrantAllowanceGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgRevokeAllowanceGas, &p.MsgRevokeAllowanceGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgSubmitProposalGas, &p.MsgSubmitProposalGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgVoteGas, &p.MsgVoteGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgVoteWeightedGas, &p.MsgVoteWeightedGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgDepositGas, &p.MsgDepositGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgUnjailGas, &p.MsgUnjailGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgImpeachGas, &p.MsgImpeachGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgEditValidatorGas, &p.MsgEditValidatorGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgDelegateGas, &p.MsgDelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgUndelegateGas, &p.MsgUndelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgBeginRedelegateGas, &p.MsgBeginRedelegateGas, validateMsgGas), - paramtypes.NewParamSetPair(KeyMsgCancelUnbondingDelegationGas, &p.MsgCancelUnbondingDelegationGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyFixedMsgGas, &p.FixedMsgGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGrantPerItemGas, &p.MsgGrantPerItemGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgMultiSendPerItemGas, &p.MsgMultiSendPerItemGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGrantAllowancePerItemGas, &p.MsgGrantAllowancePerItemGas, validateMsgGas), } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { return Params{ - MaxTxSize: DefaultMaxTxSize, - MinGasPerByte: DefaultMinGasPerByte, - MsgGrantGas: DefaultMsgGrantGas, - MsgRevokeGas: DefaultMsgRevokeGas, - MsgExecGas: DefaultMsgExecGas, - MsgSendGas: DefaultMsgSendGas, - MsgMultiSendGas: DefaultMsgMultiSendGas, - MsgWithdrawDelegatorRewardGas: DefaultMsgWithdrawDelegatorRewardGas, - MsgWithdrawValidatorCommissionGas: DefaultMsgWithdrawValidatorCommissionGas, - MsgSetWithdrawAddressGas: DefaultMsgSetWithdrawAddressGas, - MsgFundCommunityPoolGas: DefaultMsgFundCommunityPoolGas, - MsgGrantAllowanceGas: DefaultMsgGrantAllowanceGas, - MsgRevokeAllowanceGas: DefaultMsgRevokeAllowanceGas, - MsgSubmitProposalGas: DefaultMsgSubmitProposalGas, - MsgVoteGas: DefaultMsgVoteGas, - MsgVoteWeightedGas: DefaultMsgVoteWeightedGas, - MsgDepositGas: DefaultMsgDepositGas, - MsgUnjailGas: DefaultMsgUnjailGas, - MsgImpeachGas: DefaultMsgImpeachGas, - MsgEditValidatorGas: DefaultMsgEditValidatorGas, - MsgDelegateGas: DefaultMsgDelegateGas, - MsgUndelegateGas: DefaultMsgUndelegateGas, - MsgBeginRedelegateGas: DefaultMsgBeginRedelegateGas, - MsgCancelUnbondingDelegationGas: DefaultMsgCancelUnbondingDelegationGas, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + FixedMsgGas: DefaultFixedMsgGas, + MsgGrantPerItemGas: DefaultMsgGrantPerItemGas, + MsgMultiSendPerItemGas: DefaultMsgMultiSendPerItemGas, + MsgGrantAllowancePerItemGas: DefaultMsgGrantAllowancePerItemGas, } } @@ -220,70 +127,16 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMsgGas(p.MsgGrantGas); err != nil { + if err := validateMsgGas(p.FixedMsgGas); err != nil { return err } - if err := validateMsgGas(p.MsgRevokeGas); err != nil { + if err := validateMsgGas(p.MsgGrantPerItemGas); err != nil { return err } - if err := validateMsgGas(p.MsgExecGas); err != nil { + if err := validateMsgGas(p.MsgMultiSendPerItemGas); err != nil { return err } - if err := validateMsgGas(p.MsgSendGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgMultiSendGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgWithdrawDelegatorRewardGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgWithdrawValidatorCommissionGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSetWithdrawAddressGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgFundCommunityPoolGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgGrantAllowanceGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgRevokeAllowanceGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgSubmitProposalGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgVoteGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgVoteWeightedGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgDepositGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgUnjailGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgImpeachGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgEditValidatorGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgDelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgUndelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgBeginRedelegateGas); err != nil { - return err - } - if err := validateMsgGas(p.MsgCancelUnbondingDelegationGas); err != nil { + if err := validateMsgGas(p.MsgGrantAllowancePerItemGas); err != nil { return err } diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index d60d469c98..1f9016cdbb 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -6,9 +6,9 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -// // TODO: Revisit this once we have propoer gas fee framework. -// // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -// const gasCostPerIteration = uint64(10) +// TODO: Revisit this once we have propoer gas fee framework. +// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +const gasCostPerIteration = uint64(10) var _ authz.Authorization = &StakeAuthorization{} @@ -76,7 +76,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe isValidatorExists := false allowedList := a.GetAllowList().GetAddress() for _, validator := range allowedList { - // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { isValidatorExists = true break @@ -85,7 +85,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe denyList := a.GetDenyList().GetAddress() for _, validator := range denyList { - // ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validator) } From f78ce41c0abfac8b0aa401eb89acb0dea98d6019 Mon Sep 17 00:00:00 2001 From: Roshan Date: Wed, 4 Jan 2023 19:01:33 +0800 Subject: [PATCH 08/11] fix lint issues --- x/auth/ante/msg_gas.go | 2 +- x/gashub/types/gas_calculator.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/x/auth/ante/msg_gas.go b/x/auth/ante/msg_gas.go index 1be8ee335b..20dfc30845 100644 --- a/x/auth/ante/msg_gas.go +++ b/x/auth/ante/msg_gas.go @@ -134,7 +134,7 @@ func (cmfg ConsumeMsgGasDecorator) getMsgGas(params types.Params, tx sdk.Tx) (ui if err != nil { return 0, err } - totalGas = totalGas + gas + totalGas += gas } return totalGas, nil } diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index c117f4d496..97ea544a67 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -59,8 +59,7 @@ func GrantCalculator(fixedGas, gasPerItem uint64) GasCalculator { denyList := authorization.GetDenyList().GetAddress() num = len(allowList) + len(denyList) case *bank.SendAuthorization: - coins := authorization.SpendLimit - num = len(coins) + num = len(authorization.SpendLimit) } totalGas := fixedGas + uint64(num)*gasPerItem @@ -100,8 +99,17 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { } switch feeAllowance := feeAllowance.(type) { case *feegrant.AllowedMsgAllowance: - allowedMsg := feeAllowance.AllowedMessages - num = len(allowedMsg) + num = len(feeAllowance.AllowedMessages) + case *feegrant.PeriodicAllowance: + spendLimit := len(feeAllowance.PeriodSpendLimit) + canSpend := len(feeAllowance.PeriodCanSpend) + if spendLimit > canSpend { + num = spendLimit + } else { + num = canSpend + } + case *feegrant.BasicAllowance: + num = len(feeAllowance.SpendLimit) } totalGas := fixedGas + uint64(num)*gasPerItem From 6d9923cb2095a4eb3eb497fef64d9a97f683cb0b Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 5 Jan 2023 10:11:59 +0800 Subject: [PATCH 09/11] remove gas consume from some msg exec process --- proto/cosmos/gashub/v1alpha1/gashub.proto | 27 +- x/authz/errors.go | 3 + x/authz/keeper/keeper.go | 7 - x/feegrant/errors.go | 3 + x/feegrant/filtered_fee.go | 16 +- x/gashub/simulation/genesis.go | 12 +- x/gashub/simulation/genesis_test.go | 2 +- x/gashub/types/gas_calculator.go | 106 ++- x/gashub/types/gashub.pb.go | 957 ++++++++++++++++++++-- x/gashub/types/params.go | 202 ++++- x/staking/types/authz.go | 20 +- 11 files changed, 1221 insertions(+), 134 deletions(-) diff --git a/proto/cosmos/gashub/v1alpha1/gashub.proto b/proto/cosmos/gashub/v1alpha1/gashub.proto index 1a90e609fa..f99e8a714a 100644 --- a/proto/cosmos/gashub/v1alpha1/gashub.proto +++ b/proto/cosmos/gashub/v1alpha1/gashub.proto @@ -12,8 +12,29 @@ message Params { uint64 max_tx_size = 1 [(gogoproto.customname) = "MaxTxSize"]; uint64 min_gas_per_byte = 2 [(gogoproto.customname) = "MinGasPerByte"]; - uint64 fixed_msg_gas = 3 [(gogoproto.customname) = "FixedMsgGas"]; + uint64 msg_grant_fixed_gas = 3 [(gogoproto.customname) = "MsgGrantFixedGas"]; uint64 msg_grant_per_item_gas = 4 [(gogoproto.customname) = "MsgGrantPerItemGas"]; - uint64 msg_multi_send_per_item_gas = 5 [(gogoproto.customname) = "MsgMultiSendPerItemGas"]; - uint64 msg_grant_allowance_per_item_gas = 6 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"]; + uint64 msg_revoke_gas = 5 [(gogoproto.customname) = "MsgRevokeGas"]; + uint64 msg_exec_gas = 6 [(gogoproto.customname) = "MsgExecGas"]; + uint64 msg_send_gas = 7 [(gogoproto.customname) = "MsgSendGas"]; + uint64 msg_multi_send_fixed_gas = 8 [(gogoproto.customname) = "MsgMultiSendFixedGas"]; + uint64 msg_multi_send_per_item_gas = 9 [(gogoproto.customname) = "MsgMultiSendPerItemGas"]; + uint64 msg_withdraw_delegator_reward_gas = 10 [(gogoproto.customname) = "MsgWithdrawDelegatorRewardGas"]; + uint64 msg_withdraw_validator_commission_gas = 11 [(gogoproto.customname) = "MsgWithdrawValidatorCommissionGas"]; + uint64 msg_set_withdraw_address_gas = 12 [(gogoproto.customname) = "MsgSetWithdrawAddressGas"]; + uint64 msg_fund_community_pool_gas = 13 [(gogoproto.customname) = "MsgFundCommunityPoolGas"]; + uint64 msg_grant_allowance_fixed_gas = 14 [(gogoproto.customname) = "MsgGrantAllowanceFixedGas"]; + uint64 msg_grant_allowance_per_item_gas = 15 [(gogoproto.customname) = "MsgGrantAllowancePerItemGas"]; + uint64 msg_revoke_allowance_gas = 16 [(gogoproto.customname) = "MsgRevokeAllowanceGas"]; + uint64 msg_submit_proposal_gas = 17 [(gogoproto.customname) = "MsgSubmitProposalGas"]; + uint64 msg_vote_gas = 18 [(gogoproto.customname) = "MsgVoteGas"]; + uint64 msg_vote_weighted_gas = 19 [(gogoproto.customname) = "MsgVoteWeightedGas"]; + uint64 msg_deposit_gas = 20 [(gogoproto.customname) = "MsgDepositGas"]; + uint64 msg_unjail_gas = 21 [(gogoproto.customname) = "MsgUnjailGas"]; + uint64 msg_impeach_gas = 22 [(gogoproto.customname) = "MsgImpeachGas"]; + uint64 msg_edit_validator_gas = 23 [(gogoproto.customname) = "MsgEditValidatorGas"]; + uint64 msg_delegate_gas = 24 [(gogoproto.customname) = "MsgDelegateGas"]; + uint64 msg_undelegate_gas = 25 [(gogoproto.customname) = "MsgUndelegateGas"]; + uint64 msg_begin_redelegate_gas = 26 [(gogoproto.customname) = "MsgBeginRedelegateGas"]; + uint64 msg_cancel_unbonding_delegation_gas = 27 [(gogoproto.customname) = "MsgCancelUnbondingDelegationGas"]; } diff --git a/x/authz/errors.go b/x/authz/errors.go index 2aaac7122f..dc44f81ddf 100644 --- a/x/authz/errors.go +++ b/x/authz/errors.go @@ -1,6 +1,7 @@ package authz import ( + "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -22,4 +23,6 @@ var ( ErrAuthorizationNumOfSigners = sdkerrors.Register(ModuleName, 9, "authorization can be given to msg with only one signer") // ErrNegativeMaxTokens error if the max tokens is negative ErrNegativeMaxTokens = sdkerrors.Register(ModuleName, 12, "max tokens should be positive") + // ErrTooManyValidators error if the number of stake authorization validators exceeds limit + ErrTooManyValidators = errors.Register(ModuleName, 13, "the number of stake authorization validators cannot exceed the limit") ) diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 63f7714b0a..c2f87bf4cd 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -19,11 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, -// https://github.com/cosmos/cosmos-sdk/discussions/9072 -const gasCostPerIteration = uint64(20) - type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec @@ -359,8 +354,6 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran queueItems := queueItem.MsgTypeUrls for index, typeURL := range queueItems { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "grant queue") - if typeURL == msgType { end := len(queueItem.MsgTypeUrls) - 1 queueItems[index] = queueItems[end] diff --git a/x/feegrant/errors.go b/x/feegrant/errors.go index 232020e6a2..98148dec89 100644 --- a/x/feegrant/errors.go +++ b/x/feegrant/errors.go @@ -1,6 +1,7 @@ package feegrant import ( + "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -22,4 +23,6 @@ var ( ErrNoMessages = sdkerrors.Register(DefaultCodespace, 6, "allowed messages are empty") // ErrMessageNotAllowed error if message is not allowed ErrMessageNotAllowed = sdkerrors.Register(DefaultCodespace, 7, "message not allowed") + // ErrTooManyMessages error if the number of allowed messages exceeds limit + ErrTooManyMessages = errors.Register(DefaultCodespace, 8, "the number of allowed messages cannot exceed the limit") ) diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index e03ce820e0..7d077cb31b 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -8,13 +8,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/pkg/errors" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -const ( - gasCostPerIteration = uint64(10) -) +const maxAllowedMessagesLength = 22 var ( _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) @@ -88,7 +85,6 @@ func (a *AllowedMsgAllowance) Accept(ctx sdk.Context, fee sdk.Coins, msgs []sdk. func (a *AllowedMsgAllowance) allowedMsgsToMap(ctx sdk.Context) map[string]bool { msgsMap := make(map[string]bool, len(a.AllowedMessages)) for _, msg := range a.AllowedMessages { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") msgsMap[msg] = true } @@ -99,7 +95,6 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx sdk.Context, msgs []sdk.Msg msgsMap := a.allowedMsgsToMap(ctx) for _, msg := range msgs { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "check msg") if !msgsMap[sdk.MsgTypeURL(msg)] { return false } @@ -111,10 +106,13 @@ func (a *AllowedMsgAllowance) allMsgTypesAllowed(ctx sdk.Context, msgs []sdk.Msg // ValidateBasic implements FeeAllowance and enforces basic sanity checks func (a *AllowedMsgAllowance) ValidateBasic() error { if a.Allowance == nil { - return sdkerrors.Wrap(ErrNoAllowance, "allowance should not be empty") + return errors.Wrap(ErrNoAllowance, "allowance should not be empty") } if len(a.AllowedMessages) == 0 { - return sdkerrors.Wrap(ErrNoMessages, "allowed messages shouldn't be empty") + return errors.Wrap(ErrNoMessages, "allowed messages shouldn't be empty") + } + if len(a.AllowedMessages) > maxAllowedMessagesLength { + return errors.Wrapf(ErrTooManyMessages, "allowed messages number: %d, limit: %d", len(a.AllowedMessages), maxAllowedMessagesLength) } allowance, err := a.GetAllowance() diff --git a/x/gashub/simulation/genesis.go b/x/gashub/simulation/genesis.go index 2f5d7c3869..f66a363957 100644 --- a/x/gashub/simulation/genesis.go +++ b/x/gashub/simulation/genesis.go @@ -14,7 +14,7 @@ import ( const ( MaxTxSize = "max_tx_size" MinGasPerByte = "min_gas_per_byte" - FixedMsgGas = "fixed_msg_gas" + MsgGas = "msg_gas" ) // GenMaxTxSize randomized MaxTxSize @@ -46,13 +46,15 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { minGasPerByte = GenMinGasPerByte(r) }, ) - var fixedMsgGas uint64 + var msgGas uint64 simState.AppParams.GetOrGenerate( - simState.Cdc, FixedMsgGas, &fixedMsgGas, simState.Rand, - func(r *rand.Rand) { fixedMsgGas = GenMsgGas(r) }, + simState.Cdc, MsgGas, &msgGas, simState.Rand, + func(r *rand.Rand) { msgGas = GenMsgGas(r) }, ) - params := types.NewParams(maxTxSize, minGasPerByte, fixedMsgGas, fixedMsgGas, fixedMsgGas, fixedMsgGas) + params := types.NewParams(maxTxSize, minGasPerByte, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, + msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, msgGas, + msgGas, msgGas, msgGas) gashubGenesis := types.NewGenesisState(params) diff --git a/x/gashub/simulation/genesis_test.go b/x/gashub/simulation/genesis_test.go index 7a171c0911..9652a5ef87 100644 --- a/x/gashub/simulation/genesis_test.go +++ b/x/gashub/simulation/genesis_test.go @@ -41,5 +41,5 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, uint64(2540), gashubGenesis.Params.MaxTxSize) require.Equal(t, uint64(2956), gashubGenesis.Params.MinGasPerByte) - require.Equal(t, uint64(2803300), gashubGenesis.Params.FixedMsgGas) + require.Equal(t, uint64(2803300), gashubGenesis.Params.MsgSendGas) } diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index 97ea544a67..ea0ec6eccf 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -117,50 +117,102 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { } } -var fixedMsgGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetFixedMsgGas() - return FixedGasCalculator(fixedGas) -} - var msgGrantGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetFixedMsgGas() + fixedGas := params.GetMsgGrantFixedGas() gasPerItem := params.GetMsgGrantPerItemGas() return GrantCalculator(fixedGas, gasPerItem) } var msgMultiSendGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetFixedMsgGas() + fixedGas := params.GetMsgMultiSendFixedGas() gasPerItem := params.GetMsgMultiSendPerItemGas() return MultiSendCalculator(fixedGas, gasPerItem) } var msgGrantAllowanceGasCalculatorGen = func(params Params) GasCalculator { - fixedGas := params.GetFixedMsgGas() + fixedGas := params.GetMsgGrantAllowanceFixedGas() gasPerItem := params.GetMsgGrantAllowancePerItemGas() return GrantAllowanceCalculator(fixedGas, gasPerItem) } func init() { RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgGrant{}), msgGrantGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgRevoke{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgRevokeGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&authz.MsgExec{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgExecGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgSend{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgSendGas() + return FixedGasCalculator(fixedGas) + }) RegisterCalculatorGen(types.MsgTypeURL(&bank.MsgMultiSend{}), msgMultiSendGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawDelegatorReward{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgWithdrawDelegatorRewardGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgWithdrawValidatorCommission{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgWithdrawValidatorCommissionGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgSetWithdrawAddress{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgSetWithdrawAddressGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&distribution.MsgFundCommunityPool{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgFundCommunityPoolGas() + return FixedGasCalculator(fixedGas) + }) RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgGrantAllowance{}), msgGrantAllowanceGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), fixedMsgGasCalculatorGen) - RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), fixedMsgGasCalculatorGen) + RegisterCalculatorGen(types.MsgTypeURL(&feegrant.MsgRevokeAllowance{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgRevokeAllowanceGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgSubmitProposal{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgSubmitProposalGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVote{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgVoteGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgVoteWeighted{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgVoteWeightedGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&gov.MsgDeposit{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgDepositGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgUnjail{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgUnjailGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&slashing.MsgImpeach{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgImpeachGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgEditValidator{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgEditValidatorGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgDelegate{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgDelegateGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgUndelegate{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgUndelegateGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgBeginRedelegate{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgBeginRedelegateGas() + return FixedGasCalculator(fixedGas) + }) + RegisterCalculatorGen(types.MsgTypeURL(&staking.MsgCancelUnbondingDelegation{}), func(params Params) GasCalculator { + fixedGas := params.GetMsgCancelUnbondingDelegationGas() + return FixedGasCalculator(fixedGas) + }) } diff --git a/x/gashub/types/gashub.pb.go b/x/gashub/types/gashub.pb.go index b9e207acbe..a03991d6e6 100644 --- a/x/gashub/types/gashub.pb.go +++ b/x/gashub/types/gashub.pb.go @@ -25,12 +25,33 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the gashub module. type Params struct { - MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` - MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` - FixedMsgGas uint64 `protobuf:"varint,3,opt,name=fixed_msg_gas,json=fixedMsgGas,proto3" json:"fixed_msg_gas,omitempty"` - MsgGrantPerItemGas uint64 `protobuf:"varint,4,opt,name=msg_grant_per_item_gas,json=msgGrantPerItemGas,proto3" json:"msg_grant_per_item_gas,omitempty"` - MsgMultiSendPerItemGas uint64 `protobuf:"varint,5,opt,name=msg_multi_send_per_item_gas,json=msgMultiSendPerItemGas,proto3" json:"msg_multi_send_per_item_gas,omitempty"` - MsgGrantAllowancePerItemGas uint64 `protobuf:"varint,6,opt,name=msg_grant_allowance_per_item_gas,json=msgGrantAllowancePerItemGas,proto3" json:"msg_grant_allowance_per_item_gas,omitempty"` + MaxTxSize uint64 `protobuf:"varint,1,opt,name=max_tx_size,json=maxTxSize,proto3" json:"max_tx_size,omitempty"` + MinGasPerByte uint64 `protobuf:"varint,2,opt,name=min_gas_per_byte,json=minGasPerByte,proto3" json:"min_gas_per_byte,omitempty"` + MsgGrantFixedGas uint64 `protobuf:"varint,3,opt,name=msg_grant_fixed_gas,json=msgGrantFixedGas,proto3" json:"msg_grant_fixed_gas,omitempty"` + MsgGrantPerItemGas uint64 `protobuf:"varint,4,opt,name=msg_grant_per_item_gas,json=msgGrantPerItemGas,proto3" json:"msg_grant_per_item_gas,omitempty"` + MsgRevokeGas uint64 `protobuf:"varint,5,opt,name=msg_revoke_gas,json=msgRevokeGas,proto3" json:"msg_revoke_gas,omitempty"` + MsgExecGas uint64 `protobuf:"varint,6,opt,name=msg_exec_gas,json=msgExecGas,proto3" json:"msg_exec_gas,omitempty"` + MsgSendGas uint64 `protobuf:"varint,7,opt,name=msg_send_gas,json=msgSendGas,proto3" json:"msg_send_gas,omitempty"` + MsgMultiSendFixedGas uint64 `protobuf:"varint,8,opt,name=msg_multi_send_fixed_gas,json=msgMultiSendFixedGas,proto3" json:"msg_multi_send_fixed_gas,omitempty"` + MsgMultiSendPerItemGas uint64 `protobuf:"varint,9,opt,name=msg_multi_send_per_item_gas,json=msgMultiSendPerItemGas,proto3" json:"msg_multi_send_per_item_gas,omitempty"` + MsgWithdrawDelegatorRewardGas uint64 `protobuf:"varint,10,opt,name=msg_withdraw_delegator_reward_gas,json=msgWithdrawDelegatorRewardGas,proto3" json:"msg_withdraw_delegator_reward_gas,omitempty"` + MsgWithdrawValidatorCommissionGas uint64 `protobuf:"varint,11,opt,name=msg_withdraw_validator_commission_gas,json=msgWithdrawValidatorCommissionGas,proto3" json:"msg_withdraw_validator_commission_gas,omitempty"` + MsgSetWithdrawAddressGas uint64 `protobuf:"varint,12,opt,name=msg_set_withdraw_address_gas,json=msgSetWithdrawAddressGas,proto3" json:"msg_set_withdraw_address_gas,omitempty"` + MsgFundCommunityPoolGas uint64 `protobuf:"varint,13,opt,name=msg_fund_community_pool_gas,json=msgFundCommunityPoolGas,proto3" json:"msg_fund_community_pool_gas,omitempty"` + MsgGrantAllowanceFixedGas uint64 `protobuf:"varint,14,opt,name=msg_grant_allowance_fixed_gas,json=msgGrantAllowanceFixedGas,proto3" json:"msg_grant_allowance_fixed_gas,omitempty"` + MsgGrantAllowancePerItemGas uint64 `protobuf:"varint,15,opt,name=msg_grant_allowance_per_item_gas,json=msgGrantAllowancePerItemGas,proto3" json:"msg_grant_allowance_per_item_gas,omitempty"` + MsgRevokeAllowanceGas uint64 `protobuf:"varint,16,opt,name=msg_revoke_allowance_gas,json=msgRevokeAllowanceGas,proto3" json:"msg_revoke_allowance_gas,omitempty"` + MsgSubmitProposalGas uint64 `protobuf:"varint,17,opt,name=msg_submit_proposal_gas,json=msgSubmitProposalGas,proto3" json:"msg_submit_proposal_gas,omitempty"` + MsgVoteGas uint64 `protobuf:"varint,18,opt,name=msg_vote_gas,json=msgVoteGas,proto3" json:"msg_vote_gas,omitempty"` + MsgVoteWeightedGas uint64 `protobuf:"varint,19,opt,name=msg_vote_weighted_gas,json=msgVoteWeightedGas,proto3" json:"msg_vote_weighted_gas,omitempty"` + MsgDepositGas uint64 `protobuf:"varint,20,opt,name=msg_deposit_gas,json=msgDepositGas,proto3" json:"msg_deposit_gas,omitempty"` + MsgUnjailGas uint64 `protobuf:"varint,21,opt,name=msg_unjail_gas,json=msgUnjailGas,proto3" json:"msg_unjail_gas,omitempty"` + MsgImpeachGas uint64 `protobuf:"varint,22,opt,name=msg_impeach_gas,json=msgImpeachGas,proto3" json:"msg_impeach_gas,omitempty"` + MsgEditValidatorGas uint64 `protobuf:"varint,23,opt,name=msg_edit_validator_gas,json=msgEditValidatorGas,proto3" json:"msg_edit_validator_gas,omitempty"` + MsgDelegateGas uint64 `protobuf:"varint,24,opt,name=msg_delegate_gas,json=msgDelegateGas,proto3" json:"msg_delegate_gas,omitempty"` + MsgUndelegateGas uint64 `protobuf:"varint,25,opt,name=msg_undelegate_gas,json=msgUndelegateGas,proto3" json:"msg_undelegate_gas,omitempty"` + MsgBeginRedelegateGas uint64 `protobuf:"varint,26,opt,name=msg_begin_redelegate_gas,json=msgBeginRedelegateGas,proto3" json:"msg_begin_redelegate_gas,omitempty"` + MsgCancelUnbondingDelegationGas uint64 `protobuf:"varint,27,opt,name=msg_cancel_unbonding_delegation_gas,json=msgCancelUnbondingDelegationGas,proto3" json:"msg_cancel_unbonding_delegation_gas,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -79,9 +100,9 @@ func (m *Params) GetMinGasPerByte() uint64 { return 0 } -func (m *Params) GetFixedMsgGas() uint64 { +func (m *Params) GetMsgGrantFixedGas() uint64 { if m != nil { - return m.FixedMsgGas + return m.MsgGrantFixedGas } return 0 } @@ -93,6 +114,34 @@ func (m *Params) GetMsgGrantPerItemGas() uint64 { return 0 } +func (m *Params) GetMsgRevokeGas() uint64 { + if m != nil { + return m.MsgRevokeGas + } + return 0 +} + +func (m *Params) GetMsgExecGas() uint64 { + if m != nil { + return m.MsgExecGas + } + return 0 +} + +func (m *Params) GetMsgSendGas() uint64 { + if m != nil { + return m.MsgSendGas + } + return 0 +} + +func (m *Params) GetMsgMultiSendFixedGas() uint64 { + if m != nil { + return m.MsgMultiSendFixedGas + } + return 0 +} + func (m *Params) GetMsgMultiSendPerItemGas() uint64 { if m != nil { return m.MsgMultiSendPerItemGas @@ -100,6 +149,41 @@ func (m *Params) GetMsgMultiSendPerItemGas() uint64 { return 0 } +func (m *Params) GetMsgWithdrawDelegatorRewardGas() uint64 { + if m != nil { + return m.MsgWithdrawDelegatorRewardGas + } + return 0 +} + +func (m *Params) GetMsgWithdrawValidatorCommissionGas() uint64 { + if m != nil { + return m.MsgWithdrawValidatorCommissionGas + } + return 0 +} + +func (m *Params) GetMsgSetWithdrawAddressGas() uint64 { + if m != nil { + return m.MsgSetWithdrawAddressGas + } + return 0 +} + +func (m *Params) GetMsgFundCommunityPoolGas() uint64 { + if m != nil { + return m.MsgFundCommunityPoolGas + } + return 0 +} + +func (m *Params) GetMsgGrantAllowanceFixedGas() uint64 { + if m != nil { + return m.MsgGrantAllowanceFixedGas + } + return 0 +} + func (m *Params) GetMsgGrantAllowancePerItemGas() uint64 { if m != nil { return m.MsgGrantAllowancePerItemGas @@ -107,6 +191,90 @@ func (m *Params) GetMsgGrantAllowancePerItemGas() uint64 { return 0 } +func (m *Params) GetMsgRevokeAllowanceGas() uint64 { + if m != nil { + return m.MsgRevokeAllowanceGas + } + return 0 +} + +func (m *Params) GetMsgSubmitProposalGas() uint64 { + if m != nil { + return m.MsgSubmitProposalGas + } + return 0 +} + +func (m *Params) GetMsgVoteGas() uint64 { + if m != nil { + return m.MsgVoteGas + } + return 0 +} + +func (m *Params) GetMsgVoteWeightedGas() uint64 { + if m != nil { + return m.MsgVoteWeightedGas + } + return 0 +} + +func (m *Params) GetMsgDepositGas() uint64 { + if m != nil { + return m.MsgDepositGas + } + return 0 +} + +func (m *Params) GetMsgUnjailGas() uint64 { + if m != nil { + return m.MsgUnjailGas + } + return 0 +} + +func (m *Params) GetMsgImpeachGas() uint64 { + if m != nil { + return m.MsgImpeachGas + } + return 0 +} + +func (m *Params) GetMsgEditValidatorGas() uint64 { + if m != nil { + return m.MsgEditValidatorGas + } + return 0 +} + +func (m *Params) GetMsgDelegateGas() uint64 { + if m != nil { + return m.MsgDelegateGas + } + return 0 +} + +func (m *Params) GetMsgUndelegateGas() uint64 { + if m != nil { + return m.MsgUndelegateGas + } + return 0 +} + +func (m *Params) GetMsgBeginRedelegateGas() uint64 { + if m != nil { + return m.MsgBeginRedelegateGas + } + return 0 +} + +func (m *Params) GetMsgCancelUnbondingDelegationGas() uint64 { + if m != nil { + return m.MsgCancelUnbondingDelegationGas + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "cosmos.gashub.v1alpha1.Params") } @@ -116,32 +284,69 @@ func init() { } var fileDescriptor_f79bf23b48853a4a = []byte{ - // 400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0xcb, 0xd3, 0x30, - 0x18, 0xc7, 0x5b, 0xdf, 0xd7, 0xe1, 0x9b, 0x51, 0xd4, 0x20, 0x65, 0xbc, 0x83, 0xe6, 0x45, 0x2f, - 0x82, 0x6c, 0x65, 0xec, 0xb6, 0x9b, 0x03, 0x1d, 0x0a, 0x85, 0xb1, 0x09, 0x82, 0x97, 0x92, 0xad, - 0x59, 0x16, 0x6c, 0x9a, 0xd2, 0x64, 0xda, 0xed, 0x53, 0x78, 0xf4, 0xb8, 0x6f, 0xe2, 0xd5, 0xe3, - 0x8e, 0x9e, 0x8a, 0x64, 0x17, 0x3f, 0x86, 0x24, 0x5b, 0xd9, 0x86, 0xbe, 0xa7, 0xe4, 0x79, 0xf2, - 0x7b, 0x7e, 0x79, 0x0e, 0x7f, 0xf0, 0x62, 0x2e, 0x24, 0x17, 0x32, 0xa4, 0x58, 0x2e, 0x57, 0xb3, - 0xf0, 0x4b, 0x0f, 0xa7, 0xf9, 0x12, 0xf7, 0x8e, 0x75, 0x37, 0x2f, 0x84, 0x12, 0xd0, 0x3f, 0x40, - 0xdd, 0x63, 0xb3, 0x86, 0x6e, 0x9f, 0x51, 0x41, 0x85, 0x45, 0x42, 0x73, 0x3b, 0xd0, 0xcf, 0x7f, - 0x5c, 0x81, 0xc6, 0x18, 0x17, 0x98, 0x4b, 0xd8, 0x01, 0x4d, 0x8e, 0xcb, 0x58, 0x95, 0xb1, 0x64, - 0x1b, 0xd2, 0x72, 0xef, 0xdc, 0x97, 0xd7, 0x43, 0x4f, 0x57, 0xe8, 0x26, 0xc2, 0xe5, 0x87, 0x72, - 0xca, 0x36, 0x64, 0x72, 0xc3, 0xeb, 0x2b, 0x1c, 0x80, 0x27, 0x9c, 0x65, 0x31, 0xc5, 0x32, 0xce, - 0x49, 0x11, 0xcf, 0xd6, 0x8a, 0xb4, 0x1e, 0xd8, 0x99, 0xa7, 0xba, 0x42, 0x5e, 0xc4, 0xb2, 0x11, - 0x96, 0x63, 0x52, 0x0c, 0xd7, 0x8a, 0x4c, 0x3c, 0x7e, 0x5e, 0xc2, 0x3e, 0xf0, 0x16, 0xac, 0x24, - 0x49, 0xcc, 0x25, 0x35, 0x86, 0xd6, 0x95, 0x1d, 0x7c, 0xac, 0x2b, 0xd4, 0x7c, 0x6b, 0x1e, 0x22, - 0x49, 0x47, 0x58, 0x4e, 0x9a, 0x8b, 0x53, 0x01, 0xdf, 0x03, 0xdf, 0xe2, 0x05, 0xce, 0x94, 0xfd, - 0x92, 0x29, 0xc2, 0xed, 0xf4, 0xb5, 0x9d, 0xf6, 0x75, 0x85, 0xa0, 0x61, 0x0d, 0x30, 0x26, 0xc5, - 0x3b, 0x45, 0xb8, 0x91, 0x40, 0xfe, 0x4f, 0x0f, 0x7e, 0x04, 0x6d, 0xe3, 0xe2, 0xab, 0x54, 0xb1, - 0x58, 0x92, 0x2c, 0xb9, 0x14, 0x3e, 0xb4, 0xc2, 0x5b, 0x5d, 0x21, 0x3f, 0x92, 0x34, 0x32, 0xd4, - 0x94, 0x64, 0xc9, 0x99, 0xd4, 0xac, 0xf2, 0x9f, 0x3e, 0x5c, 0x80, 0xbb, 0xd3, 0x92, 0x38, 0x4d, - 0xc5, 0x57, 0x9c, 0xcd, 0xc9, 0xa5, 0xbd, 0x61, 0xed, 0x48, 0x57, 0xa8, 0x5d, 0xaf, 0xfb, 0xba, - 0x26, 0xcf, 0xbe, 0x68, 0xf3, 0xfb, 0x1f, 0x07, 0x8f, 0xbe, 0x6f, 0x91, 0xf3, 0x67, 0x8b, 0xdc, - 0xe1, 0x9b, 0x9f, 0x3a, 0x70, 0x77, 0x3a, 0x70, 0x7f, 0xeb, 0xc0, 0xfd, 0xb6, 0x0f, 0x9c, 0xdd, - 0x3e, 0x70, 0x7e, 0xed, 0x03, 0xe7, 0xd3, 0x2b, 0xca, 0x94, 0x89, 0xc0, 0x5c, 0xf0, 0xf0, 0x98, - 0x9c, 0xc3, 0xd1, 0x91, 0xc9, 0xe7, 0xb0, 0xac, 0x63, 0xa4, 0xd6, 0x39, 0x91, 0xb3, 0x86, 0xcd, - 0x43, 0xff, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x24, 0x68, 0xb2, 0xf5, 0x64, 0x02, 0x00, 0x00, + // 986 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x56, 0x4f, 0x6f, 0xdb, 0x36, + 0x14, 0x8f, 0xb7, 0x2e, 0x6b, 0xd8, 0xd8, 0x75, 0x19, 0xc7, 0x76, 0xe2, 0xc6, 0x6c, 0x16, 0x14, + 0x18, 0x30, 0xb4, 0x5e, 0x31, 0x60, 0xc0, 0x8a, 0x5d, 0xea, 0xa4, 0x0d, 0x32, 0x4c, 0x98, 0xe1, + 0x2c, 0x0d, 0x36, 0x0c, 0x10, 0x68, 0x8b, 0x91, 0xb9, 0x98, 0xa2, 0x27, 0xd2, 0xb1, 0xd3, 0x4f, + 0xb1, 0xe3, 0x8e, 0x3d, 0xec, 0xc3, 0xec, 0xd8, 0xe3, 0x4e, 0xc2, 0xc0, 0x5c, 0xf6, 0x31, 0x06, + 0x92, 0xa2, 0x2c, 0x25, 0x4e, 0x76, 0xb2, 0xf8, 0xde, 0xef, 0x8f, 0x49, 0xbe, 0xf7, 0x24, 0xb0, + 0x37, 0xe4, 0x82, 0x71, 0xd1, 0x09, 0xb1, 0x18, 0x4d, 0x07, 0x9d, 0x8b, 0x17, 0x78, 0x3c, 0x19, + 0xe1, 0x17, 0xe9, 0xfa, 0xf9, 0x24, 0xe6, 0x92, 0xc3, 0xba, 0x05, 0x3d, 0x4f, 0x83, 0x0e, 0xb4, + 0x5d, 0x0b, 0x79, 0xc8, 0x0d, 0xa4, 0xa3, 0x9f, 0x2c, 0xfa, 0xb3, 0x3f, 0xab, 0x60, 0xb5, 0x87, + 0x63, 0xcc, 0x04, 0x7c, 0x06, 0x1e, 0x30, 0x3c, 0xf7, 0xe5, 0xdc, 0x17, 0xf4, 0x1d, 0x69, 0x96, + 0x9e, 0x94, 0x3e, 0xbf, 0xd7, 0x2d, 0xab, 0x04, 0xad, 0x79, 0x78, 0xfe, 0xe3, 0xfc, 0x98, 0xbe, + 0x23, 0xfd, 0x35, 0xe6, 0x1e, 0xe1, 0x4b, 0x50, 0x65, 0x34, 0xf2, 0x43, 0x2c, 0xfc, 0x09, 0x89, + 0xfd, 0xc1, 0xa5, 0x24, 0xcd, 0x8f, 0x0c, 0xe7, 0x91, 0x4a, 0x50, 0xd9, 0xa3, 0xd1, 0x21, 0x16, + 0x3d, 0x12, 0x77, 0x2f, 0x25, 0xe9, 0x97, 0x59, 0x7e, 0x09, 0xf7, 0xc1, 0x06, 0x13, 0xa1, 0x1f, + 0xc6, 0x38, 0x92, 0xfe, 0x19, 0x9d, 0x93, 0x40, 0xeb, 0x34, 0x3f, 0x36, 0xf4, 0x9a, 0x4a, 0x50, + 0xd5, 0x13, 0xe1, 0xa1, 0xce, 0xbe, 0xd1, 0xc9, 0x43, 0x2c, 0xfa, 0x55, 0x76, 0x2d, 0x02, 0xbf, + 0x03, 0xf5, 0x85, 0x88, 0xfe, 0x0b, 0x54, 0x12, 0x66, 0x74, 0xee, 0x19, 0x9d, 0xba, 0x4a, 0x10, + 0x74, 0x3a, 0x3d, 0x12, 0x1f, 0x49, 0xc2, 0xb4, 0x12, 0x64, 0x37, 0x62, 0xf0, 0x6b, 0x50, 0xd1, + 0x5a, 0x31, 0xb9, 0xe0, 0xe7, 0xc4, 0x68, 0x7c, 0x62, 0x34, 0xaa, 0x2a, 0x41, 0xeb, 0x9e, 0x08, + 0xfb, 0x26, 0xa1, 0xd9, 0xeb, 0x2c, 0xb7, 0x82, 0x5f, 0x02, 0xbd, 0xf6, 0xc9, 0x9c, 0x0c, 0x0d, + 0x6b, 0xd5, 0xb0, 0x2a, 0x2a, 0x41, 0xc0, 0x13, 0xe1, 0xeb, 0x39, 0x19, 0x6a, 0x0e, 0x60, 0xd9, + 0xb3, 0x63, 0x08, 0x12, 0xd9, 0x3d, 0x7f, 0x5a, 0x60, 0x1c, 0x93, 0x28, 0x70, 0x8c, 0xf4, 0x19, + 0xf6, 0x40, 0x53, 0x33, 0xd8, 0x74, 0x2c, 0xa9, 0xe5, 0x2d, 0x4e, 0xec, 0xbe, 0x61, 0x37, 0x55, + 0x82, 0x6a, 0x9e, 0x08, 0x3d, 0x0d, 0xd1, 0xb4, 0xec, 0xd4, 0x6a, 0x6c, 0x49, 0x14, 0x9e, 0x82, + 0xd6, 0x35, 0xc5, 0xc2, 0xf1, 0xad, 0x19, 0xd1, 0x6d, 0x95, 0xa0, 0x7a, 0x5e, 0x34, 0x77, 0x84, + 0x75, 0xb6, 0x34, 0x0e, 0xcf, 0xc1, 0xae, 0x16, 0x9e, 0x51, 0x39, 0x0a, 0x62, 0x3c, 0xf3, 0x03, + 0x32, 0x26, 0x21, 0x96, 0x3c, 0xf6, 0x63, 0x32, 0xc3, 0xb1, 0xfd, 0xcf, 0xc0, 0xc8, 0xef, 0xaa, + 0x04, 0xed, 0x78, 0x22, 0x3c, 0x4d, 0xb1, 0x07, 0x0e, 0xda, 0x37, 0x48, 0xed, 0xb2, 0xc3, 0xee, + 0x4a, 0xc3, 0x19, 0x78, 0x5a, 0x30, 0xbb, 0xc0, 0x63, 0x1a, 0x18, 0xb3, 0x21, 0x67, 0x8c, 0x0a, + 0x41, 0xb9, 0x29, 0xcf, 0xe6, 0x03, 0x63, 0xf8, 0x54, 0x25, 0x68, 0x37, 0x67, 0xf8, 0xd6, 0xc1, + 0xf7, 0x33, 0xb4, 0x36, 0xdd, 0x65, 0xff, 0x07, 0x81, 0xbf, 0x80, 0xc7, 0xf6, 0x0a, 0xe5, 0xc2, + 0x1c, 0x07, 0x41, 0x4c, 0x84, 0x30, 0x7e, 0xeb, 0xc6, 0xef, 0xb1, 0x4a, 0x50, 0xd3, 0x5c, 0xa9, + 0x74, 0x7a, 0xaf, 0x2c, 0x48, 0xdb, 0x34, 0xd9, 0x2d, 0x19, 0xf8, 0x93, 0xbd, 0x9c, 0xb3, 0x69, + 0x14, 0x98, 0x8d, 0x4c, 0x23, 0x2a, 0x2f, 0xfd, 0x09, 0xe7, 0x63, 0x23, 0x5e, 0x36, 0xe2, 0x2d, + 0x95, 0xa0, 0x86, 0x27, 0xc2, 0x37, 0xd3, 0x28, 0xd8, 0x77, 0xa0, 0x1e, 0xe7, 0x63, 0xad, 0xdd, + 0x60, 0xcb, 0x13, 0xd0, 0x07, 0x3b, 0x8b, 0x8e, 0xc1, 0xe3, 0x31, 0x9f, 0xe1, 0x68, 0x48, 0x72, + 0xe5, 0x54, 0x31, 0xe2, 0x3b, 0x2a, 0x41, 0x5b, 0xae, 0x71, 0x5e, 0x39, 0x58, 0x56, 0x53, 0x5b, + 0xec, 0xb6, 0x14, 0x3c, 0x03, 0x4f, 0x96, 0x19, 0x14, 0xaa, 0xeb, 0xa1, 0xf1, 0x40, 0x2a, 0x41, + 0xad, 0x1b, 0x1e, 0xb9, 0x12, 0x6b, 0xb1, 0xdb, 0x93, 0xb0, 0x6f, 0x5b, 0x22, 0x6d, 0xd7, 0x85, + 0x91, 0xd6, 0xaf, 0x1a, 0xfd, 0x2d, 0x95, 0xa0, 0xcd, 0xac, 0x71, 0x33, 0x0d, 0xad, 0xbc, 0xc9, + 0x96, 0x85, 0xe1, 0x0f, 0xa0, 0x61, 0x6e, 0x75, 0x3a, 0x60, 0x54, 0xfa, 0x93, 0x98, 0x4f, 0xb8, + 0xc0, 0xf6, 0xcc, 0x1f, 0x15, 0xba, 0xec, 0xd8, 0x20, 0x7a, 0x29, 0xc0, 0x75, 0xd9, 0x8d, 0xa8, + 0xeb, 0xf4, 0x0b, 0x2e, 0xed, 0x1f, 0x83, 0x85, 0x4e, 0x7f, 0xcb, 0x25, 0x71, 0x9d, 0x9e, 0x3e, + 0xc3, 0x23, 0xb0, 0x99, 0x31, 0x66, 0x84, 0x86, 0x23, 0x99, 0xde, 0xcb, 0x46, 0x61, 0xa0, 0x69, + 0xf8, 0x69, 0x9a, 0x76, 0x03, 0xed, 0x5a, 0x0c, 0x7e, 0x03, 0x1e, 0x6a, 0xa9, 0x80, 0x4c, 0xb8, + 0xa0, 0xd2, 0x88, 0xd4, 0x72, 0xc3, 0x59, 0x84, 0x07, 0x36, 0xa3, 0xf9, 0x65, 0x96, 0x5f, 0xba, + 0x59, 0x38, 0x8d, 0x7e, 0xc5, 0xd4, 0xee, 0x7f, 0xb3, 0x30, 0x0b, 0x4f, 0x4c, 0xc2, 0xcd, 0xc2, + 0x6c, 0xe5, 0x2c, 0x29, 0x9b, 0x10, 0x3c, 0x1c, 0x19, 0x62, 0xbd, 0x60, 0x79, 0x64, 0x33, 0xce, + 0x72, 0xb1, 0x84, 0xdf, 0xdb, 0x51, 0x4e, 0x02, 0x2a, 0x73, 0x6d, 0xac, 0x15, 0x1a, 0x46, 0xa1, + 0xa1, 0x12, 0xb4, 0xa1, 0x07, 0x6a, 0x40, 0x65, 0xd6, 0x94, 0x5a, 0x47, 0xbf, 0x46, 0xae, 0x07, + 0xe1, 0xb7, 0xa0, 0x6a, 0xf7, 0x6e, 0x46, 0x86, 0x3d, 0xfc, 0xa6, 0xd1, 0x81, 0x2a, 0x41, 0x15, + 0xb3, 0x79, 0x9b, 0xd2, 0x12, 0x15, 0x56, 0x58, 0xc3, 0x2e, 0x80, 0x76, 0xfb, 0x05, 0xfe, 0x56, + 0xe1, 0xd5, 0x74, 0x92, 0x25, 0xdd, 0xab, 0xa9, 0x10, 0x71, 0xf5, 0x39, 0x20, 0x21, 0x8d, 0xfc, + 0x98, 0x14, 0x94, 0xb6, 0x0b, 0xf5, 0xd9, 0xd5, 0x90, 0x3e, 0xc9, 0xcb, 0xe9, 0x1a, 0xb8, 0x19, + 0x86, 0xbf, 0x81, 0x3d, 0xad, 0x39, 0xd4, 0xf5, 0x3a, 0xf6, 0xa7, 0xd1, 0x80, 0x47, 0x01, 0x8d, + 0xb2, 0x6d, 0xba, 0x61, 0xd7, 0x32, 0xf2, 0x7b, 0x2a, 0x41, 0xc8, 0x13, 0xe1, 0xbe, 0x41, 0x9f, + 0x38, 0xf0, 0x41, 0x86, 0xd5, 0x46, 0x88, 0xdd, 0x0d, 0x78, 0x79, 0xff, 0x8f, 0xf7, 0x68, 0xe5, + 0xdf, 0xf7, 0xa8, 0xd4, 0x7d, 0xfd, 0x97, 0x6a, 0x97, 0x3e, 0xa8, 0x76, 0xe9, 0x1f, 0xd5, 0x2e, + 0xfd, 0x7e, 0xd5, 0x5e, 0xf9, 0x70, 0xd5, 0x5e, 0xf9, 0xfb, 0xaa, 0xbd, 0xf2, 0xf3, 0x17, 0x21, + 0x95, 0xfa, 0x3b, 0x63, 0xc8, 0x59, 0x27, 0xfd, 0x3c, 0xb1, 0x3f, 0xcf, 0x44, 0x70, 0xde, 0x99, + 0xbb, 0x6f, 0x15, 0x79, 0x39, 0x21, 0x62, 0xb0, 0x6a, 0x3e, 0x3a, 0xbe, 0xfa, 0x2f, 0x00, 0x00, + 0xff, 0xff, 0x58, 0x22, 0xf1, 0x68, 0xc9, 0x08, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -169,18 +374,81 @@ func (this *Params) Equal(that interface{}) bool { if this.MinGasPerByte != that1.MinGasPerByte { return false } - if this.FixedMsgGas != that1.FixedMsgGas { + if this.MsgGrantFixedGas != that1.MsgGrantFixedGas { return false } if this.MsgGrantPerItemGas != that1.MsgGrantPerItemGas { return false } + if this.MsgRevokeGas != that1.MsgRevokeGas { + return false + } + if this.MsgExecGas != that1.MsgExecGas { + return false + } + if this.MsgSendGas != that1.MsgSendGas { + return false + } + if this.MsgMultiSendFixedGas != that1.MsgMultiSendFixedGas { + return false + } if this.MsgMultiSendPerItemGas != that1.MsgMultiSendPerItemGas { return false } + if this.MsgWithdrawDelegatorRewardGas != that1.MsgWithdrawDelegatorRewardGas { + return false + } + if this.MsgWithdrawValidatorCommissionGas != that1.MsgWithdrawValidatorCommissionGas { + return false + } + if this.MsgSetWithdrawAddressGas != that1.MsgSetWithdrawAddressGas { + return false + } + if this.MsgFundCommunityPoolGas != that1.MsgFundCommunityPoolGas { + return false + } + if this.MsgGrantAllowanceFixedGas != that1.MsgGrantAllowanceFixedGas { + return false + } if this.MsgGrantAllowancePerItemGas != that1.MsgGrantAllowancePerItemGas { return false } + if this.MsgRevokeAllowanceGas != that1.MsgRevokeAllowanceGas { + return false + } + if this.MsgSubmitProposalGas != that1.MsgSubmitProposalGas { + return false + } + if this.MsgVoteGas != that1.MsgVoteGas { + return false + } + if this.MsgVoteWeightedGas != that1.MsgVoteWeightedGas { + return false + } + if this.MsgDepositGas != that1.MsgDepositGas { + return false + } + if this.MsgUnjailGas != that1.MsgUnjailGas { + return false + } + if this.MsgImpeachGas != that1.MsgImpeachGas { + return false + } + if this.MsgEditValidatorGas != that1.MsgEditValidatorGas { + return false + } + if this.MsgDelegateGas != that1.MsgDelegateGas { + return false + } + if this.MsgUndelegateGas != that1.MsgUndelegateGas { + return false + } + if this.MsgBeginRedelegateGas != that1.MsgBeginRedelegateGas { + return false + } + if this.MsgCancelUnbondingDelegationGas != that1.MsgCancelUnbondingDelegationGas { + return false + } return true } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -203,14 +471,143 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MsgCancelUnbondingDelegationGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgCancelUnbondingDelegationGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd8 + } + if m.MsgBeginRedelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgBeginRedelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd0 + } + if m.MsgUndelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgUndelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc8 + } + if m.MsgDelegateGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgDelegateGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc0 + } + if m.MsgEditValidatorGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgEditValidatorGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb8 + } + if m.MsgImpeachGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgImpeachGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb0 + } + if m.MsgUnjailGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgUnjailGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa8 + } + if m.MsgDepositGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgDepositGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa0 + } + if m.MsgVoteWeightedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteWeightedGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x98 + } + if m.MsgVoteGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgVoteGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x90 + } + if m.MsgSubmitProposalGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSubmitProposalGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x88 + } + if m.MsgRevokeAllowanceGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeAllowanceGas)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } if m.MsgGrantAllowancePerItemGas != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowancePerItemGas)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x78 + } + if m.MsgGrantAllowanceFixedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantAllowanceFixedGas)) + i-- + dAtA[i] = 0x70 + } + if m.MsgFundCommunityPoolGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgFundCommunityPoolGas)) + i-- + dAtA[i] = 0x68 + } + if m.MsgSetWithdrawAddressGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSetWithdrawAddressGas)) + i-- + dAtA[i] = 0x60 + } + if m.MsgWithdrawValidatorCommissionGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawValidatorCommissionGas)) + i-- + dAtA[i] = 0x58 + } + if m.MsgWithdrawDelegatorRewardGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgWithdrawDelegatorRewardGas)) + i-- + dAtA[i] = 0x50 } if m.MsgMultiSendPerItemGas != 0 { i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendPerItemGas)) i-- + dAtA[i] = 0x48 + } + if m.MsgMultiSendFixedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgMultiSendFixedGas)) + i-- + dAtA[i] = 0x40 + } + if m.MsgSendGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgSendGas)) + i-- + dAtA[i] = 0x38 + } + if m.MsgExecGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgExecGas)) + i-- + dAtA[i] = 0x30 + } + if m.MsgRevokeGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgRevokeGas)) + i-- dAtA[i] = 0x28 } if m.MsgGrantPerItemGas != 0 { @@ -218,8 +615,8 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if m.FixedMsgGas != 0 { - i = encodeVarintGashub(dAtA, i, uint64(m.FixedMsgGas)) + if m.MsgGrantFixedGas != 0 { + i = encodeVarintGashub(dAtA, i, uint64(m.MsgGrantFixedGas)) i-- dAtA[i] = 0x18 } @@ -259,18 +656,81 @@ func (m *Params) Size() (n int) { if m.MinGasPerByte != 0 { n += 1 + sovGashub(uint64(m.MinGasPerByte)) } - if m.FixedMsgGas != 0 { - n += 1 + sovGashub(uint64(m.FixedMsgGas)) + if m.MsgGrantFixedGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantFixedGas)) } if m.MsgGrantPerItemGas != 0 { n += 1 + sovGashub(uint64(m.MsgGrantPerItemGas)) } + if m.MsgRevokeGas != 0 { + n += 1 + sovGashub(uint64(m.MsgRevokeGas)) + } + if m.MsgExecGas != 0 { + n += 1 + sovGashub(uint64(m.MsgExecGas)) + } + if m.MsgSendGas != 0 { + n += 1 + sovGashub(uint64(m.MsgSendGas)) + } + if m.MsgMultiSendFixedGas != 0 { + n += 1 + sovGashub(uint64(m.MsgMultiSendFixedGas)) + } if m.MsgMultiSendPerItemGas != 0 { n += 1 + sovGashub(uint64(m.MsgMultiSendPerItemGas)) } + if m.MsgWithdrawDelegatorRewardGas != 0 { + n += 1 + sovGashub(uint64(m.MsgWithdrawDelegatorRewardGas)) + } + if m.MsgWithdrawValidatorCommissionGas != 0 { + n += 1 + sovGashub(uint64(m.MsgWithdrawValidatorCommissionGas)) + } + if m.MsgSetWithdrawAddressGas != 0 { + n += 1 + sovGashub(uint64(m.MsgSetWithdrawAddressGas)) + } + if m.MsgFundCommunityPoolGas != 0 { + n += 1 + sovGashub(uint64(m.MsgFundCommunityPoolGas)) + } + if m.MsgGrantAllowanceFixedGas != 0 { + n += 1 + sovGashub(uint64(m.MsgGrantAllowanceFixedGas)) + } if m.MsgGrantAllowancePerItemGas != 0 { n += 1 + sovGashub(uint64(m.MsgGrantAllowancePerItemGas)) } + if m.MsgRevokeAllowanceGas != 0 { + n += 2 + sovGashub(uint64(m.MsgRevokeAllowanceGas)) + } + if m.MsgSubmitProposalGas != 0 { + n += 2 + sovGashub(uint64(m.MsgSubmitProposalGas)) + } + if m.MsgVoteGas != 0 { + n += 2 + sovGashub(uint64(m.MsgVoteGas)) + } + if m.MsgVoteWeightedGas != 0 { + n += 2 + sovGashub(uint64(m.MsgVoteWeightedGas)) + } + if m.MsgDepositGas != 0 { + n += 2 + sovGashub(uint64(m.MsgDepositGas)) + } + if m.MsgUnjailGas != 0 { + n += 2 + sovGashub(uint64(m.MsgUnjailGas)) + } + if m.MsgImpeachGas != 0 { + n += 2 + sovGashub(uint64(m.MsgImpeachGas)) + } + if m.MsgEditValidatorGas != 0 { + n += 2 + sovGashub(uint64(m.MsgEditValidatorGas)) + } + if m.MsgDelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgDelegateGas)) + } + if m.MsgUndelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgUndelegateGas)) + } + if m.MsgBeginRedelegateGas != 0 { + n += 2 + sovGashub(uint64(m.MsgBeginRedelegateGas)) + } + if m.MsgCancelUnbondingDelegationGas != 0 { + n += 2 + sovGashub(uint64(m.MsgCancelUnbondingDelegationGas)) + } return n } @@ -349,9 +809,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FixedMsgGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantFixedGas", wireType) } - m.FixedMsgGas = 0 + m.MsgGrantFixedGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -361,7 +821,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.FixedMsgGas |= uint64(b&0x7F) << shift + m.MsgGrantFixedGas |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -387,9 +847,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { } case 5: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendPerItemGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeGas", wireType) } - m.MsgMultiSendPerItemGas = 0 + m.MsgRevokeGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -399,16 +859,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgMultiSendPerItemGas |= uint64(b&0x7F) << shift + m.MsgRevokeGas |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 6: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowancePerItemGas", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MsgExecGas", wireType) } - m.MsgGrantAllowancePerItemGas = 0 + m.MsgExecGas = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGashub @@ -418,7 +878,406 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MsgGrantAllowancePerItemGas |= uint64(b&0x7F) << shift + m.MsgExecGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSendGas", wireType) + } + m.MsgSendGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSendGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendFixedGas", wireType) + } + m.MsgMultiSendFixedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgMultiSendFixedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgMultiSendPerItemGas", wireType) + } + m.MsgMultiSendPerItemGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgMultiSendPerItemGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawDelegatorRewardGas", wireType) + } + m.MsgWithdrawDelegatorRewardGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgWithdrawDelegatorRewardGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgWithdrawValidatorCommissionGas", wireType) + } + m.MsgWithdrawValidatorCommissionGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgWithdrawValidatorCommissionGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 12: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSetWithdrawAddressGas", wireType) + } + m.MsgSetWithdrawAddressGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSetWithdrawAddressGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 13: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgFundCommunityPoolGas", wireType) + } + m.MsgFundCommunityPoolGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgFundCommunityPoolGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowanceFixedGas", wireType) + } + m.MsgGrantAllowanceFixedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgGrantAllowanceFixedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgGrantAllowancePerItemGas", wireType) + } + m.MsgGrantAllowancePerItemGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgGrantAllowancePerItemGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 16: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgRevokeAllowanceGas", wireType) + } + m.MsgRevokeAllowanceGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgRevokeAllowanceGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 17: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitProposalGas", wireType) + } + m.MsgSubmitProposalGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgSubmitProposalGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 18: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteGas", wireType) + } + m.MsgVoteGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgVoteGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 19: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgVoteWeightedGas", wireType) + } + m.MsgVoteWeightedGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgVoteWeightedGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 20: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgDepositGas", wireType) + } + m.MsgDepositGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgDepositGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 21: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgUnjailGas", wireType) + } + m.MsgUnjailGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgUnjailGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 22: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgImpeachGas", wireType) + } + m.MsgImpeachGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgImpeachGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 23: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgEditValidatorGas", wireType) + } + m.MsgEditValidatorGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgEditValidatorGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 24: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgDelegateGas", wireType) + } + m.MsgDelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgDelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 25: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgUndelegateGas", wireType) + } + m.MsgUndelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgUndelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 26: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgBeginRedelegateGas", wireType) + } + m.MsgBeginRedelegateGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgBeginRedelegateGas |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 27: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgCancelUnbondingDelegationGas", wireType) + } + m.MsgCancelUnbondingDelegationGas = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGashub + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MsgCancelUnbondingDelegationGas |= uint64(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index 19cf0a7a88..c401525f92 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -10,37 +10,104 @@ import ( // Default parameter values const ( - DefaultMaxTxSize uint64 = 1024 - DefaultMinGasPerByte uint64 = 5 - DefaultFixedMsgGas uint64 = 1e5 - DefaultMsgGrantPerItemGas uint64 = 1e5 - DefaultMsgMultiSendPerItemGas uint64 = 1e5 - DefaultMsgGrantAllowancePerItemGas uint64 = 1e5 + DefaultMaxTxSize uint64 = 1024 + DefaultMinGasPerByte uint64 = 5 + DefaultMsgGrantFixedGas uint64 = 1e5 + DefaultMsgGrantPerItemGas uint64 = 1e5 + DefaultMsgRevokeGas uint64 = 1e5 + DefaultMsgExecGas uint64 = 1e5 + DefaultMsgSendGas uint64 = 1e5 + DefaultMsgMultiSendFixedGas uint64 = 1e5 + DefaultMsgMultiSendPerItemGas uint64 = 1e5 + DefaultMsgWithdrawDelegatorRewardGas uint64 = 1e5 + DefaultMsgWithdrawValidatorCommissionGas uint64 = 1e5 + DefaultMsgSetWithdrawAddressGas uint64 = 1e5 + DefaultMsgFundCommunityPoolGas uint64 = 1e5 + DefaultMsgGrantAllowanceFixedGas uint64 = 1e5 + DefaultMsgGrantAllowancePerItemGas uint64 = 1e5 + DefaultMsgRevokeAllowanceGas uint64 = 1e5 + DefaultMsgSubmitProposalGas uint64 = 1e5 + DefaultMsgVoteGas uint64 = 1e5 + DefaultMsgVoteWeightedGas uint64 = 1e5 + DefaultMsgDepositGas uint64 = 1e5 + DefaultMsgUnjailGas uint64 = 1e5 + DefaultMsgImpeachGas uint64 = 1e5 + DefaultMsgEditValidatorGas uint64 = 1e5 + DefaultMsgDelegateGas uint64 = 1e5 + DefaultMsgUndelegateGas uint64 = 1e5 + DefaultMsgBeginRedelegateGas uint64 = 1e5 + DefaultMsgCancelUnbondingDelegationGas uint64 = 1e5 ) // Parameter keys var ( - KeyMaxTxSize = []byte("MaxTxSize") - KeyMinGasPerByte = []byte("MinGasPerByte") - KeyFixedMsgGas = []byte("FixedMsgGas") - KeyMsgGrantPerItemGas = []byte("MsgGrantPerItemGas") - KeyMsgMultiSendPerItemGas = []byte("MsgMultiSendPerItemGas") - KeyMsgGrantAllowancePerItemGas = []byte("MsgGrantAllowancePerItemGas") + KeyMaxTxSize = []byte("MaxTxSize") + KeyMinGasPerByte = []byte("MinGasPerByte") + KeyMsgGrantFixedGas = []byte("MsgGrantFixedGas") + KeyMsgGrantPerItemGas = []byte("MsgGrantPerItemGas") + KeyMsgRevokeGas = []byte("MsgRevokeGas") + KeyMsgExecGas = []byte("MsgExecGas") + KeyMsgSendGas = []byte("MsgSendGas") + KeyMsgMultiSendFixedGas = []byte("MsgMultiSendFixedGas") + KeyMsgMultiSendPerItemGas = []byte("MsgMultiSendPerItemGas") + KeyMsgWithdrawDelegatorRewardGas = []byte("MsgWithdrawDelegatorRewardGas") + KeyMsgWithdrawValidatorCommissionGas = []byte("MsgWithdrawValidatorCommissionGas") + KeyMsgSetWithdrawAddressGas = []byte("MsgSetWithdrawAddressGas") + KeyMsgFundCommunityPoolGas = []byte("MsgFundCommunityPoolGas") + KeyMsgGrantAllowanceFixedGas = []byte("MsgGrantAllowanceFixedGas") + KeyMsgGrantAllowancePerItemGas = []byte("MsgGrantAllowancePerItemGas") + KeyMsgRevokeAllowanceGas = []byte("MsgRevokeAllowanceGas") + KeyMsgSubmitProposalGas = []byte("MsgSubmitProposalGas") + KeyMsgVoteGas = []byte("MsgVoteGas") + KeyMsgVoteWeightedGas = []byte("MsgVoteWeightedGas") + KeyMsgDepositGas = []byte("MsgDepositGas") + KeyMsgUnjailGas = []byte("MsgUnjailGas") + KeyMsgImpeachGas = []byte("MsgImpeachGas") + KeyMsgEditValidatorGas = []byte("MsgEditValidatorGas") + KeyMsgDelegateGas = []byte("MsgDelegateGas") + KeyMsgUndelegateGas = []byte("MsgUndelegateGas") + KeyMsgBeginRedelegateGas = []byte("MsgBeginRedelegateGas") + KeyMsgCancelUnbondingDelegationGas = []byte("MsgCancelUnbondingDelegationGas") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxTxSize, minGasPerByte, fixedMsgGas, msgGrantPerItemGas, msgMultiSendPerItemGas, msgGrantAllowancePerItemGas uint64, + maxTxSize, minGasPerByte, msgGrantFixedGas, msgGrantPerItemGas, msgRevokeGas, msgExecGas, msgSendGas, msgMultiSendFixedGas, + msgMultiSendPerItemGas, msgWithdrawDelegatorRewardGas, msgWithdrawValidatorCommissionGas, msgSetWithdrawAddressGas, + msgFundCommunityPoolGas, msgGrantAllowanceFixedGas, msgGrantAllowancePerItemGas, msgRevokeAllowanceGas, msgSubmitProposalGas, + msgVoteGas, msgVoteWeightedGas, msgDepositGas, msgUnjailGas, msgImpeachGas, msgEditValidatorGas, msgDelegateGas, + msgUndelegateGas, msgBeginRedelegateGas, msgCancelUnbondingDelegationGas uint64, ) Params { return Params{ - MaxTxSize: maxTxSize, - MinGasPerByte: minGasPerByte, - FixedMsgGas: fixedMsgGas, - MsgGrantPerItemGas: msgGrantPerItemGas, - MsgMultiSendPerItemGas: msgMultiSendPerItemGas, - MsgGrantAllowancePerItemGas: msgGrantAllowancePerItemGas, + MaxTxSize: maxTxSize, + MinGasPerByte: minGasPerByte, + MsgGrantFixedGas: msgGrantFixedGas, + MsgGrantPerItemGas: msgGrantPerItemGas, + MsgRevokeGas: msgRevokeGas, + MsgExecGas: msgExecGas, + MsgSendGas: msgSendGas, + MsgMultiSendFixedGas: msgMultiSendFixedGas, + MsgMultiSendPerItemGas: msgMultiSendPerItemGas, + MsgWithdrawDelegatorRewardGas: msgWithdrawDelegatorRewardGas, + MsgWithdrawValidatorCommissionGas: msgWithdrawValidatorCommissionGas, + MsgSetWithdrawAddressGas: msgSetWithdrawAddressGas, + MsgFundCommunityPoolGas: msgFundCommunityPoolGas, + MsgGrantAllowanceFixedGas: msgGrantAllowanceFixedGas, + MsgGrantAllowancePerItemGas: msgGrantAllowancePerItemGas, + MsgRevokeAllowanceGas: msgRevokeAllowanceGas, + MsgSubmitProposalGas: msgSubmitProposalGas, + MsgVoteGas: msgVoteGas, + MsgVoteWeightedGas: msgVoteWeightedGas, + MsgDepositGas: msgDepositGas, + MsgUnjailGas: msgUnjailGas, + MsgImpeachGas: msgImpeachGas, + MsgEditValidatorGas: msgEditValidatorGas, + MsgDelegateGas: msgDelegateGas, + MsgUndelegateGas: msgUndelegateGas, + MsgBeginRedelegateGas: msgBeginRedelegateGas, + MsgCancelUnbondingDelegationGas: msgCancelUnbondingDelegationGas, } } @@ -55,22 +122,64 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMaxTxSize, &p.MaxTxSize, validateMaxTxSize), paramtypes.NewParamSetPair(KeyMinGasPerByte, &p.MinGasPerByte, validateMinGasPerByte), - paramtypes.NewParamSetPair(KeyFixedMsgGas, &p.FixedMsgGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGrantFixedGas, &p.MsgGrantFixedGas, validateMsgGas), paramtypes.NewParamSetPair(KeyMsgGrantPerItemGas, &p.MsgGrantPerItemGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgRevokeGas, &p.MsgRevokeGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgExecGas, &p.MsgExecGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSendGas, &p.MsgSendGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgMultiSendFixedGas, &p.MsgMultiSendFixedGas, validateMsgGas), paramtypes.NewParamSetPair(KeyMsgMultiSendPerItemGas, &p.MsgMultiSendPerItemGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgWithdrawDelegatorRewardGas, &p.MsgWithdrawDelegatorRewardGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgWithdrawValidatorCommissionGas, &p.MsgWithdrawValidatorCommissionGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSetWithdrawAddressGas, &p.MsgSetWithdrawAddressGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgFundCommunityPoolGas, &p.MsgFundCommunityPoolGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgGrantAllowanceFixedGas, &p.MsgGrantAllowanceFixedGas, validateMsgGas), paramtypes.NewParamSetPair(KeyMsgGrantAllowancePerItemGas, &p.MsgGrantAllowancePerItemGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgRevokeAllowanceGas, &p.MsgRevokeAllowanceGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgSubmitProposalGas, &p.MsgSubmitProposalGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgVoteGas, &p.MsgVoteGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgVoteWeightedGas, &p.MsgVoteWeightedGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgDepositGas, &p.MsgDepositGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgUnjailGas, &p.MsgUnjailGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgImpeachGas, &p.MsgImpeachGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgEditValidatorGas, &p.MsgEditValidatorGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgDelegateGas, &p.MsgDelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgUndelegateGas, &p.MsgUndelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgBeginRedelegateGas, &p.MsgBeginRedelegateGas, validateMsgGas), + paramtypes.NewParamSetPair(KeyMsgCancelUnbondingDelegationGas, &p.MsgCancelUnbondingDelegationGas, validateMsgGas), } } // DefaultParams returns a default set of parameters. func DefaultParams() Params { return Params{ - MaxTxSize: DefaultMaxTxSize, - MinGasPerByte: DefaultMinGasPerByte, - FixedMsgGas: DefaultFixedMsgGas, - MsgGrantPerItemGas: DefaultMsgGrantPerItemGas, - MsgMultiSendPerItemGas: DefaultMsgMultiSendPerItemGas, - MsgGrantAllowancePerItemGas: DefaultMsgGrantAllowancePerItemGas, + MaxTxSize: DefaultMaxTxSize, + MinGasPerByte: DefaultMinGasPerByte, + MsgGrantFixedGas: DefaultMsgGrantFixedGas, + MsgGrantPerItemGas: DefaultMsgGrantPerItemGas, + MsgRevokeGas: DefaultMsgRevokeGas, + MsgExecGas: DefaultMsgExecGas, + MsgSendGas: DefaultMsgSendGas, + MsgMultiSendFixedGas: DefaultMsgMultiSendFixedGas, + MsgMultiSendPerItemGas: DefaultMsgMultiSendPerItemGas, + MsgWithdrawDelegatorRewardGas: DefaultMsgWithdrawDelegatorRewardGas, + MsgWithdrawValidatorCommissionGas: DefaultMsgWithdrawValidatorCommissionGas, + MsgSetWithdrawAddressGas: DefaultMsgSetWithdrawAddressGas, + MsgFundCommunityPoolGas: DefaultMsgFundCommunityPoolGas, + MsgGrantAllowanceFixedGas: DefaultMsgGrantAllowanceFixedGas, + MsgGrantAllowancePerItemGas: DefaultMsgGrantAllowancePerItemGas, + MsgRevokeAllowanceGas: DefaultMsgRevokeAllowanceGas, + MsgSubmitProposalGas: DefaultMsgSubmitProposalGas, + MsgVoteGas: DefaultMsgVoteGas, + MsgVoteWeightedGas: DefaultMsgVoteWeightedGas, + MsgDepositGas: DefaultMsgDepositGas, + MsgUnjailGas: DefaultMsgUnjailGas, + MsgImpeachGas: DefaultMsgImpeachGas, + MsgEditValidatorGas: DefaultMsgEditValidatorGas, + MsgDelegateGas: DefaultMsgDelegateGas, + MsgUndelegateGas: DefaultMsgUndelegateGas, + MsgBeginRedelegateGas: DefaultMsgBeginRedelegateGas, + MsgCancelUnbondingDelegationGas: DefaultMsgCancelUnbondingDelegationGas, } } @@ -127,7 +236,46 @@ func (p Params) Validate() error { if err := validateMinGasPerByte(p.MinGasPerByte); err != nil { return err } - if err := validateMsgGas(p.FixedMsgGas); err != nil { + if err := validateMsgGas(p.MsgGrantFixedGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgGrantPerItemGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgRevokeGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgExecGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgSendGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgMultiSendFixedGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgMultiSendPerItemGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgWithdrawDelegatorRewardGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgWithdrawValidatorCommissionGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgSetWithdrawAddressGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgFundCommunityPoolGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgGrantAllowanceFixedGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgGrantAllowancePerItemGas); err != nil { + return err + } + if err := validateMsgGas(p.MsgRevokeAllowanceGas); err != nil { return err } if err := validateMsgGas(p.MsgGrantPerItemGas); err != nil { diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 1f9016cdbb..a1a0293818 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -1,14 +1,14 @@ package types import ( + "github.com/pkg/errors" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/authz" ) -// TODO: Revisit this once we have propoer gas fee framework. -// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 -const gasCostPerIteration = uint64(10) +const maxValidatorsNumber = 41 var _ authz.Authorization = &StakeAuthorization{} @@ -45,11 +45,21 @@ func (a StakeAuthorization) MsgTypeURL() string { func (a StakeAuthorization) ValidateBasic() error { if a.MaxTokens != nil && a.MaxTokens.IsNegative() { - return sdkerrors.Wrapf(authz.ErrNegativeMaxTokens, "negative coin amount: %v", a.MaxTokens) + return errors.Wrapf(authz.ErrNegativeMaxTokens, "negative coin amount: %v", a.MaxTokens) } if a.AuthorizationType == AuthorizationType_AUTHORIZATION_TYPE_UNSPECIFIED { return authz.ErrUnknownAuthorizationType } + if allowList := a.GetAllowList().GetAddress(); allowList != nil { + if len(allowList) > maxValidatorsNumber { + return errors.Wrapf(authz.ErrTooManyValidators, "allow list number: %d, limit: %d", len(allowList), maxValidatorsNumber) + } + } + if denyList := a.GetDenyList().GetAddress(); denyList != nil { + if len(denyList) > maxValidatorsNumber { + return errors.Wrapf(authz.ErrTooManyValidators, "deny list number: %d, limit: %d", len(denyList), maxValidatorsNumber) + } + } return nil } @@ -76,7 +86,6 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe isValidatorExists := false allowedList := a.GetAllowList().GetAddress() for _, validator := range allowedList { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { isValidatorExists = true break @@ -85,7 +94,6 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe denyList := a.GetDenyList().GetAddress() for _, validator := range denyList { - ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validator) } From f6863b47822b84958f6a9e24dbff46cbfcd8f414 Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 5 Jan 2023 10:51:39 +0800 Subject: [PATCH 10/11] fix test case --- x/gashub/simulation/params.go | 8 ++------ x/gashub/simulation/params_test.go | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/x/gashub/simulation/params.go b/x/gashub/simulation/params.go index 70a561c639..f3bd2911d4 100644 --- a/x/gashub/simulation/params.go +++ b/x/gashub/simulation/params.go @@ -11,17 +11,13 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" ) -const ( - keyFixedMsgGas = "FixedMsgGas" -) - // ParamChanges defines the parameters that can be modified by param change proposals // on the simulation func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ - simulation.NewSimParamChange(types.ModuleName, keyFixedMsgGas, + simulation.NewSimParamChange(types.ModuleName, string(types.KeyMsgSendGas), func(r *rand.Rand) string { - return fmt.Sprintf("%d", GenMsgGas(r)) + return fmt.Sprintf("\"%d\"", GenMsgGas(r)) }, ), } diff --git a/x/gashub/simulation/params_test.go b/x/gashub/simulation/params_test.go index 72de4d0401..e89d8f4e74 100644 --- a/x/gashub/simulation/params_test.go +++ b/x/gashub/simulation/params_test.go @@ -19,7 +19,7 @@ func TestParamChanges(t *testing.T) { simValue string subspace string }{ - {"gashub/MsgSendGas", "MsgSendGas", "1698081", "gashub"}, + {"gashub/MsgSendGas", "MsgSendGas", "\"1698081\"", "gashub"}, } paramChanges := simulation.ParamChanges(r) From 763ffc90d87fba0befdb19b7b70196fe90285a82 Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 5 Jan 2023 14:45:30 +0800 Subject: [PATCH 11/11] fix review comments --- x/feegrant/filtered_fee.go | 6 +++--- x/gashub/types/gas_calculator.go | 18 ++---------------- x/gashub/types/params.go | 2 +- x/staking/types/authz.go | 10 +++++----- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index 7d077cb31b..8ce953e992 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -11,7 +11,7 @@ import ( "github.com/pkg/errors" ) -const maxAllowedMessagesLength = 22 +const allowedMessagesListSizeLimitation = 22 var ( _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) @@ -111,8 +111,8 @@ func (a *AllowedMsgAllowance) ValidateBasic() error { if len(a.AllowedMessages) == 0 { return errors.Wrap(ErrNoMessages, "allowed messages shouldn't be empty") } - if len(a.AllowedMessages) > maxAllowedMessagesLength { - return errors.Wrapf(ErrTooManyMessages, "allowed messages number: %d, limit: %d", len(a.AllowedMessages), maxAllowedMessagesLength) + if len(a.AllowedMessages) > allowedMessagesListSizeLimitation { + return errors.Wrapf(ErrTooManyMessages, "allowed messages number: %d, limit: %d", len(a.AllowedMessages), allowedMessagesListSizeLimitation) } allowance, err := a.GetAllowance() diff --git a/x/gashub/types/gas_calculator.go b/x/gashub/types/gas_calculator.go index ea0ec6eccf..19ec416173 100644 --- a/x/gashub/types/gas_calculator.go +++ b/x/gashub/types/gas_calculator.go @@ -53,13 +53,10 @@ func GrantCalculator(fixedGas, gasPerItem uint64) GasCalculator { if err != nil { return 0, err } - switch authorization := authorization.(type) { - case *staking.StakeAuthorization: + if authorization, ok := authorization.(*staking.StakeAuthorization); ok { allowList := authorization.GetAllowList().GetAddress() denyList := authorization.GetDenyList().GetAddress() num = len(allowList) + len(denyList) - case *bank.SendAuthorization: - num = len(authorization.SpendLimit) } totalGas := fixedGas + uint64(num)*gasPerItem @@ -97,19 +94,8 @@ func GrantAllowanceCalculator(fixedGas, gasPerItem uint64) GasCalculator { if err != nil { return 0, err } - switch feeAllowance := feeAllowance.(type) { - case *feegrant.AllowedMsgAllowance: + if feeAllowance, ok := feeAllowance.(*feegrant.AllowedMsgAllowance); ok { num = len(feeAllowance.AllowedMessages) - case *feegrant.PeriodicAllowance: - spendLimit := len(feeAllowance.PeriodSpendLimit) - canSpend := len(feeAllowance.PeriodCanSpend) - if spendLimit > canSpend { - num = spendLimit - } else { - num = canSpend - } - case *feegrant.BasicAllowance: - num = len(feeAllowance.SpendLimit) } totalGas := fixedGas + uint64(num)*gasPerItem diff --git a/x/gashub/types/params.go b/x/gashub/types/params.go index c401525f92..06e0046756 100644 --- a/x/gashub/types/params.go +++ b/x/gashub/types/params.go @@ -222,7 +222,7 @@ func validateMsgGas(i interface{}) error { } if v == 0 { - return fmt.Errorf("invalid msg send fee: %d", v) + return fmt.Errorf("invalid msg gas: %d", v) } return nil diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index a1a0293818..1e68e31c1f 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -const maxValidatorsNumber = 41 +const authListSizeLimitation = 41 var _ authz.Authorization = &StakeAuthorization{} @@ -51,13 +51,13 @@ func (a StakeAuthorization) ValidateBasic() error { return authz.ErrUnknownAuthorizationType } if allowList := a.GetAllowList().GetAddress(); allowList != nil { - if len(allowList) > maxValidatorsNumber { - return errors.Wrapf(authz.ErrTooManyValidators, "allow list number: %d, limit: %d", len(allowList), maxValidatorsNumber) + if len(allowList) > authListSizeLimitation { + return errors.Wrapf(authz.ErrTooManyValidators, "allow list number: %d, limit: %d", len(allowList), authListSizeLimitation) } } if denyList := a.GetDenyList().GetAddress(); denyList != nil { - if len(denyList) > maxValidatorsNumber { - return errors.Wrapf(authz.ErrTooManyValidators, "deny list number: %d, limit: %d", len(denyList), maxValidatorsNumber) + if len(denyList) > authListSizeLimitation { + return errors.Wrapf(authz.ErrTooManyValidators, "deny list number: %d, limit: %d", len(denyList), authListSizeLimitation) } }