Skip to content

Commit 44d9599

Browse files
wemeetagainnflaig
andauthored
fix: align BeaconBlockBody and BlindedBeaconBlockBody (#6782)
* fix: align BeaconBlockBody and BlindedBeaconBlockBody * Remove type hacks in test --------- Co-authored-by: Nico Flaig <nflaig@protonmail.com>
1 parent 39c1a45 commit 44d9599

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/types/src/electra/sszTypes.ts

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ export const BlindedBeaconBlockBody = new ContainerType(
223223
executionPayloadHeader: ExecutionPayloadHeader, // Modified in ELECTRA
224224
blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges,
225225
blobKzgCommitments: denebSsz.BeaconBlockBody.fields.blobKzgCommitments,
226+
consolidations: new ListCompositeType(SignedConsolidation, MAX_CONSOLIDATIONS), // [New in Electra]
226227
},
227228
{typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true}
228229
);
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import {describe, it, expect} from "vitest";
2+
import {ForkName, isForkExecution} from "@lodestar/params";
3+
import {ssz} from "../../src/index.js";
4+
5+
describe("blinded data structures", function () {
6+
it("should have the same number of fields as non-blinded", () => {
7+
const blindedTypes = [
8+
{a: "BlindedBeaconBlockBody" as const, b: "BeaconBlockBody" as const},
9+
{a: "ExecutionPayloadHeader" as const, b: "ExecutionPayload" as const},
10+
];
11+
12+
for (const {a, b} of blindedTypes) {
13+
for (const fork of Object.keys(ssz.allForks) as ForkName[]) {
14+
if (!isForkExecution(fork)) {
15+
continue;
16+
}
17+
18+
const blindedType = ssz[fork][a];
19+
if (blindedType === undefined) {
20+
expect.fail(`fork: ${fork}, type ${a} is undefined`);
21+
}
22+
23+
const type = ssz[fork][b];
24+
if (type === undefined) {
25+
expect.fail(`fork: ${fork}, type ${b} is undefined`);
26+
}
27+
28+
expect(Object.keys(blindedType.fields).length).toBeWithMessage(
29+
Object.keys(type.fields).length,
30+
`fork: ${fork}, types ${a} and ${b} have different number of fields`
31+
);
32+
}
33+
}
34+
});
35+
});

0 commit comments

Comments
 (0)