fix(engine): fail on canonical errors (#2565)

This commit is contained in:
Roman Krasiuk
2023-05-04 22:49:05 +03:00
committed by GitHub
parent 5605ab2a04
commit 70bcd76032
2 changed files with 14 additions and 0 deletions

View File

@ -360,6 +360,13 @@ where
PayloadStatus::new(PayloadStatusEnum::Valid, Some(state.head_block_hash))
}
Err(error) => {
if let Error::Execution(ref err) = error {
if err.is_fatal() {
tracing::error!(target: "consensus::engine", ?err, "Encountered fatal error");
return Err(BeaconEngineError::Common(error))
}
}
self.on_failed_canonical_forkchoice_update(&state, error, is_first_forkchoice)
}
}

View File

@ -63,3 +63,10 @@ pub enum Error {
#[error("Missing total difficulty")]
MissingTotalDifficulty { hash: H256 },
}
impl Error {
/// Returns `true` if the error is fatal.
pub fn is_fatal(&self) -> bool {
matches!(self, Self::CanonicalCommit { .. } | Self::CanonicalRevert { .. })
}
}