mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
Check block exists in pending queue before requesting from peer (#13013)
This commit is contained in:
parent
66011d5d9c
commit
39072e1b74
@ -75,14 +75,19 @@ func (s *Service) processPendingAtts(ctx context.Context) error {
|
||||
delete(s.blkRootToPendingAtts, bRoot)
|
||||
s.pendingAttsLock.Unlock()
|
||||
} else {
|
||||
// Pending attestation's missing block has not arrived yet.
|
||||
log.WithFields(logrus.Fields{
|
||||
"currentSlot": s.cfg.clock.CurrentSlot(),
|
||||
"attSlot": attestations[0].Message.Aggregate.Data.Slot,
|
||||
"attCount": len(attestations),
|
||||
"blockRoot": hex.EncodeToString(bytesutil.Trunc(bRoot[:])),
|
||||
}).Debug("Requesting block for pending attestation")
|
||||
pendingRoots = append(pendingRoots, bRoot)
|
||||
s.pendingQueueLock.RLock()
|
||||
seen := s.seenPendingBlocks[bRoot]
|
||||
s.pendingQueueLock.RUnlock()
|
||||
if !seen {
|
||||
// Pending attestation's missing block has not arrived yet.
|
||||
log.WithFields(logrus.Fields{
|
||||
"currentSlot": s.cfg.clock.CurrentSlot(),
|
||||
"attSlot": attestations[0].Message.Aggregate.Data.Slot,
|
||||
"attCount": len(attestations),
|
||||
"blockRoot": hex.EncodeToString(bytesutil.Trunc(bRoot[:])),
|
||||
}).Debug("Requesting block for pending attestation")
|
||||
pendingRoots = append(pendingRoots, bRoot)
|
||||
}
|
||||
}
|
||||
}
|
||||
return s.sendBatchRootRequest(ctx, pendingRoots, randGen)
|
||||
|
@ -247,11 +247,15 @@ func (s *Service) sendBatchRootRequest(ctx context.Context, roots [][32]byte, ra
|
||||
defer span.End()
|
||||
|
||||
roots = dedupRoots(roots)
|
||||
s.pendingQueueLock.RLock()
|
||||
for i := len(roots) - 1; i >= 0; i-- {
|
||||
if s.cfg.chain.BlockBeingSynced(roots[i]) {
|
||||
r := roots[i]
|
||||
if s.seenPendingBlocks[r] || s.cfg.chain.BlockBeingSynced(r) {
|
||||
roots = append(roots[:i], roots[i+1:]...)
|
||||
}
|
||||
}
|
||||
s.pendingQueueLock.RUnlock()
|
||||
|
||||
if len(roots) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user