From 0bd38b803489d2dbf76667951557bc186f60d2c6 Mon Sep 17 00:00:00 2001 From: Vaclav Barta Date: Tue, 5 Nov 2024 15:55:54 +0100 Subject: [PATCH] added BadClassHash error --- crates/pathfinder/src/sync/class_definitions.rs | 2 +- crates/pathfinder/src/sync/error.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/pathfinder/src/sync/class_definitions.rs b/crates/pathfinder/src/sync/class_definitions.rs index 0c24df402e..f885292ace 100644 --- a/crates/pathfinder/src/sync/class_definitions.rs +++ b/crates/pathfinder/src/sync/class_definitions.rs @@ -237,7 +237,7 @@ fn compute_hash_impl(input: ClassWithLayout) -> anyhow::Result { if hash != layout.hash { tracing::debug!(input_hash=%layout.hash, actual_hash=%hash, "Class hash mismatch"); - Err(SyncError2::ClassHashComputationError.into()) + Err(SyncError2::BadClassHash.into()) } else { Ok(Class { block_number, diff --git a/crates/pathfinder/src/sync/error.rs b/crates/pathfinder/src/sync/error.rs index 0e1431a038..625d368aeb 100644 --- a/crates/pathfinder/src/sync/error.rs +++ b/crates/pathfinder/src/sync/error.rs @@ -30,6 +30,8 @@ pub(super) enum SyncError { StateRootMismatch(PeerId), #[error("Transaction hash verification failed")] BadTransactionHash(PeerId), + #[error("Class hash verification failed")] + BadClassHash(PeerId), } impl PartialEq for SyncError { @@ -62,6 +64,7 @@ impl SyncError { } SyncError::StateRootMismatch(x) => PeerData::new(x, SyncError2::StateRootMismatch), SyncError::BadTransactionHash(x) => PeerData::new(x, SyncError2::BadTransactionHash), + SyncError::BadClassHash(x) => PeerData::new(x, SyncError2::BadClassHash), } } @@ -83,6 +86,7 @@ impl SyncError { } SyncError2::StateRootMismatch => SyncError::StateRootMismatch(peer), SyncError2::BadTransactionHash => SyncError::BadTransactionHash(peer), + SyncError2::BadClassHash => SyncError::BadClassHash(peer), other => SyncError::Other(other.into()), } } @@ -142,6 +146,8 @@ pub(super) enum SyncError2 { StateRootMismatch, #[error("Transaction hash verification failed")] BadTransactionHash, + #[error("Class hash verification failed")] + BadClassHash, } impl PartialEq for SyncError2 {