From 056ed842f7fdc08b6bd5350acdcf12e4efd33581 Mon Sep 17 00:00:00 2001 From: David Palm Date: Mon, 6 Aug 2018 09:10:31 +0200 Subject: [PATCH 1/5] Don't depend on ethereum-types --- triehash/Cargo.toml | 1 - triehash/src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index cea5374ed..703a01e79 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -8,7 +8,6 @@ license = "GPL-3.0" [dependencies] elastic-array = "0.10" -ethereum-types = "0.3" hashdb = { version = "0.2", path = "../hashdb" } rlp = { version = "0.2.1", path = "../rlp" } diff --git a/triehash/src/lib.rs b/triehash/src/lib.rs index f688d5a4c..37b5a72e2 100644 --- a/triehash/src/lib.rs +++ b/triehash/src/lib.rs @@ -19,7 +19,6 @@ //! This module should be used to generate trie root hash. extern crate elastic_array; -extern crate ethereum_types; extern crate hashdb; extern crate rlp; #[cfg(test)] extern crate keccak_hasher; From faeec17b1e96c4cb12e47bb4f9b83d8f8ac3ea0e Mon Sep 17 00:00:00 2001 From: David Palm Date: Mon, 6 Aug 2018 14:09:12 +0200 Subject: [PATCH 2/5] remove stale todo --- kvdb/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kvdb/src/lib.rs b/kvdb/src/lib.rs index 24f39914a..3295075d4 100644 --- a/kvdb/src/lib.rs +++ b/kvdb/src/lib.rs @@ -17,7 +17,7 @@ //! Key-Value store abstraction with `RocksDB` backend. extern crate elastic_array; -extern crate parity_bytes as bytes; // TODO: name changed; update upstream when `parity-common` is available +extern crate parity_bytes as bytes; use std::io; use std::path::Path; From 03747c14b2b361e989bf5ffaf3abe9b61359d733 Mon Sep 17 00:00:00 2001 From: David Palm Date: Mon, 6 Aug 2018 14:09:21 +0200 Subject: [PATCH 3/5] remove git subtree artifact --- plain_hasher/util/plain_hasher/Cargo.toml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 plain_hasher/util/plain_hasher/Cargo.toml diff --git a/plain_hasher/util/plain_hasher/Cargo.toml b/plain_hasher/util/plain_hasher/Cargo.toml deleted file mode 100644 index 8a722a13d..000000000 --- a/plain_hasher/util/plain_hasher/Cargo.toml +++ /dev/null @@ -1,13 +0,0 @@ -[package] -name = "plain_hasher" -description = "Hasher for 32-bit keys." -version = "0.1.0" -authors = ["Parity Technologies "] -license = "MIT" -keywords = ["hash", "hasher"] -homepage = "https://github.com/paritytech/plain_hasher" - -[dependencies] -crunchy = "0.1.6" -ethereum-types = "0.3" -hashdb = { version = "0.2.0", path = "../hashdb" } \ No newline at end of file From f31f7d5d52ef529797631ab090efda4e85a22fb0 Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 8 Aug 2018 11:34:28 +0200 Subject: [PATCH 4/5] Remove dep on ethereum-types and make no_std compatible --- plain_hasher/Cargo.toml | 6 ++++-- plain_hasher/src/lib.rs | 17 ++++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/plain_hasher/Cargo.toml b/plain_hasher/Cargo.toml index adc03bbc2..8fd9cfe53 100644 --- a/plain_hasher/Cargo.toml +++ b/plain_hasher/Cargo.toml @@ -9,5 +9,7 @@ homepage = "https://github.com/paritytech/plain_hasher" [dependencies] crunchy = "0.1.6" -ethereum-types = "0.3" -hashdb = { path = "../hashdb" } \ No newline at end of file + +[features] +default = ["std"] +std = [] \ No newline at end of file diff --git a/plain_hasher/src/lib.rs b/plain_hasher/src/lib.rs index 4a8a10441..3250cd63b 100644 --- a/plain_hasher/src/lib.rs +++ b/plain_hasher/src/lib.rs @@ -14,20 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +#![cfg_attr(not(feature = "std"), no_std)] + #[macro_use] extern crate crunchy; -extern crate ethereum_types; -extern crate hashdb; -use ethereum_types::H256; -// use hashdb::Hasher; -use std::hash; -use std::collections::{HashMap, HashSet}; -/// Specialized version of `HashMap` with H256 keys and fast hashing function. -pub type H256FastMap = HashMap>; -/// Specialized version of `HashSet` with H256 keys and fast hashing function. -pub type H256FastSet = HashSet>; +#[cfg(feature = "std")] +extern crate core; +use core::hash; /// Hasher that just takes 8 bytes of the provided value. /// May only be used for keys which are 32 bytes. #[derive(Default)] @@ -50,7 +45,7 @@ impl hash::Hasher for PlainHasher { unroll! { for _i in 0..8 { - unsafe { + unsafe { *prefix_ptr ^= (*bytes_ptr ^ *bytes_ptr.offset(8)) ^ (*bytes_ptr.offset(16) ^ *bytes_ptr.offset(24)); bytes_ptr = bytes_ptr.offset(1); prefix_ptr = prefix_ptr.offset(1); From d77a5799846fe370b9157fb0e84c906a3f2bc8ad Mon Sep 17 00:00:00 2001 From: David Palm Date: Thu, 9 Aug 2018 08:30:07 +0200 Subject: [PATCH 5/5] Add a README, categorize as "no-std", version bump: 0.2 --- plain_hasher/Cargo.toml | 5 +++-- plain_hasher/README.md | 5 +++++ test-support/keccak-hasher/Cargo.toml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 plain_hasher/README.md diff --git a/plain_hasher/Cargo.toml b/plain_hasher/Cargo.toml index 8fd9cfe53..53b880155 100644 --- a/plain_hasher/Cargo.toml +++ b/plain_hasher/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "plain_hasher" description = "Hasher for 32-bit keys." -version = "0.1.0" +version = "0.2.0" authors = ["Parity Technologies "] license = "MIT" keywords = ["hash", "hasher"] -homepage = "https://github.com/paritytech/plain_hasher" +homepage = "https://github.com/paritytech/parity-common" +categories = [ "no-std"] [dependencies] crunchy = "0.1.6" diff --git a/plain_hasher/README.md b/plain_hasher/README.md new file mode 100644 index 000000000..27877967c --- /dev/null +++ b/plain_hasher/README.md @@ -0,0 +1,5 @@ +# Specialized Hasher for 32-bit keys + +Provides `PlainHasher`, a specialized `core::hash::Hasher` that takes just 8 bytes of the provided value and may only be used for keys which are 32 bytes. + +The crate is `no_std`-compatible. \ No newline at end of file diff --git a/test-support/keccak-hasher/Cargo.toml b/test-support/keccak-hasher/Cargo.toml index 7c82f172f..363d5d701 100644 --- a/test-support/keccak-hasher/Cargo.toml +++ b/test-support/keccak-hasher/Cargo.toml @@ -10,4 +10,4 @@ license = "GPL-3.0" ethereum-types = "0.3" tiny-keccak = "1.4.2" hashdb = { version = "0.2.0", path = "../../hashdb" } -plain_hasher = { version = "0.1.0", path = "../../plain_hasher" } \ No newline at end of file +plain_hasher = { path = "../../plain_hasher" } \ No newline at end of file