mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
feat(community): disable x/distribution community tax in disable inflation upgrade (#1752)
* Disable distribution community tax in disable inflation upgrade * Add changelog entry
This commit is contained in:
parent
8186367c8b
commit
1d36429fe3
@ -38,7 +38,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry.
|
- (metrics) [#1668] Adds non-state breaking x/metrics module for custom telemetry
|
||||||
- (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers
|
- (metrics) [#1669] Add performance timing metrics to all Begin/EndBlockers
|
||||||
- (community) [#1704] Add module params
|
- (community) [#1704] Add module params
|
||||||
- (community) [#1706] Add disable inflation upgrade
|
- (community) [#1706] Add disable inflation upgrade
|
||||||
@ -52,8 +52,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
|||||||
|
|
||||||
- (community) [#1704] Add param to control when inflation will be disabled
|
- (community) [#1704] Add param to control when inflation will be disabled
|
||||||
- (community) [#1707] Default staking rewards per second set to `744191`
|
- (community) [#1707] Default staking rewards per second set to `744191`
|
||||||
- (community) [#1706] Add disable inflation upgrade to begin blocker that updates x/mint and x/kavadist params.
|
- (community) [#1706] Add disable inflation upgrade to begin blocker that updates x/mint and x/kavadist params
|
||||||
- (community) [#1729] Consolidate community funds from `x/distribution` and `x/kavadist` to `x/community`
|
- (community) [#1729] Consolidate community funds from `x/distribution` and `x/kavadist` to `x/community`
|
||||||
|
- (community) [#1752] Set `x/distribution` CommunityTax to zero on inflation disable upgrade
|
||||||
|
|
||||||
## [v0.24.0]
|
## [v0.24.0]
|
||||||
|
|
||||||
@ -294,10 +295,12 @@ the [changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.38.4/CHANGELOG.md).
|
|||||||
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
|
- [#257](https://github.com/Kava-Labs/kava/pulls/257) Include scripts to run
|
||||||
large-scale simulations remotely using aws-batch
|
large-scale simulations remotely using aws-batch
|
||||||
|
|
||||||
|
[#1752]: https://github.com/Kava-Labs/kava/pull/1752
|
||||||
[#1729]: https://github.com/Kava-Labs/kava/pull/1729
|
[#1729]: https://github.com/Kava-Labs/kava/pull/1729
|
||||||
[#1745]: https://github.com/Kava-Labs/kava/pull/1745
|
[#1745]: https://github.com/Kava-Labs/kava/pull/1745
|
||||||
[#1707]: https://github.com/Kava-Labs/kava/pull/1707
|
[#1707]: https://github.com/Kava-Labs/kava/pull/1707
|
||||||
[#1706]: https://github.com/Kava-Labs/kava/pull/1706
|
[#1706]: https://github.com/Kava-Labs/kava/pull/1706
|
||||||
|
[#1704]: https://github.com/Kava-Labs/kava/pull/1704
|
||||||
[#1668]: https://github.com/Kava-Labs/kava/pull/1668
|
[#1668]: https://github.com/Kava-Labs/kava/pull/1668
|
||||||
[#1669]: https://github.com/Kava-Labs/kava/pull/1669
|
[#1669]: https://github.com/Kava-Labs/kava/pull/1669
|
||||||
[#1655]: https://github.com/Kava-Labs/kava/pull/1655
|
[#1655]: https://github.com/Kava-Labs/kava/pull/1655
|
||||||
|
@ -19,8 +19,14 @@ func (k Keeper) CheckAndDisableMintAndKavaDistInflation(ctx sdk.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger := k.Logger(ctx)
|
||||||
|
logger.Info("disable inflation upgrade started")
|
||||||
|
|
||||||
// run disable inflation logic
|
// run disable inflation logic
|
||||||
k.disableInflation(ctx)
|
k.disableInflation(ctx)
|
||||||
|
k.disableCommunityTax(ctx)
|
||||||
|
|
||||||
|
logger.Info("disable inflation upgrade finished successfully!")
|
||||||
|
|
||||||
ctx.EventManager().EmitEvent(
|
ctx.EventManager().EmitEvent(
|
||||||
sdk.NewEvent(
|
sdk.NewEvent(
|
||||||
@ -43,7 +49,6 @@ func (k Keeper) CheckAndDisableMintAndKavaDistInflation(ctx sdk.Context) {
|
|||||||
// affecting rewards. In addition, inflation periods in kavadist should be removed.
|
// affecting rewards. In addition, inflation periods in kavadist should be removed.
|
||||||
func (k Keeper) disableInflation(ctx sdk.Context) {
|
func (k Keeper) disableInflation(ctx sdk.Context) {
|
||||||
logger := k.Logger(ctx)
|
logger := k.Logger(ctx)
|
||||||
logger.Info("disable inflation upgrade started")
|
|
||||||
|
|
||||||
// set x/min inflation to 0
|
// set x/min inflation to 0
|
||||||
mintParams := k.mintKeeper.GetParams(ctx)
|
mintParams := k.mintKeeper.GetParams(ctx)
|
||||||
@ -57,6 +62,14 @@ func (k Keeper) disableInflation(ctx sdk.Context) {
|
|||||||
kavadistParams.Active = false
|
kavadistParams.Active = false
|
||||||
k.kavadistKeeper.SetParams(ctx, kavadistParams)
|
k.kavadistKeeper.SetParams(ctx, kavadistParams)
|
||||||
logger.Info("x/kavadist inflation disabled")
|
logger.Info("x/kavadist inflation disabled")
|
||||||
|
}
|
||||||
logger.Info("disable inflation upgrade finished successfully!")
|
|
||||||
|
// disableCommunityTax sets x/distribution Params.CommunityTax to 0
|
||||||
|
func (k Keeper) disableCommunityTax(ctx sdk.Context) {
|
||||||
|
logger := k.Logger(ctx)
|
||||||
|
|
||||||
|
distrParams := k.distrKeeper.GetParams(ctx)
|
||||||
|
distrParams.CommunityTax = sdk.ZeroDec()
|
||||||
|
k.distrKeeper.SetParams(ctx, distrParams)
|
||||||
|
logger.Info("x/distribution community tax set to 0")
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||||
@ -29,6 +30,7 @@ type disableInflationTestSuite struct {
|
|||||||
|
|
||||||
genesisMintState *minttypes.GenesisState
|
genesisMintState *minttypes.GenesisState
|
||||||
genesisKavadistState *kavadisttypes.GenesisState
|
genesisKavadistState *kavadisttypes.GenesisState
|
||||||
|
genesisDistrState *distrtypes.GenesisState
|
||||||
|
|
||||||
testFunc testFunc
|
testFunc testFunc
|
||||||
}
|
}
|
||||||
@ -57,10 +59,15 @@ func (suite *disableInflationTestSuite) SetupTest() {
|
|||||||
kavadistGen.Params.Active = true
|
kavadistGen.Params.Active = true
|
||||||
suite.genesisKavadistState = kavadistGen
|
suite.genesisKavadistState = kavadistGen
|
||||||
|
|
||||||
|
distrGen := distrtypes.DefaultGenesisState()
|
||||||
|
distrGen.Params.CommunityTax = sdk.MustNewDecFromStr("0.949500000000000000")
|
||||||
|
suite.genesisDistrState = distrGen
|
||||||
|
|
||||||
appCodec := tApp.AppCodec()
|
appCodec := tApp.AppCodec()
|
||||||
suite.App.InitializeFromGenesisStates(
|
suite.App.InitializeFromGenesisStates(
|
||||||
app.GenesisState{minttypes.ModuleName: appCodec.MustMarshalJSON(mintGen)},
|
app.GenesisState{minttypes.ModuleName: appCodec.MustMarshalJSON(mintGen)},
|
||||||
app.GenesisState{kavadisttypes.ModuleName: appCodec.MustMarshalJSON(kavadistGen)},
|
app.GenesisState{kavadisttypes.ModuleName: appCodec.MustMarshalJSON(kavadistGen)},
|
||||||
|
app.GenesisState{distrtypes.ModuleName: appCodec.MustMarshalJSON(distrGen)},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +77,12 @@ func (suite *disableInflationTestSuite) TestDisableInflation() {
|
|||||||
suite.Require().True(found)
|
suite.Require().True(found)
|
||||||
mintParams := suite.App.GetMintKeeper().GetParams(suite.Ctx)
|
mintParams := suite.App.GetMintKeeper().GetParams(suite.Ctx)
|
||||||
kavadistParams := suite.App.GetKavadistKeeper().GetParams(suite.Ctx)
|
kavadistParams := suite.App.GetKavadistKeeper().GetParams(suite.Ctx)
|
||||||
|
distrParams := suite.App.GetDistrKeeper().GetParams(suite.Ctx)
|
||||||
|
|
||||||
disableTimeMsg := "expected inflation disable time to match"
|
disableTimeMsg := "expected inflation disable time to match"
|
||||||
expectedMintState := suite.genesisMintState
|
expectedMintState := suite.genesisMintState
|
||||||
expectedKavadistState := suite.genesisKavadistState
|
expectedKavadistState := suite.genesisKavadistState
|
||||||
|
expectedDistrState := suite.genesisDistrState
|
||||||
expectedStakingRewards := originalStakingRewards
|
expectedStakingRewards := originalStakingRewards
|
||||||
msgSuffix := "before upgrade"
|
msgSuffix := "before upgrade"
|
||||||
|
|
||||||
@ -92,6 +101,9 @@ func (suite *disableInflationTestSuite) TestDisableInflation() {
|
|||||||
expectedMintState.Params.InflationMax = sdk.ZeroDec()
|
expectedMintState.Params.InflationMax = sdk.ZeroDec()
|
||||||
|
|
||||||
expectedKavadistState.Params.Active = false
|
expectedKavadistState.Params.Active = false
|
||||||
|
|
||||||
|
expectedDistrState.Params.CommunityTax = sdk.ZeroDec()
|
||||||
|
|
||||||
msgSuffix = "after upgrade"
|
msgSuffix = "after upgrade"
|
||||||
|
|
||||||
suite.Require().NoError(app.EventsContains(suite.Ctx.EventManager().Events(), sdk.NewEvent(types.EventTypeInflationStop)))
|
suite.Require().NoError(app.EventsContains(suite.Ctx.EventManager().Events(), sdk.NewEvent(types.EventTypeInflationStop)))
|
||||||
@ -100,6 +112,7 @@ func (suite *disableInflationTestSuite) TestDisableInflation() {
|
|||||||
suite.Require().Equal(expectedMintState.Params.InflationMin, mintParams.InflationMin, msg+": expected mint inflation min to match state "+msgSuffix)
|
suite.Require().Equal(expectedMintState.Params.InflationMin, mintParams.InflationMin, msg+": expected mint inflation min to match state "+msgSuffix)
|
||||||
suite.Require().Equal(expectedMintState.Params.InflationMax, mintParams.InflationMax, msg+": expected mint inflation max to match state "+msgSuffix)
|
suite.Require().Equal(expectedMintState.Params.InflationMax, mintParams.InflationMax, msg+": expected mint inflation max to match state "+msgSuffix)
|
||||||
suite.Require().Equal(expectedKavadistState.Params.Active, kavadistParams.Active, msg+":expected kavadist active flag match state "+msgSuffix)
|
suite.Require().Equal(expectedKavadistState.Params.Active, kavadistParams.Active, msg+":expected kavadist active flag match state "+msgSuffix)
|
||||||
|
suite.Require().Equal(expectedDistrState.Params.CommunityTax, distrParams.CommunityTax, msg+":expected x/distribution community tax to match state "+msgSuffix)
|
||||||
suite.Require().Equal(expectedDisableTime, params.UpgradeTimeDisableInflation, msg+": "+disableTimeMsg)
|
suite.Require().Equal(expectedDisableTime, params.UpgradeTimeDisableInflation, msg+": "+disableTimeMsg)
|
||||||
|
|
||||||
// we always check staking rewards per second matches the passed in expectation
|
// we always check staking rewards per second matches the passed in expectation
|
||||||
|
@ -43,6 +43,8 @@ type DistributionKeeper interface {
|
|||||||
GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins
|
GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins
|
||||||
GetFeePool(ctx sdk.Context) distrtypes.FeePool
|
GetFeePool(ctx sdk.Context) distrtypes.FeePool
|
||||||
SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool)
|
SetFeePool(ctx sdk.Context, feePool distrtypes.FeePool)
|
||||||
|
GetParams(ctx sdk.Context) distrtypes.Params
|
||||||
|
SetParams(ctx sdk.Context, params distrtypes.Params)
|
||||||
}
|
}
|
||||||
|
|
||||||
type MintKeeper interface {
|
type MintKeeper interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user