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

Wrap endblock #531

Conversation

RedBird96
Copy link
Contributor

Purpose of Changes and their Description

Implemented a wrapper function for EndBlocker to catch and handle any potential panics

Link(s) to Ticket(s) or Issue(s) resolved by this PR

Are these changes tested and documented?

  • If tested, please describe how. If not, why tests are not needed.
  • If documented, please describe where. If not, describe why docs are not needed.
  • Added to Unreleased section of CHANGELOG.md?

Still Left Todo

Fill this out if this is a Draft PR so others can help.

Copy link
Collaborator

@kpeluso kpeluso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple + elegant! Just 1 small detail to fix.

sdkCtx := sdk.UnwrapSDKContext(ctx)
if r := recover(); r != nil {
err := fmt.Errorf("recovered from panic in EndBlocker: %v", r)
sdkCtx.Logger().Error("Error Getting module params", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong error message!

sdkCtx.Logger().Error("Error Getting module params", err)
}
}()

err := EndBlocker(ctx, am)
if err != nil {
sdkCtx := sdk.UnwrapSDKContext(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we fix this typo in this PR too: EnbBlocker

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it's the line below this one, won't let me leave a comment on just that line)

@relyt29
Copy link
Contributor

relyt29 commented Aug 17, 2024

I am confused how this PR works, is this just going to catch panics on unwrapping the sdk context?

@RedBird96 RedBird96 closed this Aug 17, 2024
@RedBird96 RedBird96 reopened this Aug 17, 2024
@RedBird96
Copy link
Contributor Author

@relyt29 I can understand why you are confused on this change. I think it is because I got sdkCtx inside defer() it means we try to get sdk context after panic occurs. And there is potential issue is that if the panic is related to the context, this can lead to another panic. I think you are worried about this, right? Actually I thought this panic is not related to context after examining the functions that call panic. So I wrote the code like this. But we need to fix all of the potential issues so I updated the code to get sdkCtx before defer(). wdyt?

Copy link
Contributor

@relyt29 relyt29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the sdk context will be a real problem

@kpeluso kpeluso merged commit 07101bb into dev Aug 17, 2024
13 checks passed
@kpeluso kpeluso deleted the michaelc/proto-1956-security-issues-report-potential-panics-in-abci-methods branch August 17, 2024 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants