Summary of Bug
Given the usage of panics down below
in this code section
|
iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) |
|
counter := int16(0) |
|
|
|
for ; iter.Valid(); iter.Next() { |
|
addr := sdk.ValAddress(iter.Key()[1:]) |
|
validator, found := app.StakingKeeper.GetValidator(ctx, addr) |
|
if !found { |
|
panic("expected validator, not found") |
|
} |
|
|
|
validator.UnbondingHeight = 0 |
|
if applyAllowedAddrs && !allowedAddrsMap[addr.String()] { |
|
validator.Jailed = true |
|
} |
|
|
|
app.StakingKeeper.SetValidator(ctx, validator) |
|
counter++ |
|
} |
|
|
|
iter.Close() |
, despite having an iter.Close() down at Line 174, it is important to use defer iter.Close() which will allow for clean up by closing the store and releasing resources