mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Optimize validate_data_columns (#7326)
This commit is contained in:
@@ -8,9 +8,9 @@ use std::sync::Arc;
|
|||||||
use types::beacon_block_body::KzgCommitments;
|
use types::beacon_block_body::KzgCommitments;
|
||||||
use types::data_column_sidecar::{Cell, DataColumn, DataColumnSidecarError};
|
use types::data_column_sidecar::{Cell, DataColumn, DataColumnSidecarError};
|
||||||
use types::{
|
use types::{
|
||||||
Blob, BlobSidecar, BlobSidecarList, ChainSpec, ColumnIndex, DataColumnSidecar,
|
Blob, BlobSidecar, BlobSidecarList, ChainSpec, DataColumnSidecar, DataColumnSidecarList,
|
||||||
DataColumnSidecarList, EthSpec, Hash256, KzgCommitment, KzgProof, SignedBeaconBlock,
|
EthSpec, Hash256, KzgCommitment, KzgProof, SignedBeaconBlock, SignedBeaconBlockHeader,
|
||||||
SignedBeaconBlockHeader, SignedBlindedBeaconBlock,
|
SignedBlindedBeaconBlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Converts a blob ssz List object to an array to be used with the kzg
|
/// Converts a blob ssz List object to an array to be used with the kzg
|
||||||
@@ -79,38 +79,27 @@ pub fn validate_data_columns<'a, E: EthSpec, I>(
|
|||||||
where
|
where
|
||||||
I: Iterator<Item = &'a Arc<DataColumnSidecar<E>>> + Clone,
|
I: Iterator<Item = &'a Arc<DataColumnSidecar<E>>> + Clone,
|
||||||
{
|
{
|
||||||
let cells = data_column_iter
|
let mut cells = Vec::new();
|
||||||
.clone()
|
let mut proofs = Vec::new();
|
||||||
.flat_map(|data_column| data_column.column.iter().map(ssz_cell_to_crypto_cell::<E>))
|
let mut column_indices = Vec::new();
|
||||||
.collect::<Result<Vec<_>, KzgError>>()?;
|
let mut commitments = Vec::new();
|
||||||
|
|
||||||
let proofs = data_column_iter
|
for data_column in data_column_iter {
|
||||||
.clone()
|
let col_index = data_column.index;
|
||||||
.flat_map(|data_column| {
|
|
||||||
data_column
|
|
||||||
.kzg_proofs
|
|
||||||
.iter()
|
|
||||||
.map(|&proof| Bytes48::from(proof))
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
let column_indices = data_column_iter
|
for cell in &data_column.column {
|
||||||
.clone()
|
cells.push(ssz_cell_to_crypto_cell::<E>(cell)?);
|
||||||
.flat_map(|data_column| {
|
column_indices.push(col_index);
|
||||||
let col_index = data_column.index;
|
}
|
||||||
data_column.column.iter().map(move |_| col_index)
|
|
||||||
})
|
|
||||||
.collect::<Vec<ColumnIndex>>();
|
|
||||||
|
|
||||||
let commitments = data_column_iter
|
for &proof in &data_column.kzg_proofs {
|
||||||
.clone()
|
proofs.push(Bytes48::from(proof));
|
||||||
.flat_map(|data_column| {
|
}
|
||||||
data_column
|
|
||||||
.kzg_commitments
|
for &commitment in &data_column.kzg_commitments {
|
||||||
.iter()
|
commitments.push(Bytes48::from(commitment));
|
||||||
.map(|&commitment| Bytes48::from(commitment))
|
}
|
||||||
})
|
}
|
||||||
.collect::<Vec<_>>();
|
|
||||||
|
|
||||||
kzg.verify_cell_proof_batch(&cells, &proofs, column_indices, &commitments)
|
kzg.verify_cell_proof_batch(&cells, &proofs, column_indices, &commitments)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user