Use rayon to speed up batch KZG verification (#7921)

Addresses #7866.


  Use Rayon to speed up batch KZG verification during range / backfill sync.

While I was analysing the traces, I also discovered a bug that resulted in only the first 128 columns in a chain segment batch being verified. This PR fixes it, so we might actually observe slower range sync due to more cells being KZG verified.

I've also updated the handling of batch KZG failure to only find the first invalid KZG column when verification fails as this gets very expensive during range/backfill sync.
This commit is contained in:
Jimmy Chen
2025-08-29 10:59:40 +10:00
committed by GitHub
parent b6792d85d2
commit a134d43446
10 changed files with 140 additions and 129 deletions

View File

@@ -36,7 +36,6 @@ use beacon_chain::data_availability_checker::{
use beacon_chain::{AvailabilityProcessingStatus, BeaconChainTypes, BlockError};
pub use common::RequestState;
use fnv::FnvHashMap;
use itertools::Itertools;
use lighthouse_network::service::api_types::SingleLookupReqId;
use lighthouse_network::{PeerAction, PeerId};
use lru_cache::LRUTimeCache;
@@ -653,15 +652,15 @@ impl<T: BeaconChainTypes> BlockLookups<T> {
// but future errors may follow the same pattern. Generalize this
// pattern with https://github.com/sigp/lighthouse/pull/6321
BlockError::AvailabilityCheck(
AvailabilityCheckError::InvalidColumn(errors),
) => errors
.iter()
// Collect all peers that sent a column that was invalid. Must
// run .unique as a single peer can send multiple invalid
// columns. Penalize once to avoid insta-bans
.flat_map(|(index, _)| peer_group.of_index((*index) as usize))
.unique()
.collect(),
AvailabilityCheckError::InvalidColumn((index_opt, _)),
) => {
match index_opt {
Some(index) => peer_group.of_index(index as usize).collect(),
// If no index supplied this is an un-attributable fault. In practice
// this should never happen.
None => vec![],
}
}
_ => peer_group.all().collect(),
};
for peer in peers_to_penalize {