-
Notifications
You must be signed in to change notification settings - Fork 162
chore(l1): add phase completion markers for snap sync validation #6189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The three validation functions (validate_state_root, validate_storage_root, validate_bytecodes) ran without emitting the ✓ phase completion markers that the docker monitor parses for Slack notification phase breakdowns. This made validation invisible in the per-phase timing reports. Add std::time::Instant timing and ✓ markers to all three validation functions, and register the corresponding patterns in docker_monitor.py so they appear in the Slack phase breakdown alongside the sync phases.
🤖 Kimi Code ReviewReview SummaryThe PR adds timing information to validation functions in snap sync and updates the Python monitoring script. Here are the issues found: 1. Code Duplication (snap_sync.rs:702-705, 737-740, 771-774)The elapsed time formatting is duplicated in three functions. Extract this into a helper: fn format_duration(duration: std::time::Duration) -> String {
let secs = duration.as_secs();
format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60)
}2. Inconsistent Logging (snap_sync.rs:703, 738, 772)The validation functions log completion times but use different patterns. Standardize the format string to match the Python regex expectations. 3. Regex Pattern Mismatch (docker_monitor.py:61-63)The Python regex patterns expect a count parameter (e.g., "State Root Validation": r"✓ STATE ROOT VALIDATION complete: state root verified in (\d+:\d{2}:\d{2})",
"Storage Root Validation": r"✓ STORAGE ROOT VALIDATION complete: all storage roots verified in (\d+:\d{2}:\d{2})",
"Bytecode Validation": r"✓ BYTECODE VALIDATION complete: all bytecodes verified in (\d+:\d{2}:\d{2})",4. Process Exit on Validation FailureThe functions call 5. Minor Typo (snap_sync.rs:706)"Succesfully" should be "Successfully". The changes are generally safe but could benefit from the refactoring above for maintainability. Automated review by Kimi (Moonshot AI) · custom prompt |
🤖 Codex Code ReviewReview summary Notes / Minor suggestions
No further issues spotted. Automated review by OpenAI Codex · custom prompt |
🤖 Claude Code ReviewIt seems the patterns are defined in the Python file but the actual log emission might be elsewhere. Let me look at the bigger picture of the validation logic and check the actual changes more carefully. Now I have enough context to provide a comprehensive code review. PR Review: Add phase completion markers for snap sync validationSummaryThis PR adds timing instrumentation and phase completion markers to three post-sync validation functions in snap sync. The changes are straightforward and well-motivated - they improve observability without altering validation logic. ✅ Positives
Issues Found1. CRITICAL: Timing Only Captures Success Path (snap_sync.rs:705-712)Bug in if validated.is_ok() {
info!("Succesfully validated tree, {state_root} found");
info!("✓ STATE ROOT VALIDATION complete: state root verified in {elapsed_str}");
} else {
error!("We have failed the validation of the state tree");
std::process::exit(1);
}The completion marker is only emitted on success, but timing is measured before the branch. If validation fails, the elapsed time is computed but never logged. This means the docker monitor will:
Suggestion: Emit timing info before Same issue exists in 2. Minor: Typo in Original Code (snap_sync.rs:706)info!("Succesfully validated tree, {state_root} found");Should be "Successfully" (double-s). Not introduced by this PR, but worth fixing. 3. Code Quality: Duplicate Timing Formatting Logic (multiple locations)The time formatting is duplicated across all three functions: let elapsed = start.elapsed();
let secs = elapsed.as_secs();
let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60);Suggestion: Extract to a helper function: fn format_duration(duration: std::time::Duration) -> String {
let secs = duration.as_secs();
format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60)
}This would reduce duplication and make timing format changes easier. 4. Python Regex Pattern Mismatch Risk (docker_monitor.py:61-63)The regex patterns use "State Root Validation": r"✓ STATE ROOT VALIDATION complete: ([\w ]+) in (\d+:\d{2}:\d{2})",This expects alphanumeric + spaces only, which matches current outputs:
Risk: If you later add punctuation (e.g., "state root verified (123 nodes)"), the regex will break. Consider using 5. Consistency: Variable Position (snap_sync.rs:750)In However, note that 6. Potential Issue: Regex Group Capture InconsistencyOther phase patterns capture count as group 1 and time as group 2: "Bytecodes": r"✓ BYTECODES complete: ([\d,]+) bytecodes in (\d+:\d{2}:\d{2})",The new validation patterns capture description text as group 1: "State Root Validation": r"✓ STATE ROOT VALIDATION complete: ([\w ]+) in (\d+:\d{2}:\d{2})",Risk: If the Python parsing code expects group 1 to always be a numeric count for statistics, this could break. Check how Ethereum-Specific Considerations✅ No consensus/EVM impact - purely observability changes RecommendationsMust Fix (P0):
Should Fix (P1):
Nice to Have (P2):
VerdictApprove with required changes. The core change is sound, but the timing measurement should account for failure paths to avoid incomplete monitoring data. The Python regex patterns should be validated against actual monitor parsing logic to ensure compatibility. Automated review by Claude (Anthropic) · custom prompt |
Greptile OverviewGreptile SummaryAdds phase completion markers with timing to three post-sync validation functions ( Key changes:
The implementation is clean and consistent with existing patterns in the codebase. All timing calculations use the same HH:MM:SS format used elsewhere. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| crates/networking/p2p/sync/snap_sync.rs | Added timing instrumentation and completion markers for three validation functions (validate_state_root, validate_storage_root, validate_bytecodes). Clean, consistent implementation following existing patterns. |
| tooling/sync/docker_monitor.py | Added three new regex patterns to PHASE_COMPLETION_PATTERNS dict to capture validation phase timing from logs. Patterns correctly match the new log messages. |
Lines of code reportTotal lines added: Detailed view |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds missing phase-completion markers for the three post-snap-sync validation steps so the docker monitor can include validation time in the Slack per-phase breakdown.
Changes:
- Time
validate_state_root,validate_storage_root, andvalidate_bytecodesand emit✓ ... VALIDATION complete:markers with HH:MM:SS durations. - Register new validation completion regexes in the docker monitor so these phases appear in the Slack phase breakdown.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tooling/sync/docker_monitor.py | Adds PHASE_COMPLETION_PATTERNS entries to detect the new validation completion markers and include them in Slack phase breakdowns. |
| crates/networking/p2p/sync/snap_sync.rs | Adds timing and emits phase completion marker logs for state root, storage root, and bytecode validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let elapsed = start.elapsed(); | ||
| let secs = elapsed.as_secs(); | ||
| let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elapsed_str formatting logic is duplicated across the three validation functions. Consider extracting a small helper (or reusing the existing HH:MM:SS formatter used for sync phase logs in crates/networking/p2p/network.rs) so the duration format stays consistent and future changes only need to be made in one place.
| let secs = elapsed.as_secs(); | ||
| let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60); | ||
| if validated.is_ok() { | ||
| info!("Succesfully validated tree, {state_root} found"); |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in log message: "Succesfully" should be "Successfully".
| info!("Succesfully validated tree, {state_root} found"); | |
| info!("Successfully validated tree, {state_root} found"); |
Motivation
The three post-sync validation steps (
validate_state_root,validate_storage_root,validate_bytecodes) run after snap sync healing but don't emit✓phase completion markers. This makes them invisible in the docker monitor's Slack notification phase breakdown — validation time is unaccounted for in the per-phase timing report.Description
std::time::Instanttiming to all three validation functions insnap_sync.rs✓markers matching the format used by other phases (e.g.✓ STATE ROOT VALIDATION complete: state root verified in HH:MM:SS)docker_monitor.py'sPHASE_COMPLETION_PATTERNSso they appear in the Slack phase breakdownHow to Test
release-with-debug-assertionsprofile (validation only runs insidedebug_assert!)✓ STATE ROOT VALIDATION complete:,✓ STORAGE ROOT VALIDATION complete:,✓ BYTECODE VALIDATION complete:markers with timing