Offloading KZG Proof Computation from the beacon node (#7117)

Addresses #7108

- Add EL integration for `getPayloadV5` and `getBlobsV2`
- Offload proof computation and use proofs from EL RPC APIs
This commit is contained in:
Jimmy Chen
2025-04-08 17:37:16 +10:00
committed by GitHub
parent e924264e17
commit 759b0612b3
31 changed files with 721 additions and 476 deletions

View File

@@ -141,13 +141,23 @@ pub enum GossipDataColumnError {
///
/// The column sidecar is invalid and the peer is faulty
UnexpectedDataColumn,
/// The data column length must be equal to the number of commitments/proofs, otherwise the
/// The data column length must be equal to the number of commitments, otherwise the
/// sidecar is invalid.
///
/// ## Peer scoring
///
/// The column sidecar is invalid and the peer is faulty
InconsistentCommitmentsOrProofLength,
InconsistentCommitmentsLength {
cells_len: usize,
commitments_len: usize,
},
/// The data column length must be equal to the number of proofs, otherwise the
/// sidecar is invalid.
///
/// ## Peer scoring
///
/// The column sidecar is invalid and the peer is faulty
InconsistentProofsLength { cells_len: usize, proofs_len: usize },
}
impl From<BeaconChainError> for GossipDataColumnError {
@@ -240,6 +250,14 @@ impl<E: EthSpec> KzgVerifiedDataColumn<E> {
verify_kzg_for_data_column(data_column, kzg)
}
/// Create a `KzgVerifiedDataColumn` from `data_column` that are already KZG verified.
///
/// This should be used with caution, as used incorrectly it could result in KZG verification
/// being skipped and invalid data_columns being deemed valid.
pub fn from_verified(data_column: Arc<DataColumnSidecar<E>>) -> Self {
Self { data: data_column }
}
pub fn from_batch(
data_columns: Vec<Arc<DataColumnSidecar<E>>>,
kzg: &Kzg,
@@ -473,10 +491,23 @@ fn verify_data_column_sidecar<E: EthSpec>(
if data_column.kzg_commitments.is_empty() {
return Err(GossipDataColumnError::UnexpectedDataColumn);
}
if data_column.column.len() != data_column.kzg_commitments.len()
|| data_column.column.len() != data_column.kzg_proofs.len()
{
return Err(GossipDataColumnError::InconsistentCommitmentsOrProofLength);
let cells_len = data_column.column.len();
let commitments_len = data_column.kzg_commitments.len();
let proofs_len = data_column.kzg_proofs.len();
if cells_len != commitments_len {
return Err(GossipDataColumnError::InconsistentCommitmentsLength {
cells_len,
commitments_len,
});
}
if cells_len != proofs_len {
return Err(GossipDataColumnError::InconsistentProofsLength {
cells_len,
proofs_len,
});
}
Ok(())