Update beacon/blsync/block_sync.go

Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
Felföldi Zsolt 2024-04-05 11:52:50 +02:00 committed by Zsolt Felfoldi
parent fd70b19474
commit 9de80ca574

View file

@ -127,20 +127,19 @@ func (s *beaconBlockSync) updateEventFeed() {
var finalizedHash common.Hash var finalizedHash common.Hash
if finality, ok := s.headTracker.ValidatedFinality(); ok { if finality, ok := s.headTracker.ValidatedFinality(); ok {
if he, fe := head.Header.Epoch(), finality.Attested.Header.Epoch(); he == fe { he := head.Header.Epoch()
fe := finality.Attested.Header.Epoch()
switch {
case he == fe:
finalizedHash = finality.Finalized.PayloadHeader.BlockHash() finalizedHash = finality.Finalized.PayloadHeader.BlockHash()
} else { case he < fe:
if he < fe { return
return // finality proof arrived earlier, wait for head update case he == fe+1:
} parent, ok := s.recentBlocks.Get(head.Header.ParentRoot)
if he == fe+1 { if !ok || parent.Slot()/params.EpochLength == fe {
if parent, ok := s.recentBlocks.Get(head.Header.ParentRoot); !ok ||
parent.Slot()/params.EpochLength == fe {
return // head is at first slot of next epoch, wait for finality update return // head is at first slot of next epoch, wait for finality update
//TODO trt to fetch finality update directly if subscription does not deliver //TODO trt to fetch finality update directly if subscription does not deliver
} }
}
} }
} }