Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(error): revamp make_canonical error #3899

Merged
merged 11 commits into from
Sep 20, 2023
8 changes: 3 additions & 5 deletions crates/consensus/beacon/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use reth_interfaces::{
BlockStatus, BlockchainTreeEngine, CanonicalOutcome, InsertPayloadOk,
},
consensus::ForkchoiceState,
executor::{BlockExecutionError, BlockValidationError},
executor::BlockValidationError,
p2p::{bodies::client::BodiesClient, headers::client::HeadersClient},
sync::{NetworkSyncUpdater, SyncState},
Error,
Expand Down Expand Up @@ -907,10 +907,8 @@ where

#[allow(clippy::single_match)]
match &error {
Error::Execution(
error @ BlockExecutionError::Validation(BlockValidationError::BlockPreMerge {
..
}),
Error::Canonical(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mattsse I think I spotted the bug, this one had to be modified too. Now it should be good

error @ CanonicalError::Validation(BlockValidationError::BlockPreMerge { .. }),
) => {
return PayloadStatus::from_status(PayloadStatusEnum::Invalid {
validation_error: error.to_string(),
Expand Down
6 changes: 4 additions & 2 deletions crates/interfaces/src/blockchain_tree/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@ pub type CanonicalResult<T> = std::result::Result<T, CanonicalError>;
#[allow(missing_docs)]
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
pub enum CanonicalError {
/// Error originating from validation operations.
#[error(transparent)]
Validation(#[from] BlockValidationError),
/// Error originating from blockchain tree operations.
#[error(transparent)]
BlockchainTree(#[from] BlockchainTreeError),

// === transaction errors ===
/// Error indicating a transaction reverted during execution.
#[error("Transaction error on revert: {inner:?}")]
CanonicalRevert { inner: String },
/// Error indicating a transaction failed to commit during execution.
#[error("Transaction error on commit: {inner:?}")]
CanonicalCommit { inner: String },
}
Expand Down
Loading