From 2f816225267f58f605c53e8c6a72d42e168034de Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Wed, 13 Jul 2022 14:42:33 -0700 Subject: [PATCH 1/6] Add custom mint module --- proto/mint/v1beta1/genesis.proto | 16 + proto/mint/v1beta1/mint.proto | 53 ++ proto/mint/v1beta1/query.proto | 57 ++ x/epoch/keeper/hooks.go | 0 x/epoch/types/hooks.go | 0 x/mint/abci.go | 55 ++ x/mint/client/cli/query.go | 120 +++ x/mint/client/rest/grpc_query_test.go | 112 +++ x/mint/client/rest/query.go | 86 ++ x/mint/client/rest/rest.go | 14 + x/mint/client/testutil/cli_test.go | 17 + x/mint/client/testutil/suite.go | 163 ++++ x/mint/genesis.go | 21 + x/mint/keeper/grpc_query.go | 34 + x/mint/keeper/grpc_query_test.go | 56 ++ x/mint/keeper/integration_test.go | 20 + x/mint/keeper/keeper.go | 110 +++ x/mint/keeper/querier.go | 62 ++ x/mint/keeper/querier_test.go | 86 ++ x/mint/legacy/v039/types.go | 31 + x/mint/legacy/v040/migrate.go | 27 + x/mint/legacy/v040/types.go | 5 + x/mint/module.go | 186 ++++ x/mint/module_test.go | 28 + x/mint/simulation/decoder.go | 26 + x/mint/simulation/decoder_test.go | 47 + x/mint/simulation/genesis.go | 95 ++ x/mint/simulation/genesis_test.go | 84 ++ x/mint/simulation/params.go | 47 + x/mint/simulation/params_test.go | 38 + x/mint/spec/01_concepts.md | 28 + x/mint/spec/02_state.md | 21 + x/mint/spec/03_begin_block.md | 54 ++ x/mint/spec/04_params.md | 16 + x/mint/spec/05_events.md | 16 + x/mint/spec/06_client.md | 224 +++++ x/mint/spec/README.md | 22 + x/mint/types/codec.go | 15 + x/mint/types/events.go | 10 + x/mint/types/expected_keepers.go | 29 + x/mint/types/genesis.go | 27 + x/mint/types/genesis.pb.go | 377 ++++++++ x/mint/types/keys.go | 20 + x/mint/types/mint.pb.go | 779 ++++++++++++++++ x/mint/types/minter.go | 80 ++ x/mint/types/minter_test.go | 134 +++ x/mint/types/params.go | 195 ++++ x/mint/types/query.pb.go | 1199 +++++++++++++++++++++++++ x/mint/types/query.pb.gw.go | 272 ++++++ 49 files changed, 5214 insertions(+) create mode 100644 proto/mint/v1beta1/genesis.proto create mode 100644 proto/mint/v1beta1/mint.proto create mode 100644 proto/mint/v1beta1/query.proto create mode 100644 x/epoch/keeper/hooks.go create mode 100644 x/epoch/types/hooks.go create mode 100644 x/mint/abci.go create mode 100644 x/mint/client/cli/query.go create mode 100644 x/mint/client/rest/grpc_query_test.go create mode 100644 x/mint/client/rest/query.go create mode 100644 x/mint/client/rest/rest.go create mode 100644 x/mint/client/testutil/cli_test.go create mode 100644 x/mint/client/testutil/suite.go create mode 100644 x/mint/genesis.go create mode 100644 x/mint/keeper/grpc_query.go create mode 100644 x/mint/keeper/grpc_query_test.go create mode 100644 x/mint/keeper/integration_test.go create mode 100644 x/mint/keeper/keeper.go create mode 100644 x/mint/keeper/querier.go create mode 100644 x/mint/keeper/querier_test.go create mode 100644 x/mint/legacy/v039/types.go create mode 100644 x/mint/legacy/v040/migrate.go create mode 100644 x/mint/legacy/v040/types.go create mode 100644 x/mint/module.go create mode 100644 x/mint/module_test.go create mode 100644 x/mint/simulation/decoder.go create mode 100644 x/mint/simulation/decoder_test.go create mode 100644 x/mint/simulation/genesis.go create mode 100644 x/mint/simulation/genesis_test.go create mode 100644 x/mint/simulation/params.go create mode 100644 x/mint/simulation/params_test.go create mode 100644 x/mint/spec/01_concepts.md create mode 100644 x/mint/spec/02_state.md create mode 100644 x/mint/spec/03_begin_block.md create mode 100644 x/mint/spec/04_params.md create mode 100644 x/mint/spec/05_events.md create mode 100644 x/mint/spec/06_client.md create mode 100644 x/mint/spec/README.md create mode 100644 x/mint/types/codec.go create mode 100644 x/mint/types/events.go create mode 100644 x/mint/types/expected_keepers.go create mode 100644 x/mint/types/genesis.go create mode 100644 x/mint/types/genesis.pb.go create mode 100644 x/mint/types/keys.go create mode 100644 x/mint/types/mint.pb.go create mode 100644 x/mint/types/minter.go create mode 100644 x/mint/types/minter_test.go create mode 100644 x/mint/types/params.go create mode 100644 x/mint/types/query.pb.go create mode 100644 x/mint/types/query.pb.gw.go diff --git a/proto/mint/v1beta1/genesis.proto b/proto/mint/v1beta1/genesis.proto new file mode 100644 index 0000000000..4e783fb544 --- /dev/null +++ b/proto/mint/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// GenesisState defines the mint module's genesis state. +message GenesisState { + // minter is a space for holding current inflation information. + Minter minter = 1 [(gogoproto.nullable) = false]; + + // params defines all the paramaters of the module. + Params params = 2 [(gogoproto.nullable) = false]; +} diff --git a/proto/mint/v1beta1/mint.proto b/proto/mint/v1beta1/mint.proto new file mode 100644 index 0000000000..f94d4ae2e8 --- /dev/null +++ b/proto/mint/v1beta1/mint.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +import "gogoproto/gogo.proto"; + +// Minter represents the minting state. +message Minter { + // current annual inflation rate + string inflation = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + // current annual expected provisions + string annual_provisions = 2 [ + (gogoproto.moretags) = "yaml:\"annual_provisions\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Params holds parameters for the mint module. +message Params { + option (gogoproto.goproto_stringer) = false; + + // type of coin to mint + string mint_denom = 1; + // maximum annual change in inflation rate + string inflation_rate_change = 2 [ + (gogoproto.moretags) = "yaml:\"inflation_rate_change\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // maximum inflation rate + string inflation_max = 3 [ + (gogoproto.moretags) = "yaml:\"inflation_max\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // minimum inflation rate + string inflation_min = 4 [ + (gogoproto.moretags) = "yaml:\"inflation_min\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // goal of percent bonded atoms + string goal_bonded = 5 [ + (gogoproto.moretags) = "yaml:\"goal_bonded\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // expected blocks per year + uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; +} diff --git a/proto/mint/v1beta1/query.proto b/proto/mint/v1beta1/query.proto new file mode 100644 index 0000000000..acd341d777 --- /dev/null +++ b/proto/mint/v1beta1/query.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Params returns the total set of minting parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + } + + // Inflation returns the current minting inflation value. + rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + } + + // AnnualProvisions current minting annual provisions value. + rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + } +} + +// 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]; +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +message QueryInflationRequest {} + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +message QueryInflationResponse { + // inflation is the current minting inflation value. + bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsRequest {} + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsResponse { + // annual_provisions is the current minting annual provisions value. + bytes annual_provisions = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} diff --git a/x/epoch/keeper/hooks.go b/x/epoch/keeper/hooks.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/x/epoch/types/hooks.go b/x/epoch/types/hooks.go new file mode 100644 index 0000000000..e69de29bb2 diff --git a/x/mint/abci.go b/x/mint/abci.go new file mode 100644 index 0000000000..410415d743 --- /dev/null +++ b/x/mint/abci.go @@ -0,0 +1,55 @@ +package mint + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/keeper" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// BeginBlocker mints new tokens for the previous block. +func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) + + // fetch stored minter & params + minter := k.GetMinter(ctx) + params := k.GetParams(ctx) + + // recalculate inflation rate + totalStakingSupply := k.StakingTokenSupply(ctx) + bondedRatio := k.BondedRatio(ctx) + minter.Inflation = minter.NextInflationRate(params, bondedRatio) + minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalStakingSupply) + k.SetMinter(ctx, minter) + + // mint coins, update supply + mintedCoin := minter.BlockProvision(params) + mintedCoins := sdk.NewCoins(mintedCoin) + + err := k.MintCoins(ctx, mintedCoins) + if err != nil { + panic(err) + } + + // send the minted coins to the fee collector account + err = k.AddCollectedFees(ctx, mintedCoins) + if err != nil { + panic(err) + } + + if mintedCoin.Amount.IsInt64() { + defer telemetry.ModuleSetGauge(types.ModuleName, float32(mintedCoin.Amount.Int64()), "minted_tokens") + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeMint, + sdk.NewAttribute(types.AttributeKeyBondedRatio, bondedRatio.String()), + sdk.NewAttribute(types.AttributeKeyInflation, minter.Inflation.String()), + sdk.NewAttribute(types.AttributeKeyAnnualProvisions, minter.AnnualProvisions.String()), + sdk.NewAttribute(sdk.AttributeKeyAmount, mintedCoin.Amount.String()), + ), + ) +} diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go new file mode 100644 index 0000000000..792fa8a679 --- /dev/null +++ b/x/mint/client/cli/query.go @@ -0,0 +1,120 @@ +package cli + +import ( + "fmt" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// GetQueryCmd returns the cli query commands for the minting module. +func GetQueryCmd() *cobra.Command { + mintingQueryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the minting module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + mintingQueryCmd.AddCommand( + GetCmdQueryParams(), + GetCmdQueryInflation(), + GetCmdQueryAnnualProvisions(), + ) + + return mintingQueryCmd +} + +// GetCmdQueryParams implements a command to return the current minting +// parameters. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "Query the current minting parameters", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryParamsRequest{} + res, err := queryClient.Params(cmd.Context(), params) + + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryInflation implements a command to return the current minting +// inflation value. +func GetCmdQueryInflation() *cobra.Command { + cmd := &cobra.Command{ + Use: "inflation", + Short: "Query the current minting inflation value", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryInflationRequest{} + res, err := queryClient.Inflation(cmd.Context(), params) + + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", res.Inflation)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdQueryAnnualProvisions implements a command to return the current minting +// annual provisions value. +func GetCmdQueryAnnualProvisions() *cobra.Command { + cmd := &cobra.Command{ + Use: "annual-provisions", + Short: "Query the current minting annual provisions value", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAnnualProvisionsRequest{} + res, err := queryClient.AnnualProvisions(cmd.Context(), params) + + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", res.AnnualProvisions)) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/mint/client/rest/grpc_query_test.go b/x/mint/client/rest/grpc_query_test.go new file mode 100644 index 0000000000..fdbb4ff759 --- /dev/null +++ b/x/mint/client/rest/grpc_query_test.go @@ -0,0 +1,112 @@ +// +build norace + +package rest_test + +import ( + "fmt" + "testing" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/testutil/network" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +type IntegrationTestSuite struct { + suite.Suite + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := network.DefaultConfig() + + genesisState := cfg.GenesisState + cfg.NumValidators = 1 + + var mintData minttypes.GenesisState + s.Require().NoError(cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData)) + + inflation := sdk.MustNewDecFromStr("1.0") + mintData.Minter.Inflation = inflation + mintData.Params.InflationMin = inflation + mintData.Params.InflationMax = inflation + + mintDataBz, err := cfg.Codec.MarshalJSON(&mintData) + s.Require().NoError(err) + genesisState[minttypes.ModuleName] = mintDataBz + cfg.GenesisState = genesisState + + s.cfg = cfg + s.network = network.New(s.T(), cfg) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestQueryGRPC() { + val := s.network.Validators[0] + baseURL := val.APIAddress + testCases := []struct { + name string + url string + headers map[string]string + respType proto.Message + expected proto.Message + }{ + { + "gRPC request params", + fmt.Sprintf("%s/cosmos/mint/v1beta1/params", baseURL), + map[string]string{}, + &minttypes.QueryParamsResponse{}, + &minttypes.QueryParamsResponse{ + Params: minttypes.NewParams("stake", sdk.NewDecWithPrec(13, 2), sdk.NewDecWithPrec(100, 2), + sdk.NewDec(1), sdk.NewDecWithPrec(67, 2), (60 * 60 * 8766 / 5)), + }, + }, + { + "gRPC request inflation", + fmt.Sprintf("%s/cosmos/mint/v1beta1/inflation", baseURL), + map[string]string{}, + &minttypes.QueryInflationResponse{}, + &minttypes.QueryInflationResponse{ + Inflation: sdk.NewDec(1), + }, + }, + { + "gRPC request annual provisions", + fmt.Sprintf("%s/cosmos/mint/v1beta1/annual_provisions", baseURL), + map[string]string{ + grpctypes.GRPCBlockHeightHeader: "1", + }, + &minttypes.QueryAnnualProvisionsResponse{}, + &minttypes.QueryAnnualProvisionsResponse{ + AnnualProvisions: sdk.NewDec(500000000), + }, + }, + } + for _, tc := range testCases { + resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers) + s.Run(tc.name, func() { + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType)) + s.Require().Equal(tc.expected.String(), tc.respType.String()) + }) + } +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/mint/client/rest/query.go b/x/mint/client/rest/query.go new file mode 100644 index 0000000000..1dccd194c1 --- /dev/null +++ b/x/mint/client/rest/query.go @@ -0,0 +1,86 @@ +package rest + +import ( + "fmt" + "net/http" + + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func registerQueryRoutes(clientCtx client.Context, r *mux.Router) { + r.HandleFunc( + "/minting/parameters", + queryParamsHandlerFn(clientCtx), + ).Methods("GET") + + r.HandleFunc( + "/minting/inflation", + queryInflationHandlerFn(clientCtx), + ).Methods("GET") + + r.HandleFunc( + "/minting/annual-provisions", + queryAnnualProvisionsHandlerFn(clientCtx), + ).Methods("GET") +} + +func queryParamsHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters) + + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + res, height, err := clientCtx.QueryWithData(route, nil) + if rest.CheckInternalServerError(w, err) { + return + } + + clientCtx = clientCtx.WithHeight(height) + rest.PostProcessResponse(w, clientCtx, res) + } +} + +func queryInflationHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryInflation) + + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + res, height, err := clientCtx.QueryWithData(route, nil) + if rest.CheckInternalServerError(w, err) { + return + } + + clientCtx = clientCtx.WithHeight(height) + rest.PostProcessResponse(w, clientCtx, res) + } +} + +func queryAnnualProvisionsHandlerFn(clientCtx client.Context) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAnnualProvisions) + + clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r) + if !ok { + return + } + + res, height, err := clientCtx.QueryWithData(route, nil) + if rest.CheckInternalServerError(w, err) { + return + } + + clientCtx = clientCtx.WithHeight(height) + rest.PostProcessResponse(w, clientCtx, res) + } +} diff --git a/x/mint/client/rest/rest.go b/x/mint/client/rest/rest.go new file mode 100644 index 0000000000..2ed28d41d7 --- /dev/null +++ b/x/mint/client/rest/rest.go @@ -0,0 +1,14 @@ +package rest + +import ( + "github.com/gorilla/mux" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/rest" +) + +// RegisterRoutes registers minting module REST handlers on the provided router. +func RegisterRoutes(clientCtx client.Context, rtr *mux.Router) { + r := rest.WithHTTPDeprecationHeaders(rtr) + registerQueryRoutes(clientCtx, r) +} diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go new file mode 100644 index 0000000000..dd36a6af2d --- /dev/null +++ b/x/mint/client/testutil/cli_test.go @@ -0,0 +1,17 @@ +// +build norace + +package testutil + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/testutil/network" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig() + cfg.NumValidators = 1 + suite.Run(t, NewIntegrationTestSuite(cfg)) +} diff --git a/x/mint/client/testutil/suite.go b/x/mint/client/testutil/suite.go new file mode 100644 index 0000000000..24e7426760 --- /dev/null +++ b/x/mint/client/testutil/suite.go @@ -0,0 +1,163 @@ +package testutil + +import ( + "fmt" + "strings" + + "github.com/stretchr/testify/suite" + tmcli "github.com/tendermint/tendermint/libs/cli" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/client/cli" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { + return &IntegrationTestSuite{cfg: cfg} +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + genesisState := s.cfg.GenesisState + + var mintData minttypes.GenesisState + s.Require().NoError(s.cfg.Codec.UnmarshalJSON(genesisState[minttypes.ModuleName], &mintData)) + + inflation := sdk.MustNewDecFromStr("1.0") + mintData.Minter.Inflation = inflation + mintData.Params.InflationMin = inflation + mintData.Params.InflationMax = inflation + + mintDataBz, err := s.cfg.Codec.MarshalJSON(&mintData) + s.Require().NoError(err) + genesisState[minttypes.ModuleName] = mintDataBz + s.cfg.GenesisState = genesisState + + s.network = network.New(s.T(), s.cfg) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func (s *IntegrationTestSuite) TestGetCmdQueryParams() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + `{"mint_denom":"stake","inflation_rate_change":"0.130000000000000000","inflation_max":"1.000000000000000000","inflation_min":"1.000000000000000000","goal_bonded":"0.670000000000000000","blocks_per_year":"6311520"}`, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, + `blocks_per_year: "6311520" +goal_bonded: "0.670000000000000000" +inflation_max: "1.000000000000000000" +inflation_min: "1.000000000000000000" +inflation_rate_change: "0.130000000000000000" +mint_denom: stake`, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryParams() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + s.Require().NoError(err) + s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} + +func (s *IntegrationTestSuite) TestGetCmdQueryInflation() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + `1.000000000000000000`, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, + `1.000000000000000000`, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryInflation() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + s.Require().NoError(err) + s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} + +func (s *IntegrationTestSuite) TestGetCmdQueryAnnualProvisions() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + `500000000.000000000000000000`, + }, + { + "text output", + []string{fmt.Sprintf("--%s=1", flags.FlagHeight), fmt.Sprintf("--%s=text", tmcli.OutputFlag)}, + `500000000.000000000000000000`, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryAnnualProvisions() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + s.Require().NoError(err) + s.Require().Equal(tc.expectedOutput, strings.TrimSpace(out.String())) + }) + } +} diff --git a/x/mint/genesis.go b/x/mint/genesis.go new file mode 100644 index 0000000000..be7ac61d50 --- /dev/null +++ b/x/mint/genesis.go @@ -0,0 +1,21 @@ +package mint + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/keeper" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// InitGenesis new mint genesis +func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, ak types.AccountKeeper, data *types.GenesisState) { + keeper.SetMinter(ctx, data.Minter) + keeper.SetParams(ctx, data.Params) + ak.GetModuleAccount(ctx, types.ModuleName) +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { + minter := keeper.GetMinter(ctx) + params := keeper.GetParams(ctx) + return types.NewGenesisState(minter, params) +} diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go new file mode 100644 index 0000000000..6ad3bf309c --- /dev/null +++ b/x/mint/keeper/grpc_query.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +var _ types.QueryServer = Keeper{} + +// Params returns params of the mint module. +func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + params := k.GetParams(ctx) + + return &types.QueryParamsResponse{Params: params}, nil +} + +// Inflation returns minter.Inflation of the mint module. +func (k Keeper) Inflation(c context.Context, _ *types.QueryInflationRequest) (*types.QueryInflationResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + minter := k.GetMinter(ctx) + + return &types.QueryInflationResponse{Inflation: minter.Inflation}, nil +} + +// AnnualProvisions returns minter.AnnualProvisions of the mint module. +func (k Keeper) AnnualProvisions(c context.Context, _ *types.QueryAnnualProvisionsRequest) (*types.QueryAnnualProvisionsResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + minter := k.GetMinter(ctx) + + return &types.QueryAnnualProvisionsResponse{AnnualProvisions: minter.AnnualProvisions}, nil +} diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go new file mode 100644 index 0000000000..11b6276694 --- /dev/null +++ b/x/mint/keeper/grpc_query_test.go @@ -0,0 +1,56 @@ +package keeper_test + +import ( + gocontext "context" + "testing" + + "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" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +type MintTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context + queryClient types.QueryClient +} + +func (suite *MintTestSuite) SetupTest() { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, app.MintKeeper) + queryClient := types.NewQueryClient(queryHelper) + + suite.app = app + suite.ctx = ctx + + suite.queryClient = queryClient +} + +func (suite *MintTestSuite) TestGRPCParams() { + app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient + + params, err := queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(params.Params, app.MintKeeper.GetParams(ctx)) + + inflation, err := queryClient.Inflation(gocontext.Background(), &types.QueryInflationRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(inflation.Inflation, app.MintKeeper.GetMinter(ctx).Inflation) + + annualProvisions, err := queryClient.AnnualProvisions(gocontext.Background(), &types.QueryAnnualProvisionsRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(annualProvisions.AnnualProvisions, app.MintKeeper.GetMinter(ctx).AnnualProvisions) +} + +func TestMintTestSuite(t *testing.T) { + suite.Run(t, new(MintTestSuite)) +} diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go new file mode 100644 index 0000000000..df321c33bd --- /dev/null +++ b/x/mint/keeper/integration_test.go @@ -0,0 +1,20 @@ +package keeper_test + +import ( + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// returns context and an app with updated mint keeper +func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(isCheckTx) + + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) + app.MintKeeper.SetParams(ctx, types.DefaultParams()) + app.MintKeeper.SetMinter(ctx, types.DefaultInitialMinter()) + + return app, ctx +} diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go new file mode 100644 index 0000000000..b010204e8a --- /dev/null +++ b/x/mint/keeper/keeper.go @@ -0,0 +1,110 @@ +package keeper + +import ( + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/mint/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Keeper of the mint store +type Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + paramSpace paramtypes.Subspace + stakingKeeper types.StakingKeeper + bankKeeper types.BankKeeper + feeCollectorName string +} + +// NewKeeper creates a new mint Keeper instance +func NewKeeper( + cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, + sk types.StakingKeeper, ak types.AccountKeeper, bk types.BankKeeper, + feeCollectorName string, +) Keeper { + // ensure mint module account is set + if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { + panic("the mint module account has not been set") + } + + // set KeyTable if it has not already been set + if !paramSpace.HasKeyTable() { + paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + } + + return Keeper{ + cdc: cdc, + storeKey: key, + paramSpace: paramSpace, + stakingKeeper: sk, + bankKeeper: bk, + feeCollectorName: feeCollectorName, + } +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} + +// get the minter +func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) { + store := ctx.KVStore(k.storeKey) + b := store.Get(types.MinterKey) + if b == nil { + panic("stored minter should not have been nil") + } + + k.cdc.MustUnmarshal(b, &minter) + return +} + +// set the minter +func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) { + store := ctx.KVStore(k.storeKey) + b := k.cdc.MustMarshal(&minter) + store.Set(types.MinterKey, b) +} + +// GetParams returns the total set of minting parameters. +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramSpace.GetParamSet(ctx, ¶ms) + return params +} + +// SetParams sets the total set of minting parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramSpace.SetParamSet(ctx, ¶ms) +} + +// StakingTokenSupply implements an alias call to the underlying staking keeper's +// StakingTokenSupply to be used in BeginBlocker. +func (k Keeper) StakingTokenSupply(ctx sdk.Context) sdk.Int { + return k.stakingKeeper.StakingTokenSupply(ctx) +} + +// BondedRatio implements an alias call to the underlying staking keeper's +// BondedRatio to be used in BeginBlocker. +func (k Keeper) BondedRatio(ctx sdk.Context) sdk.Dec { + return k.stakingKeeper.BondedRatio(ctx) +} + +// MintCoins implements an alias call to the underlying supply keeper's +// MintCoins to be used in BeginBlocker. +func (k Keeper) MintCoins(ctx sdk.Context, newCoins sdk.Coins) error { + if newCoins.Empty() { + // skip as no coins need to be minted + return nil + } + + return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins) +} + +// AddCollectedFees implements an alias call to the underlying supply keeper's +// AddCollectedFees to be used in BeginBlocker. +func (k Keeper) AddCollectedFees(ctx sdk.Context, fees sdk.Coins) error { + return k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, k.feeCollectorName, fees) +} diff --git a/x/mint/keeper/querier.go b/x/mint/keeper/querier.go new file mode 100644 index 0000000000..294445614a --- /dev/null +++ b/x/mint/keeper/querier.go @@ -0,0 +1,62 @@ +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/mint/types" +) + +// NewQuerier returns a minting Querier handler. +func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) { + switch path[0] { + case types.QueryParameters: + return queryParams(ctx, k, legacyQuerierCdc) + + case types.QueryInflation: + return queryInflation(ctx, k, legacyQuerierCdc) + + case types.QueryAnnualProvisions: + return queryAnnualProvisions(ctx, k, legacyQuerierCdc) + + default: + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) + } + } +} + +func queryParams(ctx sdk.Context, k Keeper, 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 +} + +func queryInflation(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + minter := k.GetMinter(ctx) + + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.Inflation) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + + return res, nil +} + +func queryAnnualProvisions(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { + minter := k.GetMinter(ctx) + + res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.AnnualProvisions) + if err != nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) + } + + return res, nil +} diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go new file mode 100644 index 0000000000..2e987aa042 --- /dev/null +++ b/x/mint/keeper/querier_test.go @@ -0,0 +1,86 @@ +package keeper_test + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/codec" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" + keep "github.com/cosmos/cosmos-sdk/x/mint/keeper" + "github.com/cosmos/cosmos-sdk/x/mint/types" + + abci "github.com/tendermint/tendermint/abci/types" +) + +func TestNewQuerier(t *testing.T) { + app, ctx := createTestApp(true) + legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) + querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) + + query := abci.RequestQuery{ + Path: "", + Data: []byte{}, + } + + _, err := querier(ctx, []string{types.QueryParameters}, query) + require.NoError(t, err) + + _, err = querier(ctx, []string{types.QueryInflation}, query) + require.NoError(t, err) + + _, err = querier(ctx, []string{types.QueryAnnualProvisions}, query) + require.NoError(t, err) + + _, err = querier(ctx, []string{"foo"}, query) + require.Error(t, err) +} + +func TestQueryParams(t *testing.T) { + app, ctx := createTestApp(true) + legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) + querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) + + var params types.Params + + res, sdkErr := querier(ctx, []string{types.QueryParameters}, abci.RequestQuery{}) + require.NoError(t, sdkErr) + + err := app.LegacyAmino().UnmarshalJSON(res, ¶ms) + require.NoError(t, err) + + require.Equal(t, app.MintKeeper.GetParams(ctx), params) +} + +func TestQueryInflation(t *testing.T) { + app, ctx := createTestApp(true) + legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) + querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) + + var inflation sdk.Dec + + res, sdkErr := querier(ctx, []string{types.QueryInflation}, abci.RequestQuery{}) + require.NoError(t, sdkErr) + + err := app.LegacyAmino().UnmarshalJSON(res, &inflation) + require.NoError(t, err) + + require.Equal(t, app.MintKeeper.GetMinter(ctx).Inflation, inflation) +} + +func TestQueryAnnualProvisions(t *testing.T) { + app, ctx := createTestApp(true) + legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) + querier := keep.NewQuerier(app.MintKeeper, legacyQuerierCdc.LegacyAmino) + + var annualProvisions sdk.Dec + + res, sdkErr := querier(ctx, []string{types.QueryAnnualProvisions}, abci.RequestQuery{}) + require.NoError(t, sdkErr) + + err := app.LegacyAmino().UnmarshalJSON(res, &annualProvisions) + require.NoError(t, err) + + require.Equal(t, app.MintKeeper.GetMinter(ctx).AnnualProvisions, annualProvisions) +} diff --git a/x/mint/legacy/v039/types.go b/x/mint/legacy/v039/types.go new file mode 100644 index 0000000000..10b351b7fb --- /dev/null +++ b/x/mint/legacy/v039/types.go @@ -0,0 +1,31 @@ +package v039 + +import sdk "github.com/cosmos/cosmos-sdk/types" + +const ( + ModuleName = "mint" +) + +type ( + // Minter represents the minting state. + Minter struct { + Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate + AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions + } + + // mint parameters + Params struct { + MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint + InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate + InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate + InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate + GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms + BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year + } + + // GenesisState - minter state + GenesisState struct { + Minter Minter `json:"minter" yaml:"minter"` // minter object + Params Params `json:"params" yaml:"params"` // inflation params + } +) diff --git a/x/mint/legacy/v040/migrate.go b/x/mint/legacy/v040/migrate.go new file mode 100644 index 0000000000..b417c68289 --- /dev/null +++ b/x/mint/legacy/v040/migrate.go @@ -0,0 +1,27 @@ +package v040 + +import ( + v039mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v039" + v040mint "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// Migrate accepts exported v0.39 x/mint genesis state and +// migrates it to v0.40 x/mint genesis state. The migration includes: +// +// - Re-encode in v0.40 GenesisState. +func Migrate(mintGenState v039mint.GenesisState) *v040mint.GenesisState { + return &v040mint.GenesisState{ + Minter: v040mint.Minter{ + Inflation: mintGenState.Minter.Inflation, + AnnualProvisions: mintGenState.Minter.AnnualProvisions, + }, + Params: v040mint.Params{ + MintDenom: mintGenState.Params.MintDenom, + InflationRateChange: mintGenState.Params.InflationRateChange, + InflationMax: mintGenState.Params.InflationMax, + InflationMin: mintGenState.Params.InflationMin, + GoalBonded: mintGenState.Params.GoalBonded, + BlocksPerYear: mintGenState.Params.BlocksPerYear, + }, + } +} diff --git a/x/mint/legacy/v040/types.go b/x/mint/legacy/v040/types.go new file mode 100644 index 0000000000..d725b48c34 --- /dev/null +++ b/x/mint/legacy/v040/types.go @@ -0,0 +1,5 @@ +package v040 + +const ( + ModuleName = "mint" +) diff --git a/x/mint/module.go b/x/mint/module.go new file mode 100644 index 0000000000..f8d51f9cf5 --- /dev/null +++ b/x/mint/module.go @@ -0,0 +1,186 @@ +package mint + +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/gorilla/mux" + "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" + cdctypes "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/mint/client/cli" + "github.com/cosmos/cosmos-sdk/x/mint/client/rest" + "github.com/cosmos/cosmos-sdk/x/mint/keeper" + "github.com/cosmos/cosmos-sdk/x/mint/simulation" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModuleSimulation = AppModule{} +) + +// AppModuleBasic defines the basic application module used by the mint module. +type AppModuleBasic struct { + cdc codec.Codec +} + +var _ module.AppModuleBasic = AppModuleBasic{} + +// Name returns the mint module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers the module's interface types +func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} + +// DefaultGenesis returns default genesis state as raw bytes for the mint +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the mint 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) +} + +// RegisterRESTRoutes registers the REST routes for the mint module. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { + rest.RegisterRoutes(clientCtx, rtr) +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + +} + +// GetTxCmd returns no root tx command for the mint module. +func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } + +// GetQueryCmd returns the root query command for the mint module. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule implements an application module for the mint module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + authKeeper types.AccountKeeper +} + +// NewAppModule creates a new AppModule object +func NewAppModule(cdc codec.Codec, keeper keeper.Keeper, ak types.AccountKeeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{cdc: cdc}, + keeper: keeper, + authKeeper: ak, + } +} + +// Name returns the mint module's name. +func (AppModule) Name() string { + return types.ModuleName +} + +// RegisterInvariants registers the mint module invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// Route returns the message routing key for the mint module. +func (AppModule) Route() sdk.Route { return sdk.Route{} } + +// QuerierRoute returns the mint module's querier route name. +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler returns the mint module sdk.Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return keeper.NewQuerier(am.keeper, legacyQuerierCdc) +} + +// RegisterServices registers a gRPC query service to respond to the +// module-specific gRPC queries. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// InitGenesis performs genesis initialization for the mint 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) + + InitGenesis(ctx, am.keeper, am.authKeeper, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mint +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock returns the begin blocker for the mint module. +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { + BeginBlocker(ctx, am.keeper) +} + +// EndBlock returns the end blocker for the mint module. It returns no validator +// updates. +func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the mint module. +func (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 mint param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return simulation.ParamChanges(r) +} + +// RegisterStoreDecoder registers a decoder for mint module's types. +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) +} + +// WeightedOperations doesn't return any mint module operation. +func (AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return nil +} diff --git a/x/mint/module_test.go b/x/mint/module_test.go new file mode 100644 index 0000000000..3b2df369e6 --- /dev/null +++ b/x/mint/module_test.go @@ -0,0 +1,28 @@ +package mint_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + abcitypes "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/simapp" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { + app := simapp.Setup(false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + app.InitChain( + abcitypes.RequestInitChain{ + AppStateBytes: []byte("{}"), + ChainId: "test-chain-id", + }, + ) + + acc := app.AccountKeeper.GetAccount(ctx, authtypes.NewModuleAddress(types.ModuleName)) + require.NotNil(t, acc) +} diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go new file mode 100644 index 0000000000..b9337fed00 --- /dev/null +++ b/x/mint/simulation/decoder.go @@ -0,0 +1,26 @@ +package simulation + +import ( + "bytes" + "fmt" + + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// NewDecodeStore returns a decoder function closure that unmarshals the KVPair's +// Value to the corresponding mint type. +func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { + return func(kvA, kvB kv.Pair) string { + switch { + case bytes.Equal(kvA.Key, types.MinterKey): + var minterA, minterB types.Minter + cdc.MustUnmarshal(kvA.Value, &minterA) + cdc.MustUnmarshal(kvB.Value, &minterB) + return fmt.Sprintf("%v\n%v", minterA, minterB) + default: + panic(fmt.Sprintf("invalid mint key %X", kvA.Key)) + } + } +} diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go new file mode 100644 index 0000000000..43a8cfbd42 --- /dev/null +++ b/x/mint/simulation/decoder_test.go @@ -0,0 +1,47 @@ +package simulation_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/x/mint/simulation" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +func TestDecodeStore(t *testing.T) { + cdc := simapp.MakeTestEncodingConfig().Marshaler + dec := simulation.NewDecodeStore(cdc) + + minter := types.NewMinter(sdk.OneDec(), sdk.NewDec(15)) + + kvPairs := kv.Pairs{ + Pairs: []kv.Pair{ + {Key: types.MinterKey, Value: cdc.MustMarshal(&minter)}, + {Key: []byte{0x99}, Value: []byte{0x99}}, + }, + } + tests := []struct { + name string + expectedLog string + }{ + {"Minter", fmt.Sprintf("%v\n%v", minter, minter)}, + {"other", ""}, + } + + for i, tt := range tests { + i, tt := i, tt + t.Run(tt.name, func(t *testing.T) { + switch i { + case len(tests) - 1: + require.Panics(t, func() { dec(kvPairs.Pairs[i], kvPairs.Pairs[i]) }, tt.name) + default: + require.Equal(t, tt.expectedLog, dec(kvPairs.Pairs[i], kvPairs.Pairs[i]), tt.name) + } + }) + } +} diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go new file mode 100644 index 0000000000..77d5064416 --- /dev/null +++ b/x/mint/simulation/genesis.go @@ -0,0 +1,95 @@ +package simulation + +// DONTCOVER + +import ( + "encoding/json" + "fmt" + "math/rand" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +// Simulation parameter constants +const ( + Inflation = "inflation" + InflationRateChange = "inflation_rate_change" + InflationMax = "inflation_max" + InflationMin = "inflation_min" + GoalBonded = "goal_bonded" +) + +// GenInflation randomized Inflation +func GenInflation(r *rand.Rand) sdk.Dec { + return sdk.NewDecWithPrec(int64(r.Intn(99)), 2) +} + +// GenInflationRateChange randomized InflationRateChange +func GenInflationRateChange(r *rand.Rand) sdk.Dec { + return sdk.NewDecWithPrec(int64(r.Intn(99)), 2) +} + +// GenInflationMax randomized InflationMax +func GenInflationMax(r *rand.Rand) sdk.Dec { + return sdk.NewDecWithPrec(20, 2) +} + +// GenInflationMin randomized InflationMin +func GenInflationMin(r *rand.Rand) sdk.Dec { + return sdk.NewDecWithPrec(7, 2) +} + +// GenGoalBonded randomized GoalBonded +func GenGoalBonded(r *rand.Rand) sdk.Dec { + return sdk.NewDecWithPrec(67, 2) +} + +// RandomizedGenState generates a random GenesisState for mint +func RandomizedGenState(simState *module.SimulationState) { + // minter + var inflation sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, Inflation, &inflation, simState.Rand, + func(r *rand.Rand) { inflation = GenInflation(r) }, + ) + + // params + var inflationRateChange sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, InflationRateChange, &inflationRateChange, simState.Rand, + func(r *rand.Rand) { inflationRateChange = GenInflationRateChange(r) }, + ) + + var inflationMax sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, InflationMax, &inflationMax, simState.Rand, + func(r *rand.Rand) { inflationMax = GenInflationMax(r) }, + ) + + var inflationMin sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, InflationMin, &inflationMin, simState.Rand, + func(r *rand.Rand) { inflationMin = GenInflationMin(r) }, + ) + + var goalBonded sdk.Dec + simState.AppParams.GetOrGenerate( + simState.Cdc, GoalBonded, &goalBonded, simState.Rand, + func(r *rand.Rand) { goalBonded = GenGoalBonded(r) }, + ) + + mintDenom := sdk.DefaultBondDenom + blocksPerYear := uint64(60 * 60 * 8766 / 5) + params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear) + + mintGenesis := types.NewGenesisState(types.InitialMinter(inflation), params) + + bz, err := json.MarshalIndent(&mintGenesis, "", " ") + if err != nil { + panic(err) + } + fmt.Printf("Selected randomly generated minting parameters:\n%s\n", bz) + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(mintGenesis) +} diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go new file mode 100644 index 0000000000..ac57da7acc --- /dev/null +++ b/x/mint/simulation/genesis_test.go @@ -0,0 +1,84 @@ +package simulation_test + +import ( + "encoding/json" + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "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/mint/simulation" + "github.com/cosmos/cosmos-sdk/x/mint/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: 1000, + GenState: make(map[string]json.RawMessage), + } + + simulation.RandomizedGenState(&simState) + + var mintGenesis types.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[types.ModuleName], &mintGenesis) + + dec1, _ := sdk.NewDecFromStr("0.670000000000000000") + dec2, _ := sdk.NewDecFromStr("0.200000000000000000") + dec3, _ := sdk.NewDecFromStr("0.070000000000000000") + + require.Equal(t, uint64(6311520), mintGenesis.Params.BlocksPerYear) + require.Equal(t, dec1, mintGenesis.Params.GoalBonded) + require.Equal(t, dec2, mintGenesis.Params.InflationMax) + require.Equal(t, dec3, mintGenesis.Params.InflationMin) + require.Equal(t, "stake", mintGenesis.Params.MintDenom) + require.Equal(t, "0stake", mintGenesis.Minter.BlockProvision(mintGenesis.Params).String()) + require.Equal(t, "0.170000000000000000", mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, sdk.OneInt()).String()) + require.Equal(t, "0.169999926644441493", mintGenesis.Minter.NextInflationRate(mintGenesis.Params, sdk.OneDec()).String()) + require.Equal(t, "0.170000000000000000", mintGenesis.Minter.Inflation.String()) + require.Equal(t, "0.000000000000000000", mintGenesis.Minter.AnnualProvisions.String()) +} + +// TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. +func TestRandomizedGenState1(t *testing.T) { + interfaceRegistry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(interfaceRegistry) + + s := rand.NewSource(1) + r := rand.New(s) + // all these tests will panic + tests := []struct { + simState module.SimulationState + panicMsg string + }{ + { // panic => reason: incomplete initialization of the simState + module.SimulationState{}, "invalid memory address or nil pointer dereference"}, + { // panic => reason: incomplete initialization of the simState + module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: cdc, + Rand: r, + }, "assignment to entry in nil map"}, + } + + for _, tt := range tests { + require.Panicsf(t, func() { simulation.RandomizedGenState(&tt.simState) }, tt.panicMsg) + } +} diff --git a/x/mint/simulation/params.go b/x/mint/simulation/params.go new file mode 100644 index 0000000000..b75b0fc700 --- /dev/null +++ b/x/mint/simulation/params.go @@ -0,0 +1,47 @@ +package simulation + +// DONTCOVER + +import ( + "fmt" + "math/rand" + + "github.com/cosmos/cosmos-sdk/x/simulation" + + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +const ( + keyInflationRateChange = "InflationRateChange" + keyInflationMax = "InflationMax" + keyInflationMin = "InflationMin" + keyGoalBonded = "GoalBonded" +) + +// 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, keyInflationRateChange, + func(r *rand.Rand) string { + return fmt.Sprintf("\"%s\"", GenInflationRateChange(r)) + }, + ), + simulation.NewSimParamChange(types.ModuleName, keyInflationMax, + func(r *rand.Rand) string { + return fmt.Sprintf("\"%s\"", GenInflationMax(r)) + }, + ), + simulation.NewSimParamChange(types.ModuleName, keyInflationMin, + func(r *rand.Rand) string { + return fmt.Sprintf("\"%s\"", GenInflationMin(r)) + }, + ), + simulation.NewSimParamChange(types.ModuleName, keyGoalBonded, + func(r *rand.Rand) string { + return fmt.Sprintf("\"%s\"", GenGoalBonded(r)) + }, + ), + } +} diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go new file mode 100644 index 0000000000..6bc0f624cf --- /dev/null +++ b/x/mint/simulation/params_test.go @@ -0,0 +1,38 @@ +package simulation_test + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/x/mint/simulation" +) + +func TestParamChangest(t *testing.T) { + s := rand.NewSource(1) + r := rand.New(s) + + expected := []struct { + composedKey string + key string + simValue string + subspace string + }{ + {"mint/InflationRateChange", "InflationRateChange", "\"0.230000000000000000\"", "mint"}, + {"mint/InflationMax", "InflationMax", "\"0.200000000000000000\"", "mint"}, + {"mint/InflationMin", "InflationMin", "\"0.070000000000000000\"", "mint"}, + {"mint/GoalBonded", "GoalBonded", "\"0.670000000000000000\"", "mint"}, + } + + paramChanges := simulation.ParamChanges(r) + require.Len(t, paramChanges, 4) + + 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/mint/spec/01_concepts.md b/x/mint/spec/01_concepts.md new file mode 100644 index 0000000000..e17e7845e8 --- /dev/null +++ b/x/mint/spec/01_concepts.md @@ -0,0 +1,28 @@ + + +# Concepts + +## The Minting Mechanism + +The minting mechanism was designed to: + +- allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio +- effect a balance between market liquidity and staked supply + +In order to best determine the appropriate market rate for inflation rewards, a +moving change rate is used. The moving change rate mechanism ensures that if +the % bonded is either over or under the goal %-bonded, the inflation rate will +adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal +%-bonded at less than 100% encourages the network to maintain some non-staked tokens +which should help provide some liquidity. + +It can be broken down in the following way: + +- If the inflation rate is below the goal %-bonded the inflation rate will + increase until a maximum value is reached +- If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation + rate will stay constant +- If the inflation rate is above the goal %-bonded the inflation rate will + decrease until a minimum value is reached diff --git a/x/mint/spec/02_state.md b/x/mint/spec/02_state.md new file mode 100644 index 0000000000..9e25ac1b34 --- /dev/null +++ b/x/mint/spec/02_state.md @@ -0,0 +1,21 @@ + + +# State + +## Minter + +The minter is a space for holding current inflation information. + +- Minter: `0x00 -> ProtocolBuffer(minter)` + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc7/proto/cosmos/mint/v1beta1/mint.proto#L8-L19 + +## Params + +Minting params are held in the global params store. + +- Params: `mint/params -> legacy_amino(params)` + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc7/proto/cosmos/mint/v1beta1/mint.proto#L21-L53 diff --git a/x/mint/spec/03_begin_block.md b/x/mint/spec/03_begin_block.md new file mode 100644 index 0000000000..2f23f0aeb1 --- /dev/null +++ b/x/mint/spec/03_begin_block.md @@ -0,0 +1,54 @@ + + +# Begin-Block + +Minting parameters are recalculated and inflation +paid at the beginning of each block. + +## NextInflationRate + +The target annual inflation rate is recalculated each block. +The inflation is also subject to a rate change (positive or negative) +depending on the distance from the desired ratio (67%). The maximum rate change +possible is defined to be 13% per year, however the annual inflation is capped +as between 7% and 20%. + +``` +NextInflationRate(params Params, bondedRatio sdk.Dec) (inflation sdk.Dec) { + inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange + inflationRateChange = inflationRateChangePerYear/blocksPerYr + + // increase the new annual inflation for this next cycle + inflation += inflationRateChange + if inflation > params.InflationMax { + inflation = params.InflationMax + } + if inflation < params.InflationMin { + inflation = params.InflationMin + } + + return inflation +} +``` + +## NextAnnualProvisions + +Calculate the annual provisions based on current total supply and inflation +rate. This parameter is calculated once per block. + +``` +NextAnnualProvisions(params Params, totalSupply sdk.Dec) (provisions sdk.Dec) { + return Inflation * totalSupply +``` + +## BlockProvision + +Calculate the provisions generated for each block based on current annual provisions. The provisions are then minted by the `mint` module's `ModuleMinterAccount` and then transferred to the `auth`'s `FeeCollector` `ModuleAccount`. + +``` +BlockProvision(params Params) sdk.Coin { + provisionAmt = AnnualProvisions/ params.BlocksPerYear + return sdk.NewCoin(params.MintDenom, provisionAmt.Truncate()) +``` diff --git a/x/mint/spec/04_params.md b/x/mint/spec/04_params.md new file mode 100644 index 0000000000..ed18e5557e --- /dev/null +++ b/x/mint/spec/04_params.md @@ -0,0 +1,16 @@ + + +# Parameters + +The minting module contains the following parameters: + +| Key | Type | Example | +|---------------------|-----------------|------------------------| +| MintDenom | string | "uatom" | +| InflationRateChange | string (dec) | "0.130000000000000000" | +| InflationMax | string (dec) | "0.200000000000000000" | +| InflationMin | string (dec) | "0.070000000000000000" | +| GoalBonded | string (dec) | "0.670000000000000000" | +| BlocksPerYear | string (uint64) | "6311520" | diff --git a/x/mint/spec/05_events.md b/x/mint/spec/05_events.md new file mode 100644 index 0000000000..f6130a3b99 --- /dev/null +++ b/x/mint/spec/05_events.md @@ -0,0 +1,16 @@ + + +# Events + +The minting module emits the following events: + +## BeginBlocker + +| Type | Attribute Key | Attribute Value | +|------|-------------------|--------------------| +| mint | bonded_ratio | {bondedRatio} | +| mint | inflation | {inflation} | +| mint | annual_provisions | {annualProvisions} | +| mint | amount | {amount} | diff --git a/x/mint/spec/06_client.md b/x/mint/spec/06_client.md new file mode 100644 index 0000000000..e2c366d932 --- /dev/null +++ b/x/mint/spec/06_client.md @@ -0,0 +1,224 @@ + + +# Client + +## CLI + +A user can query and interact with the `mint` module using the CLI. + +### Query + +The `query` commands allow users to query `mint` state. + +``` +simd query mint --help +``` + +#### annual-provisions + +The `annual-provisions` command allow users to query the current minting annual provisions value + +``` +simd query mint annual-provisions [flags] +``` + +Example: + +``` +simd query mint annual-provisions +``` + +Example Output: + +``` +22268504368893.612100895088410693 +``` + +#### inflation + +The `inflation` command allow users to query the current minting inflation value + +``` +simd query mint inflation [flags] +``` + +Example: + +``` +simd query mint inflation +``` + +Example Output: + +``` +0.199200302563256955 +``` + +#### params + +The `params` command allow users to query the current minting parameters + +``` +simd query mint params [flags] +``` + +Example: + +``` +blocks_per_year: "4360000" +goal_bonded: "0.670000000000000000" +inflation_max: "0.200000000000000000" +inflation_min: "0.070000000000000000" +inflation_rate_change: "0.130000000000000000" +mint_denom: stake +``` + +## gRPC + +A user can query the `mint` module using gRPC endpoints. + +### AnnualProvisions + +The `AnnualProvisions` endpoint allow users to query the current minting annual provisions value + +``` +/cosmos.mint.v1beta1.Query/AnnualProvisions +``` + +Example: + +``` +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/AnnualProvisions +``` + +Example Output: + +``` +{ + "annualProvisions": "1432452520532626265712995618" +} +``` + +### Inflation + +The `Inflation` endpoint allow users to query the current minting inflation value + +``` +/cosmos.mint.v1beta1.Query/Inflation +``` + +Example: + +``` +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Inflation +``` + +Example Output: + +``` +{ + "inflation": "130197115720711261" +} +``` + +### Params + +The `Params` endpoint allow users to query the current minting parameters + +``` +/cosmos.mint.v1beta1.Query/Params +``` + +Example: + +``` +grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Params +``` + +Example Output: + +``` +{ + "params": { + "mintDenom": "stake", + "inflationRateChange": "130000000000000000", + "inflationMax": "200000000000000000", + "inflationMin": "70000000000000000", + "goalBonded": "670000000000000000", + "blocksPerYear": "6311520" + } +} +``` + +## REST + +A user can query the `mint` module using REST endpoints. + +### annual-provisions + +``` +/cosmos/mint/v1beta1/annual_provisions +``` + +Example: + +``` +curl "localhost:1317/cosmos/mint/v1beta1/annual_provisions" +``` + +Example Output: + +``` +{ + "annualProvisions": "1432452520532626265712995618" +} +``` + +### inflation + +``` +/cosmos/mint/v1beta1/inflation +``` + +Example: + +``` +curl "localhost:1317/cosmos/mint/v1beta1/inflation" +``` + +Example Output: + +``` +{ + "inflation": "130197115720711261" +} +``` + +### params + +``` +/cosmos/mint/v1beta1/params +``` + +Example: + +``` +curl "localhost:1317/cosmos/mint/v1beta1/params" +``` + +Example Output: + +``` +{ + "params": { + "mintDenom": "stake", + "inflationRateChange": "130000000000000000", + "inflationMax": "200000000000000000", + "inflationMin": "70000000000000000", + "goalBonded": "670000000000000000", + "blocksPerYear": "6311520" + } +} +``` diff --git a/x/mint/spec/README.md b/x/mint/spec/README.md new file mode 100644 index 0000000000..dc60da9995 --- /dev/null +++ b/x/mint/spec/README.md @@ -0,0 +1,22 @@ + + +# `mint` + +## Contents + +1. **[Concept](01_concepts.md)** +2. **[State](02_state.md)** + - [Minter](02_state.md#minter) + - [Params](02_state.md#params) +3. **[Begin-Block](03_begin_block.md)** + - [NextInflationRate](03_begin_block.md#nextinflationrate) + - [NextAnnualProvisions](03_begin_block.md#nextannualprovisions) + - [BlockProvision](03_begin_block.md#blockprovision) +4. **[Parameters](04_params.md)** +5. **[Events](05_events.md)** + - [BeginBlocker](05_events.md#beginblocker) diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go new file mode 100644 index 0000000000..b436c10298 --- /dev/null +++ b/x/mint/types/codec.go @@ -0,0 +1,15 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" +) + +var ( + amino = codec.NewLegacyAmino() +) + +func init() { + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/mint/types/events.go b/x/mint/types/events.go new file mode 100644 index 0000000000..dce85bdb75 --- /dev/null +++ b/x/mint/types/events.go @@ -0,0 +1,10 @@ +package types + +// Minting module event types +const ( + EventTypeMint = ModuleName + + AttributeKeyBondedRatio = "bonded_ratio" + AttributeKeyInflation = "inflation" + AttributeKeyAnnualProvisions = "annual_provisions" +) diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go new file mode 100644 index 0000000000..85b6d776c5 --- /dev/null +++ b/x/mint/types/expected_keepers.go @@ -0,0 +1,29 @@ +package types // noalias + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// StakingKeeper defines the expected staking keeper +type StakingKeeper interface { + StakingTokenSupply(ctx sdk.Context) sdk.Int + BondedRatio(ctx sdk.Context) sdk.Dec +} + +// AccountKeeper defines the contract required for account APIs. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + + // TODO remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 + SetModuleAccount(sdk.Context, types.ModuleAccountI) + GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI +} + +// BankKeeper defines the contract needed to be fulfilled for banking and supply +// dependencies. +type BankKeeper interface { + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error + MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error +} diff --git a/x/mint/types/genesis.go b/x/mint/types/genesis.go new file mode 100644 index 0000000000..3d2f761b4a --- /dev/null +++ b/x/mint/types/genesis.go @@ -0,0 +1,27 @@ +package types + +// NewGenesisState creates a new GenesisState object +func NewGenesisState(minter Minter, params Params) *GenesisState { + return &GenesisState{ + Minter: minter, + Params: params, + } +} + +// DefaultGenesisState creates a default GenesisState object +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + Minter: DefaultInitialMinter(), + Params: DefaultParams(), + } +} + +// ValidateGenesis validates the provided genesis state to ensure the +// expected invariants holds. +func ValidateGenesis(data GenesisState) error { + if err := data.Params.Validate(); err != nil { + return err + } + + return ValidateMinter(data.Minter) +} diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go new file mode 100644 index 0000000000..1486c35f22 --- /dev/null +++ b/x/mint/types/genesis.pb.go @@ -0,0 +1,377 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/mint/v1beta1/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 mint module's genesis state. +type GenesisState struct { + // minter is a space for holding current inflation information. + Minter Minter `protobuf:"bytes,1,opt,name=minter,proto3" json:"minter"` + // params defines all the paramaters of the module. + Params Params `protobuf:"bytes,2,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_0e215eb1d09cd648, []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) GetMinter() Minter { + if m != nil { + return m.Minter + } + return Minter{} +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "cosmos.mint.v1beta1.GenesisState") +} + +func init() { proto.RegisterFile("cosmos/mint/v1beta1/genesis.proto", fileDescriptor_0e215eb1d09cd648) } + +var fileDescriptor_0e215eb1d09cd648 = []byte{ + // 218 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, + 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, + 0x28, 0xd1, 0x03, 0x29, 0xd1, 0x83, 0x2a, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, + 0x83, 0x58, 0x10, 0xa5, 0x52, 0x72, 0xd8, 0x4c, 0x03, 0xeb, 0x03, 0xcb, 0x2b, 0xb5, 0x30, 0x72, + 0xf1, 0xb8, 0x43, 0x0c, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe4, 0x62, 0x03, 0x49, 0xa7, + 0x16, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xeb, 0x61, 0xb1, 0x4c, 0xcf, 0x17, 0xac, + 0xc4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x06, 0x90, 0xd6, 0x82, 0xc4, 0xa2, 0xc4, + 0xdc, 0x62, 0x09, 0x26, 0x3c, 0x5a, 0x03, 0xc0, 0x4a, 0x60, 0x5a, 0x21, 0x1a, 0x9c, 0x9c, 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, 0x33, 0x3d, 0xb3, 0x24, 0xa3, 0x34, + 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x17, 0x08, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, + 0xf1, 0x58, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x4b, 0xc6, 0x80, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xbb, 0xc1, 0x11, 0x51, 0x42, 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] = 0x12 + { + size, err := m.Minter.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.Minter.Size() + n += 1 + l + sovGenesis(uint64(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 Minter", 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.Minter.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + 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/mint/types/keys.go b/x/mint/types/keys.go new file mode 100644 index 0000000000..e1c778744f --- /dev/null +++ b/x/mint/types/keys.go @@ -0,0 +1,20 @@ +package types + +// MinterKey is the key to use for the keeper store. +var MinterKey = []byte{0x00} + +const ( + // module name + ModuleName = "mint" + + // StoreKey is the default store key for mint + StoreKey = ModuleName + + // QuerierRoute is the querier route for the minting store. + QuerierRoute = StoreKey + + // Query endpoints supported by the minting querier + QueryParameters = "parameters" + QueryInflation = "inflation" + QueryAnnualProvisions = "annual_provisions" +) diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go new file mode 100644 index 0000000000..4ed1cccd69 --- /dev/null +++ b/x/mint/types/mint.pb.go @@ -0,0 +1,779 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/mint/v1beta1/mint.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "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 + +// Minter represents the minting state. +type Minter struct { + // current annual inflation rate + Inflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation"` + // current annual expected provisions + AnnualProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"annual_provisions" yaml:"annual_provisions"` +} + +func (m *Minter) Reset() { *m = Minter{} } +func (m *Minter) String() string { return proto.CompactTextString(m) } +func (*Minter) ProtoMessage() {} +func (*Minter) Descriptor() ([]byte, []int) { + return fileDescriptor_2df116d183c1e223, []int{0} +} +func (m *Minter) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Minter.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 *Minter) XXX_Merge(src proto.Message) { + xxx_messageInfo_Minter.Merge(m, src) +} +func (m *Minter) XXX_Size() int { + return m.Size() +} +func (m *Minter) XXX_DiscardUnknown() { + xxx_messageInfo_Minter.DiscardUnknown(m) +} + +var xxx_messageInfo_Minter proto.InternalMessageInfo + +// Params holds parameters for the mint module. +type Params struct { + // type of coin to mint + MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` + // maximum annual change in inflation rate + InflationRateChange github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=inflation_rate_change,json=inflationRateChange,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_rate_change" yaml:"inflation_rate_change"` + // maximum inflation rate + InflationMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=inflation_max,json=inflationMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_max" yaml:"inflation_max"` + // minimum inflation rate + InflationMin github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=inflation_min,json=inflationMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_min" yaml:"inflation_min"` + // goal of percent bonded atoms + GoalBonded github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"goal_bonded" yaml:"goal_bonded"` + // expected blocks per year + BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_2df116d183c1e223, []int{1} +} +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) GetMintDenom() string { + if m != nil { + return m.MintDenom + } + return "" +} + +func (m *Params) GetBlocksPerYear() uint64 { + if m != nil { + return m.BlocksPerYear + } + return 0 +} + +func init() { + proto.RegisterType((*Minter)(nil), "cosmos.mint.v1beta1.Minter") + proto.RegisterType((*Params)(nil), "cosmos.mint.v1beta1.Params") +} + +func init() { proto.RegisterFile("cosmos/mint/v1beta1/mint.proto", fileDescriptor_2df116d183c1e223) } + +var fileDescriptor_2df116d183c1e223 = []byte{ + // 437 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xc1, 0x6e, 0xd3, 0x30, + 0x1c, 0xc6, 0x63, 0x28, 0x95, 0x6a, 0x98, 0x00, 0x6f, 0xa0, 0x68, 0x82, 0x64, 0xca, 0x01, 0x8d, + 0x03, 0x89, 0x26, 0x6e, 0x3b, 0x66, 0x15, 0x07, 0xc4, 0x50, 0xe5, 0x1b, 0x5c, 0xa2, 0x7f, 0x52, + 0x93, 0x59, 0x8d, 0xed, 0xca, 0xf6, 0x46, 0x7b, 0xe5, 0x09, 0x38, 0x72, 0xe4, 0x2d, 0x78, 0x85, + 0xdd, 0xd8, 0x11, 0x71, 0xa8, 0x50, 0xfb, 0x06, 0x7b, 0x02, 0x14, 0xbb, 0x6a, 0xa1, 0x20, 0xa4, + 0x4a, 0x9c, 0x92, 0xef, 0xfb, 0xff, 0xf3, 0xfd, 0xbe, 0x58, 0x32, 0x8e, 0x2a, 0x65, 0x84, 0x32, + 0x99, 0xe0, 0xd2, 0x66, 0x17, 0x47, 0x25, 0xb3, 0x70, 0xe4, 0x44, 0x3a, 0xd6, 0xca, 0x2a, 0xb2, + 0xeb, 0xe7, 0xa9, 0xb3, 0x96, 0xf3, 0xfd, 0xbd, 0x5a, 0xd5, 0xca, 0xcd, 0xb3, 0xf6, 0xcd, 0xaf, + 0x26, 0x5f, 0x11, 0xee, 0x9e, 0x72, 0x69, 0x99, 0x26, 0xaf, 0x70, 0x8f, 0xcb, 0x77, 0x0d, 0x58, + 0xae, 0x64, 0x88, 0x0e, 0xd0, 0x61, 0x2f, 0x4f, 0x2f, 0x67, 0x71, 0xf0, 0x7d, 0x16, 0x3f, 0xa9, + 0xb9, 0x3d, 0x3b, 0x2f, 0xd3, 0x4a, 0x89, 0x6c, 0xc9, 0xf6, 0x8f, 0x67, 0x66, 0x38, 0xca, 0xec, + 0x74, 0xcc, 0x4c, 0xda, 0x67, 0x15, 0x5d, 0x07, 0x90, 0xf7, 0xf8, 0x3e, 0x48, 0x79, 0x0e, 0x4d, + 0x31, 0xd6, 0xea, 0x82, 0x1b, 0xae, 0xa4, 0x09, 0x6f, 0xb8, 0xd4, 0x97, 0xdb, 0xa5, 0x5e, 0xcf, + 0xe2, 0x70, 0x0a, 0xa2, 0x39, 0x4e, 0xfe, 0x08, 0x4c, 0xe8, 0x3d, 0xef, 0x0d, 0xd6, 0xd6, 0x97, + 0x0e, 0xee, 0x0e, 0x40, 0x83, 0x30, 0xe4, 0x31, 0xc6, 0xed, 0x11, 0x14, 0x43, 0x26, 0x95, 0xf0, + 0xbf, 0x44, 0x7b, 0xad, 0xd3, 0x6f, 0x0d, 0xf2, 0x01, 0xe1, 0x07, 0xab, 0xc2, 0x85, 0x06, 0xcb, + 0x8a, 0xea, 0x0c, 0x64, 0xcd, 0x96, 0x3d, 0x5f, 0x6f, 0xdd, 0xf3, 0x91, 0xef, 0xf9, 0xd7, 0xd0, + 0x84, 0xee, 0xae, 0x7c, 0x0a, 0x96, 0x9d, 0x38, 0x97, 0x8c, 0xf0, 0xce, 0x7a, 0x5d, 0xc0, 0x24, + 0xbc, 0xe9, 0xd8, 0x2f, 0xb6, 0x66, 0xef, 0x6d, 0xb2, 0x05, 0x4c, 0x12, 0x7a, 0x67, 0xa5, 0x4f, + 0x61, 0xb2, 0x01, 0xe3, 0x32, 0xec, 0xfc, 0x37, 0x18, 0x97, 0xbf, 0xc1, 0xb8, 0x24, 0x0c, 0xdf, + 0xae, 0x15, 0x34, 0x45, 0xa9, 0xe4, 0x90, 0x0d, 0xc3, 0x5b, 0x0e, 0xd5, 0xdf, 0x1a, 0x45, 0x3c, + 0xea, 0x97, 0xa8, 0x84, 0xe2, 0x56, 0xe5, 0x4e, 0x90, 0x1c, 0xdf, 0x2d, 0x1b, 0x55, 0x8d, 0x4c, + 0x31, 0x66, 0xba, 0x98, 0x32, 0xd0, 0x61, 0xf7, 0x00, 0x1d, 0x76, 0xf2, 0xfd, 0xeb, 0x59, 0xfc, + 0xd0, 0x7f, 0xbc, 0xb1, 0x90, 0xd0, 0x1d, 0xef, 0x0c, 0x98, 0x7e, 0xc3, 0x40, 0x1f, 0x77, 0x3e, + 0x7d, 0x8e, 0x83, 0xfc, 0xe4, 0x72, 0x1e, 0xa1, 0xab, 0x79, 0x84, 0x7e, 0xcc, 0x23, 0xf4, 0x71, + 0x11, 0x05, 0x57, 0x8b, 0x28, 0xf8, 0xb6, 0x88, 0x82, 0xb7, 0x4f, 0xff, 0xd9, 0x76, 0xe2, 0x2f, + 0xa2, 0x2b, 0x5d, 0x76, 0xdd, 0xbd, 0x7a, 0xfe, 0x33, 0x00, 0x00, 0xff, 0xff, 0x34, 0x52, 0xcf, + 0x87, 0xa4, 0x03, 0x00, 0x00, +} + +func (m *Minter) 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 *Minter) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Inflation.Size() + i -= size + if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +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.BlocksPerYear != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) + i-- + dAtA[i] = 0x30 + } + { + size := m.GoalBonded.Size() + i -= size + if _, err := m.GoalBonded.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + { + size := m.InflationMin.Size() + i -= size + if _, err := m.InflationMin.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.InflationMax.Size() + i -= size + if _, err := m.InflationMax.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.InflationRateChange.Size() + i -= size + if _, err := m.InflationRateChange.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.MintDenom) > 0 { + i -= len(m.MintDenom) + copy(dAtA[i:], m.MintDenom) + i = encodeVarintMint(dAtA, i, uint64(len(m.MintDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMint(dAtA []byte, offset int, v uint64) int { + offset -= sovMint(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Minter) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Inflation.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.AnnualProvisions.Size() + n += 1 + l + sovMint(uint64(l)) + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MintDenom) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + l = m.InflationRateChange.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.InflationMax.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.InflationMin.Size() + n += 1 + l + sovMint(uint64(l)) + l = m.GoalBonded.Size() + n += 1 + l + sovMint(uint64(l)) + if m.BlocksPerYear != 0 { + n += 1 + sovMint(uint64(m.BlocksPerYear)) + } + return n +} + +func sovMint(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMint(x uint64) (n int) { + return sovMint(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Minter) 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 ErrIntOverflowMint + } + 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: Minter: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +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 ErrIntOverflowMint + } + 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 != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MintDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationRateChange", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationRateChange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationMax", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationMax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InflationMin", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InflationMin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GoalBonded", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GoalBonded.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType) + } + m.BlocksPerYear = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerYear |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipMint(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMint + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMint(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, ErrIntOverflowMint + } + 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, ErrIntOverflowMint + } + 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, ErrIntOverflowMint + } + 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, ErrInvalidLengthMint + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMint + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMint + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMint = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMint = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMint = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go new file mode 100644 index 0000000000..3285d6ddf0 --- /dev/null +++ b/x/mint/types/minter.go @@ -0,0 +1,80 @@ +package types + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// NewMinter returns a new Minter object with the given inflation and annual +// provisions values. +func NewMinter(inflation, annualProvisions sdk.Dec) Minter { + return Minter{ + Inflation: inflation, + AnnualProvisions: annualProvisions, + } +} + +// InitialMinter returns an initial Minter object with a given inflation value. +func InitialMinter(inflation sdk.Dec) Minter { + return NewMinter( + inflation, + sdk.NewDec(0), + ) +} + +// DefaultInitialMinter returns a default initial Minter object for a new chain +// which uses an inflation rate of 13%. +func DefaultInitialMinter() Minter { + return InitialMinter( + sdk.NewDecWithPrec(13, 2), + ) +} + +// validate minter +func ValidateMinter(minter Minter) error { + if minter.Inflation.IsNegative() { + return fmt.Errorf("mint parameter Inflation should be positive, is %s", + minter.Inflation.String()) + } + return nil +} + +// NextInflationRate returns the new inflation rate for the next hour. +func (m Minter) NextInflationRate(params Params, bondedRatio sdk.Dec) sdk.Dec { + // The target annual inflation rate is recalculated for each previsions cycle. The + // inflation is also subject to a rate change (positive or negative) depending on + // the distance from the desired ratio (67%). The maximum rate change possible is + // defined to be 13% per year, however the annual inflation is capped as between + // 7% and 20%. + + // (1 - bondedRatio/GoalBonded) * InflationRateChange + inflationRateChangePerYear := sdk.OneDec(). + Sub(bondedRatio.Quo(params.GoalBonded)). + Mul(params.InflationRateChange) + inflationRateChange := inflationRateChangePerYear.Quo(sdk.NewDec(int64(params.BlocksPerYear))) + + // adjust the new annual inflation for this next cycle + inflation := m.Inflation.Add(inflationRateChange) // note inflationRateChange may be negative + if inflation.GT(params.InflationMax) { + inflation = params.InflationMax + } + if inflation.LT(params.InflationMin) { + inflation = params.InflationMin + } + + return inflation +} + +// NextAnnualProvisions returns the annual provisions based on current total +// supply and inflation rate. +func (m Minter) NextAnnualProvisions(_ Params, totalSupply sdk.Int) sdk.Dec { + return m.Inflation.MulInt(totalSupply) +} + +// BlockProvision returns the provisions for a block based on the annual +// provisions rate. +func (m Minter) BlockProvision(params Params) sdk.Coin { + provisionAmt := m.AnnualProvisions.QuoInt(sdk.NewInt(int64(params.BlocksPerYear))) + return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt()) +} diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go new file mode 100644 index 0000000000..4abedb51cd --- /dev/null +++ b/x/mint/types/minter_test.go @@ -0,0 +1,134 @@ +package types + +import ( + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func TestNextInflation(t *testing.T) { + minter := DefaultInitialMinter() + params := DefaultParams() + blocksPerYr := sdk.NewDec(int64(params.BlocksPerYear)) + + // Governing Mechanism: + // inflationRateChangePerYear = (1- BondedRatio/ GoalBonded) * MaxInflationRateChange + + tests := []struct { + bondedRatio, setInflation, expChange sdk.Dec + }{ + // with 0% bonded atom supply the inflation should increase by InflationRateChange + {sdk.ZeroDec(), sdk.NewDecWithPrec(7, 2), params.InflationRateChange.Quo(blocksPerYr)}, + + // 100% bonded, starting at 20% inflation and being reduced + // (1 - (1/0.67))*(0.13/8667) + {sdk.OneDec(), sdk.NewDecWithPrec(20, 2), + sdk.OneDec().Sub(sdk.OneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, + + // 50% bonded, starting at 10% inflation and being increased + {sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(10, 2), + sdk.OneDec().Sub(sdk.NewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, + + // test 7% minimum stop (testing with 100% bonded) + {sdk.OneDec(), sdk.NewDecWithPrec(7, 2), sdk.ZeroDec()}, + {sdk.OneDec(), sdk.NewDecWithPrec(700000001, 10), sdk.NewDecWithPrec(-1, 10)}, + + // test 20% maximum stop (testing with 0% bonded) + {sdk.ZeroDec(), sdk.NewDecWithPrec(20, 2), sdk.ZeroDec()}, + {sdk.ZeroDec(), sdk.NewDecWithPrec(1999999999, 10), sdk.NewDecWithPrec(1, 10)}, + + // perfect balance shouldn't change inflation + {sdk.NewDecWithPrec(67, 2), sdk.NewDecWithPrec(15, 2), sdk.ZeroDec()}, + } + for i, tc := range tests { + minter.Inflation = tc.setInflation + + inflation := minter.NextInflationRate(params, tc.bondedRatio) + diffInflation := inflation.Sub(tc.setInflation) + + require.True(t, diffInflation.Equal(tc.expChange), + "Test Index: %v\nDiff: %v\nExpected: %v\n", i, diffInflation, tc.expChange) + } +} + +func TestBlockProvision(t *testing.T) { + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + + secondsPerYear := int64(60 * 60 * 8766) + + tests := []struct { + annualProvisions int64 + expProvisions int64 + }{ + {secondsPerYear / 5, 1}, + {secondsPerYear/5 + 1, 1}, + {(secondsPerYear / 5) * 2, 2}, + {(secondsPerYear / 5) / 2, 0}, + } + for i, tc := range tests { + minter.AnnualProvisions = sdk.NewDec(tc.annualProvisions) + provisions := minter.BlockProvision(params) + + expProvisions := sdk.NewCoin(params.MintDenom, + sdk.NewInt(tc.expProvisions)) + + require.True(t, expProvisions.IsEqual(provisions), + "test: %v\n\tExp: %v\n\tGot: %v\n", + i, tc.expProvisions, provisions) + } +} + +// Benchmarking :) +// previously using sdk.Int operations: +// BenchmarkBlockProvision-4 5000000 220 ns/op +// +// using sdk.Dec operations: (current implementation) +// BenchmarkBlockProvision-4 3000000 429 ns/op +func BenchmarkBlockProvision(b *testing.B) { + b.ReportAllocs() + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + + s1 := rand.NewSource(100) + r1 := rand.New(s1) + minter.AnnualProvisions = sdk.NewDec(r1.Int63n(1000000)) + + // run the BlockProvision function b.N times + for n := 0; n < b.N; n++ { + minter.BlockProvision(params) + } +} + +// Next inflation benchmarking +// BenchmarkNextInflation-4 1000000 1828 ns/op +func BenchmarkNextInflation(b *testing.B) { + b.ReportAllocs() + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + bondedRatio := sdk.NewDecWithPrec(1, 1) + + // run the NextInflationRate function b.N times + for n := 0; n < b.N; n++ { + minter.NextInflationRate(params, bondedRatio) + } + +} + +// Next annual provisions benchmarking +// BenchmarkNextAnnualProvisions-4 5000000 251 ns/op +func BenchmarkNextAnnualProvisions(b *testing.B) { + b.ReportAllocs() + minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) + params := DefaultParams() + totalSupply := sdk.NewInt(100000000000000) + + // run the NextAnnualProvisions function b.N times + for n := 0; n < b.N; n++ { + minter.NextAnnualProvisions(params, totalSupply) + } + +} diff --git a/x/mint/types/params.go b/x/mint/types/params.go new file mode 100644 index 0000000000..f0f9ef494b --- /dev/null +++ b/x/mint/types/params.go @@ -0,0 +1,195 @@ +package types + +import ( + "errors" + "fmt" + "strings" + + yaml "gopkg.in/yaml.v2" + + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +// Parameter store keys +var ( + KeyMintDenom = []byte("MintDenom") + KeyInflationRateChange = []byte("InflationRateChange") + KeyInflationMax = []byte("InflationMax") + KeyInflationMin = []byte("InflationMin") + KeyGoalBonded = []byte("GoalBonded") + KeyBlocksPerYear = []byte("BlocksPerYear") +) + +// ParamTable for minting module. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +func NewParams( + mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, +) Params { + + return Params{ + MintDenom: mintDenom, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, + } +} + +// default minting module parameters +func DefaultParams() Params { + return Params{ + MintDenom: sdk.DefaultBondDenom, + InflationRateChange: sdk.NewDecWithPrec(13, 2), + InflationMax: sdk.NewDecWithPrec(20, 2), + InflationMin: sdk.NewDecWithPrec(7, 2), + GoalBonded: sdk.NewDecWithPrec(67, 2), + BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times + } +} + +// validate params +func (p Params) Validate() error { + if err := validateMintDenom(p.MintDenom); err != nil { + return err + } + if err := validateInflationRateChange(p.InflationRateChange); err != nil { + return err + } + if err := validateInflationMax(p.InflationMax); err != nil { + return err + } + if err := validateInflationMin(p.InflationMin); err != nil { + return err + } + if err := validateGoalBonded(p.GoalBonded); err != nil { + return err + } + if err := validateBlocksPerYear(p.BlocksPerYear); err != nil { + return err + } + if p.InflationMax.LT(p.InflationMin) { + return fmt.Errorf( + "max inflation (%s) must be greater than or equal to min inflation (%s)", + p.InflationMax, p.InflationMin, + ) + } + + return nil + +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +// Implements params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), + paramtypes.NewParamSetPair(KeyInflationRateChange, &p.InflationRateChange, validateInflationRateChange), + paramtypes.NewParamSetPair(KeyInflationMax, &p.InflationMax, validateInflationMax), + paramtypes.NewParamSetPair(KeyInflationMin, &p.InflationMin, validateInflationMin), + paramtypes.NewParamSetPair(KeyGoalBonded, &p.GoalBonded, validateGoalBonded), + paramtypes.NewParamSetPair(KeyBlocksPerYear, &p.BlocksPerYear, validateBlocksPerYear), + } +} + +func validateMintDenom(i interface{}) error { + v, ok := i.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if strings.TrimSpace(v) == "" { + return errors.New("mint denom cannot be blank") + } + if err := sdk.ValidateDenom(v); err != nil { + return err + } + + return nil +} + +func validateInflationRateChange(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNegative() { + return fmt.Errorf("inflation rate change cannot be negative: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("inflation rate change too large: %s", v) + } + + return nil +} + +func validateInflationMax(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNegative() { + return fmt.Errorf("max inflation cannot be negative: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("max inflation too large: %s", v) + } + + return nil +} + +func validateInflationMin(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNegative() { + return fmt.Errorf("min inflation cannot be negative: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("min inflation too large: %s", v) + } + + return nil +} + +func validateGoalBonded(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v.IsNegative() { + return fmt.Errorf("goal bonded cannot be negative: %s", v) + } + if v.GT(sdk.OneDec()) { + return fmt.Errorf("goal bonded too large: %s", v) + } + + return nil +} + +func validateBlocksPerYear(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("blocks per year must be positive: %d", v) + } + + return nil +} diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go new file mode 100644 index 0000000000..f707eb810d --- /dev/null +++ b/x/mint/types/query.pb.go @@ -0,0 +1,1199 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/mint/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "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_d0a1e393be338aea, []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_d0a1e393be338aea, []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{} +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +type QueryInflationRequest struct { +} + +func (m *QueryInflationRequest) Reset() { *m = QueryInflationRequest{} } +func (m *QueryInflationRequest) String() string { return proto.CompactTextString(m) } +func (*QueryInflationRequest) ProtoMessage() {} +func (*QueryInflationRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a1e393be338aea, []int{2} +} +func (m *QueryInflationRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationRequest.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 *QueryInflationRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationRequest.Merge(m, src) +} +func (m *QueryInflationRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationRequest proto.InternalMessageInfo + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +type QueryInflationResponse struct { + // inflation is the current minting inflation value. + Inflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation"` +} + +func (m *QueryInflationResponse) Reset() { *m = QueryInflationResponse{} } +func (m *QueryInflationResponse) String() string { return proto.CompactTextString(m) } +func (*QueryInflationResponse) ProtoMessage() {} +func (*QueryInflationResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a1e393be338aea, []int{3} +} +func (m *QueryInflationResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryInflationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryInflationResponse.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 *QueryInflationResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryInflationResponse.Merge(m, src) +} +func (m *QueryInflationResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryInflationResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryInflationResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryInflationResponse proto.InternalMessageInfo + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsRequest struct { +} + +func (m *QueryAnnualProvisionsRequest) Reset() { *m = QueryAnnualProvisionsRequest{} } +func (m *QueryAnnualProvisionsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsRequest) ProtoMessage() {} +func (*QueryAnnualProvisionsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a1e393be338aea, []int{4} +} +func (m *QueryAnnualProvisionsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsRequest.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 *QueryAnnualProvisionsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsRequest.Merge(m, src) +} +func (m *QueryAnnualProvisionsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsRequest proto.InternalMessageInfo + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +type QueryAnnualProvisionsResponse struct { + // annual_provisions is the current minting annual provisions value. + AnnualProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"annual_provisions"` +} + +func (m *QueryAnnualProvisionsResponse) Reset() { *m = QueryAnnualProvisionsResponse{} } +func (m *QueryAnnualProvisionsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAnnualProvisionsResponse) ProtoMessage() {} +func (*QueryAnnualProvisionsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a1e393be338aea, []int{5} +} +func (m *QueryAnnualProvisionsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAnnualProvisionsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAnnualProvisionsResponse.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 *QueryAnnualProvisionsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAnnualProvisionsResponse.Merge(m, src) +} +func (m *QueryAnnualProvisionsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAnnualProvisionsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAnnualProvisionsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAnnualProvisionsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.mint.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.mint.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryInflationRequest)(nil), "cosmos.mint.v1beta1.QueryInflationRequest") + proto.RegisterType((*QueryInflationResponse)(nil), "cosmos.mint.v1beta1.QueryInflationResponse") + proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "cosmos.mint.v1beta1.QueryAnnualProvisionsRequest") + proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "cosmos.mint.v1beta1.QueryAnnualProvisionsResponse") +} + +func init() { proto.RegisterFile("cosmos/mint/v1beta1/query.proto", fileDescriptor_d0a1e393be338aea) } + +var fileDescriptor_d0a1e393be338aea = []byte{ + // 446 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, + 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, + 0x03, 0x29, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, + 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, + 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x39, 0x6c, 0x36, 0x81, + 0x4d, 0x05, 0xcb, 0x2b, 0x89, 0x70, 0x09, 0x05, 0x82, 0xec, 0x0d, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, + 0x0e, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x0a, 0xe0, 0x12, 0x46, 0x11, 0x2d, 0x2e, 0xc8, + 0xcf, 0x2b, 0x4e, 0x15, 0xb2, 0xe4, 0x62, 0x2b, 0x00, 0x8b, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, + 0x1b, 0x49, 0xeb, 0x61, 0x71, 0xa6, 0x1e, 0x44, 0x93, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, + 0x50, 0x0d, 0x4a, 0xe2, 0x5c, 0xa2, 0x60, 0x13, 0x3d, 0xf3, 0xd2, 0x72, 0xc0, 0x0e, 0x84, 0x59, + 0x95, 0xc6, 0x25, 0x86, 0x2e, 0x01, 0xb5, 0xcd, 0x87, 0x8b, 0x33, 0x13, 0x26, 0x08, 0xb6, 0x90, + 0xc7, 0x49, 0x0f, 0x64, 0xe6, 0xad, 0x7b, 0xf2, 0x6a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, + 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x0f, 0x42, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, + 0xd4, 0x62, 0x3d, 0x97, 0xd4, 0xe4, 0x20, 0x84, 0x01, 0x4a, 0x72, 0x5c, 0x32, 0x60, 0x7b, 0x1c, + 0xf3, 0xf2, 0x4a, 0x13, 0x73, 0x02, 0x8a, 0xf2, 0xcb, 0x32, 0x8b, 0x41, 0xe1, 0x04, 0x73, 0x47, + 0x0d, 0x97, 0x2c, 0x0e, 0x79, 0xa8, 0x73, 0xa2, 0xb9, 0x04, 0x13, 0xc1, 0x72, 0xf1, 0x05, 0x70, + 0x49, 0x32, 0x9d, 0x25, 0x90, 0x88, 0x66, 0x89, 0xd1, 0x51, 0x66, 0x2e, 0x56, 0xb0, 0xf5, 0x42, + 0x0d, 0x8c, 0x5c, 0x6c, 0x90, 0x10, 0x14, 0x52, 0xc7, 0x1a, 0xbc, 0x98, 0xd1, 0x25, 0xa5, 0x41, + 0x58, 0x21, 0xc4, 0x13, 0x4a, 0xca, 0x4d, 0x97, 0x9f, 0x4c, 0x66, 0x92, 0x15, 0x92, 0xd6, 0xc7, + 0x96, 0x2e, 0x20, 0x71, 0x25, 0xd4, 0xc3, 0xc8, 0xc5, 0x09, 0x8f, 0x0e, 0x21, 0x2d, 0xdc, 0x86, + 0xa3, 0x47, 0xa6, 0x94, 0x36, 0x51, 0x6a, 0xa1, 0x6e, 0x51, 0x03, 0xbb, 0x45, 0x41, 0x48, 0x0e, + 0xab, 0x5b, 0xe0, 0x31, 0x27, 0xb4, 0x92, 0x91, 0x4b, 0x00, 0x3d, 0x56, 0x84, 0x0c, 0x71, 0xdb, + 0x84, 0x23, 0x86, 0xa5, 0x8c, 0x48, 0xd1, 0x02, 0x75, 0xa3, 0x1e, 0xd8, 0x8d, 0x1a, 0x42, 0x6a, + 0x58, 0xdd, 0x88, 0x91, 0x1e, 0x9c, 0x9c, 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, 0x13, 0x6f, 0xda, 0xa8, 0x80, 0x18, 0x0c, 0x4e, 0x22, 0x49, 0x6c, 0xe0, 0xac, 0x69, + 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xed, 0x9c, 0x7b, 0x26, 0x04, 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 returns the total set of minting parameters. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Inflation returns the current minting inflation value. + Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) + // AnnualProvisions current minting annual provisions value. + AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, 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.mint.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) { + out := new(QueryInflationResponse) + err := c.cc.Invoke(ctx, "/cosmos.mint.v1beta1.Query/Inflation", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) { + out := new(QueryAnnualProvisionsResponse) + err := c.cc.Invoke(ctx, "/cosmos.mint.v1beta1.Query/AnnualProvisions", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params returns the total set of minting parameters. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // Inflation returns the current minting inflation value. + Inflation(context.Context, *QueryInflationRequest) (*QueryInflationResponse, error) + // AnnualProvisions current minting annual provisions value. + AnnualProvisions(context.Context, *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, 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 (*UnimplementedQueryServer) Inflation(ctx context.Context, req *QueryInflationRequest) (*QueryInflationResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Inflation not implemented") +} +func (*UnimplementedQueryServer) AnnualProvisions(ctx context.Context, req *QueryAnnualProvisionsRequest) (*QueryAnnualProvisionsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AnnualProvisions 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.mint.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Inflation_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryInflationRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Inflation(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.mint.v1beta1.Query/Inflation", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Inflation(ctx, req.(*QueryInflationRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAnnualProvisionsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AnnualProvisions(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.mint.v1beta1.Query/AnnualProvisions", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AnnualProvisions(ctx, req.(*QueryAnnualProvisionsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.mint.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "Inflation", + Handler: _Query_Inflation_Handler, + }, + { + MethodName: "AnnualProvisions", + Handler: _Query_AnnualProvisions_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/mint/v1beta1/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 (m *QueryInflationRequest) 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 *QueryInflationRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryInflationResponse) 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 *QueryInflationResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryInflationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Inflation.Size() + i -= size + if _, err := m.Inflation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsRequest) 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 *QueryAnnualProvisionsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryAnnualProvisionsResponse) 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 *QueryAnnualProvisionsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAnnualProvisionsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.AnnualProvisions.Size() + i -= size + if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + 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 (m *QueryInflationRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryInflationResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Inflation.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAnnualProvisionsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryAnnualProvisionsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.AnnualProvisions.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 (m *QueryInflationRequest) 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: QueryInflationRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationRequest: 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 *QueryInflationResponse) 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: QueryInflationResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryInflationResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Inflation", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Inflation.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 (m *QueryAnnualProvisionsRequest) 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: QueryAnnualProvisionsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsRequest: 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 *QueryAnnualProvisionsResponse) 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: QueryAnnualProvisionsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAnnualProvisionsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.AnnualProvisions.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/mint/types/query.pb.gw.go b/x/mint/types/query.pb.gw.go new file mode 100644 index 0000000000..576b206d4a --- /dev/null +++ b/x/mint/types/query.pb.gw.go @@ -0,0 +1,272 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: cosmos/mint/v1beta1/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/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 + +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 + +} + +func request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRequest + var metadata runtime.ServerMetadata + + msg, err := client.Inflation(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Inflation_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryInflationRequest + var metadata runtime.ServerMetadata + + msg, err := server.Inflation(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := client.AnnualProvisions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAnnualProvisionsRequest + var metadata runtime.ServerMetadata + + msg, err := server.AnnualProvisions(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 (such as grpc.SendHeader, etc) 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() + 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) + 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()...) + + }) + + mux.Handle("GET", pattern_Query_Inflation_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Inflation_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_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.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AnnualProvisions_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AnnualProvisions_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()...) + + }) + + mux.Handle("GET", pattern_Query_Inflation_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_Inflation_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_Inflation_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AnnualProvisions_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_AnnualProvisions_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_AnnualProvisions_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", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Inflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "inflation"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_Inflation_0 = runtime.ForwardResponseMessage + + forward_Query_AnnualProvisions_0 = runtime.ForwardResponseMessage +) From b41dad2d28c0884bcd6fb3472585021803c28ebb Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Thu, 14 Jul 2022 14:12:49 -0700 Subject: [PATCH 2/6] Refactor mint module to use custom in sei --- app/app.go | 6 +- app/test_helpers.go | 2 +- proto/mint/v1beta1/genesis.proto | 6 +- proto/mint/v1beta1/mint.proto | 15 +- proto/mint/v1beta1/query.proto | 12 +- x/dex/keeper/end_block_place_orders_test.go | 2 +- x/dex/module_test.go | 2 +- x/mint/abci.go | 4 +- x/mint/client/cli/query.go | 2 +- x/mint/client/rest/grpc_query_test.go | 9 +- x/mint/client/rest/query.go | 2 +- x/mint/client/testutil/suite.go | 4 +- x/mint/genesis.go | 4 +- x/mint/keeper/grpc_query.go | 2 +- x/mint/keeper/grpc_query_test.go | 2 +- x/mint/keeper/hooks.go | 16 ++ x/mint/keeper/integration_test.go | 2 +- x/mint/keeper/keeper.go | 2 +- x/mint/keeper/querier.go | 2 +- x/mint/keeper/querier_test.go | 4 +- x/mint/legacy/v039/types.go | 31 --- x/mint/legacy/v040/migrate.go | 27 --- x/mint/legacy/v040/types.go | 5 - x/mint/module.go | 10 +- x/mint/module_test.go | 2 +- x/mint/simulation/decoder.go | 2 +- x/mint/simulation/decoder_test.go | 4 +- x/mint/simulation/genesis.go | 4 +- x/mint/simulation/genesis_test.go | 4 +- x/mint/simulation/params.go | 2 +- x/mint/simulation/params_test.go | 2 +- x/mint/spec/01_concepts.md | 28 --- x/mint/spec/02_state.md | 21 -- x/mint/spec/03_begin_block.md | 54 ----- x/mint/spec/04_params.md | 16 -- x/mint/spec/05_events.md | 16 -- x/mint/spec/06_client.md | 224 -------------------- x/mint/spec/README.md | 25 +-- x/mint/types/genesis.pb.go | 41 ++-- x/mint/types/mint.pb.go | 215 +++++++++++++++---- x/mint/types/params.go | 46 ++-- x/mint/types/query.pb.go | 112 +++++----- x/mint/types/query.pb.gw.go | 21 +- 43 files changed, 385 insertions(+), 627 deletions(-) create mode 100644 x/mint/keeper/hooks.go delete mode 100644 x/mint/legacy/v039/types.go delete mode 100644 x/mint/legacy/v040/migrate.go delete mode 100644 x/mint/legacy/v040/types.go delete mode 100644 x/mint/spec/01_concepts.md delete mode 100644 x/mint/spec/02_state.md delete mode 100644 x/mint/spec/03_begin_block.md delete mode 100644 x/mint/spec/04_params.md delete mode 100644 x/mint/spec/05_events.md delete mode 100644 x/mint/spec/06_client.md diff --git a/app/app.go b/app/app.go index 2dc9ce9c17..38fb189c40 100644 --- a/app/app.go +++ b/app/app.go @@ -59,9 +59,6 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/mint" - mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" "github.com/cosmos/cosmos-sdk/x/params" paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" @@ -87,6 +84,9 @@ import ( ibcporttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" ibchost "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + "github.com/sei-protocol/sei-chain/x/mint" + mintkeeper "github.com/sei-protocol/sei-chain/x/mint/keeper" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" "github.com/spf13/cast" abci "github.com/tendermint/tendermint/abci/types" tmjson "github.com/tendermint/tendermint/libs/json" diff --git a/app/test_helpers.go b/app/test_helpers.go index d640743fc3..81f0e07e8e 100644 --- a/app/test_helpers.go +++ b/app/test_helpers.go @@ -10,10 +10,10 @@ import ( crptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/cosmos/cosmos-sdk/x/staking/teststaking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" diff --git a/proto/mint/v1beta1/genesis.proto b/proto/mint/v1beta1/genesis.proto index 4e783fb544..f8cbe96d99 100644 --- a/proto/mint/v1beta1/genesis.proto +++ b/proto/mint/v1beta1/genesis.proto @@ -1,10 +1,10 @@ syntax = "proto3"; -package cosmos.mint.v1beta1; +package seiprotocol.seichain.mint; import "gogoproto/gogo.proto"; -import "cosmos/mint/v1beta1/mint.proto"; +import "mint/v1beta1/mint.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; +option go_package = "github.com/sei-protocol/sei-chain/x/mint/types"; // GenesisState defines the mint module's genesis state. message GenesisState { diff --git a/proto/mint/v1beta1/mint.proto b/proto/mint/v1beta1/mint.proto index f94d4ae2e8..f2576624b2 100644 --- a/proto/mint/v1beta1/mint.proto +++ b/proto/mint/v1beta1/mint.proto @@ -1,7 +1,7 @@ syntax = "proto3"; -package cosmos.mint.v1beta1; +package seiprotocol.seichain.mint; -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; +option go_package = "github.com/sei-protocol/sei-chain/x/mint/types"; import "gogoproto/gogo.proto"; @@ -50,4 +50,15 @@ message Params { ]; // expected blocks per year uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; + // mint epoch identifier + string epoch_identifier = 7 [(gogoproto.moretags) = "yaml:\"epoch_identifier\""]; + // number of epochs to take to reduce rewards + int64 reduction_period_in_epochs = 8 [(gogoproto.moretags) = "yaml:\"reduction_period_in_epochs\""]; + // reduction multiplier to execute on each period + string reduction_factor = 9 [ + (gogoproto.moretags) = "yaml:\"reduction-factor\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + } diff --git a/proto/mint/v1beta1/query.proto b/proto/mint/v1beta1/query.proto index acd341d777..264add93b1 100644 --- a/proto/mint/v1beta1/query.proto +++ b/proto/mint/v1beta1/query.proto @@ -1,27 +1,27 @@ syntax = "proto3"; -package cosmos.mint.v1beta1; +package seiprotocol.seichain.mint; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; -import "cosmos/mint/v1beta1/mint.proto"; +import "mint/v1beta1/mint.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; +option go_package = "github.com/sei-protocol/sei-chain/x/mint/types"; // Query provides defines the gRPC querier service. service Query { // Params returns the total set of minting parameters. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + option (google.api.http).get = "/seichain/mint/v1beta1/params"; } // Inflation returns the current minting inflation value. rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + option (google.api.http).get = "/seichain/mint/v1beta1/inflation"; } // AnnualProvisions current minting annual provisions value. rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { - option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + option (google.api.http).get = "/seichain/mint/v1beta1/annual_provisions"; } } diff --git a/x/dex/keeper/end_block_place_orders_test.go b/x/dex/keeper/end_block_place_orders_test.go index a09dbcee4b..558a93b662 100644 --- a/x/dex/keeper/end_block_place_orders_test.go +++ b/x/dex/keeper/end_block_place_orders_test.go @@ -4,10 +4,10 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" dex "github.com/sei-protocol/sei-chain/x/dex/cache" "github.com/sei-protocol/sei-chain/x/dex/types" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) diff --git a/x/dex/module_test.go b/x/dex/module_test.go index 3de73ab45e..51709a2e08 100644 --- a/x/dex/module_test.go +++ b/x/dex/module_test.go @@ -8,10 +8,10 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" dexcache "github.com/sei-protocol/sei-chain/x/dex/cache" "github.com/sei-protocol/sei-chain/x/dex/types" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" diff --git a/x/mint/abci.go b/x/mint/abci.go index 410415d743..f67df44f19 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/keeper" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/keeper" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // BeginBlocker mints new tokens for the previous block. diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index 792fa8a679..3754d75862 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // GetQueryCmd returns the cli query commands for the minting module. diff --git a/x/mint/client/rest/grpc_query_test.go b/x/mint/client/rest/grpc_query_test.go index fdbb4ff759..9fa7676c50 100644 --- a/x/mint/client/rest/grpc_query_test.go +++ b/x/mint/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test @@ -14,7 +15,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/testutil/network" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" ) type IntegrationTestSuite struct { @@ -68,7 +69,7 @@ func (s *IntegrationTestSuite) TestQueryGRPC() { }{ { "gRPC request params", - fmt.Sprintf("%s/cosmos/mint/v1beta1/params", baseURL), + fmt.Sprintf("%s/seichain/mint/v1beta1/params", baseURL), map[string]string{}, &minttypes.QueryParamsResponse{}, &minttypes.QueryParamsResponse{ @@ -78,7 +79,7 @@ func (s *IntegrationTestSuite) TestQueryGRPC() { }, { "gRPC request inflation", - fmt.Sprintf("%s/cosmos/mint/v1beta1/inflation", baseURL), + fmt.Sprintf("%s/seichain/mint/v1beta1/inflation", baseURL), map[string]string{}, &minttypes.QueryInflationResponse{}, &minttypes.QueryInflationResponse{ @@ -87,7 +88,7 @@ func (s *IntegrationTestSuite) TestQueryGRPC() { }, { "gRPC request annual provisions", - fmt.Sprintf("%s/cosmos/mint/v1beta1/annual_provisions", baseURL), + fmt.Sprintf("%s/seichain/mint/v1beta1/annual_provisions", baseURL), map[string]string{ grpctypes.GRPCBlockHeightHeader: "1", }, diff --git a/x/mint/client/rest/query.go b/x/mint/client/rest/query.go index 1dccd194c1..58fa836b97 100644 --- a/x/mint/client/rest/query.go +++ b/x/mint/client/rest/query.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/types/rest" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) func registerQueryRoutes(clientCtx client.Context, r *mux.Router) { diff --git a/x/mint/client/testutil/suite.go b/x/mint/client/testutil/suite.go index 24e7426760..051cebf29a 100644 --- a/x/mint/client/testutil/suite.go +++ b/x/mint/client/testutil/suite.go @@ -11,8 +11,8 @@ import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/client/cli" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/client/cli" + minttypes "github.com/sei-protocol/sei-chain/x/mint/types" ) type IntegrationTestSuite struct { diff --git a/x/mint/genesis.go b/x/mint/genesis.go index be7ac61d50..e28f049579 100644 --- a/x/mint/genesis.go +++ b/x/mint/genesis.go @@ -2,8 +2,8 @@ package mint import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/keeper" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/keeper" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // InitGenesis new mint genesis diff --git a/x/mint/keeper/grpc_query.go b/x/mint/keeper/grpc_query.go index 6ad3bf309c..fb0e080a26 100644 --- a/x/mint/keeper/grpc_query.go +++ b/x/mint/keeper/grpc_query.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) var _ types.QueryServer = Keeper{} diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 11b6276694..7fe93fbbad 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) type MintTestSuite struct { diff --git a/x/mint/keeper/hooks.go b/x/mint/keeper/hooks.go new file mode 100644 index 0000000000..fc3056b9dc --- /dev/null +++ b/x/mint/keeper/hooks.go @@ -0,0 +1,16 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sei-protocol/sei-chain/x/epoch/types" +) + +func (k Keeper) BeforeEpochStart(ctx sdk.Context, epoch types.Epoch) { +} + +func (k Keeper) AfterEpochEnd(ctx sdk.Context, epoch types.Epoch) { + //minter := k.GetMinter(ctx) + //params := k.GetParams(ctx) + //if epoch.CurrentEpochStartTime >= params.Red + +} diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go index df321c33bd..ae1cd37dd1 100644 --- a/x/mint/keeper/integration_test.go +++ b/x/mint/keeper/integration_test.go @@ -5,7 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // returns context and an app with updated mint keeper diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index b010204e8a..58a0d33395 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // Keeper of the mint store diff --git a/x/mint/keeper/querier.go b/x/mint/keeper/querier.go index 294445614a..9d60291cda 100644 --- a/x/mint/keeper/querier.go +++ b/x/mint/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/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // NewQuerier returns a minting Querier handler. diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go index 2e987aa042..64a0c0916e 100644 --- a/x/mint/keeper/querier_test.go +++ b/x/mint/keeper/querier_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - keep "github.com/cosmos/cosmos-sdk/x/mint/keeper" - "github.com/cosmos/cosmos-sdk/x/mint/types" + keep "github.com/sei-protocol/sei-chain/x/mint/keeper" + "github.com/sei-protocol/sei-chain/x/mint/types" abci "github.com/tendermint/tendermint/abci/types" ) diff --git a/x/mint/legacy/v039/types.go b/x/mint/legacy/v039/types.go deleted file mode 100644 index 10b351b7fb..0000000000 --- a/x/mint/legacy/v039/types.go +++ /dev/null @@ -1,31 +0,0 @@ -package v039 - -import sdk "github.com/cosmos/cosmos-sdk/types" - -const ( - ModuleName = "mint" -) - -type ( - // Minter represents the minting state. - Minter struct { - Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate - AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions - } - - // mint parameters - Params struct { - MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint - InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate - InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate - InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate - GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms - BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year - } - - // GenesisState - minter state - GenesisState struct { - Minter Minter `json:"minter" yaml:"minter"` // minter object - Params Params `json:"params" yaml:"params"` // inflation params - } -) diff --git a/x/mint/legacy/v040/migrate.go b/x/mint/legacy/v040/migrate.go deleted file mode 100644 index b417c68289..0000000000 --- a/x/mint/legacy/v040/migrate.go +++ /dev/null @@ -1,27 +0,0 @@ -package v040 - -import ( - v039mint "github.com/cosmos/cosmos-sdk/x/mint/legacy/v039" - v040mint "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -// Migrate accepts exported v0.39 x/mint genesis state and -// migrates it to v0.40 x/mint genesis state. The migration includes: -// -// - Re-encode in v0.40 GenesisState. -func Migrate(mintGenState v039mint.GenesisState) *v040mint.GenesisState { - return &v040mint.GenesisState{ - Minter: v040mint.Minter{ - Inflation: mintGenState.Minter.Inflation, - AnnualProvisions: mintGenState.Minter.AnnualProvisions, - }, - Params: v040mint.Params{ - MintDenom: mintGenState.Params.MintDenom, - InflationRateChange: mintGenState.Params.InflationRateChange, - InflationMax: mintGenState.Params.InflationMax, - InflationMin: mintGenState.Params.InflationMin, - GoalBonded: mintGenState.Params.GoalBonded, - BlocksPerYear: mintGenState.Params.BlocksPerYear, - }, - } -} diff --git a/x/mint/legacy/v040/types.go b/x/mint/legacy/v040/types.go deleted file mode 100644 index d725b48c34..0000000000 --- a/x/mint/legacy/v040/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package v040 - -const ( - ModuleName = "mint" -) diff --git a/x/mint/module.go b/x/mint/module.go index f8d51f9cf5..4eb0fde8d4 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -17,11 +17,11 @@ 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/mint/client/cli" - "github.com/cosmos/cosmos-sdk/x/mint/client/rest" - "github.com/cosmos/cosmos-sdk/x/mint/keeper" - "github.com/cosmos/cosmos-sdk/x/mint/simulation" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/client/cli" + "github.com/sei-protocol/sei-chain/x/mint/client/rest" + "github.com/sei-protocol/sei-chain/x/mint/keeper" + "github.com/sei-protocol/sei-chain/x/mint/simulation" + "github.com/sei-protocol/sei-chain/x/mint/types" ) var ( diff --git a/x/mint/module_test.go b/x/mint/module_test.go index 3b2df369e6..85d84fd1f9 100644 --- a/x/mint/module_test.go +++ b/x/mint/module_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { diff --git a/x/mint/simulation/decoder.go b/x/mint/simulation/decoder.go index b9337fed00..a22a8cc807 100644 --- a/x/mint/simulation/decoder.go +++ b/x/mint/simulation/decoder.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 43a8cfbd42..bc296ac5df 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - "github.com/cosmos/cosmos-sdk/x/mint/simulation" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/simulation" + "github.com/sei-protocol/sei-chain/x/mint/types" ) func TestDecodeStore(t *testing.T) { diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index 77d5064416..5ab91784a6 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // Simulation parameter constants @@ -82,7 +82,7 @@ func RandomizedGenState(simState *module.SimulationState) { mintDenom := sdk.DefaultBondDenom blocksPerYear := uint64(60 * 60 * 8766 / 5) - params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear) + params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear, "week", sdk.NewDecWithPrec(5, 1), 156) mintGenesis := types.NewGenesisState(types.InitialMinter(inflation), params) diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index ac57da7acc..19b0485fc6 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -12,8 +12,8 @@ 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/mint/simulation" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/simulation" + "github.com/sei-protocol/sei-chain/x/mint/types" ) // TestRandomizedGenState tests the normal scenario of applying RandomizedGenState. diff --git a/x/mint/simulation/params.go b/x/mint/simulation/params.go index b75b0fc700..2423351306 100644 --- a/x/mint/simulation/params.go +++ b/x/mint/simulation/params.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/simulation" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" ) const ( diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go index 6bc0f624cf..cff093d527 100644 --- a/x/mint/simulation/params_test.go +++ b/x/mint/simulation/params_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/x/mint/simulation" + "github.com/sei-protocol/sei-chain/x/mint/simulation" ) func TestParamChangest(t *testing.T) { diff --git a/x/mint/spec/01_concepts.md b/x/mint/spec/01_concepts.md deleted file mode 100644 index e17e7845e8..0000000000 --- a/x/mint/spec/01_concepts.md +++ /dev/null @@ -1,28 +0,0 @@ - - -# Concepts - -## The Minting Mechanism - -The minting mechanism was designed to: - -- allow for a flexible inflation rate determined by market demand targeting a particular bonded-stake ratio -- effect a balance between market liquidity and staked supply - -In order to best determine the appropriate market rate for inflation rewards, a -moving change rate is used. The moving change rate mechanism ensures that if -the % bonded is either over or under the goal %-bonded, the inflation rate will -adjust to further incentivize or disincentivize being bonded, respectively. Setting the goal -%-bonded at less than 100% encourages the network to maintain some non-staked tokens -which should help provide some liquidity. - -It can be broken down in the following way: - -- If the inflation rate is below the goal %-bonded the inflation rate will - increase until a maximum value is reached -- If the goal % bonded (67% in Cosmos-Hub) is maintained, then the inflation - rate will stay constant -- If the inflation rate is above the goal %-bonded the inflation rate will - decrease until a minimum value is reached diff --git a/x/mint/spec/02_state.md b/x/mint/spec/02_state.md deleted file mode 100644 index 9e25ac1b34..0000000000 --- a/x/mint/spec/02_state.md +++ /dev/null @@ -1,21 +0,0 @@ - - -# State - -## Minter - -The minter is a space for holding current inflation information. - -- Minter: `0x00 -> ProtocolBuffer(minter)` - -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc7/proto/cosmos/mint/v1beta1/mint.proto#L8-L19 - -## Params - -Minting params are held in the global params store. - -- Params: `mint/params -> legacy_amino(params)` - -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc7/proto/cosmos/mint/v1beta1/mint.proto#L21-L53 diff --git a/x/mint/spec/03_begin_block.md b/x/mint/spec/03_begin_block.md deleted file mode 100644 index 2f23f0aeb1..0000000000 --- a/x/mint/spec/03_begin_block.md +++ /dev/null @@ -1,54 +0,0 @@ - - -# Begin-Block - -Minting parameters are recalculated and inflation -paid at the beginning of each block. - -## NextInflationRate - -The target annual inflation rate is recalculated each block. -The inflation is also subject to a rate change (positive or negative) -depending on the distance from the desired ratio (67%). The maximum rate change -possible is defined to be 13% per year, however the annual inflation is capped -as between 7% and 20%. - -``` -NextInflationRate(params Params, bondedRatio sdk.Dec) (inflation sdk.Dec) { - inflationRateChangePerYear = (1 - bondedRatio/params.GoalBonded) * params.InflationRateChange - inflationRateChange = inflationRateChangePerYear/blocksPerYr - - // increase the new annual inflation for this next cycle - inflation += inflationRateChange - if inflation > params.InflationMax { - inflation = params.InflationMax - } - if inflation < params.InflationMin { - inflation = params.InflationMin - } - - return inflation -} -``` - -## NextAnnualProvisions - -Calculate the annual provisions based on current total supply and inflation -rate. This parameter is calculated once per block. - -``` -NextAnnualProvisions(params Params, totalSupply sdk.Dec) (provisions sdk.Dec) { - return Inflation * totalSupply -``` - -## BlockProvision - -Calculate the provisions generated for each block based on current annual provisions. The provisions are then minted by the `mint` module's `ModuleMinterAccount` and then transferred to the `auth`'s `FeeCollector` `ModuleAccount`. - -``` -BlockProvision(params Params) sdk.Coin { - provisionAmt = AnnualProvisions/ params.BlocksPerYear - return sdk.NewCoin(params.MintDenom, provisionAmt.Truncate()) -``` diff --git a/x/mint/spec/04_params.md b/x/mint/spec/04_params.md deleted file mode 100644 index ed18e5557e..0000000000 --- a/x/mint/spec/04_params.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Parameters - -The minting module contains the following parameters: - -| Key | Type | Example | -|---------------------|-----------------|------------------------| -| MintDenom | string | "uatom" | -| InflationRateChange | string (dec) | "0.130000000000000000" | -| InflationMax | string (dec) | "0.200000000000000000" | -| InflationMin | string (dec) | "0.070000000000000000" | -| GoalBonded | string (dec) | "0.670000000000000000" | -| BlocksPerYear | string (uint64) | "6311520" | diff --git a/x/mint/spec/05_events.md b/x/mint/spec/05_events.md deleted file mode 100644 index f6130a3b99..0000000000 --- a/x/mint/spec/05_events.md +++ /dev/null @@ -1,16 +0,0 @@ - - -# Events - -The minting module emits the following events: - -## BeginBlocker - -| Type | Attribute Key | Attribute Value | -|------|-------------------|--------------------| -| mint | bonded_ratio | {bondedRatio} | -| mint | inflation | {inflation} | -| mint | annual_provisions | {annualProvisions} | -| mint | amount | {amount} | diff --git a/x/mint/spec/06_client.md b/x/mint/spec/06_client.md deleted file mode 100644 index e2c366d932..0000000000 --- a/x/mint/spec/06_client.md +++ /dev/null @@ -1,224 +0,0 @@ - - -# Client - -## CLI - -A user can query and interact with the `mint` module using the CLI. - -### Query - -The `query` commands allow users to query `mint` state. - -``` -simd query mint --help -``` - -#### annual-provisions - -The `annual-provisions` command allow users to query the current minting annual provisions value - -``` -simd query mint annual-provisions [flags] -``` - -Example: - -``` -simd query mint annual-provisions -``` - -Example Output: - -``` -22268504368893.612100895088410693 -``` - -#### inflation - -The `inflation` command allow users to query the current minting inflation value - -``` -simd query mint inflation [flags] -``` - -Example: - -``` -simd query mint inflation -``` - -Example Output: - -``` -0.199200302563256955 -``` - -#### params - -The `params` command allow users to query the current minting parameters - -``` -simd query mint params [flags] -``` - -Example: - -``` -blocks_per_year: "4360000" -goal_bonded: "0.670000000000000000" -inflation_max: "0.200000000000000000" -inflation_min: "0.070000000000000000" -inflation_rate_change: "0.130000000000000000" -mint_denom: stake -``` - -## gRPC - -A user can query the `mint` module using gRPC endpoints. - -### AnnualProvisions - -The `AnnualProvisions` endpoint allow users to query the current minting annual provisions value - -``` -/cosmos.mint.v1beta1.Query/AnnualProvisions -``` - -Example: - -``` -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/AnnualProvisions -``` - -Example Output: - -``` -{ - "annualProvisions": "1432452520532626265712995618" -} -``` - -### Inflation - -The `Inflation` endpoint allow users to query the current minting inflation value - -``` -/cosmos.mint.v1beta1.Query/Inflation -``` - -Example: - -``` -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Inflation -``` - -Example Output: - -``` -{ - "inflation": "130197115720711261" -} -``` - -### Params - -The `Params` endpoint allow users to query the current minting parameters - -``` -/cosmos.mint.v1beta1.Query/Params -``` - -Example: - -``` -grpcurl -plaintext localhost:9090 cosmos.mint.v1beta1.Query/Params -``` - -Example Output: - -``` -{ - "params": { - "mintDenom": "stake", - "inflationRateChange": "130000000000000000", - "inflationMax": "200000000000000000", - "inflationMin": "70000000000000000", - "goalBonded": "670000000000000000", - "blocksPerYear": "6311520" - } -} -``` - -## REST - -A user can query the `mint` module using REST endpoints. - -### annual-provisions - -``` -/cosmos/mint/v1beta1/annual_provisions -``` - -Example: - -``` -curl "localhost:1317/cosmos/mint/v1beta1/annual_provisions" -``` - -Example Output: - -``` -{ - "annualProvisions": "1432452520532626265712995618" -} -``` - -### inflation - -``` -/cosmos/mint/v1beta1/inflation -``` - -Example: - -``` -curl "localhost:1317/cosmos/mint/v1beta1/inflation" -``` - -Example Output: - -``` -{ - "inflation": "130197115720711261" -} -``` - -### params - -``` -/cosmos/mint/v1beta1/params -``` - -Example: - -``` -curl "localhost:1317/cosmos/mint/v1beta1/params" -``` - -Example Output: - -``` -{ - "params": { - "mintDenom": "stake", - "inflationRateChange": "130000000000000000", - "inflationMax": "200000000000000000", - "inflationMin": "70000000000000000", - "goalBonded": "670000000000000000", - "blocksPerYear": "6311520" - } -} -``` diff --git a/x/mint/spec/README.md b/x/mint/spec/README.md index dc60da9995..e64e19e847 100644 --- a/x/mint/spec/README.md +++ b/x/mint/spec/README.md @@ -1,22 +1,7 @@ - +# Mint +The `mint` module is pretty similar to the native mint module from +Cosmos SDK, except that it allows for specifying a time-based token +release schedule, similar to that of Osmosis. -# `mint` +This module uses time-based epochs supported by the `epoch` module. -## Contents - -1. **[Concept](01_concepts.md)** -2. **[State](02_state.md)** - - [Minter](02_state.md#minter) - - [Params](02_state.md#params) -3. **[Begin-Block](03_begin_block.md)** - - [NextInflationRate](03_begin_block.md#nextinflationrate) - - [NextAnnualProvisions](03_begin_block.md#nextannualprovisions) - - [BlockProvision](03_begin_block.md#blockprovision) -4. **[Parameters](04_params.md)** -5. **[Events](05_events.md)** - - [BeginBlocker](05_events.md#beginblocker) diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go index 1486c35f22..015f18cfef 100644 --- a/x/mint/types/genesis.pb.go +++ b/x/mint/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/mint/v1beta1/genesis.proto +// source: mint/v1beta1/genesis.proto package types @@ -35,7 +35,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_0e215eb1d09cd648, []int{0} + return fileDescriptor_1dfa75836a5d5f23, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,27 +79,28 @@ func (m *GenesisState) GetParams() Params { } func init() { - proto.RegisterType((*GenesisState)(nil), "cosmos.mint.v1beta1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "seiprotocol.seichain.mint.GenesisState") } -func init() { proto.RegisterFile("cosmos/mint/v1beta1/genesis.proto", fileDescriptor_0e215eb1d09cd648) } +func init() { proto.RegisterFile("mint/v1beta1/genesis.proto", fileDescriptor_1dfa75836a5d5f23) } -var fileDescriptor_0e215eb1d09cd648 = []byte{ - // 218 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, - 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, - 0x28, 0xd1, 0x03, 0x29, 0xd1, 0x83, 0x2a, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, - 0x83, 0x58, 0x10, 0xa5, 0x52, 0x72, 0xd8, 0x4c, 0x03, 0xeb, 0x03, 0xcb, 0x2b, 0xb5, 0x30, 0x72, - 0xf1, 0xb8, 0x43, 0x0c, 0x0f, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xb2, 0xe4, 0x62, 0x03, 0x49, 0xa7, - 0x16, 0x49, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x1b, 0x49, 0xeb, 0x61, 0xb1, 0x4c, 0xcf, 0x17, 0xac, - 0xc4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x06, 0x90, 0xd6, 0x82, 0xc4, 0xa2, 0xc4, - 0xdc, 0x62, 0x09, 0x26, 0x3c, 0x5a, 0x03, 0xc0, 0x4a, 0x60, 0x5a, 0x21, 0x1a, 0x9c, 0x9c, 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, 0x33, 0x3d, 0xb3, 0x24, 0xa3, 0x34, - 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0xea, 0x17, 0x08, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x01, - 0xf1, 0x58, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x4b, 0xc6, 0x80, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xbb, 0xc1, 0x11, 0x51, 0x42, 0x01, 0x00, 0x00, +var fileDescriptor_1dfa75836a5d5f23 = []byte{ + // 225 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xca, 0xcd, 0xcc, 0x2b, + 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, + 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x2c, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, + 0xf4, 0x8a, 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x40, 0x1a, 0xa4, 0x44, 0xd2, 0xf3, + 0xd3, 0xf3, 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x83, 0x94, 0x38, 0x8a, 0x61, 0x20, 0x0e, 0x44, + 0x42, 0x69, 0x02, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0xec, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x7b, + 0x2e, 0x36, 0x90, 0x74, 0x6a, 0x91, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xa2, 0x1e, 0x4e, + 0xbb, 0xf4, 0x7c, 0xc1, 0x0a, 0x9d, 0x58, 0x4e, 0xdc, 0x93, 0x67, 0x08, 0x82, 0x6a, 0x03, 0x19, + 0x50, 0x90, 0x58, 0x94, 0x98, 0x5b, 0x2c, 0xc1, 0x44, 0xd0, 0x80, 0x00, 0xb0, 0x42, 0x98, 0x01, + 0x10, 0x6d, 0x4e, 0x1e, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, + 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0xa5, 0x97, + 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x5f, 0x9c, 0x9a, 0xa9, 0x0b, 0x33, + 0x15, 0xcc, 0x01, 0x1b, 0xab, 0x5f, 0x01, 0xf6, 0x9c, 0x7e, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0x58, 0x81, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xef, 0x52, 0xff, 0xbf, 0x4b, 0x01, 0x00, + 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 4ed1cccd69..6a9a274321 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/mint/v1beta1/mint.proto +// source: mint/v1beta1/mint.proto package types @@ -36,7 +36,7 @@ func (m *Minter) Reset() { *m = Minter{} } func (m *Minter) String() string { return proto.CompactTextString(m) } func (*Minter) ProtoMessage() {} func (*Minter) Descriptor() ([]byte, []int) { - return fileDescriptor_2df116d183c1e223, []int{0} + return fileDescriptor_06339c129491fd39, []int{0} } func (m *Minter) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,12 +79,18 @@ type Params struct { GoalBonded github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"goal_bonded" yaml:"goal_bonded"` // expected blocks per year BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` + // mint epoch identifier + EpochIdentifier string `protobuf:"bytes,7,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty" yaml:"epoch_identifier"` + // number of epochs to take to reduce rewards + ReductionPeriodInEpochs int64 `protobuf:"varint,8,opt,name=reduction_period_in_epochs,json=reductionPeriodInEpochs,proto3" json:"reduction_period_in_epochs,omitempty" yaml:"reduction_period_in_epochs"` + // reduction multiplier to execute on each period + ReductionFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=reduction_factor,json=reductionFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reduction_factor" yaml:"reduction-factor"` } func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_2df116d183c1e223, []int{1} + return fileDescriptor_06339c129491fd39, []int{1} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -127,43 +133,64 @@ func (m *Params) GetBlocksPerYear() uint64 { return 0 } +func (m *Params) GetEpochIdentifier() string { + if m != nil { + return m.EpochIdentifier + } + return "" +} + +func (m *Params) GetReductionPeriodInEpochs() int64 { + if m != nil { + return m.ReductionPeriodInEpochs + } + return 0 +} + func init() { - proto.RegisterType((*Minter)(nil), "cosmos.mint.v1beta1.Minter") - proto.RegisterType((*Params)(nil), "cosmos.mint.v1beta1.Params") + proto.RegisterType((*Minter)(nil), "seiprotocol.seichain.mint.Minter") + proto.RegisterType((*Params)(nil), "seiprotocol.seichain.mint.Params") } -func init() { proto.RegisterFile("cosmos/mint/v1beta1/mint.proto", fileDescriptor_2df116d183c1e223) } +func init() { proto.RegisterFile("mint/v1beta1/mint.proto", fileDescriptor_06339c129491fd39) } -var fileDescriptor_2df116d183c1e223 = []byte{ - // 437 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xc1, 0x6e, 0xd3, 0x30, - 0x1c, 0xc6, 0x63, 0x28, 0x95, 0x6a, 0x98, 0x00, 0x6f, 0xa0, 0x68, 0x82, 0x64, 0xca, 0x01, 0x8d, - 0x03, 0x89, 0x26, 0x6e, 0x3b, 0x66, 0x15, 0x07, 0xc4, 0x50, 0xe5, 0x1b, 0x5c, 0xa2, 0x7f, 0x52, - 0x93, 0x59, 0x8d, 0xed, 0xca, 0xf6, 0x46, 0x7b, 0xe5, 0x09, 0x38, 0x72, 0xe4, 0x2d, 0x78, 0x85, - 0xdd, 0xd8, 0x11, 0x71, 0xa8, 0x50, 0xfb, 0x06, 0x7b, 0x02, 0x14, 0xbb, 0x6a, 0xa1, 0x20, 0xa4, - 0x4a, 0x9c, 0x92, 0xef, 0xfb, 0xff, 0xf3, 0xfd, 0xbe, 0x58, 0x32, 0x8e, 0x2a, 0x65, 0x84, 0x32, - 0x99, 0xe0, 0xd2, 0x66, 0x17, 0x47, 0x25, 0xb3, 0x70, 0xe4, 0x44, 0x3a, 0xd6, 0xca, 0x2a, 0xb2, - 0xeb, 0xe7, 0xa9, 0xb3, 0x96, 0xf3, 0xfd, 0xbd, 0x5a, 0xd5, 0xca, 0xcd, 0xb3, 0xf6, 0xcd, 0xaf, - 0x26, 0x5f, 0x11, 0xee, 0x9e, 0x72, 0x69, 0x99, 0x26, 0xaf, 0x70, 0x8f, 0xcb, 0x77, 0x0d, 0x58, - 0xae, 0x64, 0x88, 0x0e, 0xd0, 0x61, 0x2f, 0x4f, 0x2f, 0x67, 0x71, 0xf0, 0x7d, 0x16, 0x3f, 0xa9, - 0xb9, 0x3d, 0x3b, 0x2f, 0xd3, 0x4a, 0x89, 0x6c, 0xc9, 0xf6, 0x8f, 0x67, 0x66, 0x38, 0xca, 0xec, - 0x74, 0xcc, 0x4c, 0xda, 0x67, 0x15, 0x5d, 0x07, 0x90, 0xf7, 0xf8, 0x3e, 0x48, 0x79, 0x0e, 0x4d, - 0x31, 0xd6, 0xea, 0x82, 0x1b, 0xae, 0xa4, 0x09, 0x6f, 0xb8, 0xd4, 0x97, 0xdb, 0xa5, 0x5e, 0xcf, - 0xe2, 0x70, 0x0a, 0xa2, 0x39, 0x4e, 0xfe, 0x08, 0x4c, 0xe8, 0x3d, 0xef, 0x0d, 0xd6, 0xd6, 0x97, - 0x0e, 0xee, 0x0e, 0x40, 0x83, 0x30, 0xe4, 0x31, 0xc6, 0xed, 0x11, 0x14, 0x43, 0x26, 0x95, 0xf0, - 0xbf, 0x44, 0x7b, 0xad, 0xd3, 0x6f, 0x0d, 0xf2, 0x01, 0xe1, 0x07, 0xab, 0xc2, 0x85, 0x06, 0xcb, - 0x8a, 0xea, 0x0c, 0x64, 0xcd, 0x96, 0x3d, 0x5f, 0x6f, 0xdd, 0xf3, 0x91, 0xef, 0xf9, 0xd7, 0xd0, - 0x84, 0xee, 0xae, 0x7c, 0x0a, 0x96, 0x9d, 0x38, 0x97, 0x8c, 0xf0, 0xce, 0x7a, 0x5d, 0xc0, 0x24, - 0xbc, 0xe9, 0xd8, 0x2f, 0xb6, 0x66, 0xef, 0x6d, 0xb2, 0x05, 0x4c, 0x12, 0x7a, 0x67, 0xa5, 0x4f, - 0x61, 0xb2, 0x01, 0xe3, 0x32, 0xec, 0xfc, 0x37, 0x18, 0x97, 0xbf, 0xc1, 0xb8, 0x24, 0x0c, 0xdf, - 0xae, 0x15, 0x34, 0x45, 0xa9, 0xe4, 0x90, 0x0d, 0xc3, 0x5b, 0x0e, 0xd5, 0xdf, 0x1a, 0x45, 0x3c, - 0xea, 0x97, 0xa8, 0x84, 0xe2, 0x56, 0xe5, 0x4e, 0x90, 0x1c, 0xdf, 0x2d, 0x1b, 0x55, 0x8d, 0x4c, - 0x31, 0x66, 0xba, 0x98, 0x32, 0xd0, 0x61, 0xf7, 0x00, 0x1d, 0x76, 0xf2, 0xfd, 0xeb, 0x59, 0xfc, - 0xd0, 0x7f, 0xbc, 0xb1, 0x90, 0xd0, 0x1d, 0xef, 0x0c, 0x98, 0x7e, 0xc3, 0x40, 0x1f, 0x77, 0x3e, - 0x7d, 0x8e, 0x83, 0xfc, 0xe4, 0x72, 0x1e, 0xa1, 0xab, 0x79, 0x84, 0x7e, 0xcc, 0x23, 0xf4, 0x71, - 0x11, 0x05, 0x57, 0x8b, 0x28, 0xf8, 0xb6, 0x88, 0x82, 0xb7, 0x4f, 0xff, 0xd9, 0x76, 0xe2, 0x2f, - 0xa2, 0x2b, 0x5d, 0x76, 0xdd, 0xbd, 0x7a, 0xfe, 0x33, 0x00, 0x00, 0xff, 0xff, 0x34, 0x52, 0xcf, - 0x87, 0xa4, 0x03, 0x00, 0x00, +var fileDescriptor_06339c129491fd39 = []byte{ + // 557 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xc1, 0x8e, 0xd3, 0x3a, + 0x14, 0x6d, 0xde, 0xf4, 0x15, 0x6a, 0x18, 0xb5, 0x98, 0x81, 0x86, 0x02, 0x49, 0x89, 0x04, 0xea, + 0xa6, 0x89, 0x46, 0xec, 0x66, 0x19, 0x4a, 0x45, 0x11, 0x83, 0xaa, 0xec, 0x60, 0x13, 0x39, 0x89, + 0xdb, 0x5a, 0x4d, 0xec, 0xc8, 0x76, 0x87, 0x76, 0xcb, 0x17, 0xb0, 0x64, 0xc9, 0xe7, 0xcc, 0x8e, + 0x59, 0x02, 0x8b, 0x08, 0xb5, 0x7f, 0xd0, 0x2f, 0x40, 0x71, 0x86, 0x74, 0x28, 0xb0, 0xa8, 0xc4, + 0xca, 0xbe, 0xe7, 0x9e, 0x7b, 0xce, 0xb1, 0x17, 0x17, 0xb4, 0x12, 0x42, 0xa5, 0x73, 0x76, 0x1c, + 0x60, 0x89, 0x8e, 0x9d, 0xbc, 0xb0, 0x53, 0xce, 0x24, 0x83, 0xf7, 0x04, 0x26, 0xea, 0x16, 0xb2, + 0xd8, 0x16, 0x98, 0x84, 0x53, 0x44, 0xa8, 0x9d, 0x13, 0xda, 0x47, 0x13, 0x36, 0x61, 0xaa, 0xe7, + 0xe4, 0xb7, 0x62, 0xc0, 0xfa, 0xac, 0x81, 0xda, 0x29, 0xa1, 0x12, 0x73, 0xf8, 0x0a, 0xd4, 0x09, + 0x1d, 0xc7, 0x48, 0x12, 0x46, 0x75, 0xad, 0xa3, 0x75, 0xeb, 0xae, 0x7d, 0x9e, 0x99, 0x95, 0x6f, + 0x99, 0xf9, 0x64, 0x42, 0xe4, 0x74, 0x1e, 0xd8, 0x21, 0x4b, 0x9c, 0x90, 0x89, 0x84, 0x89, 0xcb, + 0xa3, 0x27, 0xa2, 0x99, 0x23, 0x97, 0x29, 0x16, 0x76, 0x1f, 0x87, 0xde, 0x56, 0x00, 0xbe, 0x03, + 0xb7, 0x10, 0xa5, 0x73, 0x14, 0xfb, 0x29, 0x67, 0x67, 0x44, 0x10, 0x46, 0x85, 0xfe, 0x9f, 0x52, + 0x7d, 0xb9, 0x9f, 0xea, 0x26, 0x33, 0xf5, 0x25, 0x4a, 0xe2, 0x13, 0xeb, 0x37, 0x41, 0xcb, 0x6b, + 0x16, 0xd8, 0x68, 0x0b, 0x7d, 0xad, 0x81, 0xda, 0x08, 0x71, 0x94, 0x08, 0xf8, 0x10, 0x80, 0xfc, + 0xe9, 0x7e, 0x84, 0x29, 0x4b, 0x8a, 0x27, 0x79, 0xf5, 0x1c, 0xe9, 0xe7, 0x00, 0x7c, 0xaf, 0x81, + 0x3b, 0x65, 0x60, 0x9f, 0x23, 0x89, 0xfd, 0x70, 0x8a, 0xe8, 0x04, 0x5f, 0xe6, 0x7c, 0xbd, 0x77, + 0xce, 0x07, 0x45, 0xce, 0x3f, 0x8a, 0x5a, 0xde, 0xed, 0x12, 0xf7, 0x90, 0xc4, 0xcf, 0x14, 0x0a, + 0x67, 0xe0, 0x70, 0x4b, 0x4f, 0xd0, 0x42, 0x3f, 0x50, 0xde, 0x83, 0xbd, 0xbd, 0x8f, 0x76, 0xbd, + 0x13, 0xb4, 0xb0, 0xbc, 0x9b, 0x65, 0x7d, 0x8a, 0x16, 0x3b, 0x66, 0x84, 0xea, 0xd5, 0x7f, 0x66, + 0x46, 0xe8, 0x2f, 0x66, 0x84, 0x42, 0x0c, 0x6e, 0x4c, 0x18, 0x8a, 0xfd, 0x80, 0xd1, 0x08, 0x47, + 0xfa, 0xff, 0xca, 0xaa, 0xbf, 0xb7, 0x15, 0x2c, 0xac, 0xae, 0x48, 0x59, 0x1e, 0xc8, 0x2b, 0x57, + 0x15, 0xd0, 0x05, 0x8d, 0x20, 0x66, 0xe1, 0x4c, 0xf8, 0x29, 0xe6, 0xfe, 0x12, 0x23, 0xae, 0xd7, + 0x3a, 0x5a, 0xb7, 0xea, 0xb6, 0x37, 0x99, 0x79, 0xb7, 0x18, 0xde, 0x21, 0x58, 0xde, 0x61, 0x81, + 0x8c, 0x30, 0x7f, 0x83, 0x11, 0x87, 0x03, 0xd0, 0xc4, 0x29, 0x0b, 0xa7, 0x3e, 0x89, 0x30, 0x95, + 0x64, 0x4c, 0x30, 0xd7, 0xaf, 0xa9, 0xbc, 0xf7, 0x37, 0x99, 0xd9, 0x2a, 0x44, 0x76, 0x19, 0x96, + 0xd7, 0x50, 0xd0, 0xb0, 0x44, 0x60, 0x00, 0xda, 0x1c, 0x47, 0xf3, 0x50, 0x7d, 0x49, 0x8a, 0x39, + 0x61, 0x91, 0x4f, 0xa8, 0xaf, 0x68, 0x42, 0xbf, 0xde, 0xd1, 0xba, 0x07, 0xee, 0xe3, 0x4d, 0x66, + 0x3e, 0x2a, 0x14, 0xff, 0xce, 0xb5, 0xbc, 0x56, 0xd9, 0x1c, 0xa9, 0xde, 0x90, 0x3e, 0x57, 0x1d, + 0x28, 0x41, 0x73, 0x3b, 0x37, 0x46, 0xa1, 0x64, 0x5c, 0xaf, 0xab, 0xac, 0xc3, 0xbd, 0xff, 0xb6, + 0xb5, 0x93, 0xa3, 0x57, 0xe8, 0x59, 0x5e, 0xa3, 0x84, 0x06, 0x0a, 0x39, 0xa9, 0x7e, 0xfc, 0x64, + 0x56, 0xdc, 0x17, 0xe7, 0x2b, 0x43, 0xbb, 0x58, 0x19, 0xda, 0xf7, 0x95, 0xa1, 0x7d, 0x58, 0x1b, + 0x95, 0x8b, 0xb5, 0x51, 0xf9, 0xb2, 0x36, 0x2a, 0x6f, 0xed, 0x2b, 0x9e, 0x02, 0x93, 0xde, 0xcf, + 0x25, 0xa4, 0x0a, 0xb5, 0x85, 0x9c, 0x85, 0x5a, 0x54, 0x85, 0x7f, 0x50, 0x53, 0x84, 0xa7, 0x3f, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x93, 0xd5, 0x84, 0x2c, 0xca, 0x04, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { @@ -229,6 +256,28 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.ReductionFactor.Size() + i -= size + if _, err := m.ReductionFactor.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintMint(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + if m.ReductionPeriodInEpochs != 0 { + i = encodeVarintMint(dAtA, i, uint64(m.ReductionPeriodInEpochs)) + i-- + dAtA[i] = 0x40 + } + if len(m.EpochIdentifier) > 0 { + i -= len(m.EpochIdentifier) + copy(dAtA[i:], m.EpochIdentifier) + i = encodeVarintMint(dAtA, i, uint64(len(m.EpochIdentifier))) + i-- + dAtA[i] = 0x3a + } if m.BlocksPerYear != 0 { i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) i-- @@ -329,6 +378,15 @@ func (m *Params) Size() (n int) { if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) } + l = len(m.EpochIdentifier) + if l > 0 { + n += 1 + l + sovMint(uint64(l)) + } + if m.ReductionPeriodInEpochs != 0 { + n += 1 + sovMint(uint64(m.ReductionPeriodInEpochs)) + } + l = m.ReductionFactor.Size() + n += 1 + l + sovMint(uint64(l)) return n } @@ -672,6 +730,91 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EpochIdentifier", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EpochIdentifier = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReductionPeriodInEpochs", wireType) + } + m.ReductionPeriodInEpochs = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReductionPeriodInEpochs |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReductionFactor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMint + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMint + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMint + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ReductionFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMint(dAtA[iNdEx:]) diff --git a/x/mint/types/params.go b/x/mint/types/params.go index f0f9ef494b..1d98889c22 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -13,12 +13,15 @@ import ( // Parameter store keys var ( - KeyMintDenom = []byte("MintDenom") - KeyInflationRateChange = []byte("InflationRateChange") - KeyInflationMax = []byte("InflationMax") - KeyInflationMin = []byte("InflationMin") - KeyGoalBonded = []byte("GoalBonded") - KeyBlocksPerYear = []byte("BlocksPerYear") + KeyMintDenom = []byte("MintDenom") + KeyInflationRateChange = []byte("InflationRateChange") + KeyInflationMax = []byte("InflationMax") + KeyInflationMin = []byte("InflationMin") + KeyGoalBonded = []byte("GoalBonded") + KeyBlocksPerYear = []byte("BlocksPerYear") + KeyEpochIdentifier = []byte("EpochIdentifier") + KeyReductionPeriodInEpochs = []byte("ReductionPeriodInEpochs") + KeyReductionFactor = []byte("ReductionFactor") ) // ParamTable for minting module. @@ -28,27 +31,34 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams( mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, + epochIdentifier string, reductionFactor sdk.Dec, reductionPeriodInEpochs int64, ) Params { return Params{ - MintDenom: mintDenom, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, + MintDenom: mintDenom, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, + EpochIdentifier: epochIdentifier, + ReductionPeriodInEpochs: reductionPeriodInEpochs, + ReductionFactor: reductionFactor, } } // default minting module parameters func DefaultParams() Params { return Params{ - MintDenom: sdk.DefaultBondDenom, - InflationRateChange: sdk.NewDecWithPrec(13, 2), - InflationMax: sdk.NewDecWithPrec(20, 2), - InflationMin: sdk.NewDecWithPrec(7, 2), - GoalBonded: sdk.NewDecWithPrec(67, 2), - BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times + MintDenom: sdk.DefaultBondDenom, + InflationRateChange: sdk.NewDecWithPrec(13, 2), + InflationMax: sdk.NewDecWithPrec(20, 2), + InflationMin: sdk.NewDecWithPrec(7, 2), + GoalBonded: sdk.NewDecWithPrec(67, 2), + BlocksPerYear: uint64(60 * 60 * 8766), // assuming 1 second block times + EpochIdentifier: "week", // 1 week + ReductionPeriodInEpochs: 156, // 3 years + ReductionFactor: sdk.NewDecWithPrec(5, 1), // 0.5 } } diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go index f707eb810d..24d635a15b 100644 --- a/x/mint/types/query.pb.go +++ b/x/mint/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/mint/v1beta1/query.proto +// source: mint/v1beta1/query.proto package types @@ -38,7 +38,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_d0a1e393be338aea, []int{0} + return fileDescriptor_b0718dda172d2cb4, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +77,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_d0a1e393be338aea, []int{1} + return fileDescriptor_b0718dda172d2cb4, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -121,7 +121,7 @@ func (m *QueryInflationRequest) Reset() { *m = QueryInflationRequest{} } func (m *QueryInflationRequest) String() string { return proto.CompactTextString(m) } func (*QueryInflationRequest) ProtoMessage() {} func (*QueryInflationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d0a1e393be338aea, []int{2} + return fileDescriptor_b0718dda172d2cb4, []int{2} } func (m *QueryInflationRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -161,7 +161,7 @@ func (m *QueryInflationResponse) Reset() { *m = QueryInflationResponse{} func (m *QueryInflationResponse) String() string { return proto.CompactTextString(m) } func (*QueryInflationResponse) ProtoMessage() {} func (*QueryInflationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0a1e393be338aea, []int{3} + return fileDescriptor_b0718dda172d2cb4, []int{3} } func (m *QueryInflationResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -199,7 +199,7 @@ func (m *QueryAnnualProvisionsRequest) Reset() { *m = QueryAnnualProvisi func (m *QueryAnnualProvisionsRequest) String() string { return proto.CompactTextString(m) } func (*QueryAnnualProvisionsRequest) ProtoMessage() {} func (*QueryAnnualProvisionsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d0a1e393be338aea, []int{4} + return fileDescriptor_b0718dda172d2cb4, []int{4} } func (m *QueryAnnualProvisionsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,7 +239,7 @@ func (m *QueryAnnualProvisionsResponse) Reset() { *m = QueryAnnualProvis func (m *QueryAnnualProvisionsResponse) String() string { return proto.CompactTextString(m) } func (*QueryAnnualProvisionsResponse) ProtoMessage() {} func (*QueryAnnualProvisionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d0a1e393be338aea, []int{5} + return fileDescriptor_b0718dda172d2cb4, []int{5} } func (m *QueryAnnualProvisionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -269,46 +269,48 @@ func (m *QueryAnnualProvisionsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAnnualProvisionsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "cosmos.mint.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "cosmos.mint.v1beta1.QueryParamsResponse") - proto.RegisterType((*QueryInflationRequest)(nil), "cosmos.mint.v1beta1.QueryInflationRequest") - proto.RegisterType((*QueryInflationResponse)(nil), "cosmos.mint.v1beta1.QueryInflationResponse") - proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "cosmos.mint.v1beta1.QueryAnnualProvisionsRequest") - proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "cosmos.mint.v1beta1.QueryAnnualProvisionsResponse") -} - -func init() { proto.RegisterFile("cosmos/mint/v1beta1/query.proto", fileDescriptor_d0a1e393be338aea) } - -var fileDescriptor_d0a1e393be338aea = []byte{ - // 446 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, - 0xcd, 0x2f, 0xd6, 0xcf, 0xcd, 0xcc, 0x2b, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, - 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, - 0x03, 0x29, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, - 0x10, 0xa5, 0x52, 0x32, 0xe9, 0xf9, 0xf9, 0xe9, 0x39, 0xa9, 0xfa, 0x89, 0x05, 0x99, 0xfa, 0x89, - 0x79, 0x79, 0xf9, 0x25, 0x89, 0x25, 0x99, 0xf9, 0x79, 0xc5, 0x50, 0x59, 0x39, 0x6c, 0x36, 0x81, - 0x4d, 0x05, 0xcb, 0x2b, 0x89, 0x70, 0x09, 0x05, 0x82, 0xec, 0x0d, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, - 0x0e, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x51, 0x0a, 0xe0, 0x12, 0x46, 0x11, 0x2d, 0x2e, 0xc8, - 0xcf, 0x2b, 0x4e, 0x15, 0xb2, 0xe4, 0x62, 0x2b, 0x00, 0x8b, 0x48, 0x30, 0x2a, 0x30, 0x6a, 0x70, - 0x1b, 0x49, 0xeb, 0x61, 0x71, 0xa6, 0x1e, 0x44, 0x93, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, - 0x50, 0x0d, 0x4a, 0xe2, 0x5c, 0xa2, 0x60, 0x13, 0x3d, 0xf3, 0xd2, 0x72, 0xc0, 0x0e, 0x84, 0x59, - 0x95, 0xc6, 0x25, 0x86, 0x2e, 0x01, 0xb5, 0xcd, 0x87, 0x8b, 0x33, 0x13, 0x26, 0x08, 0xb6, 0x90, - 0xc7, 0x49, 0x0f, 0x64, 0xe6, 0xad, 0x7b, 0xf2, 0x6a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, - 0xc9, 0xf9, 0xb9, 0xfa, 0x50, 0x0f, 0x42, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, - 0xd4, 0x62, 0x3d, 0x97, 0xd4, 0xe4, 0x20, 0x84, 0x01, 0x4a, 0x72, 0x5c, 0x32, 0x60, 0x7b, 0x1c, - 0xf3, 0xf2, 0x4a, 0x13, 0x73, 0x02, 0x8a, 0xf2, 0xcb, 0x32, 0x8b, 0x41, 0xe1, 0x04, 0x73, 0x47, - 0x0d, 0x97, 0x2c, 0x0e, 0x79, 0xa8, 0x73, 0xa2, 0xb9, 0x04, 0x13, 0xc1, 0x72, 0xf1, 0x05, 0x70, - 0x49, 0x32, 0x9d, 0x25, 0x90, 0x88, 0x66, 0x89, 0xd1, 0x51, 0x66, 0x2e, 0x56, 0xb0, 0xf5, 0x42, - 0x0d, 0x8c, 0x5c, 0x6c, 0x90, 0x10, 0x14, 0x52, 0xc7, 0x1a, 0xbc, 0x98, 0xd1, 0x25, 0xa5, 0x41, - 0x58, 0x21, 0xc4, 0x13, 0x4a, 0xca, 0x4d, 0x97, 0x9f, 0x4c, 0x66, 0x92, 0x15, 0x92, 0xd6, 0xc7, - 0x96, 0x2e, 0x20, 0x71, 0x25, 0xd4, 0xc3, 0xc8, 0xc5, 0x09, 0x8f, 0x0e, 0x21, 0x2d, 0xdc, 0x86, - 0xa3, 0x47, 0xa6, 0x94, 0x36, 0x51, 0x6a, 0xa1, 0x6e, 0x51, 0x03, 0xbb, 0x45, 0x41, 0x48, 0x0e, - 0xab, 0x5b, 0xe0, 0x31, 0x27, 0xb4, 0x92, 0x91, 0x4b, 0x00, 0x3d, 0x56, 0x84, 0x0c, 0x71, 0xdb, - 0x84, 0x23, 0x86, 0xa5, 0x8c, 0x48, 0xd1, 0x02, 0x75, 0xa3, 0x1e, 0xd8, 0x8d, 0x1a, 0x42, 0x6a, - 0x58, 0xdd, 0x88, 0x91, 0x1e, 0x9c, 0x9c, 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, 0x13, 0x6f, 0xda, 0xa8, 0x80, 0x18, 0x0c, 0x4e, 0x22, 0x49, 0x6c, 0xe0, 0xac, 0x69, - 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xc7, 0xed, 0x9c, 0x7b, 0x26, 0x04, 0x00, 0x00, + proto.RegisterType((*QueryParamsRequest)(nil), "seiprotocol.seichain.mint.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "seiprotocol.seichain.mint.QueryParamsResponse") + proto.RegisterType((*QueryInflationRequest)(nil), "seiprotocol.seichain.mint.QueryInflationRequest") + proto.RegisterType((*QueryInflationResponse)(nil), "seiprotocol.seichain.mint.QueryInflationResponse") + proto.RegisterType((*QueryAnnualProvisionsRequest)(nil), "seiprotocol.seichain.mint.QueryAnnualProvisionsRequest") + proto.RegisterType((*QueryAnnualProvisionsResponse)(nil), "seiprotocol.seichain.mint.QueryAnnualProvisionsResponse") +} + +func init() { proto.RegisterFile("mint/v1beta1/query.proto", fileDescriptor_b0718dda172d2cb4) } + +var fileDescriptor_b0718dda172d2cb4 = []byte{ + // 467 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc8, 0xcd, 0xcc, 0x2b, + 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, + 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x2c, 0x4e, 0xcd, 0x04, 0xb3, 0x92, 0xf3, 0x73, 0xf4, 0x8a, + 0x53, 0x33, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xf4, 0x40, 0xca, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, + 0xc1, 0x72, 0xfa, 0x20, 0x16, 0x44, 0x83, 0x94, 0x4c, 0x7a, 0x7e, 0x7e, 0x7a, 0x4e, 0xaa, 0x7e, + 0x62, 0x41, 0xa6, 0x7e, 0x62, 0x5e, 0x5e, 0x7e, 0x49, 0x62, 0x49, 0x66, 0x7e, 0x5e, 0x31, 0x54, + 0x56, 0x1c, 0xc5, 0x22, 0x10, 0x07, 0x22, 0xa1, 0x24, 0xc2, 0x25, 0x14, 0x08, 0xb2, 0x36, 0x20, + 0xb1, 0x28, 0x31, 0xb7, 0x38, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x44, 0x29, 0x8c, 0x4b, 0x18, + 0x45, 0xb4, 0xb8, 0x20, 0x3f, 0xaf, 0x38, 0x55, 0xc8, 0x9e, 0x8b, 0xad, 0x00, 0x2c, 0x22, 0xc1, + 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0xa4, 0xa8, 0x87, 0xd3, 0x95, 0x7a, 0x10, 0xad, 0x4e, 0x2c, 0x27, + 0xee, 0xc9, 0x33, 0x04, 0x41, 0xb5, 0x29, 0x89, 0x73, 0x89, 0x82, 0xcd, 0xf5, 0xcc, 0x4b, 0xcb, + 0x01, 0xbb, 0x0f, 0x66, 0x61, 0x1a, 0x97, 0x18, 0xba, 0x04, 0xd4, 0x4e, 0x1f, 0x2e, 0xce, 0x4c, + 0x98, 0x20, 0xd8, 0x5a, 0x1e, 0x27, 0x3d, 0x90, 0x99, 0xb7, 0xee, 0xc9, 0xab, 0xa5, 0x67, 0x96, + 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0x43, 0x29, + 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0x3d, 0x97, 0xd4, 0xe4, 0x20, 0x84, + 0x01, 0x4a, 0x72, 0x5c, 0x32, 0x60, 0x7b, 0x1c, 0xf3, 0xf2, 0x4a, 0x13, 0x73, 0x02, 0x8a, 0xf2, + 0xcb, 0x32, 0x8b, 0x41, 0xc1, 0x04, 0x73, 0x47, 0x0d, 0x97, 0x2c, 0x0e, 0x79, 0xa8, 0x73, 0xa2, + 0xb9, 0x04, 0x13, 0xc1, 0x72, 0xf1, 0x05, 0x70, 0x49, 0x32, 0x9d, 0x25, 0x90, 0x88, 0x66, 0x89, + 0xd1, 0x7b, 0x66, 0x2e, 0x56, 0xb0, 0xf5, 0x42, 0x7d, 0x8c, 0x5c, 0x6c, 0x90, 0x10, 0x14, 0xd2, + 0xc5, 0x13, 0xc8, 0x98, 0x51, 0x27, 0xa5, 0x47, 0xac, 0x72, 0x88, 0x87, 0x94, 0x54, 0x9b, 0x2e, + 0x3f, 0x99, 0xcc, 0x24, 0x2f, 0x24, 0xab, 0x0f, 0x53, 0xab, 0x8f, 0x92, 0x56, 0x20, 0x31, 0x27, + 0x34, 0x8b, 0x91, 0x8b, 0x13, 0x1e, 0x39, 0x42, 0x06, 0x84, 0x2c, 0x41, 0x8f, 0x60, 0x29, 0x43, + 0x12, 0x74, 0x40, 0x5d, 0xa6, 0x01, 0x76, 0x99, 0x92, 0x90, 0x02, 0x0e, 0x97, 0xc1, 0x63, 0x55, + 0x68, 0x3b, 0x23, 0x97, 0x00, 0x7a, 0x8c, 0x09, 0x99, 0x13, 0xb2, 0x11, 0x47, 0x1a, 0x90, 0xb2, + 0x20, 0x5d, 0x23, 0xd4, 0xc5, 0x06, 0x60, 0x17, 0x6b, 0x09, 0x69, 0xe0, 0x70, 0x31, 0x46, 0xca, + 0x71, 0xf2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, + 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0x3d, 0xa4, 0x54, + 0x54, 0x9c, 0x9a, 0xa9, 0x0b, 0x73, 0x10, 0x98, 0x03, 0x31, 0xbb, 0x02, 0x62, 0x3a, 0x38, 0x45, + 0x25, 0xb1, 0x81, 0x15, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xcb, 0x45, 0xf7, 0xdf, 0x53, + 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -341,7 +343,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.mint.v1beta1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.mint.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -350,7 +352,7 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . func (c *queryClient) Inflation(ctx context.Context, in *QueryInflationRequest, opts ...grpc.CallOption) (*QueryInflationResponse, error) { out := new(QueryInflationResponse) - err := c.cc.Invoke(ctx, "/cosmos.mint.v1beta1.Query/Inflation", in, out, opts...) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.mint.Query/Inflation", in, out, opts...) if err != nil { return nil, err } @@ -359,7 +361,7 @@ func (c *queryClient) Inflation(ctx context.Context, in *QueryInflationRequest, func (c *queryClient) AnnualProvisions(ctx context.Context, in *QueryAnnualProvisionsRequest, opts ...grpc.CallOption) (*QueryAnnualProvisionsResponse, error) { out := new(QueryAnnualProvisionsResponse) - err := c.cc.Invoke(ctx, "/cosmos.mint.v1beta1.Query/AnnualProvisions", in, out, opts...) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.mint.Query/AnnualProvisions", in, out, opts...) if err != nil { return nil, err } @@ -404,7 +406,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.mint.v1beta1.Query/Params", + FullMethod: "/seiprotocol.seichain.mint.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -422,7 +424,7 @@ func _Query_Inflation_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.mint.v1beta1.Query/Inflation", + FullMethod: "/seiprotocol.seichain.mint.Query/Inflation", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Inflation(ctx, req.(*QueryInflationRequest)) @@ -440,7 +442,7 @@ func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/cosmos.mint.v1beta1.Query/AnnualProvisions", + FullMethod: "/seiprotocol.seichain.mint.Query/AnnualProvisions", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).AnnualProvisions(ctx, req.(*QueryAnnualProvisionsRequest)) @@ -449,7 +451,7 @@ func _Query_AnnualProvisions_Handler(srv interface{}, ctx context.Context, dec f } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "cosmos.mint.v1beta1.Query", + ServiceName: "seiprotocol.seichain.mint.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -466,7 +468,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "cosmos/mint/v1beta1/query.proto", + Metadata: "mint/v1beta1/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/query.pb.gw.go b/x/mint/types/query.pb.gw.go index 576b206d4a..bfa8b2183b 100644 --- a/x/mint/types/query.pb.gw.go +++ b/x/mint/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: cosmos/mint/v1beta1/query.proto +// source: mint/v1beta1/query.proto /* Package types is a reverse proxy. @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ 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 @@ -88,12 +90,14 @@ func local_request_Query_AnnualProvisions_0(ctx context.Context, marshaler runti // 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 (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// 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 { @@ -101,6 +105,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv 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) @@ -114,6 +119,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Inflation_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 { @@ -121,6 +128,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Inflation_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) @@ -134,6 +142,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_AnnualProvisions_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 { @@ -141,6 +151,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_AnnualProvisions_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) @@ -256,11 +267,11 @@ 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", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"seichain", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Inflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "inflation"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Inflation_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"seichain", "mint", "v1beta1", "inflation"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_AnnualProvisions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"seichain", "mint", "v1beta1", "annual_provisions"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( From 0f5ef5c921330b7e2747a3058d2684b73664b9ca Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Thu, 14 Jul 2022 15:09:01 -0700 Subject: [PATCH 3/6] fix unit tests --- proto/mint/v1beta1/mint.proto | 14 +-- x/mint/keeper/grpc_query_test.go | 8 +- x/mint/keeper/integration_test.go | 6 +- x/mint/simulation/genesis.go | 2 +- x/mint/types/mint.pb.go | 202 +++++------------------------- x/mint/types/minter_test.go | 75 ----------- x/mint/types/params.go | 31 ++--- 7 files changed, 57 insertions(+), 281 deletions(-) diff --git a/proto/mint/v1beta1/mint.proto b/proto/mint/v1beta1/mint.proto index f2576624b2..51e9817509 100644 --- a/proto/mint/v1beta1/mint.proto +++ b/proto/mint/v1beta1/mint.proto @@ -51,14 +51,14 @@ message Params { // expected blocks per year uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; // mint epoch identifier - string epoch_identifier = 7 [(gogoproto.moretags) = "yaml:\"epoch_identifier\""]; +// string epoch_identifier = 7 [(gogoproto.moretags) = "yaml:\"epoch_identifier\""]; // number of epochs to take to reduce rewards - int64 reduction_period_in_epochs = 8 [(gogoproto.moretags) = "yaml:\"reduction_period_in_epochs\""]; +// int64 reduction_period_in_epochs = 8 [(gogoproto.moretags) = "yaml:\"reduction_period_in_epochs\""]; // reduction multiplier to execute on each period - string reduction_factor = 9 [ - (gogoproto.moretags) = "yaml:\"reduction-factor\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; +// string reduction_factor = 9 [ +// (gogoproto.moretags) = "yaml:\"reduction-factor\"", +// (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", +// (gogoproto.nullable) = false +// ]; } diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 7fe93fbbad..72afea9807 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -2,27 +2,27 @@ package keeper_test import ( gocontext "context" + "github.com/sei-protocol/sei-chain/app" "testing" "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" - "github.com/sei-protocol/sei-chain/x/mint/types" + "github.com/sei-protocol/sei-chain/x/mint/types" // TODO: Replace this with sei-chain. Leaving it for now otherwise tests fail ) type MintTestSuite struct { suite.Suite - app *simapp.SimApp + app *app.App ctx sdk.Context queryClient types.QueryClient } func (suite *MintTestSuite) SetupTest() { - app := simapp.Setup(false) + app := app.Setup(false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) diff --git a/x/mint/keeper/integration_test.go b/x/mint/keeper/integration_test.go index ae1cd37dd1..32f43acdaf 100644 --- a/x/mint/keeper/integration_test.go +++ b/x/mint/keeper/integration_test.go @@ -1,16 +1,16 @@ package keeper_test import ( + "github.com/sei-protocol/sei-chain/app" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sei-protocol/sei-chain/x/mint/types" ) // returns context and an app with updated mint keeper -func createTestApp(isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(isCheckTx) +func createTestApp(isCheckTx bool) (*app.App, sdk.Context) { + app := app.Setup(isCheckTx) ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) app.MintKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index 5ab91784a6..54bca6c7b3 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -82,7 +82,7 @@ func RandomizedGenState(simState *module.SimulationState) { mintDenom := sdk.DefaultBondDenom blocksPerYear := uint64(60 * 60 * 8766 / 5) - params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear, "week", sdk.NewDecWithPrec(5, 1), 156) + params := types.NewParams(mintDenom, inflationRateChange, inflationMax, inflationMin, goalBonded, blocksPerYear) mintGenesis := types.NewGenesisState(types.InitialMinter(inflation), params) diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 6a9a274321..2672977c6f 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -79,12 +79,6 @@ type Params struct { GoalBonded github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"goal_bonded" yaml:"goal_bonded"` // expected blocks per year BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"` - // mint epoch identifier - EpochIdentifier string `protobuf:"bytes,7,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty" yaml:"epoch_identifier"` - // number of epochs to take to reduce rewards - ReductionPeriodInEpochs int64 `protobuf:"varint,8,opt,name=reduction_period_in_epochs,json=reductionPeriodInEpochs,proto3" json:"reduction_period_in_epochs,omitempty" yaml:"reduction_period_in_epochs"` - // reduction multiplier to execute on each period - ReductionFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=reduction_factor,json=reductionFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reduction_factor" yaml:"reduction-factor"` } func (m *Params) Reset() { *m = Params{} } @@ -133,20 +127,6 @@ func (m *Params) GetBlocksPerYear() uint64 { return 0 } -func (m *Params) GetEpochIdentifier() string { - if m != nil { - return m.EpochIdentifier - } - return "" -} - -func (m *Params) GetReductionPeriodInEpochs() int64 { - if m != nil { - return m.ReductionPeriodInEpochs - } - return 0 -} - func init() { proto.RegisterType((*Minter)(nil), "seiprotocol.seichain.mint.Minter") proto.RegisterType((*Params)(nil), "seiprotocol.seichain.mint.Params") @@ -155,42 +135,36 @@ func init() { func init() { proto.RegisterFile("mint/v1beta1/mint.proto", fileDescriptor_06339c129491fd39) } var fileDescriptor_06339c129491fd39 = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xc1, 0x8e, 0xd3, 0x3a, - 0x14, 0x6d, 0xde, 0xf4, 0x15, 0x6a, 0x18, 0xb5, 0x98, 0x81, 0x86, 0x02, 0x49, 0x89, 0x04, 0xea, - 0xa6, 0x89, 0x46, 0xec, 0x66, 0x19, 0x4a, 0x45, 0x11, 0x83, 0xaa, 0xec, 0x60, 0x13, 0x39, 0x89, - 0xdb, 0x5a, 0x4d, 0xec, 0xc8, 0x76, 0x87, 0x76, 0xcb, 0x17, 0xb0, 0x64, 0xc9, 0xe7, 0xcc, 0x8e, - 0x59, 0x02, 0x8b, 0x08, 0xb5, 0x7f, 0xd0, 0x2f, 0x40, 0x71, 0x86, 0x74, 0x28, 0xb0, 0xa8, 0xc4, - 0xca, 0xbe, 0xe7, 0x9e, 0x7b, 0xce, 0xb1, 0x17, 0x17, 0xb4, 0x12, 0x42, 0xa5, 0x73, 0x76, 0x1c, - 0x60, 0x89, 0x8e, 0x9d, 0xbc, 0xb0, 0x53, 0xce, 0x24, 0x83, 0xf7, 0x04, 0x26, 0xea, 0x16, 0xb2, - 0xd8, 0x16, 0x98, 0x84, 0x53, 0x44, 0xa8, 0x9d, 0x13, 0xda, 0x47, 0x13, 0x36, 0x61, 0xaa, 0xe7, - 0xe4, 0xb7, 0x62, 0xc0, 0xfa, 0xac, 0x81, 0xda, 0x29, 0xa1, 0x12, 0x73, 0xf8, 0x0a, 0xd4, 0x09, - 0x1d, 0xc7, 0x48, 0x12, 0x46, 0x75, 0xad, 0xa3, 0x75, 0xeb, 0xae, 0x7d, 0x9e, 0x99, 0x95, 0x6f, - 0x99, 0xf9, 0x64, 0x42, 0xe4, 0x74, 0x1e, 0xd8, 0x21, 0x4b, 0x9c, 0x90, 0x89, 0x84, 0x89, 0xcb, - 0xa3, 0x27, 0xa2, 0x99, 0x23, 0x97, 0x29, 0x16, 0x76, 0x1f, 0x87, 0xde, 0x56, 0x00, 0xbe, 0x03, - 0xb7, 0x10, 0xa5, 0x73, 0x14, 0xfb, 0x29, 0x67, 0x67, 0x44, 0x10, 0x46, 0x85, 0xfe, 0x9f, 0x52, - 0x7d, 0xb9, 0x9f, 0xea, 0x26, 0x33, 0xf5, 0x25, 0x4a, 0xe2, 0x13, 0xeb, 0x37, 0x41, 0xcb, 0x6b, - 0x16, 0xd8, 0x68, 0x0b, 0x7d, 0xad, 0x81, 0xda, 0x08, 0x71, 0x94, 0x08, 0xf8, 0x10, 0x80, 0xfc, - 0xe9, 0x7e, 0x84, 0x29, 0x4b, 0x8a, 0x27, 0x79, 0xf5, 0x1c, 0xe9, 0xe7, 0x00, 0x7c, 0xaf, 0x81, - 0x3b, 0x65, 0x60, 0x9f, 0x23, 0x89, 0xfd, 0x70, 0x8a, 0xe8, 0x04, 0x5f, 0xe6, 0x7c, 0xbd, 0x77, - 0xce, 0x07, 0x45, 0xce, 0x3f, 0x8a, 0x5a, 0xde, 0xed, 0x12, 0xf7, 0x90, 0xc4, 0xcf, 0x14, 0x0a, - 0x67, 0xe0, 0x70, 0x4b, 0x4f, 0xd0, 0x42, 0x3f, 0x50, 0xde, 0x83, 0xbd, 0xbd, 0x8f, 0x76, 0xbd, - 0x13, 0xb4, 0xb0, 0xbc, 0x9b, 0x65, 0x7d, 0x8a, 0x16, 0x3b, 0x66, 0x84, 0xea, 0xd5, 0x7f, 0x66, - 0x46, 0xe8, 0x2f, 0x66, 0x84, 0x42, 0x0c, 0x6e, 0x4c, 0x18, 0x8a, 0xfd, 0x80, 0xd1, 0x08, 0x47, - 0xfa, 0xff, 0xca, 0xaa, 0xbf, 0xb7, 0x15, 0x2c, 0xac, 0xae, 0x48, 0x59, 0x1e, 0xc8, 0x2b, 0x57, - 0x15, 0xd0, 0x05, 0x8d, 0x20, 0x66, 0xe1, 0x4c, 0xf8, 0x29, 0xe6, 0xfe, 0x12, 0x23, 0xae, 0xd7, - 0x3a, 0x5a, 0xb7, 0xea, 0xb6, 0x37, 0x99, 0x79, 0xb7, 0x18, 0xde, 0x21, 0x58, 0xde, 0x61, 0x81, - 0x8c, 0x30, 0x7f, 0x83, 0x11, 0x87, 0x03, 0xd0, 0xc4, 0x29, 0x0b, 0xa7, 0x3e, 0x89, 0x30, 0x95, - 0x64, 0x4c, 0x30, 0xd7, 0xaf, 0xa9, 0xbc, 0xf7, 0x37, 0x99, 0xd9, 0x2a, 0x44, 0x76, 0x19, 0x96, - 0xd7, 0x50, 0xd0, 0xb0, 0x44, 0x60, 0x00, 0xda, 0x1c, 0x47, 0xf3, 0x50, 0x7d, 0x49, 0x8a, 0x39, - 0x61, 0x91, 0x4f, 0xa8, 0xaf, 0x68, 0x42, 0xbf, 0xde, 0xd1, 0xba, 0x07, 0xee, 0xe3, 0x4d, 0x66, - 0x3e, 0x2a, 0x14, 0xff, 0xce, 0xb5, 0xbc, 0x56, 0xd9, 0x1c, 0xa9, 0xde, 0x90, 0x3e, 0x57, 0x1d, - 0x28, 0x41, 0x73, 0x3b, 0x37, 0x46, 0xa1, 0x64, 0x5c, 0xaf, 0xab, 0xac, 0xc3, 0xbd, 0xff, 0xb6, - 0xb5, 0x93, 0xa3, 0x57, 0xe8, 0x59, 0x5e, 0xa3, 0x84, 0x06, 0x0a, 0x39, 0xa9, 0x7e, 0xfc, 0x64, - 0x56, 0xdc, 0x17, 0xe7, 0x2b, 0x43, 0xbb, 0x58, 0x19, 0xda, 0xf7, 0x95, 0xa1, 0x7d, 0x58, 0x1b, - 0x95, 0x8b, 0xb5, 0x51, 0xf9, 0xb2, 0x36, 0x2a, 0x6f, 0xed, 0x2b, 0x9e, 0x02, 0x93, 0xde, 0xcf, - 0x25, 0xa4, 0x0a, 0xb5, 0x85, 0x9c, 0x85, 0x5a, 0x54, 0x85, 0x7f, 0x50, 0x53, 0x84, 0xa7, 0x3f, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x93, 0xd5, 0x84, 0x2c, 0xca, 0x04, 0x00, 0x00, + // 453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xb1, 0x6e, 0xd3, 0x40, + 0x18, 0xc7, 0x6d, 0x08, 0x91, 0x72, 0x50, 0x01, 0x47, 0x01, 0x53, 0x81, 0x5d, 0x79, 0x40, 0x5d, + 0x6a, 0xab, 0x62, 0xeb, 0x68, 0x22, 0x84, 0x10, 0x45, 0x91, 0x37, 0x58, 0xac, 0xcf, 0xce, 0x87, + 0x73, 0x8a, 0x7d, 0x17, 0xdd, 0x5d, 0x4b, 0xb2, 0xf2, 0x04, 0x8c, 0x8c, 0xbc, 0x05, 0xaf, 0xd0, + 0x8d, 0x8e, 0x88, 0x21, 0x42, 0xc9, 0x1b, 0xf4, 0x09, 0x90, 0xef, 0x4a, 0x12, 0x02, 0x8b, 0x25, + 0x26, 0xdf, 0xff, 0xef, 0xef, 0xfe, 0xbf, 0xff, 0x0d, 0x1f, 0x79, 0x58, 0x33, 0xae, 0xe3, 0xb3, + 0xa3, 0x1c, 0x35, 0x1c, 0xc5, 0x8d, 0x88, 0x26, 0x52, 0x68, 0x41, 0x1f, 0x29, 0x64, 0xe6, 0x54, + 0x88, 0x2a, 0x52, 0xc8, 0x8a, 0x11, 0x30, 0x1e, 0x35, 0x03, 0x7b, 0xbb, 0xa5, 0x28, 0x85, 0xf9, + 0x17, 0x37, 0x27, 0x7b, 0x21, 0xfc, 0xe6, 0x92, 0xee, 0x09, 0xe3, 0x1a, 0x25, 0x7d, 0x4d, 0x7a, + 0x8c, 0xbf, 0xaf, 0x40, 0x33, 0xc1, 0x3d, 0x77, 0xdf, 0x3d, 0xe8, 0x25, 0xd1, 0xf9, 0x3c, 0x70, + 0x7e, 0xcc, 0x83, 0xa7, 0x25, 0xd3, 0xa3, 0xd3, 0x3c, 0x2a, 0x44, 0x1d, 0x17, 0x42, 0xd5, 0x42, + 0x5d, 0x7d, 0x0e, 0xd5, 0x70, 0x1c, 0xeb, 0xd9, 0x04, 0x55, 0xd4, 0xc7, 0x22, 0x5d, 0x07, 0xd0, + 0x0f, 0xe4, 0x2e, 0x70, 0x7e, 0x0a, 0x55, 0x36, 0x91, 0xe2, 0x8c, 0x29, 0x26, 0xb8, 0xf2, 0xae, + 0x99, 0xd4, 0x57, 0xed, 0x52, 0x2f, 0xe7, 0x81, 0x37, 0x83, 0xba, 0x3a, 0x0e, 0xff, 0x0a, 0x0c, + 0xd3, 0x3b, 0xd6, 0x1b, 0xac, 0xad, 0xaf, 0x1d, 0xd2, 0x1d, 0x80, 0x84, 0x5a, 0xd1, 0x27, 0x84, + 0x34, 0x4f, 0xcf, 0x86, 0xc8, 0x45, 0x6d, 0x9f, 0x94, 0xf6, 0x1a, 0xa7, 0xdf, 0x18, 0xf4, 0xa3, + 0x4b, 0xee, 0xaf, 0x0a, 0x67, 0x12, 0x34, 0x66, 0xc5, 0x08, 0x78, 0x89, 0x57, 0x3d, 0xdf, 0xb4, + 0xee, 0xf9, 0xd8, 0xf6, 0xfc, 0x67, 0x68, 0x98, 0xde, 0x5b, 0xf9, 0x29, 0x68, 0x7c, 0x6e, 0x5c, + 0x3a, 0x26, 0x3b, 0xeb, 0xf1, 0x1a, 0xa6, 0xde, 0x75, 0xc3, 0x7e, 0xd1, 0x9a, 0xbd, 0xbb, 0xcd, + 0xae, 0x61, 0x1a, 0xa6, 0xb7, 0x56, 0xfa, 0x04, 0xa6, 0x5b, 0x30, 0xc6, 0xbd, 0xce, 0x7f, 0x83, + 0x31, 0xfe, 0x07, 0x8c, 0x71, 0x8a, 0xe4, 0x66, 0x29, 0xa0, 0xca, 0x72, 0xc1, 0x87, 0x38, 0xf4, + 0x6e, 0x18, 0x54, 0xbf, 0x35, 0x8a, 0x5a, 0xd4, 0x46, 0x54, 0x98, 0x92, 0x46, 0x25, 0x46, 0xd0, + 0x84, 0xdc, 0xce, 0x2b, 0x51, 0x8c, 0x55, 0x36, 0x41, 0x99, 0xcd, 0x10, 0xa4, 0xd7, 0xdd, 0x77, + 0x0f, 0x3a, 0xc9, 0xde, 0xe5, 0x3c, 0x78, 0x60, 0x2f, 0x6f, 0x0d, 0x84, 0xe9, 0x8e, 0x75, 0x06, + 0x28, 0xdf, 0x22, 0xc8, 0xe3, 0xce, 0xe7, 0x2f, 0x81, 0x93, 0xbc, 0x3c, 0x5f, 0xf8, 0xee, 0xc5, + 0xc2, 0x77, 0x7f, 0x2e, 0x7c, 0xf7, 0xd3, 0xd2, 0x77, 0x2e, 0x96, 0xbe, 0xf3, 0x7d, 0xe9, 0x3b, + 0xef, 0xa2, 0x8d, 0xb6, 0x0a, 0xd9, 0xe1, 0xef, 0x15, 0x33, 0xc2, 0xec, 0x58, 0x3c, 0x35, 0x6b, + 0x68, 0x9b, 0xe7, 0x5d, 0x33, 0xf0, 0xec, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x62, 0x80, + 0xcd, 0xa8, 0x03, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { @@ -256,28 +230,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.ReductionFactor.Size() - i -= size - if _, err := m.ReductionFactor.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintMint(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x4a - if m.ReductionPeriodInEpochs != 0 { - i = encodeVarintMint(dAtA, i, uint64(m.ReductionPeriodInEpochs)) - i-- - dAtA[i] = 0x40 - } - if len(m.EpochIdentifier) > 0 { - i -= len(m.EpochIdentifier) - copy(dAtA[i:], m.EpochIdentifier) - i = encodeVarintMint(dAtA, i, uint64(len(m.EpochIdentifier))) - i-- - dAtA[i] = 0x3a - } if m.BlocksPerYear != 0 { i = encodeVarintMint(dAtA, i, uint64(m.BlocksPerYear)) i-- @@ -378,15 +330,6 @@ func (m *Params) Size() (n int) { if m.BlocksPerYear != 0 { n += 1 + sovMint(uint64(m.BlocksPerYear)) } - l = len(m.EpochIdentifier) - if l > 0 { - n += 1 + l + sovMint(uint64(l)) - } - if m.ReductionPeriodInEpochs != 0 { - n += 1 + sovMint(uint64(m.ReductionPeriodInEpochs)) - } - l = m.ReductionFactor.Size() - n += 1 + l + sovMint(uint64(l)) return n } @@ -730,91 +673,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EpochIdentifier", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EpochIdentifier = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReductionPeriodInEpochs", wireType) - } - m.ReductionPeriodInEpochs = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ReductionPeriodInEpochs |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReductionFactor", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowMint - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthMint - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthMint - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.ReductionFactor.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipMint(dAtA[iNdEx:]) diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 4abedb51cd..278d4d5ad1 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -4,84 +4,9 @@ import ( "math/rand" "testing" - "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" ) -func TestNextInflation(t *testing.T) { - minter := DefaultInitialMinter() - params := DefaultParams() - blocksPerYr := sdk.NewDec(int64(params.BlocksPerYear)) - - // Governing Mechanism: - // inflationRateChangePerYear = (1- BondedRatio/ GoalBonded) * MaxInflationRateChange - - tests := []struct { - bondedRatio, setInflation, expChange sdk.Dec - }{ - // with 0% bonded atom supply the inflation should increase by InflationRateChange - {sdk.ZeroDec(), sdk.NewDecWithPrec(7, 2), params.InflationRateChange.Quo(blocksPerYr)}, - - // 100% bonded, starting at 20% inflation and being reduced - // (1 - (1/0.67))*(0.13/8667) - {sdk.OneDec(), sdk.NewDecWithPrec(20, 2), - sdk.OneDec().Sub(sdk.OneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, - - // 50% bonded, starting at 10% inflation and being increased - {sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(10, 2), - sdk.OneDec().Sub(sdk.NewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, - - // test 7% minimum stop (testing with 100% bonded) - {sdk.OneDec(), sdk.NewDecWithPrec(7, 2), sdk.ZeroDec()}, - {sdk.OneDec(), sdk.NewDecWithPrec(700000001, 10), sdk.NewDecWithPrec(-1, 10)}, - - // test 20% maximum stop (testing with 0% bonded) - {sdk.ZeroDec(), sdk.NewDecWithPrec(20, 2), sdk.ZeroDec()}, - {sdk.ZeroDec(), sdk.NewDecWithPrec(1999999999, 10), sdk.NewDecWithPrec(1, 10)}, - - // perfect balance shouldn't change inflation - {sdk.NewDecWithPrec(67, 2), sdk.NewDecWithPrec(15, 2), sdk.ZeroDec()}, - } - for i, tc := range tests { - minter.Inflation = tc.setInflation - - inflation := minter.NextInflationRate(params, tc.bondedRatio) - diffInflation := inflation.Sub(tc.setInflation) - - require.True(t, diffInflation.Equal(tc.expChange), - "Test Index: %v\nDiff: %v\nExpected: %v\n", i, diffInflation, tc.expChange) - } -} - -func TestBlockProvision(t *testing.T) { - minter := InitialMinter(sdk.NewDecWithPrec(1, 1)) - params := DefaultParams() - - secondsPerYear := int64(60 * 60 * 8766) - - tests := []struct { - annualProvisions int64 - expProvisions int64 - }{ - {secondsPerYear / 5, 1}, - {secondsPerYear/5 + 1, 1}, - {(secondsPerYear / 5) * 2, 2}, - {(secondsPerYear / 5) / 2, 0}, - } - for i, tc := range tests { - minter.AnnualProvisions = sdk.NewDec(tc.annualProvisions) - provisions := minter.BlockProvision(params) - - expProvisions := sdk.NewCoin(params.MintDenom, - sdk.NewInt(tc.expProvisions)) - - require.True(t, expProvisions.IsEqual(provisions), - "test: %v\n\tExp: %v\n\tGot: %v\n", - i, tc.expProvisions, provisions) - } -} - // Benchmarking :) // previously using sdk.Int operations: // BenchmarkBlockProvision-4 5000000 220 ns/op diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 1d98889c22..58dbec30c8 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -31,34 +31,27 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams( mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, - epochIdentifier string, reductionFactor sdk.Dec, reductionPeriodInEpochs int64, ) Params { return Params{ - MintDenom: mintDenom, - InflationRateChange: inflationRateChange, - InflationMax: inflationMax, - InflationMin: inflationMin, - GoalBonded: goalBonded, - BlocksPerYear: blocksPerYear, - EpochIdentifier: epochIdentifier, - ReductionPeriodInEpochs: reductionPeriodInEpochs, - ReductionFactor: reductionFactor, + MintDenom: mintDenom, + InflationRateChange: inflationRateChange, + InflationMax: inflationMax, + InflationMin: inflationMin, + GoalBonded: goalBonded, + BlocksPerYear: blocksPerYear, } } // default minting module parameters func DefaultParams() Params { return Params{ - MintDenom: sdk.DefaultBondDenom, - InflationRateChange: sdk.NewDecWithPrec(13, 2), - InflationMax: sdk.NewDecWithPrec(20, 2), - InflationMin: sdk.NewDecWithPrec(7, 2), - GoalBonded: sdk.NewDecWithPrec(67, 2), - BlocksPerYear: uint64(60 * 60 * 8766), // assuming 1 second block times - EpochIdentifier: "week", // 1 week - ReductionPeriodInEpochs: 156, // 3 years - ReductionFactor: sdk.NewDecWithPrec(5, 1), // 0.5 + MintDenom: sdk.DefaultBondDenom, + InflationRateChange: sdk.NewDecWithPrec(13, 2), + InflationMax: sdk.NewDecWithPrec(20, 2), + InflationMin: sdk.NewDecWithPrec(7, 2), + GoalBonded: sdk.NewDecWithPrec(67, 2), + BlocksPerYear: uint64(60 * 60 * 8766), // assuming 1 second block times } } From cbfe810efa6928bb4d86c44c9ce9ac6cf165cc43 Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Thu, 14 Jul 2022 15:30:19 -0700 Subject: [PATCH 4/6] rm file --- x/epoch/keeper/hooks.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 x/epoch/keeper/hooks.go diff --git a/x/epoch/keeper/hooks.go b/x/epoch/keeper/hooks.go deleted file mode 100644 index e69de29bb2..0000000000 From faba3a8897874652d9b42fd628c97a8c53c7186f Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Thu, 14 Jul 2022 20:34:07 -0700 Subject: [PATCH 5/6] rm empty --- x/epoch/types/hooks.go | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 x/epoch/types/hooks.go diff --git a/x/epoch/types/hooks.go b/x/epoch/types/hooks.go deleted file mode 100644 index e69de29bb2..0000000000 From 07bc8999b6eca925aa11b23533a39c1e12be2b40 Mon Sep 17 00:00:00 2001 From: philipsu522 Date: Thu, 14 Jul 2022 20:38:16 -0700 Subject: [PATCH 6/6] gofumpt --- x/mint/client/cli/query.go | 3 --- x/mint/client/testutil/cli_test.go | 1 + x/mint/keeper/grpc_query_test.go | 3 ++- x/mint/keeper/hooks.go | 6 +++--- x/mint/module.go | 1 - x/mint/simulation/params_test.go | 1 - x/mint/types/codec.go | 4 +--- x/mint/types/minter_test.go | 2 -- x/mint/types/params.go | 2 -- 9 files changed, 7 insertions(+), 16 deletions(-) diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index 3754d75862..92f0edde50 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -45,7 +45,6 @@ func GetCmdQueryParams() *cobra.Command { params := &types.QueryParamsRequest{} res, err := queryClient.Params(cmd.Context(), params) - if err != nil { return err } @@ -75,7 +74,6 @@ func GetCmdQueryInflation() *cobra.Command { params := &types.QueryInflationRequest{} res, err := queryClient.Inflation(cmd.Context(), params) - if err != nil { return err } @@ -105,7 +103,6 @@ func GetCmdQueryAnnualProvisions() *cobra.Command { params := &types.QueryAnnualProvisionsRequest{} res, err := queryClient.AnnualProvisions(cmd.Context(), params) - if err != nil { return err } diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go index dd36a6af2d..1035ca7502 100644 --- a/x/mint/client/testutil/cli_test.go +++ b/x/mint/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/mint/keeper/grpc_query_test.go b/x/mint/keeper/grpc_query_test.go index 72afea9807..8a2c28d13c 100644 --- a/x/mint/keeper/grpc_query_test.go +++ b/x/mint/keeper/grpc_query_test.go @@ -2,9 +2,10 @@ package keeper_test import ( gocontext "context" - "github.com/sei-protocol/sei-chain/app" "testing" + "github.com/sei-protocol/sei-chain/app" + "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" diff --git a/x/mint/keeper/hooks.go b/x/mint/keeper/hooks.go index fc3056b9dc..582be4b42a 100644 --- a/x/mint/keeper/hooks.go +++ b/x/mint/keeper/hooks.go @@ -9,8 +9,8 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epoch types.Epoch) { } func (k Keeper) AfterEpochEnd(ctx sdk.Context, epoch types.Epoch) { - //minter := k.GetMinter(ctx) - //params := k.GetParams(ctx) - //if epoch.CurrentEpochStartTime >= params.Red + // minter := k.GetMinter(ctx) + // params := k.GetParams(ctx) + // if epoch.CurrentEpochStartTime >= params.Red } diff --git a/x/mint/module.go b/x/mint/module.go index 4eb0fde8d4..dea9269598 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -72,7 +72,6 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) - } // GetTxCmd returns no root tx command for the mint module. diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go index cff093d527..64c43b7e8f 100644 --- a/x/mint/simulation/params_test.go +++ b/x/mint/simulation/params_test.go @@ -34,5 +34,4 @@ func TestParamChangest(t *testing.T) { require.Equal(t, expected[i].simValue, p.SimValue()(r)) require.Equal(t, expected[i].subspace, p.Subspace()) } - } diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index b436c10298..a7067d90c2 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -5,9 +5,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" ) -var ( - amino = codec.NewLegacyAmino() -) +var amino = codec.NewLegacyAmino() func init() { cryptocodec.RegisterCrypto(amino) diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 278d4d5ad1..7b7afaf42f 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -40,7 +40,6 @@ func BenchmarkNextInflation(b *testing.B) { for n := 0; n < b.N; n++ { minter.NextInflationRate(params, bondedRatio) } - } // Next annual provisions benchmarking @@ -55,5 +54,4 @@ func BenchmarkNextAnnualProvisions(b *testing.B) { for n := 0; n < b.N; n++ { minter.NextAnnualProvisions(params, totalSupply) } - } diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 58dbec30c8..349c0b310d 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -32,7 +32,6 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams( mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, ) Params { - return Params{ MintDenom: mintDenom, InflationRateChange: inflationRateChange, @@ -83,7 +82,6 @@ func (p Params) Validate() error { } return nil - } // String implements the Stringer interface.