From 0c01db4a493d01ff2056abe0e724154432a608af Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 17 Jan 2018 22:11:13 +0100 Subject: [PATCH] separated ethcore_migrations from ethcore (#7586) * separated ethcore_migrations from ethcore * fixed authorship nitpick * make ethcore_migrations related exports and imports more consistent --- Cargo.lock | 20 +++++++++++++++++++ Cargo.toml | 1 + ethcore/migrations/Cargo.toml | 19 ++++++++++++++++++ .../src}/blocks/mod.rs | 0 .../src}/blocks/v8.rs | 0 .../src}/extras/mod.rs | 0 .../src}/extras/v6.rs | 0 .../mod.rs => migrations/src/lib.rs} | 16 +++++++++++++++ .../src}/state/mod.rs | 0 .../migrations => migrations/src}/state/v7.rs | 0 .../{src/migrations => migrations/src}/v10.rs | 6 +++--- .../{src/migrations => migrations/src}/v9.rs | 0 ethcore/src/lib.rs | 3 +-- ethcore/src/state_db.rs | 9 +++++++++ parity/main.rs | 1 + parity/migration.rs | 5 ++--- 16 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 ethcore/migrations/Cargo.toml rename ethcore/{src/migrations => migrations/src}/blocks/mod.rs (100%) rename ethcore/{src/migrations => migrations/src}/blocks/v8.rs (100%) rename ethcore/{src/migrations => migrations/src}/extras/mod.rs (100%) rename ethcore/{src/migrations => migrations/src}/extras/v6.rs (100%) rename ethcore/{src/migrations/mod.rs => migrations/src/lib.rs} (76%) rename ethcore/{src/migrations => migrations/src}/state/mod.rs (100%) rename ethcore/{src/migrations => migrations/src}/state/v7.rs (100%) rename ethcore/{src/migrations => migrations/src}/v10.rs (95%) rename ethcore/{src/migrations => migrations/src}/v9.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index acebbfba7..7cd4e04d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -591,6 +591,25 @@ dependencies = [ "time 0.1.38 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ethcore-migrations" +version = "0.1.0" +dependencies = [ + "ethcore 1.9.0", + "ethcore-bloom-journal 0.1.0", + "ethcore-bytes 0.1.0", + "ethereum-types 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "journaldb 0.1.0", + "keccak-hash 0.1.0", + "kvdb 0.1.0", + "kvdb-rocksdb 0.1.0", + "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "macros 0.1.0", + "migration 0.1.0", + "patricia-trie 0.1.0", + "rlp 0.2.1", +] + [[package]] name = "ethcore-miner" version = "1.9.0" @@ -1923,6 +1942,7 @@ dependencies = [ "ethcore-io 1.9.0", "ethcore-light 1.9.0", "ethcore-logger 1.9.0", + "ethcore-migrations 0.1.0", "ethcore-miner 1.9.0", "ethcore-network 1.9.0", "ethcore-secretstore 1.0.0", diff --git a/Cargo.toml b/Cargo.toml index 354a9631d..ccaed878b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,6 +39,7 @@ ethcore-devtools = { path = "devtools" } ethcore-io = { path = "util/io" } ethcore-light = { path = "ethcore/light" } ethcore-logger = { path = "logger" } +ethcore-migrations = { path = "ethcore/migrations" } ethcore-miner = { path = "miner" } ethcore-network = { path = "util/network" } ethcore-stratum = { path = "stratum" } diff --git a/ethcore/migrations/Cargo.toml b/ethcore/migrations/Cargo.toml new file mode 100644 index 000000000..8b8c58842 --- /dev/null +++ b/ethcore/migrations/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "ethcore-migrations" +version = "0.1.0" +authors = ["Parity Technologies "] + +[dependencies] +ethcore-bytes = { path = "../../util/bytes" } +ethereum-types = "0.1.4" +keccak-hash = { path = "../../util/hash" } +kvdb = { path = "../../util/kvdb" } +kvdb-rocksdb = { path = "../../util/kvdb-rocksdb" } +log = "0.3" +macros = { path = "../../util/macros" } +migration = { path = "../../util/migration" } +rlp = { path = "../../util/rlp" } +patricia-trie = { path = "../../util/patricia_trie" } +journaldb = { path = "../../util/journaldb" } +ethcore-bloom-journal = { path = "../../util/bloom" } +ethcore = { path = ".." } diff --git a/ethcore/src/migrations/blocks/mod.rs b/ethcore/migrations/src/blocks/mod.rs similarity index 100% rename from ethcore/src/migrations/blocks/mod.rs rename to ethcore/migrations/src/blocks/mod.rs diff --git a/ethcore/src/migrations/blocks/v8.rs b/ethcore/migrations/src/blocks/v8.rs similarity index 100% rename from ethcore/src/migrations/blocks/v8.rs rename to ethcore/migrations/src/blocks/v8.rs diff --git a/ethcore/src/migrations/extras/mod.rs b/ethcore/migrations/src/extras/mod.rs similarity index 100% rename from ethcore/src/migrations/extras/mod.rs rename to ethcore/migrations/src/extras/mod.rs diff --git a/ethcore/src/migrations/extras/v6.rs b/ethcore/migrations/src/extras/v6.rs similarity index 100% rename from ethcore/src/migrations/extras/v6.rs rename to ethcore/migrations/src/extras/v6.rs diff --git a/ethcore/src/migrations/mod.rs b/ethcore/migrations/src/lib.rs similarity index 76% rename from ethcore/src/migrations/mod.rs rename to ethcore/migrations/src/lib.rs index fc4975f10..44cc3045f 100644 --- a/ethcore/src/migrations/mod.rs +++ b/ethcore/migrations/src/lib.rs @@ -16,6 +16,22 @@ //! Database migrations. +#[macro_use] +extern crate log; +#[macro_use] +extern crate macros; +extern crate migration; +extern crate rlp; +extern crate ethereum_types; +extern crate ethcore_bytes as bytes; +extern crate kvdb; +extern crate kvdb_rocksdb; +extern crate keccak_hash as hash; +extern crate journaldb; +extern crate ethcore_bloom_journal as bloom_journal; +extern crate ethcore; +extern crate patricia_trie as trie; + use migration::ChangeColumns; pub mod state; diff --git a/ethcore/src/migrations/state/mod.rs b/ethcore/migrations/src/state/mod.rs similarity index 100% rename from ethcore/src/migrations/state/mod.rs rename to ethcore/migrations/src/state/mod.rs diff --git a/ethcore/src/migrations/state/v7.rs b/ethcore/migrations/src/state/v7.rs similarity index 100% rename from ethcore/src/migrations/state/v7.rs rename to ethcore/migrations/src/state/v7.rs diff --git a/ethcore/src/migrations/v10.rs b/ethcore/migrations/src/v10.rs similarity index 95% rename from ethcore/src/migrations/v10.rs rename to ethcore/migrations/src/v10.rs index 8b7ad0e68..8caf97192 100644 --- a/ethcore/src/migrations/v10.rs +++ b/ethcore/migrations/src/v10.rs @@ -17,10 +17,10 @@ //! Bloom upgrade use std::sync::Arc; -use db::{COL_EXTRA, COL_HEADERS, COL_STATE}; -use state_db::{ACCOUNT_BLOOM_SPACE, DEFAULT_ACCOUNT_PRESET, StateDB}; +use ethcore::db::{COL_EXTRA, COL_HEADERS, COL_STATE}; +use ethcore::state_db::{ACCOUNT_BLOOM_SPACE, DEFAULT_ACCOUNT_PRESET, StateDB}; use trie::TrieDB; -use views::HeaderView; +use ethcore::views::HeaderView; use bloom_journal::Bloom; use migration::{Error, Migration, Progress, Batch, Config, ErrorKind}; use journaldb; diff --git a/ethcore/src/migrations/v9.rs b/ethcore/migrations/src/v9.rs similarity index 100% rename from ethcore/src/migrations/v9.rs rename to ethcore/migrations/src/v9.rs diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index 19acaa516..12ee0e45f 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -138,13 +138,13 @@ pub mod ethereum; pub mod executed; pub mod header; pub mod machine; -pub mod migrations; pub mod miner; pub mod pod_state; pub mod service; pub mod snapshot; pub mod spec; pub mod state; +pub mod state_db; pub mod timer; pub mod trace; pub mod verification; @@ -153,7 +153,6 @@ pub mod views; mod cache_manager; mod blooms; mod pod_account; -mod state_db; mod account_db; mod builtin; mod executive; diff --git a/ethcore/src/state_db.rs b/ethcore/src/state_db.rs index 99ee5ed6e..c315875fd 100644 --- a/ethcore/src/state_db.rs +++ b/ethcore/src/state_db.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Parity. If not, see . +//! State database abstraction. + use std::collections::{VecDeque, HashSet}; use std::sync::Arc; use lru_cache::LruCache; @@ -31,9 +33,13 @@ use bloom_journal::{Bloom, BloomJournal}; use db::COL_ACCOUNT_BLOOM; use byteorder::{LittleEndian, ByteOrder}; +/// Number of bytes allocated in the memory for accounts bloom. pub const ACCOUNT_BLOOM_SPACE: usize = 1048576; + +/// Estimated maximum number of accounts in memory bloom. pub const DEFAULT_ACCOUNT_PRESET: usize = 1000000; +/// Database key represening number of account hashes. pub const ACCOUNT_BLOOM_HASHCOUNT_KEY: &'static [u8] = b"account_hash_count"; const STATE_CACHE_BLOCKS: usize = 12; @@ -169,6 +175,7 @@ impl StateDB { bloom } + /// Commit bloom to a database transaction pub fn commit_bloom(batch: &mut DBTransaction, journal: BloomJournal) -> Result<(), UtilError> { assert!(journal.hash_functions <= 255); batch.put(COL_ACCOUNT_BLOOM, ACCOUNT_BLOOM_HASHCOUNT_KEY, &[journal.hash_functions as u8]); @@ -298,10 +305,12 @@ impl StateDB { } } + /// Returns immutable reference to underlying hashdb. pub fn as_hashdb(&self) -> &HashDB { self.db.as_hashdb() } + /// Returns mutable reference to underlying hashdb. pub fn as_hashdb_mut(&mut self) -> &mut HashDB { self.db.as_hashdb_mut() } diff --git a/parity/main.rs b/parity/main.rs index ad3f786b1..2aa218d00 100644 --- a/parity/main.rs +++ b/parity/main.rs @@ -52,6 +52,7 @@ extern crate ethcore_devtools as devtools; extern crate ethcore_io as io; extern crate ethcore_light as light; extern crate ethcore_logger; +extern crate ethcore_migrations as migrations; extern crate ethcore_miner as miner; extern crate ethcore_network as network; extern crate ethcore_transaction as transaction; diff --git a/parity/migration.rs b/parity/migration.rs index df91c2624..60a2afb4c 100644 --- a/parity/migration.rs +++ b/parity/migration.rs @@ -24,9 +24,8 @@ use journaldb::Algorithm; use migr::{self, Manager as MigrationManager, Config as MigrationConfig, Migration}; use kvdb; use kvdb_rocksdb::{CompactionProfile, Database, DatabaseConfig}; -use ethcore::migrations; +use migrations::{self, Extract}; use ethcore::db; -use ethcore::migrations::Extract; /// Database is assumed to be at default version, when no version file is found. const DEFAULT_VERSION: u32 = 5; @@ -284,7 +283,7 @@ mod legacy { use std::path::{Path, PathBuf}; use migr::{Manager as MigrationManager}; use kvdb_rocksdb::CompactionProfile; - use ethcore::migrations; + use migrations; /// Blocks database path. pub fn blocks_database_path(path: &Path) -> PathBuf {