diff --git a/Cargo.toml b/Cargo.toml index eaca0fd61..c076461c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ ethereum-types = "0.4.0" futures = "0.1.23" network-libp2p = { path = "network-libp2p" } rand = "0.3" +rayon = "1.0.2" rocksdb = "0.10.1" rlp = { git = "https://github.com/paritytech/parity-common" } slog = "^2.2.3" diff --git a/lighthouse/state/block/validation/validate_ssz_block.rs b/lighthouse/state/block/validation/validate_ssz_block.rs index ada0be5a4..1067798db 100644 --- a/lighthouse/state/block/validation/validate_ssz_block.rs +++ b/lighthouse/state/block/validation/validate_ssz_block.rs @@ -1,3 +1,6 @@ +extern crate rayon; +use self::rayon::prelude::*; + use std::sync::{ Arc, RwLock, @@ -48,6 +51,7 @@ pub enum SszBlockValidationError { FirstAttestationSignatureFailed, NoProposerSignature, BadProposerMap, + RwLockPoisoned, DatabaseError(String), } @@ -175,7 +179,7 @@ pub fn validate_ssz_block(b: &SszBlock, */ let failure: Option = None; let failure = RwLock::new(failure); - other_attestations.iter() + other_attestations.par_iter() .for_each(|attestation| { if let Some(_) = *failure.read().unwrap() { () @@ -210,6 +214,16 @@ pub fn validate_ssz_block(b: &SszBlock, }; }); + match failure.into_inner() { + Err(_) => return Err(SszBlockValidationError::RwLockPoisoned), + Ok(failure) => { + match failure { + Some(error) => return Err(error), + _ => () + } + + } + } // TODO: handle validation failure. Presently, it will just pass everything /*