Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions crates/networking/p2p/sync/snap_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ pub fn calculate_staleness_timestamp(timestamp: u64) -> u64 {

pub async fn validate_state_root(store: Store, state_root: H256) -> bool {
info!("Starting validate_state_root");
let start = std::time::Instant::now();
let validated = tokio::task::spawn_blocking(move || {
store
.open_locked_state_trie(state_root)
Expand All @@ -698,8 +699,12 @@ pub async fn validate_state_root(store: Store, state_root: H256) -> bool {
.await
.expect("We should be able to create threads");

let elapsed = start.elapsed();
let secs = elapsed.as_secs();
let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60);
Comment on lines +702 to +704
Copy link

Copilot AI Feb 12, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This formatting is repeated three times in this PR. There's already a format_duration helper in network.rs:678 that does exactly the same thing:

fn format_duration(duration: Duration) -> String {
    let total_seconds = duration.as_secs();
    let hours = total_seconds / 3600;
    let minutes = (total_seconds % 3600) / 60;
    let seconds = total_seconds % 60;
    format!("{hours:02}:{minutes:02}:{seconds:02}")
}

Making it pub(crate) would let you replace the 3-line block with let elapsed_str = format_duration(start.elapsed()); everywhere.

if validated.is_ok() {
info!("Succesfully validated tree, {state_root} found");
Copy link

Copilot AI Feb 12, 2026

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".

Suggested change
info!("Succesfully validated tree, {state_root} found");
info!("Successfully validated tree, {state_root} found");

Copilot uses AI. Check for mistakes.
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);
Expand All @@ -709,6 +714,7 @@ pub async fn validate_state_root(store: Store, state_root: H256) -> bool {

pub async fn validate_storage_root(store: Store, state_root: H256) -> bool {
info!("Starting validate_storage_root");
let start = std::time::Instant::now();
let is_valid = tokio::task::spawn_blocking(move || {
store
.iter_accounts(state_root)
Expand All @@ -728,15 +734,20 @@ pub async fn validate_storage_root(store: Store, state_root: H256) -> bool {
})
.await
.expect("We should be able to create threads");
let elapsed = start.elapsed();
let secs = elapsed.as_secs();
let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60);
info!("Finished validate_storage_root");
if is_valid.is_err() {
std::process::exit(1);
}
info!("✓ STORAGE ROOT VALIDATION complete: all storage roots verified in {elapsed_str}");
is_valid.is_ok()
}

pub fn validate_bytecodes(store: Store, state_root: H256) -> bool {
info!("Starting validate_bytecodes");
let start = std::time::Instant::now();
let mut is_valid = true;
for (account_hash, account_state) in store
.iter_accounts(state_root)
Expand All @@ -757,6 +768,10 @@ pub fn validate_bytecodes(store: Store, state_root: H256) -> bool {
if !is_valid {
std::process::exit(1);
}
let elapsed = start.elapsed();
let secs = elapsed.as_secs();
let elapsed_str = format!("{:02}:{:02}:{:02}", secs / 3600, (secs % 3600) / 60, secs % 60);
info!("✓ BYTECODE VALIDATION complete: all bytecodes verified in {elapsed_str}");
is_valid
}

Expand Down
3 changes: 3 additions & 0 deletions tooling/sync/docker_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
"State Healing": r"✓ STATE HEALING complete: ([\d,]+) state paths healed in (\d+:\d{2}:\d{2})",
"Storage Healing": r"✓ STORAGE HEALING complete: ([\d,]+) storage accounts healed in (\d+:\d{2}:\d{2})",
"Bytecodes": r"✓ BYTECODES complete: ([\d,]+) bytecodes in (\d+:\d{2}:\d{2})",
"State Root Validation": r"✓ STATE ROOT VALIDATION complete: ([\w ]+) in (\d+:\d{2}:\d{2})",
"Storage Root Validation": r"✓ STORAGE ROOT VALIDATION complete: ([\w ]+) in (\d+:\d{2}:\d{2})",
"Bytecode Validation": r"✓ BYTECODE VALIDATION complete: ([\w ]+) in (\d+:\d{2}:\d{2})",
}


Expand Down
Loading