diff --git a/Cargo.toml b/Cargo.toml index 893189941..00c354309 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ members = [ "eth2/utils/fisher_yates_shuffle", "eth2/utils/test_random_derive", "beacon_node", - "beacon_node/db", + "beacon_node/store", "beacon_node/client", "beacon_node/network", "beacon_node/eth2-libp2p", diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index da31bfa77..d78a5b596 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" [dependencies] types = { path = "../eth2/types" } -db = { path = "./db" } +store = { path = "./store" } client = { path = "client" } version = { path = "version" } clap = "2.32.0" diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index 34b6e11c6..3a84256a7 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] bls = { path = "../../eth2/utils/bls" } boolean-bitfield = { path = "../../eth2/utils/boolean-bitfield" } -db = { path = "../db" } +store = { path = "../store" } failure = "0.1" failure_derive = "0.1" hashing = { path = "../../eth2/utils/hashing" } diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 7c52fed5d..f2c4b3dbe 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -1,6 +1,5 @@ use crate::checkpoint::CheckPoint; use crate::errors::{BeaconChainError as Error, BlockProductionError}; -use db::{Error as DBError, Store}; use fork_choice::{ForkChoice, ForkChoiceError}; use log::{debug, trace}; use operation_pool::DepositInsertStatus; @@ -16,6 +15,7 @@ use state_processing::{ per_slot_processing, BlockProcessingError, SlotProcessingError, }; use std::sync::Arc; +use store::{Error as DBError, Store}; use types::*; #[derive(Debug, PartialEq)] diff --git a/beacon_node/beacon_chain/src/errors.rs b/beacon_node/beacon_chain/src/errors.rs index dea7f63d9..73884916a 100644 --- a/beacon_node/beacon_chain/src/errors.rs +++ b/beacon_node/beacon_chain/src/errors.rs @@ -20,7 +20,7 @@ pub enum BeaconChainError { UnableToReadSlot, BeaconStateError(BeaconStateError), DBInconsistent(String), - DBError(db::Error), + DBError(store::Error), ForkChoiceError(ForkChoiceError), MissingBeaconBlock(Hash256), MissingBeaconState(Hash256), diff --git a/beacon_node/beacon_chain/src/initialise.rs b/beacon_node/beacon_chain/src/initialise.rs index 197f7ace0..b9d950ed5 100644 --- a/beacon_node/beacon_chain/src/initialise.rs +++ b/beacon_node/beacon_chain/src/initialise.rs @@ -3,11 +3,11 @@ // testnet. These are examples. Also. there is code duplication which can/should be cleaned up. use crate::BeaconChain; -use db::{DiskDB, MemoryDB}; use fork_choice::BitwiseLMDGhost; use slot_clock::SystemTimeSlotClock; use std::path::PathBuf; use std::sync::Arc; +use store::{DiskStore, MemoryStore}; use tree_hash::TreeHash; use types::test_utils::TestingBeaconStateBuilder; use types::{BeaconBlock, ChainSpec, FewValidatorsEthSpec, FoundationEthSpec, Hash256}; @@ -19,14 +19,14 @@ pub fn initialise_beacon_chain( db_name: Option<&PathBuf>, ) -> Arc< BeaconChain< - DiskDB, + DiskStore, SystemTimeSlotClock, - BitwiseLMDGhost, + BitwiseLMDGhost, FoundationEthSpec, >, > { let path = db_name.expect("db_name cannot be None."); - let store = DiskDB::open(path).expect("Unable to open DB."); + let store = DiskStore::open(path).expect("Unable to open DB."); let store = Arc::new(store); let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, &spec); @@ -66,13 +66,13 @@ pub fn initialise_test_beacon_chain_with_memory_db( _db_name: Option<&PathBuf>, ) -> Arc< BeaconChain< - MemoryDB, + MemoryStore, SystemTimeSlotClock, - BitwiseLMDGhost, + BitwiseLMDGhost, FewValidatorsEthSpec, >, > { - let store = Arc::new(MemoryDB::open()); + let store = Arc::new(MemoryStore::open()); let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, spec); let (genesis_state, _keypairs) = state_builder.build(); @@ -111,14 +111,14 @@ pub fn initialise_test_beacon_chain_with_disk_db( db_name: Option<&PathBuf>, ) -> Arc< BeaconChain< - DiskDB, + DiskStore, SystemTimeSlotClock, - BitwiseLMDGhost, + BitwiseLMDGhost, FewValidatorsEthSpec, >, > { let path = db_name.expect("db_name cannot be None."); - let store = DiskDB::open(path).expect("Unable to open DB."); + let store = DiskStore::open(path).expect("Unable to open DB."); let store = Arc::new(store); let state_builder = TestingBeaconStateBuilder::from_default_keypairs_file_if_exists(8, spec); diff --git a/beacon_node/beacon_chain/src/lib.rs b/beacon_node/beacon_chain/src/lib.rs index d8d85a8a6..6ac01a5d5 100644 --- a/beacon_node/beacon_chain/src/lib.rs +++ b/beacon_node/beacon_chain/src/lib.rs @@ -7,7 +7,6 @@ pub mod test_utils; pub use self::beacon_chain::{BeaconChain, BlockProcessingOutcome, InvalidBlock, ValidBlock}; pub use self::checkpoint::CheckPoint; pub use self::errors::{BeaconChainError, BlockProductionError}; -pub use db; pub use fork_choice; pub use parking_lot; pub use slot_clock; @@ -15,4 +14,5 @@ pub use state_processing::per_block_processing::errors::{ AttestationValidationError, AttesterSlashingValidationError, DepositValidationError, ExitValidationError, ProposerSlashingValidationError, TransferValidationError, }; +pub use store; pub use types; diff --git a/beacon_node/beacon_chain/src/test_utils/testing_beacon_chain_builder.rs b/beacon_node/beacon_chain/src/test_utils/testing_beacon_chain_builder.rs index ce3588674..b6b1defcc 100644 --- a/beacon_node/beacon_chain/src/test_utils/testing_beacon_chain_builder.rs +++ b/beacon_node/beacon_chain/src/test_utils/testing_beacon_chain_builder.rs @@ -1,14 +1,18 @@ pub use crate::{BeaconChain, BeaconChainError, CheckPoint}; -use db::MemoryDB; use fork_choice::BitwiseLMDGhost; use slot_clock::TestingSlotClock; use std::sync::Arc; +use store::MemoryStore; use tree_hash::TreeHash; use types::*; use types::{test_utils::TestingBeaconStateBuilder, EthSpec, FewValidatorsEthSpec}; -type TestingBeaconChain = - BeaconChain, E>; +type TestingBeaconChain = BeaconChain< + MemoryStore, + TestingSlotClock, + BitwiseLMDGhost, + E, +>; pub struct TestingBeaconChainBuilder { state_builder: TestingBeaconStateBuilder, @@ -16,7 +20,7 @@ pub struct TestingBeaconChainBuilder { impl TestingBeaconChainBuilder { pub fn build(self, spec: &ChainSpec) -> TestingBeaconChain { - let store = Arc::new(MemoryDB::open()); + let store = Arc::new(MemoryStore::open()); let slot_clock = TestingSlotClock::new(spec.genesis_slot.as_u64()); let fork_choice = BitwiseLMDGhost::new(store.clone()); diff --git a/beacon_node/client/Cargo.toml b/beacon_node/client/Cargo.toml index 8956dbb07..4a976eec4 100644 --- a/beacon_node/client/Cargo.toml +++ b/beacon_node/client/Cargo.toml @@ -7,7 +7,7 @@ edition = "2018" [dependencies] beacon_chain = { path = "../beacon_chain" } network = { path = "../network" } -db = { path = "../db" } +store = { path = "../store" } rpc = { path = "../rpc" } fork_choice = { path = "../../eth2/fork_choice" } types = { path = "../../eth2/types" } diff --git a/beacon_node/client/src/client_types.rs b/beacon_node/client/src/client_types.rs index c54028d28..4cce42a06 100644 --- a/beacon_node/client/src/client_types.rs +++ b/beacon_node/client/src/client_types.rs @@ -1,9 +1,9 @@ use crate::{ArcBeaconChain, ClientConfig}; use beacon_chain::{ - db::{DiskDB, MemoryDB, Store}, fork_choice::BitwiseLMDGhost, initialise, slot_clock::{SlotClock, SystemTimeSlotClock}, + store::{DiskStore, MemoryStore, Store}, }; use fork_choice::ForkChoice; use types::{EthSpec, FewValidatorsEthSpec, FoundationEthSpec}; @@ -22,7 +22,7 @@ pub trait ClientTypes { pub struct StandardClientType; impl ClientTypes for StandardClientType { - type DB = DiskDB; + type DB = DiskStore; type SlotClock = SystemTimeSlotClock; type ForkChoice = BitwiseLMDGhost; type EthSpec = FoundationEthSpec; @@ -34,10 +34,10 @@ impl ClientTypes for StandardClientType { } } -pub struct MemoryDBTestingClientType; +pub struct MemoryStoreTestingClientType; -impl ClientTypes for MemoryDBTestingClientType { - type DB = MemoryDB; +impl ClientTypes for MemoryStoreTestingClientType { + type DB = MemoryStore; type SlotClock = SystemTimeSlotClock; type ForkChoice = BitwiseLMDGhost; type EthSpec = FewValidatorsEthSpec; @@ -49,10 +49,10 @@ impl ClientTypes for MemoryDBTestingClientType { } } -pub struct DiskDBTestingClientType; +pub struct DiskStoreTestingClientType; -impl ClientTypes for DiskDBTestingClientType { - type DB = DiskDB; +impl ClientTypes for DiskStoreTestingClientType { + type DB = DiskStore; type SlotClock = SystemTimeSlotClock; type ForkChoice = BitwiseLMDGhost; type EthSpec = FewValidatorsEthSpec; diff --git a/beacon_node/client/src/lib.rs b/beacon_node/client/src/lib.rs index 00478b475..71d4013d3 100644 --- a/beacon_node/client/src/lib.rs +++ b/beacon_node/client/src/lib.rs @@ -8,7 +8,6 @@ pub mod notifier; use beacon_chain::BeaconChain; pub use client_config::{ClientConfig, DBType}; pub use client_types::ClientTypes; -use db::Store; use exit_future::Signal; use fork_choice::ForkChoice; use futures::{future::Future, Stream}; @@ -18,6 +17,7 @@ use slot_clock::SlotClock; use std::marker::PhantomData; use std::sync::Arc; use std::time::{Duration, Instant}; +use store::Store; use tokio::runtime::TaskExecutor; use tokio::timer::Interval; use types::EthSpec; diff --git a/beacon_node/network/src/beacon_chain.rs b/beacon_node/network/src/beacon_chain.rs index f123e4540..2a42376f7 100644 --- a/beacon_node/network/src/beacon_chain.rs +++ b/beacon_node/network/src/beacon_chain.rs @@ -1,9 +1,9 @@ use beacon_chain::BeaconChain as RawBeaconChain; use beacon_chain::{ - db::Store, fork_choice::ForkChoice, parking_lot::RwLockReadGuard, slot_clock::SlotClock, + store::Store, types::{BeaconState, ChainSpec}, AttestationValidationError, CheckPoint, }; diff --git a/beacon_node/rpc/Cargo.toml b/beacon_node/rpc/Cargo.toml index 3fc52c6b1..a361c94ab 100644 --- a/beacon_node/rpc/Cargo.toml +++ b/beacon_node/rpc/Cargo.toml @@ -17,7 +17,7 @@ protos = { path = "../../protos" } grpcio = { version = "0.4", default-features = false, features = ["protobuf-codec"] } protobuf = "2.0.2" clap = "2.32.0" -db = { path = "../db" } +store = { path = "../store" } dirs = "1.0.3" futures = "0.1.23" slog = "^2.2.3" diff --git a/beacon_node/rpc/src/beacon_chain.rs b/beacon_node/rpc/src/beacon_chain.rs index 9b6b05e9d..d12baf1d1 100644 --- a/beacon_node/rpc/src/beacon_chain.rs +++ b/beacon_node/rpc/src/beacon_chain.rs @@ -1,9 +1,9 @@ use beacon_chain::BeaconChain as RawBeaconChain; use beacon_chain::{ - db::Store, fork_choice::ForkChoice, parking_lot::{RwLockReadGuard, RwLockWriteGuard}, slot_clock::SlotClock, + store::Store, types::{BeaconState, ChainSpec, Signature}, AttestationValidationError, BlockProductionError, }; diff --git a/beacon_node/src/run.rs b/beacon_node/src/run.rs index ec421fc6e..4cf930060 100644 --- a/beacon_node/src/run.rs +++ b/beacon_node/src/run.rs @@ -1,4 +1,4 @@ -use client::client_types::{DiskDBTestingClientType, MemoryDBTestingClientType}; +use client::client_types::{DiskStoreTestingClientType, MemoryStoreTestingClientType}; use client::{error, DBType}; use client::{notifier, Client, ClientConfig, ClientTypes}; use futures::sync::oneshot; @@ -29,9 +29,9 @@ pub fn run_beacon_node(config: ClientConfig, log: &slog::Logger) -> error::Resul info!( log, "BeaconNode starting"; - "type" => "DiskDBTestingClientType" + "type" => "DiskStoreTestingClientType" ); - let client: Client = + let client: Client = Client::new(config, log.clone(), &executor)?; run(client, executor, runtime, log) @@ -40,9 +40,9 @@ pub fn run_beacon_node(config: ClientConfig, log: &slog::Logger) -> error::Resul info!( log, "BeaconNode starting"; - "type" => "MemoryDBTestingClientType" + "type" => "MemoryStoreTestingClientType" ); - let client: Client = + let client: Client = Client::new(config, log.clone(), &executor)?; run(client, executor, runtime, log) diff --git a/beacon_node/db/Cargo.toml b/beacon_node/store/Cargo.toml similarity index 96% rename from beacon_node/db/Cargo.toml rename to beacon_node/store/Cargo.toml index 808d420a5..a95dafa90 100644 --- a/beacon_node/db/Cargo.toml +++ b/beacon_node/store/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "db" +name = "store" version = "0.1.0" authors = ["Paul Hauner "] edition = "2018" diff --git a/beacon_node/db/src/block_at_slot.rs b/beacon_node/store/src/block_at_slot.rs similarity index 98% rename from beacon_node/db/src/block_at_slot.rs rename to beacon_node/store/src/block_at_slot.rs index 4fa9635a2..4a8abaefd 100644 --- a/beacon_node/db/src/block_at_slot.rs +++ b/beacon_node/store/src/block_at_slot.rs @@ -121,7 +121,7 @@ mod tests { #[test] fn chain_without_skips() { let n: usize = 10; - let store = MemoryDB::open(); + let store = MemoryStore::open(); let spec = FewValidatorsEthSpec::spec(); let slots: Vec = (0..n).collect(); @@ -145,7 +145,7 @@ mod tests { #[test] fn chain_with_skips() { - let store = MemoryDB::open(); + let store = MemoryStore::open(); let spec = FewValidatorsEthSpec::spec(); let slots = vec![0, 1, 2, 5]; diff --git a/beacon_node/db/src/disk_db.rs b/beacon_node/store/src/disk_db.rs similarity index 97% rename from beacon_node/db/src/disk_db.rs rename to beacon_node/store/src/disk_db.rs index e2162e29a..eb2b885c6 100644 --- a/beacon_node/db/src/disk_db.rs +++ b/beacon_node/store/src/disk_db.rs @@ -10,11 +10,11 @@ use std::path::Path; /// A on-disk database which implements the ClientDB trait. /// /// This implementation uses RocksDB with default options. -pub struct DiskDB { +pub struct DiskStore { db: DB, } -impl DiskDB { +impl DiskStore { /// Open the RocksDB database, optionally supplying columns if required. /// /// The RocksDB database will be contained in a directory titled @@ -71,7 +71,7 @@ impl From for DBError { } } -impl ClientDB for DiskDB { +impl ClientDB for DiskStore { /// Get the value for some key on some column. /// /// Corresponds to the `get_cf()` method on the RocksDB API. @@ -154,7 +154,7 @@ mod tests { let col_name: &str = "TestColumn"; let column_families = vec![col_name]; - let mut db = DiskDB::open(&path, None); + let mut db = DiskStore::open(&path, None); for cf in column_families { db.create_col(&cf).unwrap(); diff --git a/beacon_node/db/src/errors.rs b/beacon_node/store/src/errors.rs similarity index 100% rename from beacon_node/db/src/errors.rs rename to beacon_node/store/src/errors.rs diff --git a/beacon_node/db/src/impls.rs b/beacon_node/store/src/impls.rs similarity index 100% rename from beacon_node/db/src/impls.rs rename to beacon_node/store/src/impls.rs diff --git a/beacon_node/db/src/leveldb_store.rs b/beacon_node/store/src/leveldb_store.rs similarity index 100% rename from beacon_node/db/src/leveldb_store.rs rename to beacon_node/store/src/leveldb_store.rs diff --git a/beacon_node/db/src/lib.rs b/beacon_node/store/src/lib.rs similarity index 95% rename from beacon_node/db/src/lib.rs rename to beacon_node/store/src/lib.rs index 708ac698f..096a88184 100644 --- a/beacon_node/db/src/lib.rs +++ b/beacon_node/store/src/lib.rs @@ -5,8 +5,8 @@ mod impls; mod leveldb_store; mod memory_db; -pub use self::leveldb_store::LevelDB as DiskDB; -pub use self::memory_db::MemoryDB; +pub use self::leveldb_store::LevelDB as DiskStore; +pub use self::memory_db::MemoryStore; pub use errors::Error; pub use types::*; pub type DBValue = Vec; @@ -154,21 +154,21 @@ mod tests { fn diskdb() { let dir = tempdir().unwrap(); let path = dir.path(); - let store = DiskDB::open(&path).unwrap(); + let store = DiskStore::open(&path).unwrap(); test_impl(store); } #[test] fn memorydb() { - let store = MemoryDB::open(); + let store = MemoryStore::open(); test_impl(store); } #[test] fn exists() { - let store = MemoryDB::open(); + let store = MemoryStore::open(); let key = Hash256::random(); let item = StorableThing { a: 1, b: 42 }; diff --git a/beacon_node/db/src/memory_db.rs b/beacon_node/store/src/memory_db.rs similarity index 79% rename from beacon_node/db/src/memory_db.rs rename to beacon_node/store/src/memory_db.rs index 83ff77ce1..38b0c0698 100644 --- a/beacon_node/db/src/memory_db.rs +++ b/beacon_node/store/src/memory_db.rs @@ -4,11 +4,11 @@ use std::collections::HashMap; type DBHashMap = HashMap, Vec>; -pub struct MemoryDB { +pub struct MemoryStore { db: RwLock, } -impl MemoryDB { +impl MemoryStore { pub fn open() -> Self { Self { db: RwLock::new(HashMap::new()), @@ -22,10 +22,10 @@ impl MemoryDB { } } -impl Store for MemoryDB { +impl Store for MemoryStore { /// Get the value of some key from the database. Returns `None` if the key does not exist. fn get_bytes(&self, col: &str, key: &[u8]) -> Result, Error> { - let column_key = MemoryDB::get_key_for_col(col, key); + let column_key = MemoryStore::get_key_for_col(col, key); Ok(self .db @@ -36,7 +36,7 @@ impl Store for MemoryDB { /// Puts a key in the database. fn put_bytes(&self, col: &str, key: &[u8], val: &[u8]) -> Result<(), Error> { - let column_key = MemoryDB::get_key_for_col(col, key); + let column_key = MemoryStore::get_key_for_col(col, key); self.db.write().insert(column_key, val.to_vec()); @@ -45,14 +45,14 @@ impl Store for MemoryDB { /// Return true if some key exists in some column. fn key_exists(&self, col: &str, key: &[u8]) -> Result { - let column_key = MemoryDB::get_key_for_col(col, key); + let column_key = MemoryStore::get_key_for_col(col, key); Ok(self.db.read().contains_key(&column_key)) } /// Delete some key from the database. fn key_delete(&self, col: &str, key: &[u8]) -> Result<(), Error> { - let column_key = MemoryDB::get_key_for_col(col, key); + let column_key = MemoryStore::get_key_for_col(col, key); self.db.write().remove(&column_key); diff --git a/eth2/fork_choice/Cargo.toml b/eth2/fork_choice/Cargo.toml index 819b84055..f2e6825ed 100644 --- a/eth2/fork_choice/Cargo.toml +++ b/eth2/fork_choice/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Age Manning "] edition = "2018" [dependencies] -db = { path = "../../beacon_node/db" } +store = { path = "../../beacon_node/store" } ssz = { path = "../utils/ssz" } types = { path = "../types" } log = "0.4.6" diff --git a/eth2/fork_choice/src/bitwise_lmd_ghost.rs b/eth2/fork_choice/src/bitwise_lmd_ghost.rs index a76970f01..0e579c0b9 100644 --- a/eth2/fork_choice/src/bitwise_lmd_ghost.rs +++ b/eth2/fork_choice/src/bitwise_lmd_ghost.rs @@ -1,13 +1,11 @@ //! The optimised bitwise LMD-GHOST fork choice rule. -extern crate bit_vec; - use crate::{ForkChoice, ForkChoiceError}; use bit_vec::BitVec; -use db::Store; use log::{debug, trace}; use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; +use store::Store; use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot, SlotHeight}; //TODO: Pruning - Children diff --git a/eth2/fork_choice/src/lib.rs b/eth2/fork_choice/src/lib.rs index ed3a1ce08..ffc40e6c6 100644 --- a/eth2/fork_choice/src/lib.rs +++ b/eth2/fork_choice/src/lib.rs @@ -21,9 +21,9 @@ pub mod longest_chain; pub mod optimized_lmd_ghost; pub mod slow_lmd_ghost; -// use db::stores::BeaconBlockAtSlotError; -// use db::DBError; -use db::Error as DBError; +// use store::stores::BeaconBlockAtSlotError; +// use store::DBError; +use store::Error as DBError; use types::{BeaconBlock, ChainSpec, Hash256}; pub use bitwise_lmd_ghost::BitwiseLMDGhost; diff --git a/eth2/fork_choice/src/longest_chain.rs b/eth2/fork_choice/src/longest_chain.rs index 6aaf56c32..11453cf49 100644 --- a/eth2/fork_choice/src/longest_chain.rs +++ b/eth2/fork_choice/src/longest_chain.rs @@ -1,6 +1,6 @@ use crate::{ForkChoice, ForkChoiceError}; -use db::Store; use std::sync::Arc; +use store::Store; use types::{BeaconBlock, ChainSpec, Hash256, Slot}; pub struct LongestChain { diff --git a/eth2/fork_choice/src/optimized_lmd_ghost.rs b/eth2/fork_choice/src/optimized_lmd_ghost.rs index aa7d65c85..dba6e60da 100644 --- a/eth2/fork_choice/src/optimized_lmd_ghost.rs +++ b/eth2/fork_choice/src/optimized_lmd_ghost.rs @@ -1,13 +1,11 @@ //! The optimised bitwise LMD-GHOST fork choice rule. -extern crate bit_vec; - use crate::{ForkChoice, ForkChoiceError}; -use db::Store; use log::{debug, trace}; use std::cmp::Ordering; use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; +use store::Store; use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot, SlotHeight}; //TODO: Pruning - Children diff --git a/eth2/fork_choice/src/slow_lmd_ghost.rs b/eth2/fork_choice/src/slow_lmd_ghost.rs index a41eacbb2..888356417 100644 --- a/eth2/fork_choice/src/slow_lmd_ghost.rs +++ b/eth2/fork_choice/src/slow_lmd_ghost.rs @@ -1,11 +1,9 @@ -extern crate db; - use crate::{ForkChoice, ForkChoiceError}; -use db::Store; use log::{debug, trace}; use std::collections::HashMap; use std::marker::PhantomData; use std::sync::Arc; +use store::Store; use types::{BeaconBlock, BeaconState, ChainSpec, EthSpec, Hash256, Slot}; //TODO: Pruning and syncing diff --git a/eth2/fork_choice/tests/tests.rs b/eth2/fork_choice/tests/tests.rs index b4f4ede2c..0327e8cb3 100644 --- a/eth2/fork_choice/tests/tests.rs +++ b/eth2/fork_choice/tests/tests.rs @@ -1,26 +1,14 @@ #![cfg(not(debug_assertions))] // Tests the available fork-choice algorithms -extern crate beacon_chain; -extern crate bls; -extern crate db; -// extern crate env_logger; // for debugging -extern crate fork_choice; -extern crate hex; -extern crate log; -extern crate slot_clock; -extern crate types; -extern crate yaml_rust; - pub use beacon_chain::BeaconChain; use bls::Signature; -use db::MemoryDB; -use db::Store; +use store::MemoryStore; +use store::Store; // use env_logger::{Builder, Env}; use fork_choice::{ BitwiseLMDGhost, ForkChoice, ForkChoiceAlgorithm, LongestChain, OptimizedLMDGhost, SlowLMDGhost, }; -use ssz::ssz_encode; use std::collections::HashMap; use std::sync::Arc; use std::{fs::File, io::prelude::*, path::PathBuf}; @@ -220,23 +208,23 @@ fn load_test_cases_from_yaml(file_path: &str) -> Vec { fn setup_inital_state( fork_choice_algo: &ForkChoiceAlgorithm, num_validators: usize, -) -> (Box, Arc, Hash256) { - let store = Arc::new(MemoryDB::open()); +) -> (Box, Arc, Hash256) { + let store = Arc::new(MemoryStore::open()); // the fork choice instantiation let fork_choice: Box = match fork_choice_algo { ForkChoiceAlgorithm::OptimizedLMDGhost => { - let f: OptimizedLMDGhost = + let f: OptimizedLMDGhost = OptimizedLMDGhost::new(store.clone()); Box::new(f) } ForkChoiceAlgorithm::BitwiseLMDGhost => { - let f: BitwiseLMDGhost = + let f: BitwiseLMDGhost = BitwiseLMDGhost::new(store.clone()); Box::new(f) } ForkChoiceAlgorithm::SlowLMDGhost => { - let f: SlowLMDGhost = SlowLMDGhost::new(store.clone()); + let f: SlowLMDGhost = SlowLMDGhost::new(store.clone()); Box::new(f) } ForkChoiceAlgorithm::LongestChain => Box::new(LongestChain::new(store.clone())),