mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-10 15:05:24 -05:00
convert ``OptimismBlockExecution`` error variant into a general purpose error variant (#8100)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@@ -293,8 +293,7 @@ impl InsertBlockErrorKind {
|
||||
BlockExecutionError::CanonicalCommit { .. } |
|
||||
BlockExecutionError::AppendChainDoesntConnect { .. } |
|
||||
BlockExecutionError::UnavailableForTest => false,
|
||||
#[cfg(feature = "optimism")]
|
||||
BlockExecutionError::OptimismBlockExecution(_) => false,
|
||||
BlockExecutionError::Other(_) => false,
|
||||
}
|
||||
}
|
||||
InsertBlockErrorKind::Tree(err) => {
|
||||
|
||||
@@ -16,7 +16,7 @@ pub type RethResult<T> = Result<T, RethError>;
|
||||
/// This enum encapsulates various error types that can occur during blockchain interactions.
|
||||
///
|
||||
/// It allows for structured error handling based on the nature of the encountered issue.
|
||||
#[derive(Debug, thiserror::Error, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RethError {
|
||||
/// Error encountered during block execution.
|
||||
#[error(transparent)]
|
||||
|
||||
@@ -80,7 +80,7 @@ pub enum BlockValidationError {
|
||||
}
|
||||
|
||||
/// BlockExecutor Errors
|
||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Error, Debug)]
|
||||
pub enum BlockExecutionError {
|
||||
/// Validation error, transparently wrapping `BlockValidationError`
|
||||
#[error(transparent)]
|
||||
@@ -118,35 +118,28 @@ pub enum BlockExecutionError {
|
||||
/// Error when fetching latest block state.
|
||||
#[error(transparent)]
|
||||
LatestBlock(#[from] ProviderError),
|
||||
|
||||
/// Optimism Block Executor Errors
|
||||
#[cfg(feature = "optimism")]
|
||||
#[error(transparent)]
|
||||
OptimismBlockExecution(#[from] OptimismBlockExecutionError),
|
||||
}
|
||||
|
||||
/// Optimism Block Executor Errors
|
||||
#[cfg(feature = "optimism")]
|
||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||
pub enum OptimismBlockExecutionError {
|
||||
/// Error when trying to parse L1 block info
|
||||
#[error("could not get L1 block info from L2 block: {message:?}")]
|
||||
L1BlockInfoError {
|
||||
/// The inner error message
|
||||
message: String,
|
||||
},
|
||||
/// Thrown when force deploy of create2deployer code fails.
|
||||
#[error("failed to force create2deployer account code")]
|
||||
ForceCreate2DeployerFail,
|
||||
/// Thrown when a blob transaction is included in a sequencer's block.
|
||||
#[error("blob transaction included in sequencer block")]
|
||||
BlobTransactionRejected,
|
||||
/// Thrown when a database account could not be loaded.
|
||||
#[error("failed to load account {0}")]
|
||||
AccountLoadFailed(reth_primitives::Address),
|
||||
Other(Box<dyn std::error::Error + Send + Sync>),
|
||||
}
|
||||
|
||||
impl BlockExecutionError {
|
||||
/// Create a new `BlockExecutionError::Other` variant.
|
||||
pub fn other<E>(error: E) -> Self
|
||||
where
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
{
|
||||
Self::Other(Box::new(error))
|
||||
}
|
||||
|
||||
/// Returns the inner `BlockValidationError` if the error is a validation error.
|
||||
pub const fn as_validation(&self) -> Option<&BlockValidationError> {
|
||||
match self {
|
||||
Self::Validation(err) => Some(err),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the error is fatal.
|
||||
///
|
||||
/// This represents an unrecoverable database related error.
|
||||
|
||||
Reference in New Issue
Block a user