Skip to content

Commit

Permalink
Fix incorrect inflation drop
Browse files Browse the repository at this point in the history
  • Loading branch information
bsrinivas8687 committed Sep 27, 2021
1 parent 6c3dcc8 commit eae2ad6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
24 changes: 22 additions & 2 deletions x/mint/abci.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,29 @@
package mint

import (
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
abcitypes "github.com/tendermint/tendermint/abci/types"

"github.com/sentinel-official/hub/x/mint/keeper"
"github.com/sentinel-official/hub/x/mint/types"
)

const (
fix1Height = 2_642_500
)

func BeginBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate {
if ctx.BlockHeight() == fix1Height {
k.SetInflation(ctx, types.Inflation{
Max: sdk.NewDecWithPrec(49, 2),
Min: sdk.NewDecWithPrec(43, 2),
RateChange: sdk.NewDecWithPrec(6, 2),
Timestamp: time.Date(2021, 9, 27, 12, 0, 0, 0, time.UTC),
})
}

k.IterateInflations(ctx, func(_ int, inflation types.Inflation) bool {
if inflation.Timestamp.After(ctx.BlockTime()) {
return true
Expand All @@ -18,10 +33,15 @@ func BeginBlock(ctx sdk.Context, k keeper.Keeper) []abcitypes.ValidatorUpdate {
params.InflationMax = inflation.Max
params.InflationMin = inflation.Min
params.InflationRateChange = inflation.RateChange

k.SetParams(ctx, params)
k.DeleteInflation(ctx, inflation.Timestamp)

if ctx.BlockHeight() >= fix1Height {
minter := k.GetMinter(ctx)
minter.Inflation = inflation.Min
k.SetMinter(ctx, minter)
}

k.DeleteInflation(ctx, inflation.Timestamp)
return false
})

Expand Down
2 changes: 2 additions & 0 deletions x/mint/expected/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
)

type MintKeeper interface {
GetMinter(ctx sdk.Context) minttypes.Minter
SetMinter(ctx sdk.Context, minter minttypes.Minter)
GetParams(ctx sdk.Context) minttypes.Params
SetParams(ctx sdk.Context, params minttypes.Params)
}
8 changes: 8 additions & 0 deletions x/mint/keeper/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)

func (k *Keeper) GetMinter(ctx sdk.Context) minttypes.Minter {
return k.mint.GetMinter(ctx)
}

func (k *Keeper) SetMinter(ctx sdk.Context, minter minttypes.Minter) {
k.mint.SetMinter(ctx, minter)
}

func (k *Keeper) GetParams(ctx sdk.Context) minttypes.Params {
return k.mint.GetParams(ctx)
}
Expand Down

0 comments on commit eae2ad6

Please sign in to comment.