Skip to content

Commit

Permalink
fix: mark downloaded block as invalid if insertion fails (paradigmxyz…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected authored Jun 6, 2023
1 parent 088c388 commit 9614b46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions crates/interfaces/src/blockchain_tree/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 9614b46

Please sign in to comment.