fix pruned backfill summary (fixes #4552)

When enabling pruned history mode, the backfill summary as it was
computed with full backfilling may be pruned - don't try to load it on
init
This commit is contained in:
Jacek Sieka 2023-01-25 11:26:58 +01:00 committed by Zahary Karadjov
parent fa27ce76a3
commit 0c1686eb20
No known key found for this signature in database
GPG Key ID: C1F42EAFF38D570F
1 changed files with 4 additions and 1 deletions

View File

@ -1097,7 +1097,10 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
dag.backfill = block:
let backfillSlot = db.finalizedBlocks.low.expect("tail at least")
if backfillSlot < dag.tail.slot:
if backfillSlot <= dag.horizon:
# Backfill done, no need to load anything
BeaconBlockSummary()
elif backfillSlot < dag.tail.slot:
let backfillRoot = db.finalizedBlocks.get(backfillSlot).expect(
"low to be loadable")