Ignore NotFound errors in the syncer (#3131)

This commit is contained in:
teor 2021-12-03 00:28:20 +10:00 committed by GitHub
parent b1acdc61b4
commit a92c431c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 11 deletions

View File

@ -47,9 +47,6 @@ pub enum PeerError {
#[error("Internal services over capacity")]
Overloaded,
// TODO: stop closing connections on these errors (#2107)
// log info or debug logs instead
//
/// We requested data that the peer couldn't find.
#[error("Remote peer could not find items: {0:?}")]
NotFound(Vec<InventoryHash>),

View File

@ -718,6 +718,7 @@ where
/// from the block downloader and verifier stream.
fn should_restart_sync(e: BlockDownloadVerifyError) -> bool {
match e {
// Structural matches
BlockDownloadVerifyError::Invalid(VerifyChainError::Checkpoint(
VerifyCheckpointError::AlreadyVerified { .. },
)) => {
@ -732,19 +733,29 @@ where
tracing::debug!(error = ?e, "block is already in chain, possibly from a previous sync run, continuing");
false
}
BlockDownloadVerifyError::Invalid(VerifyChainError::Block(
VerifyBlockError::Commit(ref source),
)) if format!("{:?}", source).contains("block is already committed to the state") => {
// TODO: improve this by checking the type
// https://github.com/ZcashFoundation/zebra/issues/2908
tracing::debug!(error = ?e, "block is already committed, possibly from a previous sync run, continuing");
false
}
BlockDownloadVerifyError::CancelledDuringDownload
| BlockDownloadVerifyError::CancelledDuringVerification => {
tracing::debug!(error = ?e, "block verification was cancelled, continuing");
false
}
// String matches
BlockDownloadVerifyError::Invalid(VerifyChainError::Block(
VerifyBlockError::Commit(ref source),
)) if format!("{:?}", source).contains("block is already committed to the state") => {
// TODO: improve this by checking the type (#2908)
tracing::debug!(error = ?e, "block is already committed, possibly from a previous sync run, continuing");
false
}
BlockDownloadVerifyError::DownloadFailed(ref source)
if format!("{:?}", source).contains("NotFound") =>
{
// TODO: improve this by checking the type (#2908)
// restart after a certain number of NotFound errors?
tracing::debug!(error = ?e, "block was not found, possibly from a peer that doesn't have the block yet, continuing");
false
}
_ => {
// download_and_verify downcasts errors from the block verifier
// into VerifyChainError, and puts the result inside one of the
@ -757,7 +768,9 @@ where
let err_str = format!("{:?}", e);
if err_str.contains("AlreadyVerified")
|| err_str.contains("AlreadyInChain")
|| err_str.contains("Cancelled")
|| err_str.contains("block is already committed to the state")
|| err_str.contains("NotFound")
{
tracing::error!(?e,
"a BlockDownloadVerifyError that should have been filtered out was detected, \