From 2c99d1edb91769ff936687d60cb27a8b35084c0d Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 7 Feb 2019 10:30:26 +0100 Subject: [PATCH] Remove deps to hashdb, memdb, patricia-trie, keccak-hash. --- Cargo.toml | 3 -- hashdb/README.md | 5 ++- memorydb/README.md | 4 +- patricia_trie/Cargo.toml | 2 +- test-support/keccak-hasher/src/lib.rs | 2 + .../patricia-trie-ethereum/Cargo.toml | 8 ++-- triehash/Cargo.toml | 6 +-- triehash/src/lib.rs | 38 +++++++++++-------- 8 files changed, 39 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d1d26e1..9eb6526 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,16 +1,13 @@ [workspace] members = [ "fixed-hash", - "hashdb", "keccak-hash", "kvdb", "kvdb-memorydb", "kvdb-rocksdb", - "memorydb", "parity-bytes", "parity-crypto", "parity-path", - "patricia_trie", "plain_hasher", "rlp", "transaction-pool", diff --git a/hashdb/README.md b/hashdb/README.md index 23b49ae..6af0246 100644 --- a/hashdb/README.md +++ b/hashdb/README.md @@ -1,4 +1,7 @@ # HashDB `HashDB` defines a common interface for databases of byte-slices keyed to their hash. It is generic over hash type through the `Hasher` trait. -The `Hasher` trait can be used in a `no_std` context. \ No newline at end of file +The `Hasher` trait can be used in a `no_std` context. + + +**This crate is deprecated in favor of ['hash-db'](https://crates.io/crates/hash-db)** diff --git a/memorydb/README.md b/memorydb/README.md index 642ef5b..38ac6fa 100644 --- a/memorydb/README.md +++ b/memorydb/README.md @@ -1 +1,3 @@ -MemoryDB is a reference counted memory-based [`HashDB`](https://github.com/paritytech/parity-common/tree/master/hashdb) implementation backed by a `HashMap`. \ No newline at end of file +MemoryDB is a reference counted memory-based [`HashDB`](https://github.com/paritytech/parity-common/tree/master/hashdb) implementation backed by a `HashMap`. + +**This crate is deprecated in favor of ['memory-db'](https://crates.io/crates/hash-db)** diff --git a/patricia_trie/Cargo.toml b/patricia_trie/Cargo.toml index 1906601..c92ab30 100644 --- a/patricia_trie/Cargo.toml +++ b/patricia_trie/Cargo.toml @@ -2,7 +2,7 @@ name = "patricia-trie" version = "0.3.0" authors = ["Parity Technologies "] -description = "Merkle-Patricia Trie generic over key hasher and node encoding" +description = "Merkle-Patricia Trie generic over key hasher and node encoding, deprecated please use trie-db crate" repository = "https://github.com/paritytech/parity-common" license = "GPL-3.0" diff --git a/test-support/keccak-hasher/src/lib.rs b/test-support/keccak-hasher/src/lib.rs index bb2b5b4..b7237db 100644 --- a/test-support/keccak-hasher/src/lib.rs +++ b/test-support/keccak-hasher/src/lib.rs @@ -15,6 +15,8 @@ // along with Parity. If not, see . //! Hasher implementation for the Keccak-256 hash +//! +//! This is deprecated in favor of trie crate. extern crate hashdb; extern crate ethereum_types; extern crate tiny_keccak; diff --git a/test-support/patricia-trie-ethereum/Cargo.toml b/test-support/patricia-trie-ethereum/Cargo.toml index 1f987b9..be37337 100644 --- a/test-support/patricia-trie-ethereum/Cargo.toml +++ b/test-support/patricia-trie-ethereum/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "patricia-trie-ethereum" -version = "0.1.0" +version = "0.2.0" authors = ["Parity Technologies "] description = "Merkle-Patricia Trie (Ethereum Style)" license = "GPL-3.0" [dependencies] -patricia-trie = { version = "0.3.0", path = "../../patricia_trie" } -keccak-hasher = { version = "0.1", path = "../keccak-hasher" } -hashdb = { version = "0.3.0", path = "../../hashdb" } +trie-db = { version = "0.11.0" } +keccak-hasher = { version = "0.11.0" } +hash-db = { version = "0.11.0" } rlp = { version = "0.3.0", path = "../../rlp" } parity-bytes = { version = "0.1", path = "../../parity-bytes" } diff --git a/triehash/Cargo.toml b/triehash/Cargo.toml index 00f03be..621e350 100644 --- a/triehash/Cargo.toml +++ b/triehash/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "triehash" -version = "0.3.0" +version = "0.4.0" authors = ["Parity Technologies "] description = "In-memory patricia trie operations" repository = "https://github.com/paritytech/parity-common" license = "GPL-3.0" [dependencies] -hashdb = { version = "0.3.0", path = "../hashdb", default-features = false } +hash-db = { version = "0.11.0", default-features = false } rlp = { version = "0.3.0", path = "../rlp", default-features = false } [dev-dependencies] trie-standardmap = { version = "0.1", path = "../trie-standardmap" } -keccak-hasher = { version = "0.1", path = "../test-support/keccak-hasher" } +keccak-hasher = { version = "0.11.0" } tiny-keccak = "1.4.2" ethereum-types = "0.4" diff --git a/triehash/src/lib.rs b/triehash/src/lib.rs index 8125abb..995fb02 100644 --- a/triehash/src/lib.rs +++ b/triehash/src/lib.rs @@ -1,4 +1,4 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// Copyright 2015-2019 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify @@ -18,14 +18,14 @@ //! //! This module should be used to generate trie root hash. -extern crate hashdb; +extern crate hash_db; extern crate rlp; #[cfg(test)] extern crate keccak_hasher; use std::collections::BTreeMap; use std::cmp; use std::iter::once; -use hashdb::Hasher; +use hash_db::Hasher; use rlp::RlpStream; fn shared_prefix_len(first: &[T], second: &[T]) -> usize { @@ -40,13 +40,15 @@ fn shared_prefix_len(first: &[T], second: &[T]) -> usize { /// ```rust /// extern crate triehash; /// extern crate keccak_hasher; +/// extern crate ethereum_types; +/// use ethereum_types::H256; /// use triehash::ordered_trie_root; /// use keccak_hasher::KeccakHasher; /// /// fn main() { /// let v = &["doe", "reindeer"]; -/// let root = "e766d5d51b89dc39d981b41bda63248d7abce4f0225eefd023792a540bcffee3"; -/// assert_eq!(ordered_trie_root::(v), root.into()); +/// let root = H256::from("e766d5d51b89dc39d981b41bda63248d7abce4f0225eefd023792a540bcffee3"); +/// assert_eq!(ordered_trie_root::(v), root.as_ref()); /// } /// ``` pub fn ordered_trie_root(input: I) -> H::Out @@ -54,7 +56,7 @@ where I: IntoIterator, I::Item: AsRef<[u8]>, H: Hasher, - ::Out: cmp::Ord + rlp::Encodable, + ::Out: cmp::Ord, { trie_root::(input.into_iter().enumerate().map(|(i, v)| (rlp::encode(&i), v))) } @@ -63,8 +65,10 @@ where /// /// ```rust /// extern crate triehash; +/// extern crate ethereum_types; /// extern crate keccak_hasher; /// use triehash::trie_root; +/// use ethereum_types::H256; /// use keccak_hasher::KeccakHasher; /// /// fn main() { @@ -74,8 +78,8 @@ where /// ("dogglesworth", "cat"), /// ]; /// -/// let root = "8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3"; -/// assert_eq!(trie_root::(v), root.into()); +/// let root = H256::from("8aad789dff2f538bca5d8ea56e8abe10f4c7ba3a5dea95fea4cd6e7c3a1168d3"); +/// assert_eq!(trie_root::(v), root.as_ref()); /// } /// ``` pub fn trie_root(input: I) -> H::Out @@ -84,7 +88,7 @@ where A: AsRef<[u8]> + Ord, B: AsRef<[u8]>, H: Hasher, - ::Out: cmp::Ord + rlp::Encodable, + ::Out: cmp::Ord, { // first put elements into btree to sort them and to remove duplicates @@ -118,6 +122,8 @@ where /// ```rust /// extern crate triehash; /// extern crate keccak_hasher; +/// extern crate ethereum_types; +/// use ethereum_types::H256; /// use triehash::sec_trie_root; /// use keccak_hasher::KeccakHasher; /// @@ -128,8 +134,8 @@ where /// ("dogglesworth", "cat"), /// ]; /// -/// let root = "d4cd937e4a4368d7931a9cf51686b7e10abb3dce38a39000fd7902a092b64585"; -/// assert_eq!(sec_trie_root::(v), root.into()); +/// let root = H256::from("d4cd937e4a4368d7931a9cf51686b7e10abb3dce38a39000fd7902a092b64585"); +/// assert_eq!(sec_trie_root::(v), root.as_ref()); /// } /// ``` pub fn sec_trie_root(input: I) -> H::Out @@ -138,7 +144,7 @@ where A: AsRef<[u8]>, B: AsRef<[u8]>, H: Hasher, - ::Out: cmp::Ord + rlp::Encodable, + ::Out: cmp::Ord, { trie_root::(input.into_iter().map(|(k, v)| (H::hash(k.as_ref()), v))) } @@ -181,7 +187,6 @@ where A: AsRef<[u8]>, B: AsRef<[u8]>, H: Hasher, - ::Out: rlp::Encodable, { let inlen = input.len(); @@ -264,21 +269,22 @@ where A: AsRef<[u8]>, B: AsRef<[u8]>, H: Hasher, - ::Out: rlp::Encodable, { let mut s = RlpStream::new(); hash256rlp::(input, pre_len, &mut s); let out = s.out(); match out.len() { 0...31 => stream.append_raw(&out, 1), - _ => stream.append(&H::hash(&out)) + _ => stream.append(&H::hash(&out).as_ref()) }; } #[cfg(test)] mod tests { + extern crate ethereum_types; use super::{trie_root, shared_prefix_len, hex_prefix_encode}; use keccak_hasher::KeccakHasher; + use self::ethereum_types::H256; #[test] fn test_hex_prefix_encode() { @@ -317,7 +323,7 @@ mod tests { fn simple_test() { assert_eq!(trie_root::(vec![ (b"A", b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" as &[u8]) - ]), "d23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab".into()); + ]), H256::from("d23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab").as_ref()); } #[test]