mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 15:37:56 -05:00
Better parent block request (#4572)
* Use a good peer instead of a random one, if we know about it * Exit init sync if there is an issue * Merge refs/heads/master into better-parent-block-processing * Merge refs/heads/master into better-parent-block-processing * Merge refs/heads/master into better-parent-block-processing * Merge refs/heads/master into better-parent-block-processing * Update pending_blocks_queue.go
This commit is contained in:
committed by
prylabs-bulldozer[bot]
parent
3d3dccbdb4
commit
ccfc650375
@@ -69,7 +69,18 @@ func (r *Service) processPendingBlocks(ctx context.Context) error {
|
||||
"parentRoot": hex.EncodeToString(b.Block.ParentRoot),
|
||||
}).Info("Requesting parent block")
|
||||
req := [][32]byte{bytesutil.ToBytes32(b.Block.ParentRoot)}
|
||||
if err := r.sendRecentBeaconBlocksRequest(ctx, req, pids[rand.Int()%len(pids)]); err != nil {
|
||||
|
||||
// Start with a random peer to query, but choose the first peer in our unsorted list that claims to
|
||||
// have a head slot newer than the block slot we are requesting.
|
||||
pid := pids[rand.Int()%len(pids)]
|
||||
for _, p := range pids {
|
||||
if cs, _ := r.p2p.Peers().ChainState(p); cs != nil && cs.HeadSlot >= uint64(s) {
|
||||
pid = p
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if err := r.sendRecentBeaconBlocksRequest(ctx, req, pid); err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
log.Errorf("Could not send recent block request: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user