mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
chore: update and enable PeerDAS tests to latest spec test release (1.5.0-alpha-5) (#6312)
* enable DAS tests * update spec testing code * Update PeerDAS kzg tests input structures to latest spec. * Update `ef_tests` ignore files.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use super::*;
|
||||
use crate::case_result::compare_result;
|
||||
use kzg::{CellsAndKzgProofs, KzgProof};
|
||||
use kzg::CellsAndKzgProofs;
|
||||
use serde::Deserialize;
|
||||
use std::convert::Infallible;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
@@ -10,7 +9,6 @@ use std::marker::PhantomData;
|
||||
pub struct KZGRecoverCellsAndKzgProofsInput {
|
||||
pub cell_indices: Vec<u64>,
|
||||
pub cells: Vec<String>,
|
||||
pub proofs: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
@@ -35,29 +33,17 @@ impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
|
||||
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
let parse_input = |input: &KZGRecoverCellsAndKzgProofsInput| {
|
||||
// Proofs are not used for `recover_cells_and_compute_kzg_proofs`, they are only checked
|
||||
// to satisfy the spec tests.
|
||||
if input.proofs.len() != input.cell_indices.len() {
|
||||
return Err(Error::SkippedKnownFailure);
|
||||
}
|
||||
|
||||
let proofs = input
|
||||
.proofs
|
||||
.iter()
|
||||
.map(|s| parse_proof(s))
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
|
||||
let cells = input
|
||||
.cells
|
||||
.iter()
|
||||
.map(|s| parse_cell(s))
|
||||
.collect::<Result<Vec<_>, Error>>()?;
|
||||
|
||||
Ok((proofs, cells, input.cell_indices.clone()))
|
||||
Ok((cells, input.cell_indices.clone()))
|
||||
};
|
||||
|
||||
let result =
|
||||
parse_input(&self.input).and_then(|(input_proofs, input_cells, cell_indices)| {
|
||||
let result: Result<_, Error> =
|
||||
parse_input(&self.input).and_then(|(input_cells, cell_indices)| {
|
||||
let input_cells_ref: Vec<_> = input_cells.iter().map(|cell| &**cell).collect();
|
||||
let kzg = get_kzg();
|
||||
let (cells, proofs) = kzg
|
||||
@@ -71,18 +57,6 @@ impl<E: EthSpec> Case for KZGRecoverCellsAndKZGProofs<E> {
|
||||
))
|
||||
})?;
|
||||
|
||||
// Check recovered proofs matches inputs proofs. This is done only to satisfy the
|
||||
// spec tests, as the ckzg library recomputes all proofs and does not require
|
||||
// proofs to recover.
|
||||
for (input_proof, cell_id) in input_proofs.iter().zip(cell_indices) {
|
||||
if let Err(e) = compare_result::<KzgProof, Infallible>(
|
||||
&Ok(*input_proof),
|
||||
&proofs.get(cell_id as usize).cloned(),
|
||||
) {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
|
||||
Ok((cells, proofs))
|
||||
});
|
||||
|
||||
|
||||
@@ -13,8 +13,7 @@ static KZG: LazyLock<Arc<Kzg>> = LazyLock::new(|| {
|
||||
let trusted_setup: TrustedSetup = serde_json::from_reader(TRUSTED_SETUP_BYTES)
|
||||
.map_err(|e| Error::InternalError(format!("Failed to initialize trusted setup: {:?}", e)))
|
||||
.expect("failed to initialize trusted setup");
|
||||
// TODO(das): need to enable these tests when rayon issues in rust_eth_kzg are fixed
|
||||
let kzg = Kzg::new_from_trusted_setup(trusted_setup)
|
||||
let kzg = Kzg::new_from_trusted_setup_das_enabled(trusted_setup)
|
||||
.map_err(|e| Error::InternalError(format!("Failed to initialize kzg: {:?}", e)))
|
||||
.expect("failed to initialize kzg");
|
||||
Arc::new(kzg)
|
||||
|
||||
@@ -7,9 +7,8 @@ use std::marker::PhantomData;
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub struct KZGVerifyCellKZGProofBatchInput {
|
||||
pub row_commitments: Vec<String>,
|
||||
pub row_indices: Vec<usize>,
|
||||
pub column_indices: Vec<usize>,
|
||||
pub commitments: Vec<String>,
|
||||
pub cell_indices: Vec<u64>,
|
||||
pub cells: Vec<String>,
|
||||
pub proofs: Vec<String>,
|
||||
}
|
||||
@@ -37,32 +36,22 @@ impl<E: EthSpec> Case for KZGVerifyCellKZGProofBatch<E> {
|
||||
fn result(&self, _case_index: usize, _fork_name: ForkName) -> Result<(), Error> {
|
||||
let parse_input = |input: &KZGVerifyCellKZGProofBatchInput| -> Result<_, Error> {
|
||||
let (cells, proofs) = parse_cells_and_proofs(&input.cells, &input.proofs)?;
|
||||
let row_commitments = input
|
||||
.row_commitments
|
||||
let commitments = input
|
||||
.commitments
|
||||
.iter()
|
||||
.map(|s| parse_commitment(s))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let coordinates = input
|
||||
.row_indices
|
||||
.iter()
|
||||
.zip(&input.column_indices)
|
||||
.map(|(&row, &col)| (row as u64, col as u64))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
Ok((cells, proofs, coordinates, row_commitments))
|
||||
Ok((cells, proofs, input.cell_indices.clone(), commitments))
|
||||
};
|
||||
|
||||
let result =
|
||||
parse_input(&self.input).and_then(|(cells, proofs, coordinates, commitments)| {
|
||||
parse_input(&self.input).and_then(|(cells, proofs, cell_indices, commitments)| {
|
||||
let proofs: Vec<Bytes48> = proofs.iter().map(|&proof| proof.into()).collect();
|
||||
let commitments: Vec<Bytes48> = commitments.iter().map(|&c| c.into()).collect();
|
||||
let cells = cells.iter().map(|c| c.as_ref()).collect::<Vec<_>>();
|
||||
let column_indices = coordinates
|
||||
.into_iter()
|
||||
.map(|(_row, col)| col)
|
||||
.collect::<Vec<_>>();
|
||||
let kzg = get_kzg();
|
||||
match kzg.verify_cell_proof_batch(&cells, &proofs, column_indices, &commitments) {
|
||||
match kzg.verify_cell_proof_batch(&cells, &proofs, cell_indices, &commitments) {
|
||||
Ok(_) => Ok(true),
|
||||
Err(KzgError::KzgVerificationFailed) => Ok(false),
|
||||
Err(e) => Err(Error::InternalError(format!(
|
||||
|
||||
Reference in New Issue
Block a user