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

Improve VerifyBlockError::Commit typing, so we don't accidentally break syncer error handling #2908

Open
conradoplg opened this issue Oct 19, 2021 · 8 comments
Labels
A-network Area: Network protocol updates or fixes C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement C-tech-debt Category: Code maintainability issues

Comments

@conradoplg
Copy link
Collaborator

conradoplg commented Oct 19, 2021

Motivation

VerifyBlockError::Commit is a wrapper over a BoxError. However, in #2890 a check was added in the should_restart_sync function to ignore Commit errors corresponding to "block is already committed to the state" when deciding whether to reset the sync procedure. That check is fragile since it will break if the string changes.

Change Commit to wrap a specific error type enumeration, and create a specific item for that particular error to be used for matching and filtering it in should_restart_sync.

Currently, this check is implemented by the is_duplicate_request() method, which can't use Commit because it is a BoxError.

There's also a BlockDownloadVerifyError::Invalid error that comes from the chain verifier and a BlockDownloadVerifyError::DownloadFailed from the network service.

We should downcast all BoxErrors in the syncer's BlockDownloadVerifyError to concrete types and add them to the match statement in should_restart_sync():

fn should_restart_sync(e: &BlockDownloadVerifyError) -> bool {

// TODO: add a proper test and remove this
// https://github.com/ZcashFoundation/zebra/issues/2909
let err_str = format!("{e:?}");
if err_str.contains("AlreadyVerified")
|| err_str.contains("AlreadyInState")
|| err_str.contains("block is already committed to the state")
|| err_str.contains("block has already been sent to be committed to the state")
|| err_str.contains("NotFound")
{

Specifications

Designs

Related Work

Follow up to #2890

@conradoplg conradoplg added C-enhancement Category: This is an improvement S-needs-triage Status: A bug report needs triage labels Oct 19, 2021
@mpguerra mpguerra added C-cleanup Category: This is a cleanup P-Medium labels Nov 23, 2021
@mpguerra
Copy link
Contributor

@teor2345
Copy link
Contributor

We're de-prioritizing network changes, and network-related changes.

@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 25, 2022
@teor2345 teor2345 reopened this Nov 2, 2022
@teor2345
Copy link
Contributor

teor2345 commented Nov 2, 2022

This is needed to do #5487

@teor2345 teor2345 changed the title Improve VerifyBlockError::Commit typing Improve VerifyBlockError::Commit typing, so we don't accidentally break syncer error handling Nov 2, 2022
@arya2 arya2 self-assigned this Nov 17, 2022
@arya2 arya2 removed their assignment Nov 21, 2022
@teor2345
Copy link
Contributor

teor2345 commented Dec 1, 2022

I added this as a TODO in the source code, so we can do it if we are rewriting that code for other reasons.

@teor2345 teor2345 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 1, 2022
@arya2 arya2 reopened this Mar 25, 2023
@arya2 arya2 added the C-tech-debt Category: Code maintainability issues label Mar 25, 2023
@teor2345
Copy link
Contributor

@arya2 just checking that this isn't an audit issue?

@mpguerra we've tried to do this a few times and it's been tricky due to Rust language limitations. Some of those might have been fixed recently, but I still think we should time-box this task to 1 day in total. (And maybe one or two reviews.)

This code is also hard to test, it's only really tested by our integration tests. (And not all our errors are covered by those tests.) So it will need careful review or extra unit tests to avoid introducing new panics.

@mpguerra
Copy link
Contributor

We haven't scheduled this work yet and I think it can probably wait for discussion until our next gardening sync. I'll add it to the agenda.

@arya2
Copy link
Contributor

arya2 commented Mar 28, 2023

@arya2 just checking that this isn't an audit issue?

Nothing in this issue has been brought up in the audit so far.

@teor2345 teor2345 added the A-network Area: Network protocol updates or fixes label Oct 30, 2023
@arya2 arya2 mentioned this issue Jun 28, 2024
43 tasks
@arya2
Copy link
Contributor

arya2 commented Sep 12, 2024

@daira may want to take this one on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-cleanup Category: This is a cleanup C-enhancement Category: This is an improvement C-tech-debt Category: Code maintainability issues
Projects
Status: New
Development

No branches or pull requests

4 participants