Fix fillInMissingBlocks (#11353)

* Fix fillInMissingBlocks

Only check that the chain's parent is in forkchoice, rather than it
being the finalized checkpoint. Forkchoice anyway guarantees that the
chain will be a descendant of the finalized checkpoint.

* ensure root is not zero

* fix tests

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Potuz 2022-09-01 11:40:32 -03:00 committed by GitHub
parent c4deb84012
commit 84bc8f3d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -277,7 +277,7 @@ func (s *Service) fillInForkChoiceMissingBlocks(ctx context.Context, blk interfa
if len(pendingNodes) == 1 { if len(pendingNodes) == 1 {
return nil return nil
} }
if root != s.ensureRootNotZeros(finalized.Root) { if root != s.ensureRootNotZeros(finalized.Root) && !s.ForkChoicer().HasNode(root) {
return errNotDescendantOfFinalized return errNotDescendantOfFinalized
} }
return s.cfg.ForkChoiceStore.InsertOptimisticChain(ctx, pendingNodes) return s.cfg.ForkChoiceStore.InsertOptimisticChain(ctx, pendingNodes)