Skip to content

Commit

Permalink
Merge 49fb07c into 871ea9a
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain authored May 17, 2022
2 parents 871ea9a + 49fb07c commit 748af08
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/lodestar/src/chain/lightClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ export class LightClientServer {
* ```
*
* 3. On new blocks use `block.body.sync_aggregate`, `block.parent_root` and `block.slot - 1`
*
* @param syncPeriod The sync period of the sync aggregate and signed block root
*/
private async onSyncAggregate(
syncPeriod: SyncPeriod,
Expand All @@ -445,6 +447,11 @@ export class LightClientServer {
}
}

const attestedPeriod = computeSyncPeriodAtSlot(attestedData.attestedHeader.slot);
if (syncPeriod !== attestedPeriod) {
throw new Error("attested data period different than signature period");
}

const headerUpdate: routes.lightclient.LightclientHeaderUpdate = {
attestedHeader: attestedData.attestedHeader,
syncAggregate,
Expand Down Expand Up @@ -506,7 +513,7 @@ export class LightClientServer {
// Only checkpoint candidates are stored, and not all headers are guaranteed to be available
const finalizedCheckpointRoot = attestedData.finalizedCheckpoint.root as Uint8Array;
const finalizedHeader = await this.getFinalizedHeader(finalizedCheckpointRoot);
if (finalizedHeader) {
if (finalizedHeader && computeSyncPeriodAtSlot(finalizedHeader.slot) == syncPeriod) {
// If finalizedHeader is available (should be most times) create a finalized update
newPartialUpdate = {...attestedData, finalizedHeader, syncAggregate};
} else {
Expand Down

0 comments on commit 748af08

Please sign in to comment.