From 04adabe55ce9349e81de0d0527fc9e9d0aedcff1 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Mon, 24 Feb 2025 16:46:41 +0800 Subject: [PATCH] eth/downloader: fix nil droppeer in state sync (#19232) --- eth/downloader/statesync.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/eth/downloader/statesync.go b/eth/downloader/statesync.go index cf5c78ac37..f78541c051 100644 --- a/eth/downloader/statesync.go +++ b/eth/downloader/statesync.go @@ -306,7 +306,13 @@ func (s *stateSync) loop() error { // 2 items are the minimum requested, if even that times out, we've no use of // this peer at the moment. log.Warn("Stalling state sync, dropping peer", "peer", req.peer.id) - s.d.dropPeer(req.peer.id) + if s.d.dropPeer == nil { + // The dropPeer method is nil when `--copydb` is used for a local copy. + // Timeouts can occur if e.g. compaction hits at the wrong time, and can be ignored + req.peer.log.Warn("Downloader wants to drop peer, but peerdrop-function is not set", "peer", req.peer.id) + } else { + s.d.dropPeer(req.peer.id) + } } // Process all the received blobs and check for stale delivery delivered, err := s.process(req)