fix light client data pruning (#3523)

When eliminating orphaned forks, light client data about blocks was also
deleted when the orphaned fork was referring to a state several slots
after the block. Linking light client data pruning with block deletion
instead of state deletion fixes this problem. Light client data always
refers to blocks and their immediate post-state.
This commit is contained in:
Etan Kissling 2022-03-20 10:09:43 +01:00 committed by GitHub
parent ca045900c8
commit 04b851f775
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -1252,13 +1252,14 @@ proc pruneBlocksDAG(dag: ChainDAGRef) =
var cur = head.atSlot() var cur = head.atSlot()
while not cur.blck.isAncestorOf(dag.finalizedHead.blck): while not cur.blck.isAncestorOf(dag.finalizedHead.blck):
# Update light client data
dag.deleteLightClientData(cur.blck.bid)
# TODO: should we move that disk I/O to `onSlotEnd` # TODO: should we move that disk I/O to `onSlotEnd`
dag.delState(cur.toBlockSlotId().expect("not nil")) dag.delState(cur.toBlockSlotId().expect("not nil"))
if cur.isProposed(): if cur.isProposed():
# Update light client data
dag.deleteLightClientData(cur.blck.bid)
dag.forkBlocks.excl(KeyedBlockRef.init(cur.blck)) dag.forkBlocks.excl(KeyedBlockRef.init(cur.blck))
dag.db.delBlock(cur.blck.root) dag.db.delBlock(cur.blck.root)