Description
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 BoxError
s in the syncer's BlockDownloadVerifyError
to concrete types and add them to the match statement in should_restart_sync()
:
zebra/zebrad/src/components/sync.rs
Line 1088 in 0152c86
zebra/zebrad/src/components/sync.rs
Lines 1155 to 1163 in 0152c86
Specifications
Designs
- See Improves block commit error typing (WIP) #5682
- See fix(lint): Fix result_large_err lint by making errors smaller, improve error handling #5757
- we don't need to reorder fields manually to save space, because Rust 1.67 will do this automatically: optimize field ordering by grouping m*2^n-sized fields with equivalently aligned ones rust-lang/rust#102750
- we can still turn unnamed tuple fields into named fields, because that makes debugging easier
Related Work
Follow up to #2890
Metadata
Assignees
Labels
Type
Projects
Status
New