Skip to content

Commit

Permalink
conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed May 16, 2022
2 parents 2404263 + b8c079a commit 54d73f8
Show file tree
Hide file tree
Showing 40 changed files with 5,132 additions and 10 deletions.
15 changes: 8 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,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"
Expand Down Expand Up @@ -129,6 +126,10 @@ import (
claimmodulekeeper "github.com/tendermint/spn/x/claim/keeper"
claimmoduletypes "github.com/tendermint/spn/x/claim/types"

"github.com/tendermint/spn/x/mint"
mintkeeper "github.com/tendermint/spn/x/mint/keeper"
minttypes "github.com/tendermint/spn/x/mint/types"

// this line is used by starport scaffolding # stargate/app/moduleImport

"github.com/ignite-hq/cli/ignite/pkg/cosmoscmd"
Expand Down Expand Up @@ -375,14 +376,14 @@ func New(
stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AuthKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)
app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
app.AuthKeeper, app.BankKeeper, authtypes.FeeCollectorName,
)
app.DistrKeeper = distrkeeper.NewKeeper(
appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AuthKeeper, app.BankKeeper,
&stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
)
app.MintKeeper = mintkeeper.NewKeeper(
appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper,
app.AuthKeeper, app.BankKeeper, app.DistrKeeper, authtypes.FeeCollectorName,
)
app.SlashingKeeper = slashingkeeper.NewKeeper(
appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName),
)
Expand Down
4 changes: 4 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ genesis:
mint:
params:
mint_denom: "uspn"
distribution_proportions:
staking: "0.400000000000000000"
incentives: "0.400000000000000000"
community_pool: "0.200000000000000000"
launch:
params:
revertDelay: "5"
Expand Down
7 changes: 6 additions & 1 deletion localnet/genesis_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,12 @@
"inflation_max": "0.200000000000000000",
"inflation_min": "0.070000000000000000",
"inflation_rate_change": "0.130000000000000000",
"mint_denom": "uspn"
"mint_denom": "uspn",
"distribution_proportions": {
"staking": "0.400000000000000000",
"incentives": "0.400000000000000000",
"community_pool": "0.200000000000000000",
}
}
},
"monitoringc": {
Expand Down
16 changes: 16 additions & 0 deletions proto/mint/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = "proto3";
package tendermint.spn.mint;

import "gogoproto/gogo.proto";
import "mint/mint.proto";

option go_package = "github.com/tendermint/spn/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];
}
72 changes: 72 additions & 0 deletions proto/mint/mint.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
syntax = "proto3";
package tendermint.spn.mint;

option go_package = "github.com/tendermint/spn/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.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
}

message DistributionProportions {
// staking defines the proportion of the minted minted_denom that is to be
// allocated as staking rewards.
string staking = 1 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// incentives defines the proportion of the minted minted_denom that is
// to be allocated as incentives.
string incentives = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// community_pool defines the proportion of the minted minted_denom that is
// to be allocated to the community pool.
string community_pool = 3 [
(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.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// maximum inflation rate
string inflation_max = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// minimum inflation rate
string inflation_min = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// goal of percent bonded atoms
string goal_bonded = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// expected blocks per year
uint64 blocks_per_year = 6;
// distribution_proportions defines the proportion of the minted denom
DistributionProportions distribution_proportions = 7
[ (gogoproto.nullable) = false ];
}
57 changes: 57 additions & 0 deletions proto/mint/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
syntax = "proto3";
package tendermint.spn.mint;

import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "mint/mint.proto";

option go_package = "github.com/tendermint/spn/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];
}
2 changes: 1 addition & 1 deletion testutil/keeper/initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
Expand All @@ -32,6 +31,7 @@ import (
claimtypes "github.com/tendermint/spn/x/claim/types"
launchkeeper "github.com/tendermint/spn/x/launch/keeper"
launchtypes "github.com/tendermint/spn/x/launch/types"
minttypes "github.com/tendermint/spn/x/mint/types"
monitoringcmodulekeeper "github.com/tendermint/spn/x/monitoringc/keeper"
monitoringcmoduletypes "github.com/tendermint/spn/x/monitoringc/types"
monitoringpmodulekeeper "github.com/tendermint/spn/x/monitoringp/keeper"
Expand Down
3 changes: 2 additions & 1 deletion x/campaign/module_simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,11 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
weightMsgUnredeemVouchers,
campaignsim.SimulateMsgUnredeemVouchers(am.accountKeeper, am.bankKeeper, am.keeper),
),

// disabled: https://github.com/tendermint/spn/issues/774
// simulation.NewWeightedOperation(
// weightMsgAddVestingOptions,
// campaignsim.SimulateMsgAddVestingOptions(am.accountKeeper, am.bankKeeper, am.profileKeeper, am.keeper),
//),
// ),
}
}
56 changes: 56 additions & 0 deletions x/mint/abci.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package mint

import (
"time"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/tendermint/spn/x/mint/keeper"
"github.com/tendermint/spn/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)
}

// distribute minted coins according to the defined proportions
err = k.DistributeMintedCoins(ctx, mintedCoin)
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()),
),
)
}
Loading

0 comments on commit 54d73f8

Please sign in to comment.