Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decide on error handling if map iteration fails #12

Open
p-offtermatt opened this issue Apr 11, 2024 · 0 comments
Open

Decide on error handling if map iteration fails #12

p-offtermatt opened this issue Apr 11, 2024 · 0 comments
Labels
priority: nice-to-have Features that are nice to have, but that ultimately should not block deployment.

Comments

@p-offtermatt
Copy link
Member

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

@p-offtermatt p-offtermatt added the priority: nice-to-have Features that are nice to have, but that ultimately should not block deployment. label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: nice-to-have Features that are nice to have, but that ultimately should not block deployment.
Projects
None yet
Development

No branches or pull requests

1 participant