Skip to content

Commit d5a07e6

Browse files
committed
Fix the types
1 parent d4e8b9f commit d5a07e6

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

packages/beacon-node/src/db/repositories/blockArchive.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class BlockArchiveRepository extends Repository<Slot, FullOrBlindedSigned
9191
async remove(value: FullOrBlindedSignedBeaconBlock): Promise<void> {
9292
await Promise.all([
9393
super.remove(value),
94-
deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).BeaconBlock, value),
94+
deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value),
9595
deleteParentRootIndex(this.db, value),
9696
]);
9797
}
@@ -100,7 +100,7 @@ export class BlockArchiveRepository extends Repository<Slot, FullOrBlindedSigned
100100
await Promise.all([
101101
super.batchRemove(values),
102102
Array.from(values).map((value) =>
103-
deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).BeaconBlock, value)
103+
deleteRootIndex(this.db, this.config.getForkTypes(value.message.slot).SignedBeaconBlock, value)
104104
),
105105
Array.from(values).map((value) => deleteParentRootIndex(this.db, value)),
106106
]);

packages/beacon-node/src/db/repositories/blockArchiveIndex.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function deleteRootIndex(
1717
signedBeaconBlockType: SSZTypesFor<ForkAll, "SignedBeaconBlock">,
1818
block: FullOrBlindedSignedBeaconBlock
1919
): Promise<void> {
20-
return db.delete(getRootIndexKey(beaconBlockType.hashTreeRoot(block.message)));
20+
return db.delete(getRootIndexKey(signedBeaconBlockType.hashTreeRoot(block.message)));
2121
}
2222

2323
export async function deleteParentRootIndex(db: Db, block: FullOrBlindedSignedBeaconBlock): Promise<void> {

packages/beacon-node/src/util/fullOrBlindedBlock.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
SignedBeaconBlock,
99
SignedBlindedBeaconBlock,
1010
FullOrBlindedSignedBeaconBlock,
11-
FullOrBlindedSignedBeaconBlockExecution,
12-
FullOrBlindedSignedBeaconBlockPreExecution,
1311
} from "@lodestar/types";
1412
import {BYTES_PER_LOGS_BLOOM, ForkSeq, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
1513
import {executionPayloadToPayloadHeader} from "@lodestar/state-transition";
@@ -129,7 +127,7 @@ export function isBlindedBytes(forkSeq: ForkSeq, blockBytes: Uint8Array): boolea
129127
}
130128

131129
// same as isBlindedSignedBeaconBlock but without type narrowing
132-
export function isBlinded(block: FullOrBlindedSignedBeaconBlock): boolean {
130+
export function isBlinded(block: FullOrBlindedSignedBeaconBlock): block is SignedBlindedBeaconBlock {
133131
return (block as bellatrix.SignedBlindedBeaconBlock).message.body.executionPayloadHeader !== undefined;
134132
}
135133

@@ -138,11 +136,11 @@ export function serializeFullOrBlindedSignedBeaconBlock(
138136
value: FullOrBlindedSignedBeaconBlock
139137
): Uint8Array {
140138
if (isBlinded(value)) {
141-
const type = config.getExecutionForkTypes(value.message.slot).SignedBeaconBlock;
142-
return type.serialize(value as SignedBeaconBlock);
139+
const type = config.getExecutionForkTypes(value.message.slot).SignedBlindedBeaconBlock;
140+
return type.serialize(value);
143141
}
144142
const type = config.getForkTypes(value.message.slot).SignedBeaconBlock;
145-
return type.serialize(value as FullOrBlindedSignedBeaconBlockPreExecution);
143+
return type.serialize(value);
146144
}
147145

148146
export function deserializeFullOrBlindedSignedBeaconBlock(
@@ -263,7 +261,7 @@ export function blindedOrFullBlockToFull(
263261
message: {
264262
...block.message,
265263
body: {
266-
...(block.message.body as bellatrix.BeaconBlockBody),
264+
...block.message.body,
267265
executionPayload: executionPayloadHeaderToPayload(
268266
forkSeq,
269267
(block.message.body as bellatrix.BlindedBeaconBlockBody).executionPayloadHeader,

packages/types/src/types.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,9 @@ export type BlindedBeaconBlock<F extends ForkExecution = ForkExecution> = TypesB
162162
export type SignedBeaconBlock<F extends ForkAll = ForkAll> = TypesByFork[F]["SignedBeaconBlock"];
163163
export type SignedBlindedBeaconBlock<F extends ForkExecution = ForkExecution> =
164164
TypesByFork[F]["SignedBlindedBeaconBlock"];
165-
export type FullOrBlindedSignedBeaconBlockPreExecution<F extends ForkPreExecution = ForkPreExecution> =
166-
TypesByFork[F]["SignedBeaconBlock"];
167-
export type FullOrBlindedSignedBeaconBlockExecution<F extends ForkExecution = ForkExecution> =
168-
TypesByFork[F]["FullOrBlindedSignedBeaconBlock"];
169-
export type FullOrBlindedSignedBeaconBlock =
170-
| FullOrBlindedSignedBeaconBlockPreExecution
171-
| FullOrBlindedSignedBeaconBlockExecution;
165+
export type FullOrBlindedSignedBeaconBlock<F extends ForkAll = ForkAll, E extends ForkExecution = ForkExecution> =
166+
| SignedBeaconBlock<F>
167+
| SignedBlindedBeaconBlock<E>;
172168

173169
export type BeaconBlockBody<F extends ForkAll = ForkAll> = TypesByFork[F]["BeaconBlockBody"];
174170
export type BlindedBeaconBlockBody<F extends ForkExecution = ForkExecution> = TypesByFork[F]["BlindedBeaconBlockBody"];

0 commit comments

Comments
 (0)