From bd4757b3b53022f871872790c27aa571d2ec2fdb Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 19 Apr 2024 17:18:43 +0200 Subject: [PATCH] chore: make alloy impls feature gated (#7747) --- Cargo.toml | 3 ++- crates/primitives/Cargo.toml | 2 +- crates/primitives/src/transaction/mod.rs | 2 +- crates/storage/codecs/Cargo.toml | 10 ++++++---- crates/storage/codecs/src/lib.rs | 5 +++++ crates/storage/db/Cargo.toml | 2 +- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 688041827..c1b57e008 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -291,7 +291,7 @@ alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8", default-features = false, features = [ "reqwest", ] } -alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } +alloy-eips = { git = "https://github.com/alloy-rs/alloy", default-features = false, rev = "188c4f8" } alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "188c4f8" } @@ -321,6 +321,7 @@ itertools = "0.12" parking_lot = "0.12" # Needed for `metrics-macro` to resolve the crate using `::metrics` notation metrics = "0.21.1" +modular-bitfield = "0.11.2" hex-literal = "0.4" once_cell = "1.17" syn = "2.0" diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index daddf3e9b..3e08655db 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -40,7 +40,7 @@ byteorder = "1" clap = { workspace = true, features = ["derive"], optional = true } derive_more.workspace = true itertools.workspace = true -modular-bitfield = "0.11.2" +modular-bitfield.workspace = true once_cell.workspace = true rayon.workspace = true serde_with.workspace = true diff --git a/crates/primitives/src/transaction/mod.rs b/crates/primitives/src/transaction/mod.rs index 3fd21c9a3..f51b5ca3a 100644 --- a/crates/primitives/src/transaction/mod.rs +++ b/crates/primitives/src/transaction/mod.rs @@ -1104,7 +1104,7 @@ impl Compact for TransactionSignedNoHash { to_compact_ztd_unaware(self, buf) } - fn from_compact(mut buf: &[u8], _len: usize) -> (Self, &[u8]) { + fn from_compact(buf: &[u8], _len: usize) -> (Self, &[u8]) { from_compact_zstd_unaware(buf, _len) } } diff --git a/crates/storage/codecs/Cargo.toml b/crates/storage/codecs/Cargo.toml index f585accf6..31f954f86 100644 --- a/crates/storage/codecs/Cargo.toml +++ b/crates/storage/codecs/Cargo.toml @@ -13,15 +13,16 @@ workspace = true [dependencies] reth-codecs-derive = { path = "./derive", default-features = false } -alloy-eips.workspace = true +alloy-eips = { workspace = true, optional = true } alloy-primitives.workspace = true + bytes.workspace = true [dev-dependencies] -alloy-eips = { workspace = true, features = ["arbitrary", "serde"] } +alloy-eips = { workspace = true, default-features = false, features = ["arbitrary", "serde"] } alloy-primitives = { workspace = true, features = ["arbitrary", "serde"] } serde.workspace = true -modular-bitfield = "0.11.2" +modular-bitfield.workspace = true test-fuzz.workspace = true serde_json.workspace = true @@ -30,6 +31,7 @@ proptest.workspace = true proptest-derive.workspace = true [features] -default = ["std"] +default = ["std", "alloy"] std = ["alloy-primitives/std", "bytes/std"] +alloy = ["alloy-eips"] optimism = ["reth-codecs-derive/optimism"] diff --git a/crates/storage/codecs/src/lib.rs b/crates/storage/codecs/src/lib.rs index dbfb68b3c..9c5d757b9 100644 --- a/crates/storage/codecs/src/lib.rs +++ b/crates/storage/codecs/src/lib.rs @@ -1,4 +1,8 @@ //! Compact codec. +//! +//! ## Feature Flags +//! +//! - `alloy`: [Compact] implementation for various alloy types. #![doc( html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png", @@ -16,6 +20,7 @@ pub use reth_codecs_derive::*; use alloy_primitives::{Address, Bloom, Bytes, B256, B512, U256}; use bytes::Buf; +#[cfg(any(test, feature = "alloy"))] mod alloy; /// Trait that implements the `Compact` codec. diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index 2986884a1..461a84f3e 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -23,7 +23,7 @@ reth-tracing.workspace = true # codecs serde = { workspace = true, default-features = false } parity-scale-codec = { version = "3.2.1", features = ["bytes"] } -modular-bitfield = "0.11.2" +modular-bitfield.workspace = true # metrics reth-metrics.workspace = true