diff --git a/crates/consensus/beacon/src/engine/mod.rs b/crates/consensus/beacon/src/engine/mod.rs index a394d91af0..7d6333e216 100644 --- a/crates/consensus/beacon/src/engine/mod.rs +++ b/crates/consensus/beacon/src/engine/mod.rs @@ -1009,6 +1009,10 @@ where } Err(err) => { debug!(target: "consensus::engine", ?err, "Failed to insert downloaded block"); + if !matches!(err.kind(), InsertBlockErrorKind::Internal(_)) { + // non-internal error kinds occurr if the payload is invalid + self.invalid_headers.insert(err.into_block().header); + } } } } diff --git a/crates/interfaces/src/blockchain_tree/error.rs b/crates/interfaces/src/blockchain_tree/error.rs index 2f48b91dfc..36012996b6 100644 --- a/crates/interfaces/src/blockchain_tree/error.rs +++ b/crates/interfaces/src/blockchain_tree/error.rs @@ -65,6 +65,12 @@ impl InsertBlockError { Self::new(block, InsertBlockErrorKind::Execution(error)) } + /// Consumes the error and returns the block that resulted in the error + #[inline] + pub fn into_block(self) -> SealedBlock { + self.inner.block + } + /// Returns the error kind #[inline] pub fn kind(&self) -> &InsertBlockErrorKind {