Skip to content

Commit

Permalink
Rename old_root to depth_based_root
Browse files Browse the repository at this point in the history
explain logic for the two root calculation
  • Loading branch information
coderofstuff committed Aug 24, 2024
1 parent a63acdb commit 46dbac3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions consensus/src/processes/pruning_proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,8 +1013,12 @@ impl PruningProofManager {
.map_err(|err| format!("level: {}, err: {}", level, err))
.unwrap();

// (New Logic) This is the root we calculated by going through block relations
let root = roots_by_level[level];
let old_root = if level != self.max_block_level as usize {
// (Old Logic) This is the root we can calculate given that the GD records are already filled
// The root calc logic below is the original logic before the on-demand higher level GD calculation
// We only need depth_based_root to sanity check the new logic
let depth_based_root = if level != self.max_block_level as usize {
let block_at_depth_m_at_next_level = self
.block_at_depth(&*ghostdag_stores[level + 1], selected_tip_by_level[level + 1], self.pruning_proof_m)
.map_err(|err| format!("level + 1: {}, err: {}", level + 1, err))
Expand All @@ -1036,8 +1040,8 @@ impl PruningProofManager {
block_at_depth_2m
};

// new root is expected to be always an ancestor of old root because new root takes a safety margin
assert!(self.reachability_service.is_dag_ancestor_of(root, old_root));
// new root is expected to be always an ancestor of depth_based_root because new root takes a safety margin
assert!(self.reachability_service.is_dag_ancestor_of(root, depth_based_root));

let mut headers = Vec::with_capacity(2 * self.pruning_proof_m as usize);
let mut queue = BinaryHeap::<Reverse<SortableBlock>>::new();
Expand Down

0 comments on commit 46dbac3

Please sign in to comment.