Skip to content

Commit

Permalink
[review] address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akichidis committed Sep 19, 2024
1 parent 86f843e commit 0d782f5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion consensus/core/src/dag_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,9 @@ impl DagState {
self.last_committed_rounds.clone()
}

/// The latest Garbage Collection (GC) round that is calculated based on the latest committed leader round. When GC is disabled that will return the genesis round.
/// The GC round is the highest round that blocks of equal or lower round are considered obsolete and no longer possible to be committed.
/// There is no meaning accepting any blocks with round <= gc_round. The Garbage Collection (GC) round is calculated based on the latest
/// committed leader round. When GC is disabled that will return the genesis round.
pub(crate) fn gc_round(&self) -> Round {
let gc_depth = self.context.protocol_config.gc_depth();
if gc_depth > 0 {
Expand Down
4 changes: 3 additions & 1 deletion consensus/core/src/linearizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ impl Linearizer {
.filter(|ancestor| {
// We skip the block if we already committed it or we reached a
// round that we already committed.
// TODO: for Fast Path we need to ammend the recursion rule here and allow us to commit blocks all the way up to the `gc_round`.
// Some additional work will be needed to make sure that we keep the uncommitted blocks up to the `gc_round` across commits.
!committed.contains(ancestor)
&& last_committed_rounds[ancestor.author] < ancestor.round
})
Expand Down Expand Up @@ -99,7 +101,7 @@ impl Linearizer {
// The above code should have not yielded any blocks that are <= gc_round, but just to make sure that we'll never
// commit anything that should be garbage collected we attempt to prune here as well.
if gc_enabled {
to_commit.retain(|block| block.round() > gc_round);
assert!(to_commit.iter().all(|block| block.round() > gc_round), "No blocks <= {gc_round} should be committed. Commit index {}, leader round {}, blocks {to_commit:?}.", last_commit_index, leader_block_ref);
}

// Sort the blocks of the sub-dag blocks
Expand Down

0 comments on commit 0d782f5

Please sign in to comment.