From 37f33870cf3abeac3c81efa7d9b4cded34955555 Mon Sep 17 00:00:00 2001 From: dapplion <35266934+dapplion@users.noreply.github.com> Date: Fri, 18 Nov 2022 22:40:36 +0100 Subject: [PATCH] Skip verifyAggregateKzgProof is empty blobs --- .../src/chain/validation/blobsSidecar.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/packages/beacon-node/src/chain/validation/blobsSidecar.ts b/packages/beacon-node/src/chain/validation/blobsSidecar.ts index 52a7fcd9535a..89d2aaea2f09 100644 --- a/packages/beacon-node/src/chain/validation/blobsSidecar.ts +++ b/packages/beacon-node/src/chain/validation/blobsSidecar.ts @@ -89,19 +89,23 @@ export function validateBlobsSidecar( ); } - // assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof) - let isProofValid: boolean; - try { - isProofValid = verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof); - } catch (e) { - // TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here - (e as Error).message = `Error on verifyAggregateKzgProof: ${(e as Error).message}`; - throw e; - } + // No need to verify the aggregate proof of zero blobs. Also c-kzg throws. + // https://github.com/dankrad/c-kzg/pull/12/files#r1025851956 + if (blobs.length > 0) { + // assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof) + let isProofValid: boolean; + try { + isProofValid = verifyAggregateKzgProof(blobs, expectedKzgCommitments, kzgAggregatedProof); + } catch (e) { + // TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here + (e as Error).message = `Error on verifyAggregateKzgProof: ${(e as Error).message}`; + throw e; + } - // TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here - if (!isProofValid) { - throw Error("Invalid AggregateKzgProof"); + // TODO EIP-4844: TEMP Nov17: May always throw error -- we need to fix Geth's KZG to match C-KZG and the trusted setup used here + if (!isProofValid) { + throw Error("Invalid AggregateKzgProof"); + } } }