-
Notifications
You must be signed in to change notification settings - Fork 608
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
Error handling in hooks instead of panics #2520
Comments
ah, sweet #2519 already makes this very straight forward.. |
This is a great idea, lets do it! |
Lets scope this issue only for the epoch module, but i would want to create these issues for other hooks as well. It would be best to have error handling over panic recovery for functions. |
not really @Anmol1696 , it's do it for all, will be weird to have it included in different versions. |
Yup agreed. I was planning to create smaller issues for all the other hooks as well and then tackle it. Cool let me just add the PRs to this issue itself then. |
Ah my bad, I thought you were doing it for just epochs my bad. I don't think this is something we should do for all hooks, several should have the ability to halt the action. I guess we can always leave it to hook caller level to panic |
@ValarDragon
|
Ideally we should have the ability for the hooks to return an error. They can always panic if there is a usecase for it. Currently for all hooks there is no error handling, just panic recoverying (if at all). |
I see, that makes a lot of sense |
I definitely agree, the semantic for hooks should be return an error, rather than panicking. But whether the chain should:
Is pretty subtle thing to navigate. Would rather not do this for the particularly complex / sensitive cases right now. To mitigate complexity in these, I would like to make some SDK level framework for navigating and defining this tradeoff space. Most tx code should just be But Beginblock/Endblock code and what scope we revert at actually takes more intense thought. I'd rather reason about a more general framework for defining this, and if {thing A} errors/gets reverted, ensuring that later things in the pipeline are aware and can not trigger accordingly. |
Right now, reading the code, the But others PR's you made were probably very close, but I'm worried about it being subtly off and want to spend more time on that. But the more general case + architecture for a framework dealing with this is going to be the more effective way (that also solves many more isolation issues) |
Makes sense, I would be curious to keep an eye on how you are planing to redesign the system. Could you point me to where the discussion is happening? |
Background
Avoiding raising panic on error for hooks by handling the errors instead of recovering from panic in hooks interfaces. Currently a panic from any of the hooks are first recovered and then handled, we should be just handling the error instead
This is possible now since we pass
cacheCtx
to hooks functions instead ofctx
.Note: All module hooks functions would need to be modified. Each module would be a seperate PR.
Suggested Design
Change the interface for hook functions to return error, and handle the error before
write()
to context.Example
Change in
EpochHooks
interface would be something like:Acceptance Criteria
The text was updated successfully, but these errors were encountered: