Skip to content

Validator missed blocks count is incorrect after decreasing slashing window #12541

Open
@mintthemoon

Description

Summary of Bug

After lowering the slashing window from 35000 to 18000 on the Kujira blockchain some validators are stuck with a missed block count that won't clear even if they don't miss any more blocks. Querying all blocks in the signing window for some validators (e.g. kujiravaloper1pshqems6hdka48gc56r2ykshyaarkt40hl0rlh) shows no misses while kujirad query slashing signing-info reports a positive count.

I believe the issue is here:

signInfo, found := k.GetValidatorSigningInfo(ctx, consAddr)
if !found {
panic(fmt.Sprintf("Expected signing info for validator %s but not found", consAddr))
}
// 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 start height
index := signInfo.IndexOffset % k.SignedBlocksWindow(ctx)
signInfo.IndexOffset++
// 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.GetValidatorMissedBlockBitArray(ctx, consAddr, index)
missed := !signed
switch {
case !previous && missed:
// Array value has changed from not missed to missed, increment counter
k.SetValidatorMissedBlockBitArray(ctx, consAddr, index, true)
signInfo.MissedBlocksCounter++
case previous && !missed:
// Array value has changed from missed to not missed, decrement counter
k.SetValidatorMissedBlockBitArray(ctx, consAddr, index, false)
signInfo.MissedBlocksCounter--
default:
// Array value at this index has not changed, no need to update counter
}

This code updates the missed block count by checking the current value against the previous value at that index. The problem is any blocks missed at indexes above 18000 in the bit array are "lost" when the window changes because they'll contribute to the count but never be checked again. That explains the behavior we're seeing where multiple validators have miss counts that won't go below where they were on 7/3 when the parameter change took effect.

Version

v0.45.4

Steps to Reproduce

Cause a validator to miss blocks distributed throughout the slashing window and then lower the slashing window parameter for the chain. Compare manual missed block counts from checking signatures against what's reported by query slashing signing-info.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      ☃️ Icebox

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions