From 55a471efaf6f0c3ac093c0923ffa089df438ece9 Mon Sep 17 00:00:00 2001 From: Forostovec Date: Mon, 11 Aug 2025 16:34:59 +0300 Subject: [PATCH] eth/downloader: skip nil peer in GetHeader (#32369) The GetHeader function was incorrectly returning an error when encountering nil peers in the peers list, which contradicted the comment "keep retrying if none are yet available". Changed the logic to skip nil peers with 'continue' instead of returning an error, allowing the function to properly iterate through all available peers and attempt to retrieve the target header from each valid peer. This ensures the function behaves as intended - trying all available peers before giving up, rather than failing on the first nil peer encountered. --- eth/downloader/beacondevsync.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eth/downloader/beacondevsync.go b/eth/downloader/beacondevsync.go index 7b30684133..03f17b1a52 100644 --- a/eth/downloader/beacondevsync.go +++ b/eth/downloader/beacondevsync.go @@ -52,7 +52,8 @@ func (d *Downloader) GetHeader(hash common.Hash) (*types.Header, error) { for _, peer := range d.peers.peers { if peer == nil { - return nil, errors.New("could not find peer") + log.Warn("Encountered nil peer while retrieving sync target", "hash", hash) + continue } // Found a peer, attempt to retrieve the header whilst blocking and // retry if it fails for whatever reason