diff --git a/src/store.ts b/src/store.ts index cef105b..513d5e0 100644 --- a/src/store.ts +++ b/src/store.ts @@ -5,6 +5,7 @@ import { concatBytes } from "@noble/hashes/utils"; import { LightClientUpdate } from "#types.js"; import * as capella from "@lodestar/types/capella"; import NodeCache from "node-cache"; +import { fixSerializedUint8Array } from "#util.js"; export interface StoreItem { update: Uint8Array; @@ -22,10 +23,14 @@ export default class Store implements IStore { addUpdate(period: number, update: LightClientUpdate) { try { this.store.set(period, { - update: capella.ssz.LightClientUpdate.serialize(update), - nextCommittee: CommitteeSSZ.serialize(update.nextSyncCommittee.pubkeys), - nextCommitteeHash: digest( - concatBytes(...update.nextSyncCommittee.pubkeys), + update: fixSerializedUint8Array( + capella.ssz.LightClientUpdate.serialize(update), + ), + nextCommittee: fixSerializedUint8Array( + CommitteeSSZ.serialize(update.nextSyncCommittee.pubkeys), + ), + nextCommitteeHash: fixSerializedUint8Array( + digest(concatBytes(...update.nextSyncCommittee.pubkeys)), ), }); } catch (e) { diff --git a/src/util.ts b/src/util.ts index 97349ff..a8887c6 100644 --- a/src/util.ts +++ b/src/util.ts @@ -131,3 +131,6 @@ function isValidLightClientHeader( header.beacon.bodyRoot, ); } +export function fixSerializedUint8Array(arr: Uint8Array) { + return new Uint8Array(Object.values(arr)); +}