diff --git a/crates/consensus/consensus/src/lib.rs b/crates/consensus/consensus/src/lib.rs index 40e4d1ce5871..5dfe466566ad 100644 --- a/crates/consensus/consensus/src/lib.rs +++ b/crates/consensus/consensus/src/lib.rs @@ -127,7 +127,7 @@ pub trait Consensus: Debug + Send + Sync { } /// Consensus Errors -#[derive(Debug, PartialEq, Eq, Clone, derive_more::Display)] +#[derive(Debug, PartialEq, Eq, Clone, derive_more::Display, derive_more::Error)] pub enum ConsensusError { /// Error when the gas used in the header exceeds the gas limit. #[display("block used gas ({gas_used}) is greater than gas limit ({gas_limit})")] @@ -395,16 +395,6 @@ pub enum ConsensusError { }, } -#[cfg(feature = "std")] -impl std::error::Error for ConsensusError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - match self { - Self::InvalidTransaction(err) => std::error::Error::source(err), - _ => Option::None, - } - } -} - impl ConsensusError { /// Returns `true` if the error is a state root error. pub const fn is_state_root_error(&self) -> bool { @@ -419,9 +409,6 @@ impl From for ConsensusError { } /// `HeaderConsensusError` combines a `ConsensusError` with the `SealedHeader` it relates to. -#[derive(derive_more::Display, Debug)] +#[derive(derive_more::Display, derive_more::Error, Debug)] #[display("Consensus error: {_0}, Invalid header: {_1:?}")] pub struct HeaderConsensusError(ConsensusError, SealedHeader); - -#[cfg(feature = "std")] -impl std::error::Error for HeaderConsensusError {}