From 55bf29e6d2ee51c84a12a371c9f79d8e07b8d1db Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Sun, 29 Sep 2024 18:47:48 +0200 Subject: [PATCH] use `core::error::Error` (#11317) --- crates/blockchain-tree-api/src/error.rs | 12 +++---- crates/consensus/beacon/src/engine/error.rs | 8 ++--- .../consensus/beacon/src/engine/hooks/mod.rs | 2 +- crates/errors/src/error.rs | 4 +-- crates/evm/execution-errors/src/lib.rs | 36 +++++++++---------- crates/evm/execution-errors/src/trie.rs | 34 ++++++++---------- crates/fs-util/src/lib.rs | 2 +- crates/payload/primitives/src/error.rs | 8 ++--- crates/payload/primitives/src/traits.rs | 4 +-- crates/primitives/src/transaction/error.rs | 6 ++-- crates/rpc/ipc/src/client/mod.rs | 2 +- crates/rpc/ipc/src/server/connection.rs | 2 +- crates/rpc/ipc/src/server/mod.rs | 12 +++---- crates/rpc/rpc-engine-api/src/error.rs | 2 +- crates/rpc/rpc-eth-types/src/error.rs | 4 +-- crates/rpc/rpc-types/src/eth/error.rs | 2 +- crates/stages/api/src/error.rs | 4 +-- crates/stages/stages/src/test_utils/runner.rs | 2 +- crates/storage/errors/src/db.rs | 10 +++--- crates/storage/errors/src/lockfile.rs | 3 +- crates/storage/errors/src/provider.rs | 13 ++++--- crates/storage/nippy-jar/src/error.rs | 2 +- crates/transaction-pool/src/blobstore/mod.rs | 2 +- crates/transaction-pool/src/error.rs | 13 ++++--- crates/transaction-pool/src/validate/mod.rs | 2 +- 25 files changed, 90 insertions(+), 101 deletions(-) diff --git a/crates/blockchain-tree-api/src/error.rs b/crates/blockchain-tree-api/src/error.rs index 155e57c5e..4dd42c889 100644 --- a/crates/blockchain-tree-api/src/error.rs +++ b/crates/blockchain-tree-api/src/error.rs @@ -194,8 +194,8 @@ impl std::fmt::Debug for InsertBlockErrorData { } } -impl std::error::Error for InsertBlockErrorData { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for InsertBlockErrorData { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { Some(&self.kind) } } @@ -240,8 +240,8 @@ impl std::fmt::Debug for InsertBlockErrorDataTwo { } } -impl std::error::Error for InsertBlockErrorDataTwo { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for InsertBlockErrorDataTwo { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { Some(&self.kind) } } @@ -335,7 +335,7 @@ pub enum InsertBlockErrorKindTwo { Provider(#[from] ProviderError), /// Other errors. #[error(transparent)] - Other(#[from] Box), + Other(#[from] Box), } impl InsertBlockErrorKindTwo { @@ -425,7 +425,7 @@ pub enum InsertBlockErrorKind { Provider(#[from] ProviderError), /// An internal error occurred, like interacting with the database. #[error(transparent)] - Internal(#[from] Box), + Internal(#[from] Box), /// Canonical error. #[error(transparent)] Canonical(#[from] CanonicalError), diff --git a/crates/consensus/beacon/src/engine/error.rs b/crates/consensus/beacon/src/engine/error.rs index 4f58b7300..5fc6df2b8 100644 --- a/crates/consensus/beacon/src/engine/error.rs +++ b/crates/consensus/beacon/src/engine/error.rs @@ -57,12 +57,12 @@ pub enum BeaconForkChoiceUpdateError { EngineUnavailable, /// An internal error occurred, not necessarily related to the update. #[error(transparent)] - Internal(Box), + Internal(Box), } impl BeaconForkChoiceUpdateError { /// Create a new internal error. - pub fn internal(e: E) -> Self { + pub fn internal(e: E) -> Self { Self::Internal(Box::new(e)) } } @@ -89,12 +89,12 @@ pub enum BeaconOnNewPayloadError { EngineUnavailable, /// An internal error occurred, not necessarily related to the payload. #[error(transparent)] - Internal(Box), + Internal(Box), } impl BeaconOnNewPayloadError { /// Create a new internal error. - pub fn internal(e: E) -> Self { + pub fn internal(e: E) -> Self { Self::Internal(Box::new(e)) } } diff --git a/crates/consensus/beacon/src/engine/hooks/mod.rs b/crates/consensus/beacon/src/engine/hooks/mod.rs index b5e6ea61e..828a6f968 100644 --- a/crates/consensus/beacon/src/engine/hooks/mod.rs +++ b/crates/consensus/beacon/src/engine/hooks/mod.rs @@ -104,7 +104,7 @@ pub enum EngineHookError { Common(#[from] RethError), /// An internal error occurred. #[error(transparent)] - Internal(#[from] Box), + Internal(#[from] Box), } /// Level of database access the hook needs for execution. diff --git a/crates/errors/src/error.rs b/crates/errors/src/error.rs index e74d58275..869d57327 100644 --- a/crates/errors/src/error.rs +++ b/crates/errors/src/error.rs @@ -37,14 +37,14 @@ pub enum RethError { /// Any other error. #[error(transparent)] - Other(Box), + Other(Box), } impl RethError { /// Create a new `RethError` from a given error. pub fn other(error: E) -> Self where - E: std::error::Error + Send + Sync + 'static, + E: core::error::Error + Send + Sync + 'static, { Self::Other(Box::new(error)) } diff --git a/crates/evm/execution-errors/src/lib.rs b/crates/evm/execution-errors/src/lib.rs index 1113cc83d..4dbbfb7ab 100644 --- a/crates/evm/execution-errors/src/lib.rs +++ b/crates/evm/execution-errors/src/lib.rs @@ -125,12 +125,11 @@ impl From for BlockValidationError { } } -#[cfg(feature = "std")] -impl std::error::Error for BlockValidationError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for BlockValidationError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::EVM { error, .. } => std::error::Error::source(error), - Self::StateRoot(source) => std::error::Error::source(source), + Self::EVM { error, .. } => core::error::Error::source(error), + Self::StateRoot(source) => core::error::Error::source(source), _ => Option::None, } } @@ -153,7 +152,7 @@ impl BlockExecutionError { #[cfg(feature = "std")] pub fn other(error: E) -> Self where - E: std::error::Error + Send + Sync + 'static, + E: core::error::Error + Send + Sync + 'static, { Self::Internal(InternalBlockExecutionError::other(error)) } @@ -185,13 +184,12 @@ impl From for BlockExecutionError { } } -#[cfg(feature = "std")] -impl std::error::Error for BlockExecutionError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for BlockExecutionError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Validation(source) => std::error::Error::source(source), - Self::Consensus(source) => std::error::Error::source(source), - Self::Internal(source) => std::error::Error::source(source), + Self::Validation(source) => core::error::Error::source(source), + Self::Consensus(source) => core::error::Error::source(source), + Self::Internal(source) => core::error::Error::source(source), } } } @@ -216,8 +214,7 @@ pub enum InternalBlockExecutionError { #[from] LatestBlock(ProviderError), /// Arbitrary Block Executor Errors - #[cfg(feature = "std")] - Other(Box), + Other(Box), } impl InternalBlockExecutionError { @@ -225,7 +222,7 @@ impl InternalBlockExecutionError { #[cfg(feature = "std")] pub fn other(error: E) -> Self where - E: std::error::Error + Send + Sync + 'static, + E: core::error::Error + Send + Sync + 'static, { Self::Other(Box::new(error)) } @@ -237,12 +234,11 @@ impl InternalBlockExecutionError { } } -#[cfg(feature = "std")] -impl std::error::Error for InternalBlockExecutionError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for InternalBlockExecutionError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Pruning(source) => std::error::Error::source(source), - Self::LatestBlock(source) => std::error::Error::source(source), + Self::Pruning(source) => core::error::Error::source(source), + Self::LatestBlock(source) => core::error::Error::source(source), _ => Option::None, } } diff --git a/crates/evm/execution-errors/src/trie.rs b/crates/evm/execution-errors/src/trie.rs index c85819ee7..9e4b16d8d 100644 --- a/crates/evm/execution-errors/src/trie.rs +++ b/crates/evm/execution-errors/src/trie.rs @@ -15,12 +15,11 @@ pub enum StateRootError { StorageRootError(StorageRootError), } -#[cfg(feature = "std")] -impl std::error::Error for StateRootError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for StateRootError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Database(source) => std::error::Error::source(source), - Self::StorageRootError(source) => std::error::Error::source(source), + Self::Database(source) => core::error::Error::source(source), + Self::StorageRootError(source) => core::error::Error::source(source), } } } @@ -49,11 +48,10 @@ impl From for DatabaseError { } } -#[cfg(feature = "std")] -impl std::error::Error for StorageRootError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for StorageRootError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Database(source) => std::error::Error::source(source), + Self::Database(source) => core::error::Error::source(source), } } } @@ -76,12 +74,11 @@ impl From for ProviderError { } } -#[cfg(feature = "std")] -impl std::error::Error for StateProofError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for StateProofError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Database(source) => std::error::Error::source(source), - Self::Rlp(source) => std::error::Error::source(source), + Self::Database(source) => core::error::Error::source(source), + Self::Rlp(source) => core::error::Error::source(source), } } } @@ -112,12 +109,11 @@ impl From for ProviderError { } } -#[cfg(feature = "std")] -impl std::error::Error for TrieWitnessError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for TrieWitnessError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Proof(source) => std::error::Error::source(source), - Self::Rlp(source) => std::error::Error::source(source), + Self::Proof(source) => core::error::Error::source(source), + Self::Rlp(source) => core::error::Error::source(source), _ => Option::None, } } diff --git a/crates/fs-util/src/lib.rs b/crates/fs-util/src/lib.rs index f77632cc8..0cfcf0453 100644 --- a/crates/fs-util/src/lib.rs +++ b/crates/fs-util/src/lib.rs @@ -305,7 +305,7 @@ pub fn write_json_file(path: &Path, obj: &T) -> Result<()> { pub fn atomic_write_file(file_path: &Path, write_fn: F) -> Result<()> where F: FnOnce(&mut File) -> std::result::Result<(), E>, - E: Into>, + E: Into>, { let mut tmp_path = file_path.to_path_buf(); tmp_path.set_extension("tmp"); diff --git a/crates/payload/primitives/src/error.rs b/crates/payload/primitives/src/error.rs index 0b8113f67..00df9e8d2 100644 --- a/crates/payload/primitives/src/error.rs +++ b/crates/payload/primitives/src/error.rs @@ -35,14 +35,14 @@ pub enum PayloadBuilderError { WithdrawalsBeforeShanghai, /// Any other payload building errors. #[error(transparent)] - Other(Box), + Other(Box), } impl PayloadBuilderError { /// Create a new error from a boxed error. pub fn other(error: E) -> Self where - E: std::error::Error + Send + Sync + 'static, + E: core::error::Error + Send + Sync + 'static, { Self::Other(Box::new(error)) } @@ -84,7 +84,7 @@ pub enum EngineObjectValidationError { UnsupportedFork, /// Another type of error that is not covered by the above variants. #[error("Invalid params: {0}")] - InvalidParams(#[from] Box), + InvalidParams(#[from] Box), } /// Thrown when validating an execution payload OR payload attributes fails due to: @@ -117,7 +117,7 @@ impl EngineObjectValidationError { /// Creates an instance of the `InvalidParams` variant with the given error. pub fn invalid_params(error: E) -> Self where - E: std::error::Error + Send + Sync + 'static, + E: core::error::Error + Send + Sync + 'static, { Self::InvalidParams(Box::new(error)) } diff --git a/crates/payload/primitives/src/traits.rs b/crates/payload/primitives/src/traits.rs index 9551b75a7..b0647691f 100644 --- a/crates/payload/primitives/src/traits.rs +++ b/crates/payload/primitives/src/traits.rs @@ -80,7 +80,7 @@ pub trait PayloadBuilderAttributes: Send + Sync + std::fmt::Debug { /// [`PayloadBuilderAttributes::try_new`]. type RpcPayloadAttributes; /// The error type used in [`PayloadBuilderAttributes::try_new`]. - type Error: std::error::Error; + type Error: core::error::Error; /// Creates a new payload builder for the given parent block and the attributes. /// @@ -164,7 +164,7 @@ pub trait PayloadAttributesBuilder: std::fmt::Debug + Send + Sync + 'static { /// The payload attributes type returned by the builder. type PayloadAttributes: PayloadAttributes; /// The error type returned by [`PayloadAttributesBuilder::build`]. - type Error: std::error::Error + Send + Sync; + type Error: core::error::Error + Send + Sync; /// Return a new payload attribute from the builder. fn build(&self) -> Result; diff --git a/crates/primitives/src/transaction/error.rs b/crates/primitives/src/transaction/error.rs index de4efa4d8..0c53c2c8d 100644 --- a/crates/primitives/src/transaction/error.rs +++ b/crates/primitives/src/transaction/error.rs @@ -61,8 +61,7 @@ pub enum InvalidTransactionError { SignerAccountHasBytecode, } -#[cfg(feature = "std")] -impl std::error::Error for InvalidTransactionError {} +impl core::error::Error for InvalidTransactionError {} /// Represents error variants that can happen when trying to convert a transaction to /// [`PooledTransactionsElement`](crate::PooledTransactionsElement) @@ -87,5 +86,4 @@ pub enum TryFromRecoveredTransactionError { BlobSidecarMissing, } -#[cfg(feature = "std")] -impl std::error::Error for TryFromRecoveredTransactionError {} +impl core::error::Error for TryFromRecoveredTransactionError {} diff --git a/crates/rpc/ipc/src/client/mod.rs b/crates/rpc/ipc/src/client/mod.rs index e8eff9c8f..8f2fe0255 100644 --- a/crates/rpc/ipc/src/client/mod.rs +++ b/crates/rpc/ipc/src/client/mod.rs @@ -90,7 +90,7 @@ impl IpcClientBuilder { /// use jsonrpsee::{core::client::ClientT, rpc_params}; /// use reth_ipc::client::IpcClientBuilder; /// - /// # async fn run_client() -> Result<(), Box> { + /// # async fn run_client() -> Result<(), Box> { /// let client = IpcClientBuilder::default().build("/tmp/my-uds").await?; /// let response: String = client.request("say_hello", rpc_params![]).await?; /// # Ok(()) } diff --git a/crates/rpc/ipc/src/server/connection.rs b/crates/rpc/ipc/src/server/connection.rs index 5e7497cb9..aaf6731d0 100644 --- a/crates/rpc/ipc/src/server/connection.rs +++ b/crates/rpc/ipc/src/server/connection.rs @@ -82,7 +82,7 @@ impl IpcConnDriver { impl Future for IpcConnDriver where S: Service> + Send + 'static, - S::Error: Into>, + S::Error: Into>, S::Future: Send + Unpin, T: AsyncRead + AsyncWrite + Unpin + Send + 'static, { diff --git a/crates/rpc/ipc/src/server/mod.rs b/crates/rpc/ipc/src/server/mod.rs index 168819754..a02d3ca32 100644 --- a/crates/rpc/ipc/src/server/mod.rs +++ b/crates/rpc/ipc/src/server/mod.rs @@ -72,7 +72,7 @@ where Service: Service< String, Response = Option, - Error = Box, + Error = Box, Future: Send + Unpin, > + Send, > + Send @@ -86,7 +86,7 @@ where /// ``` /// use jsonrpsee::RpcModule; /// use reth_ipc::server::Builder; - /// async fn run_server() -> Result<(), Box> { + /// async fn run_server() -> Result<(), Box> { /// let server = Builder::default().build("/tmp/my-uds".into()); /// let mut module = RpcModule::new(()); /// module.register_method("say_hello", |_, _, _| "lo")?; @@ -366,7 +366,7 @@ where /// response will be emitted via the `method_sink`. type Response = Option; - type Error = Box; + type Error = Box; type Future = Pin> + Send>>; @@ -441,7 +441,7 @@ fn process_connection<'b, RpcMiddleware, HttpMiddleware>( + Service< String, Response = Option, - Error = Box, + Error = Box, >, <>>::Service as Service>::Future: Send + Unpin, @@ -496,7 +496,7 @@ async fn to_ipc_service( rx: mpsc::Receiver, ) where S: Service> + Send + 'static, - S::Error: Into>, + S::Error: Into>, S::Future: Send + Unpin, T: AsyncRead + AsyncWrite + Unpin + Send + 'static, { @@ -823,7 +823,7 @@ mod tests { async fn pipe_from_stream_with_bounded_buffer( pending: PendingSubscriptionSink, stream: BroadcastStream, - ) -> Result<(), Box> { + ) -> Result<(), Box> { let sink = pending.accept().await.unwrap(); let closed = sink.closed(); diff --git a/crates/rpc/rpc-engine-api/src/error.rs b/crates/rpc/rpc-engine-api/src/error.rs index 564919161..677bd2fb2 100644 --- a/crates/rpc/rpc-engine-api/src/error.rs +++ b/crates/rpc/rpc-engine-api/src/error.rs @@ -84,7 +84,7 @@ pub enum EngineApiError { NewPayload(#[from] BeaconOnNewPayloadError), /// Encountered an internal error. #[error(transparent)] - Internal(#[from] Box), + Internal(#[from] Box), /// Fetching the payload failed #[error(transparent)] GetPayloadError(#[from] PayloadBuilderError), diff --git a/crates/rpc/rpc-eth-types/src/error.rs b/crates/rpc/rpc-eth-types/src/error.rs index 90aec2127..8387439f6 100644 --- a/crates/rpc/rpc-eth-types/src/error.rs +++ b/crates/rpc/rpc-eth-types/src/error.rs @@ -591,7 +591,7 @@ impl std::fmt::Display for RevertError { } } -impl std::error::Error for RevertError {} +impl core::error::Error for RevertError {} /// A helper error type that's mainly used to mirror `geth` Txpool's error messages #[derive(Debug, thiserror::Error)] @@ -643,7 +643,7 @@ pub enum RpcPoolError { AddressAlreadyReserved, /// Other unspecified error #[error(transparent)] - Other(Box), + Other(Box), } impl From for jsonrpsee_types::error::ErrorObject<'static> { diff --git a/crates/rpc/rpc-types/src/eth/error.rs b/crates/rpc/rpc-types/src/eth/error.rs index 9212b2f17..71b71b04a 100644 --- a/crates/rpc/rpc-types/src/eth/error.rs +++ b/crates/rpc/rpc-types/src/eth/error.rs @@ -2,7 +2,7 @@ /// A trait to convert an error to an RPC error. #[cfg(feature = "jsonrpsee-types")] -pub trait ToRpcError: std::error::Error + Send + Sync + 'static { +pub trait ToRpcError: core::error::Error + Send + Sync + 'static { /// Converts the error to a JSON-RPC error object. fn to_rpc_error(&self) -> jsonrpsee_types::ErrorObject<'static>; } diff --git a/crates/stages/api/src/error.rs b/crates/stages/api/src/error.rs index 1941375d2..4285b9720 100644 --- a/crates/stages/api/src/error.rs +++ b/crates/stages/api/src/error.rs @@ -133,12 +133,12 @@ pub enum StageError { /// These types of errors are caught by the [Pipeline][crate::Pipeline] and trigger a restart /// of the stage. #[error(transparent)] - Recoverable(Box), + Recoverable(Box), /// The stage encountered a fatal error. /// /// These types of errors stop the pipeline. #[error(transparent)] - Fatal(Box), + Fatal(Box), } impl StageError { diff --git a/crates/stages/stages/src/test_utils/runner.rs b/crates/stages/stages/src/test_utils/runner.rs index d2c4e68be..26f245c13 100644 --- a/crates/stages/stages/src/test_utils/runner.rs +++ b/crates/stages/stages/src/test_utils/runner.rs @@ -13,7 +13,7 @@ pub(crate) enum TestRunnerError { #[error(transparent)] Database(#[from] DatabaseError), #[error(transparent)] - Internal(#[from] Box), + Internal(#[from] Box), #[error(transparent)] Provider(#[from] ProviderError), } diff --git a/crates/storage/errors/src/db.rs b/crates/storage/errors/src/db.rs index f27dacdc3..22efbb1fb 100644 --- a/crates/storage/errors/src/db.rs +++ b/crates/storage/errors/src/db.rs @@ -50,11 +50,10 @@ pub enum DatabaseError { Other(String), } -#[cfg(feature = "std")] -impl std::error::Error for DatabaseError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for DatabaseError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Write(err) => std::error::Error::source(err), + Self::Write(err) => core::error::Error::source(err), _ => Option::None, } } @@ -113,8 +112,7 @@ impl fmt::Display for DatabaseWriteError { } } -#[cfg(feature = "std")] -impl std::error::Error for DatabaseWriteError {} +impl core::error::Error for DatabaseWriteError {} /// Database write operation type. #[derive(Clone, Copy, Debug, PartialEq, Eq)] diff --git a/crates/storage/errors/src/lockfile.rs b/crates/storage/errors/src/lockfile.rs index 667197f57..9a3af4ba3 100644 --- a/crates/storage/errors/src/lockfile.rs +++ b/crates/storage/errors/src/lockfile.rs @@ -12,8 +12,7 @@ pub enum StorageLockError { Other(String), } -#[cfg(feature = "std")] -impl std::error::Error for StorageLockError {} +impl core::error::Error for StorageLockError {} /// TODO: turn into variant once `ProviderError` impl From for StorageLockError { diff --git a/crates/storage/errors/src/provider.rs b/crates/storage/errors/src/provider.rs index f0ecfbea8..d60a2adb9 100644 --- a/crates/storage/errors/src/provider.rs +++ b/crates/storage/errors/src/provider.rs @@ -172,14 +172,13 @@ impl From for ProviderError { } } -#[cfg(feature = "std")] -impl std::error::Error for ProviderError { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for ProviderError { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { match self { - Self::Database(source) => std::error::Error::source(source), - Self::Rlp(source) => std::error::Error::source(source), - Self::StorageLockError(source) => std::error::Error::source(source), - Self::UnifiedStorageWriterError(source) => std::error::Error::source(source), + Self::Database(source) => core::error::Error::source(source), + Self::Rlp(source) => core::error::Error::source(source), + Self::StorageLockError(source) => core::error::Error::source(source), + Self::UnifiedStorageWriterError(source) => core::error::Error::source(source), _ => Option::None, } } diff --git a/crates/storage/nippy-jar/src/error.rs b/crates/storage/nippy-jar/src/error.rs index ffeb5f393..fc096cf84 100644 --- a/crates/storage/nippy-jar/src/error.rs +++ b/crates/storage/nippy-jar/src/error.rs @@ -5,7 +5,7 @@ use thiserror::Error; #[derive(Error, Debug)] pub enum NippyJarError { #[error(transparent)] - Internal(#[from] Box), + Internal(#[from] Box), #[error(transparent)] Disconnect(#[from] std::io::Error), #[error(transparent)] diff --git a/crates/transaction-pool/src/blobstore/mod.rs b/crates/transaction-pool/src/blobstore/mod.rs index d127b3e8e..ee98e3eed 100644 --- a/crates/transaction-pool/src/blobstore/mod.rs +++ b/crates/transaction-pool/src/blobstore/mod.rs @@ -90,7 +90,7 @@ pub enum BlobStoreError { DecodeError(#[from] alloy_rlp::Error), /// Other implementation specific error. #[error(transparent)] - Other(Box), + Other(Box), } /// Keeps track of the size of the blob store. diff --git a/crates/transaction-pool/src/error.rs b/crates/transaction-pool/src/error.rs index e5142e18a..a4766a89d 100644 --- a/crates/transaction-pool/src/error.rs +++ b/crates/transaction-pool/src/error.rs @@ -10,7 +10,7 @@ pub type PoolResult = Result; /// /// For example during validation /// [`TransactionValidator::validate_transaction`](crate::validate::TransactionValidator::validate_transaction) -pub trait PoolTransactionError: std::error::Error + Send + Sync { +pub trait PoolTransactionError: core::error::Error + Send + Sync { /// Returns `true` if the error was caused by a transaction that is considered bad in the /// context of the transaction pool and warrants peer penalization. /// @@ -19,8 +19,8 @@ pub trait PoolTransactionError: std::error::Error + Send + Sync { } // Needed for `#[error(transparent)]` -impl std::error::Error for Box { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { +impl core::error::Error for Box { + fn source(&self) -> Option<&(dyn core::error::Error + 'static)> { (**self).source() } } @@ -63,7 +63,7 @@ pub enum PoolErrorKind { /// Any other error that occurred while inserting/validating a transaction. e.g. IO database /// error #[error(transparent)] - Other(#[from] Box), + Other(#[from] Box), } // === impl PoolError === @@ -75,7 +75,10 @@ impl PoolError { } /// Creates a new pool error with the `Other` kind. - pub fn other(hash: TxHash, error: impl Into>) -> Self { + pub fn other( + hash: TxHash, + error: impl Into>, + ) -> Self { Self { hash, kind: PoolErrorKind::Other(error.into()) } } diff --git a/crates/transaction-pool/src/validate/mod.rs b/crates/transaction-pool/src/validate/mod.rs index 80aee0afe..b8fe7cbb1 100644 --- a/crates/transaction-pool/src/validate/mod.rs +++ b/crates/transaction-pool/src/validate/mod.rs @@ -51,7 +51,7 @@ pub enum TransactionValidationOutcome { /// this transaction from ever becoming valid. Invalid(T, InvalidPoolTransactionError), /// An error occurred while trying to validate the transaction - Error(TxHash, Box), + Error(TxHash, Box), } impl TransactionValidationOutcome {