From e2b96e1fe045b2d6218e83e04b62d3368957f7a4 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Mon, 16 Oct 2017 21:12:54 +0700 Subject: [PATCH 1/7] Moves journaldb sources to a separate crate (#6693) --- util/journaldb/Cargo.toml | 18 ++++++++++++++++++ .../journaldb => journaldb/src}/archivedb.rs | 4 ++-- .../src}/earlymergedb.rs | 0 .../journaldb/mod.rs => journaldb/src/lib.rs} | 13 +++++++++++++ util/{ => journaldb}/src/overlaydb.rs | 0 .../src}/overlayrecentdb.rs | 0 .../src}/refcounteddb.rs | 0 .../{src/journaldb => journaldb/src}/traits.rs | 0 8 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 util/journaldb/Cargo.toml rename util/{src/journaldb => journaldb/src}/archivedb.rs (99%) rename util/{src/journaldb => journaldb/src}/earlymergedb.rs (100%) rename util/{src/journaldb/mod.rs => journaldb/src/lib.rs} (95%) rename util/{ => journaldb}/src/overlaydb.rs (100%) rename util/{src/journaldb => journaldb/src}/overlayrecentdb.rs (100%) rename util/{src/journaldb => journaldb/src}/refcounteddb.rs (100%) rename util/{src/journaldb => journaldb/src}/traits.rs (100%) diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml new file mode 100644 index 000000000..0b537be41 --- /dev/null +++ b/util/journaldb/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "journaldb" +version = "0.1.0" +authors = ["Parity Technologies "] +description = "A `HashDB` which can manage a short-term journal potentially containing many forks of mutually exclusive actions" +license = "GPL3" + +[dependencies] +hashdb = { path = "../hashdb" } +kvdb = { path = "../kvdb" } +ethcore-bigint = { path = "../bigint", features = ["heapsizeof"] } +ethcore-bytes = { path = "../bytes" } +rlp = { path = "../rlp" } +memorydb = { path = "../memorydb" } +parking_lot = "0.4" +heapsize = "0.4" +util-error = { path = "../error" } +log = "0.3" diff --git a/util/src/journaldb/archivedb.rs b/util/journaldb/src/archivedb.rs similarity index 99% rename from util/src/journaldb/archivedb.rs rename to util/journaldb/src/archivedb.rs index 446a5459c..4a3225f1f 100644 --- a/util/src/journaldb/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -21,9 +21,9 @@ use std::collections::hash_map::Entry; use std::sync::Arc; use rlp::*; use hashdb::*; -use super::super::memorydb::*; +use super::memorydb::*; use super::{DB_PREFIX_LEN, LATEST_ERA_KEY}; -use super::traits::JournalDB; +use traits::JournalDB; use kvdb::{KeyValueDB, DBTransaction}; use bigint::hash::H256; use error::{BaseDataError, UtilError}; diff --git a/util/src/journaldb/earlymergedb.rs b/util/journaldb/src/earlymergedb.rs similarity index 100% rename from util/src/journaldb/earlymergedb.rs rename to util/journaldb/src/earlymergedb.rs diff --git a/util/src/journaldb/mod.rs b/util/journaldb/src/lib.rs similarity index 95% rename from util/src/journaldb/mod.rs rename to util/journaldb/src/lib.rs index c048342b2..d21679242 100644 --- a/util/src/journaldb/mod.rs +++ b/util/journaldb/src/lib.rs @@ -16,6 +16,17 @@ //! `JournalDB` interface and implementation. +extern crate ethcore_bigint as bigint; +extern crate ethcore_bytes as bytes; +extern crate parking_lot; +extern crate rlp; +extern crate hashdb; +extern crate memorydb; +extern crate kvdb; +extern crate util_error as error; +extern crate heapsize; +#[macro_use] extern crate log; + use std::{fmt, str}; use std::sync::Arc; @@ -26,6 +37,8 @@ mod earlymergedb; mod overlayrecentdb; mod refcounteddb; +pub mod overlaydb; + /// Export the `JournalDB` trait. pub use self::traits::JournalDB; diff --git a/util/src/overlaydb.rs b/util/journaldb/src/overlaydb.rs similarity index 100% rename from util/src/overlaydb.rs rename to util/journaldb/src/overlaydb.rs diff --git a/util/src/journaldb/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs similarity index 100% rename from util/src/journaldb/overlayrecentdb.rs rename to util/journaldb/src/overlayrecentdb.rs diff --git a/util/src/journaldb/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs similarity index 100% rename from util/src/journaldb/refcounteddb.rs rename to util/journaldb/src/refcounteddb.rs diff --git a/util/src/journaldb/traits.rs b/util/journaldb/src/traits.rs similarity index 100% rename from util/src/journaldb/traits.rs rename to util/journaldb/src/traits.rs From c0fc83988f05c44373626179bb6a01a53c190617 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 17 Oct 2017 11:20:24 +0700 Subject: [PATCH 2/7] Refactors ethcore to use journaldb crate (#6693) --- Cargo.lock | 18 ++++++++++++++++++ ethcore/Cargo.toml | 1 + ethcore/src/client/client.rs | 3 ++- ethcore/src/client/config.rs | 2 +- ethcore/src/client/evm_test_client.rs | 2 +- ethcore/src/client/test_client.rs | 3 ++- ethcore/src/lib.rs | 1 + ethcore/src/migrations/v10.rs | 2 +- ethcore/src/snapshot/mod.rs | 2 +- ethcore/src/snapshot/service.rs | 2 +- ethcore/src/spec/spec.rs | 2 +- ethcore/src/state_db.rs | 2 +- util/Cargo.toml | 1 + util/src/lib.rs | 6 ------ 14 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8930a592f..633347405 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,6 +539,7 @@ dependencies = [ "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.10.0-a.0 (git+https://github.com/paritytech/hyper)", "itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "journaldb 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "kvdb-rocksdb 0.1.0", @@ -772,6 +773,7 @@ dependencies = [ "hash 0.1.0", "hashdb 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "journaldb 0.1.0", "kvdb 0.1.0", "kvdb-memorydb 0.1.0", "libc 0.2.31 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1252,6 +1254,22 @@ name = "itoa" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "journaldb" +version = "0.1.0" +dependencies = [ + "ethcore-bigint 0.1.3", + "ethcore-bytes 0.1.0", + "hashdb 0.1.0", + "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kvdb 0.1.0", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "memorydb 0.1.0", + "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "rlp 0.2.0", + "util-error 0.1.0", +] + [[package]] name = "jsonrpc-core" version = "8.0.0" diff --git a/ethcore/Cargo.toml b/ethcore/Cargo.toml index b379c3fea..2f77b8cb3 100644 --- a/ethcore/Cargo.toml +++ b/ethcore/Cargo.toml @@ -71,6 +71,7 @@ hash = { path = "../util/hash" } triehash = { path = "../util/triehash" } semantic_version = { path = "../util/semantic_version" } unexpected = { path = "../util/unexpected" } +journaldb = { path = "../util/journaldb" } [dev-dependencies] native-contracts = { path = "native_contracts", features = ["test_contracts"] } diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 366b40747..b65e698df 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -26,7 +26,8 @@ use itertools::Itertools; use hash::keccak; use timer::PerfTimer; use bytes::Bytes; -use util::{Address, journaldb, DBValue}; +use util::{Address, DBValue}; +use journaldb; use util_error::UtilError; use trie::{TrieSpec, TrieFactory, Trie}; use kvdb::{KeyValueDB, DBTransaction}; diff --git a/ethcore/src/client/config.rs b/ethcore/src/client/config.rs index 14efb3ec4..ce5878f1e 100644 --- a/ethcore/src/client/config.rs +++ b/ethcore/src/client/config.rs @@ -20,7 +20,7 @@ use std::fmt::{Display, Formatter, Error as FmtError}; use mode::Mode as IpcMode; use verification::{VerifierType, QueueConfig}; -use util::journaldb; +use journaldb; use kvdb_rocksdb::CompactionProfile; pub use std::time::Duration; diff --git a/ethcore/src/client/evm_test_client.rs b/ethcore/src/client/evm_test_client.rs index 55883e189..88f1c4f2c 100644 --- a/ethcore/src/client/evm_test_client.rs +++ b/ethcore/src/client/evm_test_client.rs @@ -20,7 +20,7 @@ use std::fmt; use std::sync::Arc; use bigint::prelude::U256; use bigint::hash::H256; -use util::journaldb; +use journaldb; use {trie, kvdb_memorydb, bytes}; use kvdb::{self, KeyValueDB}; use {state, state_db, client, executive, trace, transaction, db, spec, pod_state}; diff --git a/ethcore/src/client/test_client.rs b/ethcore/src/client/test_client.rs index 4ee3c420c..d06f94768 100644 --- a/ethcore/src/client/test_client.rs +++ b/ethcore/src/client/test_client.rs @@ -26,7 +26,8 @@ use hash::keccak; use bigint::prelude::U256; use bigint::hash::H256; use parking_lot::RwLock; -use util::*; +use journaldb; +use util::{Address, DBValue}; use kvdb_rocksdb::{Database, DatabaseConfig}; use bytes::Bytes; use rlp::*; diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index ce2b8d346..4620cc892 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -131,6 +131,7 @@ extern crate vm; extern crate wasm; extern crate ethcore_util as util; extern crate memory_cache; +extern crate journaldb; #[macro_use] extern crate macros; diff --git a/ethcore/src/migrations/v10.rs b/ethcore/src/migrations/v10.rs index f0460dd4a..e9317d4a6 100644 --- a/ethcore/src/migrations/v10.rs +++ b/ethcore/src/migrations/v10.rs @@ -23,7 +23,7 @@ use trie::TrieDB; use views::HeaderView; use bloom_journal::Bloom; use migration::{Error, Migration, Progress, Batch, Config, ErrorKind}; -use util::journaldb; +use journaldb; use bigint::hash::H256; use trie::Trie; use kvdb::{DBTransaction, ResultExt}; diff --git a/ethcore/src/snapshot/mod.rs b/ethcore/src/snapshot/mod.rs index 4a3446e6e..02adb2c16 100644 --- a/ethcore/src/snapshot/mod.rs +++ b/ethcore/src/snapshot/mod.rs @@ -36,7 +36,7 @@ use util::{HashDB, DBValue}; use snappy; use bytes::Bytes; use parking_lot::Mutex; -use util::journaldb::{self, Algorithm, JournalDB}; +use journaldb::{self, Algorithm, JournalDB}; use kvdb::KeyValueDB; use trie::{TrieDB, TrieDBMut, Trie, TrieMut}; use rlp::{RlpStream, UntrustedRlp}; diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index ae6a34cfa..7af706c90 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -39,7 +39,7 @@ use bigint::hash::H256; use parking_lot::{Mutex, RwLock, RwLockReadGuard}; use util_error::UtilError; use bytes::Bytes; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use kvdb_rocksdb::{Database, DatabaseConfig}; use snappy; diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 70a6d9afd..14a7ff413 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -670,7 +670,7 @@ impl Spec { /// constructor. pub fn genesis_epoch_data(&self) -> Result, String> { use transaction::{Action, Transaction}; - use util::journaldb; + use journaldb; use kvdb_memorydb; let genesis = self.genesis_header(); diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 148c0d8c8..953b7b388 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -18,7 +18,7 @@ use std::collections::{VecDeque, HashSet}; use std::sync::Arc; use lru_cache::LruCache; use memory_cache::MemoryLruCache; -use util::journaldb::JournalDB; +use journaldb::JournalDB; use kvdb::{KeyValueDB, DBTransaction}; use bigint::hash::H256; use hashdb::HashDB; diff --git a/util/Cargo.toml b/util/Cargo.toml index 8dbbd9a76..6dee72718 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -32,6 +32,7 @@ ethcore-bytes = { path = "bytes" } memorydb = { path = "memorydb" } util-error = { path = "error" } kvdb = { path = "kvdb" } +journaldb = { path = "journaldb" } [dev-dependencies] kvdb-memorydb = { path = "kvdb-memorydb" } diff --git a/util/src/lib.rs b/util/src/lib.rs index c02342668..d63119a5c 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -112,18 +112,12 @@ extern crate util_error as error; #[cfg(test)] extern crate kvdb_memorydb; -#[macro_use] -extern crate log as rlog; pub mod misc; -pub mod overlaydb; -pub mod journaldb; pub use misc::*; pub use hashdb::*; pub use memorydb::MemoryDB; -pub use overlaydb::*; -pub use journaldb::JournalDB; /// 160-bit integer representing account address pub type Address = bigint::hash::H160; From f9e588dd7ba3987150e3ff476a2f314413179586 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 17 Oct 2017 11:41:05 +0700 Subject: [PATCH 3/7] Refactors parity/parity to use journaldb crate (#6693) --- Cargo.lock | 1 + Cargo.toml | 1 + parity/dir.rs | 2 +- parity/helpers.rs | 2 +- parity/main.rs | 1 + parity/migration.rs | 3 +-- parity/params.rs | 2 +- parity/run.rs | 2 +- parity/upgrade.rs | 2 +- parity/user_defaults.rs | 2 +- 10 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 633347405..0e5cd4abe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1959,6 +1959,7 @@ dependencies = [ "hash 0.1.0", "ipnetwork 0.12.7 (registry+https://github.com/rust-lang/crates.io-index)", "isatty 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "journaldb 0.1.0", "jsonrpc-core 8.0.0 (git+https://github.com/paritytech/jsonrpc.git?branch=parity-1.8)", "kvdb 0.1.0", "kvdb-rocksdb 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index ccdb46b56..08f8b4398 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -62,6 +62,7 @@ hash = { path = "util/hash" } migration = { path = "util/migration" } kvdb = { path = "util/kvdb" } kvdb-rocksdb = { path = "util/kvdb-rocksdb" } +journaldb = { path = "util/journaldb" } parity-dapps = { path = "dapps", optional = true } clippy = { version = "0.0.103", optional = true} diff --git a/parity/dir.rs b/parity/dir.rs index 4046e48a6..a7b676bc7 100644 --- a/parity/dir.rs +++ b/parity/dir.rs @@ -17,7 +17,7 @@ use std::fs; use std::path::{PathBuf, Path}; use bigint::hash::{H64, H256}; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use helpers::{replace_home, replace_home_and_local}; use app_dirs::{AppInfo, get_app_root, AppDataType}; diff --git a/parity/helpers.rs b/parity/helpers.rs index 1319f45d3..f04027029 100644 --- a/parity/helpers.rs +++ b/parity/helpers.rs @@ -22,7 +22,7 @@ use bigint::prelude::U256; use bigint::hash::clean_0x; use util::Address; use kvdb_rocksdb::CompactionProfile; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use ethcore::client::{Mode, BlockId, VMType, DatabaseCompactionProfile, ClientConfig, VerifierType}; use ethcore::miner::{PendingSet, GasLimit, PrioritizationStrategy}; use cache::CacheConfig; diff --git a/parity/main.rs b/parity/main.rs index 5f6cd4292..10e825d8b 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -76,6 +76,7 @@ extern crate path; extern crate rpc_cli; extern crate node_filter; extern crate hash; +extern crate journaldb; #[macro_use] extern crate log as rlog; diff --git a/parity/migration.rs b/parity/migration.rs index 9ccb7131a..63385e033 100644 --- a/parity/migration.rs +++ b/parity/migration.rs @@ -20,7 +20,7 @@ use std::io::{Read, Write, Error as IoError, ErrorKind}; use std::path::{Path, PathBuf}; use std::fmt::{Display, Formatter, Error as FmtError}; use std::sync::Arc; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use migr::{self, Manager as MigrationManager, Config as MigrationConfig, Migration}; use kvdb; use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig}; @@ -282,7 +282,6 @@ pub fn migrate(path: &Path, pruning: Algorithm, compaction_profile: CompactionPr mod legacy { use super::*; use std::path::{Path, PathBuf}; - use util::journaldb::Algorithm; use migr::{Manager as MigrationManager}; use kvdb_rocksdb::CompactionProfile; use ethcore::migrations; diff --git a/parity/params.rs b/parity/params.rs index f508b59f1..3dbe065f3 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -18,7 +18,7 @@ use std::{str, fs, fmt}; use std::time::Duration; use bigint::prelude::U256; use util::{Address, version_data}; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use ethcore::spec::{Spec, SpecParams}; use ethcore::ethereum; use ethcore::client::Mode; diff --git a/parity/run.rs b/parity/run.rs index 87ab56679..13c3575d9 100644 --- a/parity/run.rs +++ b/parity/run.rs @@ -42,7 +42,7 @@ use ansi_term::Colour; use util::version; use parking_lot::{Condvar, Mutex}; use node_filter::NodeFilter; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use params::{ SpecType, Pruning, AccountsConfig, GasPricerConfig, MinerExtras, Switch, diff --git a/parity/upgrade.rs b/parity/upgrade.rs index cef501b50..99d2abdcb 100644 --- a/parity/upgrade.rs +++ b/parity/upgrade.rs @@ -25,7 +25,7 @@ use std::io::{Read, Write}; use std::path::{PathBuf, Path}; use dir::{DatabaseDirectories, default_data_path}; use helpers::replace_home; -use util::journaldb::Algorithm; +use journaldb::Algorithm; #[cfg_attr(feature="dev", allow(enum_variant_names))] #[derive(Debug)] diff --git a/parity/user_defaults.rs b/parity/user_defaults.rs index 703b3bf16..be91e302e 100644 --- a/parity/user_defaults.rs +++ b/parity/user_defaults.rs @@ -26,7 +26,7 @@ use serde::de::value::MapAccessDeserializer; use serde_json::Value; use serde_json::de::from_reader; use serde_json::ser::to_string; -use util::journaldb::Algorithm; +use journaldb::Algorithm; use ethcore::client::Mode; pub struct UserDefaults { From 7fe7b6d9a4499982c49ee066059aa18c622d832a Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 17 Oct 2017 12:12:46 +0700 Subject: [PATCH 4/7] Fixes import in test --- parity/params.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parity/params.rs b/parity/params.rs index 3dbe065f3..32353e168 100644 --- a/parity/params.rs +++ b/parity/params.rs @@ -326,7 +326,7 @@ pub fn mode_switch_to_bool(switch: Option, user_defaults: &UserDefaults) - #[cfg(test)] mod tests { - use util::journaldb::Algorithm; + use journaldb::Algorithm; use user_defaults::UserDefaults; use super::{SpecType, Pruning, ResealPolicy, Switch, tracing_switch_to_bool}; From 607cc6c78215355ea086613dca27297eb8fbe87f Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 17 Oct 2017 10:40:45 +0200 Subject: [PATCH 5/7] fixed compiling util tests --- Cargo.lock | 3 +++ util/journaldb/Cargo.toml | 15 ++++++++++----- util/journaldb/src/archivedb.rs | 3 +-- util/journaldb/src/lib.rs | 19 ++++++++++++++----- util/journaldb/src/overlayrecentdb.rs | 5 ++--- util/journaldb/src/refcounteddb.rs | 3 +-- 6 files changed, 31 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e5cd4abe..895c837ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1260,9 +1260,12 @@ version = "0.1.0" dependencies = [ "ethcore-bigint 0.1.3", "ethcore-bytes 0.1.0", + "ethcore-logger 1.9.0", + "hash 0.1.0", "hashdb 0.1.0", "heapsize 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "kvdb 0.1.0", + "kvdb-memorydb 0.1.0", "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "memorydb 0.1.0", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/util/journaldb/Cargo.toml b/util/journaldb/Cargo.toml index 0b537be41..a70631836 100644 --- a/util/journaldb/Cargo.toml +++ b/util/journaldb/Cargo.toml @@ -6,13 +6,18 @@ description = "A `HashDB` which can manage a short-term journal potentially cont license = "GPL3" [dependencies] -hashdb = { path = "../hashdb" } -kvdb = { path = "../kvdb" } ethcore-bigint = { path = "../bigint", features = ["heapsizeof"] } ethcore-bytes = { path = "../bytes" } -rlp = { path = "../rlp" } +hashdb = { path = "../hashdb" } +heapsize = "0.4" +kvdb = { path = "../kvdb" } +log = "0.3" memorydb = { path = "../memorydb" } parking_lot = "0.4" -heapsize = "0.4" +rlp = { path = "../rlp" } util-error = { path = "../error" } -log = "0.3" + +[dev-dependencies] +ethcore-logger = { path = "../../logger" } +hash = { path = "../hash" } +kvdb-memorydb = { path = "../kvdb-memorydb" } diff --git a/util/journaldb/src/archivedb.rs b/util/journaldb/src/archivedb.rs index 4a3225f1f..5fa1277e4 100644 --- a/util/journaldb/src/archivedb.rs +++ b/util/journaldb/src/archivedb.rs @@ -202,8 +202,7 @@ mod tests { use keccak::keccak; use hashdb::{HashDB, DBValue}; use super::*; - use journaldb::traits::JournalDB; - use kvdb_memorydb; + use {kvdb_memorydb, JournalDB}; #[test] fn insert_same_in_fork() { diff --git a/util/journaldb/src/lib.rs b/util/journaldb/src/lib.rs index d21679242..ef26cb8d6 100644 --- a/util/journaldb/src/lib.rs +++ b/util/journaldb/src/lib.rs @@ -16,16 +16,25 @@ //! `JournalDB` interface and implementation. +extern crate heapsize; +#[macro_use] +extern crate log; + extern crate ethcore_bigint as bigint; extern crate ethcore_bytes as bytes; +extern crate hashdb; +extern crate kvdb; +extern crate memorydb; extern crate parking_lot; extern crate rlp; -extern crate hashdb; -extern crate memorydb; -extern crate kvdb; extern crate util_error as error; -extern crate heapsize; -#[macro_use] extern crate log; + +#[cfg(test)] +extern crate ethcore_logger; +#[cfg(test)] +extern crate hash as keccak; +#[cfg(test)] +extern crate kvdb_memorydb; use std::{fmt, str}; use std::sync::Arc; diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index 71ce05696..b74e3adb6 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -324,7 +324,7 @@ impl JournalDB for OverlayRecentDB { trace!(target: "journaldb", "Delete journal for time #{}.{}: {}, (canon was {}): +{} -{} entries", end_era, index, journal.id, canon_id, journal.insertions.len(), journal.deletions.len()); { if *canon_id == journal.id { - for h in &journal.insertions { + for h in &journal.insertions { if let Some((d, rc)) = journal_overlay.backing_overlay.raw(&to_short_key(h)) { if rc > 0 { canon_insertions.push((h.clone(), d)); //TODO: optimize this to avoid data copy @@ -459,8 +459,7 @@ mod tests { use super::*; use hashdb::{HashDB, DBValue}; use ethcore_logger::init_log; - use journaldb::JournalDB; - use kvdb_memorydb; + use {kvdb_memorydb, JournalDB}; fn new_db() -> OverlayRecentDB { let backing = Arc::new(kvdb_memorydb::create(0)); diff --git a/util/journaldb/src/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs index b97940321..6e114e476 100644 --- a/util/journaldb/src/refcounteddb.rs +++ b/util/journaldb/src/refcounteddb.rs @@ -210,9 +210,8 @@ mod tests { use keccak::keccak; use hashdb::{HashDB, DBValue}; - use kvdb_memorydb; use super::*; - use super::super::traits::JournalDB; + use {JournalDB, kvdb_memorydb}; fn new_db() -> RefCountedDB { let backing = Arc::new(kvdb_memorydb::create(0)); From 0e912bca5b510dcb57604b4f5513bfe8984855d1 Mon Sep 17 00:00:00 2001 From: debris Date: Tue, 17 Oct 2017 10:44:05 +0200 Subject: [PATCH 6/7] bring back accidently removed whitespace --- util/journaldb/src/overlayrecentdb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/journaldb/src/overlayrecentdb.rs b/util/journaldb/src/overlayrecentdb.rs index b74e3adb6..d57e172d5 100644 --- a/util/journaldb/src/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -324,7 +324,7 @@ impl JournalDB for OverlayRecentDB { trace!(target: "journaldb", "Delete journal for time #{}.{}: {}, (canon was {}): +{} -{} entries", end_era, index, journal.id, canon_id, journal.insertions.len(), journal.deletions.len()); { if *canon_id == journal.id { - for h in &journal.insertions { + for h in &journal.insertions { if let Some((d, rc)) = journal_overlay.backing_overlay.raw(&to_short_key(h)) { if rc > 0 { canon_insertions.push((h.clone(), d)); //TODO: optimize this to avoid data copy From 153b8572ddafa2767e64cef09ce02ff71dbe3b59 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 17 Oct 2017 22:24:47 +0700 Subject: [PATCH 7/7] Fixes tests --- ethcore/src/snapshot/service.rs | 2 +- ethcore/src/snapshot/tests/helpers.rs | 2 +- ethcore/src/snapshot/tests/service.rs | 4 ++-- ethcore/src/snapshot/tests/state.rs | 2 +- ethcore/src/tests/helpers.rs | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index 7af706c90..21e7a6752 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -625,7 +625,7 @@ mod tests { use io::{IoService}; use devtools::RandomTempPath; use tests::helpers::get_test_spec; - use util::journaldb::Algorithm; + use journaldb::Algorithm; use error::Error; use snapshot::{ManifestData, RestorationStatus, SnapshotService}; use super::*; diff --git a/ethcore/src/snapshot/tests/helpers.rs b/ethcore/src/snapshot/tests/helpers.rs index cdd51a63c..a6f0cbb05 100644 --- a/ethcore/src/snapshot/tests/helpers.rs +++ b/ethcore/src/snapshot/tests/helpers.rs @@ -35,7 +35,7 @@ use util::DBValue; use kvdb::KeyValueDB; use bigint::hash::H256; use hashdb::HashDB; -use util::journaldb; +use journaldb; use trie::{Alphabet, StandardMap, SecTrieDBMut, TrieMut, ValueMode}; use trie::{TrieDB, TrieDBMut, Trie}; diff --git a/ethcore/src/snapshot/tests/service.rs b/ethcore/src/snapshot/tests/service.rs index ccaf819b0..7730d67a9 100644 --- a/ethcore/src/snapshot/tests/service.rs +++ b/ethcore/src/snapshot/tests/service.rs @@ -69,7 +69,7 @@ fn restored_is_equivalent() { engine: spec.engine.clone(), genesis_block: spec.genesis_block(), db_config: db_config, - pruning: ::util::journaldb::Algorithm::Archive, + pruning: ::journaldb::Algorithm::Archive, channel: IoChannel::disconnected(), snapshot_root: path, db_restore: client2.clone(), @@ -112,7 +112,7 @@ fn guards_delete_folders() { engine: spec.engine.clone(), genesis_block: spec.genesis_block(), db_config: DatabaseConfig::with_columns(::db::NUM_COLUMNS), - pruning: ::util::journaldb::Algorithm::Archive, + pruning: ::journaldb::Algorithm::Archive, channel: IoChannel::disconnected(), snapshot_root: path.clone(), db_restore: Arc::new(NoopDBRestore), diff --git a/ethcore/src/snapshot/tests/state.rs b/ethcore/src/snapshot/tests/state.rs index 9f9b434df..213053a68 100644 --- a/ethcore/src/snapshot/tests/state.rs +++ b/ethcore/src/snapshot/tests/state.rs @@ -26,7 +26,7 @@ use error::Error; use rand::{XorShiftRng, SeedableRng}; use bigint::hash::H256; -use util::journaldb::{self, Algorithm}; +use journaldb::{self, Algorithm}; use kvdb_rocksdb::{Database, DatabaseConfig}; use memorydb::MemoryDB; use parking_lot::Mutex; diff --git a/ethcore/src/tests/helpers.rs b/ethcore/src/tests/helpers.rs index cf14915c5..1b286df9a 100644 --- a/ethcore/src/tests/helpers.rs +++ b/ethcore/src/tests/helpers.rs @@ -36,7 +36,6 @@ use state_db::StateDB; use state::*; use std::sync::Arc; use transaction::{Action, Transaction, SignedTransaction}; -use util::*; use views::BlockView; // TODO: move everything over to get_null_spec. @@ -282,7 +281,7 @@ pub fn get_temp_state_with_factory(factory: EvmFactory) -> State<::state_db::Sta pub fn get_temp_state_db() -> StateDB { let db = new_db(); - let journal_db = journaldb::new(db, journaldb::Algorithm::EarlyMerge, ::db::COL_STATE); + let journal_db = ::journaldb::new(db, ::journaldb::Algorithm::EarlyMerge, ::db::COL_STATE); StateDB::new(journal_db, 5 * 1024 * 1024) }