Sync: don't process pending blocks w/o genesis time (#10750)

* Sync: don't process pending blocks w/o genesis time

* Update pending_blocks_queue.go

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
This commit is contained in:
terencechain 2022-06-09 22:02:47 -07:00 committed by GitHub
parent 7f443e8387
commit a58809597e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,6 +36,10 @@ func (s *Service) processPendingBlocksQueue() {
// Prevents multiple queue processing goroutines (invoked by RunEvery) from contending for data.
locker := new(sync.Mutex)
async.RunEvery(s.ctx, processPendingBlocksPeriod, func() {
// Don't process the pending blocks if genesis time has not been set. The chain is not ready.
if !s.isGenesisTimeSet() {
return
}
locker.Lock()
if err := s.processPendingBlocks(s.ctx); err != nil {
log.WithError(err).Debug("Could not process pending blocks")
@ -410,6 +414,12 @@ func (s *Service) addPendingBlockToCache(b interfaces.SignedBeaconBlock) error {
return nil
}
// Returns true if the genesis time has been set in chain service.
// Without the genesis time, the chain does not start.
func (s *Service) isGenesisTimeSet() bool {
return s.cfg.chain.GenesisTime().Unix() != 0
}
// This converts input string to slot.
func cacheKeyToSlot(s string) types.Slot {
b := []byte(s)