mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Avoid rayon in lighthouse block verification (#5992)
* Avoid rayon in lighthouse
This commit is contained in:
@@ -4,7 +4,6 @@ use super::signature_sets::{Error as SignatureSetError, *};
|
||||
use crate::per_block_processing::errors::{AttestationInvalid, BlockOperationError};
|
||||
use crate::{ConsensusContext, ContextError};
|
||||
use bls::{verify_signature_sets, PublicKey, PublicKeyBytes, SignatureSet};
|
||||
use rayon::prelude::*;
|
||||
use std::borrow::Cow;
|
||||
use types::{
|
||||
AbstractExecPayload, BeaconState, BeaconStateError, ChainSpec, EthSpec, Hash256,
|
||||
@@ -411,15 +410,10 @@ impl<'a> ParallelSignatureSets<'a> {
|
||||
/// It is not possible to know exactly _which_ signature is invalid here, just that
|
||||
/// _at least one_ was invalid.
|
||||
///
|
||||
/// Uses `rayon` to do a map-reduce of Vitalik's method across multiple cores.
|
||||
/// Blst library spreads the signature verification work across multiple available cores, so
|
||||
/// this function is already parallelized.
|
||||
#[must_use]
|
||||
pub fn verify(self) -> bool {
|
||||
let num_sets = self.sets.len();
|
||||
let num_chunks = std::cmp::max(1, num_sets / rayon::current_num_threads());
|
||||
self.sets
|
||||
.into_par_iter()
|
||||
.chunks(num_chunks)
|
||||
.map(|chunk| verify_signature_sets(chunk.iter()))
|
||||
.reduce(|| true, |current, this| current && this)
|
||||
verify_signature_sets(self.sets.iter())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user