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

NU6 Audit: Suggestion 2: Improve Error Handling and Avoid Using Panics #8904

Open
mpguerra opened this issue Oct 2, 2024 · 0 comments
Open
Assignees
Labels
C-audit Category: Issues arising from audit findings I-panic Zebra panics with an internal error message NU-6 Network Upgrade: NU6 specific tasks
Milestone

Comments

@mpguerra
Copy link
Contributor

mpguerra commented Oct 2, 2024

Motivation

There are a number of instances where the code could potentially panic, leading to the code crashing unexpectedly. For example, If any of the parameters in parameters/network/subsidy.rs are not correctly set, then this will lead to panics in all of the below functions

  • block/subsidy/general.rs#L106
  • block/subsidy/general.rs#L137
  • src/block/check.rs#L189
  • subsidy/funding_streams/tests.rs#L132

This is just an example and there may be other instances where this could happen.

Scope

Least Authority recommends removing panics where possible. One of the possible improvements is to propagate errors to the caller and handle them on the upper layers. Note that error handling does not exclude using panics. In addition, if a caller can return an error, the callee function may not panic but, instead, propagate an error to the caller.

@mpguerra mpguerra added I-panic Zebra panics with an internal error message NU-6 Network Upgrade: NU6 specific tasks C-audit Category: Issues arising from audit findings labels Oct 2, 2024
@mpguerra mpguerra added this to the NU6 milestone Oct 2, 2024
@arya2 arya2 self-assigned this Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-audit Category: Issues arising from audit findings I-panic Zebra panics with an internal error message NU-6 Network Upgrade: NU6 specific tasks
Projects
Status: Review/QA
Development

No branches or pull requests

2 participants