diff --git a/crates/consensus/Cargo.toml b/crates/consensus/Cargo.toml index 1d333decad86..beeb8adfa9b7 100644 --- a/crates/consensus/Cargo.toml +++ b/crates/consensus/Cargo.toml @@ -21,7 +21,7 @@ workspace = true [dependencies] alloy-primitives = { workspace = true, features = ["rlp"] } alloy-rlp.workspace = true -alloy-eips.workspace = true +alloy-eips = { workspace = true, features = ["kzg-sidecar"] } alloy-serde = { workspace = true, optional = true } # kzg diff --git a/crates/eips/Cargo.toml b/crates/eips/Cargo.toml index 139b461016a2..07ffbcd5a857 100644 --- a/crates/eips/Cargo.toml +++ b/crates/eips/Cargo.toml @@ -22,16 +22,15 @@ workspace = true alloy-primitives = { workspace = true, features = ["rlp"] } alloy-rlp = { workspace = true, features = ["derive"] } -sha2.workspace = true - # serde alloy-serde = { workspace = true, optional = true } serde = { workspace = true, optional = true } # kzg -derive_more = { workspace = true, optional = true } c-kzg = { workspace = true, optional = true } +derive_more = { workspace = true, optional = true } once_cell = { workspace = true, features = ["race", "alloc"], optional = true } +sha2 = { workspace = true, optional = true } # ssz ethereum_ssz_derive = { workspace = true, optional = true } @@ -68,7 +67,9 @@ serde = [ "alloy-primitives/serde", "c-kzg?/serde", ] -kzg = ["dep:derive_more", "dep:c-kzg", "dep:once_cell"] +kzg = ["kzg-sidecar", "sha2", "dep:derive_more", "dep:c-kzg", "dep:once_cell"] +kzg-sidecar = ["sha2"] +sha2 = ["dep:sha2"] ssz = [ "std", "dep:ethereum_ssz", diff --git a/crates/eips/src/eip4844/mod.rs b/crates/eips/src/eip4844/mod.rs index 4a344151a756..dbba4352d449 100644 --- a/crates/eips/src/eip4844/mod.rs +++ b/crates/eips/src/eip4844/mod.rs @@ -14,14 +14,16 @@ pub mod builder; pub mod utils; /// Contains sidecar related types +#[cfg(feature = "kzg-sidecar")] mod sidecar; +#[cfg(feature = "kzg-sidecar")] pub use sidecar::*; use alloy_primitives::{b256, FixedBytes, B256, U256}; /// The modulus of the BLS group used in the KZG commitment scheme. All field /// elements contained in a blob MUST be STRICTLY LESS than this value. -pub const BLS_MODULUS_BYTES: FixedBytes<32> = +pub const BLS_MODULUS_BYTES: B256 = b256!("73eda753299d7d483339d80809a1d80553bda402fffe5bfeffffffff00000001"); /// The modulus of the BLS group used in the KZG commitment scheme. All field @@ -90,6 +92,7 @@ pub type Bytes48 = FixedBytes<48>; /// # Panics /// /// If the given commitment is not 48 bytes long. +#[cfg(feature = "sha2")] pub fn kzg_to_versioned_hash(commitment: &[u8]) -> B256 { use sha2::Digest; diff --git a/crates/eips/src/eip4844/utils.rs b/crates/eips/src/eip4844/utils.rs index cf5a5ed5ca2a..6f4e6acb5617 100644 --- a/crates/eips/src/eip4844/utils.rs +++ b/crates/eips/src/eip4844/utils.rs @@ -2,6 +2,7 @@ //! [`SidecarCoder`]. //! //! [`SidecarCoder`]: crate::eip4844::builder::SidecarCoder + use crate::eip4844::USABLE_BITS_PER_FIELD_ELEMENT; /// Determine whether a slice of bytes can be contained in a field element.