Skip to content

Conversation

@jbearer
Copy link
Contributor

@jbearer jbearer commented Jan 1, 2024

  • When a function already returns a Result, propagate errors instead of panicking with expect
  • For NovaError::SynthesisError, retain information about the original bellpepper error. Since NovaError implements Clone but bellpepper's SynthesisError does not, we keep the error information as a String.

This commit only fixes low-hanging fruit in lib.rs, for functions that already return a Result and can easily propagate errors just by replacing expect(...) with ?. There are still many unwrap() calls in functions returning Result in other modules, particularly gadgets. But I don't understand the code well in those parts, and I suspect some of those unwrap()s actually can't fail based on invariants of the code, so it makes perfect sense to leave them as is.

* When a function already returns a `Result`, propagate errors
  instead of panicking with `expect`
* For `NovaError::SynthesisError`, retain information about the
  original bellpepper error. Since `NovaError` implements `Clone`
  but bellpepper's `SynthesisError` does not, we keep the error
  information as a `String`.

This commit only fixes low-hanging fruit in lib.rs, for functions
that already return a `Result` and can easily propagate errors just
by replacing `expect(...)` with `?`. There are still many `unwrap()`
calls in functions returning `Result` in other modules, particularly
gadgets. But I don't understand the code well in those parts, and I
suspect some of those `unwrap()`s actually can't fail based on
invariants of the code, so it makes perfect sense to leave them as is.
@jbearer
Copy link
Contributor Author

jbearer commented Jan 1, 2024

@microsoft-github-policy-service agree

@srinathsetty srinathsetty merged commit fe5b932 into microsoft:main Jan 2, 2024
hero78119 pushed a commit to hero78119/SuperNova that referenced this pull request Jan 5, 2024
…t#226)

* Expose the last outputs and number of steps from RecursiveSNARK (microsoft#285)

Both of these data are easily accessible, and could be very useful
to clients:
* Exposing the last outputs allows us to get the current state of
  the computation on the prover side without wasting energy
  recomputing it
* Exposing the number of steps makes it easier to eventually pass
  `num_steps` into `CompressedSNARK::verify`

* Improve error handling (microsoft#286)

* When a function already returns a `Result`, propagate errors
  instead of panicking with `expect`
* For `NovaError::SynthesisError`, retain information about the
  original bellpepper error. Since `NovaError` implements `Clone`
  but bellpepper's `SynthesisError` does not, we keep the error
  information as a `String`.

This commit only fixes low-hanging fruit in lib.rs, for functions
that already return a `Result` and can easily propagate errors just
by replacing `expect(...)` with `?`. There are still many `unwrap()`
calls in functions returning `Result` in other modules, particularly
gadgets. But I don't understand the code well in those parts, and I
suspect some of those `unwrap()`s actually can't fail based on
invariants of the code, so it makes perfect sense to leave them as is.

Co-authored-by: Francois Garillot <francois@lurk-lab.com>

---------

Co-authored-by: Jeb Bearer <jeb.bearer@gmail.com>
huitseeker added a commit to huitseeker/Nova that referenced this pull request Feb 14, 2024
See microsoft#222, the commit_open_prove_verify test is subsumed by the subsequent unit test.
@tchataigner was right from the start.
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.

2 participants