Skip to content

Commit

Permalink
validate inclusion proof
Browse files Browse the repository at this point in the history
  • Loading branch information
g11tech committed Sep 17, 2024
1 parent 20ef4c6 commit fee7c08
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export enum DataColumnSidecarErrorCode {
// following errors are adapted from the block errors
FUTURE_SLOT = "DATA_COLUMN_SIDECAR_ERROR_FUTURE_SLOT",
PARENT_UNKNOWN = "DATA_COLUMN_SIDECAR_ERROR_PARENT_UNKNOWN",
INCLUSION_PROOF_INVALID = "BLOB_SIDECAR_ERROR_INCLUSION_PROOF_INVALID",
}

export type DataColumnSidecarErrorType =
| {code: DataColumnSidecarErrorCode.INVALID_INDEX; columnIndex: number; gossipIndex: number}
| {code: DataColumnSidecarErrorCode.FUTURE_SLOT; blockSlot: Slot; currentSlot: Slot}
| {code: DataColumnSidecarErrorCode.PARENT_UNKNOWN; parentRoot: RootHex};
| {code: DataColumnSidecarErrorCode.PARENT_UNKNOWN; parentRoot: RootHex}
| {code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID; slot: Slot; columnIdx: number};

export class DataColumnSidecarGossipError extends GossipActionError<DataColumnSidecarErrorType> {}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ export async function validateGossipDataColumnSidecar(
});
}

validateInclusionProof(dataColumnSideCar);
if (!validateInclusionProof(dataColumnSideCar)) {
throw new DataColumnSidecarGossipError(GossipAction.REJECT, {
code: DataColumnSidecarErrorCode.INCLUSION_PROOF_INVALID,
slot: dataColumnSideCar.signedBlockHeader.message.slot,
columnIdx: dataColumnSideCar.index,
});
}
}

export function validateDataColumnsSidecars(
Expand Down

0 comments on commit fee7c08

Please sign in to comment.