From 45d50adb7a15ca568c356a409b59181299066458 Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Wed, 6 Oct 2021 23:53:02 +0000 Subject: [PATCH] refactor: change the meaning of `VoteSetCounter` Now `VoteSetCounter` in HandleValidatorSignature indicates the real counted number, not a index-like number. --- x/slashing/keeper/infractions.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/slashing/keeper/infractions.go b/x/slashing/keeper/infractions.go index 9b803a942d..1c41c99be7 100644 --- a/x/slashing/keeper/infractions.go +++ b/x/slashing/keeper/infractions.go @@ -27,9 +27,9 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre // this is a relative index, so it counts blocks the validator *should* have signed // will use the 0-value default signing info if not present, except for the beginning - voterSetCounter := signInfo.VoterSetCounter signInfo.VoterSetCounter++ - index := voterSetCounter % k.SignedBlocksWindow(ctx) + voterSetCounter := signInfo.VoterSetCounter + index := (voterSetCounter - 1) % k.SignedBlocksWindow(ctx) // Update signed block bit array & counter // This counter just tracks the sum of the bit array @@ -70,7 +70,7 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre ) } - minVoterSetCount := k.SignedBlocksWindow(ctx) - 1 + minVoterSetCount := k.SignedBlocksWindow(ctx) maxMissed := k.SignedBlocksWindow(ctx) - minSignedPerWindow // if we have joined enough times to voter set and the validator has missed too many blocks, punish them