From 76a28ad4d01de5f10456dbfb93a8cf4de4277717 Mon Sep 17 00:00:00 2001 From: Marko Date: Tue, 11 Jun 2024 11:33:15 +0200 Subject: [PATCH] chore: reduce default inflation (#20606) --- tests/e2e/bank/grpc.go | 8 ++++---- tests/e2e/distribution/grpc_query_suite.go | 6 +++--- x/mint/README.md | 3 +-- x/mint/types/minter_test.go | 20 ++++++++++---------- x/mint/types/params.go | 4 ++-- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/tests/e2e/bank/grpc.go b/tests/e2e/bank/grpc.go index 435778eae8..3f17667a4a 100644 --- a/tests/e2e/bank/grpc.go +++ b/tests/e2e/bank/grpc.go @@ -35,7 +35,7 @@ func (s *E2ETestSuite) TestTotalSupplyGRPCHandler() { &types.QueryTotalSupplyResponse{ Supply: sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.GetMoniker()), s.cfg.AccountTokens), - sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(10))), + sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(3))), ), Pagination: &query.PageResponse{ Total: 2, @@ -50,7 +50,7 @@ func (s *E2ETestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(3))), }, }, { @@ -61,7 +61,7 @@ func (s *E2ETestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(20))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(6))), }, }, { @@ -72,7 +72,7 @@ func (s *E2ETestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(10))), + Amount: sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(math.NewInt(3))), }, }, { diff --git a/tests/e2e/distribution/grpc_query_suite.go b/tests/e2e/distribution/grpc_query_suite.go index 7392c5fa1c..d90a74988a 100644 --- a/tests/e2e/distribution/grpc_query_suite.go +++ b/tests/e2e/distribution/grpc_query_suite.go @@ -116,7 +116,7 @@ func (s *GRPCQueryTestSuite) TestQueryOutstandingRewardsGRPC() { val := s.network.GetValidators()[0] baseURL := val.GetAPIAddress() - rewards, err := sdk.ParseDecCoins("19.6stake") + rewards, err := sdk.ParseDecCoins("5.88stake") s.Require().NoError(err) testCases := []struct { @@ -170,7 +170,7 @@ func (s *GRPCQueryTestSuite) TestQueryValidatorCommissionGRPC() { val := s.network.GetValidators()[0] baseURL := val.GetAPIAddress() - commission, err := sdk.ParseDecCoins("9.8stake") + commission, err := sdk.ParseDecCoins("2.94stake") s.Require().NoError(err) testCases := []struct { @@ -283,7 +283,7 @@ func (s *GRPCQueryTestSuite) TestQueryDelegatorRewardsGRPC() { val := s.network.GetValidators()[0] baseURL := val.GetAPIAddress() - rewards, err := sdk.ParseDecCoins("9.8stake") + rewards, err := sdk.ParseDecCoins("2.94stake") s.Require().NoError(err) testCases := []struct { diff --git a/x/mint/README.md b/x/mint/README.md index ff2467d754..0d16ce2082 100644 --- a/x/mint/README.md +++ b/x/mint/README.md @@ -95,8 +95,7 @@ type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, 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%. +possible is defined to be 5% per year, however, the annual inflation is capped between 0% and 5%. ```go NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.LegacyDec) { diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index dbfdf4cd2a..b89773a6cb 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -23,31 +23,31 @@ func TestNextInflation(t *testing.T) { bondedRatio, setInflation, expChange math.LegacyDec }{ // with 0% bonded atom supply the inflation should increase by InflationRateChange - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(7, 2), params.InflationRateChange.Quo(blocksPerYr)}, + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(0, 2), params.InflationRateChange.Quo(blocksPerYr)}, // 100% bonded, starting at 20% inflation and being reduced // (1 - (1/0.67))*(0.13/8667) { - math.LegacyOneDec(), math.LegacyNewDecWithPrec(20, 2), + math.LegacyOneDec(), math.LegacyNewDecWithPrec(5, 2), math.LegacyOneDec().Sub(math.LegacyOneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), }, // 50% bonded, starting at 10% inflation and being increased { - math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(10, 2), + math.LegacyNewDecWithPrec(5, 1), math.LegacyNewDecWithPrec(2, 2), math.LegacyOneDec().Sub(math.LegacyNewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), }, - // test 7% minimum stop (testing with 100% bonded) - {math.LegacyOneDec(), math.LegacyNewDecWithPrec(7, 2), math.LegacyZeroDec()}, - {math.LegacyOneDec(), math.LegacyNewDecWithPrec(700000001, 10), math.LegacyNewDecWithPrec(-1, 10)}, + // test 0% minimum stop (testing with 100% bonded) + {math.LegacyOneDec(), math.LegacyNewDecWithPrec(0, 2), math.LegacyZeroDec()}, + {math.LegacyOneDec(), math.LegacyNewDecWithPrec(1, 10), math.LegacyNewDecWithPrec(-1, 10)}, - // test 20% maximum stop (testing with 0% bonded) - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(20, 2), math.LegacyZeroDec()}, - {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(1999999999, 10), math.LegacyNewDecWithPrec(1, 10)}, + // test 5% maximum stop (testing with 0% bonded) + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(5, 2), math.LegacyZeroDec()}, + {math.LegacyZeroDec(), math.LegacyNewDecWithPrec(499999999, 10), math.LegacyNewDecWithPrec(1, 10)}, // perfect balance shouldn't change inflation - {math.LegacyNewDecWithPrec(67, 2), math.LegacyNewDecWithPrec(15, 2), math.LegacyZeroDec()}, + {math.LegacyNewDecWithPrec(67, 2), math.LegacyNewDecWithPrec(5, 2), math.LegacyZeroDec()}, } for i, tc := range tests { minter.Inflation = tc.setInflation diff --git a/x/mint/types/params.go b/x/mint/types/params.go index 9c5c483671..370eeea910 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -28,8 +28,8 @@ func DefaultParams() Params { return Params{ MintDenom: sdk.DefaultBondDenom, InflationRateChange: math.LegacyNewDecWithPrec(13, 2), - InflationMax: math.LegacyNewDecWithPrec(20, 2), - InflationMin: math.LegacyNewDecWithPrec(7, 2), + InflationMax: math.LegacyNewDecWithPrec(5, 2), + InflationMin: math.LegacyNewDecWithPrec(0, 2), GoalBonded: math.LegacyNewDecWithPrec(67, 2), BlocksPerYear: uint64(60 * 60 * 8766 / 5), // assuming 5 second block times MaxSupply: math.ZeroInt(), // assuming zero is infinite