8000 app: (*SommelierApp).prepForZeroHeightGenesis should instead use a defer iter.Close() to ensure that the store gets closed on any panic · Issue #295 · PeggyJV/sommelier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
app: (*SommelierApp).prepForZeroHeightGenesis should instead use a defer iter.Close() to ensure that the store gets closed on any panic #295
Open
@odeke-em

Description

@odeke-em

Summary of Bug

Given the usage of panics down below image in this code section

sommelier/app/export.go

Lines 155 to 174 in 3157d97

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0