Skip to content

Commit cc6893b

Browse files
authored
fix(l1): force final progress print on snap sync phase completion (#6142)
## Motivation The snap sync progress logs are printed every 10s. When a phase finishes between prints, its progress bar is never shown at its final state — the next print detects the transition and jumps straight to the completion message, leaving the bar looking incomplete (e.g. stuck at 75%). ## Description Force a final `log_phase_progress()` call for the finishing phase right before `log_phase_completion()`, so the bar always reaches its end state before the completion line is printed. **Before:** ``` ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░ 75.0% ← stale, from 10s ago ✓ BLOCK HEADERS complete: 1,234 headers in 15s 200ms ── PHASE 2/8: ACCOUNT RANGES ────────────── ``` **After:** ``` ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% ← forced final print ✓ BLOCK HEADERS complete: 1,234 headers in 15s 200ms ── PHASE 2/8: ACCOUNT RANGES ────────────── ``` ## How to test Run a snap sync and observe that each phase's progress bar is printed at its final state before the completion message appears.
1 parent 13f553d commit cc6893b

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

crates/networking/p2p/network.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,22 @@ pub async fn periodically_show_peer_stats_during_syncing(
318318
if current_step != previous_step && current_step != CurrentStepValue::None {
319319
// Log completion of previous phase (if any)
320320
if previous_step != CurrentStepValue::None {
321-
let phase_elapsed = format_duration(phase_start_time.elapsed());
322-
log_phase_completion(
321+
// Force a final progress print so the bar doesn't look incomplete
322+
let phase_elapsed = phase_start_time.elapsed();
323+
let total_elapsed = format_duration(start.elapsed());
324+
log_phase_progress(
323325
previous_step,
324326
phase_elapsed,
327+
&total_elapsed,
328+
peer_number,
329+
&prev_interval,
330+
)
331+
.await;
332+
333+
let phase_elapsed_str = format_duration(phase_start_time.elapsed());
334+
log_phase_completion(
335+
previous_step,
336+
phase_elapsed_str,
325337
&phase_metrics(previous_step, &phase_start).await,
326338
);
327339
}

0 commit comments

Comments
 (0)