Skip to content

Commit

Permalink
fix(engine): fail on canonical errors (paradigmxyz#2565)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk authored May 4, 2023
1 parent 5605ab2 commit 70bcd76
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/interfaces/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { .. })
}
}

0 comments on commit 70bcd76

Please sign in to comment.