From f94f530c5d8deb67ea7a1f020a02cd7cdb6c0d40 Mon Sep 17 00:00:00 2001 From: pk910 Date: Tue, 17 Sep 2024 16:08:44 +0200 Subject: [PATCH] fix nil pointer panic in finalization routine when dependent block of a orphaned block cannot be loaded --- indexer/beacon/finalization.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indexer/beacon/finalization.go b/indexer/beacon/finalization.go index aeb51f92..f3ea3bf1 100644 --- a/indexer/beacon/finalization.go +++ b/indexer/beacon/finalization.go @@ -313,7 +313,11 @@ func (indexer *Indexer) finalizeEpoch(epoch phase0.Epoch, justifiedRoot phase0.R // persist orphaned blocks for _, block := range orphanedBlocks { dependentBlock := indexer.blockCache.getDependentBlock(chainState, block, client) - epochStats := indexer.epochCache.getEpochStats(epoch, dependentBlock.Root) + + var epochStats *EpochStats + if dependentBlock != nil { + epochStats = indexer.epochCache.getEpochStats(epoch, dependentBlock.Root) + } if _, err := indexer.dbWriter.persistBlockData(tx, block, epochStats, nil, true, nil); err != nil { return fmt.Errorf("failed persisting orphaned slot %v (%v): %v", block.Slot, block.Root.String(), err)