From 3cd7cebc7c0cce94f17de5c329202eab4f1a5caa Mon Sep 17 00:00:00 2001 From: Jacek Sieka Date: Thu, 1 Apr 2021 13:26:17 +0200 Subject: [PATCH] Fix block dag pruning frequency (#2469) Should always prune after finality change but not more than once --- .../consensus_object_pools/blockchain_dag.nim | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 36a721f53..3bd134502 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -874,7 +874,7 @@ proc delState(dag: ChainDAGRef, bs: BlockSlot) = proc pruneBlocksDAG(dag: ChainDAGRef) = ## This prunes the block DAG ## This does NOT prune the cached state checkpoints and EpochRef - ## This should be done after a new finalization point is reached + ## This must be done after a new finalization point is reached ## to invalidate pending blocks or attestations referring ## to a now invalid fork. ## @@ -882,43 +882,39 @@ proc pruneBlocksDAG(dag: ChainDAGRef) = ## as the caches and fork choice can be pruned at a later time. # Clean up block refs, walking block by block - if dag.lastPrunePoint != dag.finalizedHead: - let start = Moment.now() + let start = Moment.now() - # Finalization means that we choose a single chain as the canonical one - - # it also means we're no longer interested in any branches from that chain - # up to the finalization point - let hlen = dag.heads.len - for i in 0..