fix check for attaching to pre-finalized parent (#4161)

When the BN's head is reorged while shut down, reloading the BN will not
assign `BlockRef` to alternate branches. However, blocks from other
branches are still present in the database, leading to their descendants
incorrectly marked as `UnviableFork`. By restricting the check to blocks
that have been finalized, they should be reported as `MissingParent`
instead, eventually re-assigning a `BlockRef` to them.
This commit is contained in:
Etan Kissling 2022-09-22 20:33:26 +02:00 committed by GitHub
parent d697a54846
commit 6069003a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -211,7 +211,7 @@ proc addHeadBlock*(
# at this stage, but we can check if we've seen the parent block previously # at this stage, but we can check if we've seen the parent block previously
# and thus prevent requests for it to be downloaded again. # and thus prevent requests for it to be downloaded again.
let parentId = dag.getBlockId(blck.parent_root) let parentId = dag.getBlockId(blck.parent_root)
if parentId.isSome(): if parentId.isSome() and parentId.get.slot < dag.finalizedHead.slot:
debug "Block unviable due to pre-finalized-checkpoint parent", debug "Block unviable due to pre-finalized-checkpoint parent",
parentId = parentId.get() parentId = parentId.get()
return err(BlockError.UnviableFork) return err(BlockError.UnviableFork)