Skip to content

Commit 649deb6

Browse files
jsvisaholiman
andauthored
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 <[email protected]>
1 parent 1aa5520 commit 649deb6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

eth/downloader/skeleton.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ func (s *skeleton) processNewHead(head *types.Header, final *types.Header, force
648648
}
649649
if parent := rawdb.ReadSkeletonHeader(s.db, number-1); parent.Hash() != head.ParentHash {
650650
if force {
651-
log.Warn("Beacon chain forked", "ancestor", parent.Number, "hash", parent.Hash(), "want", head.ParentHash)
651+
log.Warn("Beacon chain forked", "ancestor", number-1, "hash", parent.Hash(), "want", head.ParentHash)
652652
}
653653
return true
654654
}

0 commit comments

Comments
 (0)