Fix durationToNextSlot() and durationToNextEpoch() to work not only after Genesis, but also before Genesis.

Change VC pre-genesis behavior, add runPreGenesisWaitingLoop() and runGenesisWaitingLoop().
Add checkedWaitForSlot() and checkedWaitForNextSlot() to strictly check current time and print warnings.
Fix VC main loop to use checkedWaitForNextSlot().
Fix attestation_service to run attestations processing only until the end of the duty slot.
Change attestation_service main loop to use checkedWaitForNextSlot().
Change block_service to properly cancel all the pending proposer tasks.
Use checkedWaitForSlot to wait for block proposal.
Fix block_service waitForBlockPublished() to be compatible with BN.
Fix sync_committee_service to avoid asyncSpawn.
Fix sync_committee_service to run only until the end of the duty slot.
Fix sync_committee_service to use checkedWaitForNextSlot().
This commit is contained in:
cheatfate 2023-03-14 23:58:43 +02:00
parent 8f2f40f0af
commit b063e7e0e7
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
2 changed files with 5 additions and 0 deletions

View File

@ -16,6 +16,10 @@ from times import Time, getTime, fromUnix, `<`, `-`, inNanoseconds
export chronos.Duration, Moment, now
const
NANOSECONDS_PER_SLOT* = SECONDS_PER_SLOT * 1_000_000_000'u64
NANOSECONDS_PER_EPOCH* = NANOSECONDS_PER_SLOT * SLOTS_PER_EPOCH
type
BeaconClock* = object
## The beacon clock represents time as it passes on a beacon chain. Beacon

View File

@ -936,6 +936,7 @@ proc checkedWaitForSlot*(vc: ValidatorClientRef, destinationSlot: Slot,
start_slot = shortLog(currentSlot)
dest_slot = shortLog(destinationSlot)
time_to_slot = shortLog(timeToSlot)
offset = shortLog(chronosOffset)
while true:
await sleepAsync(timeToSlot)