Skip to content

Commit

Permalink
added BadClassHash error
Browse files Browse the repository at this point in the history
  • Loading branch information
vbar committed Nov 5, 2024
1 parent f7198bd commit 0bd38b8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/pathfinder/src/sync/class_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fn compute_hash_impl(input: ClassWithLayout) -> anyhow::Result<Class> {

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,
Expand Down
6 changes: 6 additions & 0 deletions crates/pathfinder/src/sync/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
}
}

Expand All @@ -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()),
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0bd38b8

Please sign in to comment.