Skip to content

Commit

Permalink
[refactor] make sure that blocks that are reported as missing when tr…
Browse files Browse the repository at this point in the history
…y_find_blocks they are also reported on the missing_ancestors map to allow us seamlessly GC them.
  • Loading branch information
akichidis committed Jan 27, 2025
1 parent d350bf5 commit 39f1a9b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion consensus/core/src/block_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ impl BlockManager {
// Fetches the block if it is not in dag state or suspended.
missing_blocks.insert(*block_ref);
if self.missing_blocks.insert(*block_ref) {
// We want to report this as a missing ancestor even if there is no block that is actually references it right now. That will allow us
// to seamlessly GC the block later if needed.
self.missing_ancestors.entry(*block_ref).or_default();

let block_ref_hostname =
&self.context.committee.authority(block_ref.author).hostname;
self.context
Expand Down Expand Up @@ -483,7 +487,7 @@ impl BlockManager {
// If the first block in the missing ancestors is higher than the gc_round, then we can't unsuspend it yet. So we just put it back
// and we terminate the iteration as any next entry will be of equal or higher round anyways.
if block_ref.round > gc_round {
return;
break;
}

blocks_gc_ed += 1;
Expand Down

0 comments on commit 39f1a9b

Please sign in to comment.