diff --git a/x/slashing/keeper.go b/x/slashing/keeper.go index 61cfbb15c..68cbd90b0 100644 --- a/x/slashing/keeper.go +++ b/x/slashing/keeper.go @@ -110,17 +110,17 @@ func (k Keeper) handleValidatorSignature(ctx sdk.Context, addr crypto.Address, p // Update signed block bit array & counter // This counter just tracks the sum of the bit array // That way we avoid needing to read/write the whole array each time - previous := k.getValidatorSigningBitArray(ctx, consAddr, index) + previous := k.getValidatorMissedBlockBitArray(ctx, consAddr, index) missed := !signed if previous == missed { // Array value at this index has not changed, no need to update counter } else if !previous && missed { // Array value has changed from not missed to missed, increment counter - k.setValidatorSigningBitArray(ctx, consAddr, index, true) + k.setValidatorMissedBlockBitArray(ctx, consAddr, index, true) signInfo.MissedBlocksCounter++ } else if previous && !missed { // Array value has changed from missed to not missed, decrement counter - k.setValidatorSigningBitArray(ctx, consAddr, index, false) + k.setValidatorMissedBlockBitArray(ctx, consAddr, index, false) signInfo.MissedBlocksCounter-- } diff --git a/x/slashing/signing_info.go b/x/slashing/signing_info.go index 64f47838a..88e00fd67 100644 --- a/x/slashing/signing_info.go +++ b/x/slashing/signing_info.go @@ -28,7 +28,7 @@ func (k Keeper) setValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress } // Stored by *validator* address (not operator address) -func (k Keeper) getValidatorSigningBitArray(ctx sdk.Context, address sdk.ConsAddress, index int64) (signed bool) { +func (k Keeper) getValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress, index int64) (signed bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(GetValidatorSigningBitArrayKey(address, index)) if bz == nil { @@ -41,7 +41,7 @@ func (k Keeper) getValidatorSigningBitArray(ctx sdk.Context, address sdk.ConsAdd } // Stored by *validator* address (not operator address) -func (k Keeper) setValidatorSigningBitArray(ctx sdk.Context, address sdk.ConsAddress, index int64, signed bool) { +func (k Keeper) setValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress, index int64, signed bool) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshalBinary(signed) store.Set(GetValidatorSigningBitArrayKey(address, index), bz) diff --git a/x/slashing/signing_info_test.go b/x/slashing/signing_info_test.go index f5c8d6ea3..c5ffc8bf1 100644 --- a/x/slashing/signing_info_test.go +++ b/x/slashing/signing_info_test.go @@ -30,9 +30,9 @@ func TestGetSetValidatorSigningInfo(t *testing.T) { func TestGetSetValidatorSigningBitArray(t *testing.T) { ctx, _, _, _, keeper := createTestInput(t, DefaultParams()) - missed := keeper.getValidatorSigningBitArray(ctx, sdk.ConsAddress(addrs[0]), 0) + missed := keeper.getValidatorMissedBlockBitArray(ctx, sdk.ConsAddress(addrs[0]), 0) require.False(t, missed) // treat empty key as not missed - keeper.setValidatorSigningBitArray(ctx, sdk.ConsAddress(addrs[0]), 0, true) - missed = keeper.getValidatorSigningBitArray(ctx, sdk.ConsAddress(addrs[0]), 0) + keeper.setValidatorMissedBlockBitArray(ctx, sdk.ConsAddress(addrs[0]), 0, true) + missed = keeper.getValidatorMissedBlockBitArray(ctx, sdk.ConsAddress(addrs[0]), 0) require.True(t, missed) // now should be missed }