Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce default inflation #20606

Merged
merged 5 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions orm/encoding/ormfield/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ const (

// DurationCodec encodes google.protobuf.Duration values with the following
// encoding:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from -315,576,000,000 to +315,576,000,000) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Durations:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from -315,576,000,000 to +315,576,000,000) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Durations:
// - []byte{0xBB, 0x9A, 0xC9, 0xFF} for zero nanos
// - 4 fixed bytes with the bit mask 0x80 applied to the first byte, with negative nanos scaled so that -999,999,999
// is encoded as 0 and -1 is encoded as 999,999,998
Expand Down
12 changes: 6 additions & 6 deletions orm/encoding/ormfield/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (

// TimestampCodec encodes google.protobuf.Timestamp values with the following
// encoding:
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Timestamps.
// - nil is encoded as []byte{0xFF}
// - seconds (which can range from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z) is encoded as 5 fixed bytes
// - nanos (which can range from 0 to 999,999,999 or -999,999,999 to 0 if seconds is negative) are encoded such
// that 999,999,999 is always added to nanos. This ensures that the encoded nanos are always >= 0. Additionally,
// by adding 999,999,999 to both positive and negative nanos, we guarantee that the lexicographical order is
// preserved when comparing the encoded values of two Timestamps.
//
// When iterating over timestamp indexes, nil values will always be ordered last.
//
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/bank/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))),
},
},
{
Expand All @@ -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))),
},
},
{
Expand All @@ -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))),
},
},
{
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/distribution/grpc_query_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions x/mint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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%.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the grammatical structure around "however".

- possible is defined to be 5% per year, however, the annual inflation is capped between 0% and 5%.
+ possible is defined to be 5% per year; however, the annual inflation is capped between 0% and 5%.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
possible is defined to be 5% per year, however, the annual inflation is capped between 0% and 5%.
possible is defined to be 5% per year; however, the annual inflation is capped between 0% and 5%.
Tools
LanguageTool

[typographical] ~98-~98: The word “however” is an adverb that can’t be used like a conjunction, and therefore needs to be separated from the sentence. (HOWEVER_SENTENCE)
Context: ...ge possible is defined to be 5% per year, however, the annual inflation is capped between ...


```go
NextInflationRate(params Params, bondedRatio math.LegacyDec) (inflation math.LegacyDec) {
Expand Down
20 changes: 10 additions & 10 deletions x/mint/types/minter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions x/mint/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading