diff --git a/ethbloom/Cargo.toml b/ethbloom/Cargo.toml index 4c5d6a981..f0e48af73 100644 --- a/ethbloom/Cargo.toml +++ b/ethbloom/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethbloom" -version = "0.6.4" +version = "0.7.0" authors = ["Parity Technologies "] description = "Ethereum bloom filter" license = "MIT" @@ -11,7 +11,7 @@ repository = "https://github.com/paritytech/parity-common" [dependencies] tiny-keccak = "1.4" crunchy = { version = "0.2", default-features = false, features = ["limit_256"] } -fixed-hash = { path = "../fixed-hash", version = "0.3", default-features = false } +fixed-hash = { path = "../fixed-hash", version = "0.4", default-features = false } impl-serde = { path = "../primitive-types/impls/serde", version = "0.2", default-features = false, optional = true } impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false } @@ -20,7 +20,6 @@ rand = { version = "0.4" } hex-literal = "0.1.1" [features] -default = ["std", "heapsize", "serialize", "fixed-hash/libc", "fixed-hash/rustc-hex"] +default = ["std", "serialize", "fixed-hash/libc", "fixed-hash/rustc-hex"] std = ["fixed-hash/std", "crunchy/std"] -heapsize = ["fixed-hash/heapsize"] serialize = ["std", "impl-serde"] diff --git a/ethereum-types/Cargo.toml b/ethereum-types/Cargo.toml index 0b9ca9651..e5c5f5e90 100644 --- a/ethereum-types/Cargo.toml +++ b/ethereum-types/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "ethereum-types" -version = "0.6.0" +version = "0.7.0" authors = ["Parity Technologies "] license = "MIT" homepage = "https://github.com/paritytech/parity-common" description = "Ethereum types" [dependencies] -ethbloom = { path = "../ethbloom", version = "0.6", default-features = false } -fixed-hash = { path = "../fixed-hash", version = "0.3", default-features = false, features = ["byteorder", "rustc-hex"] } -uint = { path = "../uint", version = "0.7", default-features = false } -primitive-types = { path = "../primitive-types", version = "0.3", features = ["rlp", "byteorder", "rustc-hex"], default-features = false } +ethbloom = { path = "../ethbloom", version = "0.7", default-features = false } +fixed-hash = { path = "../fixed-hash", version = "0.4", default-features = false, features = ["byteorder", "rustc-hex"] } +uint = { path = "../uint", version = "0.8", default-features = false } +primitive-types = { path = "../primitive-types", version = "0.4", features = ["rlp", "byteorder", "rustc-hex"], default-features = false } impl-serde = { path = "../primitive-types/impls/serde", version = "0.2", default-features = false, optional = true } impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-features = false } @@ -18,7 +18,6 @@ impl-rlp = { path = "../primitive-types/impls/rlp", version = "0.2", default-fea serde_json = "1.0" [features] -default = ["std", "heapsize", "serialize"] +default = ["std", "serialize"] std = ["uint/std", "fixed-hash/std", "ethbloom/std", "primitive-types/std"] -heapsize = ["uint/heapsize", "primitive-types/heapsize", "fixed-hash/heapsize", "ethbloom/heapsize"] serialize = ["std", "impl-serde", "primitive-types/serde", "ethbloom/serialize"] diff --git a/fixed-hash/Cargo.toml b/fixed-hash/Cargo.toml index c85eb2417..9947ceaa2 100644 --- a/fixed-hash/Cargo.toml +++ b/fixed-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fixed-hash" -version = "0.3.2" +version = "0.4.0" authors = ["Parity Technologies "] license = "MIT" homepage = "https://github.com/paritytech/parity-common" @@ -10,10 +10,9 @@ documentation = "https://docs.rs/fixed-hash/" readme = "README.md" [package.metadata.docs.rs] -features = ["heapsize", "quickcheck", "api-dummy"] +features = ["quickcheck", "api-dummy"] [dependencies] -heapsize = { version = "0.4", optional = true } rand = { version = "0.5", optional = true, default-features = false } rustc-hex = { version = "2.0", optional = true, default-features = false } quickcheck = { version = "0.7", optional = true } diff --git a/fixed-hash/README.md b/fixed-hash/README.md index 24d685561..19f4c79f9 100644 --- a/fixed-hash/README.md +++ b/fixed-hash/README.md @@ -63,8 +63,6 @@ fixed-hash = { version = "0.3", default-features = false } - Enabled by default. - `byteorder`: Provide API based on the `byteorder` crate. - Enabled by default. -- `heapsize`: Provide `HeapsizeOf` implementation for hash types. - - Disabled by default. - `quickcheck`: Provide `quickcheck` implementation for hash types. - Disabled by default. - `api-dummy`: Generate a dummy hash type for API documentation. diff --git a/fixed-hash/src/hash.rs b/fixed-hash/src/hash.rs index 7a6395ce0..95c762848 100644 --- a/fixed-hash/src/hash.rs +++ b/fixed-hash/src/hash.rs @@ -323,7 +323,6 @@ macro_rules! construct_fixed_hash { impl_rand_for_fixed_hash!($name); impl_libc_for_fixed_hash!($name); impl_rustc_hex_for_fixed_hash!($name); - impl_heapsize_for_fixed_hash!($name); impl_quickcheck_for_fixed_hash!($name); } } @@ -667,45 +666,6 @@ macro_rules! impl_rustc_hex_for_fixed_hash { } } -// Implementation for disabled heapsize crate support. -// -// # Note -// -// Feature guarded macro definitions instead of feature guarded impl blocks -// to work around the problems of introducing `heapsize` crate feature in -// a user crate. -#[cfg(not( - all(feature = "heapsize", not(target_os = "unknown")) -))] -#[macro_export] -#[doc(hidden)] -macro_rules! impl_heapsize_for_fixed_hash { - ( $name:ident ) => {} -} - -// Implementation for enabled heapsize crate support. -// -// # Note -// -// Feature guarded macro definitions instead of feature guarded impl blocks -// to work around the problems of introducing `heapsize` crate feature in -// a user crate. -#[cfg( - all(feature = "heapsize", not(target_os = "unknown")) -)] -#[macro_export] -#[doc(hidden)] -macro_rules! impl_heapsize_for_fixed_hash { - ( $name:ident ) => { - impl $crate::heapsize::HeapSizeOf for $name { - #[inline] - fn heap_size_of_children(&self) -> usize { - 0 - } - } - } -} - // Implementation for disabled quickcheck crate support. // // # Note diff --git a/fixed-hash/src/lib.rs b/fixed-hash/src/lib.rs index 760b05086..adc2335e3 100644 --- a/fixed-hash/src/lib.rs +++ b/fixed-hash/src/lib.rs @@ -43,10 +43,6 @@ pub extern crate byteorder; #[doc(hidden)] pub mod libc {} -#[cfg(feature = "heapsize")] -#[doc(hidden)] -pub extern crate heapsize; - #[cfg(feature = "rustc-hex")] #[doc(hidden)] pub extern crate rustc_hex; diff --git a/fixed-hash/src/tests.rs b/fixed-hash/src/tests.rs index 5a0c43c0f..66869d002 100644 --- a/fixed-hash/src/tests.rs +++ b/fixed-hash/src/tests.rs @@ -310,17 +310,6 @@ mod from_str { } } -#[cfg(all( - feature = "heapsize", - not(target_os = "unknown") -))] -#[test] -fn test_heapsizeof() { - use heapsize::HeapSizeOf; - let h = H128::zero(); - assert_eq!(h.heap_size_of_children(), 0); -} - #[test] fn from_h160_to_h256() { let h160 = H160::from([ diff --git a/keccak-hash/Cargo.toml b/keccak-hash/Cargo.toml index c1178a96b..7d2371887 100644 --- a/keccak-hash/Cargo.toml +++ b/keccak-hash/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "keccak-hash" -version = "0.2.0" +version = "0.3.0" description = "`keccak-hash` is a set of utility functions to facilitate working with Keccak hashes (256/512 bits long)." authors = ["Parity Technologies "] repository = "https://github.com/paritytech/parity-common" @@ -9,7 +9,7 @@ license = "GPL-3.0" [dependencies] tiny-keccak = "1.4" -primitive-types = { path = "../primitive-types", version = "0.3" } +primitive-types = { path = "../primitive-types", version = "0.4" } [dev-dependencies] tempdir = "0.3" diff --git a/kvdb-rocksdb/Cargo.toml b/kvdb-rocksdb/Cargo.toml index b43026e0d..57e7e6a2b 100644 --- a/kvdb-rocksdb/Cargo.toml +++ b/kvdb-rocksdb/Cargo.toml @@ -19,4 +19,4 @@ parity-rocksdb = "0.5" [dev-dependencies] tempdir = "0.3" -ethereum-types = { version = "0.6", path = "../ethereum-types" } +ethereum-types = { version = "0.7", path = "../ethereum-types" } diff --git a/parity-util-mem/Cargo.toml b/parity-util-mem/Cargo.toml index 6293d6348..c22796d68 100644 --- a/parity-util-mem/Cargo.toml +++ b/parity-util-mem/Cargo.toml @@ -13,9 +13,9 @@ malloc_size_of_derive = "0.1.0" dlmalloc = { version = "0.1", features = ["global"], optional = true } wee_alloc = { version = "0.4", optional = true } -elastic-array = { version = "*", optional = true } -ethereum-types = { version = "*", optional = true } -parking_lot = { version = "*", optional = true } +elastic-array = { version = "0", optional = true } +ethereum-types = { version = "0", optional = true } +parking_lot = { version = "0", optional = true } [target.'cfg(target_os = "windows")'.dependencies.winapi] version = "0.3.4" @@ -27,8 +27,6 @@ optional = true [features] default = ["std", "ethereum-impls"] std = [] -# when activated mem is removed through volatile primitive instead of clear_on_drop crate -volatile-erase = [] # use dlmalloc as global allocator dlmalloc-global = ["dlmalloc", "estimate-heapsize"] # use wee_alloc as global allocator diff --git a/parity-util-mem/README.md b/parity-util-mem/README.md index e01fb6ce6..14d6e6c19 100644 --- a/parity-util-mem/README.md +++ b/parity-util-mem/README.md @@ -4,13 +4,14 @@ Collection of memory related utilities. ## Features -- volatile-erase : Not set by default, `Memzero` struct will be erasing memory through a simple [`write_volatile`](https://doc.rust-lang.org/std/ptr/fn.write_volatile.html) call. - estimate-heapsize : Do not use allocator, but `size_of` or `size_of_val`. Others features define global allocator, see `src/alloc.rs`. ## Dependency -This crate groups common dependency, [`clear_on_drop`](https://crates.io/crates/clear_on_drop) is reexported, and a patched copy of unpublished [`malloc_size_of`](https://github.com/servo/servo/tree/master/components/malloc_size_of) from servo project is copied and partially reexported. +This crate groups common dependency, a patched copy of unpublished [`malloc_size_of`](https://github.com/servo/servo/tree/master/components/malloc_size_of) from servo project is copied and partially reexported. `Malloc_size_of` code is used internally as a module with a few modification to be able to implement type locally. + +For existing code using deprecated `HeapsizeOf` crate, calls to `heapsize_of_children` should be replace by calls to `size_of`. diff --git a/parity-util-mem/src/allocators.rs b/parity-util-mem/src/allocators.rs index 6f63b89fb..9db01309a 100644 --- a/parity-util-mem/src/allocators.rs +++ b/parity-util-mem/src/allocators.rs @@ -45,8 +45,6 @@ use malloc_size::MallocUnconditionalSizeOf; use std::os::raw::c_void; #[cfg(not(feature = "std"))] use core::ffi::c_void; -#[cfg(not(feature = "std"))] -use alloc::collections::btree_set::BTreeSet; mod usable_size { diff --git a/parity-util-mem/src/lib.rs b/parity-util-mem/src/lib.rs index a07ff5c57..7e2ba7068 100644 --- a/parity-util-mem/src/lib.rs +++ b/parity-util-mem/src/lib.rs @@ -29,19 +29,12 @@ extern crate cfg_if; #[cfg(not(feature = "std"))] extern crate alloc; -extern crate clear_on_drop as cod; - -#[macro_use] extern crate malloc_size_of_derive as malloc_size_derive; +extern crate malloc_size_of_derive as malloc_size_derive; use std::ops::{Deref, DerefMut}; -#[cfg(feature = "volatile-erase")] use std::ptr; -#[cfg(not(feature = "volatile-erase"))] -pub use cod::clear::Clear; - - cfg_if! { if #[cfg(all( feature = "jemalloc-global", @@ -91,11 +84,6 @@ use core as std; #[cfg(feature = "ethereum-impls")] pub mod impls; -/// Reexport clear_on_drop crate. -pub mod clear_on_drop { - pub use cod::*; -} - pub use malloc_size_derive::*; pub use malloc_size::{ MallocSizeOfOps, @@ -115,7 +103,6 @@ impl> From for Memzero { } } -#[cfg(feature = "volatile-erase")] impl> Drop for Memzero { fn drop(&mut self) { unsafe { @@ -126,13 +113,6 @@ impl> Drop for Memzero { } } -#[cfg(not(feature = "volatile-erase"))] -impl> Drop for Memzero { - fn drop(&mut self) { - self.as_mut().clear(); - } -} - impl> Deref for Memzero { type Target = T; diff --git a/parity-util-mem/src/malloc_size.rs b/parity-util-mem/src/malloc_size.rs index ab9b0327b..e7599ea85 100644 --- a/parity-util-mem/src/malloc_size.rs +++ b/parity-util-mem/src/malloc_size.rs @@ -50,8 +50,6 @@ #[cfg(not(feature = "std"))] use alloc::vec::Vec; #[cfg(not(feature = "std"))] -use alloc::string::String; -#[cfg(not(feature = "std"))] mod std { pub use core::*; pub use alloc::collections; @@ -60,7 +58,9 @@ mod std { #[cfg(feature = "std")] use std::sync::Arc; -use std::hash::{BuildHasher, Hash}; +#[cfg(feature = "std")] +use std::hash::BuildHasher; +use std::hash::Hash; use std::mem::size_of; use std::ops::Range; use std::ops::{Deref, DerefMut}; @@ -75,7 +75,7 @@ pub use alloc::boxed::Box; pub type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize; /// A closure implementing a stateful predicate on pointers. -pub type VoidPtrToBoolFnMut = FnMut(*const c_void) -> bool; +pub type VoidPtrToBoolFnMut = dyn FnMut(*const c_void) -> bool; /// Operations used when measuring heap usage of data structures. pub struct MallocSizeOfOps { @@ -211,6 +211,9 @@ pub mod inner_allocator_use { use super::*; +#[cfg(not(feature = "std"))] +use alloc::string::String; + impl MallocShallowSizeOf for Box { fn shallow_size_of(&self, ops: &mut MallocSizeOfOps) -> usize { unsafe { ops.malloc_size_of(&**self) } diff --git a/parity-util-mem/src/sizeof.rs b/parity-util-mem/src/sizeof.rs index 405063d8a..fb917b1b6 100644 --- a/parity-util-mem/src/sizeof.rs +++ b/parity-util-mem/src/sizeof.rs @@ -24,7 +24,21 @@ use crate::malloc_size::{ MallocUnconditionalShallowSizeOf, MallocSizeOfOps }; +#[cfg(not(feature = "std"))] +use alloc::boxed::Box; +#[cfg(not(feature = "std"))] +use alloc::vec::Vec; +#[cfg(not(feature = "std"))] +use alloc::string::String; +#[cfg(not(feature = "std"))] +use core::mem::{size_of, size_of_val}; +#[cfg(not(feature = "std"))] +use alloc::sync::Arc; + +#[cfg(feature = "std")] use std::mem::{size_of, size_of_val}; +#[cfg(feature = "std")] +use std::sync::Arc; impl MallocShallowSizeOf for Box { fn shallow_size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { @@ -44,7 +58,7 @@ impl MallocShallowSizeOf for Vec { } } -impl MallocUnconditionalShallowSizeOf for std::sync::Arc { +impl MallocUnconditionalShallowSizeOf for Arc { fn unconditional_shallow_size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { size_of::() } diff --git a/primitive-types/Cargo.toml b/primitive-types/Cargo.toml index bfbb04618..70c88283d 100644 --- a/primitive-types/Cargo.toml +++ b/primitive-types/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "primitive-types" -version = "0.3.0" +version = "0.4.0" authors = ["Parity Technologies "] license = "Apache-2.0/MIT" homepage = "https://github.com/paritytech/parity-common" description = "Primitive types shared by Ethereum and Substrate" [dependencies] -fixed-hash = { version = "0.3", path = "../fixed-hash", default-features = false } -uint = { version = "0.7", path = "../uint", default-features = false } +fixed-hash = { version = "0.4", path = "../fixed-hash", default-features = false } +uint = { version = "0.8", path = "../uint", default-features = false } impl-serde = { version = "0.2", path = "impls/serde", default-features = false, optional = true } impl-codec = { version = "0.2", path = "impls/codec", default-features = false, optional = true } impl-rlp = { version = "0.2", path = "impls/rlp", default-features = false, optional = true } @@ -16,7 +16,6 @@ impl-rlp = { version = "0.2", path = "impls/rlp", default-features = false, opti [features] default = ["std"] std = ["uint/std", "fixed-hash/std", "impl-codec/std"] -heapsize = ["uint/heapsize", "fixed-hash/heapsize"] byteorder = ["fixed-hash/byteorder"] libc = ["fixed-hash/libc"] rustc-hex = ["fixed-hash/rustc-hex"] diff --git a/rlp/Cargo.toml b/rlp/Cargo.toml index 18945c9e8..380387d01 100644 --- a/rlp/Cargo.toml +++ b/rlp/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rlp" -version = "0.4.0" +version = "0.4.1" description = "Recursive-length prefix encoding, decoding, and compression" repository = "https://github.com/paritytech/parity-common" license = "MIT/Apache-2.0" @@ -13,5 +13,5 @@ rustc-hex = {version = "2.0", default-features = false } [dev-dependencies] hex-literal = "0.2" -primitive-types = { path = "../primitive-types", version = "0.3", features = ["impl-rlp"] } +primitive-types = { path = "../primitive-types", version = "0.4", features = ["impl-rlp"] } diff --git a/transaction-pool/Cargo.toml b/transaction-pool/Cargo.toml index 5c61a5873..312d4f3b0 100644 --- a/transaction-pool/Cargo.toml +++ b/transaction-pool/Cargo.toml @@ -13,4 +13,4 @@ smallvec = "0.6" trace-time = { path = "../trace-time", version = "0.1" } [dev-dependencies] -ethereum-types = { version = "0.6", path = "../ethereum-types" } +ethereum-types = { version = "0.7", path = "../ethereum-types" } diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index c02e70d0b..3e0638051 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -13,5 +13,5 @@ rlp = { version = "0.4", path = "../rlp" } [dev-dependencies] keccak-hasher = { version = "0.11.0" } tiny-keccak = "1.4.2" -ethereum-types = { version = "0.6", path = "../ethereum-types" } +ethereum-types = { version = "0.7", path = "../ethereum-types" } hex-literal = "0.2" diff --git a/uint/Cargo.toml b/uint/Cargo.toml index 08d5973d8..61ae39068 100644 --- a/uint/Cargo.toml +++ b/uint/Cargo.toml @@ -4,14 +4,13 @@ homepage = "http://parity.io" repository = "https://github.com/paritytech/parity-common" license = "MIT/Apache-2.0" name = "uint" -version = "0.7.1" +version = "0.8.0" authors = ["Parity Technologies "] readme = "README.md" edition = "2018" [dependencies] byteorder = { version = "1", default-features = false } -heapsize = { version = "0.4.2", optional = true } rustc-hex = { version = "2.0", default-features = false } quickcheck = { version = "0.6", optional = true } crunchy = { version = "0.2", default-features = true } diff --git a/uint/README.md b/uint/README.md index 4cd286706..dce830977 100644 --- a/uint/README.md +++ b/uint/README.md @@ -13,7 +13,7 @@ Support a very similar API as the built-in primitive integer types. In your `Cargo.toml` paste ``` -uint = "0.7" +uint = "0.8" ``` Construct your own big unsigned integer type as follows. @@ -56,5 +56,3 @@ see fuzz [README.md](fuzz/README.md) - Enabled by default. - `quickcheck`: Enable quickcheck-style property testing - Use with `cargo test --release --features=quickcheck`. -- `heapsize`: Implement base trait of the `heapsizeof` crate - - Use with `cargo build --feature=heapsize`. diff --git a/uint/src/lib.rs b/uint/src/lib.rs index dd95ab301..352ccf70d 100644 --- a/uint/src/lib.rs +++ b/uint/src/lib.rs @@ -13,10 +13,6 @@ #[doc(hidden)] pub extern crate byteorder; -#[cfg(feature="heapsize")] -#[doc(hidden)] -pub extern crate heapsize; - // Re-export libcore using an alias so that the macros can work without // requiring `extern crate core` downstream. #[doc(hidden)] diff --git a/uint/src/uint.rs b/uint/src/uint.rs index 570a018dd..6dcdb4fd0 100644 --- a/uint/src/uint.rs +++ b/uint/src/uint.rs @@ -1525,7 +1525,6 @@ macro_rules! construct_uint { } impl_std_for_uint!($name, $n_words); - impl_heapsize_for_uint!($name); // `$n_words * 8` because macro expects bytes and // uints use 64 bit (8 byte) words impl_quickcheck_arbitrary_for_uint!($name, ($n_words * 8)); @@ -1567,26 +1566,6 @@ macro_rules! impl_std_for_uint { ($name: ident, $n_words: tt) => {} } -#[cfg(feature = "heapsize")] -#[macro_export] -#[doc(hidden)] -macro_rules! impl_heapsize_for_uint { - ($name: ident) => { - impl $crate::heapsize::HeapSizeOf for $name { - fn heap_size_of_children(&self) -> usize { - 0 - } - } - } -} - -#[cfg(not(feature = "heapsize"))] -#[macro_export] -#[doc(hidden)] -macro_rules! impl_heapsize_for_uint { - ($name: ident) => {} -} - #[cfg(feature = "quickcheck")] #[macro_export] #[doc(hidden)]