Skip to content

Commit

Permalink
Explain finished headers logic
Browse files Browse the repository at this point in the history
Add back the panic if we couldn't find the required block and our headers are done

Add explanation in comment for why trying anyway if finished_headers is acceptable
  • Loading branch information
coderofstuff committed Aug 24, 2024
1 parent fb3d1e9 commit c9855d3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions consensus/src/processes/pruning_proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -943,8 +943,16 @@ impl PruningProofManager {

tries += 1;
if finished_headers {
warn!("Failed to find sufficient root for level {level} after {tries} tries. Headers below the current depth of {required_level_0_depth} are already pruned. Trying anyway.");
break Ok((ghostdag_store, selected_tip, root));
if has_required_block {
// Normally this scenario doesn't occur when syncing with nodes that already have the safety margin change in place.
// However, when syncing with an older node version that doesn't have a safety margin for the proof, it's possible to
// try to find 2500 depth worth of headers at a level, but the proof only contains about 2000 headers. To be able to sync
// with such an older node. As long as we found the required block, we can still proceed.
warn!("Failed to find sufficient root for level {level} after {tries} tries. Headers below the current depth of {required_level_0_depth} are already pruned. Required block found so trying anyway.");
break Ok((ghostdag_store, selected_tip, root));
} else {
panic!("Failed to find sufficient root for level {level} after {tries} tries. Headers below the current depth of {required_level_0_depth} are already pruned");
}
}
required_level_0_depth <<= 1;
warn!("Failed to find sufficient root for level {level} after {tries} tries. Retrying again to find with depth {required_level_0_depth}");
Expand Down

0 comments on commit c9855d3

Please sign in to comment.