ZcashFoundation / zebra

Zcash - Financial Privacy in Rust 🦓
https://zfnd.org/zebra/
Apache License 2.0
413 stars 106 forks source link

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

Closed mpguerra closed 1 week ago

mpguerra commented 1 month ago

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

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 commented 1 week ago

We've done all we're going to do here for now