Skip to content

Commit 1816b52

Browse files
authored
feat(slashing): add singularity height getter (#20)
1 parent 8f5df61 commit 1816b52

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

x/slashing/keeper/infractions.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func (k Keeper) HandleValidatorSignature(ctx context.Context, addr cryptotypes.A
109109
minHeight := signInfo.StartHeight + signedBlocksWindow
110110
maxMissed := signedBlocksWindow - minSignedPerWindow
111111

112-
params, err := k.GetParams(ctx)
112+
singularityHeight, err := k.SingularityHeight(ctx)
113113
if err != nil {
114114
return errors.Wrap(err, "failed to get params")
115115
}
116116

117117
// if we are past the minimum height and the validator has missed too many blocks, punish them
118-
if height > int64(params.SingularityHeight) && height > minHeight && signInfo.MissedBlocksCounter > maxMissed {
118+
if height > int64(singularityHeight) && height > minHeight && signInfo.MissedBlocksCounter > maxMissed {
119119
validator, err := k.sk.ValidatorByConsAddr(ctx, consAddr)
120120
if err != nil {
121121
return err
@@ -175,7 +175,7 @@ func (k Keeper) HandleValidatorSignature(ctx context.Context, addr cryptotypes.A
175175
"slashed", slashFractionDowntime.String(),
176176
"jailed_until", signInfo.JailedUntil,
177177
)
178-
} else if height == int64(params.SingularityHeight) {
178+
} else if height == int64(singularityHeight) {
179179
// reset the counter & bitmap so that the validator won't be
180180
// immediately slashed after singularity.
181181
signInfo.MissedBlocksCounter = 0

x/slashing/keeper/params.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ func (k Keeper) SlashFractionDowntime(ctx context.Context) (sdkmath.LegacyDec, e
4848
return params.SlashFractionDowntime, err
4949
}
5050

51+
func (k Keeper) SingularityHeight(ctx context.Context) (uint64, error) {
52+
params, err := k.GetParams(ctx)
53+
return params.SingularityHeight, err
54+
}
55+
5156
// GetParams returns the current x/slashing module parameters.
5257
func (k Keeper) GetParams(ctx context.Context) (params types.Params, err error) {
5358
store := k.storeService.OpenKVStore(ctx)

0 commit comments

Comments
 (0)