Skip to content

Commit

Permalink
fix: run sync notifier once every slot pre-genesis (#6002)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored Sep 29, 2023
1 parent 070c121 commit ce54e32
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/beacon-node/src/node/notifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ function timeToNextHalfSlot(config: BeaconConfig, chain: IBeaconChain, isFirstTi
const msPerSlot = config.SECONDS_PER_SLOT * 1000;
const msPerHalfSlot = msPerSlot / 2;
const msFromGenesis = Date.now() - chain.genesisTime * 1000;
const msToNextSlot = msPerSlot - (msFromGenesis % msPerSlot);
const msToNextSlot =
msFromGenesis < 0
? // For future genesis time, calculate time left in the slot
-msFromGenesis % msPerSlot
: // For past genesis time, calculate time until the next slot
msPerSlot - (msFromGenesis % msPerSlot);
if (isFirstTime) {
// at the 1st time we may miss middle of the current clock slot
return msToNextSlot > msPerHalfSlot ? msToNextSlot - msPerHalfSlot : msToNextSlot + msPerHalfSlot;
Expand Down

0 comments on commit ce54e32

Please sign in to comment.