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

Update panics by todo! and unimplemented! macros #2471

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Jul 8, 2021

Motivation

When NU5 activates, Zebra must not panic unexpectedly. This can happen for example if execution reaches a code that's not complete and has a todo! or unimplemented! panicking placeholder.

Solution

I executed the command:

grep -RI '\(todo\|unimplemented\)!' zebra*/src

and went through each occurrence.

  • Some I was able to remove;
  • Some were changed to unreachable if I figured that there was no code missing but the condition could be reached due a coding mistake;
  • Others were updated to have a reference to a tracking issue nearby.

Closes #2369

Review

@teor2345.

Reviewer Checklist

  • Code implements Specs and Designs
  • Tests for Expected Behaviour
  • Tests for Errors

Follow Up Work

Go through all TODO, FIXME and XXX comments to see if there are any missing pieces that aren't tracked by issues.

@jvff jvff requested a review from teor2345 July 8, 2021 21:32
@zfnd-bot zfnd-bot bot assigned jvff Jul 8, 2021
Comment on lines 168 to 173
impl From<Vec<NoteCommitment>> for NoteCommitmentTree {
fn from(_values: Vec<NoteCommitment>) -> Self {
unimplemented!();
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about merge conflicts here: we probably just want to let PR #2407 deal with this.

Comment on lines 118 to 122
impl From<Vec<NoteCommitment>> for NoteCommitmentTree {
fn from(_values: Vec<NoteCommitment>) -> Self {
unimplemented!();
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about merge conflicts here: we probably just want to let PR #2407 deal with this.

Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This looks good.

There's just a few changes we need to revert to avoid conflicts with other PRs.

I also have a suggestion about cleaning up the transaction verifier struct, but please don't spend too much time on it. It's not as urgent as unexpected panics.

@jvff jvff force-pushed the update-panics-by-todo-and-unimplemented-macros branch from e37e17e to 0d00293 Compare July 9, 2021 01:22
jvff added 3 commits July 9, 2021 01:25
So that it is clear why the panic happened upon initial inspection. Also
include a reference to the mempool epic, so that it's easier to find the
issue that tracks the implementation of the missing code.
Make it easy to find the relevant issue if the panic occurs.
The current implementation works, the commented out code was just a
previous improvement idea, which is now tracked by issue ZcashFoundation#2473.
@jvff jvff force-pushed the update-panics-by-todo-and-unimplemented-macros branch from 0d00293 to 7e6d8bb Compare July 9, 2021 01:25
Copy link
Contributor

@teor2345 teor2345 left a comment

Choose a reason for hiding this comment

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

This is actually a really good outcome, we only have poseidon hash and mempool left to go.

(And all the other tickets in the next few sprints.)

@teor2345 teor2345 enabled auto-merge (squash) July 9, 2021 01:33
@teor2345 teor2345 merged commit 23fe2c2 into ZcashFoundation:main Jul 9, 2021
@jvff jvff deleted the update-panics-by-todo-and-unimplemented-macros branch July 9, 2021 19:29
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.

Security: stop panicking due to NU5 unimplemented!() statements
2 participants