From 383f89567305881f865607b023bb8fc69ec23a3f Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 8 Aug 2018 11:19:45 +0200 Subject: [PATCH 1/4] Add a `fastmap` crate that provides the H256FastMap specialized HashMap --- util/fastmap/Cargo.toml | 10 ++++++++++ util/fastmap/src/lib.rs | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 util/fastmap/Cargo.toml create mode 100644 util/fastmap/src/lib.rs diff --git a/util/fastmap/Cargo.toml b/util/fastmap/Cargo.toml new file mode 100644 index 00000000000..3889c670008 --- /dev/null +++ b/util/fastmap/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "fastmap" +version = "0.1.0" +authors = ["Parity Technologies "] +description = "Specialized version of `HashMap` with H256 keys and fast hashing function." +license = "GPL-3.0" + +[dependencies] +ethereum-types = "0.3" +plain_hasher = { git = "https://github.com/paritytech/parity-common" } diff --git a/util/fastmap/src/lib.rs b/util/fastmap/src/lib.rs new file mode 100644 index 00000000000..135ce54babe --- /dev/null +++ b/util/fastmap/src/lib.rs @@ -0,0 +1,39 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +//! Provides a `H256FastMap` type with H256 keys and fast hashing function. + +extern crate ethereum_types; +extern crate plain_hasher; + +use ethereum_types::H256; +use std::hash; +use std::collections::HashMap; +use plain_hasher::PlainHasher; + +/// Specialized version of `HashMap` with H256 keys and fast hashing function. +pub type H256FastMap = HashMap>; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_works() { + let mut h = H256FastMap::default(); + h.insert(H256::from(123), "abc"); + } +} \ No newline at end of file From 441149a68b1126d49ec36bcd134b6ac7232a7e36 Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 8 Aug 2018 11:20:35 +0200 Subject: [PATCH 2/4] Use `fastmap` instead of `plain_hasher` --- Cargo.lock | 14 +++++++++++--- Cargo.toml | 1 + ethcore/light/Cargo.toml | 2 +- ethcore/light/src/client/header_chain.rs | 2 +- ethcore/light/src/lib.rs | 2 +- ethcore/light/src/transaction_queue.rs | 2 +- ethcore/res/wasm-tests | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/sync/src/chain/mod.rs | 2 +- ethcore/sync/src/lib.rs | 2 +- ethcore/sync/src/transactions_stats.rs | 2 +- util/journaldb/Cargo.toml | 2 +- util/journaldb/src/lib.rs | 2 +- util/journaldb/src/overlayrecentdb.rs | 2 +- 14 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 54a05ba05be..1760b3b922c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,6 +597,7 @@ dependencies = [ "ethcore-network 1.12.0", "ethcore-transaction 0.1.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fastmap 0.1.0", "futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -612,7 +613,6 @@ dependencies = [ "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.2.1 (git+https://github.com/paritytech/parity-common)", "patricia-trie-ethereum 0.1.0", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rlp_derive 0.1.0", @@ -845,6 +845,7 @@ dependencies = [ "ethcore-transaction 0.1.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", + "fastmap 0.1.0", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", @@ -856,7 +857,6 @@ dependencies = [ "macros 0.1.0", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1044,6 +1044,14 @@ dependencies = [ "ethkey 0.3.0", ] +[[package]] +name = "fastmap" +version = "0.1.0" +dependencies = [ + "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", +] + [[package]] name = "fdlimit" version = "0.1.1" @@ -1323,6 +1331,7 @@ version = "0.2.0" dependencies = [ "ethcore-logger 1.12.0", "ethereum-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "fastmap 0.1.0", "hashdb 0.2.0 (git+https://github.com/paritytech/parity-common)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (git+https://github.com/paritytech/parity-common)", @@ -1333,7 +1342,6 @@ dependencies = [ "memorydb 0.2.1 (git+https://github.com/paritytech/parity-common)", "parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common)", "parking_lot 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain_hasher 0.1.0 (git+https://github.com/paritytech/parity-common)", "rlp 0.2.1 (git+https://github.com/paritytech/parity-common)", ] diff --git a/Cargo.toml b/Cargo.toml index 697afeab3ae..26b387e80b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -136,6 +136,7 @@ members = [ "util/triehash-ethereum", "util/keccak-hasher", "util/patricia-trie-ethereum", + "util/fastmap", ] [patch.crates-io] diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 6c3a454e20a..16f70de620c 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -20,7 +20,7 @@ ethcore-io = { path = "../../util/io" } hashdb = { git = "https://github.com/paritytech/parity-common" } heapsize = "0.4" vm = { path = "../vm" } -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } rlp_derive = { path = "../../util/rlp_derive" } smallvec = "0.4" diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index 957a1ea4330..4611adbfe0b 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -41,7 +41,7 @@ use ethereum_types::{H256, H264, U256}; use heapsize::HeapSizeOf; use kvdb::{DBTransaction, KeyValueDB}; use parking_lot::{Mutex, RwLock}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use rlp::{Encodable, Decodable, DecoderError, RlpStream, Rlp}; use smallvec::SmallVec; diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index 24c95cfdeb7..e151267a9c9 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -68,7 +68,7 @@ extern crate keccak_hasher; extern crate memorydb; extern crate patricia_trie as trie; extern crate patricia_trie_ethereum as ethtrie; -extern crate plain_hasher; +extern crate fastmap; extern crate rand; extern crate rlp; extern crate parking_lot; diff --git a/ethcore/light/src/transaction_queue.rs b/ethcore/light/src/transaction_queue.rs index e8880037a17..cb017bcb1b1 100644 --- a/ethcore/light/src/transaction_queue.rs +++ b/ethcore/light/src/transaction_queue.rs @@ -29,7 +29,7 @@ use std::collections::hash_map::Entry; use transaction::{self, Condition, PendingTransaction, SignedTransaction}; use ethereum_types::{H256, U256, Address}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; // Knowledge of an account's current nonce. #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/ethcore/res/wasm-tests b/ethcore/res/wasm-tests index 242b8d8a89e..474110de59a 160000 --- a/ethcore/res/wasm-tests +++ b/ethcore/res/wasm-tests @@ -1 +1 @@ -Subproject commit 242b8d8a89ecb3e11277f0beb8180c95792aac6b +Subproject commit 474110de59a0f632b20615256c913b144c49354c diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index dfd45777233..9cdd0d84b07 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -17,7 +17,7 @@ ethcore-transaction = { path = "../transaction" } ethcore = { path = ".." } ethereum-types = "0.3" hashdb = { git = "https://github.com/paritytech/parity-common" } -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } rustc-hex = "1.0" keccak-hash = { git = "https://github.com/paritytech/parity-common" } diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 520226a9c7e..625ccb30d22 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -99,7 +99,7 @@ use std::time::{Duration, Instant}; use hash::keccak; use heapsize::HeapSizeOf; use ethereum_types::{H256, U256}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use parking_lot::RwLock; use bytes::Bytes; use rlp::{Rlp, RlpStream, DecoderError}; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index f9f8a3e3e93..eb38d09d9d5 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -31,7 +31,7 @@ extern crate ethcore; extern crate ethereum_types; extern crate env_logger; extern crate hashdb; -extern crate plain_hasher; +extern crate fastmap; extern crate rand; extern crate semver; extern crate parking_lot; diff --git a/ethcore/sync/src/transactions_stats.rs b/ethcore/sync/src/transactions_stats.rs index c45b1ad8b3c..4d11dcf6809 100644 --- a/ethcore/sync/src/transactions_stats.rs +++ b/ethcore/sync/src/transactions_stats.rs @@ -17,7 +17,7 @@ use api::TransactionStats; use std::collections::{HashSet, HashMap}; use ethereum_types::{H256, H512}; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; type NodeId = H512; type BlockNumber = u64; diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 27b0ae195b7..7e559e229c0 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -15,7 +15,7 @@ kvdb = { git = "https://github.com/paritytech/parity-common" } log = "0.3" memorydb = { git = "https://github.com/paritytech/parity-common" } parking_lot = "0.6" -plain_hasher = { git = "https://github.com/paritytech/parity-common" } +fastmap = { path = "../../util/fastmap" } rlp = { git = "https://github.com/paritytech/parity-common" } [dev-dependencies] diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index b14ef88e923..e88b437d828 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -27,7 +27,7 @@ extern crate keccak_hasher; extern crate kvdb; extern crate memorydb; extern crate parking_lot; -extern crate plain_hasher; +extern crate fastmap; extern crate rlp; #[cfg(test)] diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index b63168e547c..1549d3baa34 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -29,7 +29,7 @@ use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction}; use memorydb::*; use parking_lot::RwLock; -use plain_hasher::H256FastMap; +use fastmap::H256FastMap; use rlp::{Rlp, RlpStream, encode, decode, DecoderError, Decodable, Encodable}; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, JournalDB, error_negatively_reference_hash}; use util::DatabaseKey; From c3b33335c6fe5af283ee6bcd8e001a5001ddd442 Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 8 Aug 2018 12:08:35 +0200 Subject: [PATCH 3/4] =?UTF-8?q?Update=20submodules=20for=20Reasons?= =?UTF-8?q?=E2=84=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ethcore/res/ethereum/tests | 2 +- ethcore/res/wasm-tests | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ethcore/res/ethereum/tests b/ethcore/res/ethereum/tests index b6011c3fb56..aebb8e9eb44 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit b6011c3fb567d7178915574de0a8d4b5331fe725 +Subproject commit aebb8e9eb44611767dc847e90e64fbc4365c1223 diff --git a/ethcore/res/wasm-tests b/ethcore/res/wasm-tests index 474110de59a..242b8d8a89e 160000 --- a/ethcore/res/wasm-tests +++ b/ethcore/res/wasm-tests @@ -1 +1 @@ -Subproject commit 474110de59a0f632b20615256c913b144c49354c +Subproject commit 242b8d8a89ecb3e11277f0beb8180c95792aac6b From 85f25646c83a3abcffc88dc8cb6aa19b8f40154d Mon Sep 17 00:00:00 2001 From: David Palm Date: Wed, 8 Aug 2018 12:45:12 +0200 Subject: [PATCH 4/4] Submodule update --- ethcore/res/ethereum/tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/res/ethereum/tests b/ethcore/res/ethereum/tests index aebb8e9eb44..b6011c3fb56 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit aebb8e9eb44611767dc847e90e64fbc4365c1223 +Subproject commit b6011c3fb567d7178915574de0a8d4b5331fe725