chore(sync): add block number to body validation error (#7918)

Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Emilia Hane
2024-04-26 18:39:35 +02:00
committed by GitHub
parent 51bdc6afe8
commit 704b3e3ac4
2 changed files with 10 additions and 3 deletions

View File

@ -158,10 +158,12 @@ pub enum DownloadError {
/* ==================== BODIES ERRORS ==================== */
/// Block validation failed
#[error("failed to validate body for header {hash}: {error}")]
#[error("failed to validate body for header {hash}, block number {number}: {error}")]
BodyValidation {
/// Hash of header failing validation
/// Hash of the block failing validation
hash: B256,
/// Number of the block failing validation
number: u64,
/// The details of validation failure
#[source]
error: Box<ConsensusError>,

View File

@ -184,8 +184,13 @@ where
if let Err(error) = self.consensus.validate_block(&block) {
// Body is invalid, put the header back and return an error
let hash = block.hash();
let number = block.number;
self.pending_headers.push_front(block.header);
return Err(DownloadError::BodyValidation { hash, error: Box::new(error) })
return Err(DownloadError::BodyValidation {
hash,
number,
error: Box::new(error),
})
}
self.buffer.push(BlockResponse::Full(block));