Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/types/src/electra/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export const BlindedBeaconBlockBody = new ContainerType(
executionPayloadHeader: ExecutionPayloadHeader, // Modified in ELECTRA
blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges,
blobKzgCommitments: denebSsz.BeaconBlockBody.fields.blobKzgCommitments,
consolidations: new ListCompositeType(SignedConsolidation, MAX_CONSOLIDATIONS), // [New in Electra]
},
{typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
);
Expand Down
35 changes: 35 additions & 0 deletions packages/types/test/unit/blinded.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {describe, it, expect} from "vitest";
import {ForkName, isForkExecution} from "@lodestar/params";
import {ssz} from "../../src/index.js";

describe("blinded data structures", function () {
it("should have the same number of fields as non-blinded", () => {
const blindedTypes = [
{a: "BlindedBeaconBlockBody" as const, b: "BeaconBlockBody" as const},
{a: "ExecutionPayloadHeader" as const, b: "ExecutionPayload" as const},
];

for (const {a, b} of blindedTypes) {
for (const fork of Object.keys(ssz.allForks) as ForkName[]) {
if (!isForkExecution(fork)) {
continue;
}

const blindedType = ssz[fork][a];
if (blindedType === undefined) {
expect.fail(`fork: ${fork}, type ${a} is undefined`);
}

const type = ssz[fork][b];
if (type === undefined) {
expect.fail(`fork: ${fork}, type ${b} is undefined`);
}

expect(Object.keys(blindedType.fields).length).toBeWithMessage(
Object.keys(type.fields).length,
`fork: ${fork}, types ${a} and ${b} have different number of fields`
Comment thread
nflaig marked this conversation as resolved.
);
}
}
});
});