-
Notifications
You must be signed in to change notification settings - Fork 13
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
Review panic strategy #104
Comments
Panic, where there is a panic it means pre validity checks are failing, so there is faulty code that is allowing invalid requests to go through. So even if I returned an error I'd need to panic on top level and hence lose some parts of stack trace. Msgs and Queries validate these things. If some things pass through we have faulty code. I don't like the design, it's not intuitive, but if I'm checking request validity with a msg, as forced in cosmos sdk, should i repeat the same checks again while processing it? If yes, then there's a lot of logic changes to do. Cosmos SDK KVStore does not return errors, so my idea was to go through with keepers without returning errors. If an error would come out while calling a keeper then it means the request I'm processing is faulty and my pre-checks are not doing their job correctly. |
OK, so the onus is on us to test every single possible contingency and ensure that we don't encounter a panic. I don't love the strategy but I understand it given our time-to-market constraints. |
Yes, as soon as @orkunkl is ready with simulations, my best guess is that we will have one single point of control to test everything. Stateless checks are handled through Msg and Query validation, so: domain name empty, account name empty and so on. ATM we don't have a single point to check every interaction as everything is a sparse. This is a good design as every component should behave independently from the other. The problem is that cosmos forces us to divide things that we should not divide. Our handlers would not require panics if statelss checks were done alongside stateful ones. So if something goes through stateless checks and makes editing state fail (trying to iterate an empty account key in an index) what should I do? If I returned an error I'd be left with partial state (which can happen during iterations)? Would the state be rolled back? At least now we know for sure that if we panic state is cached and won't be applied so we're 100% sure that we don't 'infect' our state. Let me know your thoughts: @davepuchyr, @orkunkl |
Your implementation looks solid. Actually I checked out cosmos-sdk to see any issues related to this topic and fortunately recently someone made some improvements to the base app which we can use in the next minor updates I assume. Here it is: cosmos/cosmos-sdk#6053 |
We can use the |
I just wish we could edit the handler processor middleware... so we could add caches and not apply cache if handler returns an error, we could add top level logging there etc. it would solve a lot of stuff and make debugging 100000% easier... but sadly. |
Should we use panic or return an error?
The text was updated successfully, but these errors were encountered: