chore(no_std): fixed no_std compiler errors in reth-primitives-traits (#9572)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
frostburn
2024-07-17 10:23:02 -07:00
committed by GitHub
parent 38bc7a14a3
commit 84174737f9
9 changed files with 33 additions and 10 deletions

1
Cargo.lock generated
View File

@ -8042,7 +8042,6 @@ dependencies = [
"serde",
"serde_json",
"test-fuzz",
"thiserror-no-std",
]
[[package]]

View File

@ -341,7 +341,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" }

View File

@ -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

View File

@ -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",

View File

@ -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;

View File

@ -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)]

View File

@ -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::*;

View File

@ -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;

View File

@ -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 = [