From bcaa9eb027bc8408681e77159d7bbafca9f10f79 Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 6 Dec 2018 20:02:08 +0100 Subject: [PATCH 01/22] Use mem utils crate from parity common --- Cargo.lock | 57 +++++++++++++------ Cargo.toml | 20 ++++++- ethcore/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/evm/benches/basic.rs | 2 +- ethcore/evm/src/interpreter/shared_cache.rs | 6 +- ethcore/evm/src/lib.rs | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/light/src/cache.rs | 8 +-- ethcore/light/src/client/header_chain.rs | 12 ++-- ethcore/light/src/client/mod.rs | 4 +- ethcore/light/src/lib.rs | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/private-tx/src/lib.rs | 2 +- .../private-tx/src/private_transactions.rs | 4 +- ethcore/src/blockchain/blockchain.rs | 22 +++---- ethcore/src/blockchain/extras.rs | 18 +++--- ethcore/src/encoded.rs | 20 ++++--- .../src/engines/validator_set/simple_list.rs | 8 +-- ethcore/src/engines/validator_set/test.rs | 8 +-- ethcore/src/header.rs | 8 +-- ethcore/src/lib.rs | 2 +- ethcore/src/trace/db.rs | 6 +- ethcore/src/trace/types/flat.rs | 20 +++---- ethcore/src/verification/queue/kind.rs | 22 +++---- ethcore/src/verification/queue/mod.rs | 20 +++---- ethcore/src/verification/verification.rs | 12 ++-- ethcore/sync/Cargo.toml | 2 +- ethcore/sync/src/block_sync.rs | 5 +- ethcore/sync/src/blocks.rs | 43 +++++++------- ethcore/sync/src/chain/mod.rs | 7 ++- ethcore/sync/src/lib.rs | 2 +- ethcore/transaction/Cargo.toml | 2 +- ethcore/transaction/src/lib.rs | 2 +- ethcore/transaction/src/transaction.rs | 21 +++---- ethcore/types/Cargo.toml | 2 +- ethcore/types/src/lib.rs | 2 +- ethcore/types/src/log_entry.rs | 8 +-- ethcore/types/src/receipt.rs | 8 +-- ethkey/Cargo.toml | 2 +- ethkey/src/lib.rs | 2 +- miner/Cargo.toml | 2 +- miner/src/lib.rs | 3 +- miner/src/pool/mod.rs | 4 +- util/journaldb/Cargo.toml | 2 +- util/journaldb/src/earlymergedb.rs | 8 +-- util/journaldb/src/lib.rs | 2 +- util/journaldb/src/overlayrecentdb.rs | 12 ++-- util/journaldb/src/refcounteddb.rs | 4 +- util/mem/Cargo.toml | 4 -- util/mem/src/lib.rs | 54 ------------------ util/memory_cache/Cargo.toml | 2 +- util/memory_cache/src/lib.rs | 12 ++-- whisper/Cargo.toml | 2 +- whisper/src/lib.rs | 2 +- 55 files changed, 254 insertions(+), 260 deletions(-) delete mode 100644 util/mem/Cargo.toml delete mode 100644 util/mem/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index f6a828b7cdf..28fc4fe7253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,6 +247,14 @@ dependencies = [ "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "clear_on_drop" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cloudabi" version = "0.0.3" @@ -281,9 +289,9 @@ version = "0.1.0" dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -655,7 +663,6 @@ dependencies = [ "fake-hardware-wallet 0.0.1", "hardware-wallet 1.12.0", "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -676,6 +683,7 @@ dependencies = [ "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -742,7 +750,6 @@ dependencies = [ "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -752,6 +759,7 @@ dependencies = [ "memory-cache 0.1.0", "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -795,12 +803,12 @@ dependencies = [ "ethkey 0.3.0", "fetch 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.12.11 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -880,11 +888,11 @@ dependencies = [ "ethkey 0.3.0", "fetch 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -990,7 +998,6 @@ dependencies = [ "ethkey 0.3.0", "fastmap 0.1.0", "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -998,6 +1005,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1014,8 +1022,8 @@ dependencies = [ "ethjson 0.1.0", "ethkey 0.3.0", "evm 0.1.0", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "unexpected 0.1.0", @@ -1063,8 +1071,8 @@ dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "mem 0.1.0", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1137,12 +1145,12 @@ dependencies = [ "bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "criterion 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -1656,7 +1664,6 @@ dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1664,6 +1671,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1953,15 +1961,20 @@ dependencies = [ name = "macros" version = "0.1.0" +[[package]] +name = "malloc_size_of_derive" +version = "0.0.1" +dependencies = [ + "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", + "synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "matches" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "mem" -version = "0.1.0" - [[package]] name = "memchr" version = "2.1.0" @@ -1990,8 +2003,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "memory-cache" version = "0.1.0" dependencies = [ - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", ] [[package]] @@ -2328,7 +2341,6 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-rocksdb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "mem 0.1.0", "migration-rocksdb 0.1.0", "node-filter 1.12.0", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2603,6 +2615,16 @@ dependencies = [ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "parity-util-mem" +version = "0.1.0" +dependencies = [ + "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "malloc_size_of_derive 0.0.1", +] + [[package]] name = "parity-version" version = "2.3.0" @@ -2637,9 +2659,9 @@ dependencies = [ "jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "mem 0.1.0", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4243,6 +4265,7 @@ dependencies = [ "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0e37fba0087d9f3f4e269827a55dc511abf3e440cc097a0c154ff4e6584f988" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" +"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17" "checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" "checksum cmake 0.1.35 (registry+https://github.com/rust-lang/crates.io-index)" = "6ec65ee4f9c9d16f335091d23693457ed4928657ba4982289d7fafee03bc614a" "checksum combine 3.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fc1d011beeed29187b8db2ac3925c8dd4d3e87db463dc9d2d2833985388fc5bc" diff --git a/Cargo.toml b/Cargo.toml index a777771e45f..e8be6d51d26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,7 +64,6 @@ migration-rocksdb = { path = "util/migration-rocksdb" } kvdb = "0.1" kvdb-rocksdb = "0.1.3" journaldb = { path = "util/journaldb" } -mem = { path = "util/mem" } ethcore-secretstore = { path = "secret_store", optional = true } @@ -136,4 +135,23 @@ members = [ "util/keccak-hasher", "util/patricia-trie-ethereum", "util/fastmap", + "util/journaldb", ] + +#[patch.crates-io] +#ethabi = { path = "../../ethabi/ethabi" } +#ethabi-derive = { path = "../../ethabi/derive" } +#fixed-hash = { path = "../../parity-common/fixed-hash" } +#keccak-hash = { path = "../../parity-common/keccak-hash" } +#memorydb = { path = "../../parity-common/memorydb" } +#hashdb = { path = "../../parity-common/hashdb" } +#kvdb = { path = "../../parity-common/kvdb" } +#patricia-trie = { path = "../../parity-common/patricia_trie" } +#rlp = { path = "../../parity-common/rlp" } +#uint = { path = "../../parity-common/uint" } +#ethereum-types = { path = "../../parity-primitives/ethereum-types" } +#ethbloom = { path = "../../parity-primitives/ethbloom" } +#[replace] +#"fixed-hash:0.2.2" = { path = "../../parity-common/fixed-hash" } +#"uint:0.4.1" = { path = "../../parity-common/uint" } +#"ethereum-types:0.4.0" = { path = "../../parity-primitives/ethereum-types" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 4d1f120586a..5d918098db6 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -36,7 +36,7 @@ ethjson = { path = "../json" } ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } evm = { path = "evm" } -heapsize = "0.4" +parity-util-mem = { path = "../../../parity-common/mem" } itertools = "0.5" lazy_static = "1.0" log = "0.4" diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 9f47d8714b8..7267c1a7159 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] bit-set = "0.4" parity-bytes = "0.1" ethereum-types = "0.4" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } lazy_static = "1.0" log = "0.4" vm = { path = "../vm" } diff --git a/ethcore/evm/benches/basic.rs b/ethcore/evm/benches/basic.rs index c254abe298e..6e5f2672c9a 100644 --- a/ethcore/evm/benches/basic.rs +++ b/ethcore/evm/benches/basic.rs @@ -21,7 +21,7 @@ extern crate criterion; extern crate bit_set; extern crate ethereum_types; extern crate parking_lot; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate vm; extern crate evm; extern crate keccak_hash as hash; diff --git a/ethcore/evm/src/interpreter/shared_cache.rs b/ethcore/evm/src/interpreter/shared_cache.rs index 63c4f507d82..d3063714680 100644 --- a/ethcore/evm/src/interpreter/shared_cache.rs +++ b/ethcore/evm/src/interpreter/shared_cache.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use hash::KECCAK_EMPTY; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::H256; use parking_lot::Mutex; use memory_cache::MemoryLruCache; @@ -28,8 +28,8 @@ const DEFAULT_CACHE_SIZE: usize = 4 * 1024 * 1024; // stub for a HeapSizeOf implementation. struct Bits(Arc); -impl HeapSizeOf for Bits { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for Bits { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { // dealing in bits here self.0.capacity() * 8 } diff --git a/ethcore/evm/src/lib.rs b/ethcore/evm/src/lib.rs index 6b1b1d3bf86..c26c80f56b6 100644 --- a/ethcore/evm/src/lib.rs +++ b/ethcore/evm/src/lib.rs @@ -19,7 +19,7 @@ extern crate bit_set; extern crate ethereum_types; extern crate parking_lot; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate vm; extern crate keccak_hash as hash; extern crate memory_cache; diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index d4bdc628cb0..e3afb7f6a69 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -18,7 +18,7 @@ patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } hashdb = "0.3.0" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] } diff --git a/ethcore/light/src/cache.rs b/ethcore/light/src/cache.rs index 22339f40a81..fb8c99a45ee 100644 --- a/ethcore/light/src/cache.rs +++ b/ethcore/light/src/cache.rs @@ -26,7 +26,7 @@ use ethcore::receipt::Receipt; use stats::Corpus; use std::time::{Instant, Duration}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use ethereum_types::{H256, U256}; use memory_cache::MemoryLruCache; @@ -157,12 +157,12 @@ impl Cache { /// Get the memory used. pub fn mem_used(&self) -> usize { - self.heap_size_of_children() + self.m_size_of() } } -impl HeapSizeOf for Cache { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for Cache { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { self.headers.current_size() + self.canon_hashes.current_size() + self.bodies.current_size() diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index f6d903176c9..ce03195a63e 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -38,7 +38,7 @@ use ethcore::header::Header; use ethcore::ids::BlockId; use ethcore::spec::{Spec, SpecHardcodedSync}; use ethereum_types::{H256, H264, U256}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use kvdb::{DBTransaction, KeyValueDB}; use parking_lot::{Mutex, RwLock}; use fastmap::H256FastMap; @@ -95,8 +95,8 @@ struct Entry { canonical_hash: H256, } -impl HeapSizeOf for Entry { - fn heap_size_of_children(&self) -> usize { +impl MallocSizeOf for Entry { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { if self.candidates.spilled() { self.candidates.capacity() * ::std::mem::size_of::() } else { @@ -832,9 +832,9 @@ impl HeaderChain { } } -impl HeapSizeOf for HeaderChain { - fn heap_size_of_children(&self) -> usize { - self.candidates.read().heap_size_of_children() +impl MallocSizeOf for HeaderChain { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.candidates.read().size_of(ops) } } diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index e1c823ee2da..0102fc5c23d 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -354,9 +354,9 @@ impl Client { /// Get blockchain mem usage in bytes. pub fn chain_mem_used(&self) -> usize { - use heapsize::HeapSizeOf; + use mem::MallocSizeOfExt; - self.chain.heap_size_of_children() + self.chain.m_size_of() } /// Get a handle to the verification engine. diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index 1102f58bc05..e2b5e02b13b 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -61,7 +61,7 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate ethcore; extern crate hashdb; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate failsafe; extern crate futures; extern crate itertools; diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index d8705b4b6fa..9637f06f56c 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -22,7 +22,7 @@ ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } keccak-hash = "0.1.2" log = "0.4" parking_lot = "0.6" diff --git a/ethcore/private-tx/src/lib.rs b/ethcore/private-tx/src/lib.rs index 5e480b7edb9..1cfc7b66e45 100644 --- a/ethcore/private-tx/src/lib.rs +++ b/ethcore/private-tx/src/lib.rs @@ -37,7 +37,7 @@ extern crate ethkey; extern crate ethjson; extern crate fetch; extern crate futures; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate keccak_hash as hash; extern crate parking_lot; extern crate patricia_trie as trie; diff --git a/ethcore/private-tx/src/private_transactions.rs b/ethcore/private-tx/src/private_transactions.rs index a0f58f9cabc..c781efe62fd 100644 --- a/ethcore/private-tx/src/private_transactions.rs +++ b/ethcore/private-tx/src/private_transactions.rs @@ -21,7 +21,7 @@ use std::collections::{HashMap, HashSet}; use bytes::Bytes; use ethcore_miner::pool; use ethereum_types::{H256, U256, Address}; -use heapsize::HeapSizeOf; +use mem::MallocSizeOfExt; use ethkey::Signature; use messages::PrivateTransaction; use parking_lot::RwLock; @@ -59,7 +59,7 @@ impl txpool::VerifiedTransaction for VerifiedPrivateTransaction { } fn mem_usage(&self) -> usize { - self.transaction.heap_size_of_children() + self.transaction.m_size_of() } fn sender(&self) -> &Address { diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 4286dc41482..bed57267376 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -37,7 +37,7 @@ use engines::ForkChoice; use ethereum_types::{H256, Bloom, BloomRef, U256}; use error::Error as EthcoreError; use header::*; -use heapsize::HeapSizeOf; +use mem::MallocSizeOfExt; use itertools::Itertools; use kvdb::{DBTransaction, KeyValueDB}; use log_entry::{LogEntry, LocalizedLogEntry}; @@ -1465,10 +1465,10 @@ impl BlockChain { /// Get current cache size. pub fn cache_size(&self) -> CacheSize { CacheSize { - blocks: self.block_headers.read().heap_size_of_children() + self.block_bodies.read().heap_size_of_children(), - block_details: self.block_details.read().heap_size_of_children(), - transaction_addresses: self.transaction_addresses.read().heap_size_of_children(), - block_receipts: self.block_receipts.read().heap_size_of_children(), + blocks: self.block_headers.read().m_size_of() + self.block_bodies.read().m_size_of(), + block_details: self.block_details.read().m_size_of(), + transaction_addresses: self.transaction_addresses.read().m_size_of(), + block_receipts: self.block_receipts.read().m_size_of(), } } @@ -1503,12 +1503,12 @@ impl BlockChain { transaction_addresses.shrink_to_fit(); block_receipts.shrink_to_fit(); - block_headers.heap_size_of_children() + - block_bodies.heap_size_of_children() + - block_details.heap_size_of_children() + - block_hashes.heap_size_of_children() + - transaction_addresses.heap_size_of_children() + - block_receipts.heap_size_of_children() + block_headers.m_size_of() + + block_bodies.m_size_of() + + block_details.m_size_of() + + block_hashes.m_size_of() + + transaction_addresses.m_size_of() + + block_receipts.m_size_of() }); } diff --git a/ethcore/src/blockchain/extras.rs b/ethcore/src/blockchain/extras.rs index 1dd51b7c753..9f1b4ae309c 100644 --- a/ethcore/src/blockchain/extras.rs +++ b/ethcore/src/blockchain/extras.rs @@ -23,7 +23,7 @@ use db::Key; use engines::epoch::{Transition as EpochTransition}; use ethereum_types::{H256, H264, U256}; use header::BlockNumber; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use kvdb::PREFIX_LEN as DB_PREFIX_LEN; use receipt::Receipt; use rlp; @@ -195,9 +195,9 @@ impl rlp::Decodable for BlockDetails { } } -impl HeapSizeOf for BlockDetails { - fn heap_size_of_children(&self) -> usize { - self.children.heap_size_of_children() +impl MallocSizeOf for BlockDetails { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.children.size_of(ops) } } @@ -210,8 +210,8 @@ pub struct TransactionAddress { pub index: usize } -impl HeapSizeOf for TransactionAddress { - fn heap_size_of_children(&self) -> usize { 0 } +impl MallocSizeOf for TransactionAddress { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } } /// Contains all block receipts. @@ -228,9 +228,9 @@ impl BlockReceipts { } } -impl HeapSizeOf for BlockReceipts { - fn heap_size_of_children(&self) -> usize { - self.receipts.heap_size_of_children() +impl MallocSizeOf for BlockReceipts { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.receipts.size_of(ops) } } diff --git a/ethcore/src/encoded.rs b/ethcore/src/encoded.rs index 9573bb5d16c..b08e0710649 100644 --- a/ethcore/src/encoded.rs +++ b/ethcore/src/encoded.rs @@ -27,7 +27,7 @@ use block::Block as FullBlock; use ethereum_types::{H256, Bloom, U256, Address}; use hash::keccak; use header::{BlockNumber, Header as FullHeader}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use rlp::{self, Rlp, RlpStream}; use transaction::UnverifiedTransaction; use views::{self, BlockView, HeaderView, BodyView}; @@ -36,8 +36,10 @@ use views::{self, BlockView, HeaderView, BodyView}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Header(Vec); -impl HeapSizeOf for Header { - fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() } +impl MallocSizeOf for Header { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + } } impl Header { @@ -115,8 +117,10 @@ impl Header { #[derive(Debug, Clone, PartialEq, Eq)] pub struct Body(Vec); -impl HeapSizeOf for Body { - fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() } +impl MallocSizeOf for Body { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + } } impl Body { @@ -180,8 +184,10 @@ impl Body { #[derive(Debug, Clone, PartialEq, Eq)] pub struct Block(Vec); -impl HeapSizeOf for Block { - fn heap_size_of_children(&self) -> usize { self.0.heap_size_of_children() } +impl MallocSizeOf for Block { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) + } } impl Block { diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/src/engines/validator_set/simple_list.rs index dc269600d00..b0a6d96a868 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/src/engines/validator_set/simple_list.rs @@ -16,7 +16,7 @@ /// Preconfigured validator list. -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::{H256, Address}; use machine::{AuxiliaryData, Call, EthereumMachine}; @@ -57,9 +57,9 @@ impl From> for SimpleList { } } -impl HeapSizeOf for SimpleList { - fn heap_size_of_children(&self) -> usize { - self.validators.heap_size_of_children() +impl MallocSizeOf for SimpleList { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.validators.size_of(ops) } } diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index 6459803d191..e85a524d078 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -19,7 +19,7 @@ use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::{H256, Address}; use bytes::Bytes; @@ -44,9 +44,9 @@ impl TestSet { } } -impl HeapSizeOf for TestSet { - fn heap_size_of_children(&self) -> usize { - self.validator.heap_size_of_children() +impl MallocSizeOf for TestSet { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.validator.size_of(ops) } } diff --git a/ethcore/src/header.rs b/ethcore/src/header.rs index 100210b70bc..d1f89329112 100644 --- a/ethcore/src/header.rs +++ b/ethcore/src/header.rs @@ -18,7 +18,7 @@ use std::cmp; use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::{H256, U256, Address, Bloom}; use bytes::Bytes; use rlp::{Rlp, RlpStream, Encodable, DecoderError, Decodable}; @@ -370,9 +370,9 @@ impl Encodable for Header { } } -impl HeapSizeOf for Header { - fn heap_size_of_children(&self) -> usize { - self.extra_data.heap_size_of_children() + self.seal.heap_size_of_children() +impl MallocSizeOf for Header { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.extra_data.size_of(ops) + self.seal.size_of(ops) } } diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 852cf1e1cf4..b2c41a3db46 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -92,7 +92,7 @@ extern crate rlp; extern crate rlp_compress; extern crate keccak_hash as hash; extern crate keccak_hasher; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate memorydb; extern crate patricia_trie as trie; extern crate patricia_trie_ethereum as ethtrie; diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 12e62826951..4f1d871a26c 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -18,7 +18,7 @@ use std::collections::HashMap; use std::sync::Arc; use blockchain::{BlockChainDB}; -use heapsize::HeapSizeOf; +use mem::MallocSizeOfExt; use ethereum_types::{H256, H264}; use kvdb::{DBTransaction}; use parking_lot::RwLock; @@ -86,7 +86,7 @@ impl TraceDB where T: DatabaseExtras { } fn cache_size(&self) -> usize { - self.traces.read().heap_size_of_children() + self.traces.read().m_size_of() } /// Let the cache system know that a cacheable item has been used. @@ -108,7 +108,7 @@ impl TraceDB where T: DatabaseExtras { } traces.shrink_to_fit(); - traces.heap_size_of_children() + traces.m_size_of() }); } diff --git a/ethcore/src/trace/types/flat.rs b/ethcore/src/trace/types/flat.rs index f4cbba665ab..876b090c26b 100644 --- a/ethcore/src/trace/types/flat.rs +++ b/ethcore/src/trace/types/flat.rs @@ -17,7 +17,7 @@ //! Flat trace module use rlp::{Rlp, RlpStream, Decodable, Encodable, DecoderError}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::Bloom; use super::trace::{Action, Res}; @@ -45,9 +45,9 @@ impl FlatTrace { } } -impl HeapSizeOf for FlatTrace { - fn heap_size_of_children(&self) -> usize { - self.trace_address.heap_size_of_children() +impl MallocSizeOf for FlatTrace { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.trace_address.size_of(ops) } } @@ -85,9 +85,9 @@ impl From> for FlatTransactionTraces { } } -impl HeapSizeOf for FlatTransactionTraces { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() +impl MallocSizeOf for FlatTransactionTraces { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) } } @@ -108,9 +108,9 @@ impl Into> for FlatTransactionTraces { #[derive(Debug, PartialEq, Clone, Default, RlpEncodableWrapper, RlpDecodableWrapper)] pub struct FlatBlockTraces(Vec); -impl HeapSizeOf for FlatBlockTraces { - fn heap_size_of_children(&self) -> usize { - self.0.heap_size_of_children() +impl MallocSizeOf for FlatBlockTraces { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.0.size_of(ops) } } diff --git a/ethcore/src/verification/queue/kind.rs b/ethcore/src/verification/queue/kind.rs index 5333cc7e311..63247edaefe 100644 --- a/ethcore/src/verification/queue/kind.rs +++ b/ethcore/src/verification/queue/kind.rs @@ -19,7 +19,7 @@ use engines::EthEngine; use error::Error; -use heapsize::HeapSizeOf; +use mem::MallocSizeOf; use ethereum_types::{H256, U256}; pub use self::blocks::Blocks; @@ -49,13 +49,13 @@ pub trait BlockLike { /// consistent. pub trait Kind: 'static + Sized + Send + Sync { /// The first stage: completely unverified. - type Input: Sized + Send + BlockLike + HeapSizeOf; + type Input: Sized + Send + BlockLike + MallocSizeOf; /// The second stage: partially verified. - type Unverified: Sized + Send + BlockLike + HeapSizeOf; + type Unverified: Sized + Send + BlockLike + MallocSizeOf; /// The third stage: completely verified. - type Verified: Sized + Send + BlockLike + HeapSizeOf; + type Verified: Sized + Send + BlockLike + MallocSizeOf; /// Attempt to create the `Unverified` item from the input. fn create(input: Self::Input, engine: &EthEngine, check_seal: bool) -> Result; @@ -74,7 +74,7 @@ pub mod blocks { use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered}; use transaction::UnverifiedTransaction; - use heapsize::HeapSizeOf; + use mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::{H256, U256}; use bytes::Bytes; @@ -146,12 +146,12 @@ pub mod blocks { } } - impl HeapSizeOf for Unverified { - fn heap_size_of_children(&self) -> usize { - self.header.heap_size_of_children() - + self.transactions.heap_size_of_children() - + self.uncles.heap_size_of_children() - + self.bytes.heap_size_of_children() + impl MallocSizeOf for Unverified { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.header.size_of(ops) + + self.transactions.size_of(ops) + + self.uncles.size_of(ops) + + self.bytes.size_of(ops) } } diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index f6b1f48dc78..6b151b3b890 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -22,7 +22,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering}; use std::sync::Arc; use std::cmp; use std::collections::{VecDeque, HashSet, HashMap}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use ethereum_types::{H256, U256}; use parking_lot::{Condvar, Mutex, RwLock}; use io::*; @@ -101,9 +101,9 @@ pub struct Verifying { output: Option, } -impl HeapSizeOf for Verifying { - fn heap_size_of_children(&self) -> usize { - self.output.heap_size_of_children() +impl MallocSizeOf for Verifying { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.output.size_of(ops) } } @@ -353,7 +353,7 @@ impl VerificationQueue { None => continue, }; - verification.sizes.unverified.fetch_sub(item.heap_size_of_children(), AtomicOrdering::SeqCst); + verification.sizes.unverified.fetch_sub(item.m_size_of(), AtomicOrdering::SeqCst); verifying.push_back(Verifying { hash: item.hash(), output: None }); item }; @@ -367,7 +367,7 @@ impl VerificationQueue { if e.hash == hash { idx = Some(i); - verification.sizes.verifying.fetch_add(verified.heap_size_of_children(), AtomicOrdering::SeqCst); + verification.sizes.verifying.fetch_add(verified.m_size_of(), AtomicOrdering::SeqCst); e.output = Some(verified); break; } @@ -417,7 +417,7 @@ impl VerificationQueue { while let Some(output) = verifying.front_mut().and_then(|x| x.output.take()) { assert!(verifying.pop_front().is_some()); - let size = output.heap_size_of_children(); + let size = output.m_size_of(); removed_size += size; if bad.contains(&output.parent_hash()) { @@ -490,7 +490,7 @@ impl VerificationQueue { match K::create(input, &*self.engine, self.verification.check_seal) { Ok(item) => { - self.verification.sizes.unverified.fetch_add(item.heap_size_of_children(), AtomicOrdering::SeqCst); + self.verification.sizes.unverified.fetch_add(item.m_size_of(), AtomicOrdering::SeqCst); self.processing.write().insert(hash, item.difficulty()); { @@ -537,7 +537,7 @@ impl VerificationQueue { let mut removed_size = 0; for output in verified.drain(..) { if bad.contains(&output.parent_hash()) { - removed_size += output.heap_size_of_children(); + removed_size += output.m_size_of(); bad.insert(output.hash()); if let Some(difficulty) = processing.remove(&output.hash()) { let mut td = self.total_difficulty.write(); @@ -574,7 +574,7 @@ impl VerificationQueue { let count = cmp::min(max, verified.len()); let result = verified.drain(..count).collect::>(); - let drained_size = result.iter().map(HeapSizeOf::heap_size_of_children).fold(0, |a, c| a + c); + let drained_size = result.iter().map(MallocSizeOfExt::m_size_of).fold(0, |a, c| a + c); self.verification.sizes.verified.fetch_sub(drained_size, AtomicOrdering::SeqCst); self.ready_signal.reset(); diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 3bfe30a4495..161d09ecb34 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -26,7 +26,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use bytes::Bytes; use hash::keccak; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; use rlp::Rlp; use triehash::ordered_trie_root; use unexpected::{Mismatch, OutOfBounds}; @@ -51,11 +51,11 @@ pub struct PreverifiedBlock { pub bytes: Bytes, } -impl HeapSizeOf for PreverifiedBlock { - fn heap_size_of_children(&self) -> usize { - self.header.heap_size_of_children() - + self.transactions.heap_size_of_children() - + self.bytes.heap_size_of_children() +impl MallocSizeOf for PreverifiedBlock { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.header.size_of(ops) + + self.transactions.size_of(ops) + + self.bytes.size_of(ops) } } diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index c38fa71c03e..5fec115d1d6 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -28,7 +28,7 @@ macros = { path = "../../util/macros" } log = "0.4" env_logger = "0.5" rand = "0.4" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } parking_lot = "0.6" trace-time = "0.1" diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index 149e312245d..9907b9f5aa8 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -20,7 +20,7 @@ use std::collections::{HashSet, VecDeque}; use std::cmp; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use ethereum_types::H256; use rlp::{self, Rlp}; use ethcore::header::BlockNumber; @@ -220,9 +220,10 @@ impl BlockDownloader { self.state = State::Blocks; } + // TODO switch to MallocSizeOf !! /// Returns used heap memory size. pub fn heap_size(&self) -> usize { - self.blocks.heap_size() + self.round_parents.heap_size_of_children() + self.blocks.heap_size() + self.round_parents.m_size_of() } /// Returns best imported block number. diff --git a/ethcore/sync/src/blocks.rs b/ethcore/sync/src/blocks.rs index 5f0f6a0c23d..87ac40da54b 100644 --- a/ethcore/sync/src/blocks.rs +++ b/ethcore/sync/src/blocks.rs @@ -16,7 +16,7 @@ use std::collections::{HashSet, HashMap, hash_map}; use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use ethereum_types::H256; use triehash_ethereum::ordered_trie_root; use bytes::Bytes; @@ -26,7 +26,7 @@ use ethcore::header::Header as BlockHeader; use ethcore::verification::queue::kind::blocks::Unverified; use transaction::UnverifiedTransaction; -known_heap_size!(0, HeaderId); +malloc_size_of_is_0!(HeaderId); #[derive(PartialEq, Debug, Clone)] pub struct SyncHeader { @@ -34,10 +34,10 @@ pub struct SyncHeader { pub header: BlockHeader, } -impl HeapSizeOf for SyncHeader { - fn heap_size_of_children(&self) -> usize { - self.bytes.heap_size_of_children() - + self.header.heap_size_of_children() +impl MallocSizeOf for SyncHeader { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.bytes.size_of(ops) + + self.header.size_of(ops) } } @@ -85,12 +85,12 @@ impl SyncBody { } } -impl HeapSizeOf for SyncBody { - fn heap_size_of_children(&self) -> usize { - self.transactions_bytes.heap_size_of_children() - + self.transactions.heap_size_of_children() - + self.uncles_bytes.heap_size_of_children() - + self.uncles.heap_size_of_children() +impl MallocSizeOf for SyncBody { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.transactions_bytes.size_of(ops) + + self.transactions.size_of(ops) + + self.uncles_bytes.size_of(ops) + + self.uncles.size_of(ops) } } @@ -102,9 +102,9 @@ struct SyncBlock { receipts_root: H256, } -impl HeapSizeOf for SyncBlock { - fn heap_size_of_children(&self) -> usize { - self.header.heap_size_of_children() + self.body.heap_size_of_children() +impl MallocSizeOf for SyncBlock { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.header.size_of(ops) + self.body.size_of(ops) } } @@ -399,14 +399,15 @@ impl BlockCollection { self.heads.len() } + // TODO switch to MallocSizeOf !! /// Return used heap size. pub fn heap_size(&self) -> usize { - self.heads.heap_size_of_children() - + self.blocks.heap_size_of_children() - + self.parents.heap_size_of_children() - + self.header_ids.heap_size_of_children() - + self.downloading_headers.heap_size_of_children() - + self.downloading_bodies.heap_size_of_children() + self.heads.m_size_of() + + self.blocks.m_size_of() + + self.parents.m_size_of() + + self.header_ids.m_size_of() + + self.downloading_headers.m_size_of() + + self.downloading_bodies.m_size_of() } /// Check if given block hash is marked as being downloaded. diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index a01b25528f0..e7a978a3c34 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -97,7 +97,7 @@ use std::collections::{HashSet, HashMap, BTreeMap}; use std::cmp; use std::time::{Duration, Instant}; use hash::keccak; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use ethereum_types::{H256, U256}; use fastmap::{H256FastMap, H256FastSet}; use parking_lot::{Mutex, RwLock, RwLockWriteGuard}; @@ -122,7 +122,7 @@ use self::propagator::SyncPropagator; use self::requester::SyncRequester; pub(crate) use self::supplier::SyncSupplier; -known_heap_size!(0, PeerInfo); +malloc_size_of_is_0!(PeerInfo); pub type PacketDecodeError = DecoderError; @@ -682,10 +682,11 @@ impl ChainSync { num_active_peers: self.peers.values().filter(|p| p.is_allowed() && p.asking != PeerAsking::Nothing).count(), num_snapshot_chunks: self.snapshot.total_chunks(), snapshot_chunks_done: self.snapshot.done_chunks(), + // TODO implement and use MallocSizeOf mem_used: self.new_blocks.heap_size() + self.old_blocks.as_ref().map_or(0, |d| d.heap_size()) - + self.peers.heap_size_of_children(), + + self.peers.m_size_of(), } } diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index 294ba0cd781..9f2de985c8b 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -49,7 +49,7 @@ extern crate macros; #[macro_use] extern crate log; #[macro_use] -extern crate heapsize; +extern crate parity_util_mem as mem; #[macro_use] extern crate trace_time; diff --git a/ethcore/transaction/Cargo.toml b/ethcore/transaction/Cargo.toml index 1481f87160c..e6fc06b9569 100644 --- a/ethcore/transaction/Cargo.toml +++ b/ethcore/transaction/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } evm = { path = "../evm" } -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } keccak-hash = "0.1" rlp = { version = "0.3.0", features = ["ethereum"] } unexpected = { path = "../../util/unexpected" } diff --git a/ethcore/transaction/src/lib.rs b/ethcore/transaction/src/lib.rs index 829613cf9c7..adcf30bf625 100644 --- a/ethcore/transaction/src/lib.rs +++ b/ethcore/transaction/src/lib.rs @@ -20,7 +20,7 @@ extern crate ethereum_types; extern crate ethjson; extern crate ethkey; extern crate evm; -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate keccak_hash as hash; extern crate rlp; extern crate unexpected; diff --git a/ethcore/transaction/src/transaction.rs b/ethcore/transaction/src/transaction.rs index ee37f68524d..9fbfa32b8de 100644 --- a/ethcore/transaction/src/transaction.rs +++ b/ethcore/transaction/src/transaction.rs @@ -23,7 +23,8 @@ use ethjson; use ethkey::{self, Signature, Secret, Public, recover, public_to_address}; use evm::Schedule; use hash::keccak; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfOps}; + use rlp::{self, RlpStream, Rlp, DecoderError, Encodable}; type Bytes = Vec; @@ -132,9 +133,9 @@ impl Transaction { } } -impl HeapSizeOf for Transaction { - fn heap_size_of_children(&self) -> usize { - self.data.heap_size_of_children() +impl MallocSizeOf for Transaction { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.data.size_of(ops) } } @@ -282,9 +283,9 @@ pub struct UnverifiedTransaction { hash: H256, } -impl HeapSizeOf for UnverifiedTransaction { - fn heap_size_of_children(&self) -> usize { - self.unsigned.heap_size_of_children() +impl MallocSizeOf for UnverifiedTransaction { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.unsigned.size_of(ops) } } @@ -423,9 +424,9 @@ pub struct SignedTransaction { public: Option, } -impl HeapSizeOf for SignedTransaction { - fn heap_size_of_children(&self) -> usize { - self.transaction.heap_size_of_children() +impl MallocSizeOf for SignedTransaction { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.transaction.size_of(ops) } } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 1833db871ce..3a5ddae6172 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -11,7 +11,7 @@ parity-bytes = "0.1" ethereum-types = "0.4" ethjson = { path = "../../json" } keccak-hash = "0.1" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } [dev-dependencies] rustc-hex= "1.0" diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index f375fec13c9..6b3ca4aea68 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -23,7 +23,7 @@ extern crate rlp; #[macro_use] extern crate rlp_derive; extern crate keccak_hash as hash; -extern crate heapsize; +extern crate parity_util_mem as mem; #[cfg(test)] extern crate rustc_hex; diff --git a/ethcore/types/src/log_entry.rs b/ethcore/types/src/log_entry.rs index 0b7455df496..7b342ce772f 100644 --- a/ethcore/types/src/log_entry.rs +++ b/ethcore/types/src/log_entry.rs @@ -17,7 +17,7 @@ //! Log entry type definition. use std::ops::Deref; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; use bytes::Bytes; use ethereum_types::{H256, Address, Bloom, BloomInput}; @@ -35,9 +35,9 @@ pub struct LogEntry { pub data: Bytes, } -impl HeapSizeOf for LogEntry { - fn heap_size_of_children(&self) -> usize { - self.topics.heap_size_of_children() + self.data.heap_size_of_children() +impl MallocSizeOf for LogEntry { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.topics.size_of(ops) + self.data.size_of(ops) } } diff --git a/ethcore/types/src/receipt.rs b/ethcore/types/src/receipt.rs index ec3b3c66f55..d9c73f2e8f0 100644 --- a/ethcore/types/src/receipt.rs +++ b/ethcore/types/src/receipt.rs @@ -17,7 +17,7 @@ //! Receipt use ethereum_types::{H160, H256, U256, Address, Bloom}; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; use rlp::{Rlp, RlpStream, Encodable, Decodable, DecoderError}; use BlockNumber; @@ -110,9 +110,9 @@ impl Decodable for Receipt { } } -impl HeapSizeOf for Receipt { - fn heap_size_of_children(&self) -> usize { - self.logs.heap_size_of_children() +impl MallocSizeOf for Receipt { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.logs.size_of(ops) } } diff --git a/ethkey/Cargo.toml b/ethkey/Cargo.toml index 536e5b47d9c..074311c78cd 100644 --- a/ethkey/Cargo.toml +++ b/ethkey/Cargo.toml @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.4" lazy_static = "1.0" log = "0.4" -mem = { path = "../util/mem" } +parity-util-mem = { path = "../../../parity-common/mem" } parity-wordlist = "1.2" quick-error = "1.2.2" rand = "0.4" diff --git a/ethkey/src/lib.rs b/ethkey/src/lib.rs index 013a60cd3a8..270f46acfab 100644 --- a/ethkey/src/lib.rs +++ b/ethkey/src/lib.rs @@ -20,7 +20,7 @@ extern crate byteorder; extern crate edit_distance; extern crate parity_crypto; extern crate ethereum_types; -extern crate mem; +extern crate parity_util_mem as mem; extern crate parity_wordlist; #[macro_use] extern crate quick_error; diff --git a/miner/Cargo.toml b/miner/Cargo.toml index b3e0daaa1c7..f940b915c50 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -20,7 +20,7 @@ ethcore-transaction = { path = "../ethcore/transaction" } ethereum-types = "0.4" futures = "0.1" parity-runtime = { path = "../util/runtime" } -heapsize = "0.4" +parity-util-mem = { path = "../../../parity-common/mem" } keccak-hash = "0.1" linked-hash-map = "0.5" log = "0.4" diff --git a/miner/src/lib.rs b/miner/src/lib.rs index 2288d1db180..fcd1e5b12f6 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -24,7 +24,8 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate futures; extern crate parity_runtime; -extern crate heapsize; + +extern crate parity_util_mem as mem; extern crate keccak_hash as hash; extern crate linked_hash_map; extern crate parking_lot; diff --git a/miner/src/pool/mod.rs b/miner/src/pool/mod.rs index ccfbba7f800..cba5e286595 100644 --- a/miner/src/pool/mod.rs +++ b/miner/src/pool/mod.rs @@ -17,7 +17,7 @@ //! Transaction Pool use ethereum_types::{U256, H256, Address}; -use heapsize::HeapSizeOf; +use mem::MallocSizeOfExt; use transaction; use txpool; @@ -175,7 +175,7 @@ impl txpool::VerifiedTransaction for VerifiedTransaction { } fn mem_usage(&self) -> usize { - self.transaction.heap_size_of_children() + self.transaction.m_size_of() } fn sender(&self) -> &Address { diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 709664a534f..6d37a4171b7 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL3" parity-bytes = "0.1" ethereum-types = "0.4" hashdb = "0.3.0" -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index e50df30733e..b45b953d61e 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; @@ -40,8 +40,8 @@ struct RefInfo { in_archive: bool, } -impl HeapSizeOf for RefInfo { - fn heap_size_of_children(&self) -> usize { 0 } +impl MallocSizeOf for RefInfo { + fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } } #[derive(Clone, PartialEq, Eq)] @@ -353,7 +353,7 @@ impl JournalDB for EarlyMergeDB { fn mem_used(&self) -> usize { self.overlay.mem_used() + match self.refs { - Some(ref c) => c.read().heap_size_of_children(), + Some(ref c) => c.read().m_size_of(), None => 0 } } diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index e88b437d828..635b82b50d0 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -16,7 +16,7 @@ //! `JournalDB` interface and implementation. -extern crate heapsize; +extern crate parity_util_mem as mem; #[macro_use] extern crate log; diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 017447bcc4b..a91977011bb 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; @@ -135,9 +135,9 @@ struct JournalEntry { deletions: Vec, } -impl HeapSizeOf for JournalEntry { - fn heap_size_of_children(&self) -> usize { - self.insertions.heap_size_of_children() + self.deletions.heap_size_of_children() +impl MallocSizeOf for JournalEntry { + fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { + self.insertions.size_of(ops) + self.deletions.size_of(ops) } } @@ -252,8 +252,8 @@ impl JournalDB for OverlayRecentDB { let overlay = self.journal_overlay.read(); mem += overlay.backing_overlay.mem_used(); - mem += overlay.pending_overlay.heap_size_of_children(); - mem += overlay.journal.heap_size_of_children(); + mem += overlay.pending_overlay.m_size_of(); + mem += overlay.journal.m_size_of(); mem } diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 99b3d8d738e..286c3c84b97 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::MemoryDB; @@ -102,7 +102,7 @@ impl JournalDB for RefCountedDB { } fn mem_used(&self) -> usize { - self.inserts.heap_size_of_children() + self.removes.heap_size_of_children() + self.inserts.m_size_of() + self.removes.m_size_of() } fn is_empty(&self) -> bool { diff --git a/util/mem/Cargo.toml b/util/mem/Cargo.toml deleted file mode 100644 index 29d1db923ee..00000000000 --- a/util/mem/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -name = "mem" -version = "0.1.0" -authors = ["Parity Technologies "] diff --git a/util/mem/src/lib.rs b/util/mem/src/lib.rs deleted file mode 100644 index 735a58cd232..00000000000 --- a/util/mem/src/lib.rs +++ /dev/null @@ -1,54 +0,0 @@ -// 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 . - -use std::ops::{Deref, DerefMut}; -use std::ptr; - -/// Wrapper to zero out memory when dropped. -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -pub struct Memzero> { - mem: T, -} - -impl> From for Memzero { - fn from(mem: T) -> Memzero { - Memzero { mem } - } -} - -impl> Drop for Memzero { - fn drop(&mut self) { - unsafe { - for byte_ref in self.mem.as_mut() { - ptr::write_volatile(byte_ref, 0) - } - } - } -} - -impl> Deref for Memzero { - type Target = T; - - fn deref(&self) -> &Self::Target { - &self.mem - } -} - -impl> DerefMut for Memzero { - fn deref_mut(&mut self) -> &mut Self::Target { - &mut self.mem - } -} diff --git a/util/memory_cache/Cargo.toml b/util/memory_cache/Cargo.toml index f2b612463ac..8b7521b45bf 100644 --- a/util/memory_cache/Cargo.toml +++ b/util/memory_cache/Cargo.toml @@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used" license = "GPL3" [dependencies] -heapsize = "0.4" +parity-util-mem = { path = "../../../../parity-common/mem" } lru-cache = "0.1" diff --git a/util/memory_cache/src/lib.rs b/util/memory_cache/src/lib.rs index ab3feafbf5f..fede9501854 100644 --- a/util/memory_cache/src/lib.rs +++ b/util/memory_cache/src/lib.rs @@ -18,10 +18,10 @@ //! crate. // TODO: push changes upstream in a clean way. -extern crate heapsize; +extern crate parity_util_mem as mem; extern crate lru_cache; -use heapsize::HeapSizeOf; +use mem::{MallocSizeOf, MallocSizeOfExt}; use lru_cache::LruCache; use std::hash::Hash; @@ -29,18 +29,18 @@ use std::hash::Hash; const INITIAL_CAPACITY: usize = 4; /// An LRU-cache which operates on memory used. -pub struct MemoryLruCache { +pub struct MemoryLruCache { inner: LruCache, cur_size: usize, max_size: usize, } // amount of memory used when the item will be put on the heap. -fn heap_size_of(val: &T) -> usize { - ::std::mem::size_of::() + val.heap_size_of_children() +fn heap_size_of(val: &T) -> usize { + ::std::mem::size_of::() + val.m_size_of() } -impl MemoryLruCache { +impl MemoryLruCache { /// Create a new cache with a maximum size in bytes. pub fn new(max_size: usize) -> Self { MemoryLruCache { diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index ac87540ac87..088f29899fa 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -13,7 +13,7 @@ parity-crypto = "0.2" ethkey = { path = "../ethkey" } hex = "0.2" log = "0.4" -mem = { path = "../util/mem" } +parity-util-mem = { path = "../../../parity-common/mem" } ordered-float = "0.5" parking_lot = "0.6" rand = "0.4" diff --git a/whisper/src/lib.rs b/whisper/src/lib.rs index 66d8d1b7321..adb7c51e112 100644 --- a/whisper/src/lib.rs +++ b/whisper/src/lib.rs @@ -23,7 +23,7 @@ extern crate ethcore_network as network; extern crate ethereum_types; extern crate ethkey; extern crate hex; -extern crate mem; +extern crate parity_util_mem as mem; extern crate ordered_float; extern crate parking_lot; extern crate rand; From 1776a322a5d9513cf87cffeb1e975ba43091490b Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 7 Dec 2018 16:23:52 +0100 Subject: [PATCH 02/22] Use derive macro for clarity (even when derive impl return 0). --- Cargo.lock | 1 + ethcore/light/src/cache.rs | 2 + ethcore/light/src/client/header_chain.rs | 13 +++--- ethcore/light/src/lib.rs | 1 + ethcore/src/blockchain/blockchain.rs | 24 ++++++----- ethcore/src/blockchain/extras.rs | 24 ++--------- ethcore/src/encoded.rs | 26 ++---------- .../src/engines/validator_set/simple_list.rs | 10 +---- ethcore/src/engines/validator_set/test.rs | 9 ++--- ethcore/src/header.rs | 10 +---- ethcore/src/lib.rs | 1 + ethcore/src/trace/types/flat.rs | 28 +++---------- ethcore/src/verification/queue/kind.rs | 13 +----- ethcore/src/verification/queue/mod.rs | 9 +---- ethcore/src/verification/verification.rs | 11 +---- ethcore/sync/src/api.rs | 2 +- ethcore/sync/src/block_sync.rs | 11 ++--- ethcore/sync/src/blocks.rs | 40 +++---------------- ethcore/sync/src/chain/mod.rs | 14 +++---- ethcore/sync/src/lib.rs | 1 + ethcore/sync/src/snapshot.rs | 1 + ethcore/sync/src/transactions_stats.rs | 4 +- ethcore/transaction/src/lib.rs | 1 + ethcore/transaction/src/transaction.rs | 28 +++---------- ethcore/types/src/lib.rs | 1 + ethcore/types/src/log_entry.rs | 10 +---- ethcore/types/src/receipt.rs | 12 ++---- util/journaldb/src/earlymergedb.rs | 8 +--- util/journaldb/src/lib.rs | 1 + util/journaldb/src/overlayrecentdb.rs | 16 +++----- util/journaldb/src/refcounteddb.rs | 5 ++- 31 files changed, 95 insertions(+), 242 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28fc4fe7253..3904ec2ac1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2623,6 +2623,7 @@ dependencies = [ "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.0.1", + "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/ethcore/light/src/cache.rs b/ethcore/light/src/cache.rs index fb8c99a45ee..5509835e0ca 100644 --- a/ethcore/light/src/cache.rs +++ b/ethcore/light/src/cache.rs @@ -161,6 +161,8 @@ impl Cache { } } + +// TODO this is fast method: should feature gate an exhaustive implementation impl MallocSizeOf for Cache { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { self.headers.current_size() diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index ce03195a63e..773bfd822d3 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -196,14 +196,21 @@ pub enum HardcodedSync { Deny, } +#[derive(MallocSizeOf)] /// Header chain. See module docs for more details. pub struct HeaderChain { + #[ignore_malloc_size_of = "perf"] genesis_header: encoded::Header, // special-case the genesis. candidates: RwLock>, + #[ignore_malloc_size_of = "perf"] best_block: RwLock, + #[ignore_malloc_size_of = "perf"] live_epoch_proofs: RwLock>, + #[ignore_malloc_size_of = "perf"] db: Arc, + #[ignore_malloc_size_of = "perf"] col: Option, + #[ignore_malloc_size_of = "perf"] cache: Arc>, } @@ -832,12 +839,6 @@ impl HeaderChain { } } -impl MallocSizeOf for HeaderChain { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.candidates.read().size_of(ops) - } -} - /// Iterator over a block's ancestry. pub struct AncestryIter<'a> { next: Option, diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index e2b5e02b13b..6252643ae2e 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -61,6 +61,7 @@ extern crate ethcore_transaction as transaction; extern crate ethereum_types; extern crate ethcore; extern crate hashdb; +extern crate parity_util_mem as malloc_size_of; extern crate parity_util_mem as mem; extern crate failsafe; extern crate futures; diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index bed57267376..6c0b9708a08 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -37,7 +37,7 @@ use engines::ForkChoice; use ethereum_types::{H256, Bloom, BloomRef, U256}; use error::Error as EthcoreError; use header::*; -use mem::MallocSizeOfExt; +use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; use itertools::Itertools; use kvdb::{DBTransaction, KeyValueDB}; use log_entry::{LogEntry, LocalizedLogEntry}; @@ -1464,11 +1464,12 @@ impl BlockChain { /// Get current cache size. pub fn cache_size(&self) -> CacheSize { + let mut ops = new_malloc_size_ops(); CacheSize { - blocks: self.block_headers.read().m_size_of() + self.block_bodies.read().m_size_of(), - block_details: self.block_details.read().m_size_of(), - transaction_addresses: self.transaction_addresses.read().m_size_of(), - block_receipts: self.block_receipts.read().m_size_of(), + blocks: self.block_headers.size_of(&mut ops) + self.block_bodies.size_of(&mut ops), + block_details: self.block_details.size_of(&mut ops), + transaction_addresses: self.transaction_addresses.size_of(&mut ops), + block_receipts: self.block_receipts.size_of(&mut ops), } } @@ -1503,12 +1504,13 @@ impl BlockChain { transaction_addresses.shrink_to_fit(); block_receipts.shrink_to_fit(); - block_headers.m_size_of() + - block_bodies.m_size_of() + - block_details.m_size_of() + - block_hashes.m_size_of() + - transaction_addresses.m_size_of() + - block_receipts.m_size_of() + let mut ops = new_malloc_size_ops(); + block_headers.size_of(&mut ops) + + block_bodies.size_of(&mut ops) + + block_details.size_of(&mut ops) + + block_hashes.size_of(&mut ops) + + transaction_addresses.size_of(&mut ops) + + block_receipts.size_of(&mut ops) }); } diff --git a/ethcore/src/blockchain/extras.rs b/ethcore/src/blockchain/extras.rs index 9f1b4ae309c..c8c4aeef978 100644 --- a/ethcore/src/blockchain/extras.rs +++ b/ethcore/src/blockchain/extras.rs @@ -23,7 +23,7 @@ use db::Key; use engines::epoch::{Transition as EpochTransition}; use ethereum_types::{H256, H264, U256}; use header::BlockNumber; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use kvdb::PREFIX_LEN as DB_PREFIX_LEN; use receipt::Receipt; use rlp; @@ -140,7 +140,7 @@ impl Key for u64 { } /// Familial details concerning a block -#[derive(Debug, Clone)] +#[derive(Debug, Clone, MallocSizeOf)] pub struct BlockDetails { /// Block number pub number: BlockNumber, @@ -195,14 +195,8 @@ impl rlp::Decodable for BlockDetails { } } -impl MallocSizeOf for BlockDetails { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.children.size_of(ops) - } -} - /// Represents address of certain transaction within block -#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable)] +#[derive(Debug, PartialEq, Clone, RlpEncodable, RlpDecodable, MallocSizeOf)] pub struct TransactionAddress { /// Block hash pub block_hash: H256, @@ -210,12 +204,8 @@ pub struct TransactionAddress { pub index: usize } -impl MallocSizeOf for TransactionAddress { - fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } -} - /// Contains all block receipts. -#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper)] +#[derive(Clone, RlpEncodableWrapper, RlpDecodableWrapper, MallocSizeOf)] pub struct BlockReceipts { pub receipts: Vec, } @@ -228,12 +218,6 @@ impl BlockReceipts { } } -impl MallocSizeOf for BlockReceipts { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.receipts.size_of(ops) - } -} - /// Candidate transitions to an epoch with specific number. #[derive(Clone, RlpEncodable, RlpDecodable)] pub struct EpochTransitions { diff --git a/ethcore/src/encoded.rs b/ethcore/src/encoded.rs index b08e0710649..388ed0bde49 100644 --- a/ethcore/src/encoded.rs +++ b/ethcore/src/encoded.rs @@ -27,21 +27,15 @@ use block::Block as FullBlock; use ethereum_types::{H256, Bloom, U256, Address}; use hash::keccak; use header::{BlockNumber, Header as FullHeader}; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use rlp::{self, Rlp, RlpStream}; use transaction::UnverifiedTransaction; use views::{self, BlockView, HeaderView, BodyView}; /// Owning header view. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub struct Header(Vec); -impl MallocSizeOf for Header { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.0.size_of(ops) - } -} - impl Header { /// Create a new owning header view. /// Expects the data to be an RLP-encoded header -- any other case will likely lead to @@ -114,15 +108,9 @@ impl Header { } /// Owning block body view. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub struct Body(Vec); -impl MallocSizeOf for Body { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.0.size_of(ops) - } -} - impl Body { /// Create a new owning block body view. The raw bytes passed in must be an rlp-encoded block /// body. @@ -181,15 +169,9 @@ impl Body { } /// Owning block view. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub struct Block(Vec); -impl MallocSizeOf for Block { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.0.size_of(ops) - } -} - impl Block { /// Create a new owning block view. The raw bytes passed in must be an rlp-encoded block. pub fn new(raw: Vec) -> Self { Block(raw) } diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/src/engines/validator_set/simple_list.rs index b0a6d96a868..5ab74159e6d 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/src/engines/validator_set/simple_list.rs @@ -16,7 +16,7 @@ /// Preconfigured validator list. -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use ethereum_types::{H256, Address}; use machine::{AuxiliaryData, Call, EthereumMachine}; @@ -24,7 +24,7 @@ use header::{BlockNumber, Header}; use super::ValidatorSet; /// Validator set containing a known set of addresses. -#[derive(Clone, Debug, PartialEq, Eq, Default)] +#[derive(Clone, Debug, PartialEq, Eq, Default, MallocSizeOf)] pub struct SimpleList { validators: Vec
, } @@ -57,12 +57,6 @@ impl From> for SimpleList { } } -impl MallocSizeOf for SimpleList { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.validators.size_of(ops) - } -} - impl ValidatorSet for SimpleList { fn default_caller(&self, _block_id: ::ids::BlockId) -> Box { Box::new(|_, _| Err("Simple list doesn't require calls.".into())) diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index e85a524d078..bc026a6623d 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -28,9 +28,12 @@ use header::{Header, BlockNumber}; use super::{ValidatorSet, SimpleList}; /// Set used for testing with a single validator. +#[derive(MallocSizeOf)] pub struct TestSet { validator: SimpleList, + #[ignore_malloc_size_of = "zero sized"] last_malicious: Arc, + #[ignore_malloc_size_of = "zero sized"] last_benign: Arc, } @@ -44,12 +47,6 @@ impl TestSet { } } -impl MallocSizeOf for TestSet { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.validator.size_of(ops) - } -} - impl ValidatorSet for TestSet { fn default_caller(&self, _block_id: ::ids::BlockId) -> Box { Box::new(|_, _| Err("Test set doesn't require calls.".into())) diff --git a/ethcore/src/header.rs b/ethcore/src/header.rs index d1f89329112..3b61b5ade17 100644 --- a/ethcore/src/header.rs +++ b/ethcore/src/header.rs @@ -18,7 +18,7 @@ use std::cmp; use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak}; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use ethereum_types::{H256, U256, Address, Bloom}; use bytes::Bytes; use rlp::{Rlp, RlpStream, Encodable, DecoderError, Decodable}; @@ -51,7 +51,7 @@ pub struct ExtendedHeader { /// which is non-specific. /// /// Doesn't do all that much on its own. -#[derive(Debug, Clone, Eq)] +#[derive(Debug, Clone, Eq, MallocSizeOf)] pub struct Header { /// Parent hash. parent_hash: H256, @@ -370,12 +370,6 @@ impl Encodable for Header { } } -impl MallocSizeOf for Header { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.extra_data.size_of(ops) + self.seal.size_of(ops) - } -} - impl ::parity_machine::Header for Header { fn bare_hash(&self) -> H256 { Header::bare_hash(self) } fn hash(&self) -> H256 { Header::hash(self) } diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index b2c41a3db46..452fb92d104 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -93,6 +93,7 @@ extern crate rlp_compress; extern crate keccak_hash as hash; extern crate keccak_hasher; extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; extern crate memorydb; extern crate patricia_trie as trie; extern crate patricia_trie_ethereum as ethtrie; diff --git a/ethcore/src/trace/types/flat.rs b/ethcore/src/trace/types/flat.rs index 876b090c26b..07f55f79d9c 100644 --- a/ethcore/src/trace/types/flat.rs +++ b/ethcore/src/trace/types/flat.rs @@ -17,17 +17,19 @@ //! Flat trace module use rlp::{Rlp, RlpStream, Decodable, Encodable, DecoderError}; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use ethereum_types::Bloom; use super::trace::{Action, Res}; /// Trace localized in vector of traces produced by a single transaction. /// /// Parent and children indexes refer to positions in this vector. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, MallocSizeOf)] pub struct FlatTrace { + #[ignore_malloc_size_of = "perf"] /// Type of action performed by a transaction. pub action: Action, + #[ignore_malloc_size_of = "perf"] /// Result of this action. pub result: Res, /// Number of subtraces. @@ -45,12 +47,6 @@ impl FlatTrace { } } -impl MallocSizeOf for FlatTrace { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.trace_address.size_of(ops) - } -} - impl Encodable for FlatTrace { fn rlp_append(&self, s: &mut RlpStream) { s.begin_list(4); @@ -76,7 +72,7 @@ impl Decodable for FlatTrace { } /// Represents all traces produced by a single transaction. -#[derive(Debug, PartialEq, Clone, RlpEncodableWrapper, RlpDecodableWrapper)] +#[derive(Debug, PartialEq, Clone, RlpEncodableWrapper, RlpDecodableWrapper, MallocSizeOf)] pub struct FlatTransactionTraces(Vec); impl From> for FlatTransactionTraces { @@ -85,12 +81,6 @@ impl From> for FlatTransactionTraces { } } -impl MallocSizeOf for FlatTransactionTraces { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.0.size_of(ops) - } -} - impl FlatTransactionTraces { /// Returns bloom of all traces in the collection. pub fn bloom(&self) -> Bloom { @@ -105,15 +95,9 @@ impl Into> for FlatTransactionTraces { } /// Represents all traces produced by transactions in a single block. -#[derive(Debug, PartialEq, Clone, Default, RlpEncodableWrapper, RlpDecodableWrapper)] +#[derive(Debug, PartialEq, Clone, Default, RlpEncodableWrapper, RlpDecodableWrapper, MallocSizeOf)] pub struct FlatBlockTraces(Vec); -impl MallocSizeOf for FlatBlockTraces { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.0.size_of(ops) - } -} - impl From> for FlatBlockTraces { fn from(v: Vec) -> Self { FlatBlockTraces(v) diff --git a/ethcore/src/verification/queue/kind.rs b/ethcore/src/verification/queue/kind.rs index 63247edaefe..5e798cf8660 100644 --- a/ethcore/src/verification/queue/kind.rs +++ b/ethcore/src/verification/queue/kind.rs @@ -74,7 +74,7 @@ pub mod blocks { use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered}; use transaction::UnverifiedTransaction; - use mem::{MallocSizeOf, MallocSizeOfOps}; + use mem::MallocSizeOf; use ethereum_types::{H256, U256}; use bytes::Bytes; @@ -113,7 +113,7 @@ pub mod blocks { } /// An unverified block. - #[derive(PartialEq, Debug)] + #[derive(PartialEq, Debug, MallocSizeOf)] pub struct Unverified { /// Unverified block header. pub header: Header, @@ -146,15 +146,6 @@ pub mod blocks { } } - impl MallocSizeOf for Unverified { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.header.size_of(ops) - + self.transactions.size_of(ops) - + self.uncles.size_of(ops) - + self.bytes.size_of(ops) - } - } - impl BlockLike for Unverified { fn hash(&self) -> H256 { self.header.hash() diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 6b151b3b890..32fce0c7e7f 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -22,7 +22,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering}; use std::sync::Arc; use std::cmp; use std::collections::{VecDeque, HashSet, HashMap}; -use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; +use mem::{MallocSizeOf, MallocSizeOfExt}; use ethereum_types::{H256, U256}; use parking_lot::{Condvar, Mutex, RwLock}; use io::*; @@ -96,17 +96,12 @@ enum State { } /// An item which is in the process of being verified. +#[derive(MallocSizeOf)] pub struct Verifying { hash: H256, output: Option, } -impl MallocSizeOf for Verifying { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.output.size_of(ops) - } -} - /// Status of items in the queue. pub enum Status { /// Currently queued. diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 161d09ecb34..2d60623894f 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -26,7 +26,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use bytes::Bytes; use hash::keccak; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use rlp::Rlp; use triehash::ordered_trie_root; use unexpected::{Mismatch, OutOfBounds}; @@ -40,6 +40,7 @@ use transaction::SignedTransaction; use verification::queue::kind::blocks::Unverified; /// Preprocessed block data gathered in `verify_block_unordered` call +#[derive(MallocSizeOf)] pub struct PreverifiedBlock { /// Populated block header pub header: Header, @@ -51,14 +52,6 @@ pub struct PreverifiedBlock { pub bytes: Bytes, } -impl MallocSizeOf for PreverifiedBlock { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.header.size_of(ops) - + self.transactions.size_of(ops) - + self.bytes.size_of(ops) - } -} - /// Phase 1 quick block verification. Only does checks that are cheap. Operates on a single block pub fn verify_block_basic(block: &Unverified, engine: &EthEngine, check_seal: bool) -> Result<(), Error> { verify_header_params(&block.header, engine, true, check_seal)?; diff --git a/ethcore/sync/src/api.rs b/ethcore/sync/src/api.rs index 7474d79b37f..aa0867b9f65 100644 --- a/ethcore/sync/src/api.rs +++ b/ethcore/sync/src/api.rs @@ -58,7 +58,7 @@ pub const ETH_PROTOCOL: ProtocolId = *b"eth"; pub const LIGHT_PROTOCOL: ProtocolId = *b"pip"; /// Determine warp sync status. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, MallocSizeOf)] pub enum WarpSync { /// Warp sync is enabled. Enabled, diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index 9907b9f5aa8..6cd3b7da87f 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -20,7 +20,7 @@ use std::collections::{HashSet, VecDeque}; use std::cmp; -use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; +use mem::MallocSizeOf; use ethereum_types::H256; use rlp::{self, Rlp}; use ethcore::header::BlockNumber; @@ -57,7 +57,7 @@ macro_rules! debug_sync { }; } -#[derive(Copy, Clone, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, MallocSizeOf)] /// Downloader state pub enum State { /// No active downloads. @@ -110,6 +110,7 @@ impl From for BlockDownloaderImportError { /// Block downloader strategy. /// Manages state and block data for a block download process. +#[derive(MallocSizeOf)] pub struct BlockDownloader { /// Which set of blocks to download block_set: BlockSet, @@ -220,12 +221,6 @@ impl BlockDownloader { self.state = State::Blocks; } - // TODO switch to MallocSizeOf !! - /// Returns used heap memory size. - pub fn heap_size(&self) -> usize { - self.blocks.heap_size() + self.round_parents.m_size_of() - } - /// Returns best imported block number. pub fn last_imported_block_number(&self) -> BlockNumber { self.last_imported_block diff --git a/ethcore/sync/src/blocks.rs b/ethcore/sync/src/blocks.rs index 87ac40da54b..c3b35f4ee5c 100644 --- a/ethcore/sync/src/blocks.rs +++ b/ethcore/sync/src/blocks.rs @@ -16,7 +16,7 @@ use std::collections::{HashSet, HashMap, hash_map}; use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP}; -use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; +use mem::MallocSizeOf; use ethereum_types::H256; use triehash_ethereum::ordered_trie_root; use bytes::Bytes; @@ -29,18 +29,12 @@ use transaction::UnverifiedTransaction; malloc_size_of_is_0!(HeaderId); #[derive(PartialEq, Debug, Clone)] +#[derive(MallocSizeOf)] pub struct SyncHeader { pub bytes: Bytes, pub header: BlockHeader, } -impl MallocSizeOf for SyncHeader { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.bytes.size_of(ops) - + self.header.size_of(ops) - } -} - impl SyncHeader { pub fn from_rlp(bytes: Bytes) -> Result { let result = SyncHeader { @@ -52,6 +46,7 @@ impl SyncHeader { } } +#[derive(MallocSizeOf)] pub struct SyncBody { pub transactions_bytes: Bytes, pub transactions: Vec, @@ -85,16 +80,8 @@ impl SyncBody { } } -impl MallocSizeOf for SyncBody { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.transactions_bytes.size_of(ops) - + self.transactions.size_of(ops) - + self.uncles_bytes.size_of(ops) - + self.uncles.size_of(ops) - } -} - /// Block data with optional body. +#[derive(MallocSizeOf)] struct SyncBlock { header: SyncHeader, body: Option, @@ -102,12 +89,6 @@ struct SyncBlock { receipts_root: H256, } -impl MallocSizeOf for SyncBlock { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.header.size_of(ops) + self.body.size_of(ops) - } -} - fn unverified_from_sync(header: SyncHeader, body: Option) -> Unverified { let mut stream = RlpStream::new_list(3); stream.append_raw(&header.bytes, 1); @@ -141,7 +122,7 @@ struct HeaderId { /// A collection of blocks and subchain pointers being downloaded. This keeps track of /// which headers/bodies need to be downloaded, which are being downloaded and also holds /// the downloaded blocks. -#[derive(Default)] +#[derive(Default, MallocSizeOf)] pub struct BlockCollection { /// Does this collection need block receipts. need_receipts: bool, @@ -399,17 +380,6 @@ impl BlockCollection { self.heads.len() } - // TODO switch to MallocSizeOf !! - /// Return used heap size. - pub fn heap_size(&self) -> usize { - self.heads.m_size_of() - + self.blocks.m_size_of() - + self.parents.m_size_of() - + self.header_ids.m_size_of() - + self.downloading_headers.m_size_of() - + self.downloading_bodies.m_size_of() - } - /// Check if given block hash is marked as being downloaded. pub fn is_downloading(&self, hash: &H256) -> bool { self.downloading_headers.contains(hash) || self.downloading_bodies.contains(hash) diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index e7a978a3c34..1a90671784f 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -97,7 +97,7 @@ use std::collections::{HashSet, HashMap, BTreeMap}; use std::cmp; use std::time::{Duration, Instant}; use hash::keccak; -use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; +use mem::MallocSizeOfExt; use ethereum_types::{H256, U256}; use fastmap::{H256FastMap, H256FastSet}; use parking_lot::{Mutex, RwLock, RwLockWriteGuard}; @@ -192,7 +192,7 @@ const SNAPSHOT_DATA_TIMEOUT: Duration = Duration::from_secs(120); /// (so we might sent only to some part of the peers we originally intended to send to) const PRIORITY_TASK_DEADLINE: Duration = Duration::from_millis(100); -#[derive(Copy, Clone, Eq, PartialEq, Debug)] +#[derive(Copy, Clone, Eq, PartialEq, Debug, MallocSizeOf)] /// Sync state pub enum SyncState { /// Collecting enough peers to start syncing. @@ -286,7 +286,7 @@ pub enum PeerAsking { SnapshotData, } -#[derive(PartialEq, Eq, Debug, Clone, Copy)] +#[derive(PartialEq, Eq, Debug, Clone, Copy, MallocSizeOf)] /// Block downloader channel. pub enum BlockSet { /// New blocks better than out best blocks @@ -593,6 +593,7 @@ enum PeerState { /// Blockchain sync handler. /// See module documentation for more details. +#[derive(MallocSizeOf)] pub struct ChainSync { /// Sync state state: SyncState, @@ -626,6 +627,7 @@ pub struct ChainSync { /// Enable ancient block downloading download_old_blocks: bool, /// Shared private tx service. + #[ignore_malloc_size_of = "arc on dyn trait here seems tricky, ignoring"] private_tx_handler: Arc, /// Enable warp sync. warp_sync: WarpSync, @@ -682,11 +684,7 @@ impl ChainSync { num_active_peers: self.peers.values().filter(|p| p.is_allowed() && p.asking != PeerAsking::Nothing).count(), num_snapshot_chunks: self.snapshot.total_chunks(), snapshot_chunks_done: self.snapshot.done_chunks(), - // TODO implement and use MallocSizeOf - mem_used: - self.new_blocks.heap_size() - + self.old_blocks.as_ref().map_or(0, |d| d.heap_size()) - + self.peers.m_size_of(), + mem_used: self.m_size_of(), } } diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index 9f2de985c8b..e8e998dcafa 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -49,6 +49,7 @@ extern crate macros; #[macro_use] extern crate log; #[macro_use] +extern crate parity_util_mem as malloc_size_of; extern crate parity_util_mem as mem; #[macro_use] extern crate trace_time; diff --git a/ethcore/sync/src/snapshot.rs b/ethcore/sync/src/snapshot.rs index c7f0d284f39..7e13a74d8fc 100644 --- a/ethcore/sync/src/snapshot.rs +++ b/ethcore/sync/src/snapshot.rs @@ -27,6 +27,7 @@ pub enum ChunkType { Block(H256), } +#[derive(MallocSizeOf)] pub struct Snapshot { pending_state_chunks: Vec, pending_block_chunks: Vec, diff --git a/ethcore/sync/src/transactions_stats.rs b/ethcore/sync/src/transactions_stats.rs index 7d5e2ca4a86..d0c64be48cb 100644 --- a/ethcore/sync/src/transactions_stats.rs +++ b/ethcore/sync/src/transactions_stats.rs @@ -23,7 +23,7 @@ use fastmap::H256FastMap; type NodeId = H512; type BlockNumber = u64; -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Clone, MallocSizeOf)] pub struct Stats { first_seen: BlockNumber, propagated_to: HashMap, @@ -50,7 +50,7 @@ impl<'a> From<&'a Stats> for TransactionStats { } } -#[derive(Debug, Default)] +#[derive(Debug, Default, MallocSizeOf)] pub struct TransactionsStats { pending_transactions: H256FastMap, } diff --git a/ethcore/transaction/src/lib.rs b/ethcore/transaction/src/lib.rs index adcf30bf625..b980c0624a6 100644 --- a/ethcore/transaction/src/lib.rs +++ b/ethcore/transaction/src/lib.rs @@ -21,6 +21,7 @@ extern crate ethjson; extern crate ethkey; extern crate evm; extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; extern crate keccak_hash as hash; extern crate rlp; extern crate unexpected; diff --git a/ethcore/transaction/src/transaction.rs b/ethcore/transaction/src/transaction.rs index 9fbfa32b8de..54540a59b79 100644 --- a/ethcore/transaction/src/transaction.rs +++ b/ethcore/transaction/src/transaction.rs @@ -23,7 +23,7 @@ use ethjson; use ethkey::{self, Signature, Secret, Public, recover, public_to_address}; use evm::Schedule; use hash::keccak; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::MallocSizeOf; use rlp::{self, RlpStream, Rlp, DecoderError, Encodable}; @@ -37,7 +37,7 @@ pub const UNSIGNED_SENDER: Address = H160([0xff; 20]); pub const SYSTEM_ADDRESS: Address = H160([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xff,0xff, 0xff, 0xff, 0xfe]); /// Transaction action type. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub enum Action { /// Create creates new contract. Create, @@ -99,7 +99,7 @@ pub mod signature { /// A set of information describing an externally-originating message call /// or contract creation operation. -#[derive(Default, Debug, Clone, PartialEq, Eq)] +#[derive(Default, Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub struct Transaction { /// Nonce. pub nonce: U256, @@ -133,12 +133,6 @@ impl Transaction { } } -impl MallocSizeOf for Transaction { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.data.size_of(ops) - } -} - impl From for SignedTransaction { fn from(t: ethjson::state::Transaction) -> Self { let to: Option = t.to.into(); @@ -268,7 +262,7 @@ impl Transaction { } /// Signed transaction information without verified signature. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf)] pub struct UnverifiedTransaction { /// Plain Transaction. unsigned: Transaction, @@ -283,12 +277,6 @@ pub struct UnverifiedTransaction { hash: H256, } -impl MallocSizeOf for UnverifiedTransaction { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.unsigned.size_of(ops) - } -} - impl Deref for UnverifiedTransaction { type Target = Transaction; @@ -417,19 +405,13 @@ impl UnverifiedTransaction { } /// A `UnverifiedTransaction` with successfully recovered `sender`. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq, MallocSizeOf)] pub struct SignedTransaction { transaction: UnverifiedTransaction, sender: Address, public: Option, } -impl MallocSizeOf for SignedTransaction { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.transaction.size_of(ops) - } -} - impl rlp::Encodable for SignedTransaction { fn rlp_append(&self, s: &mut RlpStream) { self.transaction.rlp_append_sealed_transaction(s) } } diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index 6b3ca4aea68..ea732b95487 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -24,6 +24,7 @@ extern crate rlp; extern crate rlp_derive; extern crate keccak_hash as hash; extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; #[cfg(test)] extern crate rustc_hex; diff --git a/ethcore/types/src/log_entry.rs b/ethcore/types/src/log_entry.rs index 7b342ce772f..84c352f11ea 100644 --- a/ethcore/types/src/log_entry.rs +++ b/ethcore/types/src/log_entry.rs @@ -17,7 +17,7 @@ //! Log entry type definition. use std::ops::Deref; -use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; +use mem::MallocSizeOf; use bytes::Bytes; use ethereum_types::{H256, Address, Bloom, BloomInput}; @@ -25,7 +25,7 @@ use {BlockNumber}; use ethjson; /// A record of execution for a `LOG` operation. -#[derive(Default, Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] +#[derive(Default, Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable, MallocSizeOf)] pub struct LogEntry { /// The address of the contract executing at the point of the `LOG` operation. pub address: Address, @@ -35,12 +35,6 @@ pub struct LogEntry { pub data: Bytes, } -impl MallocSizeOf for LogEntry { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.topics.size_of(ops) + self.data.size_of(ops) - } -} - impl LogEntry { /// Calculates the bloom of this log entry. pub fn bloom(&self) -> Bloom { diff --git a/ethcore/types/src/receipt.rs b/ethcore/types/src/receipt.rs index d9c73f2e8f0..6c4f2dc6b54 100644 --- a/ethcore/types/src/receipt.rs +++ b/ethcore/types/src/receipt.rs @@ -17,14 +17,14 @@ //! Receipt use ethereum_types::{H160, H256, U256, Address, Bloom}; -use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; +use mem::MallocSizeOf; use rlp::{Rlp, RlpStream, Encodable, Decodable, DecoderError}; use BlockNumber; use log_entry::{LogEntry, LocalizedLogEntry}; /// Transaction outcome store in the receipt. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub enum TransactionOutcome { /// Status and state root are unknown under EIP-98 rules. Unknown, @@ -35,7 +35,7 @@ pub enum TransactionOutcome { } /// Information describing execution of a transaction. -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] pub struct Receipt { /// The total gas used in the block following execution of the transaction. pub gas_used: U256, @@ -110,12 +110,6 @@ impl Decodable for Receipt { } } -impl MallocSizeOf for Receipt { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.logs.size_of(ops) - } -} - /// Receipt with additional info. #[derive(Debug, Clone, PartialEq)] pub struct RichReceipt { diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index b45b953d61e..c7d1672a903 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; +use mem::{MallocSizeOf, MallocSizeOfExt}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; @@ -34,16 +34,12 @@ use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, error_negatively_reference_hash, erro use super::traits::JournalDB; use util::{DatabaseKey, DatabaseValueView, DatabaseValueRef}; -#[derive(Debug, Clone, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, MallocSizeOf)] struct RefInfo { queue_refs: usize, in_archive: bool, } -impl MallocSizeOf for RefInfo { - fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { 0 } -} - #[derive(Clone, PartialEq, Eq)] enum RemoveFrom { Queue, diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index 635b82b50d0..c2d469d0ae1 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -17,6 +17,7 @@ //! `JournalDB` interface and implementation. extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; #[macro_use] extern crate log; diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index a91977011bb..638654fe885 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, MallocSizeOfExt, MallocSizeOfOps}; +use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; @@ -128,19 +128,13 @@ struct JournalOverlay { cumulative_size: usize, // cumulative size of all entries. } -#[derive(PartialEq)] +#[derive(PartialEq, MallocSizeOf)] struct JournalEntry { id: H256, insertions: Vec, deletions: Vec, } -impl MallocSizeOf for JournalEntry { - fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize { - self.insertions.size_of(ops) + self.deletions.size_of(ops) - } -} - impl Clone for OverlayRecentDB { fn clone(&self) -> OverlayRecentDB { OverlayRecentDB { @@ -248,12 +242,14 @@ impl JournalDB for OverlayRecentDB { } fn mem_used(&self) -> usize { + // TODO could use mem alloc derive instead (require some switch in other crates) let mut mem = self.transaction_overlay.mem_used(); + let mut ops = new_malloc_size_ops(); let overlay = self.journal_overlay.read(); mem += overlay.backing_overlay.mem_used(); - mem += overlay.pending_overlay.m_size_of(); - mem += overlay.journal.m_size_of(); + mem += overlay.pending_overlay.size_of(&mut ops); + mem += overlay.journal.size_of(&mut ops); mem } diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 286c3c84b97..d6b394d900a 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, MallocSizeOfExt}; +use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::MemoryDB; @@ -102,7 +102,8 @@ impl JournalDB for RefCountedDB { } fn mem_used(&self) -> usize { - self.inserts.m_size_of() + self.removes.m_size_of() + let mut ops = new_malloc_size_ops(); + self.inserts.size_of(&mut ops) + self.removes.size_of(&mut ops) } fn is_empty(&self) -> bool { From 3a0d78d462ad14ee2183b3540a6efd2cdb4ae449 Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 7 Dec 2018 17:58:54 +0100 Subject: [PATCH 03/22] Setting jemalloc as default allocator for parity client. --- Cargo.lock | 29 +++++++++++++++++++++++++++++ Cargo.toml | 2 ++ 2 files changed, 31 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 3904ec2ac1c..6e69f721fc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1292,6 +1292,11 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fs_extra" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1638,6 +1643,25 @@ name = "itoa" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "jemalloc-sys" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jemallocator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jni" version = "0.10.2" @@ -2355,6 +2379,7 @@ dependencies = [ "parity-rpc-client 1.4.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", + "parity-util-mem 0.1.0", "parity-version 2.3.0", "parity-whisper 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2622,6 +2647,7 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.0.1", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4312,6 +4338,7 @@ dependencies = [ "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" +"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" @@ -4348,6 +4375,8 @@ dependencies = [ "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itertools-num 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "83ca7b70b838f2e34bc6c2f367a1ed1cfe34fb82464adecadd31cdcc7da882fc" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" +"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae" +"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" "checksum jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" diff --git a/Cargo.toml b/Cargo.toml index e8be6d51d26..99e73123005 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,8 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } +parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global"] } + [build-dependencies] rustc_version = "0.2" From 10e30b73e00816c13d80f7353d269f4a53383754 Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 7 Dec 2018 17:59:44 +0100 Subject: [PATCH 04/22] Revert jmalloc default: need to update memorydb crate to stop using heapsize. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 99e73123005..8d4918fbd00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,7 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } -parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global"] } +# parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global"] } [build-dependencies] rustc_version = "0.2" From a159dcd396f404b4b480d6fdda2889c4d75fca5e Mon Sep 17 00:00:00 2001 From: cheme Date: Mon, 10 Dec 2018 16:18:27 +0100 Subject: [PATCH 05/22] update to new module name (alloc -> allocators), test estimate. --- Cargo.lock | 28 --------------------------- Cargo.toml | 3 ++- ethcore/src/blockchain/blockchain.rs | 2 +- util/journaldb/src/overlayrecentdb.rs | 2 +- util/journaldb/src/refcounteddb.rs | 2 +- 5 files changed, 5 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6e69f721fc7..95da2b450b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1292,11 +1292,6 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "fs_extra" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1643,25 +1638,6 @@ name = "itoa" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "jemalloc-sys" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "jemallocator" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "jni" version = "0.10.2" @@ -2647,7 +2623,6 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.0.1", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4338,7 +4313,6 @@ dependencies = [ "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" -"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" @@ -4375,8 +4349,6 @@ dependencies = [ "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itertools-num 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "83ca7b70b838f2e34bc6c2f367a1ed1cfe34fb82464adecadd31cdcc7da882fc" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" -"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae" -"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" "checksum jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" diff --git a/Cargo.toml b/Cargo.toml index 8d4918fbd00..2f39f347965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,7 +69,8 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } -# parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global"] } +# parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global", "estimate-heapsize"] } +parity-util-mem = { path = "../../parity-common/mem", features = ["estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" diff --git a/ethcore/src/blockchain/blockchain.rs b/ethcore/src/blockchain/blockchain.rs index 6c0b9708a08..ec66aa29c8d 100644 --- a/ethcore/src/blockchain/blockchain.rs +++ b/ethcore/src/blockchain/blockchain.rs @@ -37,7 +37,7 @@ use engines::ForkChoice; use ethereum_types::{H256, Bloom, BloomRef, U256}; use error::Error as EthcoreError; use header::*; -use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; +use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use itertools::Itertools; use kvdb::{DBTransaction, KeyValueDB}; use log_entry::{LogEntry, LocalizedLogEntry}; diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 638654fe885..7a134212cb3 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; +use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index d6b394d900a..7d705563bdf 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, alloc::new_malloc_size_ops}; +use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::MemoryDB; From 24131fd28936bcc7d4cb4b2e589f892680dc26da Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 27 Dec 2018 17:31:24 +0100 Subject: [PATCH 06/22] latest test --- Cargo.lock | 1 - Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95da2b450b9..3904ec2ac1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2355,7 +2355,6 @@ dependencies = [ "parity-rpc-client 1.4.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-util-mem 0.1.0", "parity-version 2.3.0", "parity-whisper 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 2f39f347965..d45cf49c5da 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } # parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global", "estimate-heapsize"] } -parity-util-mem = { path = "../../parity-common/mem", features = ["estimate-heapsize"] } +# parity-util-mem = { path = "../../parity-common/mem", features = ["estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" From 9157b74b2f61d19e27c1a0e9c33cfe35e6c97056 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 2 Jan 2019 19:53:19 +0100 Subject: [PATCH 07/22] update renamings --- ethcore/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/light/src/cache.rs | 2 +- ethcore/light/src/client/mod.rs | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/private-tx/src/private_transactions.rs | 2 +- ethcore/src/trace/db.rs | 4 ++-- ethcore/src/verification/queue/mod.rs | 12 ++++++------ ethcore/sync/Cargo.toml | 2 +- ethcore/sync/src/chain/mod.rs | 2 +- ethcore/transaction/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- ethkey/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- miner/src/pool/mod.rs | 2 +- util/journaldb/Cargo.toml | 2 +- util/journaldb/src/earlymergedb.rs | 2 +- util/memory_cache/Cargo.toml | 2 +- util/memory_cache/src/lib.rs | 2 +- whisper/Cargo.toml | 2 +- 21 files changed, 27 insertions(+), 27 deletions(-) diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 5d918098db6..05b26408f4d 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -36,7 +36,7 @@ ethjson = { path = "../json" } ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } evm = { path = "evm" } -parity-util-mem = { path = "../../../parity-common/mem" } +parity-util-mem = { path = "../../../parity-common/parity-util-mem" } itertools = "0.5" lazy_static = "1.0" log = "0.4" diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 7267c1a7159..24cbd8f971d 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] bit-set = "0.4" parity-bytes = "0.1" ethereum-types = "0.4" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } lazy_static = "1.0" log = "0.4" vm = { path = "../vm" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index e3afb7f6a69..2146b552904 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -18,7 +18,7 @@ patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } hashdb = "0.3.0" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] } diff --git a/ethcore/light/src/cache.rs b/ethcore/light/src/cache.rs index 5509835e0ca..2f408f594f0 100644 --- a/ethcore/light/src/cache.rs +++ b/ethcore/light/src/cache.rs @@ -157,7 +157,7 @@ impl Cache { /// Get the memory used. pub fn mem_used(&self) -> usize { - self.m_size_of() + self.malloc_size_of() } } diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index 0102fc5c23d..38f1f050551 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -356,7 +356,7 @@ impl Client { pub fn chain_mem_used(&self) -> usize { use mem::MallocSizeOfExt; - self.chain.m_size_of() + self.chain.malloc_size_of() } /// Get a handle to the verification engine. diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 9637f06f56c..fb4ec7e4f11 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -22,7 +22,7 @@ ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } keccak-hash = "0.1.2" log = "0.4" parking_lot = "0.6" diff --git a/ethcore/private-tx/src/private_transactions.rs b/ethcore/private-tx/src/private_transactions.rs index c781efe62fd..ca07c2c9fa4 100644 --- a/ethcore/private-tx/src/private_transactions.rs +++ b/ethcore/private-tx/src/private_transactions.rs @@ -59,7 +59,7 @@ impl txpool::VerifiedTransaction for VerifiedPrivateTransaction { } fn mem_usage(&self) -> usize { - self.transaction.m_size_of() + self.transaction.malloc_size_of() } fn sender(&self) -> &Address { diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 4f1d871a26c..efac1d571c4 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -86,7 +86,7 @@ impl TraceDB where T: DatabaseExtras { } fn cache_size(&self) -> usize { - self.traces.read().m_size_of() + self.traces.read().malloc_size_of() } /// Let the cache system know that a cacheable item has been used. @@ -108,7 +108,7 @@ impl TraceDB where T: DatabaseExtras { } traces.shrink_to_fit(); - traces.m_size_of() + traces.malloc_size_of() }); } diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 32fce0c7e7f..4330b884364 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -348,7 +348,7 @@ impl VerificationQueue { None => continue, }; - verification.sizes.unverified.fetch_sub(item.m_size_of(), AtomicOrdering::SeqCst); + verification.sizes.unverified.fetch_sub(item.malloc_size_of(), AtomicOrdering::SeqCst); verifying.push_back(Verifying { hash: item.hash(), output: None }); item }; @@ -362,7 +362,7 @@ impl VerificationQueue { if e.hash == hash { idx = Some(i); - verification.sizes.verifying.fetch_add(verified.m_size_of(), AtomicOrdering::SeqCst); + verification.sizes.verifying.fetch_add(verified.malloc_size_of(), AtomicOrdering::SeqCst); e.output = Some(verified); break; } @@ -412,7 +412,7 @@ impl VerificationQueue { while let Some(output) = verifying.front_mut().and_then(|x| x.output.take()) { assert!(verifying.pop_front().is_some()); - let size = output.m_size_of(); + let size = output.malloc_size_of(); removed_size += size; if bad.contains(&output.parent_hash()) { @@ -485,7 +485,7 @@ impl VerificationQueue { match K::create(input, &*self.engine, self.verification.check_seal) { Ok(item) => { - self.verification.sizes.unverified.fetch_add(item.m_size_of(), AtomicOrdering::SeqCst); + self.verification.sizes.unverified.fetch_add(item.malloc_size_of(), AtomicOrdering::SeqCst); self.processing.write().insert(hash, item.difficulty()); { @@ -532,7 +532,7 @@ impl VerificationQueue { let mut removed_size = 0; for output in verified.drain(..) { if bad.contains(&output.parent_hash()) { - removed_size += output.m_size_of(); + removed_size += output.malloc_size_of(); bad.insert(output.hash()); if let Some(difficulty) = processing.remove(&output.hash()) { let mut td = self.total_difficulty.write(); @@ -569,7 +569,7 @@ impl VerificationQueue { let count = cmp::min(max, verified.len()); let result = verified.drain(..count).collect::>(); - let drained_size = result.iter().map(MallocSizeOfExt::m_size_of).fold(0, |a, c| a + c); + let drained_size = result.iter().map(MallocSizeOfExt::malloc_size_of).fold(0, |a, c| a + c); self.verification.sizes.verified.fetch_sub(drained_size, AtomicOrdering::SeqCst); self.ready_signal.reset(); diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 5fec115d1d6..2bc7d44d14d 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -28,7 +28,7 @@ macros = { path = "../../util/macros" } log = "0.4" env_logger = "0.5" rand = "0.4" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } parking_lot = "0.6" trace-time = "0.1" diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 1a90671784f..4fa06a3a988 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -684,7 +684,7 @@ impl ChainSync { num_active_peers: self.peers.values().filter(|p| p.is_allowed() && p.asking != PeerAsking::Nothing).count(), num_snapshot_chunks: self.snapshot.total_chunks(), snapshot_chunks_done: self.snapshot.done_chunks(), - mem_used: self.m_size_of(), + mem_used: self.malloc_size_of(), } } diff --git a/ethcore/transaction/Cargo.toml b/ethcore/transaction/Cargo.toml index e6fc06b9569..350f6885857 100644 --- a/ethcore/transaction/Cargo.toml +++ b/ethcore/transaction/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } evm = { path = "../evm" } -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } keccak-hash = "0.1" rlp = { version = "0.3.0", features = ["ethereum"] } unexpected = { path = "../../util/unexpected" } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 3a5ddae6172..f2186ed9131 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -11,7 +11,7 @@ parity-bytes = "0.1" ethereum-types = "0.4" ethjson = { path = "../../json" } keccak-hash = "0.1" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } [dev-dependencies] rustc-hex= "1.0" diff --git a/ethkey/Cargo.toml b/ethkey/Cargo.toml index 074311c78cd..3317a6c7d8b 100644 --- a/ethkey/Cargo.toml +++ b/ethkey/Cargo.toml @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.4" lazy_static = "1.0" log = "0.4" -parity-util-mem = { path = "../../../parity-common/mem" } +parity-util-mem = { path = "../../../parity-common/parity-util-mem" } parity-wordlist = "1.2" quick-error = "1.2.2" rand = "0.4" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index f940b915c50..48a92bd842d 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -20,7 +20,7 @@ ethcore-transaction = { path = "../ethcore/transaction" } ethereum-types = "0.4" futures = "0.1" parity-runtime = { path = "../util/runtime" } -parity-util-mem = { path = "../../../parity-common/mem" } +parity-util-mem = { path = "../../../parity-common/parity-util-mem" } keccak-hash = "0.1" linked-hash-map = "0.5" log = "0.4" diff --git a/miner/src/pool/mod.rs b/miner/src/pool/mod.rs index cba5e286595..7a71167f62a 100644 --- a/miner/src/pool/mod.rs +++ b/miner/src/pool/mod.rs @@ -175,7 +175,7 @@ impl txpool::VerifiedTransaction for VerifiedTransaction { } fn mem_usage(&self) -> usize { - self.transaction.m_size_of() + self.transaction.malloc_size_of() } fn sender(&self) -> &Address { diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 6d37a4171b7..100a74fc019 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL3" parity-bytes = "0.1" ethereum-types = "0.4" hashdb = "0.3.0" -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index c7d1672a903..b670d620674 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -349,7 +349,7 @@ impl JournalDB for EarlyMergeDB { fn mem_used(&self) -> usize { self.overlay.mem_used() + match self.refs { - Some(ref c) => c.read().m_size_of(), + Some(ref c) => c.read().malloc_size_of(), None => 0 } } diff --git a/util/memory_cache/Cargo.toml b/util/memory_cache/Cargo.toml index 8b7521b45bf..cd5d19cbd9d 100644 --- a/util/memory_cache/Cargo.toml +++ b/util/memory_cache/Cargo.toml @@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used" license = "GPL3" [dependencies] -parity-util-mem = { path = "../../../../parity-common/mem" } +parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } lru-cache = "0.1" diff --git a/util/memory_cache/src/lib.rs b/util/memory_cache/src/lib.rs index fede9501854..5516948aa6a 100644 --- a/util/memory_cache/src/lib.rs +++ b/util/memory_cache/src/lib.rs @@ -37,7 +37,7 @@ pub struct MemoryLruCache { // amount of memory used when the item will be put on the heap. fn heap_size_of(val: &T) -> usize { - ::std::mem::size_of::() + val.m_size_of() + ::std::mem::size_of::() + val.malloc_size_of() } impl MemoryLruCache { diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index 088f29899fa..4aaf7adf927 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -13,7 +13,7 @@ parity-crypto = "0.2" ethkey = { path = "../ethkey" } hex = "0.2" log = "0.4" -parity-util-mem = { path = "../../../parity-common/mem" } +parity-util-mem = { path = "../../../parity-common/parity-util-mem" } ordered-float = "0.5" parking_lot = "0.6" rand = "0.4" From 1668aec963955407ee0b852042ce4d7261ac3bd5 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 9 Jan 2019 14:32:34 +0100 Subject: [PATCH 08/22] test with jemalloc --- Cargo.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------- Cargo.toml | 9 +++++--- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3904ec2ac1c..da96f2e93d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -676,7 +676,7 @@ dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memorydb 0.3.0", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -757,7 +757,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memorydb 0.3.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1292,6 +1292,11 @@ dependencies = [ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fs_extra" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -1638,6 +1643,25 @@ name = "itoa" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "jemalloc-sys" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", + "fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "jemallocator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "jni" version = "0.10.2" @@ -1669,7 +1693,7 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memorydb 0.3.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2015,12 +2039,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memorydb" version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0", + "plain_hasher 0.2.0", + "rlp 0.3.0", ] [[package]] @@ -2355,6 +2378,7 @@ dependencies = [ "parity-rpc-client 1.4.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", + "parity-util-mem 0.1.0", "parity-version 2.3.0", "parity-whisper 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2622,8 +2646,10 @@ dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.0.1", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2729,7 +2755,7 @@ dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memorydb 0.3.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2799,6 +2825,13 @@ dependencies = [ "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "plain_hasher" +version = "0.2.0" +dependencies = [ + "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "plain_hasher" version = "0.2.0" @@ -3103,6 +3136,14 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rlp" +version = "0.3.0" +dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rlp" version = "0.3.0" @@ -4312,6 +4353,7 @@ dependencies = [ "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "921d332c89b3b61a826de38c61ee5b6e02c56806cade1b0e5d81bd71f57a71bb" +"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)" = "49e7653e374fe0d0c12de4250f0bdb60680b8c80eed558c5c7538eec9c89e21b" @@ -4348,6 +4390,8 @@ dependencies = [ "checksum itertools 0.7.8 (registry+https://github.com/rust-lang/crates.io-index)" = "f58856976b776fedd95533137617a02fb25719f40e7d9b01c7043cd65474f450" "checksum itertools-num 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "83ca7b70b838f2e34bc6c2f367a1ed1cfe34fb82464adecadd31cdcc7da882fc" "checksum itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1306f3464951f30e30d12373d31c79fbd52d236e5e896fd92f96ec7babbbe60b" +"checksum jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "bfc62c8e50e381768ce8ee0428ee53741929f7ebd73e4d83f669bcf7693e00ae" +"checksum jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9f0cd42ac65f758063fea55126b0148b1ce0a6354ff78e07a4d6806bc65c4ab3" "checksum jni 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1ecfa3b81afc64d9a6539c4eece96ac9a93c551c713a313800dade8e33d7b5c1" "checksum jni-sys 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" "checksum jsonrpc-core 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)" = "" @@ -4383,7 +4427,6 @@ dependencies = [ "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum memorydb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e143fbad9f90d2158bca3c4b09015276a6de6f085a77088943901cb26828780f" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" diff --git a/Cargo.toml b/Cargo.toml index d45cf49c5da..6026a48b6be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,8 +69,10 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } -# parity-util-mem = { path = "../../parity-common/mem", features = ["jemalloc-global", "estimate-heapsize"] } -# parity-util-mem = { path = "../../parity-common/mem", features = ["estimate-heapsize"] } +# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["jemalloc-global"] } +# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["estimate-heapsize"] } +parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["jemalloc-global", "estimate-heapsize"] } +# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" @@ -141,7 +143,8 @@ members = [ "util/journaldb", ] -#[patch.crates-io] +[patch.crates-io] +memorydb = { path = "../../parity-common2/memorydb" } #ethabi = { path = "../../ethabi/ethabi" } #ethabi-derive = { path = "../../ethabi/derive" } #fixed-hash = { path = "../../parity-common/fixed-hash" } From c521348bed954d3022f1c04ee413d2a50ff44864 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 9 Jan 2019 16:03:53 +0100 Subject: [PATCH 09/22] Plug onto github branch --- Cargo.lock | 75 +++++++++++++++++++--------------- Cargo.toml | 8 ++-- ethcore/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 2 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/transaction/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- ethkey/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 2 +- util/memory_cache/Cargo.toml | 2 +- whisper/Cargo.toml | 2 +- 14 files changed, 58 insertions(+), 49 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da96f2e93d3..10114073131 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,7 +69,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "backtrace-sys 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-demangle 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -202,7 +202,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "cfg-if" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -291,7 +291,7 @@ dependencies = [ "ethjson 0.1.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -371,7 +371,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -385,7 +385,7 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -397,7 +397,7 @@ name = "crossbeam-utils" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -569,7 +569,7 @@ source = "git+https://github.com/paritytech/rust-secp256k1#ccc06e7480148b723eb44 dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -676,14 +676,14 @@ dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memorydb 0.3.0", + "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -757,9 +757,9 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memorydb 0.3.0", + "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -808,7 +808,7 @@ dependencies = [ "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -892,7 +892,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -1005,7 +1005,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1023,7 +1023,7 @@ dependencies = [ "ethkey 0.3.0", "evm 0.1.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "unexpected 0.1.0", @@ -1072,7 +1072,7 @@ dependencies = [ "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1150,7 +1150,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -1693,9 +1693,9 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.3.0", + "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1962,7 +1962,7 @@ name = "log" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1988,6 +1988,7 @@ version = "0.1.0" [[package]] name = "malloc_size_of_derive" version = "0.0.1" +source = "git+https://github.com/cheme/parity-common?branch=mem-tools2#8ada8148718d5c1d247aca5ba5d19135f399d284" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2004,7 +2005,7 @@ name = "memchr" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2028,7 +2029,7 @@ name = "memory-cache" version = "0.1.0" dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", ] [[package]] @@ -2039,11 +2040,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memorydb" version = "0.3.0" +source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", - "plain_hasher 0.2.0", - "rlp 0.3.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", ] [[package]] @@ -2163,7 +2165,7 @@ name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2378,7 +2380,7 @@ dependencies = [ "parity-rpc-client 1.4.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parity-version 2.3.0", "parity-whisper 0.1.0", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2642,12 +2644,14 @@ dependencies = [ [[package]] name = "parity-util-mem" version = "0.1.0" +source = "git+https://github.com/cheme/parity-common?branch=mem-tools2#8ada8148718d5c1d247aca5ba5d19135f399d284" dependencies = [ + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "malloc_size_of_derive 0.0.1", + "malloc_size_of_derive 0.0.1 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2688,7 +2692,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2755,7 +2759,7 @@ dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memorydb 0.3.0", + "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2828,6 +2832,7 @@ dependencies = [ [[package]] name = "plain_hasher" version = "0.2.0" +source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3139,6 +3144,7 @@ dependencies = [ [[package]] name = "rlp" version = "0.3.0" +source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3414,7 +3420,7 @@ name = "socket2" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", "redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4303,7 +4309,7 @@ dependencies = [ "checksum cast 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "926013f2860c46252efceabb19f4a6b308197505082c609025aa6706c011d427" "checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16" "checksum cesu8 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" -"checksum cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0c4e7bb64a8ebb0d856483e1e682ea3422f883c5f5615a90d51a2c82fe87fdd3" +"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4" "checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" "checksum cid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0e37fba0087d9f3f4e269827a55dc511abf3e440cc097a0c154ff4e6584f988" "checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" @@ -4422,11 +4428,13 @@ dependencies = [ "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" "checksum lunarity-lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a1670671f305792567116d4660e6e5bd785d6fa973e817c3445c0a7a54cecb6" +"checksum malloc_size_of_derive 0.0.1 (git+https://github.com/cheme/parity-common?branch=mem-tools2)" = "" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +"checksum memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" @@ -4460,6 +4468,7 @@ dependencies = [ "checksum parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63" "checksum parity-snappy-sys 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c2086caac40c79289cb70d7e1c64f5888e1c53f5d38399d3e95101493739f423" "checksum parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb002c2d3539ccd3b82bd915ec060028d4ab350ad203dbffa20028c1e483af5b" +"checksum parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)" = "" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf13102febd98f4ad416a526b42deb82daf482626ba6ab10d0ebf8f45327514c" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -4473,6 +4482,7 @@ dependencies = [ "checksum phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "7d187f00cd98d5afbcd8898f6cf181743a449162aeb329dcd2f3849009e605ad" "checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b" "checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93" +"checksum plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" "checksum plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "95fa6386b1d34aaf0adb9b7dd2885dbe7c34190e6263785e5a7ec2b19044a90f" "checksum pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2412f3332a07c7a2a50168988dcc184f32180a9758ad470390e5f55e089f6b6e" "checksum primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0e31b86efadeaeb1235452171a66689682783149a6249ff334a2c5d8218d00a4" @@ -4504,6 +4514,7 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum ring 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe642b9dd1ba0038d78c4a3999d1ee56178b4d415c1e1fbaba83b06dce012f0" "checksum rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "524c5ad554859785dfc8469df3ed5e0b5784d4d335877ed47c8d90fc0eb238fe" +"checksum rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" "checksum rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" "checksum rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1601f32bc5858aae3cbfa1c645c96c4d820cc5c16be0194f089560c00b6eb625" diff --git a/Cargo.toml b/Cargo.toml index 6026a48b6be..e66b42295d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,10 +69,7 @@ ethcore-secretstore = { path = "secret_store", optional = true } registrar = { path = "registrar" } -# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["jemalloc-global"] } -# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["estimate-heapsize"] } -parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["jemalloc-global", "estimate-heapsize"] } -# parity-util-mem = { path = "../../parity-common/parity-util-mem", features = ["estimate-heapsize"] } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2", features = ["jemalloc-global", "estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" @@ -144,7 +141,8 @@ members = [ ] [patch.crates-io] -memorydb = { path = "../../parity-common2/memorydb" } +memorydb = { git = "https://github.com/cheme/parity-common", branch = "rem_heapsize" } +#memorydb = { path = "../../parity-common2/memorydb" } #ethabi = { path = "../../ethabi/ethabi" } #ethabi-derive = { path = "../../ethabi/derive" } #fixed-hash = { path = "../../parity-common/fixed-hash" } diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 05b26408f4d..78fea00ad5c 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -36,7 +36,7 @@ ethjson = { path = "../json" } ethkey = { path = "../ethkey" } ethstore = { path = "../ethstore" } evm = { path = "evm" } -parity-util-mem = { path = "../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } itertools = "0.5" lazy_static = "1.0" log = "0.4" diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 24cbd8f971d..cf58f687ba9 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] bit-set = "0.4" parity-bytes = "0.1" ethereum-types = "0.4" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } lazy_static = "1.0" log = "0.4" vm = { path = "../vm" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 2146b552904..cf12f0eac54 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -18,7 +18,7 @@ patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } hashdb = "0.3.0" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] } diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index fb4ec7e4f11..779d9f0ed54 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -22,7 +22,7 @@ ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } keccak-hash = "0.1.2" log = "0.4" parking_lot = "0.6" diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 2bc7d44d14d..2b296492a18 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -28,7 +28,7 @@ macros = { path = "../../util/macros" } log = "0.4" env_logger = "0.5" rand = "0.4" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } parking_lot = "0.6" trace-time = "0.1" diff --git a/ethcore/transaction/Cargo.toml b/ethcore/transaction/Cargo.toml index 350f6885857..85fd2f62923 100644 --- a/ethcore/transaction/Cargo.toml +++ b/ethcore/transaction/Cargo.toml @@ -8,7 +8,7 @@ authors = ["Parity Technologies "] ethjson = { path = "../../json" } ethkey = { path = "../../ethkey" } evm = { path = "../evm" } -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } keccak-hash = "0.1" rlp = { version = "0.3.0", features = ["ethereum"] } unexpected = { path = "../../util/unexpected" } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index f2186ed9131..c3342b2927b 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -11,7 +11,7 @@ parity-bytes = "0.1" ethereum-types = "0.4" ethjson = { path = "../../json" } keccak-hash = "0.1" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } [dev-dependencies] rustc-hex= "1.0" diff --git a/ethkey/Cargo.toml b/ethkey/Cargo.toml index 3317a6c7d8b..5afee1c1138 100644 --- a/ethkey/Cargo.toml +++ b/ethkey/Cargo.toml @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.4" lazy_static = "1.0" log = "0.4" -parity-util-mem = { path = "../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } parity-wordlist = "1.2" quick-error = "1.2.2" rand = "0.4" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index 48a92bd842d..87f31583ae8 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -20,7 +20,7 @@ ethcore-transaction = { path = "../ethcore/transaction" } ethereum-types = "0.4" futures = "0.1" parity-runtime = { path = "../util/runtime" } -parity-util-mem = { path = "../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } keccak-hash = "0.1" linked-hash-map = "0.5" log = "0.4" diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 100a74fc019..78ec1ed275c 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -9,7 +9,7 @@ license = "GPL3" parity-bytes = "0.1" ethereum-types = "0.4" hashdb = "0.3.0" -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" diff --git a/util/memory_cache/Cargo.toml b/util/memory_cache/Cargo.toml index cd5d19cbd9d..d9817e0ea63 100644 --- a/util/memory_cache/Cargo.toml +++ b/util/memory_cache/Cargo.toml @@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used" license = "GPL3" [dependencies] -parity-util-mem = { path = "../../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } lru-cache = "0.1" diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index 4aaf7adf927..c59fe4b6b09 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -13,7 +13,7 @@ parity-crypto = "0.2" ethkey = { path = "../ethkey" } hex = "0.2" log = "0.4" -parity-util-mem = { path = "../../../parity-common/parity-util-mem" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } ordered-float = "0.5" parking_lot = "0.6" rand = "0.4" From 5d0b165c84d2a02463d9da56dac008c8f5cc2291 Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 9 Jan 2019 17:30:52 +0100 Subject: [PATCH 10/22] Update to reorg. --- Cargo.lock | 36 +++++------------------ accounts/ethkey/src/secret.rs | 2 +- ethcore/blockchain/Cargo.toml | 2 +- ethcore/blockchain/src/blockchain.rs | 2 +- ethcore/blockchain/src/lib.rs | 3 ++ ethcore/db/Cargo.toml | 2 +- ethcore/db/src/lib.rs | 3 ++ ethcore/light/src/cache.rs | 1 - ethcore/src/engines/validator_set/test.rs | 1 - ethcore/src/lib.rs | 1 - ethcore/src/trace/db.rs | 1 - ethcore/types/src/lib.rs | 1 - whisper/src/rpc/crypto.rs | 2 +- whisper/src/rpc/key_store.rs | 2 +- whisper/src/rpc/mod.rs | 2 +- 15 files changed, 21 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index be1361997b9..412f4f648d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -299,12 +299,11 @@ version = "0.1.0" dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethjson 0.1.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "ethkey 0.3.0", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -439,7 +438,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -464,7 +463,7 @@ name = "crossbeam-utils" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cfg-if 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -770,13 +769,13 @@ dependencies = [ "ethcore-db 0.1.0", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethkey 0.3.0", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -799,8 +798,8 @@ version = "0.1.0" dependencies = [ "common-types 0.1.0", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", @@ -1088,6 +1087,7 @@ dependencies = [ "ethstore 0.2.1", "fastmap 0.1.0", "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1104,21 +1104,6 @@ dependencies = [ "triehash-ethereum 0.2.0", ] -[[package]] -name = "ethcore-transaction" -version = "0.1.0" -dependencies = [ - "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ethjson 0.1.0", - "ethkey 0.3.0", - "evm 0.1.0", - "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", - "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unexpected 0.1.0", -] - [[package]] name = "ethereum-types" version = "0.4.0" @@ -2139,10 +2124,6 @@ dependencies = [ "rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", ] -[[package]] -name = "memzero" -version = "0.1.0" - [[package]] name = "migration-rocksdb" version = "0.1.0" @@ -2750,7 +2731,7 @@ dependencies = [ "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.0.1 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", - "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2788,10 +2769,9 @@ dependencies = [ "jsonrpc-macros 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", "jsonrpc-pubsub 9.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-2.2)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", - "memzero 0.1.0", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/accounts/ethkey/src/secret.rs b/accounts/ethkey/src/secret.rs index 84e849cabc5..231a99e9c89 100644 --- a/accounts/ethkey/src/secret.rs +++ b/accounts/ethkey/src/secret.rs @@ -21,7 +21,7 @@ use rustc_hex::ToHex; use secp256k1::constants::{SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE}; use secp256k1::key; use ethereum_types::H256; -use memzero::Memzero; +use mem::Memzero; use {Error, SECP256K1}; #[derive(Clone, PartialEq, Eq)] diff --git a/ethcore/blockchain/Cargo.toml b/ethcore/blockchain/Cargo.toml index a2636975705..bce6b9aa284 100644 --- a/ethcore/blockchain/Cargo.toml +++ b/ethcore/blockchain/Cargo.toml @@ -13,7 +13,7 @@ blooms-db = { path = "../../util/blooms-db" } common-types = { path = "../types" } ethcore-db = { path = "../db" } ethereum-types = "0.4" -heapsize = "0.4" +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } itertools = "0.5" kvdb = "0.1" log = "0.4" diff --git a/ethcore/blockchain/src/blockchain.rs b/ethcore/blockchain/src/blockchain.rs index 0207a3ace9a..f72b88cfc97 100644 --- a/ethcore/blockchain/src/blockchain.rs +++ b/ethcore/blockchain/src/blockchain.rs @@ -39,7 +39,7 @@ use ethcore_db::cache_manager::CacheManager; use ethcore_db::keys::{BlockReceipts, BlockDetails, TransactionAddress, EPOCH_KEY_PREFIX, EpochTransitions}; use ethcore_db::{self as db, Writable, Readable, CacheUpdatePolicy}; use ethereum_types::{H256, Bloom, BloomRef, U256}; -use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; +use util_mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use itertools::Itertools; use kvdb::{DBTransaction, KeyValueDB}; use log::{trace, warn, info}; diff --git a/ethcore/blockchain/src/lib.rs b/ethcore/blockchain/src/lib.rs index 0ee7a5c1c8c..5aafc930157 100644 --- a/ethcore/blockchain/src/lib.rs +++ b/ethcore/blockchain/src/lib.rs @@ -18,6 +18,9 @@ #![warn(missing_docs)] +extern crate parity_util_mem as util_mem; +extern crate parity_util_mem as malloc_size_of; + mod best_block; mod block_info; mod blockchain; diff --git a/ethcore/db/Cargo.toml b/ethcore/db/Cargo.toml index 53ec9f7b881..efb112d0f72 100644 --- a/ethcore/db/Cargo.toml +++ b/ethcore/db/Cargo.toml @@ -10,8 +10,8 @@ edition = "2018" [dependencies] common-types = { path = "../types" } ethereum-types = "0.4" -heapsize = "0.4" kvdb = "0.1" +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } parking_lot = "0.7" rlp = { version = "0.3.0", features = ["ethereum"] } rlp_derive = { path = "../../util/rlp-derive" } diff --git a/ethcore/db/src/lib.rs b/ethcore/db/src/lib.rs index 3fdb368a1aa..492d255c497 100644 --- a/ethcore/db/src/lib.rs +++ b/ethcore/db/src/lib.rs @@ -18,6 +18,9 @@ #![warn(missing_docs)] +extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; + mod db; pub mod keys; diff --git a/ethcore/light/src/cache.rs b/ethcore/light/src/cache.rs index 1d72028a804..ca33e5f8065 100644 --- a/ethcore/light/src/cache.rs +++ b/ethcore/light/src/cache.rs @@ -27,7 +27,6 @@ use common_types::encoded; use common_types::BlockNumber; use common_types::receipt::Receipt; use ethereum_types::{H256, U256}; -use heapsize::HeapSizeOf; use memory_cache::MemoryLruCache; use stats::Corpus; diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index 485e1e12c62..07b947fea77 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -23,7 +23,6 @@ use mem::{MallocSizeOf, MallocSizeOfOps}; use bytes::Bytes; use ethereum_types::{H256, Address}; -use heapsize::HeapSizeOf; use types::BlockNumber; use types::header::Header; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 2d92273de1a..c40f5c423aa 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -74,7 +74,6 @@ extern crate ethjson; extern crate ethkey; extern crate ethstore; extern crate hashdb; -extern crate heapsize; extern crate itertools; extern crate journaldb; extern crate keccak_hash as hash; diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 579dfae7ef2..b42ba194231 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -23,7 +23,6 @@ use blockchain::BlockChainDB; use db::cache_manager::CacheManager; use db::{self, Key, Writable, Readable, CacheUpdatePolicy}; use ethereum_types::{H256, H264}; -use heapsize::HeapSizeOf; use kvdb::{DBTransaction}; use parking_lot::RwLock; use types::BlockNumber; diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index 5129c722c6c..7bb656436cd 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -36,7 +36,6 @@ extern crate ethereum_types; extern crate ethjson; extern crate ethkey; -extern crate heapsize; extern crate keccak_hash as hash; extern crate parity_bytes as bytes; extern crate parity_machine; diff --git a/whisper/src/rpc/crypto.rs b/whisper/src/rpc/crypto.rs index 89116345313..fe783e733e0 100644 --- a/whisper/src/rpc/crypto.rs +++ b/whisper/src/rpc/crypto.rs @@ -20,7 +20,7 @@ use crypto::aes_gcm::{Encryptor, Decryptor}; use ethkey::crypto::ecies; use ethereum_types::H256; use ethkey::{self, Public, Secret}; -use memzero::Memzero; +use mem::Memzero; /// Length of AES key pub const AES_KEY_LEN: usize = 32; diff --git a/whisper/src/rpc/key_store.rs b/whisper/src/rpc/key_store.rs index 081a8b374d6..f8d3fddab21 100644 --- a/whisper/src/rpc/key_store.rs +++ b/whisper/src/rpc/key_store.rs @@ -23,7 +23,7 @@ use std::collections::HashMap; use ethereum_types::H256; use ethkey::{KeyPair, Public, Secret}; -use memzero::Memzero; +use mem::Memzero; use rand::{Rng, OsRng}; use rpc::crypto::{AES_KEY_LEN, EncryptionInstance, DecryptionInstance}; diff --git a/whisper/src/rpc/mod.rs b/whisper/src/rpc/mod.rs index c3958f77f72..61d361c68ef 100644 --- a/whisper/src/rpc/mod.rs +++ b/whisper/src/rpc/mod.rs @@ -28,7 +28,7 @@ use jsonrpc_pubsub::{Session, PubSubMetadata, SubscriptionId}; use jsonrpc_macros::pubsub; use ethereum_types::H256; -use memzero::Memzero; +use mem::Memzero; use parking_lot::RwLock; use self::filter::Filter; From 3f0ed813e6c81fccf377ecbc270478333a844c86 Mon Sep 17 00:00:00 2001 From: cheme Date: Mon, 14 Jan 2019 12:15:56 +0100 Subject: [PATCH 11/22] switch to deprecate branch of memorydb --- Cargo.lock | 77 ++++++++++++----------- Cargo.toml | 22 +------ accounts/ethkey/Cargo.toml | 2 +- ethcore/Cargo.toml | 5 +- ethcore/blockchain/Cargo.toml | 2 +- ethcore/db/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 5 +- ethcore/private-tx/Cargo.toml | 2 +- ethcore/src/engines/validator_set/test.rs | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/types/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 5 +- util/journaldb/src/archivedb.rs | 3 +- util/journaldb/src/earlymergedb.rs | 7 ++- util/journaldb/src/overlayrecentdb.rs | 5 +- util/memory-cache/Cargo.toml | 2 +- util/patricia-trie-ethereum/Cargo.toml | 3 +- whisper/Cargo.toml | 2 +- 20 files changed, 70 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 393036f6dbe..6a261652f89 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ dependencies = [ "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -728,14 +728,14 @@ dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "memorydb 0.4.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -775,7 +775,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -799,7 +799,7 @@ dependencies = [ "common-types 0.1.0", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", @@ -846,9 +846,9 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "memorydb 0.4.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -897,7 +897,7 @@ dependencies = [ "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -981,7 +981,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", @@ -1095,7 +1095,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1147,7 +1147,7 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1226,7 +1226,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -1769,9 +1769,9 @@ dependencies = [ "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "memorydb 0.4.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2060,8 +2060,8 @@ version = "0.1.0" [[package]] name = "malloc_size_of_derive" -version = "0.0.1" -source = "git+https://github.com/cheme/parity-common?branch=mem-tools2#8ada8148718d5c1d247aca5ba5d19135f399d284" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)", "syn 0.15.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2102,7 +2102,7 @@ name = "memory-cache" version = "0.1.0" dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", ] [[package]] @@ -2112,13 +2112,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "memorydb" -version = "0.3.0" -source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" +version = "0.4.0" +source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#81b2da10d435e710d41dc792b223c84d192028a8" dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", - "plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", - "rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", ] [[package]] @@ -2296,7 +2297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2469,7 +2470,7 @@ dependencies = [ "parity-rpc 1.12.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parity-version 2.3.0", "parity-whisper 0.1.0", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2731,14 +2732,14 @@ dependencies = [ [[package]] name = "parity-util-mem" version = "0.1.0" -source = "git+https://github.com/cheme/parity-common?branch=mem-tools2#8ada8148718d5c1d247aca5ba5d19135f399d284" +source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#81b2da10d435e710d41dc792b223c84d192028a8" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "malloc_size_of_derive 0.0.1 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2779,7 +2780,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)", + "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2867,7 +2868,7 @@ dependencies = [ "hashdb 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)", + "memorydb 0.4.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2940,7 +2941,7 @@ dependencies = [ [[package]] name = "plain_hasher" version = "0.2.0" -source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" +source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#81b2da10d435e710d41dc792b223c84d192028a8" dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3136,7 +3137,7 @@ name = "rand_chacha" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3158,7 +3159,7 @@ name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3183,7 +3184,7 @@ name = "rand_xorshift" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3312,7 +3313,7 @@ dependencies = [ [[package]] name = "rlp" version = "0.3.0" -source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize#e3516d2c3fdce8dc2c3547b714ea92393581ee0b" +source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#81b2da10d435e710d41dc792b223c84d192028a8" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4585,13 +4586,13 @@ dependencies = [ "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4d06ff7ff06f729ce5f4e227876cb88d10bc59cd4ae1e09fbb2bde15c850dc21" "checksum lunarity-lexer 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8a1670671f305792567116d4660e6e5bd785d6fa973e817c3445c0a7a54cecb6" -"checksum malloc_size_of_derive 0.0.1 (git+https://github.com/cheme/parity-common?branch=mem-tools2)" = "" +"checksum malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "35adee9ed962cf7d07d62cb58bc45029f3227f5b5b86246caa8632f06c187bc3" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" -"checksum memorydb 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" +"checksum memorydb 0.4.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)" = "" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" "checksum mio 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "71646331f2619b1026cc302f87a2b8b648d5c6dd6937846a16cc8ce0f347f432" @@ -4626,7 +4627,7 @@ dependencies = [ "checksum parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63" "checksum parity-snappy-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1a413d51e5e1927320c9de992998e4a279dffb8c8a7363570198bd8383e66f1b" "checksum parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb002c2d3539ccd3b82bd915ec060028d4ab350ad203dbffa20028c1e483af5b" -"checksum parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=mem-tools2)" = "" +"checksum parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)" = "" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf13102febd98f4ad416a526b42deb82daf482626ba6ab10d0ebf8f45327514c" "checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5" @@ -4642,7 +4643,7 @@ dependencies = [ "checksum phf_codegen 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "7d187f00cd98d5afbcd8898f6cf181743a449162aeb329dcd2f3849009e605ad" "checksum phf_generator 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "03dc191feb9b08b0dc1330d6549b795b9d81aec19efe6b4a45aec8d4caee0c4b" "checksum phf_shared 0.7.23 (registry+https://github.com/rust-lang/crates.io-index)" = "b539898d22d4273ded07f64a05737649dc69095d92cb87c7097ec68e3f150b93" -"checksum plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" +"checksum plain_hasher 0.2.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)" = "" "checksum plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "95fa6386b1d34aaf0adb9b7dd2885dbe7c34190e6263785e5a7ec2b19044a90f" "checksum pretty_assertions 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2412f3332a07c7a2a50168988dcc184f32180a9758ad470390e5f55e089f6b6e" "checksum primal 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0e31b86efadeaeb1235452171a66689682783149a6249ff334a2c5d8218d00a4" @@ -4680,7 +4681,7 @@ dependencies = [ "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" "checksum rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "524c5ad554859785dfc8469df3ed5e0b5784d4d335877ed47c8d90fc0eb238fe" -"checksum rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=rem_heapsize)" = "" +"checksum rlp 0.3.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)" = "" "checksum rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" "checksum rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1601f32bc5858aae3cbfa1c645c96c4d820cc5c16be0194f089560c00b6eb625" diff --git a/Cargo.toml b/Cargo.toml index deef7b39d5f..d91e08f4a7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,7 @@ ethcore-secretstore = { path = "secret-store", optional = true } registrar = { path = "util/registrar" } -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2", features = ["jemalloc-global", "estimate-heapsize"] } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize", features = ["jemalloc-global", "estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" @@ -135,23 +135,3 @@ members = [ "parity-clib", "whisper/cli", ] - -[patch.crates-io] -memorydb = { git = "https://github.com/cheme/parity-common", branch = "rem_heapsize" } -#memorydb = { path = "../../parity-common2/memorydb" } -#ethabi = { path = "../../ethabi/ethabi" } -#ethabi-derive = { path = "../../ethabi/derive" } -#fixed-hash = { path = "../../parity-common/fixed-hash" } -#keccak-hash = { path = "../../parity-common/keccak-hash" } -#memorydb = { path = "../../parity-common/memorydb" } -#hashdb = { path = "../../parity-common/hashdb" } -#kvdb = { path = "../../parity-common/kvdb" } -#patricia-trie = { path = "../../parity-common/patricia_trie" } -#rlp = { path = "../../parity-common/rlp" } -#uint = { path = "../../parity-common/uint" } -#ethereum-types = { path = "../../parity-primitives/ethereum-types" } -#ethbloom = { path = "../../parity-primitives/ethbloom" } -#[replace] -#"fixed-hash:0.2.2" = { path = "../../parity-common/fixed-hash" } -#"uint:0.4.1" = { path = "../../parity-common/uint" } -#"ethereum-types:0.4.0" = { path = "../../parity-primitives/ethereum-types" } diff --git a/accounts/ethkey/Cargo.toml b/accounts/ethkey/Cargo.toml index 5afee1c1138..810b7bb12a9 100644 --- a/accounts/ethkey/Cargo.toml +++ b/accounts/ethkey/Cargo.toml @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.4" lazy_static = "1.0" log = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } parity-wordlist = "1.2" quick-error = "1.2.2" rand = "0.4" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 9b02b70cd98..a66cd8b1910 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -30,7 +30,7 @@ ethjson = { path = "../json" } ethkey = { path = "../accounts/ethkey" } ethstore = { path = "../accounts/ethstore" } evm = { path = "evm" } -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } hashdb = "0.3.0" itertools = "0.5" journaldb = { path = "../util/journaldb" } @@ -45,7 +45,8 @@ log = "0.4" lru-cache = "0.1" macros = { path = "../util/macros" } memory-cache = { path = "../util/memory-cache" } -memorydb = "0.3.0" +#memorydb = "0.4" +memorydb = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } num = { version = "0.1", default-features = false, features = ["bigint"] } num_cpus = "1.2" parity-bytes = "0.1" diff --git a/ethcore/blockchain/Cargo.toml b/ethcore/blockchain/Cargo.toml index bce6b9aa284..d7e04b74ba8 100644 --- a/ethcore/blockchain/Cargo.toml +++ b/ethcore/blockchain/Cargo.toml @@ -13,7 +13,7 @@ blooms-db = { path = "../../util/blooms-db" } common-types = { path = "../types" } ethcore-db = { path = "../db" } ethereum-types = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } itertools = "0.5" kvdb = "0.1" log = "0.4" diff --git a/ethcore/db/Cargo.toml b/ethcore/db/Cargo.toml index efb112d0f72..d694520f45c 100644 --- a/ethcore/db/Cargo.toml +++ b/ethcore/db/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" common-types = { path = "../types" } ethereum-types = "0.4" kvdb = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } parking_lot = "0.7" rlp = { version = "0.3.0", features = ["ethereum"] } rlp_derive = { path = "../../util/rlp-derive" } diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index fa32d2451db..1f971707ea1 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] bit-set = "0.4" parity-bytes = "0.1" ethereum-types = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } lazy_static = "1.0" log = "0.4" vm = { path = "../vm" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 63e2cf28f79..35e2f6c0c0f 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -14,13 +14,14 @@ ethcore = { path = ".."} ethcore-db = { path = "../db" } ethcore-blockchain = { path = "../blockchain" } ethereum-types = "0.4" -memorydb = "0.3.0" +#memorydb = "0.4" +memorydb = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } patricia-trie = "0.3.0" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } hashdb = "0.3.0" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] } diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 9ac9a3f1e5b..56b5bf5327a 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -19,7 +19,7 @@ ethjson = { path = "../../json" } ethkey = { path = "../../accounts/ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } keccak-hash = "0.1.2" log = "0.4" parity-bytes = "0.1" diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index 07b947fea77..376b536cf88 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -19,7 +19,7 @@ use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use mem::{MallocSizeOf}; use bytes::Bytes; use ethereum_types::{H256, Address}; diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index c23c503a221..4a3312c4308 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -28,7 +28,7 @@ macros = { path = "../../util/macros" } parity-bytes = "0.1" parking_lot = "0.7" rand = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } rlp = { version = "0.3.0", features = ["ethereum"] } trace-time = "0.1" triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index 866351ca54b..ff1e5724afb 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] ethereum-types = "0.4" ethjson = { path = "../../json" } -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } ethkey = { path = "../../accounts/ethkey" } keccak-hash = "0.1" parity-bytes = "0.1" diff --git a/miner/Cargo.toml b/miner/Cargo.toml index f90588d87e0..75785cb9f2a 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -19,7 +19,7 @@ common-types = { path = "../ethcore/types" } error-chain = "0.12" ethereum-types = "0.4" futures = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } keccak-hash = "0.1" linked-hash-map = "0.5" log = "0.4" diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 4d21d9c6f18..6ba5447ff14 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -9,11 +9,12 @@ license = "GPL3" parity-bytes = "0.1" ethereum-types = "0.4" hashdb = "0.3.0" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" -memorydb = "0.3.0" +#memorydb = "0.4" +memorydb = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } parking_lot = "0.7" fastmap = { path = "../../util/fastmap" } rlp = { version = "0.3.0", features = ["ethereum"] } diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index a6dcd293775..2ce34b4287c 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -23,6 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; +use mem::{MallocSizeOfExt}; use hashdb::*; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; @@ -120,7 +121,7 @@ impl JournalDB for ArchiveDB { } fn mem_used(&self) -> usize { - self.overlay.mem_used() + self.overlay.malloc_size_of() } fn is_empty(&self) -> bool { diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index 44949168125..7977abb970c 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hashdb::*; -use mem::{MallocSizeOf, MallocSizeOfExt}; +use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use memorydb::*; @@ -348,8 +348,9 @@ impl JournalDB for EarlyMergeDB { fn latest_era(&self) -> Option { self.latest_era } fn mem_used(&self) -> usize { - self.overlay.mem_used() + match self.refs { - Some(ref c) => c.read().malloc_size_of(), + let mut ops = new_malloc_size_ops(); + self.overlay.size_of(&mut ops) + match self.refs { + Some(ref c) => c.read().size_of(&mut ops), None => 0 } } diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 241d7b9282c..61de3780ae3 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -242,12 +242,11 @@ impl JournalDB for OverlayRecentDB { } fn mem_used(&self) -> usize { - // TODO could use mem alloc derive instead (require some switch in other crates) - let mut mem = self.transaction_overlay.mem_used(); let mut ops = new_malloc_size_ops(); + let mut mem = self.transaction_overlay.size_of(&mut ops); let overlay = self.journal_overlay.read(); - mem += overlay.backing_overlay.mem_used(); + mem += overlay.backing_overlay.size_of(&mut ops); mem += overlay.pending_overlay.size_of(&mut ops); mem += overlay.journal.size_of(&mut ops); diff --git a/util/memory-cache/Cargo.toml b/util/memory-cache/Cargo.toml index d9817e0ea63..ad9e5bbb68a 100644 --- a/util/memory-cache/Cargo.toml +++ b/util/memory-cache/Cargo.toml @@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used" license = "GPL3" [dependencies] -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } lru-cache = "0.1" diff --git a/util/patricia-trie-ethereum/Cargo.toml b/util/patricia-trie-ethereum/Cargo.toml index e6880691a12..3be95268ac3 100644 --- a/util/patricia-trie-ethereum/Cargo.toml +++ b/util/patricia-trie-ethereum/Cargo.toml @@ -15,5 +15,6 @@ ethereum-types = "0.4" elastic-array = "0.10" [dev-dependencies] -memorydb = "0.3.0" +#memorydb = "0.4" +memorydb = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } keccak-hash = "0.1.2" diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index ce0df282e1f..0da227a1032 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -13,7 +13,7 @@ parity-crypto = "0.2" ethkey = { path = "../accounts/ethkey" } hex = "0.2" log = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "mem-tools2" } +parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } ordered-float = "0.5" parking_lot = "0.7" rand = "0.4" From 7c56348423d578102c352326c55adb7e5646570e Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 25 Jan 2019 15:36:52 +0100 Subject: [PATCH 12/22] latest version of parity-util-mem --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0612decbc3c..052f625dde4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2749,7 +2749,7 @@ dependencies = [ [[package]] name = "parity-util-mem" version = "0.1.0" -source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#81b2da10d435e710d41dc792b223c84d192028a8" +source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#df840886bf9e4e19a025642b97e09d744956bd66" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", From 59ab2d1adbf79fe6046b349c0e0c03bf087326ef Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 28 Feb 2019 16:37:01 +0100 Subject: [PATCH 13/22] Do not switch test ... --- 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 04940788157..725dbc73a54 160000 --- a/ethcore/res/ethereum/tests +++ b/ethcore/res/ethereum/tests @@ -1 +1 @@ -Subproject commit 04940788157c88c75b014e5e6969a249f49db4c0 +Subproject commit 725dbc73a54649e22a00330bd0f4d6699a5060e5 From 32cafaaf4a5ed93c5d250f7d3ad92a74b3a264bc Mon Sep 17 00:00:00 2001 From: cheme Date: Mon, 3 Jun 2019 10:28:59 +0200 Subject: [PATCH 14/22] In progress version switch, will require full upgrade of mem-db hash-db trie-db (memdb only is not enough). also parity common crate using those three need an upgrade (plus trie-hash need feature std to avoid error on build). --- Cargo.lock | 141 ++++++++++++++----------- Cargo.toml | 2 +- accounts/ethkey/Cargo.toml | 2 +- ethcore/Cargo.toml | 8 +- ethcore/blockchain/Cargo.toml | 2 +- ethcore/db/Cargo.toml | 2 +- ethcore/evm/Cargo.toml | 2 +- ethcore/light/Cargo.toml | 8 +- ethcore/private-tx/Cargo.toml | 4 +- ethcore/sync/Cargo.toml | 4 +- ethcore/types/Cargo.toml | 2 +- ethcore/vm/Cargo.toml | 2 +- miner/Cargo.toml | 2 +- rpc/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 6 +- util/keccak-hasher/Cargo.toml | 2 +- util/memory-cache/Cargo.toml | 2 +- util/patricia-trie-ethereum/Cargo.toml | 6 +- util/triehash-ethereum/Cargo.toml | 2 +- whisper/Cargo.toml | 2 +- 20 files changed, 113 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdd880b1e22..9c17230e7f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -314,7 +314,7 @@ dependencies = [ "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-machine 0.1.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -591,7 +591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "elastic-array" -version = "0.10.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -727,7 +727,7 @@ dependencies = [ "ethkey 0.3.0", "evm 0.1.0", "fetch 0.1.0", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -741,7 +741,7 @@ dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memory-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -749,7 +749,7 @@ dependencies = [ "parity-machine 0.1.0", "parity-runtime 0.1.0", "parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -763,7 +763,7 @@ dependencies = [ "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "trie-standardmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "unexpected 0.1.0", @@ -807,7 +807,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rayon 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -840,7 +840,7 @@ dependencies = [ "common-types 0.1.0", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp_derive 0.1.0", @@ -879,7 +879,7 @@ dependencies = [ "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -888,9 +888,9 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memory-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -901,7 +901,7 @@ dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "triehash-ethereum 0.2.0", "vm 0.1.0", ] @@ -943,7 +943,7 @@ dependencies = [ "linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-runtime 0.1.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "price-info 1.12.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1033,7 +1033,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1045,7 +1045,7 @@ dependencies = [ "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1140,7 +1140,7 @@ dependencies = [ "ethkey 0.3.0", "ethstore 0.2.1", "fastmap 0.1.0", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -1149,7 +1149,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1201,7 +1201,7 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1281,7 +1281,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "vm 0.1.0", @@ -1553,7 +1553,17 @@ dependencies = [ [[package]] name = "hash-db" version = "0.11.0" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#cba8e5e2600beff862e5c57638886369dd8cba20" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "hash-db" +version = "0.12.2" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" + +[[package]] +name = "hashmap_core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "heapsize" @@ -1819,15 +1829,15 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1947,7 +1957,7 @@ name = "keccak-hasher" version = "0.1.1" dependencies = [ "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1966,7 +1976,7 @@ name = "kvdb" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1984,7 +1994,7 @@ name = "kvdb-rocksdb" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "fs-swap 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "interleaved-ordered 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2159,17 +2169,17 @@ name = "memory-cache" version = "0.1.0" dependencies = [ "lru-cache 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "memory-db" -version = "0.11.0" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#cba8e5e2600beff862e5c57638886369dd8cba20" +version = "0.12.3" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" dependencies = [ - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", - "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2352,7 +2362,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2540,7 +2550,7 @@ dependencies = [ "parity-rpc 1.12.0", "parity-runtime 0.1.0", "parity-updater 1.12.0", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-version 2.5.0", "parity-whisper 0.1.0", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2708,7 +2718,7 @@ dependencies = [ "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "vm 0.1.0", ] @@ -2802,11 +2812,11 @@ dependencies = [ [[package]] name = "parity-util-mem" version = "0.1.0" -source = "git+https://github.com/cheme/parity-common?branch=deprecate_heapsize#233bd998201ded0e8279d095e6754d5ddc067870" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", "malloc_size_of_derive 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2850,7 +2860,7 @@ dependencies = [ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "ordered-float 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "parity-crypto 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)", + "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2938,16 +2948,16 @@ dependencies = [ name = "patricia-trie-ethereum" version = "0.1.0" dependencies = [ - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memory-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", ] [[package]] @@ -3373,7 +3383,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3388,11 +3398,20 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rlp" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rlp_compress" version = "0.1.0" dependencies = [ - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4102,11 +4121,12 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.11.0" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#cba8e5e2600beff862e5c57638886369dd8cba20" +version = "0.12.2" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" dependencies = [ - "elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4124,11 +4144,11 @@ dependencies = [ [[package]] name = "triehash" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", - "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4137,7 +4157,7 @@ version = "0.2.0" dependencies = [ "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "triehash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "triehash 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4315,7 +4335,7 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", ] [[package]] @@ -4553,7 +4573,7 @@ dependencies = [ "checksum docopt 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db2906c2579b5b7207fc1e328796a9a8835dc44e22dbe8e460b1d636f9a7b225" "checksum edit-distance 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3bd26878c3d921f89797a4e1a1711919f999a9f6946bb6f5a4ffda126d297b7e" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" -"checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" +"checksum elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "073be79b6538296faf81c631872676600616073817dd9a440c477ad09b408983" "checksum enum_primitive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be4551092f4d519593039259a9ed8daedf0da12e5109c5280338073eaeb81180" "checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" @@ -4586,7 +4606,9 @@ dependencies = [ "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" -"checksum hash-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03501f6e1a2a97f1618879aba3156f14ca2847faa530c4e28859638bd11483" +"checksum hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" "checksum hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6a22814455d41612f41161581c2883c0c6a1c41852729b17d5ed88f01e153aa" @@ -4647,7 +4669,7 @@ dependencies = [ "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum memory-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" "checksum mime_guess 2.0.0-alpha.6 (registry+https://github.com/rust-lang/crates.io-index)" = "30de2e4613efcba1ec63d8133f344076952090c122992a903359be5a4f99c3ed" @@ -4684,7 +4706,7 @@ dependencies = [ "checksum parity-snappy 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2c5f9d149b13134b8b354d93a92830efcbee6fe5b73a2e6e540fe70d4dd8a63" "checksum parity-snappy-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1a413d51e5e1927320c9de992998e4a279dffb8c8a7363570198bd8383e66f1b" "checksum parity-tokio-ipc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eb002c2d3539ccd3b82bd915ec060028d4ab350ad203dbffa20028c1e483af5b" -"checksum parity-util-mem 0.1.0 (git+https://github.com/cheme/parity-common?branch=deprecate_heapsize)" = "" +"checksum parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "89e80f22052161e0cb55cb5a8a75890420c525031f95c9d262dbb0434aa85dc1" "checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc" "checksum parity-wordlist 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf13102febd98f4ad416a526b42deb82daf482626ba6ab10d0ebf8f45327514c" "checksum parity-ws 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fec5048fba72a2e01baeb0d08089db79aead4b57e2443df172fb1840075a233" @@ -4738,6 +4760,7 @@ dependencies = [ "checksum ring 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be5386a5f59e5f5bcaea38b50ad26c09e3918a0abc0610640b3be5cfd85d6894" "checksum rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "524c5ad554859785dfc8469df3ed5e0b5784d4d335877ed47c8d90fc0eb238fe" "checksum rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720" +"checksum rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b0d56c1450bfbef1181fdeb78b902dc1d23178de77c23d705317508e03d1b7c" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" "checksum rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1601f32bc5858aae3cbfa1c645c96c4d820cc5c16be0194f089560c00b6eb625" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" @@ -4817,9 +4840,9 @@ dependencies = [ "checksum transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e5866e5126b14358f1d7af4bf51a0be677a363799b90e655edcec8254edef1d2" "checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e" "checksum trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)" = "" -"checksum trie-db 0.11.0 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum trie-standardmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e26f52976a57a0859616d6fcec87092ac35d08eabbd78dc3dabee93b480ea5f" -"checksum triehash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d26efb4ddf87870fc08dc9a6580dc3061be350d7b9d0eb30aef1c8b4227aa46" +"checksum triehash 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92148b4d8d55eff71bc8c9e3c5f714e266c2a05e724dce5405a10deabbf449a8" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" diff --git a/Cargo.toml b/Cargo.toml index 393571b1106..ba4a1d49d90 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ ethcore-secretstore = { path = "secret-store", optional = true } registrar = { path = "util/registrar" } -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize", features = ["jemalloc-global", "estimate-heapsize"] } +parity-util-mem = { version = "0.1", features = ["jemalloc-global", "estimate-heapsize"] } [build-dependencies] rustc_version = "0.2" diff --git a/accounts/ethkey/Cargo.toml b/accounts/ethkey/Cargo.toml index 78f66d526a1..3ae67cb0681 100644 --- a/accounts/ethkey/Cargo.toml +++ b/accounts/ethkey/Cargo.toml @@ -11,7 +11,7 @@ eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" } ethereum-types = "0.4" lazy_static = "1.0" log = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" parity-wordlist = "1.2" quick-error = "1.2.2" rand = "0.4" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 8eea6b7ed86..bfc168e7554 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -30,8 +30,8 @@ ethereum-types = "0.4" ethjson = { path = "../json" } ethkey = { path = "../accounts/ethkey" } evm = { path = "evm" } -hash-db = "0.11.0" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +hash-db = "0.12.2" +parity-util-mem = "0.1" itertools = "0.5" journaldb = { path = "../util/journaldb" } keccak-hash = "0.1" @@ -45,7 +45,7 @@ log = "0.4" lru-cache = "0.1" macros = { path = "../util/macros" } memory-cache = { path = "../util/memory-cache" } -memory-db = "0.11.0" +memory-db = "0.12.3" num = { version = "0.1", default-features = false, features = ["bigint"] } num_cpus = "1.2" parity-bytes = "0.1" @@ -53,7 +53,7 @@ parity-crypto = "0.3.0" parity-machine = { path = "../machine" } parity-snappy = "0.1" parking_lot = "0.7" -trie-db = "0.11.0" +trie-db = "0.12.2" patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" } rand = "0.4" rayon = "1.0" diff --git a/ethcore/blockchain/Cargo.toml b/ethcore/blockchain/Cargo.toml index d7e04b74ba8..11adbcdac0e 100644 --- a/ethcore/blockchain/Cargo.toml +++ b/ethcore/blockchain/Cargo.toml @@ -13,7 +13,7 @@ blooms-db = { path = "../../util/blooms-db" } common-types = { path = "../types" } ethcore-db = { path = "../db" } ethereum-types = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" itertools = "0.5" kvdb = "0.1" log = "0.4" diff --git a/ethcore/db/Cargo.toml b/ethcore/db/Cargo.toml index d694520f45c..b9cc8fe7e38 100644 --- a/ethcore/db/Cargo.toml +++ b/ethcore/db/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" common-types = { path = "../types" } ethereum-types = "0.4" kvdb = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" parking_lot = "0.7" rlp = { version = "0.3.0", features = ["ethereum"] } rlp_derive = { path = "../../util/rlp-derive" } diff --git a/ethcore/evm/Cargo.toml b/ethcore/evm/Cargo.toml index 1f971707ea1..c779c98d880 100644 --- a/ethcore/evm/Cargo.toml +++ b/ethcore/evm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] bit-set = "0.4" parity-bytes = "0.1" ethereum-types = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" lazy_static = "1.0" log = "0.4" vm = { path = "../vm" } diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 22aa2d32923..4bc1a8892d1 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -14,13 +14,13 @@ ethcore = { path = ".."} ethcore-db = { path = "../db" } ethcore-blockchain = { path = "../blockchain" } ethereum-types = "0.4" -memory-db = "0.11.0" -trie-db = "0.11.0" +memory-db = "0.12.3" +trie-db = "0.12.2" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-io = { path = "../../util/io" } -hash-db = "0.11.0" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +hash-db = "0.12.2" +parity-util-mem = "0.1" vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } failsafe = { version = "0.3.0", default-features = false, features = ["parking_lot_mutex"] } diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 8ab8c47f46a..7591cf2888b 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -20,13 +20,13 @@ ethjson = { path = "../../json" } ethkey = { path = "../../accounts/ethkey" } fetch = { path = "../../util/fetch" } futures = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" keccak-hash = "0.1.2" log = "0.4" parity-bytes = "0.1" parity-crypto = "0.3.0" parking_lot = "0.7" -trie-db = "0.11.0" +trie-db = "0.12.2" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } rand = "0.3" rlp = { version = "0.3.0", features = ["ethereum"] } diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index b606df32a6c..8771fd0076f 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -19,7 +19,7 @@ ethereum-types = "0.4" ethkey = { path = "../../accounts/ethkey" } ethstore = { path = "../../accounts/ethstore" } fastmap = { path = "../../util/fastmap" } -hash-db = "0.11.0" +hash-db = "0.12.2" heapsize = "0.4" keccak-hash = "0.1" keccak-hasher = { path = "../../util/keccak-hasher" } @@ -29,7 +29,7 @@ macros = { path = "../../util/macros" } parity-bytes = "0.1" parking_lot = "0.7" rand = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" rlp = { version = "0.3.0", features = ["ethereum"] } trace-time = "0.1" triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" } diff --git a/ethcore/types/Cargo.toml b/ethcore/types/Cargo.toml index ff1e5724afb..d2ec86e4716 100644 --- a/ethcore/types/Cargo.toml +++ b/ethcore/types/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] [dependencies] ethereum-types = "0.4" ethjson = { path = "../../json" } -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" ethkey = { path = "../../accounts/ethkey" } keccak-hash = "0.1" parity-bytes = "0.1" diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index 19b84a6ecc2..bf0f275b536 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] byteorder = "1.0" parity-bytes = "0.1" ethereum-types = "0.4" -trie-db = "0.11.0" +trie-db = "0.12.2" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } log = "0.4" ethjson = { path = "../../json" } diff --git a/miner/Cargo.toml b/miner/Cargo.toml index af4b664af4e..b4f51c08fc4 100644 --- a/miner/Cargo.toml +++ b/miner/Cargo.toml @@ -23,7 +23,7 @@ ethabi-contract = "6.0" ethcore-call-contract = { path = "../ethcore/call-contract" } ethereum-types = "0.4" futures = "0.1" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" keccak-hash = "0.1" linked-hash-map = "0.5" log = "0.4" diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index c6c59dc15a4..dc9df9ba287 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -59,7 +59,7 @@ keccak-hash = "0.1.2" parity-runtime = { path = "../util/runtime" } parity-updater = { path = "../updater" } parity-version = { path = "../util/version" } -trie-db = "0.11.0" +trie-db = "0.12.2" rlp = { version = "0.3.0", features = ["ethereum"] } stats = { path = "../util/stats" } vm = { path = "../ethcore/vm" } diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index d0b25cf0a45..a1be5359f37 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -8,12 +8,12 @@ license = "GPL3" [dependencies] parity-bytes = "0.1" ethereum-types = "0.4" -hash-db = "0.11.0" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +hash-db = "0.12.2" +parity-util-mem = "0.1" keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" -memory-db = "0.11.0" +memory-db = "0.12.3" parking_lot = "0.7" fastmap = { path = "../../util/fastmap" } rlp = { version = "0.3.0", features = ["ethereum"] } diff --git a/util/keccak-hasher/Cargo.toml b/util/keccak-hasher/Cargo.toml index edeecda8331..bc26a78d053 100644 --- a/util/keccak-hasher/Cargo.toml +++ b/util/keccak-hasher/Cargo.toml @@ -8,5 +8,5 @@ license = "GPL-3.0" [dependencies] ethereum-types = "0.4" tiny-keccak = "1.4.2" -hash-db = "0.11.0" +hash-db = "0.12.2" plain_hasher = "0.2" diff --git a/util/memory-cache/Cargo.toml b/util/memory-cache/Cargo.toml index ad9e5bbb68a..ceb49c4dc44 100644 --- a/util/memory-cache/Cargo.toml +++ b/util/memory-cache/Cargo.toml @@ -6,5 +6,5 @@ description = "An LRU-cache which operates on memory used" license = "GPL3" [dependencies] -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" lru-cache = "0.1" diff --git a/util/patricia-trie-ethereum/Cargo.toml b/util/patricia-trie-ethereum/Cargo.toml index 8cb8664a5ed..e77d384d53f 100644 --- a/util/patricia-trie-ethereum/Cargo.toml +++ b/util/patricia-trie-ethereum/Cargo.toml @@ -6,15 +6,15 @@ description = "Merkle-Patricia Trie (Ethereum Style)" license = "GPL-3.0" [dependencies] -trie-db = "0.11.0" +trie-db = "0.12.2" keccak-hasher = { version = "0.1.1", path = "../keccak-hasher" } -hash-db = "0.11.0" +hash-db = "0.12.2" rlp = "0.3.0" parity-bytes = "0.1" ethereum-types = "0.4" elastic-array = "0.10" [dev-dependencies] -memory-db = "0.11.0" +memory-db = "0.12.3" keccak-hash = "0.1.2" journaldb = { path = "../journaldb" } diff --git a/util/triehash-ethereum/Cargo.toml b/util/triehash-ethereum/Cargo.toml index 5b636429753..ceab1288cf3 100644 --- a/util/triehash-ethereum/Cargo.toml +++ b/util/triehash-ethereum/Cargo.toml @@ -6,6 +6,6 @@ description = "Trie-root helpers, ethereum style" license = "GPL-3.0" [dependencies] -triehash = { version = "0.4.0", features = ["ethereum"] } +triehash = { version = "0.5.0" } ethereum-types = "0.4" keccak-hasher = { path = "../keccak-hasher" } diff --git a/whisper/Cargo.toml b/whisper/Cargo.toml index fed5c71746e..6bc2cbd2f0d 100644 --- a/whisper/Cargo.toml +++ b/whisper/Cargo.toml @@ -13,7 +13,7 @@ parity-crypto = "0.3.0" ethkey = { path = "../accounts/ethkey" } hex = "0.2" log = "0.4" -parity-util-mem = { git = "https://github.com/cheme/parity-common", branch = "deprecate_heapsize" } +parity-util-mem = "0.1" ordered-float = "0.5" parking_lot = "0.7" rand = "0.4" From a5718782bdc9b706f47775b40fc710efb8b03e8d Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 6 Jun 2019 11:24:59 +0200 Subject: [PATCH 15/22] in progress (need merge with memorydb update) --- Cargo.lock | 24 +++++++++--------------- Cargo.toml | 1 + util/journaldb/src/archivedb.rs | 5 ++--- util/journaldb/src/earlymergedb.rs | 5 ++--- util/journaldb/src/lib.rs | 12 ++++++++++-- util/journaldb/src/overlaydb.rs | 3 +-- util/journaldb/src/overlayrecentdb.rs | 7 +++---- util/journaldb/src/refcounteddb.rs | 3 +-- util/journaldb/src/traits.rs | 2 +- util/triehash-ethereum/Cargo.toml | 2 +- 10 files changed, 31 insertions(+), 33 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9c17230e7f3..ecbcb5ae9d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1550,11 +1550,6 @@ dependencies = [ "trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)", ] -[[package]] -name = "hash-db" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "hash-db" version = "0.12.2" @@ -3400,8 +3395,8 @@ dependencies = [ [[package]] name = "rlp" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.4.1" +source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize2#357eb06b4b20794a8a21189bcae7d0af65a18094" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4144,11 +4139,11 @@ dependencies = [ [[package]] name = "triehash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +version = "0.5.1" +source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize2#357eb06b4b20794a8a21189bcae7d0af65a18094" dependencies = [ - "hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "rlp 0.4.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)", ] [[package]] @@ -4157,7 +4152,7 @@ version = "0.2.0" dependencies = [ "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "triehash 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "triehash 0.5.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)", ] [[package]] @@ -4606,7 +4601,6 @@ dependencies = [ "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" -"checksum hash-db 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1b03501f6e1a2a97f1618879aba3156f14ca2847faa530c4e28859638bd11483" "checksum hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" @@ -4760,7 +4754,7 @@ dependencies = [ "checksum ring 0.14.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be5386a5f59e5f5bcaea38b50ad26c09e3918a0abc0610640b3be5cfd85d6894" "checksum rlp 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "524c5ad554859785dfc8469df3ed5e0b5784d4d335877ed47c8d90fc0eb238fe" "checksum rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "16d1effe9845d54f90e7be8420ee49e5c94623140b97ee4bc6fb5bfddb745720" -"checksum rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b0d56c1450bfbef1181fdeb78b902dc1d23178de77c23d705317508e03d1b7c" +"checksum rlp 0.4.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)" = "" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" "checksum rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1601f32bc5858aae3cbfa1c645c96c4d820cc5c16be0194f089560c00b6eb625" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" @@ -4842,7 +4836,7 @@ dependencies = [ "checksum trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)" = "" "checksum trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum trie-standardmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e26f52976a57a0859616d6fcec87092ac35d08eabbd78dc3dabee93b480ea5f" -"checksum triehash 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "92148b4d8d55eff71bc8c9e3c5f714e266c2a05e724dce5405a10deabbf449a8" +"checksum triehash 0.5.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)" = "" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" diff --git a/Cargo.toml b/Cargo.toml index ba4a1d49d90..cb160a04ba9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -147,3 +147,4 @@ members = [ memory-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } trie-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } hash-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } +triehash = { git = "https://github.com/cheme/parity-common", branch = "rem_heapsize2" } diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index 09f08da190c..67559c83213 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -29,7 +29,6 @@ use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use rlp::{encode, decode}; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, error_key_already_exists, error_negatively_reference_hash}; -use super::memory_db::*; use traits::JournalDB; /// Implementation of the `HashDB` trait for a disk-backed database with a memory overlay @@ -40,7 +39,7 @@ use traits::JournalDB; /// immediately. As this is an "archive" database, nothing is ever removed. This means /// that the states of any block the node has ever processed will be accessible. pub struct ArchiveDB { - overlay: MemoryDB, + overlay: super::MemoryDB, backing: Arc, latest_era: Option, column: Option, @@ -198,7 +197,7 @@ impl JournalDB for ArchiveDB { &self.backing } - fn consolidate(&mut self, with: MemoryDB) { + fn consolidate(&mut self, with: super::MemoryDB) { self.overlay.consolidate(with); } } diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index 52c59d2ad78..b3db9e579b4 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -27,7 +27,6 @@ use hash_db::HashDB; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; -use memory_db::*; use parking_lot::RwLock; use rlp::{encode, decode}; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY, error_negatively_reference_hash, error_key_already_exists}; @@ -103,7 +102,7 @@ enum RemoveFrom { /// /// TODO: `store_reclaim_period` pub struct EarlyMergeDB { - overlay: MemoryDB, + overlay: super::MemoryDB, backing: Arc, refs: Option>>>, latest_era: Option, @@ -514,7 +513,7 @@ impl JournalDB for EarlyMergeDB { Ok(ops) } - fn consolidate(&mut self, with: MemoryDB) { + fn consolidate(&mut self, with: super::MemoryDB) { self.overlay.consolidate(with); } } diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index 6160655193d..f8ee35b0d03 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -60,6 +60,14 @@ pub use self::traits::KeyedHashDB; /// Export as keyed hash trait pub use self::traits::AsKeyedHashDB; + +/// Alias to ethereum MemoryDB +type MemoryDB = memory_db::MemoryDB< + keccak_hasher::KeccakHasher, + memory_db::HashKey, + kvdb::DBValue, +>; + /// Journal database operating strategy. #[derive(Debug, PartialEq, Clone, Copy)] pub enum Algorithm { @@ -164,8 +172,8 @@ fn error_negatively_reference_hash(hash: ðereum_types::H256) -> io::Error { io::Error::new(io::ErrorKind::Other, format!("Entry {} removed from database more times than it was added.", hash)) } -pub fn new_memory_db() -> memory_db::MemoryDB { - memory_db::MemoryDB::from_null_node(&rlp::NULL_RLP, rlp::NULL_RLP.as_ref().into()) +pub fn new_memory_db() -> MemoryDB { + MemoryDB::from_null_node(&rlp::NULL_RLP, rlp::NULL_RLP.as_ref().into()) } #[cfg(test)] diff --git a/util/journaldb/src/overlaydb.rs b/util/journaldb/src/overlaydb.rs index 757a92e6219..368af2656f3 100644 --- a/util/journaldb/src/overlaydb.rs +++ b/util/journaldb/src/overlaydb.rs @@ -25,7 +25,6 @@ use ethereum_types::H256; use rlp::{Rlp, RlpStream, Encodable, DecoderError, Decodable, encode, decode}; use hash_db::{HashDB}; use keccak_hasher::KeccakHasher; -use memory_db::*; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use super::{error_negatively_reference_hash}; @@ -39,7 +38,7 @@ use super::{error_negatively_reference_hash}; /// queries have an immediate effect in terms of these functions. #[derive(Clone)] pub struct OverlayDB { - overlay: MemoryDB, + overlay: super::MemoryDB, backing: Arc, column: Option, } diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 358fc1ef3e8..78cfe80b235 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -27,7 +27,6 @@ use hash_db::HashDB; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; -use memory_db::*; use parking_lot::RwLock; use fastmap::H256FastMap; use rlp::{Rlp, RlpStream, encode, decode, DecoderError, Decodable, Encodable}; @@ -66,7 +65,7 @@ use util::DatabaseKey; /// 7. Delete ancient record from memory and disk. pub struct OverlayRecentDB { - transaction_overlay: MemoryDB, + transaction_overlay: super::MemoryDB, backing: Arc, journal_overlay: Arc>, column: Option, @@ -120,7 +119,7 @@ impl<'a> Encodable for DatabaseValueRef<'a> { #[derive(PartialEq)] struct JournalOverlay { - backing_overlay: MemoryDB, // Nodes added in the history period + backing_overlay: super::MemoryDB, // Nodes added in the history period pending_overlay: H256FastMap, // Nodes being transfered from backing_overlay to backing db journal: HashMap>, latest_era: Option, @@ -451,7 +450,7 @@ impl JournalDB for OverlayRecentDB { Ok(ops) } - fn consolidate(&mut self, with: MemoryDB) { + fn consolidate(&mut self, with: super::MemoryDB) { self.transaction_overlay.consolidate(with); } } diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 39797e421aa..98791ce9a35 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -26,7 +26,6 @@ use hash_db::HashDB; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; -use memory_db::MemoryDB; use overlaydb::OverlayDB; use rlp::{encode, decode}; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY}; @@ -203,7 +202,7 @@ impl JournalDB for RefCountedDB { self.forward.commit_to_batch(batch) } - fn consolidate(&mut self, mut with: MemoryDB) { + fn consolidate(&mut self, mut with: super::MemoryDB) { for (key, (value, rc)) in with.drain() { for _ in 0..rc { self.emplace(key, value.clone()); diff --git a/util/journaldb/src/traits.rs b/util/journaldb/src/traits.rs index e6ce8acb040..470598a02db 100644 --- a/util/journaldb/src/traits.rs +++ b/util/journaldb/src/traits.rs @@ -93,7 +93,7 @@ pub trait JournalDB: KeyedHashDB { fn flush(&self) {} /// Consolidate all the insertions and deletions in the given memory overlay. - fn consolidate(&mut self, overlay: ::memory_db::MemoryDB); + fn consolidate(&mut self, overlay: super::MemoryDB); /// Commit all changes in a single batch #[cfg(test)] diff --git a/util/triehash-ethereum/Cargo.toml b/util/triehash-ethereum/Cargo.toml index ceab1288cf3..9f5ac82b363 100644 --- a/util/triehash-ethereum/Cargo.toml +++ b/util/triehash-ethereum/Cargo.toml @@ -6,6 +6,6 @@ description = "Trie-root helpers, ethereum style" license = "GPL-3.0" [dependencies] -triehash = { version = "0.5.0" } +triehash = { version = "0.5.1" } ethereum-types = "0.4" keccak-hasher = { path = "../keccak-hasher" } From d44a8f9657b747d21e55dbc32f8ae0661ccfbf3b Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 6 Jun 2019 19:06:17 +0200 Subject: [PATCH 16/22] Branch ready to rebase (synch with latest trie changes done). --- Cargo.lock | 46 ++-- ethcore/light/src/cht.rs | 5 +- ethcore/light/src/on_demand/request.rs | 2 +- ethcore/src/account_db.rs | 70 +++--- ethcore/src/block.rs | 7 +- ethcore/src/client/client.rs | 4 +- ethcore/src/pod_account.rs | 2 +- ethcore/src/snapshot/account.rs | 10 +- ethcore/src/snapshot/mod.rs | 6 +- ethcore/src/snapshot/tests/state.rs | 8 +- ethcore/src/spec/spec.rs | 2 +- ethcore/src/state/account.rs | 6 +- ethcore/src/state/backend.rs | 52 ++--- ethcore/src/state/mod.rs | 2 +- util/journaldb/src/archivedb.rs | 172 +++++++------- util/journaldb/src/earlymergedb.rs | 278 +++++++++++------------ util/journaldb/src/overlaydb.rs | 120 +++++----- util/journaldb/src/overlayrecentdb.rs | 298 ++++++++++++------------- util/journaldb/src/refcounteddb.rs | 118 +++++----- 19 files changed, 606 insertions(+), 602 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecbcb5ae9d9..cbe167ee47e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -727,7 +727,7 @@ dependencies = [ "ethkey 0.3.0", "evm 0.1.0", "fetch 0.1.0", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -763,7 +763,7 @@ dependencies = [ "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "trie-standardmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "unexpected 0.1.0", @@ -879,7 +879,7 @@ dependencies = [ "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -901,7 +901,7 @@ dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "triehash-ethereum 0.2.0", "vm 0.1.0", ] @@ -1045,7 +1045,7 @@ dependencies = [ "serde_json 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1140,7 +1140,7 @@ dependencies = [ "ethkey 0.3.0", "ethstore 0.2.1", "fastmap 0.1.0", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", @@ -1552,8 +1552,8 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.12.2" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" +version = "0.12.3" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" [[package]] name = "hashmap_core" @@ -1824,7 +1824,7 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1952,7 +1952,7 @@ name = "keccak-hasher" version = "0.1.1" dependencies = [ "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2170,9 +2170,9 @@ dependencies = [ [[package]] name = "memory-db" version = "0.12.3" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" dependencies = [ - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2357,7 +2357,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2713,7 +2713,7 @@ dependencies = [ "tokio-timer 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)", "transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "vm 0.1.0", ] @@ -2945,14 +2945,14 @@ version = "0.1.0" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "journaldb 0.2.0", "keccak-hash 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", ] [[package]] @@ -4116,11 +4116,11 @@ dependencies = [ [[package]] name = "trie-db" -version = "0.12.2" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#6c01e71932bec7c24c7c117930066fe6716c17d8" +version = "0.12.3" +source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4142,7 +4142,7 @@ name = "triehash" version = "0.5.1" source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize2#357eb06b4b20794a8a21189bcae7d0af65a18094" dependencies = [ - "hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", "rlp 0.4.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)", ] @@ -4330,7 +4330,7 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", ] [[package]] @@ -4601,7 +4601,7 @@ dependencies = [ "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" -"checksum hash-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" @@ -4834,7 +4834,7 @@ dependencies = [ "checksum transaction-pool 1.13.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e5866e5126b14358f1d7af4bf51a0be677a363799b90e655edcec8254edef1d2" "checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e" "checksum trezor-sys 1.0.0 (git+https://github.com/paritytech/trezor-sys)" = "" -"checksum trie-db 0.12.2 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" "checksum trie-standardmap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e26f52976a57a0859616d6fcec87092ac35d08eabbd78dc3dabee93b480ea5f" "checksum triehash 0.5.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)" = "" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" diff --git a/ethcore/light/src/cht.rs b/ethcore/light/src/cht.rs index a9bc5d7f260..ffbf1faa580 100644 --- a/ethcore/light/src/cht.rs +++ b/ethcore/light/src/cht.rs @@ -95,7 +95,8 @@ pub struct BlockInfo { /// Build an in-memory CHT from a closure which provides necessary information /// about blocks. If the fetcher ever fails to provide the info, the CHT /// will not be generated. -pub fn build(cht_num: u64, mut fetcher: F) -> Option>> +pub fn build(cht_num: u64, mut fetcher: F) + -> Option, DBValue>>> where F: FnMut(BlockId) -> Option { let mut db = new_memory_db(); @@ -154,7 +155,7 @@ pub fn compute_root(cht_num: u64, iterable: I) -> Option pub fn check_proof(proof: &[Bytes], num: u64, root: H256) -> Option<(H256, U256)> { let mut db = new_memory_db(); - for node in proof { db.insert(&node[..]); } + for node in proof { db.insert(hash_db::EMPTY_PREFIX, &node[..]); } let res = match TrieDB::new(&db, &root) { Err(_) => return None, Ok(trie) => trie.get_with(&key!(num), |val: &[u8]| { diff --git a/ethcore/light/src/on_demand/request.rs b/ethcore/light/src/on_demand/request.rs index a183dcbcabc..c39bbd4593c 100644 --- a/ethcore/light/src/on_demand/request.rs +++ b/ethcore/light/src/on_demand/request.rs @@ -981,7 +981,7 @@ impl Account { let state_root = header.state_root(); let mut db = journaldb::new_memory_db(); - for node in proof { db.insert(&node[..]); } + for node in proof { db.insert(hash_db::EMPTY_PREFIX, &node[..]); } match TrieDB::new(&db, &state_root).and_then(|t| t.get(&keccak(&self.address)))? { Some(val) => { diff --git a/ethcore/src/account_db.rs b/ethcore/src/account_db.rs index a389c009bf7..c2df574cd1d 100644 --- a/ethcore/src/account_db.rs +++ b/ethcore/src/account_db.rs @@ -17,7 +17,7 @@ //! DB backend wrapper for Account trie use ethereum_types::H256; use hash::{KECCAK_NULL_RLP, keccak}; -use hash_db::{HashDB, AsHashDB}; +use hash_db::{HashDB, AsHashDB, Prefix}; use keccak_hasher::KeccakHasher; use kvdb::DBValue; use rlp::NULL_RLP; @@ -103,29 +103,29 @@ impl<'db> AsHashDB for AccountDB<'db> { } impl<'db> HashDB for AccountDB<'db> { - fn get(&self, key: &H256) -> Option { + fn get(&self, key: &H256, prefix: Prefix) -> Option { if key == &KECCAK_NULL_RLP { return Some(DBValue::from_slice(&NULL_RLP)); } - self.db.get(&combine_key(&self.address_hash, key)) + self.db.get(&combine_key(&self.address_hash, key), prefix) } - fn contains(&self, key: &H256) -> bool { + fn contains(&self, key: &H256, prefix: Prefix) -> bool { if key == &KECCAK_NULL_RLP { return true; } - self.db.contains(&combine_key(&self.address_hash, key)) + self.db.contains(&combine_key(&self.address_hash, key), prefix) } - fn insert(&mut self, _value: &[u8]) -> H256 { + fn insert(&mut self, _prefix: Prefix, _value: &[u8]) -> H256 { unimplemented!() } - fn emplace(&mut self, _key: H256, _value: DBValue) { + fn emplace(&mut self, _key: H256, _prefix: Prefix, _value: DBValue) { unimplemented!() } - fn remove(&mut self, _key: &H256) { + fn remove(&mut self, _key: &H256, _prefix: Prefix) { unimplemented!() } } @@ -158,44 +158,44 @@ impl<'db> AccountDBMut<'db> { } impl<'db> HashDB for AccountDBMut<'db>{ - fn get(&self, key: &H256) -> Option { + fn get(&self, key: &H256, prefix: Prefix) -> Option { if key == &KECCAK_NULL_RLP { return Some(DBValue::from_slice(&NULL_RLP)); } - self.db.get(&combine_key(&self.address_hash, key)) + self.db.get(&combine_key(&self.address_hash, key), prefix) } - fn contains(&self, key: &H256) -> bool { + fn contains(&self, key: &H256, prefix: Prefix) -> bool { if key == &KECCAK_NULL_RLP { return true; } - self.db.contains(&combine_key(&self.address_hash, key)) + self.db.contains(&combine_key(&self.address_hash, key), prefix) } - fn insert(&mut self, value: &[u8]) -> H256 { + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { if value == &NULL_RLP { return KECCAK_NULL_RLP.clone(); } let k = keccak(value); let ak = combine_key(&self.address_hash, &k); - self.db.emplace(ak, DBValue::from_slice(value)); + self.db.emplace(ak, prefix, DBValue::from_slice(value)); k } - fn emplace(&mut self, key: H256, value: DBValue) { + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { if key == KECCAK_NULL_RLP { return; } let key = combine_key(&self.address_hash, &key); - self.db.emplace(key, value) + self.db.emplace(key, prefix, value) } - fn remove(&mut self, key: &H256) { + fn remove(&mut self, key: &H256, prefix: Prefix) { if key == &KECCAK_NULL_RLP { return; } let key = combine_key(&self.address_hash, key); - self.db.remove(&key) + self.db.remove(&key, prefix) } } @@ -212,29 +212,29 @@ impl<'db> AsHashDB for Wrapping<'db> { } impl<'db> HashDB for Wrapping<'db> { - fn get(&self, key: &H256) -> Option { + fn get(&self, key: &H256, prefix: Prefix) -> Option { if key == &KECCAK_NULL_RLP { return Some(DBValue::from_slice(&NULL_RLP)); } - self.0.get(key) + self.0.get(key, prefix) } - fn contains(&self, key: &H256) -> bool { + fn contains(&self, key: &H256, prefix: Prefix) -> bool { if key == &KECCAK_NULL_RLP { return true; } - self.0.contains(key) + self.0.contains(key, prefix) } - fn insert(&mut self, _value: &[u8]) -> H256 { + fn insert(&mut self, _prefix: Prefix, _value: &[u8]) -> H256 { unimplemented!() } - fn emplace(&mut self, _key: H256, _value: DBValue) { + fn emplace(&mut self, _key: H256, _prefix: Prefix, _value: DBValue) { unimplemented!() } - fn remove(&mut self, _key: &H256) { + fn remove(&mut self, _key: &H256, _prefix: Prefix) { unimplemented!() } } @@ -246,38 +246,38 @@ impl<'db> AsHashDB for WrappingMut<'db> { } impl<'db> HashDB for WrappingMut<'db>{ - fn get(&self, key: &H256) -> Option { + fn get(&self, key: &H256, prefix: Prefix) -> Option { if key == &KECCAK_NULL_RLP { return Some(DBValue::from_slice(&NULL_RLP)); } - self.0.get(key) + self.0.get(key, prefix) } - fn contains(&self, key: &H256) -> bool { + fn contains(&self, key: &H256, prefix: Prefix) -> bool { if key == &KECCAK_NULL_RLP { return true; } - self.0.contains(key) + self.0.contains(key, prefix) } - fn insert(&mut self, value: &[u8]) -> H256 { + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { if value == &NULL_RLP { return KECCAK_NULL_RLP.clone(); } - self.0.insert(value) + self.0.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { if key == KECCAK_NULL_RLP { return; } - self.0.emplace(key, value) + self.0.emplace(key, prefix, value) } - fn remove(&mut self, key: &H256) { + fn remove(&mut self, key: &H256, prefix: Prefix) { if key == &KECCAK_NULL_RLP { return; } - self.0.remove(key) + self.0.remove(key, prefix) } } diff --git a/ethcore/src/block.rs b/ethcore/src/block.rs index e5fcb451617..008195433b2 100644 --- a/ethcore/src/block.rs +++ b/ethcore/src/block.rs @@ -604,6 +604,7 @@ mod tests { use types::header::Header; use types::view; use types::views::BlockView; + use hash_db::EMPTY_PREFIX; /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header fn enact_bytes( @@ -705,7 +706,8 @@ mod tests { let db = e.drain().state.drop().1; assert_eq!(orig_db.journal_db().keys(), db.journal_db().keys()); - assert!(orig_db.journal_db().keys().iter().filter(|k| orig_db.journal_db().get(k.0) != db.journal_db().get(k.0)).next() == None); + assert!(orig_db.journal_db().keys().iter().filter(|k| orig_db.journal_db().get(k.0, EMPTY_PREFIX) + != db.journal_db().get(k.0, EMPTY_PREFIX)).next() == None); } #[test] @@ -739,6 +741,7 @@ mod tests { let db = e.drain().state.drop().1; assert_eq!(orig_db.journal_db().keys(), db.journal_db().keys()); - assert!(orig_db.journal_db().keys().iter().filter(|k| orig_db.journal_db().get(k.0) != db.journal_db().get(k.0)).next() == None); + assert!(orig_db.journal_db().keys().iter().filter(|k| orig_db.journal_db().get(k.0, EMPTY_PREFIX) + != db.journal_db().get(k.0, EMPTY_PREFIX)).next() == None); } } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index d40fc30330a..6f323f9272a 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -44,7 +44,7 @@ use types::log_entry::LocalizedLogEntry; use types::receipt::{Receipt, LocalizedReceipt}; use types::{BlockNumber, header::{Header, ExtendedHeader}}; use vm::{EnvInfo, LastHashes}; - +use hash_db::EMPTY_PREFIX; use block::{IsBlock, LockedBlock, Drain, ClosedBlock, OpenBlock, enact_verified, SealedBlock}; use client::ancient_import::AncientVerifier; use client::{ @@ -751,7 +751,7 @@ impl Client { config.history }; - if !chain.block_header_data(&chain.best_block_hash()).map_or(true, |h| state_db.journal_db().contains(&h.state_root())) { + if !chain.block_header_data(&chain.best_block_hash()).map_or(true, |h| state_db.journal_db().contains(&h.state_root(), EMPTY_PREFIX)) { warn!("State root not found for block #{} ({:x})", chain.best_block_number(), chain.best_block_hash()); } diff --git a/ethcore/src/pod_account.rs b/ethcore/src/pod_account.rs index 39dce6e36da..ef028f818d9 100644 --- a/ethcore/src/pod_account.rs +++ b/ethcore/src/pod_account.rs @@ -81,7 +81,7 @@ impl PodAccount { /// Place additional data into given hash DB. pub fn insert_additional(&self, db: &mut HashDB, factory: &TrieFactory) { match self.code { - Some(ref c) if !c.is_empty() => { db.insert(c); } + Some(ref c) if !c.is_empty() => { db.insert(hash_db::EMPTY_PREFIX, c); } _ => {} } let mut r = H256::new(); diff --git a/ethcore/src/snapshot/account.rs b/ethcore/src/snapshot/account.rs index ed56e2435b8..01fbbbff8eb 100644 --- a/ethcore/src/snapshot/account.rs +++ b/ethcore/src/snapshot/account.rs @@ -86,7 +86,7 @@ pub fn to_fat_rlps(account_hash: &H256, acc: &BasicAccount, acct_db: &AccountDB, } else if used_code.contains(&acc.code_hash) { account_stream.append(&CodeState::Hash.raw()).append(&acc.code_hash); } else { - match acct_db.get(&acc.code_hash) { + match acct_db.get(&acc.code_hash, hash_db::EMPTY_PREFIX) { Some(c) => { used_code.insert(acc.code_hash.clone()); account_stream.append(&CodeState::Inline.raw()).append(&&*c); @@ -169,7 +169,7 @@ pub fn from_fat_rlp( CodeState::Empty => (KECCAK_EMPTY, None), CodeState::Inline => { let code: Bytes = rlp.val_at(3)?; - let code_hash = acct_db.insert(&code); + let code_hash = acct_db.insert(hash_db::EMPTY_PREFIX, &code); (code_hash, Some(code)) } @@ -214,7 +214,7 @@ mod tests { use hash::{KECCAK_EMPTY, KECCAK_NULL_RLP, keccak}; use ethereum_types::{H256, Address}; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use kvdb::DBValue; use rlp::Rlp; @@ -307,12 +307,12 @@ mod tests { let code_hash = { let mut acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr1); - acct_db.insert(b"this is definitely code") + acct_db.insert(EMPTY_PREFIX, b"this is definitely code") }; { let mut acct_db = AccountDBMut::new(db.as_hash_db_mut(), &addr2); - acct_db.emplace(code_hash.clone(), DBValue::from_slice(b"this is definitely code")); + acct_db.emplace(code_hash.clone(), EMPTY_PREFIX, DBValue::from_slice(b"this is definitely code")); } let account1 = BasicAccount { diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index c05d0de6a3a..33f859c3d57 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -430,7 +430,7 @@ impl StateRebuilder { for (code_hash, code, first_with) in status.new_code { for addr_hash in self.missing_code.remove(&code_hash).unwrap_or_else(Vec::new) { let mut db = AccountDBMut::from_hash(self.db.as_hash_db_mut(), addr_hash); - db.emplace(code_hash, DBValue::from_slice(&code)); + db.emplace(code_hash, hash_db::EMPTY_PREFIX, DBValue::from_slice(&code)); } self.known_code.insert(code_hash, first_with); @@ -527,11 +527,11 @@ fn rebuild_accounts( Some(&first_with) => { // if so, load it from the database. let code = AccountDB::from_hash(db, first_with) - .get(&code_hash) + .get(&code_hash, hash_db::EMPTY_PREFIX) .ok_or_else(|| Error::MissingCode(vec![first_with]))?; // and write it again under a different mangled key - AccountDBMut::from_hash(db, hash).emplace(code_hash, code); + AccountDBMut::from_hash(db, hash).emplace(code_hash, hash_db::EMPTY_PREFIX, code); } // if not, queue it up to be filled later None => status.missing_code.push((hash, code_hash)), diff --git a/ethcore/src/snapshot/tests/state.rs b/ethcore/src/snapshot/tests/state.rs index fa7df6b6195..6ead6bef1eb 100644 --- a/ethcore/src/snapshot/tests/state.rs +++ b/ethcore/src/snapshot/tests/state.rs @@ -37,7 +37,7 @@ use tempdir::TempDir; #[test] fn snap_and_restore() { - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; let mut producer = StateProducer::new(); let mut rng = XorShiftRng::from_seed([1, 2, 3, 4]); let mut old_db = journaldb::new_memory_db(); @@ -94,7 +94,7 @@ fn snap_and_restore() { let keys = old_db.keys(); for key in keys.keys() { - assert_eq!(old_db.get(&key).unwrap(), new_db.as_hash_db().get(&key).unwrap()); + assert_eq!(old_db.get(&key, EMPTY_PREFIX).unwrap(), new_db.as_hash_db().get(&key, EMPTY_PREFIX).unwrap()); } } @@ -103,7 +103,7 @@ fn get_code_from_prev_chunk() { use std::collections::HashSet; use rlp::RlpStream; use ethereum_types::{H256, U256}; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use account_db::{AccountDBMut, AccountDB}; @@ -125,7 +125,7 @@ fn get_code_from_prev_chunk() { let mut make_chunk = |acc, hash| { let mut db = journaldb::new_memory_db(); - AccountDBMut::from_hash(&mut db, hash).insert(&code[..]); + AccountDBMut::from_hash(&mut db, hash).insert(EMPTY_PREFIX, &code[..]); let fat_rlp = account::to_fat_rlps(&hash, &acc, &AccountDB::from_hash(&db, hash), &mut used_code, usize::max_value(), usize::max_value()).unwrap(); let mut stream = RlpStream::new_list(1); diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 4bd46b2bb63..d9556e6a16a 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -812,7 +812,7 @@ impl Spec { /// Ensure that the given state DB has the trie nodes in for the genesis state. pub fn ensure_db_good(&self, db: T, factories: &Factories) -> Result { - if db.as_hash_db().contains(&self.state_root()) { + if db.as_hash_db().contains(&self.state_root(), hash_db::EMPTY_PREFIX) { return Ok(db); } diff --git a/ethcore/src/state/account.rs b/ethcore/src/state/account.rs index fea9444b1cc..e9aef5a14ea 100644 --- a/ethcore/src/state/account.rs +++ b/ethcore/src/state/account.rs @@ -364,7 +364,7 @@ impl Account { if self.is_cached() { return Some(self.code_cache.clone()); } - match db.get(&self.code_hash) { + match db.get(&self.code_hash, hash_db::EMPTY_PREFIX) { Some(x) => { self.code_size = Some(x.len()); self.code_cache = Arc::new(x.into_vec()); @@ -393,7 +393,7 @@ impl Account { trace!("Account::cache_code_size: ic={}; self.code_hash={:?}, self.code_cache={}", self.is_cached(), self.code_hash, self.code_cache.pretty()); self.code_size.is_some() || if self.code_hash != KECCAK_EMPTY { - match db.get(&self.code_hash) { + match db.get(&self.code_hash, hash_db::EMPTY_PREFIX) { Some(x) => { self.code_size = Some(x.len()); true @@ -507,7 +507,7 @@ impl Account { self.code_filth = Filth::Clean; }, (true, false) => { - db.emplace(self.code_hash.clone(), DBValue::from_slice(&*self.code_cache)); + db.emplace(self.code_hash.clone(), hash_db::EMPTY_PREFIX, DBValue::from_slice(&*self.code_cache)); self.code_size = Some(self.code_cache.len()); self.code_filth = Filth::Clean; }, diff --git a/ethcore/src/state/backend.rs b/ethcore/src/state/backend.rs index 11e73edb3ab..792dfbba1cf 100644 --- a/ethcore/src/state/backend.rs +++ b/ethcore/src/state/backend.rs @@ -27,8 +27,8 @@ use std::sync::Arc; use state::Account; use parking_lot::Mutex; use ethereum_types::{Address, H256}; -use memory_db::MemoryDB; -use hash_db::{AsHashDB, HashDB}; +use memory_db::{MemoryDB, HashKey}; +use hash_db::{AsHashDB, HashDB, Prefix, EMPTY_PREFIX}; use kvdb::DBValue; use keccak_hasher::KeccakHasher; use journaldb::AsKeyedHashDB; @@ -78,13 +78,13 @@ pub trait Backend: Send { // TODO: when account lookup moved into backends, this won't rely as tenuously on intended // usage. #[derive(Clone, PartialEq)] -pub struct ProofCheck(MemoryDB); +pub struct ProofCheck(MemoryDB, DBValue>); impl ProofCheck { /// Create a new `ProofCheck` backend from the given state items. pub fn new(proof: &[DBValue]) -> Self { let mut db = journaldb::new_memory_db(); - for item in proof { db.insert(item); } + for item in proof { db.insert(EMPTY_PREFIX, item); } ProofCheck(db) } } @@ -94,23 +94,23 @@ impl journaldb::KeyedHashDB for ProofCheck { } impl HashDB for ProofCheck { - fn get(&self, key: &H256) -> Option { - self.0.get(key) + fn get(&self, key: &H256, prefix: Prefix) -> Option { + self.0.get(key, prefix) } - fn contains(&self, key: &H256) -> bool { - self.0.contains(key) + fn contains(&self, key: &H256, prefix: Prefix) -> bool { + self.0.contains(key, prefix) } - fn insert(&mut self, value: &[u8]) -> H256 { - self.0.insert(value) + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { + self.0.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { - self.0.emplace(key, value) + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { + self.0.emplace(key, prefix, value) } - fn remove(&mut self, _key: &H256) { } + fn remove(&mut self, _key: &H256, _prefix: Prefix) { } } impl AsHashDB for ProofCheck { @@ -141,7 +141,7 @@ impl Backend for ProofCheck { /// This doesn't cache anything or rely on the canonical state caches. pub struct Proving { base: H, // state we're proving values from. - changed: MemoryDB, // changed state via insertions. + changed: MemoryDB, DBValue>, // changed state via insertions. proof: Mutex>, } @@ -163,32 +163,32 @@ impl journaldb::KeyedHashDB for Proving { } impl + Send + Sync> HashDB for Proving { - fn get(&self, key: &H256) -> Option { - match self.base.as_hash_db().get(key) { + fn get(&self, key: &H256, prefix: Prefix) -> Option { + match self.base.as_hash_db().get(key, prefix) { Some(val) => { self.proof.lock().insert(val.clone()); Some(val) } - None => self.changed.get(key) + None => self.changed.get(key, prefix) } } - fn contains(&self, key: &H256) -> bool { - self.get(key).is_some() + fn contains(&self, key: &H256, prefix: Prefix) -> bool { + self.get(key, prefix).is_some() } - fn insert(&mut self, value: &[u8]) -> H256 { - self.changed.insert(value) + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { + self.changed.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { - self.changed.emplace(key, value) + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { + self.changed.emplace(key, prefix, value) } - fn remove(&mut self, key: &H256) { + fn remove(&mut self, key: &H256, prefix: Prefix) { // only remove from `changed` - if self.changed.contains(key) { - self.changed.remove(key) + if self.changed.contains(key, prefix) { + self.changed.remove(key, prefix) } } } diff --git a/ethcore/src/state/mod.rs b/ethcore/src/state/mod.rs index c670ed89e3e..1b46fa73e20 100644 --- a/ethcore/src/state/mod.rs +++ b/ethcore/src/state/mod.rs @@ -381,7 +381,7 @@ impl State { /// Creates new state with existing state root pub fn from_existing(db: B, root: H256, account_start_nonce: U256, factories: Factories) -> TrieResult> { - if !db.as_hash_db().contains(&root) { + if !db.as_hash_db().contains(&root, hash_db::EMPTY_PREFIX) { return Err(Box::new(TrieError::InvalidStateRoot(root))); } diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index 67559c83213..fe52d059a0f 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use mem::MallocSizeOfExt; -use hash_db::HashDB; +use hash_db::{HashDB, Prefix}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use rlp::{encode, decode}; @@ -66,8 +66,8 @@ impl ArchiveDB { } impl HashDB for ArchiveDB { - fn get(&self, key: &H256) -> Option { - if let Some((d, rc)) = self.overlay.raw(key) { + fn get(&self, key: &H256, prefix: Prefix) -> Option { + if let Some((d, rc)) = self.overlay.raw(key, prefix) { if rc > 0 { return Some(d.clone()); } @@ -75,20 +75,20 @@ impl HashDB for ArchiveDB { self.payload(key) } - fn contains(&self, key: &H256) -> bool { - self.get(key).is_some() + fn contains(&self, key: &H256, prefix: Prefix) -> bool { + self.get(key, prefix).is_some() } - fn insert(&mut self, value: &[u8]) -> H256 { - self.overlay.insert(value) + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { + self.overlay.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { - self.overlay.emplace(key, value); + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { + self.overlay.emplace(key, prefix, value); } - fn remove(&mut self, key: &H256) { - self.overlay.remove(key); + fn remove(&mut self, key: &H256, prefix: Prefix) { + self.overlay.remove(key, prefix); } } @@ -206,7 +206,7 @@ impl JournalDB for ArchiveDB { mod tests { use keccak::keccak; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use super::*; use {kvdb_memorydb, JournalDB}; @@ -215,50 +215,50 @@ mod tests { // history is 1 let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); jdb.commit_batch(3, &keccak(b"1002a"), Some((1, keccak(b"1")))).unwrap(); jdb.commit_batch(4, &keccak(b"1003a"), Some((2, keccak(b"2")))).unwrap(); - jdb.remove(&x); + jdb.remove(&x, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"1002b"), Some((1, keccak(b"1")))).unwrap(); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(4, &keccak(b"1003b"), Some((2, keccak(b"2")))).unwrap(); jdb.commit_batch(5, &keccak(b"1004a"), Some((3, keccak(b"1002a")))).unwrap(); jdb.commit_batch(6, &keccak(b"1005a"), Some((4, keccak(b"1003a")))).unwrap(); - assert!(jdb.contains(&x)); + assert!(jdb.contains(&x, EMPTY_PREFIX)); } #[test] fn long_history() { // history is 3 let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&h)); - jdb.remove(&h); + assert!(jdb.contains(&h, EMPTY_PREFIX)); + jdb.remove(&h, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"3"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); } #[test] #[should_panic] fn multiple_owed_removal_not_allowed() { let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&h)); - jdb.remove(&h); - jdb.remove(&h); + assert!(jdb.contains(&h, EMPTY_PREFIX)); + jdb.remove(&h, EMPTY_PREFIX); + jdb.remove(&h, EMPTY_PREFIX); // commit_batch would call journal_under(), // and we don't allow multiple owned removals. jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); @@ -269,29 +269,29 @@ mod tests { // history is 1 let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - jdb.remove(&bar); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - let foo = jdb.insert(b"foo"); - jdb.remove(&baz); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.remove(&baz, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); } @@ -301,25 +301,25 @@ mod tests { // history is 1 let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -327,18 +327,18 @@ mod tests { // history is 1 let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); - jdb.insert(b"foo"); - assert!(jdb.contains(&foo)); + jdb.insert(EMPTY_PREFIX, b"foo"); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"2"), Some((0, keccak(b"2")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -347,15 +347,15 @@ mod tests { let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2a"), Some((1, keccak(b"1a")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -366,22 +366,22 @@ mod tests { let foo = { let mut jdb = ArchiveDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - jdb.emplace(bar.clone(), DBValue::from_slice(b"bar")); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.emplace(bar.clone(), EMPTY_PREFIX, DBValue::from_slice(b"bar")); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); foo }; { let mut jdb = ArchiveDB::new(shared_db.clone(), None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); } { let mut jdb = ArchiveDB::new(shared_db, None); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); } } @@ -393,23 +393,23 @@ mod tests { let foo = { let mut jdb = ArchiveDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); // foo is ancient history. - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); foo }; { let mut jdb = ArchiveDB::new(shared_db, None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); - assert!(jdb.contains(&foo)); - jdb.remove(&foo); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); jdb.commit_batch(5, &keccak(b"5"), Some((4, keccak(b"4")))).unwrap(); } @@ -421,14 +421,14 @@ mod tests { let (foo, _, _) = { let mut jdb = ArchiveDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); (foo, bar, baz) }; @@ -436,7 +436,7 @@ mod tests { { let mut jdb = ArchiveDB::new(shared_db, None); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } } @@ -446,7 +446,7 @@ mod tests { let key = { let mut jdb = ArchiveDB::new(shared_db.clone(), None); - let key = jdb.insert(b"foo"); + let key = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); key }; @@ -461,13 +461,13 @@ mod tests { #[test] fn inject() { let mut jdb = ArchiveDB::new(Arc::new(kvdb_memorydb::create(0)), None); - let key = jdb.insert(b"dog"); + let key = jdb.insert(EMPTY_PREFIX, b"dog"); jdb.inject_batch().unwrap(); - assert_eq!(jdb.get(&key).unwrap(), DBValue::from_slice(b"dog")); - jdb.remove(&key); + assert_eq!(jdb.get(&key, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"dog")); + jdb.remove(&key, EMPTY_PREFIX); jdb.inject_batch().unwrap(); - assert!(jdb.get(&key).is_none()); + assert!(jdb.get(&key, EMPTY_PREFIX).is_none()); } } diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index b3db9e579b4..4fce6506bdd 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; -use hash_db::HashDB; +use hash_db::{HashDB, Prefix}; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; @@ -284,8 +284,8 @@ impl EarlyMergeDB { } impl HashDB for EarlyMergeDB { - fn get(&self, key: &H256) -> Option { - if let Some((d, rc)) = self.overlay.raw(key) { + fn get(&self, key: &H256, prefix: Prefix) -> Option { + if let Some((d, rc)) = self.overlay.raw(key, prefix) { if rc > 0 { return Some(d.clone()) } @@ -293,18 +293,18 @@ impl HashDB for EarlyMergeDB { self.payload(key) } - fn contains(&self, key: &H256) -> bool { - self.get(key).is_some() + fn contains(&self, key: &H256, prefix: Prefix) -> bool { + self.get(key, prefix).is_some() } - fn insert(&mut self, value: &[u8]) -> H256 { - self.overlay.insert(value) + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { + self.overlay.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { - self.overlay.emplace(key, value); + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { + self.overlay.emplace(key, prefix, value); } - fn remove(&mut self, key: &H256) { - self.overlay.remove(key); + fn remove(&mut self, key: &H256, prefix: Prefix) { + self.overlay.remove(key, prefix); } } @@ -522,7 +522,7 @@ impl JournalDB for EarlyMergeDB { mod tests { use keccak::keccak; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use super::*; use super::super::traits::JournalDB; use kvdb_memorydb; @@ -532,7 +532,7 @@ mod tests { // history is 1 let mut jdb = new_db(); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); @@ -542,10 +542,10 @@ mod tests { jdb.commit_batch(4, &keccak(b"1003a"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&x); + jdb.remove(&x, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"1002b"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(4, &keccak(b"1003b"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -554,50 +554,50 @@ mod tests { jdb.commit_batch(6, &keccak(b"1005a"), Some((4, keccak(b"1003a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&x)); + assert!(jdb.contains(&x, EMPTY_PREFIX)); } #[test] fn insert_older_era() { let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let bar = jdb.insert(b"bar"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(0, &keccak(b"0b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); } #[test] fn long_history() { // history is 3 let mut jdb = new_db(); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); - jdb.remove(&h); + assert!(jdb.contains(&h, EMPTY_PREFIX)); + jdb.remove(&h, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"3"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&h)); + assert!(!jdb.contains(&h, EMPTY_PREFIX)); } #[test] @@ -605,42 +605,42 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - jdb.remove(&bar); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - let foo = jdb.insert(b"foo"); - jdb.remove(&baz); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.remove(&baz, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); } #[test] @@ -648,31 +648,31 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&baz)); - assert!(!jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); } #[test] @@ -680,22 +680,22 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); - assert!(jdb.contains(&foo)); + jdb.insert(EMPTY_PREFIX, b"foo"); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"2"), Some((0, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -705,23 +705,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1c"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2a"), Some((1, keccak(b"1a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -730,23 +730,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1c"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -755,23 +755,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3a"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3b"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -795,8 +795,8 @@ mod tests { let foo = { let mut jdb = EarlyMergeDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - jdb.emplace(bar.clone(), DBValue::from_slice(b"bar")); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.emplace(bar.clone(), EMPTY_PREFIX, DBValue::from_slice(b"bar")); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); foo @@ -804,18 +804,18 @@ mod tests { { let mut jdb = EarlyMergeDB::new(shared_db.clone(), None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); } { let mut jdb = EarlyMergeDB::new(shared_db, None); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } } @@ -826,19 +826,19 @@ mod tests { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); // expunge foo @@ -852,39 +852,39 @@ mod tests { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -898,28 +898,28 @@ mod tests { let mut jdb = new_db(); // history is 1 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); // foo is ancient history. - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); // BROKEN assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(5, &keccak(b"5"), Some((4, keccak(b"4")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -927,7 +927,7 @@ mod tests { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); @@ -941,16 +941,16 @@ mod tests { // foo is ancient history. - jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(5, &keccak(b"5"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); - jdb.remove(&bar); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(6, &keccak(b"6"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); - jdb.insert(b"bar"); + jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(7, &keccak(b"7"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); } @@ -965,7 +965,7 @@ mod tests { { let mut jdb = EarlyMergeDB::new(shared_db.clone(), None); // history is 1 - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); @@ -973,24 +973,24 @@ mod tests { // foo is ancient history. - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { let mut jdb = EarlyMergeDB::new(shared_db.clone(), None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(4, &keccak(b"4"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { @@ -998,7 +998,7 @@ mod tests { jdb.commit_batch(5, &keccak(b"5"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { @@ -1006,7 +1006,7 @@ mod tests { jdb.commit_batch(6, &keccak(b"6"), Some((4, keccak(b"4")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } } @@ -1017,16 +1017,16 @@ mod tests { let (foo, bar, baz) = { let mut jdb = EarlyMergeDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); (foo, bar, baz) @@ -1036,22 +1036,22 @@ mod tests { let mut jdb = EarlyMergeDB::new(shared_db, None); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&baz)); - assert!(!jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); } } #[test] fn inject() { let mut jdb = new_db(); - let key = jdb.insert(b"dog"); + let key = jdb.insert(EMPTY_PREFIX, b"dog"); jdb.inject_batch().unwrap(); - assert_eq!(jdb.get(&key).unwrap(), DBValue::from_slice(b"dog")); - jdb.remove(&key); + assert_eq!(jdb.get(&key, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"dog")); + jdb.remove(&key, EMPTY_PREFIX); jdb.inject_batch().unwrap(); - assert!(jdb.get(&key).is_none()); + assert!(jdb.get(&key, EMPTY_PREFIX).is_none()); } } diff --git a/util/journaldb/src/overlaydb.rs b/util/journaldb/src/overlaydb.rs index 368af2656f3..65179b150e5 100644 --- a/util/journaldb/src/overlaydb.rs +++ b/util/journaldb/src/overlaydb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use ethereum_types::H256; use rlp::{Rlp, RlpStream, Encodable, DecoderError, Decodable, encode, decode}; -use hash_db::{HashDB}; +use hash_db::{HashDB, Prefix, EMPTY_PREFIX}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use super::{error_negatively_reference_hash}; @@ -133,7 +133,7 @@ impl OverlayDB { pub fn revert(&mut self) { self.overlay.clear(); } /// Get the number of references that would be committed. - pub fn commit_refs(&self, key: &H256) -> i32 { self.overlay.raw(key).map_or(0, |(_, refs)| refs) } + pub fn commit_refs(&self, key: &H256) -> i32 { self.overlay.raw(key, EMPTY_PREFIX).map_or(0, |(_, refs)| refs) } /// Get the refs and value of the given key. fn payload(&self, key: &H256) -> Option { @@ -181,10 +181,10 @@ impl crate::KeyedHashDB for OverlayDB { } impl HashDB for OverlayDB { - fn get(&self, key: &H256) -> Option { + fn get(&self, key: &H256, prefix: Prefix) -> Option { // return ok if positive; if negative, check backing - might be enough references there to make // it positive again. - let k = self.overlay.raw(key); + let k = self.overlay.raw(key, prefix); let memrc = { if let Some((d, rc)) = k { if rc > 0 { return Some(d.clone()); } @@ -208,10 +208,10 @@ impl HashDB for OverlayDB { } } - fn contains(&self, key: &H256) -> bool { + fn contains(&self, key: &H256, prefix: Prefix) -> bool { // return ok if positive; if negative, check backing - might be enough references there to make // it positive again. - let k = self.overlay.raw(key); + let k = self.overlay.raw(key, prefix); match k { Some((_, rc)) if rc > 0 => true, _ => { @@ -228,111 +228,111 @@ impl HashDB for OverlayDB { } } - fn insert(&mut self, value: &[u8]) -> H256 { self.overlay.insert(value) } - fn emplace(&mut self, key: H256, value: DBValue) { self.overlay.emplace(key, value); } - fn remove(&mut self, key: &H256) { self.overlay.remove(key); } + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { self.overlay.insert(prefix, value) } + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { self.overlay.emplace(key, prefix, value); } + fn remove(&mut self, key: &H256, prefix: Prefix) { self.overlay.remove(key, prefix); } } #[test] fn overlaydb_revert() { let mut m = OverlayDB::new_temp(); - let foo = m.insert(b"foo"); // insert foo. + let foo = m.insert(EMPTY_PREFIX, b"foo"); // insert foo. let mut batch = m.backing.transaction(); m.commit_to_batch(&mut batch).unwrap(); // commit - new operations begin here... m.backing.write(batch).unwrap(); - let bar = m.insert(b"bar"); // insert bar. - m.remove(&foo); // remove foo. - assert!(!m.contains(&foo)); // foo is gone. - assert!(m.contains(&bar)); // bar is here. + let bar = m.insert(EMPTY_PREFIX, b"bar"); // insert bar. + m.remove(&foo, EMPTY_PREFIX); // remove foo. + assert!(!m.contains(&foo, EMPTY_PREFIX)); // foo is gone. + assert!(m.contains(&bar, EMPTY_PREFIX)); // bar is here. m.revert(); // revert the last two operations. - assert!(m.contains(&foo)); // foo is here. - assert!(!m.contains(&bar)); // bar is gone. + assert!(m.contains(&foo, EMPTY_PREFIX)); // foo is here. + assert!(!m.contains(&bar, EMPTY_PREFIX)); // bar is gone. } #[test] fn overlaydb_overlay_insert_and_remove() { let mut trie = OverlayDB::new_temp(); - let h = trie.insert(b"hello world"); - assert_eq!(trie.get(&h).unwrap(), DBValue::from_slice(b"hello world")); - trie.remove(&h); - assert_eq!(trie.get(&h), None); + let h = trie.insert(EMPTY_PREFIX, b"hello world"); + assert_eq!(trie.get(&h, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"hello world")); + trie.remove(&h, EMPTY_PREFIX); + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); } #[test] fn overlaydb_backing_insert_revert() { let mut trie = OverlayDB::new_temp(); - let h = trie.insert(b"hello world"); - assert_eq!(trie.get(&h).unwrap(), DBValue::from_slice(b"hello world")); + let h = trie.insert(EMPTY_PREFIX, b"hello world"); + assert_eq!(trie.get(&h, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"hello world")); trie.commit().unwrap(); - assert_eq!(trie.get(&h).unwrap(), DBValue::from_slice(b"hello world")); + assert_eq!(trie.get(&h, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"hello world")); trie.revert(); - assert_eq!(trie.get(&h).unwrap(), DBValue::from_slice(b"hello world")); + assert_eq!(trie.get(&h, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"hello world")); } #[test] fn overlaydb_backing_remove() { let mut trie = OverlayDB::new_temp(); - let h = trie.insert(b"hello world"); + let h = trie.insert(EMPTY_PREFIX, b"hello world"); trie.commit().unwrap(); - trie.remove(&h); - assert_eq!(trie.get(&h), None); + trie.remove(&h, EMPTY_PREFIX); + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); trie.commit().unwrap(); - assert_eq!(trie.get(&h), None); + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); trie.revert(); - assert_eq!(trie.get(&h), None); + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); } #[test] fn overlaydb_backing_remove_revert() { let mut trie = OverlayDB::new_temp(); - let h = trie.insert(b"hello world"); + let h = trie.insert(EMPTY_PREFIX, b"hello world"); trie.commit().unwrap(); - trie.remove(&h); - assert_eq!(trie.get(&h), None); + trie.remove(&h, EMPTY_PREFIX); + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); trie.revert(); - assert_eq!(trie.get(&h).unwrap(), DBValue::from_slice(b"hello world")); + assert_eq!(trie.get(&h, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"hello world")); } #[test] fn overlaydb_negative() { let mut trie = OverlayDB::new_temp(); - let h = trie.insert(b"hello world"); + let h = trie.insert(EMPTY_PREFIX, b"hello world"); trie.commit().unwrap(); - trie.remove(&h); - trie.remove(&h); //bad - sends us into negative refs. - assert_eq!(trie.get(&h), None); + trie.remove(&h, EMPTY_PREFIX); + trie.remove(&h, EMPTY_PREFIX); //bad - sends us into negative refs. + assert_eq!(trie.get(&h, EMPTY_PREFIX), None); assert!(trie.commit().is_err()); } #[test] fn overlaydb_complex() { let mut trie = OverlayDB::new_temp(); - let hfoo = trie.insert(b"foo"); - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); - let hbar = trie.insert(b"bar"); - assert_eq!(trie.get(&hbar).unwrap(), DBValue::from_slice(b"bar")); + let hfoo = trie.insert(EMPTY_PREFIX, b"foo"); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); + let hbar = trie.insert(EMPTY_PREFIX, b"bar"); + assert_eq!(trie.get(&hbar, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"bar")); trie.commit().unwrap(); - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); - assert_eq!(trie.get(&hbar).unwrap(), DBValue::from_slice(b"bar")); - trie.insert(b"foo"); // two refs - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); + assert_eq!(trie.get(&hbar, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"bar")); + trie.insert(EMPTY_PREFIX, b"foo"); // two refs + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); trie.commit().unwrap(); - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); - assert_eq!(trie.get(&hbar).unwrap(), DBValue::from_slice(b"bar")); - trie.remove(&hbar); // zero refs - delete - assert_eq!(trie.get(&hbar), None); - trie.remove(&hfoo); // one ref - keep - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); + assert_eq!(trie.get(&hbar, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"bar")); + trie.remove(&hbar, EMPTY_PREFIX); // zero refs - delete + assert_eq!(trie.get(&hbar, EMPTY_PREFIX), None); + trie.remove(&hfoo, EMPTY_PREFIX); // one ref - keep + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); trie.commit().unwrap(); - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); - trie.remove(&hfoo); // zero ref - would delete, but... - assert_eq!(trie.get(&hfoo), None); - trie.insert(b"foo"); // one ref - keep after all. - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); + trie.remove(&hfoo, EMPTY_PREFIX); // zero ref - would delete, but... + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX), None); + trie.insert(EMPTY_PREFIX, b"foo"); // one ref - keep after all. + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); trie.commit().unwrap(); - assert_eq!(trie.get(&hfoo).unwrap(), DBValue::from_slice(b"foo")); - trie.remove(&hfoo); // zero ref - delete - assert_eq!(trie.get(&hfoo), None); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"foo")); + trie.remove(&hfoo, EMPTY_PREFIX); // zero ref - delete + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX), None); trie.commit().unwrap(); // - assert_eq!(trie.get(&hfoo), None); + assert_eq!(trie.get(&hfoo, EMPTY_PREFIX), None); } diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 78cfe80b235..032bdf36082 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; -use hash_db::HashDB; +use hash_db::{HashDB, Prefix, EMPTY_PREFIX}; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; @@ -195,11 +195,11 @@ impl OverlayRecentDB { for (k, v) in value.inserts { let short_key = to_short_key(&k); - if !overlay.contains(&short_key) { + if !overlay.contains(&short_key, EMPTY_PREFIX) { cumulative_size += v.len(); } - overlay.emplace(short_key, v); + overlay.emplace(short_key, EMPTY_PREFIX, v); inserted_keys.push(k); } journal.entry(era).or_insert_with(Vec::new).push(JournalEntry { @@ -294,7 +294,7 @@ impl JournalDB for OverlayRecentDB { fn state(&self, key: &H256) -> Option { let journal_overlay = self.journal_overlay.read(); let key = to_short_key(key); - journal_overlay.backing_overlay.get(&key).map(|v| v.into_vec()) + journal_overlay.backing_overlay.get(&key, EMPTY_PREFIX).map(|v| v.into_vec()) .or_else(|| journal_overlay.pending_overlay.get(&key).map(|d| d.clone().into_vec())) .or_else(|| self.backing.get_by_prefix(self.column, &key[0..DB_PREFIX_LEN]).map(|b| b.into_vec())) } @@ -326,11 +326,11 @@ impl JournalDB for OverlayRecentDB { for (k, v) in insertions { let short_key = to_short_key(&k); - if !journal_overlay.backing_overlay.contains(&short_key) { + if !journal_overlay.backing_overlay.contains(&short_key, EMPTY_PREFIX) { journal_overlay.cumulative_size += v.len(); } - journal_overlay.backing_overlay.emplace(short_key, v); + journal_overlay.backing_overlay.emplace(short_key, EMPTY_PREFIX, v); } let index = journal_overlay.journal.get(&now).map_or(0, |j| j.len()); @@ -379,7 +379,7 @@ impl JournalDB for OverlayRecentDB { { if *canon_id == journal.id { for h in &journal.insertions { - if let Some((d, rc)) = journal_overlay.backing_overlay.raw(&to_short_key(h)) { + if let Some((d, rc)) = journal_overlay.backing_overlay.raw(&to_short_key(h), EMPTY_PREFIX) { if rc > 0 { canon_insertions.push((h.clone(), d.clone())); //TODO: optimize this to avoid data copy } @@ -402,13 +402,13 @@ impl JournalDB for OverlayRecentDB { } // update the overlay for k in overlay_deletions { - if let Some(val) = journal_overlay.backing_overlay.remove_and_purge(&to_short_key(&k)) { + if let Some(val) = journal_overlay.backing_overlay.remove_and_purge(&to_short_key(&k), EMPTY_PREFIX) { journal_overlay.cumulative_size -= val.len(); } } // apply canon deletions for k in canon_deletions { - if !journal_overlay.backing_overlay.contains(&to_short_key(&k)) { + if !journal_overlay.backing_overlay.contains(&to_short_key(&k), EMPTY_PREFIX) { batch.delete(self.column, &k); } } @@ -456,8 +456,8 @@ impl JournalDB for OverlayRecentDB { } impl HashDB for OverlayRecentDB { - fn get(&self, key: &H256) -> Option { - if let Some((d, rc)) = self.transaction_overlay.raw(key) { + fn get(&self, key: &H256, prefix: Prefix) -> Option { + if let Some((d, rc)) = self.transaction_overlay.raw(key, prefix) { if rc > 0 { return Some(d.clone()) } @@ -465,24 +465,24 @@ impl HashDB for OverlayRecentDB { let v = { let journal_overlay = self.journal_overlay.read(); let key = to_short_key(key); - journal_overlay.backing_overlay.get(&key) + journal_overlay.backing_overlay.get(&key, prefix) .or_else(|| journal_overlay.pending_overlay.get(&key).cloned()) }; v.or_else(|| self.payload(key)) } - fn contains(&self, key: &H256) -> bool { - self.get(key).is_some() + fn contains(&self, key: &H256, prefix: Prefix) -> bool { + self.get(key, prefix).is_some() } - fn insert(&mut self, value: &[u8]) -> H256 { - self.transaction_overlay.insert(value) + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { + self.transaction_overlay.insert(prefix, value) } - fn emplace(&mut self, key: H256, value: DBValue) { - self.transaction_overlay.emplace(key, value); + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { + self.transaction_overlay.emplace(key, prefix, value); } - fn remove(&mut self, key: &H256) { - self.transaction_overlay.remove(key); + fn remove(&mut self, key: &H256, prefix: Prefix) { + self.transaction_overlay.remove(key, prefix); } } @@ -491,7 +491,7 @@ mod tests { use keccak::keccak; use super::*; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use {kvdb_memorydb, JournalDB}; fn new_db() -> OverlayRecentDB { @@ -504,7 +504,7 @@ mod tests { // history is 1 let mut jdb = new_db(); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); @@ -514,10 +514,10 @@ mod tests { jdb.commit_batch(4, &keccak(b"1003a"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&x); + jdb.remove(&x, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"1002b"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - let x = jdb.insert(b"X"); + let x = jdb.insert(EMPTY_PREFIX, b"X"); jdb.commit_batch(4, &keccak(b"1003b"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -526,30 +526,30 @@ mod tests { jdb.commit_batch(6, &keccak(b"1005a"), Some((4, keccak(b"1003a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&x)); + assert!(jdb.contains(&x, EMPTY_PREFIX)); } #[test] fn long_history() { // history is 3 let mut jdb = new_db(); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); - jdb.remove(&h); + assert!(jdb.contains(&h, EMPTY_PREFIX)); + jdb.remove(&h, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"3"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&h)); + assert!(!jdb.contains(&h, EMPTY_PREFIX)); } #[test] @@ -557,42 +557,42 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - jdb.remove(&bar); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - let foo = jdb.insert(b"foo"); - jdb.remove(&baz); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.remove(&baz, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); } #[test] @@ -600,31 +600,31 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&baz)); - assert!(!jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); } #[test] @@ -632,22 +632,22 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); - assert!(jdb.contains(&foo)); + jdb.insert(EMPTY_PREFIX, b"foo"); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"2"), Some((0, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -656,23 +656,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1c"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2a"), Some((1, keccak(b"1a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -682,23 +682,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1c"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); } #[test] @@ -708,23 +708,23 @@ mod tests { jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3a"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3b"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -743,8 +743,8 @@ mod tests { let foo = { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - jdb.emplace(bar.clone(), DBValue::from_slice(b"bar")); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.emplace(bar.clone(), EMPTY_PREFIX, DBValue::from_slice(b"bar")); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); foo @@ -752,18 +752,18 @@ mod tests { { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); } { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } } @@ -773,19 +773,19 @@ mod tests { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); // expunge foo @@ -799,39 +799,39 @@ mod tests { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(2, &keccak(b"2b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(4, &keccak(b"4b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); @@ -844,35 +844,35 @@ mod tests { fn broken_assert() { let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); // foo is ancient history. - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); // BROKEN assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(5, &keccak(b"5"), Some((4, keccak(b"4")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } #[test] fn reopen_test() { let mut jdb = new_db(); // history is 4 - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); @@ -886,16 +886,16 @@ mod tests { // foo is ancient history. - jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(5, &keccak(b"5"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); - jdb.remove(&bar); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(6, &keccak(b"6"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.insert(b"foo"); - jdb.insert(b"bar"); + jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(7, &keccak(b"7"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); } @@ -910,7 +910,7 @@ mod tests { { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); // history is 1 - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); @@ -918,24 +918,24 @@ mod tests { // foo is ancient history. - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); - jdb.insert(b"foo"); + jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(3, &keccak(b"3"), Some((1, keccak(b"1")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(4, &keccak(b"4"), Some((2, keccak(b"2")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { @@ -943,7 +943,7 @@ mod tests { jdb.commit_batch(5, &keccak(b"5"), Some((3, keccak(b"3")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); // incantation to reopen the db }; { @@ -951,7 +951,7 @@ mod tests { jdb.commit_batch(6, &keccak(b"6"), Some((4, keccak(b"4")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(!jdb.contains(&foo)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); } } @@ -962,16 +962,16 @@ mod tests { let (foo, bar, baz) = { let mut jdb = OverlayRecentDB::new(shared_db.clone(), None); // history is 1 - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); assert!(jdb.can_reconstruct_refs()); (foo, bar, baz) @@ -981,43 +981,43 @@ mod tests { let mut jdb = OverlayRecentDB::new(shared_db, None); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&baz)); - assert!(!jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); } } #[test] fn insert_older_era() { let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0a"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); - let bar = jdb.insert(b"bar"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0a")))).unwrap(); assert!(jdb.can_reconstruct_refs()); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(0, &keccak(b"0b"), None).unwrap(); assert!(jdb.can_reconstruct_refs()); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); } #[test] fn inject() { let mut jdb = new_db(); - let key = jdb.insert(b"dog"); + let key = jdb.insert(EMPTY_PREFIX, b"dog"); jdb.inject_batch().unwrap(); - assert_eq!(jdb.get(&key).unwrap(), DBValue::from_slice(b"dog")); - jdb.remove(&key); + assert_eq!(jdb.get(&key, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"dog")); + jdb.remove(&key, EMPTY_PREFIX); jdb.inject_batch().unwrap(); - assert!(jdb.get(&key).is_none()); + assert!(jdb.get(&key, EMPTY_PREFIX).is_none()); } #[test] @@ -1029,7 +1029,7 @@ mod tests { assert!(jdb.earliest_era().is_none()); // single journalled era. - let _key = jdb.insert(b"hello!"); + let _key = jdb.insert(EMPTY_PREFIX, b"hello!"); let mut batch = jdb.backing().transaction(); jdb.journal_under(&mut batch, 0, &keccak(b"0")).unwrap(); jdb.backing().write_buffered(batch); diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 98791ce9a35..2c5ae3e9d13 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -22,7 +22,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; -use hash_db::HashDB; +use hash_db::{HashDB, Prefix, EMPTY_PREFIX}; use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; @@ -80,11 +80,11 @@ impl RefCountedDB { } impl HashDB for RefCountedDB { - fn get(&self, key: &H256) -> Option { self.forward.get(key) } - fn contains(&self, key: &H256) -> bool { self.forward.contains(key) } - fn insert(&mut self, value: &[u8]) -> H256 { let r = self.forward.insert(value); self.inserts.push(r.clone()); r } - fn emplace(&mut self, key: H256, value: DBValue) { self.inserts.push(key.clone()); self.forward.emplace(key, value); } - fn remove(&mut self, key: &H256) { self.removes.push(key.clone()); } + fn get(&self, key: &H256, prefix: Prefix) -> Option { self.forward.get(key, prefix) } + fn contains(&self, key: &H256, prefix: Prefix) -> bool { self.forward.contains(key, prefix) } + fn insert(&mut self, prefix: Prefix, value: &[u8]) -> H256 { let r = self.forward.insert(prefix, value); self.inserts.push(r.clone()); r } + fn emplace(&mut self, key: H256, prefix: Prefix, value: DBValue) { self.inserts.push(key.clone()); self.forward.emplace(key, prefix, value); } + fn remove(&mut self, key: &H256, _prefix: Prefix) { self.removes.push(key.clone()); } } impl ::traits::KeyedHashDB for RefCountedDB { @@ -184,7 +184,7 @@ impl JournalDB for RefCountedDB { }.expect("rlp read from db; qed"); trace!(target: "rcdb", "delete journal for time #{}.{}=>{}, (canon was {}): deleting {:?}", end_era, db_key.index, our_id, canon_id, to_remove); for i in &to_remove { - self.forward.remove(i); + self.forward.remove(i, EMPTY_PREFIX); } batch.delete(self.column, &last); db_key.index += 1; @@ -197,7 +197,7 @@ impl JournalDB for RefCountedDB { fn inject(&mut self, batch: &mut DBTransaction) -> io::Result { self.inserts.clear(); for remove in self.removes.drain(..) { - self.forward.remove(&remove); + self.forward.remove(&remove, EMPTY_PREFIX); } self.forward.commit_to_batch(batch) } @@ -205,11 +205,11 @@ impl JournalDB for RefCountedDB { fn consolidate(&mut self, mut with: super::MemoryDB) { for (key, (value, rc)) in with.drain() { for _ in 0..rc { - self.emplace(key, value.clone()); + self.emplace(key, EMPTY_PREFIX, value.clone()); } for _ in rc..0 { - self.remove(&key); + self.remove(&key, EMPTY_PREFIX); } } } @@ -219,7 +219,7 @@ impl JournalDB for RefCountedDB { mod tests { use keccak::keccak; - use hash_db::HashDB; + use hash_db::{HashDB, EMPTY_PREFIX}; use super::*; use {JournalDB, kvdb_memorydb}; @@ -232,18 +232,18 @@ mod tests { fn long_history() { // history is 3 let mut jdb = new_db(); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&h)); - jdb.remove(&h); + assert!(jdb.contains(&h, EMPTY_PREFIX)); + jdb.remove(&h, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(3, &keccak(b"3"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&h)); + assert!(jdb.contains(&h, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((1, keccak(b"1")))).unwrap(); - assert!(!jdb.contains(&h)); + assert!(!jdb.contains(&h, EMPTY_PREFIX)); } #[test] @@ -251,10 +251,10 @@ mod tests { // history is 3 let mut jdb = new_db(); assert_eq!(jdb.latest_era(), None); - let h = jdb.insert(b"foo"); + let h = jdb.insert(EMPTY_PREFIX, b"foo"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); assert_eq!(jdb.latest_era(), Some(0)); - jdb.remove(&h); + jdb.remove(&h, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1"), None).unwrap(); assert_eq!(jdb.latest_era(), Some(1)); jdb.commit_batch(2, &keccak(b"2"), None).unwrap(); @@ -270,37 +270,37 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - jdb.remove(&bar); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + jdb.remove(&bar, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - let foo = jdb.insert(b"foo"); - jdb.remove(&baz); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + jdb.remove(&baz, EMPTY_PREFIX); jdb.commit_batch(2, &keccak(b"2"), Some((1, keccak(b"1")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); - jdb.remove(&foo); + jdb.remove(&foo, EMPTY_PREFIX); jdb.commit_batch(3, &keccak(b"3"), Some((2, keccak(b"2")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(4, &keccak(b"4"), Some((3, keccak(b"3")))).unwrap(); - assert!(!jdb.contains(&foo)); - assert!(!jdb.contains(&bar)); - assert!(!jdb.contains(&baz)); + assert!(!jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); } #[test] @@ -308,39 +308,39 @@ mod tests { // history is 1 let mut jdb = new_db(); - let foo = jdb.insert(b"foo"); - let bar = jdb.insert(b"bar"); + let foo = jdb.insert(EMPTY_PREFIX, b"foo"); + let bar = jdb.insert(EMPTY_PREFIX, b"bar"); jdb.commit_batch(0, &keccak(b"0"), None).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); - jdb.remove(&foo); - let baz = jdb.insert(b"baz"); + jdb.remove(&foo, EMPTY_PREFIX); + let baz = jdb.insert(EMPTY_PREFIX, b"baz"); jdb.commit_batch(1, &keccak(b"1a"), Some((0, keccak(b"0")))).unwrap(); - jdb.remove(&bar); + jdb.remove(&bar, EMPTY_PREFIX); jdb.commit_batch(1, &keccak(b"1b"), Some((0, keccak(b"0")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(jdb.contains(&bar)); - assert!(jdb.contains(&baz)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(jdb.contains(&bar, EMPTY_PREFIX)); + assert!(jdb.contains(&baz, EMPTY_PREFIX)); jdb.commit_batch(2, &keccak(b"2b"), Some((1, keccak(b"1b")))).unwrap(); - assert!(jdb.contains(&foo)); - assert!(!jdb.contains(&baz)); - assert!(!jdb.contains(&bar)); + assert!(jdb.contains(&foo, EMPTY_PREFIX)); + assert!(!jdb.contains(&baz, EMPTY_PREFIX)); + assert!(!jdb.contains(&bar, EMPTY_PREFIX)); } #[test] fn inject() { let mut jdb = new_db(); - let key = jdb.insert(b"dog"); + let key = jdb.insert(EMPTY_PREFIX, b"dog"); jdb.inject_batch().unwrap(); - assert_eq!(jdb.get(&key).unwrap(), DBValue::from_slice(b"dog")); - jdb.remove(&key); + assert_eq!(jdb.get(&key, EMPTY_PREFIX).unwrap(), DBValue::from_slice(b"dog")); + jdb.remove(&key, EMPTY_PREFIX); jdb.inject_batch().unwrap(); - assert!(jdb.get(&key).is_none()); + assert!(jdb.get(&key, EMPTY_PREFIX).is_none()); } } From 449e23a167f89e51411e91870e2ba2c937569cea Mon Sep 17 00:00:00 2001 From: cheme Date: Fri, 7 Jun 2019 11:28:07 +0200 Subject: [PATCH 17/22] Remove 'estimate_heapsize' mode. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 70c1e15e413..7f4386fd9e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -73,7 +73,7 @@ ethcore-secretstore = { path = "secret-store", optional = true } registrar = { path = "util/registrar" } -parity-util-mem = { version = "0.1", features = ["jemalloc-global", "estimate-heapsize"] } +parity-util-mem = { version = "0.1", features = ["jemalloc-global"] } [build-dependencies] rustc_version = "0.2" From 527ff6bb68085ac5c2090f8f6ec1b123d190015e Mon Sep 17 00:00:00 2001 From: Emeric Chevalier Date: Sun, 9 Jun 2019 08:59:38 +0200 Subject: [PATCH 18/22] fix comment related to perf ignored and bitset heapsize impl. --- ethcore/evm/src/interpreter/shared_cache.rs | 3 ++- ethcore/light/src/client/header_chain.rs | 12 ++++++------ ethcore/src/trace/types/flat.rs | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ethcore/evm/src/interpreter/shared_cache.rs b/ethcore/evm/src/interpreter/shared_cache.rs index e924f3a7350..350135dd9a1 100644 --- a/ethcore/evm/src/interpreter/shared_cache.rs +++ b/ethcore/evm/src/interpreter/shared_cache.rs @@ -25,7 +25,8 @@ use super::super::instructions::{self, Instruction}; const DEFAULT_CACHE_SIZE: usize = 4 * 1024 * 1024; -// stub for a HeapSizeOf implementation. +/// Stub for a sharing `BitSet` data in cache (reference counted) +/// and implementing MallocSizeOf on it. struct Bits(Arc); impl MallocSizeOf for Bits { diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index b26fb3d9653..9ddb3e43d00 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -205,18 +205,18 @@ pub enum HardcodedSync { #[derive(MallocSizeOf)] /// Header chain. See module docs for more details. pub struct HeaderChain { - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] genesis_header: encoded::Header, // special-case the genesis. candidates: RwLock>, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] best_block: RwLock, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] live_epoch_proofs: RwLock>, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] db: Arc, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] col: Option, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] cache: Arc>, } diff --git a/ethcore/src/trace/types/flat.rs b/ethcore/src/trace/types/flat.rs index 257c5a8b6d1..c3c7ccbf8b5 100644 --- a/ethcore/src/trace/types/flat.rs +++ b/ethcore/src/trace/types/flat.rs @@ -26,10 +26,10 @@ use super::trace::{Action, Res}; /// Parent and children indexes refer to positions in this vector. #[derive(Debug, PartialEq, Clone, MallocSizeOf)] pub struct FlatTrace { - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] /// Type of action performed by a transaction. pub action: Action, - #[ignore_malloc_size_of = "perf"] + #[ignore_malloc_size_of = "ignored for performance reason"] /// Result of this action. pub result: Res, /// Number of subtraces. From 26531063b5e179441cd496bd8470b5a00543d8e2 Mon Sep 17 00:00:00 2001 From: cheme Date: Thu, 13 Jun 2019 17:52:21 +0200 Subject: [PATCH 19/22] Remove patch in favor of published crates. --- Cargo.lock | 72 +++++++++++++------------------ Cargo.toml | 6 --- util/triehash-ethereum/Cargo.toml | 2 +- 3 files changed, 32 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f96fced2156..8d81946530d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -881,7 +881,7 @@ dependencies = [ "evm 0.1.0", "fetch 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -895,7 +895,7 @@ dependencies = [ "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -918,7 +918,7 @@ dependencies = [ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time-utils 0.1.0", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "unexpected 0.1.0", @@ -1032,7 +1032,7 @@ dependencies = [ "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1041,7 +1041,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1054,7 +1054,7 @@ dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "vm 0.1.0", ] @@ -1202,7 +1202,7 @@ dependencies = [ "time-utils 0.1.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1299,7 +1299,7 @@ dependencies = [ "ethstore 0.2.1", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1695,7 +1695,7 @@ dependencies = [ [[package]] name = "hash-db" version = "0.12.3" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" +source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" @@ -1998,13 +1998,13 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2154,7 +2154,7 @@ name = "keccak-hasher" version = "0.1.1" dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2164,7 +2164,7 @@ name = "keccak-hasher" version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2358,9 +2358,9 @@ dependencies = [ [[package]] name = "memory-db" version = "0.12.3" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3153,14 +3153,14 @@ version = "0.1.0" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -3659,15 +3659,6 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rlp" -version = "0.4.1" -source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize2#357eb06b4b20794a8a21189bcae7d0af65a18094" -dependencies = [ - "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rlp_compress" version = "0.1.0" @@ -4435,10 +4426,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trie-db" version = "0.12.3" -source = "git+https://github.com/cheme/trie?branch=deprecate_heapsize#3867002062bed1b540f8d01f42cf63e2e317a7f2" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4449,17 +4440,17 @@ name = "trie-standardmap" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "triehash" -version = "0.5.1" -source = "git+https://github.com/cheme/parity-common?branch=rem_heapsize2#357eb06b4b20794a8a21189bcae7d0af65a18094" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", - "rlp 0.4.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)", + "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4468,7 +4459,7 @@ version = "0.2.0" dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "triehash 0.5.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)", + "triehash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4646,7 +4637,7 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)", + "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4937,7 +4928,7 @@ dependencies = [ "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" -"checksum hash-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "587e81efd5dd9596084ff9a1bca98d710da46a10f247a0dfdf1b70b59ba3635e" "checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" @@ -5003,7 +4994,7 @@ dependencies = [ "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum memory-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05a7eb58c07b6ea348f32a9a02d6bad643d1cafea6e1d84f379bb086984feb7a" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum memzero 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" @@ -5102,7 +5093,6 @@ dependencies = [ "checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c" "checksum ripemd160 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ad5112e0dbbb87577bfbc56c42450235e3012ce336e29c5befd7807bd626da4a" "checksum rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b0d56c1450bfbef1181fdeb78b902dc1d23178de77c23d705317508e03d1b7c" -"checksum rlp 0.4.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)" = "" "checksum rpassword 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b273c91bd242ca03ad6d71c143b6f17a48790e61f21a6c78568fa2b6774a24a4" "checksum rprompt 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1601f32bc5858aae3cbfa1c645c96c4d820cc5c16be0194f089560c00b6eb625" "checksum rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f76d05d3993fd5f4af9434e8e436db163a12a9d40e1a58a726f27a01dfd12a2a" @@ -5189,9 +5179,9 @@ dependencies = [ "checksum trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe82f2f0bf1991e163e757baf044282823155dd326e70f44ce2186c3c320cc9" "checksum transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d8bd3123931aa6e49dd03bc8a2400490e14701d779458d1f1fff1f04c6f666" "checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e" -"checksum trie-db 0.12.3 (git+https://github.com/cheme/trie?branch=deprecate_heapsize)" = "" +"checksum trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e77b2115092606c0fa3cc84b04dd4d0b03537575f491ffab7a319a96dc5dc14" "checksum trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ebaa4b340046196efad8872b2dffe585b5ea330230dc44ee14e399f77da29f51" -"checksum triehash 0.5.1 (git+https://github.com/cheme/parity-common?branch=rem_heapsize2)" = "" +"checksum triehash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b645ad3fc9871596897fb64a57c9c29adc9f5ece87c2d78766e3fc5a5da56b56" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" diff --git a/Cargo.toml b/Cargo.toml index 7f4386fd9e3..4f37f08a8d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,9 +142,3 @@ members = [ "util/fastmap", "util/time-utils" ] - -[patch.crates-io] -memory-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } -trie-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } -hash-db = { git = "https://github.com/cheme/trie", branch = "deprecate_heapsize" } -triehash = { git = "https://github.com/cheme/parity-common", branch = "rem_heapsize2" } diff --git a/util/triehash-ethereum/Cargo.toml b/util/triehash-ethereum/Cargo.toml index e4c66d16264..07f720be189 100644 --- a/util/triehash-ethereum/Cargo.toml +++ b/util/triehash-ethereum/Cargo.toml @@ -6,6 +6,6 @@ description = "Trie-root helpers, ethereum style" license = "GPL-3.0" [dependencies] -triehash = { version = "0.5.1" } +triehash = "0.6.0" ethereum-types = "0.6.0" keccak-hasher = { path = "../keccak-hasher" } From 82521c43884ebd90dddf93cca7f8bf5edaf0e9d1 Mon Sep 17 00:00:00 2001 From: cheme Date: Tue, 18 Jun 2019 14:24:12 +0200 Subject: [PATCH 20/22] 0.12.3 trie crate were yanked, using 0.12.4 --- Cargo.lock | 70 +++++++++++++------------- ethcore/Cargo.toml | 8 +-- ethcore/light/Cargo.toml | 6 +-- ethcore/private-tx/Cargo.toml | 2 +- ethcore/sync/Cargo.toml | 2 +- ethcore/vm/Cargo.toml | 2 +- util/journaldb/Cargo.toml | 4 +- util/keccak-hasher/Cargo.toml | 2 +- util/patricia-trie-ethereum/Cargo.toml | 6 +-- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8d81946530d..f45d53e57a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -881,7 +881,7 @@ dependencies = [ "evm 0.1.0", "fetch 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -895,7 +895,7 @@ dependencies = [ "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "macros 0.1.0", "memory-cache 0.1.0", - "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", "num_cpus 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -918,8 +918,8 @@ dependencies = [ "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "time-utils 0.1.0", "trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-standardmap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "unexpected 0.1.0", "using_queue 0.1.0", @@ -1032,7 +1032,7 @@ dependencies = [ "failsafe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1041,7 +1041,7 @@ dependencies = [ "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memory-cache 0.1.0", - "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1054,7 +1054,7 @@ dependencies = [ "smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "stats 0.1.0", "tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "triehash-ethereum 0.2.0", "vm 0.1.0", ] @@ -1202,7 +1202,7 @@ dependencies = [ "time-utils 0.1.0", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1299,7 +1299,7 @@ dependencies = [ "ethstore 0.2.1", "fastmap 0.1.0", "futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1694,12 +1694,12 @@ dependencies = [ [[package]] name = "hash-db" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "hash256-std-hasher" -version = "0.12.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1998,13 +1998,13 @@ dependencies = [ "env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "fastmap 0.1.0", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", "kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2154,18 +2154,18 @@ name = "keccak-hasher" version = "0.1.1" dependencies = [ "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "plain_hasher 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "keccak-hasher" -version = "0.12.2" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", + "hash256-std-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2357,10 +2357,10 @@ dependencies = [ [[package]] name = "memory-db" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "parity-util-mem 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3153,14 +3153,14 @@ version = "0.1.0" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "journaldb 0.2.0", "keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "keccak-hasher 0.1.1", - "memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4425,11 +4425,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "trie-db" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "elastic-array 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)", - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -4437,11 +4437,11 @@ dependencies = [ [[package]] name = "trie-standardmap" -version = "0.12.3" +version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", - "keccak-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", + "keccak-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4449,7 +4449,7 @@ name = "triehash" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4637,7 +4637,7 @@ dependencies = [ "parity-bytes 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "patricia-trie-ethereum 0.1.0", "rlp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -4928,8 +4928,8 @@ dependencies = [ "checksum h2 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "a27e7ed946e8335bdf9a191bc1b9b14a03ba822d013d2f58437f4fabcbd7fc2c" "checksum hamming 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65043da274378d68241eb9a8f8f8aa54e349136f7b8e12f63e3ef44043cc30e1" "checksum handlebars 0.32.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d89ec99d1594f285d4590fc32bac5f75cdab383f1123d504d27862c644a807dd" -"checksum hash-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "587e81efd5dd9596084ff9a1bca98d710da46a10f247a0dfdf1b70b59ba3635e" -"checksum hash256-std-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f8b2027c19ec91eb304999abae7307d225cf93be42af53b0039f76e98ed5af86" +"checksum hash-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c95a428c86ed4633d83e07ef9e0a147a906da01e931f07e74a85bedce5a43" +"checksum hash256-std-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "663ce20dae36902c16d12c6aaae400ca40d922407a8cf2b4caf8cae9b39b4f03" "checksum hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8e04cb7a5051270ef3fa79f8c7604d581ecfa73d520e74f554e45541c4b5881a" "checksum heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1679e6ea370dee694f91f1dc469bf94cf8f52051d147aec3e1f9497c6fc22461" "checksum heck 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ea04fa3ead4e05e51a7c806fc07271fdbde4e246a6c6d1efd52e72230b771b82" @@ -4972,7 +4972,7 @@ dependencies = [ "checksum jsonrpc-tcp-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c873dac37a601fb88d40ba49eeac3f1aa60953c06b2e99ddbf0569b6f8028478" "checksum jsonrpc-ws-server 10.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20b8333a5a6e6ccbcf5c90f90919de557cba4929efa164e9bd0e8e497eb20e46" "checksum keccak-hash 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69e8ee697b9aa6dcc34d7657565fa5052763a1627a5b59e4c3c0ae3ed0d70a65" -"checksum keccak-hasher 0.12.2 (registry+https://github.com/rust-lang/crates.io-index)" = "af672553b2abac1c86c29fd62c79880638b6abc91d96db4aa42a5baab2bc1ca9" +"checksum keccak-hasher 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6c936c737d79690593c34275faf583151a0e8c0abf34eaecad10399eed0beb7d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum kvdb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72ae89206cea31c32014b39d5a454b96135894221610dbfd19cf4d2d044fa546" "checksum kvdb-memorydb 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "45bcdf5eb083602cff61a6f8438dce2a7900d714e893fc48781c39fb119d37aa" @@ -4994,7 +4994,7 @@ dependencies = [ "checksum memchr 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4b3629fe9fdbff6daa6c33b90f7c08355c1aca05a3d01fa8063b822fcf185f3b" "checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff" "checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3" -"checksum memory-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "05a7eb58c07b6ea348f32a9a02d6bad643d1cafea6e1d84f379bb086984feb7a" +"checksum memory-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1eeeeab44c01c7da4409e68ec5b5db74c92305386efab3615e495b1dacaec196" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum memzero 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "93c0d11ac30a033511ae414355d80f70d9f29a44a49140face477117a1ee90db" "checksum mime 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "0a907b83e7b9e987032439a387e187119cddafc92d5c2aaeb1d92580a793f630" @@ -5179,8 +5179,8 @@ dependencies = [ "checksum trace-time 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe82f2f0bf1991e163e757baf044282823155dd326e70f44ce2186c3c320cc9" "checksum transaction-pool 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d8bd3123931aa6e49dd03bc8a2400490e14701d779458d1f1fff1f04c6f666" "checksum transient-hashmap 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aeb4b191d033a35edfce392a38cdcf9790b6cebcb30fa690c312c29da4dc433e" -"checksum trie-db 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8e77b2115092606c0fa3cc84b04dd4d0b03537575f491ffab7a319a96dc5dc14" -"checksum trie-standardmap 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ebaa4b340046196efad8872b2dffe585b5ea330230dc44ee14e399f77da29f51" +"checksum trie-db 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ae063390324bfcf36c7e8e4fb1f85f6f0fb5dd04e1cd282581eb7b8b34b32de7" +"checksum trie-standardmap 0.12.4 (registry+https://github.com/rust-lang/crates.io-index)" = "40787fb1a63a97ed56d12bc303937ea274e09d1afa2e20e4f074eff2074b24d3" "checksum triehash 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b645ad3fc9871596897fb64a57c9c29adc9f5ece87c2d78766e3fc5a5da56b56" "checksum try-lock 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee2aa4715743892880f70885373966c83d73ef1b0838a664ef0c76fffd35e7c2" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index 605f7e8bc8e..57e28f6e15d 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -31,7 +31,7 @@ ethjson = { path = "../json" } ethkey = { path = "../accounts/ethkey" } evm = { path = "evm" } futures = "0.1" -hash-db = "0.12.3" +hash-db = "0.12.4" parity-util-mem = "0.1" itertools = "0.5" journaldb = { path = "../util/journaldb" } @@ -46,14 +46,14 @@ log = "0.4" lru-cache = "0.1" macros = { path = "../util/macros" } memory-cache = { path = "../util/memory-cache" } -memory-db = "0.12.3" +memory-db = "0.12.4" num = { version = "0.1", default-features = false, features = ["bigint"] } num_cpus = "1.2" parity-bytes = "0.1" parity-crypto = "0.4.0" parity-snappy = "0.1" parking_lot = "0.7" -trie-db = "0.12.3" +trie-db = "0.12.4" patricia-trie-ethereum = { path = "../util/patricia-trie-ethereum" } rand = "0.6" rayon = "1.0" @@ -83,7 +83,7 @@ kvdb-rocksdb = "0.1.3" parity-runtime = { path = "../util/runtime" } rlp_compress = { path = "../util/rlp-compress" } tempdir = "0.3" -trie-standardmap = "0.12.3" +trie-standardmap = "0.12.4" [features] parity = ["work-notify", "price-info", "stratum"] diff --git a/ethcore/light/Cargo.toml b/ethcore/light/Cargo.toml index 0d96742ac8b..9bca92d9659 100644 --- a/ethcore/light/Cargo.toml +++ b/ethcore/light/Cargo.toml @@ -14,13 +14,13 @@ ethcore = { path = ".."} ethcore-db = { path = "../db" } ethcore-blockchain = { path = "../blockchain" } ethereum-types = "0.6.0" -memory-db = "0.12.3" -trie-db = "0.12.3" +memory-db = "0.12.4" +trie-db = "0.12.4" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } ethcore-network = { path = "../../util/network" } ethcore-miner = { path = "../../miner" } ethcore-io = { path = "../../util/io" } -hash-db = "0.12.3" +hash-db = "0.12.4" parity-util-mem = "0.1" vm = { path = "../vm" } fastmap = { path = "../../util/fastmap" } diff --git a/ethcore/private-tx/Cargo.toml b/ethcore/private-tx/Cargo.toml index 5922d880b10..ec2f66382b3 100644 --- a/ethcore/private-tx/Cargo.toml +++ b/ethcore/private-tx/Cargo.toml @@ -26,7 +26,7 @@ log = "0.4" parity-bytes = "0.1" parity-crypto = "0.4.0" parking_lot = "0.7" -trie-db = "0.12.3" +trie-db = "0.12.4" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } rand = "0.3" rlp = "0.4.0" diff --git a/ethcore/sync/Cargo.toml b/ethcore/sync/Cargo.toml index 12253dbb127..1bec74526af 100644 --- a/ethcore/sync/Cargo.toml +++ b/ethcore/sync/Cargo.toml @@ -19,7 +19,7 @@ ethereum-types = "0.6.0" ethkey = { path = "../../accounts/ethkey" } ethstore = { path = "../../accounts/ethstore" } fastmap = { path = "../../util/fastmap" } -hash-db = "0.12.3" +hash-db = "0.12.4" keccak-hash = "0.2.0" keccak-hasher = { path = "../../util/keccak-hasher" } kvdb = "0.1" diff --git a/ethcore/vm/Cargo.toml b/ethcore/vm/Cargo.toml index 9a712127c4e..02504372bc3 100644 --- a/ethcore/vm/Cargo.toml +++ b/ethcore/vm/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Parity Technologies "] byteorder = "1.0" parity-bytes = "0.1" ethereum-types = "0.6.0" -trie-db = "0.12.3" +trie-db = "0.12.4" patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" } log = "0.4" ethjson = { path = "../../json" } diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index a465d94a744..64c7d4db181 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -8,12 +8,12 @@ license = "GPL3" [dependencies] parity-bytes = "0.1" ethereum-types = "0.6.0" -hash-db = "0.12.3" +hash-db = "0.12.4" parity-util-mem = "0.1" keccak-hasher = { path = "../keccak-hasher" } kvdb = "0.1" log = "0.4" -memory-db = "0.12.3" +memory-db = "0.12.4" parking_lot = "0.7" fastmap = { path = "../../util/fastmap" } rlp = "0.4.0" diff --git a/util/keccak-hasher/Cargo.toml b/util/keccak-hasher/Cargo.toml index 1897a9274c1..b15a2872482 100644 --- a/util/keccak-hasher/Cargo.toml +++ b/util/keccak-hasher/Cargo.toml @@ -8,5 +8,5 @@ license = "GPL-3.0" [dependencies] ethereum-types = "0.6.0" tiny-keccak = "1.4.2" -hash-db = "0.12.3" +hash-db = "0.12.4" plain_hasher = "0.2" diff --git a/util/patricia-trie-ethereum/Cargo.toml b/util/patricia-trie-ethereum/Cargo.toml index 806357e971b..52f6d7dc716 100644 --- a/util/patricia-trie-ethereum/Cargo.toml +++ b/util/patricia-trie-ethereum/Cargo.toml @@ -6,15 +6,15 @@ description = "Merkle-Patricia Trie (Ethereum Style)" license = "GPL-3.0" [dependencies] -trie-db = "0.12.3" +trie-db = "0.12.4" keccak-hasher = { version = "0.1.1", path = "../keccak-hasher" } -hash-db = "0.12.3" +hash-db = "0.12.4" rlp = "0.4.0" parity-bytes = "0.1" ethereum-types = "0.6.0" elastic-array = "0.10" [dev-dependencies] -memory-db = "0.12.3" +memory-db = "0.12.4" keccak-hash = "0.2.0" journaldb = { path = "../journaldb" } From d3a5bed6fad62e888cf2e527086f9342d381edea Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 19 Jun 2019 11:49:57 +0200 Subject: [PATCH 21/22] Refactor parity_util_mem import (crate alias are kept only for macro derive purpose) --- ethcore/db/src/keys.rs | 2 +- ethcore/evm/src/interpreter/shared_cache.rs | 2 +- ethcore/evm/src/lib.rs | 2 +- ethcore/light/src/cache.rs | 6 +++--- ethcore/light/src/client/header_chain.rs | 2 +- ethcore/light/src/lib.rs | 3 ++- ethcore/src/engines/validator_set/simple_list.rs | 2 +- ethcore/src/engines/validator_set/test.rs | 2 +- ethcore/src/lib.rs | 1 + ethcore/src/trace/types/flat.rs | 2 +- ethcore/src/verification/queue/kind.rs | 4 ++-- ethcore/src/verification/queue/mod.rs | 2 +- ethcore/src/verification/verification.rs | 2 +- ethcore/sync/src/block_sync.rs | 2 +- ethcore/sync/src/blocks.rs | 2 +- ethcore/sync/src/lib.rs | 3 ++- ethcore/types/src/encoded.rs | 2 +- ethcore/types/src/header.rs | 2 +- ethcore/types/src/lib.rs | 1 + ethcore/types/src/log_entry.rs | 2 +- ethcore/types/src/receipt.rs | 2 +- ethcore/types/src/transaction/transaction.rs | 2 +- util/journaldb/src/earlymergedb.rs | 2 +- util/journaldb/src/lib.rs | 1 + util/journaldb/src/overlayrecentdb.rs | 2 +- util/journaldb/src/refcounteddb.rs | 2 +- util/memory-cache/src/lib.rs | 4 ++-- 27 files changed, 33 insertions(+), 28 deletions(-) diff --git a/ethcore/db/src/keys.rs b/ethcore/db/src/keys.rs index e3b41cfea4f..ceab94211ec 100644 --- a/ethcore/db/src/keys.rs +++ b/ethcore/db/src/keys.rs @@ -23,7 +23,7 @@ use common_types::BlockNumber; use common_types::engines::epoch::Transition as EpochTransition; use common_types::receipt::Receipt; use ethereum_types::{H256, H264, U256}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use kvdb::PREFIX_LEN as DB_PREFIX_LEN; use rlp; use rlp_derive::{RlpEncodableWrapper, RlpDecodableWrapper, RlpEncodable, RlpDecodable}; diff --git a/ethcore/evm/src/interpreter/shared_cache.rs b/ethcore/evm/src/interpreter/shared_cache.rs index 350135dd9a1..2507d274d63 100644 --- a/ethcore/evm/src/interpreter/shared_cache.rs +++ b/ethcore/evm/src/interpreter/shared_cache.rs @@ -16,7 +16,7 @@ use std::sync::Arc; use hash::KECCAK_EMPTY; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use parity_util_mem::{MallocSizeOf, MallocSizeOfOps}; use ethereum_types::H256; use parking_lot::Mutex; use memory_cache::MemoryLruCache; diff --git a/ethcore/evm/src/lib.rs b/ethcore/evm/src/lib.rs index 23fe35ff5ef..7cfa5a69eaa 100644 --- a/ethcore/evm/src/lib.rs +++ b/ethcore/evm/src/lib.rs @@ -19,7 +19,7 @@ extern crate bit_set; extern crate ethereum_types; extern crate parking_lot; -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate vm; extern crate keccak_hash as hash; extern crate memory_cache; diff --git a/ethcore/light/src/cache.rs b/ethcore/light/src/cache.rs index ca33e5f8065..5f56c1ad936 100644 --- a/ethcore/light/src/cache.rs +++ b/ethcore/light/src/cache.rs @@ -21,7 +21,7 @@ //! vector of all gas prices from a recent range of blocks. use std::time::{Instant, Duration}; -use mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; +use parity_util_mem::{MallocSizeOf, MallocSizeOfOps, MallocSizeOfExt}; use common_types::encoded; use common_types::BlockNumber; @@ -162,7 +162,7 @@ impl Cache { } -// TODO this is fast method: should feature gate an exhaustive implementation +// This is fast method: it is possible to have a more exhaustive implementation impl MallocSizeOf for Cache { fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { self.headers.current_size() @@ -170,7 +170,7 @@ impl MallocSizeOf for Cache { + self.bodies.current_size() + self.receipts.current_size() + self.chain_score.current_size() - // TODO: + corpus + // `self.corpus` is skipped } } diff --git a/ethcore/light/src/client/header_chain.rs b/ethcore/light/src/client/header_chain.rs index c3d17c4bf17..2a3e8d5d0ad 100644 --- a/ethcore/light/src/client/header_chain.rs +++ b/ethcore/light/src/client/header_chain.rs @@ -38,7 +38,7 @@ use ethcore::engines::epoch::{Transition as EpochTransition, PendingTransition a use ethcore::error::{Error, EthcoreResult, BlockError}; use ethcore::spec::{Spec, SpecHardcodedSync}; use ethereum_types::{H256, H264, U256}; -use mem::{MallocSizeOf, MallocSizeOfOps}; +use parity_util_mem::{MallocSizeOf, MallocSizeOfOps}; use kvdb::{DBTransaction, KeyValueDB}; use parking_lot::{Mutex, RwLock}; use fastmap::H256FastMap; diff --git a/ethcore/light/src/lib.rs b/ethcore/light/src/lib.rs index b1f7c2d767d..d169c6925e2 100644 --- a/ethcore/light/src/lib.rs +++ b/ethcore/light/src/lib.rs @@ -64,8 +64,9 @@ extern crate ethereum_types; extern crate ethcore_miner as miner; extern crate ethcore; extern crate hash_db; -extern crate parity_util_mem as malloc_size_of; +extern crate parity_util_mem; extern crate parity_util_mem as mem; +extern crate parity_util_mem as malloc_size_of; extern crate failsafe; extern crate futures; extern crate itertools; diff --git a/ethcore/src/engines/validator_set/simple_list.rs b/ethcore/src/engines/validator_set/simple_list.rs index b39d96a3811..d9a4c6e1c23 100644 --- a/ethcore/src/engines/validator_set/simple_list.rs +++ b/ethcore/src/engines/validator_set/simple_list.rs @@ -16,7 +16,7 @@ /// Preconfigured validator list. -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::{H256, Address}; use machine::{AuxiliaryData, Call, EthereumMachine}; diff --git a/ethcore/src/engines/validator_set/test.rs b/ethcore/src/engines/validator_set/test.rs index 376b536cf88..c81259f5b90 100644 --- a/ethcore/src/engines/validator_set/test.rs +++ b/ethcore/src/engines/validator_set/test.rs @@ -19,7 +19,7 @@ use std::str::FromStr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering as AtomicOrdering}; -use mem::{MallocSizeOf}; +use parity_util_mem::MallocSizeOf; use bytes::Bytes; use ethereum_types::{H256, Address}; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 3ac49cef382..4c729147a8e 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -97,6 +97,7 @@ extern crate patricia_trie_ethereum as ethtrie; extern crate rand; extern crate rayon; extern crate rlp; +extern crate parity_util_mem; extern crate parity_util_mem as mem; extern crate parity_util_mem as malloc_size_of; extern crate rustc_hex; diff --git a/ethcore/src/trace/types/flat.rs b/ethcore/src/trace/types/flat.rs index c3c7ccbf8b5..17ea1d37887 100644 --- a/ethcore/src/trace/types/flat.rs +++ b/ethcore/src/trace/types/flat.rs @@ -17,7 +17,7 @@ //! Flat trace module use rlp::{Rlp, RlpStream, Decodable, Encodable, DecoderError}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::Bloom; use super::trace::{Action, Res}; diff --git a/ethcore/src/verification/queue/kind.rs b/ethcore/src/verification/queue/kind.rs index 947db60a4e4..508503a04b0 100644 --- a/ethcore/src/verification/queue/kind.rs +++ b/ethcore/src/verification/queue/kind.rs @@ -19,7 +19,7 @@ use engines::EthEngine; use error::Error; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::{H256, U256}; pub use self::blocks::Blocks; @@ -74,7 +74,7 @@ pub mod blocks { use verification::{PreverifiedBlock, verify_block_basic, verify_block_unordered}; use types::transaction::UnverifiedTransaction; - use mem::MallocSizeOf; + use parity_util_mem::MallocSizeOf; use ethereum_types::{H256, U256}; use bytes::Bytes; diff --git a/ethcore/src/verification/queue/mod.rs b/ethcore/src/verification/queue/mod.rs index 2e8c4e7a63c..7acc496ebb8 100644 --- a/ethcore/src/verification/queue/mod.rs +++ b/ethcore/src/verification/queue/mod.rs @@ -22,7 +22,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering as AtomicOrdering}; use std::sync::Arc; use std::cmp; use std::collections::{VecDeque, HashSet, HashMap}; -use mem::{MallocSizeOf, MallocSizeOfExt}; +use parity_util_mem::{MallocSizeOf, MallocSizeOfExt}; use ethereum_types::{H256, U256}; use parking_lot::{Condvar, Mutex, RwLock}; use io::*; diff --git a/ethcore/src/verification/verification.rs b/ethcore/src/verification/verification.rs index 54a08d774bb..7440ad5c645 100644 --- a/ethcore/src/verification/verification.rs +++ b/ethcore/src/verification/verification.rs @@ -26,7 +26,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use bytes::Bytes; use hash::keccak; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use rlp::Rlp; use triehash::ordered_trie_root; use unexpected::{Mismatch, OutOfBounds}; diff --git a/ethcore/sync/src/block_sync.rs b/ethcore/sync/src/block_sync.rs index f40f0ae6605..ca521790dc0 100644 --- a/ethcore/sync/src/block_sync.rs +++ b/ethcore/sync/src/block_sync.rs @@ -20,7 +20,7 @@ use std::collections::{HashSet, VecDeque}; use std::cmp; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::H256; use rlp::{self, Rlp}; use types::BlockNumber; diff --git a/ethcore/sync/src/blocks.rs b/ethcore/sync/src/blocks.rs index f0be7eb50e7..e9b7000a4a7 100644 --- a/ethcore/sync/src/blocks.rs +++ b/ethcore/sync/src/blocks.rs @@ -16,7 +16,7 @@ use std::collections::{HashSet, HashMap, hash_map}; use hash::{keccak, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::H256; use triehash_ethereum::ordered_trie_root; use bytes::Bytes; diff --git a/ethcore/sync/src/lib.rs b/ethcore/sync/src/lib.rs index d8e4867a9f5..805e9f0c15f 100644 --- a/ethcore/sync/src/lib.rs +++ b/ethcore/sync/src/lib.rs @@ -53,9 +53,10 @@ extern crate enum_primitive; extern crate macros; #[macro_use] extern crate log; +extern crate parity_util_mem; +extern crate parity_util_mem as mem; #[macro_use] extern crate parity_util_mem as malloc_size_of; -extern crate parity_util_mem as mem; #[macro_use] extern crate trace_time; diff --git a/ethcore/types/src/encoded.rs b/ethcore/types/src/encoded.rs index 6ea1e0327ad..c402d7e497d 100644 --- a/ethcore/types/src/encoded.rs +++ b/ethcore/types/src/encoded.rs @@ -27,7 +27,7 @@ use block::Block as FullBlock; use ethereum_types::{H256, Bloom, U256, Address}; use hash::keccak; use header::{Header as FullHeader}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use rlp::{self, Rlp, RlpStream}; use transaction::UnverifiedTransaction; use views::{self, BlockView, HeaderView, BodyView}; diff --git a/ethcore/types/src/header.rs b/ethcore/types/src/header.rs index 9451d9d45b5..b5245fcbb28 100644 --- a/ethcore/types/src/header.rs +++ b/ethcore/types/src/header.rs @@ -17,7 +17,7 @@ //! Block header. use hash::{KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use ethereum_types::{H256, U256, Address, Bloom}; use bytes::Bytes; use rlp::{Rlp, RlpStream, Encodable, DecoderError, Decodable}; diff --git a/ethcore/types/src/lib.rs b/ethcore/types/src/lib.rs index df264f2cc11..93145b2e9c5 100644 --- a/ethcore/types/src/lib.rs +++ b/ethcore/types/src/lib.rs @@ -43,6 +43,7 @@ extern crate unexpected; #[macro_use] extern crate rlp_derive; +extern crate parity_util_mem; extern crate parity_util_mem as mem; extern crate parity_util_mem as malloc_size_of; diff --git a/ethcore/types/src/log_entry.rs b/ethcore/types/src/log_entry.rs index 5675cfd5613..2d74554a610 100644 --- a/ethcore/types/src/log_entry.rs +++ b/ethcore/types/src/log_entry.rs @@ -17,7 +17,7 @@ //! Log entry type definition. use std::ops::Deref; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use bytes::Bytes; use ethereum_types::{H256, Address, Bloom, BloomInput}; diff --git a/ethcore/types/src/receipt.rs b/ethcore/types/src/receipt.rs index e5181441ff9..95b39e7de4b 100644 --- a/ethcore/types/src/receipt.rs +++ b/ethcore/types/src/receipt.rs @@ -17,7 +17,7 @@ //! Receipt use ethereum_types::{H160, H256, U256, Address, Bloom}; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use rlp::{Rlp, RlpStream, Encodable, Decodable, DecoderError}; use BlockNumber; diff --git a/ethcore/types/src/transaction/transaction.rs b/ethcore/types/src/transaction/transaction.rs index cc08db5fbe5..12e0d712563 100644 --- a/ethcore/types/src/transaction/transaction.rs +++ b/ethcore/types/src/transaction/transaction.rs @@ -22,7 +22,7 @@ use ethereum_types::{H256, H160, Address, U256, BigEndianHash}; use ethjson; use ethkey::{self, Signature, Secret, Public, recover, public_to_address}; use hash::keccak; -use mem::MallocSizeOf; +use parity_util_mem::MallocSizeOf; use rlp::{self, RlpStream, Rlp, DecoderError, Encodable}; diff --git a/util/journaldb/src/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs index 5746f9c70d8..5d12cd480c0 100644 --- a/util/journaldb/src/earlymergedb.rs +++ b/util/journaldb/src/earlymergedb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hash_db::{HashDB, Prefix}; -use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; +use parity_util_mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use parking_lot::RwLock; diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index f8ee35b0d03..b141a90ab02 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -16,6 +16,7 @@ //! `JournalDB` interface and implementation. +extern crate parity_util_mem; extern crate parity_util_mem as mem; extern crate parity_util_mem as malloc_size_of; #[macro_use] diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 47a1a1e4177..ea389e0ce19 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -24,7 +24,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hash_db::{HashDB, Prefix, EMPTY_PREFIX}; -use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; +use parity_util_mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use parking_lot::RwLock; diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index 2c5ae3e9d13..b0eb7809d1b 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; use hash_db::{HashDB, Prefix, EMPTY_PREFIX}; -use mem::{MallocSizeOf, allocators::new_malloc_size_ops}; +use parity_util_mem::{MallocSizeOf, allocators::new_malloc_size_ops}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; use overlaydb::OverlayDB; diff --git a/util/memory-cache/src/lib.rs b/util/memory-cache/src/lib.rs index 512d426586a..960ebc20a49 100644 --- a/util/memory-cache/src/lib.rs +++ b/util/memory-cache/src/lib.rs @@ -18,10 +18,10 @@ //! crate. // TODO: push changes upstream in a clean way. -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate lru_cache; -use mem::{MallocSizeOf, MallocSizeOfExt}; +use parity_util_mem::{MallocSizeOf, MallocSizeOfExt}; use lru_cache::LruCache; use std::hash::Hash; From 620a0c13438126a5a46fde7a36612e64c66bd08f Mon Sep 17 00:00:00 2001 From: cheme Date: Wed, 19 Jun 2019 12:09:36 +0200 Subject: [PATCH 22/22] Missing parity_util_mem direct usage. --- accounts/ethkey/src/lib.rs | 2 +- accounts/ethkey/src/secret.rs | 2 +- ethcore/light/src/client/mod.rs | 2 +- ethcore/private-tx/src/lib.rs | 2 +- ethcore/private-tx/src/private_transactions.rs | 2 +- ethcore/src/trace/db.rs | 2 +- ethcore/sync/src/chain/mod.rs | 2 +- miner/src/lib.rs | 2 +- miner/src/pool/mod.rs | 2 +- util/journaldb/src/archivedb.rs | 2 +- whisper/src/lib.rs | 2 +- whisper/src/rpc/crypto.rs | 2 +- whisper/src/rpc/key_store.rs | 2 +- whisper/src/rpc/mod.rs | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/accounts/ethkey/src/lib.rs b/accounts/ethkey/src/lib.rs index 6bd3ac0599d..f22c77e3c59 100644 --- a/accounts/ethkey/src/lib.rs +++ b/accounts/ethkey/src/lib.rs @@ -20,7 +20,7 @@ extern crate byteorder; extern crate edit_distance; extern crate parity_crypto; extern crate ethereum_types; -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate parity_wordlist; #[macro_use] extern crate quick_error; diff --git a/accounts/ethkey/src/secret.rs b/accounts/ethkey/src/secret.rs index 5f1c3f0fb9a..25136ee8330 100644 --- a/accounts/ethkey/src/secret.rs +++ b/accounts/ethkey/src/secret.rs @@ -21,7 +21,7 @@ use rustc_hex::ToHex; use secp256k1::constants::{SECRET_KEY_SIZE as SECP256K1_SECRET_KEY_SIZE}; use secp256k1::key; use ethereum_types::H256; -use mem::Memzero; +use parity_util_mem::Memzero; use {Error, SECP256K1}; #[derive(Clone, PartialEq, Eq)] diff --git a/ethcore/light/src/client/mod.rs b/ethcore/light/src/client/mod.rs index ad514c209e5..6ed2b222ecd 100644 --- a/ethcore/light/src/client/mod.rs +++ b/ethcore/light/src/client/mod.rs @@ -362,7 +362,7 @@ impl Client { /// Get blockchain mem usage in bytes. pub fn chain_mem_used(&self) -> usize { - use mem::MallocSizeOfExt; + use parity_util_mem::MallocSizeOfExt; self.chain.malloc_size_of() } diff --git a/ethcore/private-tx/src/lib.rs b/ethcore/private-tx/src/lib.rs index c93b5262cdf..2f23de3fc86 100644 --- a/ethcore/private-tx/src/lib.rs +++ b/ethcore/private-tx/src/lib.rs @@ -34,7 +34,7 @@ extern crate ethjson; extern crate ethkey; extern crate fetch; extern crate futures; -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate keccak_hash as hash; extern crate parity_bytes as bytes; extern crate parity_crypto as crypto; diff --git a/ethcore/private-tx/src/private_transactions.rs b/ethcore/private-tx/src/private_transactions.rs index 2906bc7bb5c..b9108289135 100644 --- a/ethcore/private-tx/src/private_transactions.rs +++ b/ethcore/private-tx/src/private_transactions.rs @@ -21,7 +21,7 @@ use std::collections::{HashMap, HashSet}; use bytes::Bytes; use ethcore_miner::pool; use ethereum_types::{H256, U256, Address}; -use mem::MallocSizeOfExt; +use parity_util_mem::MallocSizeOfExt; use ethkey::Signature; use messages::PrivateTransaction; use parking_lot::RwLock; diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 5e4456bf6dd..baeca316665 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -17,7 +17,7 @@ //! Trace database. use std::collections::HashMap; use std::sync::Arc; -use mem::MallocSizeOfExt; +use parity_util_mem::MallocSizeOfExt; use blockchain::BlockChainDB; use db::cache_manager::CacheManager; diff --git a/ethcore/sync/src/chain/mod.rs b/ethcore/sync/src/chain/mod.rs index 8ae13f89fe9..bde38cda399 100644 --- a/ethcore/sync/src/chain/mod.rs +++ b/ethcore/sync/src/chain/mod.rs @@ -98,7 +98,7 @@ use std::collections::{HashSet, HashMap, BTreeMap}; use std::cmp; use std::time::{Duration, Instant}; use hash::keccak; -use mem::MallocSizeOfExt; +use parity_util_mem::MallocSizeOfExt; use futures::sync::mpsc as futures_mpsc; use api::Notification; use ethereum_types::{H256, U256}; diff --git a/miner/src/lib.rs b/miner/src/lib.rs index ab457368542..2880a645c36 100644 --- a/miner/src/lib.rs +++ b/miner/src/lib.rs @@ -26,7 +26,7 @@ extern crate ethcore_call_contract as call_contract; extern crate ethereum_types; extern crate futures; -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate keccak_hash as hash; extern crate linked_hash_map; extern crate parity_runtime; diff --git a/miner/src/pool/mod.rs b/miner/src/pool/mod.rs index b075391316a..6dfb26ffeb5 100644 --- a/miner/src/pool/mod.rs +++ b/miner/src/pool/mod.rs @@ -17,7 +17,7 @@ //! Transaction Pool use ethereum_types::{U256, H256, Address}; -use mem::MallocSizeOfExt; +use parity_util_mem::MallocSizeOfExt; use types::transaction; use txpool; diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index c38182be9b9..edeac382690 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -23,7 +23,7 @@ use std::sync::Arc; use bytes::Bytes; use ethereum_types::H256; -use mem::MallocSizeOfExt; +use parity_util_mem::MallocSizeOfExt; use hash_db::{HashDB, Prefix}; use keccak_hasher::KeccakHasher; use kvdb::{KeyValueDB, DBTransaction, DBValue}; diff --git a/whisper/src/lib.rs b/whisper/src/lib.rs index c7d06a91531..7ff7794b77a 100644 --- a/whisper/src/lib.rs +++ b/whisper/src/lib.rs @@ -24,7 +24,7 @@ extern crate ethcore_network as network; extern crate ethereum_types; extern crate ethkey; extern crate hex; -extern crate parity_util_mem as mem; +extern crate parity_util_mem; extern crate ordered_float; extern crate parking_lot; extern crate rand; diff --git a/whisper/src/rpc/crypto.rs b/whisper/src/rpc/crypto.rs index d186be21f9a..3f26e0350a0 100644 --- a/whisper/src/rpc/crypto.rs +++ b/whisper/src/rpc/crypto.rs @@ -20,7 +20,7 @@ use aes_gcm::{Encryptor, Decryptor}; use ethkey::crypto::ecies; use ethereum_types::H256; use ethkey::{self, Public, Secret}; -use mem::Memzero; +use parity_util_mem::Memzero; /// Length of AES key pub const AES_KEY_LEN: usize = 32; diff --git a/whisper/src/rpc/key_store.rs b/whisper/src/rpc/key_store.rs index 834dbcb806a..3f84e59ad3a 100644 --- a/whisper/src/rpc/key_store.rs +++ b/whisper/src/rpc/key_store.rs @@ -23,7 +23,7 @@ use std::collections::HashMap; use ethereum_types::H256; use ethkey::{KeyPair, Public, Secret}; -use mem::Memzero; +use parity_util_mem::Memzero; use rand::{Rng, rngs::OsRng}; use rpc::crypto::{AES_KEY_LEN, EncryptionInstance, DecryptionInstance}; diff --git a/whisper/src/rpc/mod.rs b/whisper/src/rpc/mod.rs index c5c7e23c6f3..61cd14d4b9b 100644 --- a/whisper/src/rpc/mod.rs +++ b/whisper/src/rpc/mod.rs @@ -28,7 +28,7 @@ use jsonrpc_derive::rpc; use jsonrpc_pubsub::{Session, PubSubMetadata, SubscriptionId, typed::Subscriber}; use ethereum_types::H256; -use mem::Memzero; +use parity_util_mem::Memzero; use parking_lot::RwLock; use self::filter::Filter;