Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Merge pull request #6801 from paritytech/refactoring/journal-6693
Browse files Browse the repository at this point in the history
Refactors journaldb as a separate crate
  • Loading branch information
debris authored Oct 18, 2017
2 parents b1df272 + 153b857 commit 5281e09
Show file tree
Hide file tree
Showing 35 changed files with 102 additions and 39 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
1 change: 1 addition & 0 deletions ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/client/evm_test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/client/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/migrations/v10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/snapshot/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/snapshot/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/snapshot/tests/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ impl Spec {
/// constructor.
pub fn genesis_epoch_data(&self) -> Result<Vec<u8>, String> {
use transaction::{Action, Transaction};
use util::journaldb;
use journaldb;
use kvdb_memorydb;

let genesis = self.genesis_header();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/state_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions ethcore/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion parity/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion parity/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions parity/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions parity/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions parity/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -326,7 +326,7 @@ pub fn mode_switch_to_bool(switch: Option<Mode>, 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};

Expand Down
2 changes: 1 addition & 1 deletion parity/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion parity/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion parity/user_defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
23 changes: 23 additions & 0 deletions util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "journaldb"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
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" }
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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() {
Expand Down
File renamed without changes.
22 changes: 22 additions & 0 deletions util/src/journaldb/mod.rs → util/journaldb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -26,6 +46,8 @@ mod earlymergedb;
mod overlayrecentdb;
mod refcounteddb;

pub mod overlaydb;

/// Export the `JournalDB` trait.
pub use self::traits::JournalDB;

Expand Down
File renamed without changes.
Loading

0 comments on commit 5281e09

Please sign in to comment.