Skip to content

Commit

Permalink
test: add sanity check for empty blob commitments in column validation
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkeil committed Oct 21, 2024
1 parent 4e676c7 commit 889e7ed
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions packages/beacon-node/test/unit/util/dataColumn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,43 @@ describe("data column sidecars", () => {

expect(validateDataColumnsSidecars(slot, blockRoot, kzgCommitments, columnSidecars)).toBeUndefined();
});

it("fail for no blob commitments in validateDataColumnsSidecars", () => {
const chainConfig = createChainForkConfig({
...defaultChainConfig,
ALTAIR_FORK_EPOCH: 0,
BELLATRIX_FORK_EPOCH: 0,
DENEB_FORK_EPOCH: 0,
ELECTRA_FORK_EPOCH: 0,
});
const genesisValidatorsRoot = Buffer.alloc(32, 0xaa);
const config = createBeaconConfig(chainConfig, genesisValidatorsRoot);

const chain = getMockedBeaconChain({config});
afterEachCallbacks.push(() => chain.close());

const slot = 0;
const blobs = [generateRandomBlob(), generateRandomBlob()];
const kzgCommitments = blobs.map((blob) => ckzg.blobToKzgCommitment(blob));

const signedBeaconBlock = ssz.deneb.SignedBeaconBlock.defaultValue();

for (const kzgCommitment of kzgCommitments) {
signedBeaconBlock.message.body.executionPayload.transactions.push(transactionForKzgCommitment(kzgCommitment));
signedBeaconBlock.message.body.blobKzgCommitments.push(kzgCommitment);
}
const blockRoot = ssz.deneb.BeaconBlock.hashTreeRoot(signedBeaconBlock.message);
const columnSidecars = computeDataColumnSidecars(config, signedBeaconBlock, {
blobs,
});

expect(columnSidecars.length).toEqual(NUMBER_OF_COLUMNS);
expect(columnSidecars[0].column.length).toEqual(blobs.length);

signedBeaconBlock.message.body.blobKzgCommitments.length = [];

expect(() => validateDataColumnsSidecars(slot, blockRoot, kzgCommitments, columnSidecars)).toThrow(
`Invalid data column sidecar slot=${slot}`
);
});
});

0 comments on commit 889e7ed

Please sign in to comment.