diff --git a/shared/src/shared_builder.rs b/shared/src/shared_builder.rs index 72b0ce3343a..d547bb82617 100644 --- a/shared/src/shared_builder.rs +++ b/shared/src/shared_builder.rs @@ -446,10 +446,25 @@ impl SharedBuilder { let block_status_map = Arc::new(DashMap::new()); let assume_valid_targets = Arc::new(Mutex::new({ - if Self::check_assume_valid_target_already_exists(&sync_config, &snapshot) { + let not_exists_targets: Option> = + sync_config.assume_valid_targets.map(|targets| { + targets + .iter() + .filter(|&target_hash| { + let exists = snapshot.block_exists(target_hash); + if exists { + info!("assume valid target 0x{} already exists in db", target_hash); + } + exists + }) + .collect::>() + }); + + if not_exists_targets.is_some_and(|targets| targets.is_empty()) { + info!("all assume valid targets is already in db, CKB will do full verification from now on"); None } else { - sync_config.assume_valid_targets.clone() + not_exists_targets } }));