Skip to content

Commit

Permalink
fix: invalid build and update validity condition of validateDataColum…
Browse files Browse the repository at this point in the history
…nsSidecars
  • Loading branch information
matthewkeil committed Sep 10, 2024
1 parent 49b13f5 commit 6f1f025
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
DATA_COLUMN_SIDECAR_SUBNET_COUNT,
NUMBER_OF_COLUMNS,
} from "@lodestar/params";
import {ssz, electra, Slot, Root} from "@lodestar/types";
import {ssz, electra, Slot, Root, deneb} from "@lodestar/types";
import {toHex, verifyMerkleBranch} from "@lodestar/utils";

import {DataColumnSidecarGossipError, DataColumnSidecarErrorCode} from "../errors/dataColumnSidecarError.js";
Expand Down Expand Up @@ -57,6 +57,7 @@ export function validateDataColumnsSidecars(
const cellIndices: number[] = [];
const cells: Uint8Array[] = [];
const proofBytes: Uint8Array[] = [];

for (let sidecarsIndex = 0; sidecarsIndex < dataColumnSidecars.length; sidecarsIndex++) {
const columnSidecar = dataColumnSidecars[sidecarsIndex];
const {index: columnIndex, column, kzgCommitments, kzgProofs} = columnSidecar;
Expand All @@ -65,7 +66,10 @@ export function validateDataColumnsSidecars(
if (
columnBlockHeader.slot !== blockSlot ||
!byteArrayEquals(columnBlockRoot, blockRoot) ||
!byteArrayEquals(blockKzgCommitments, kzgCommitments)
blockKzgCommitments.length !== kzgCommitments.length ||
blockKzgCommitments
.map((commitment, i) => byteArrayEquals(commitment, kzgCommitments[i]))
.filter((result) => result === false).length
) {
throw new Error(
`Invalid data column sidecar with slot=${columnBlockHeader.slot} columnBlockRoot=${toHex(columnBlockRoot)} columnIndex=${columnIndex} for the block blockRoot=${toHex(blockRoot)} slot=${blockSlot} sidecarsIndex=${sidecarsIndex}`
Expand Down

0 comments on commit 6f1f025

Please sign in to comment.