mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: support no_std for reth-execution-errors (#8729)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -16,4 +16,9 @@ reth-consensus.workspace = true
|
||||
reth-primitives.workspace = true
|
||||
reth-storage-errors.workspace = true
|
||||
reth-prune-types.workspace = true
|
||||
thiserror.workspace = true
|
||||
thiserror-no-std = { workspace = true, default-features = false }
|
||||
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["thiserror-no-std/std"]
|
||||
@ -7,19 +7,24 @@
|
||||
)]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
|
||||
use reth_consensus::ConsensusError;
|
||||
use reth_primitives::{revm_primitives::EVMError, BlockNumHash, B256};
|
||||
use reth_prune_types::PruneSegmentError;
|
||||
use reth_storage_errors::provider::ProviderError;
|
||||
use std::fmt::Display;
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{boxed::Box, string::String};
|
||||
|
||||
pub mod trie;
|
||||
pub use trie::{StateRootError, StorageRootError};
|
||||
|
||||
/// Transaction validation errors
|
||||
#[derive(Error, Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(thiserror_no_std::Error, Debug, Clone, PartialEq, Eq)]
|
||||
pub enum BlockValidationError {
|
||||
/// EVM error with transaction hash and message
|
||||
#[error("EVM reported invalid transaction ({hash}): {error}")]
|
||||
@ -99,7 +104,7 @@ pub enum BlockValidationError {
|
||||
}
|
||||
|
||||
/// `BlockExecutor` Errors
|
||||
#[derive(Error, Debug)]
|
||||
#[derive(thiserror_no_std::Error, Debug)]
|
||||
pub enum BlockExecutionError {
|
||||
/// Validation error, transparently wrapping `BlockValidationError`
|
||||
#[error(transparent)]
|
||||
@ -119,7 +124,7 @@ pub enum BlockExecutionError {
|
||||
/// Transaction error on commit with inner details
|
||||
#[error("transaction error on commit: {inner}")]
|
||||
CanonicalCommit {
|
||||
/// The inner error message
|
||||
/// The inner error message.
|
||||
inner: String,
|
||||
},
|
||||
/// Error when appending chain on fork is not possible
|
||||
@ -136,12 +141,14 @@ pub enum BlockExecutionError {
|
||||
#[error(transparent)]
|
||||
LatestBlock(#[from] ProviderError),
|
||||
/// Arbitrary Block Executor Errors
|
||||
#[cfg(feature = "std")]
|
||||
#[error(transparent)]
|
||||
Other(Box<dyn std::error::Error + Send + Sync>),
|
||||
}
|
||||
|
||||
impl BlockExecutionError {
|
||||
/// Create a new `BlockExecutionError::Other` variant.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn other<E>(error: E) -> Self
|
||||
where
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
@ -150,7 +157,8 @@ impl BlockExecutionError {
|
||||
}
|
||||
|
||||
/// Create a new [`BlockExecutionError::Other`] from a given message.
|
||||
pub fn msg(msg: impl Display) -> Self {
|
||||
#[cfg(feature = "std")]
|
||||
pub fn msg(msg: impl std::fmt::Display) -> Self {
|
||||
Self::Other(msg.to_string().into())
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
//! Errors when computing the state root.
|
||||
|
||||
use reth_storage_errors::db::DatabaseError;
|
||||
use thiserror::Error;
|
||||
use thiserror_no_std::Error;
|
||||
|
||||
/// State root errors.
|
||||
#[derive(Error, Debug, PartialEq, Eq, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user