Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions beacon-chain/db/kv/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,18 @@ func (s *Store) DeleteHistoricalDataBeforeSlot(ctx context.Context, cutoffSlot p
return nil
}

// Remove the child from its parent's index before deleting the block itself.
// This keeps the parentRoot -> [children] index consistent during pruning.
if enc := tx.Bucket(blocksBucket).Get(sr.root[:]); enc != nil {
blk, uerr := unmarshalBlock(ctx, enc)
if uerr != nil {
return uerr
}
if derr := s.deleteMatchingParentIndex(tx, blk.Block().ParentRoot(), sr.root); derr != nil {
return derr
}
}

// Delete block
if err = s.deleteBlock(tx, sr.root[:]); err != nil {
return err
Expand Down
3 changes: 3 additions & 0 deletions changelog/Galoretka_db-kv-prune-parent-index-cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Fixed

- Remove pruned blocks from parent index during historical deletion