From 649deb69f3b93c2ac35bdf910ec9d3a68fc2fb77 Mon Sep 17 00:00:00 2001 From: Delweng Date: Fri, 18 Aug 2023 05:15:29 +0800 Subject: [PATCH] eth/downloader: fix rare crash when parent header missing in db (#27945) ReadSkeletonHeader can return nil if the header is missing, so we should not access fields on it. Note that calling .Hash() on a nil header is fine, so there is no need to actually check for nil. Co-authored-by: Martin Holst Swende --- eth/downloader/skeleton.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/downloader/skeleton.go b/eth/downloader/skeleton.go index 79f4e37dc..59df82bd9 100644 --- a/eth/downloader/skeleton.go +++ b/eth/downloader/skeleton.go @@ -648,7 +648,7 @@ func (s *skeleton) processNewHead(head *types.Header, final *types.Header, force } if parent := rawdb.ReadSkeletonHeader(s.db, number-1); parent.Hash() != head.ParentHash { if force { - log.Warn("Beacon chain forked", "ancestor", parent.Number, "hash", parent.Hash(), "want", head.ParentHash) + log.Warn("Beacon chain forked", "ancestor", number-1, "hash", parent.Hash(), "want", head.ParentHash) } return true }