You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In our code, we often iterate over maps.
In reality, we then iterate over Results, because appearantly sometimes deserializing objects from the store can fail:
Another critical thing to notice is that the iterator returned by both keys and range functions are not iterators over elements - they are iterators over Results. It is a thing because, as it is rare, it might be that item is supposed to exist, but there is some error while reading from storage - maybe the stored value is serialized in a way we didn't expect, and deserialization fails. This is actually a real thing that happened in one of the contracts I worked on in the past - we changed the value type of the Map, and then forgot to migrate it, which caused all sorts of problems. https://book.cosmwasm.com/cross-contract/map-storage.html
We need to decide what to do for error handling here.
We can either panic (but this might deadlock the contract if the deserialization always fails); or we could just skip the erroring entries (but we might be losing some entries due to this, which might have other implications)
For now, we decided to just panic, but we should make sure to check back on this decision.
We likely need to understand better
a) when would the iteration encounter errors
b) is there a way to recover
The text was updated successfully, but these errors were encountered:
In our code, we often iterate over maps.
In reality, we then iterate over Results, because appearantly sometimes deserializing objects from the store can fail:
We need to decide what to do for error handling here.
We can either panic (but this might deadlock the contract if the deserialization always fails); or we could just skip the erroring entries (but we might be losing some entries due to this, which might have other implications)
For now, we decided to just panic, but we should make sure to check back on this decision.
We likely need to understand better
a) when would the iteration encounter errors
b) is there a way to recover
The text was updated successfully, but these errors were encountered: