Skip to content

Commit

Permalink
make fork detection more resilent for non-permanent execution (dev se…
Browse files Browse the repository at this point in the history
…tups)
  • Loading branch information
pk910 committed Feb 7, 2025
1 parent 898c4f9 commit 5c4732d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions indexer/beacon/forkdetection.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ func (cache *forkCache) processBlock(block *Block) error {
}
}

// avoid using forkid 0 for unfinalized blocks, add a new temporary forkid if needed
if currentForkId == 0 && parentIsFinalized {
cache.lastForkId++
fork := newFork(cache.lastForkId, parentSlot, *parentRoot, block, parentForkId)
cache.addFork(fork)

currentForkId = cache.lastForkId
cache.indexer.logger.Infof("new fork for canonical chain (base(%v) %v [%v], head(%v) %v [%v])", parentForkId, parentSlot, parentRoot.String(), currentForkId, block.Slot, block.Root.String())
}

// check scenario 2
childBlocks := make([]*Block, 0)
for _, child := range cache.indexer.blockCache.getBlocksByParentRoot(block.Root) {
Expand Down

0 comments on commit 5c4732d

Please sign in to comment.