From c0fc83988f05c44373626179bb6a01a53c190617 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Tue, 17 Oct 2017 11:20:24 +0700 Subject: [PATCH] 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;