From 4d3422d332e771b9bc5f553b7435664ef2e5e303 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 22 Sep 2018 15:53:31 +1000 Subject: [PATCH] Remove warnings, restructure validation files --- lighthouse/db/disk_db.rs | 4 ++++ lighthouse/db/stores/validator_store.rs | 2 +- lighthouse/state/helpers.rs | 3 --- lighthouse/state/transition/mod.rs | 8 -------- lighthouse/state/validation/mod.rs | 8 +++++++- .../validate_block.rs => validation/ssz_block.rs} | 13 ++++++------- lighthouse/utils/macros.rs | 2 +- 7 files changed, 19 insertions(+), 21 deletions(-) rename lighthouse/state/{transition/validate_block.rs => validation/ssz_block.rs} (77%) diff --git a/lighthouse/db/disk_db.rs b/lighthouse/db/disk_db.rs index 338ec4709..2b101355d 100644 --- a/lighthouse/db/disk_db.rs +++ b/lighthouse/db/disk_db.rs @@ -36,6 +36,9 @@ impl DiskDB { let mut options = Options::default(); options.create_if_missing(true); + // TODO: ensure that columns are created (and remove + // the dead_code allow) + /* * Initialise the path */ @@ -58,6 +61,7 @@ impl DiskDB { /// Create a RocksDB column family. Corresponds to the /// `create_cf()` function on the RocksDB API. + #[allow(dead_code)] fn create_col(&mut self, col: &str) -> Result<(), DBError> { diff --git a/lighthouse/db/stores/validator_store.rs b/lighthouse/db/stores/validator_store.rs index 6f095ca2b..badea16e2 100644 --- a/lighthouse/db/stores/validator_store.rs +++ b/lighthouse/db/stores/validator_store.rs @@ -21,7 +21,7 @@ impl ValidatorStore { pub fn put_validator_record_by_index(&self, hash: &[u8], val: &[u8]) -> Result<(), DBError> { - self.db.put(DB_COLUMN, hash, &vec![0]) + self.db.put(DB_COLUMN, hash, val) } pub fn get_validator_record_by_index(&self, hash: &[u8]) diff --git a/lighthouse/state/helpers.rs b/lighthouse/state/helpers.rs index 388fedafb..5ed03daf7 100644 --- a/lighthouse/state/helpers.rs +++ b/lighthouse/state/helpers.rs @@ -1,9 +1,6 @@ /* * Collection of helper functions used in the state transition modules */ -use super::active_state::ActiveState; -use super::block::Block; -use super::chain_config::ChainConfig; use super::utils::errors::ParameterError; use super::utils::types::Hash256; diff --git a/lighthouse/state/transition/mod.rs b/lighthouse/state/transition/mod.rs index de80e4961..9fe381757 100644 --- a/lighthouse/state/transition/mod.rs +++ b/lighthouse/state/transition/mod.rs @@ -1,16 +1,8 @@ -use super::block; -use super::Logger; use super::utils::types::Hash256; use super::utils::errors::ParameterError; -use super::db; mod attestation_parent_hashes; mod shuffling; -mod validate_block; pub use self::attestation_parent_hashes::attestation_parent_hashes; pub use self::shuffling::shuffle; - - - - diff --git a/lighthouse/state/validation/mod.rs b/lighthouse/state/validation/mod.rs index c11b65261..5630a96e9 100644 --- a/lighthouse/state/validation/mod.rs +++ b/lighthouse/state/validation/mod.rs @@ -1,7 +1,13 @@ +/* use super::crystallized_state::CrystallizedState; use super::active_state::ActiveState; use super::attestation_record::AttestationRecord; use super::block::Block; use super::chain_config::ChainConfig; +*/ +use super::block; +use super::Logger; +use super::db; -mod attestation_validation; +// mod attestation_validation; +mod ssz_block; diff --git a/lighthouse/state/transition/validate_block.rs b/lighthouse/state/validation/ssz_block.rs similarity index 77% rename from lighthouse/state/transition/validate_block.rs rename to lighthouse/state/validation/ssz_block.rs index c7c04e10b..5d3d9b59a 100644 --- a/lighthouse/state/transition/validate_block.rs +++ b/lighthouse/state/validation/ssz_block.rs @@ -16,7 +16,6 @@ pub enum BlockStatus { } pub enum SszBlockValidationError { - SszInvalid, FutureSlot, UnknownPoWChainRef, DatabaseError(String), @@ -28,13 +27,13 @@ impl From for SszBlockValidationError { } } - +#[allow(dead_code)] pub fn validate_ssz_block(b: &SszBlock, - expected_slot: u64, - block_store: &BlockStore, - pow_store: &PoWChainStore, - validator_store: &ValidatorStore, - log: &Logger) + expected_slot: u64, + block_store: &BlockStore, + pow_store: &PoWChainStore, + _validator_store: &ValidatorStore, + _log: &Logger) -> Result where T: Sized + ClientDB { diff --git a/lighthouse/utils/macros.rs b/lighthouse/utils/macros.rs index e6e3be01e..60bb12914 100644 --- a/lighthouse/utils/macros.rs +++ b/lighthouse/utils/macros.rs @@ -1,7 +1,7 @@ #[macro_export] macro_rules! assert_error { ($exp: expr, $err: expr) => { - if ( !$exp ) { + if !$exp { return Err($err); } }