diff --git a/Cargo.lock b/Cargo.lock index ba8b60533..2eb248e71 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,25 @@ 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", + "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)", + "rlp 0.2.0", + "util-error 0.1.0", +] + [[package]] name = "jsonrpc-core" version = "8.0.0" @@ -1941,6 +1962,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 f70333a4a..a953dcef8 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/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..21e7a6752 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; @@ -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/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/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) } 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..32353e168 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; @@ -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}; 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 { 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/journaldb/Cargo.toml b/util/journaldb/Cargo.toml new file mode 100644 index 000000000..a70631836 --- /dev/null +++ b/util/journaldb/Cargo.toml @@ -0,0 +1,23 @@ +[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] +ethcore-bigint = { path = "../bigint", features = ["heapsizeof"] } +ethcore-bytes = { path = "../bytes" } +hashdb = { path = "../hashdb" } +heapsize = "0.4" +kvdb = { path = "../kvdb" } +log = "0.3" +memorydb = { path = "../memorydb" } +parking_lot = "0.4" +rlp = { path = "../rlp" } +util-error = { path = "../error" } + +[dev-dependencies] +ethcore-logger = { path = "../../logger" } +hash = { path = "../hash" } +kvdb-memorydb = { path = "../kvdb-memorydb" } 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..5fa1277e4 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}; @@ -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/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 93% rename from util/src/journaldb/mod.rs rename to util/journaldb/src/lib.rs index c048342b2..ef26cb8d6 100644 --- a/util/src/journaldb/mod.rs +++ b/util/journaldb/src/lib.rs @@ -16,6 +16,26 @@ //! `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 util_error as error; + +#[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; @@ -26,6 +46,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 99% rename from util/src/journaldb/overlayrecentdb.rs rename to util/journaldb/src/overlayrecentdb.rs index 71ce05696..d57e172d5 100644 --- a/util/src/journaldb/overlayrecentdb.rs +++ b/util/journaldb/src/overlayrecentdb.rs @@ -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/src/journaldb/refcounteddb.rs b/util/journaldb/src/refcounteddb.rs similarity index 99% rename from util/src/journaldb/refcounteddb.rs rename to util/journaldb/src/refcounteddb.rs index b97940321..6e114e476 100644 --- a/util/src/journaldb/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)); 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 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;