Skip to content

Commit

Permalink
Merge pull request #101 from ethpandaops/pk910/fix-finalization-order
Browse files Browse the repository at this point in the history
process fork cache finalization before cleaning up finalized blocks
  • Loading branch information
pk910 committed Aug 17, 2024
2 parents efb55e3 + 0ca6c06 commit b762c1f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions indexer/beacon/finalization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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))
Expand Down

0 comments on commit b762c1f

Please sign in to comment.