diff --git a/Cargo.lock b/Cargo.lock index c1f28262e598..2539757ac28f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8032,7 +8032,6 @@ dependencies = [ "serde", "serde_json", "test-fuzz", - "thiserror-no-std", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c0d952fbb4ca..ced891d76db1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -340,7 +340,7 @@ reth-payload-builder = { path = "crates/payload/builder" } reth-payload-primitives = { path = "crates/payload/primitives" } reth-payload-validator = { path = "crates/payload/validator" } reth-primitives = { path = "crates/primitives" } -reth-primitives-traits = { path = "crates/primitives-traits" } +reth-primitives-traits = { path = "crates/primitives-traits", default-features = false } reth-provider = { path = "crates/storage/provider" } reth-prune = { path = "crates/prune/prune" } reth-prune-types = { path = "crates/prune/types" } diff --git a/crates/optimism/cli/Cargo.toml b/crates/optimism/cli/Cargo.toml index fc097ea3a7a8..3ca591480ebc 100644 --- a/crates/optimism/cli/Cargo.toml +++ b/crates/optimism/cli/Cargo.toml @@ -17,7 +17,6 @@ reth-consensus.workspace = true reth-db = { workspace = true, features = ["mdbx"] } reth-db-api.workspace = true reth-downloaders.workspace = true -reth-optimism-primitives.workspace = true reth-provider.workspace = true reth-prune.workspace = true reth-stages.workspace = true @@ -26,6 +25,9 @@ reth-execution-types.workspace = true reth-node-core.workspace = true reth-primitives.workspace = true +## optimisim +reth-optimism-primitives.workspace = true + reth-chainspec.workspace = true reth-stages-types.workspace = true reth-node-events.workspace = true diff --git a/crates/primitives-traits/Cargo.toml b/crates/primitives-traits/Cargo.toml index 638cdccc6134..b7eb8515f26b 100644 --- a/crates/primitives-traits/Cargo.toml +++ b/crates/primitives-traits/Cargo.toml @@ -25,7 +25,6 @@ derive_more.workspace = true revm-primitives = { workspace = true, features = ["serde"] } # misc -thiserror-no-std = { workspace = true, default-features = false } roaring = "0.10.2" byteorder = "1" @@ -40,6 +39,8 @@ proptest = { workspace = true, optional = true } proptest-arbitrary-interop = { workspace = true, optional = true } [dev-dependencies] +alloy-primitives = { workspace = true, features = ["arbitrary"] } +alloy-consensus = { workspace = true, features = ["arbitrary"] } arbitrary = { workspace = true, features = ["derive"] } proptest.workspace = true proptest-arbitrary-interop.workspace = true @@ -50,10 +51,12 @@ serde_json.workspace = true [features] default = ["std"] -std = ["thiserror-no-std/std"] +std = [] test-utils = ["arbitrary"] arbitrary = [ + "std", "alloy-consensus/arbitrary", + "alloy-primitives/arbitrary", "dep:arbitrary", "dep:proptest", "dep:proptest-arbitrary-interop", diff --git a/crates/primitives-traits/src/constants/gas_units.rs b/crates/primitives-traits/src/constants/gas_units.rs index 0af0d2c24ce1..ed287e6d299b 100644 --- a/crates/primitives-traits/src/constants/gas_units.rs +++ b/crates/primitives-traits/src/constants/gas_units.rs @@ -1,4 +1,7 @@ -use std::time::Duration; +use core::time::Duration; + +#[cfg(not(feature = "std"))] +use alloc::string::String; /// Represents one Kilogas, or `1_000` gas. pub const KILOGAS: u64 = 1_000; diff --git a/crates/primitives-traits/src/error.rs b/crates/primitives-traits/src/error.rs index 8ae946c24208..144c210ba9e5 100644 --- a/crates/primitives-traits/src/error.rs +++ b/crates/primitives-traits/src/error.rs @@ -5,6 +5,8 @@ use core::{ #[cfg(not(feature = "std"))] use alloc::boxed::Box; +#[cfg(not(feature = "std"))] +extern crate alloc; /// A pair of values, one of which is expected and one of which is actual. #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] diff --git a/crates/primitives-traits/src/integer_list.rs b/crates/primitives-traits/src/integer_list.rs index 8e258fd8b060..173b054d8e5c 100644 --- a/crates/primitives-traits/src/integer_list.rs +++ b/crates/primitives-traits/src/integer_list.rs @@ -140,16 +140,26 @@ impl<'a> Arbitrary<'a> for IntegerList { } /// Primitives error type. -#[derive(Debug, thiserror_no_std::Error)] +#[derive(Debug)] pub enum RoaringBitmapError { /// The provided input is invalid. - #[error("the provided input is invalid")] InvalidInput, /// Failed to deserialize data into type. - #[error("failed to deserialize data into type")] FailedToDeserialize, } +#[cfg(feature = "std")] +impl std::error::Error for RoaringBitmapError {} + +impl fmt::Display for RoaringBitmapError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::InvalidInput => f.write_str("the provided input is invalid"), + Self::FailedToDeserialize {} => f.write_str("failed to deserialize data into type"), + } + } +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/primitives-traits/src/lib.rs b/crates/primitives-traits/src/lib.rs index b7a42d9c7b5c..6421e99b0d3c 100644 --- a/crates/primitives-traits/src/lib.rs +++ b/crates/primitives-traits/src/lib.rs @@ -9,6 +9,10 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![cfg_attr(not(feature = "std"), no_std)] +#[cfg(not(feature = "std"))] +#[macro_use] +extern crate alloc; + #[cfg(feature = "alloy-compat")] mod alloy_compat; diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 696708a7703c..3f44fc62c0c8 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -87,7 +87,7 @@ secp256k1.workspace = true [features] default = ["c-kzg", "alloy-compat", "std", "reth-codec"] -std = ["thiserror-no-std/std"] +std = ["thiserror-no-std/std", "reth-primitives-traits/std"] reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield"] asm-keccak = ["alloy-primitives/asm-keccak"] arbitrary = [