diff --git a/indexer/beacon/finalization.go b/indexer/beacon/finalization.go index fbddf22..7bb4eda 100644 --- a/indexer/beacon/finalization.go +++ b/indexer/beacon/finalization.go @@ -369,6 +369,12 @@ func (indexer *Indexer) finalizeEpoch(epoch phase0.Epoch, justifiedRoot phase0.R t1 = time.Now() + // clean fork cache + indexer.forkCache.setFinalizedEpoch(deleteBeforeSlot, justifiedRoot) + for _, fork := range indexer.forkCache.getForksBefore(deleteBeforeSlot) { + indexer.forkCache.removeFork(fork.forkId) + } + // clean epoch stats indexer.epochCache.removeEpochStatsByEpoch(epoch) @@ -380,12 +386,6 @@ func (indexer *Indexer) finalizeEpoch(epoch phase0.Epoch, justifiedRoot phase0.R indexer.blockCache.removeBlock(block) } - // clean fork cache - indexer.forkCache.setFinalizedEpoch(deleteBeforeSlot, justifiedRoot) - for _, fork := range indexer.forkCache.getForksBefore(deleteBeforeSlot) { - indexer.forkCache.removeFork(fork.forkId) - } - // log summary indexer.logger.Infof("completed epoch %v finalization (process: %v ms, load: %v s, write: %v ms, clean: %v ms)", epoch, t1dur.Milliseconds(), t1loading.Seconds(), t2dur.Milliseconds(), time.Since(t1).Milliseconds()) indexer.logger.Infof("epoch %v blocks: %v canonical, %v orphaned", epoch, len(canonicalBlocks), len(orphanedBlocks))