Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RLP optional in several crates #466

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ethbloom/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ tiny-keccak = { version = "2.0", features = ["keccak"] }
crunchy = { version = "0.2.2", default-features = false, features = ["limit_256"] }
fixed-hash = { path = "../fixed-hash", version = "0.6", default-features = false }
impl-serde = { path = "../primitive-types/impls/serde", version = "0.3", default-features = false, optional = true }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false, optional = true }
impl-codec = { version = "0.4.1", path = "../primitive-types/impls/codec", default-features = false, optional = true }

[dev-dependencies]
Expand All @@ -23,11 +23,12 @@ rand = "0.7.2"
hex-literal = "0.3.1"

[features]
default = ["std", "serialize", "rustc-hex"]
default = ["std", "rlp", "serialize", "rustc-hex"]
std = ["fixed-hash/std", "crunchy/std"]
serialize = ["std", "impl-serde"]
rustc-hex = ["fixed-hash/rustc-hex"]
arbitrary = ["fixed-hash/arbitrary"]
rlp = ["impl-rlp"]
codec = ["impl-codec"]

[[bench]]
Expand Down
2 changes: 2 additions & 0 deletions ethbloom/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ use crunchy::unroll;
use fixed_hash::*;
#[cfg(feature = "codec")]
use impl_codec::impl_fixed_hash_codec;
#[cfg(feature = "rlp")]
use impl_rlp::impl_fixed_hash_rlp;
#[cfg(feature = "serialize")]
use impl_serde::impl_fixed_hash_serde;
Expand All @@ -69,6 +70,7 @@ construct_fixed_hash! {
/// Bloom hash type with 256 bytes (2048 bits) size.
pub struct Bloom(BLOOM_SIZE);
}
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(Bloom, BLOOM_SIZE);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(Bloom, BLOOM_SIZE);
Expand Down
7 changes: 4 additions & 3 deletions ethereum-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ edition = "2018"
ethbloom = { path = "../ethbloom", version = "0.9", default-features = false }
fixed-hash = { path = "../fixed-hash", version = "0.6", default-features = false, features = ["byteorder", "rustc-hex"] }
uint-crate = { path = "../uint", package = "uint", version = "0.8", default-features = false }
primitive-types = { path = "../primitive-types", version = "0.7", features = ["rlp", "byteorder", "rustc-hex"], default-features = false }
primitive-types = { path = "../primitive-types", version = "0.7", features = ["byteorder", "rustc-hex"], default-features = false }
impl-serde = { path = "../primitive-types/impls/serde", version = "0.3.0", default-features = false, optional = true }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false }
impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false, optional = true }
impl-codec = { version = "0.4.1", path = "../primitive-types/impls/codec", default-features = false, optional = true }

[dev-dependencies]
serde_json = "1.0.41"

[features]
default = ["std", "serialize"]
default = ["std", "rlp", "serialize"]
std = ["uint-crate/std", "fixed-hash/std", "ethbloom/std", "primitive-types/std"]
serialize = ["std", "impl-serde", "primitive-types/serde", "ethbloom/serialize"]
arbitrary = ["ethbloom/arbitrary", "fixed-hash/arbitrary", "uint-crate/arbitrary"]
rlp = ["impl-rlp", "ethbloom/rlp"]
codec = ["impl-codec", "ethbloom/codec"]
6 changes: 6 additions & 0 deletions ethereum-types/src/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::{U128, U256, U512, U64};
use fixed_hash::*;
#[cfg(feature = "codec")]
use impl_codec::impl_fixed_hash_codec;
#[cfg(feature = "rlp")]
use impl_rlp::impl_fixed_hash_rlp;
#[cfg(feature = "serialize")]
use impl_serde::impl_fixed_hash_serde;
Expand All @@ -22,20 +23,23 @@ pub trait BigEndianHash {
}

construct_fixed_hash! { pub struct H32(4); }
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H32, 4);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H32, 4);
#[cfg(feature = "codec")]
impl_fixed_hash_codec!(H32, 4);

construct_fixed_hash! { pub struct H64(8); }
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H64, 8);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H64, 8);
#[cfg(feature = "codec")]
impl_fixed_hash_codec!(H64, 8);

construct_fixed_hash! { pub struct H128(16); }
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H128, 16);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H128, 16);
Expand All @@ -46,6 +50,7 @@ pub use primitive_types::H160;
pub use primitive_types::H256;

construct_fixed_hash! { pub struct H264(33); }
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H264, 33);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H264, 33);
Expand All @@ -55,6 +60,7 @@ impl_fixed_hash_codec!(H264, 33);
pub use primitive_types::H512;

construct_fixed_hash! { pub struct H520(65); }
#[cfg(feature = "rlp")]
impl_fixed_hash_rlp!(H520, 65);
#[cfg(feature = "serialize")]
impl_fixed_hash_serde!(H520, 65);
Expand Down
2 changes: 2 additions & 0 deletions ethereum-types/src/uint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#[cfg(feature = "codec")]
use impl_codec::impl_uint_codec;
#[cfg(feature = "rlp")]
use impl_rlp::impl_uint_rlp;
#[cfg(feature = "serialize")]
use impl_serde::impl_uint_serde;
Expand All @@ -19,6 +20,7 @@ construct_uint! {
/// Unsigned 64-bit integer.
pub struct U64(1);
}
#[cfg(feature = "rlp")]
impl_uint_rlp!(U64, 1);
#[cfg(feature = "serialize")]
impl_uint_serde!(U64, 1);
Expand Down