0g-chain/x/community/spec/02_state.md

76 lines
2.8 KiB
Markdown
Raw Normal View History

add x/kavamint & x/community modules (#1400) * add `x/kavamint` module (#1376) * stub out the x/kavamint module * mint staking rewards in x/kavamint BeginBlocker * calculate cumulative inflation from x/kavamint * cleanup, abstract bond denom, grpc query tests * store & use previous block time to calculate mints * move test suite to testutil * add test of x/kavamint BeginBlocker * cleanup & comments from @DracoLi review * fix x/incentive integration test * remove rest client grpc test * add x/kavamint module spec * track previous block time in genesis * suggested cleanup from PR review * bugfix incorrect module account check * add x/community module (#1388) * add x/community module * refactor and setup fund-community-pool tx * remove unused features (params, genesis state) * test x/community query and message * update with master branch deps * updates from review * indicate deprecated methods on module (still needed to fulfill interface) * remove legacy querier * derive msg Route() and Type() from sdk.MsgTypeURL(&msg) * use module name for message Route() * mint community pool inflation in x/kavamint (#1389) * mint community pool inflation in x/kavamint * refactor x/kavamint abci inflation test * test inflation from x/kavamint * default kavamint rates to 0% * rename kavamint account name variables * panic if genesis kavamint previous block time not set * emit event on kavamint begin blocker * add kavamint year of inflation sanity check test * update fund_community_pool message event * add x/community spec * refactor inflation accumulation into single func * use new comm pool in kavadist multispend proposal (#1403) the x/community module houses the new community pool. this commit points the CommunityPoolMultiSpendProposal at the new community pool so that multispend proposals can continue to be processed once original fee pool funds are move to x/community * updates from proto lint changes * update earn proposals to use new community pool originally the CommunityPoolDepositProposal & CommunityPoolWithdrawProposal used the vanilla community pool fee pool. this commit updates them both to use the new x/community module account. * spec formatting update * add x/community & x/kavamint to internal testnet genesis * increase test coverage of x/kavamint * increase test coverage of x/community * use string type for sdk.Dec proto fields; disable generation of getters for genesis and params (and other store objects) * follow sdk conventions for params endpoint naming * add kavamint to swagger; update swagger & proto docs * remove legacy querier; touch up module to match others * reduce max minting rate; refactor genesis to allow nil/zero block time; repace proto stringers and remove getters; keep sdk.Dec values strings in protos; increase validation of sdk.Dec values in params; increase coverage; add module account permission checks; ensure import and export of genesis does not change state * fix scaling of rate values -- should be yearly rates * revert key change * fix typo in test name * fix regression in running tests -- rename method Co-authored-by: Nick DeLuca <nickdeluca08@gmail.com>
2022-12-09 21:24:35 +00:00
<!--
order: 2
-->
# State
## Parameters and Genesis State
`Params` define the module parameters, containing the information required to
set the current staking rewards per second at a future date. When the
`upgrade_time_disable_inflation` time is reached, `staking_rewards_per_second`
will be set to `upgrade_time_set_staking_rewards_per_second`.
```protobuf
// Params defines the parameters of the community module.
message Params {
option (gogoproto.equal) = true;
// upgrade_time_disable_inflation is the time at which to disable mint and kavadist module inflation.
// If set to 0, inflation will be disabled from block 1.
google.protobuf.Timestamp upgrade_time_disable_inflation = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// staking_rewards_per_second is the amount paid out to delegators each block from the community account
string staking_rewards_per_second = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// upgrade_time_set_staking_rewards_per_second is the initial staking_rewards_per_second to set
// and use when the disable inflation time is reached
string upgrade_time_set_staking_rewards_per_second = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
```
`GenesisState` defines the state that must be persisted when the blockchain
stops/restarts in order for normal function of the module to resume. It contains
the parameters and staking rewards state to keep track of payout between blocks.
```protobuf
// GenesisState defines the community module's genesis state.
message GenesisState {
// params defines all the paramaters related to commmunity
Params params = 1 [(gogoproto.nullable) = false];
// StakingRewardsState stores the internal staking reward data required to
// track staking rewards across blocks
StakingRewardsState staking_rewards_state = 2 [(gogoproto.nullable) = false];
}
// StakingRewardsState represents the state of staking reward accumulation between blocks.
message StakingRewardsState {
// last_accumulation_time represents the last block time which rewards where calculated and distributed.
// This may be zero to signal accumulation should start on the next interval.
google.protobuf.Timestamp last_accumulation_time = 1 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false
];
// accumulated_truncation_error represents the sum of previous errors due to truncation on payout
// This value will always be on the interval [0, 1).
string last_truncation_error = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
}
```