fn step(&mut self) -> anyhow::Result<Option<StepStats>> {
        let repair_data = self
            .db
            .stale_keys_repair_data()
            .context("failed getting repair data")?;
        let min_stale_key_version = self.db.min_stale_key_version();
        let start_version = match (repair_data, min_stale_key_version) {
            (_, None) => {
                tracing::debug!("No stale keys in tree, nothing to do");
                return Ok(None);
            }
            (None, Some(version)) => version,
            (Some(data), Some(version)) => data.next_version.max(version),
        };

        let latest_version = self
            .db
            .manifest()
            .and_then(|manifest| manifest.version_count.checked_sub(1));
        let Some(latest_version) = latest_version else {
            tracing::warn!(
                min_stale_key_version,
                "Tree has stale keys, but no latest versions"
            );
            return Ok(None);
        };

        let end_version = (start_version + self.parallelism - 1).min(latest_version);
        let versions = start_version..=end_version;
        if versions.is_empty() {
            tracing::debug!(?versions, latest_version, "No tree versions to check");
            return Ok(None);
        }

        tracing::debug!(
            ?versions,
            latest_version,
            ?min_stale_key_version,
            "Checking stale keys"
        );

        let stale_keys = versions
            .clone()
            .into_par_iter()
            .map(|version| {
                Self::bogus_stale_keys(&self.db, version)
                    .into_iter()
                    .map(|key| StaleNodeKey::new(key, version))
                    .collect::<Vec<_>>()
            })
            .reduce(Vec::new, |mut acc, keys| {
                acc.extend(keys);
                acc
            });
        self.update_task_data(versions.clone(), &stale_keys)?;

        Ok(Some(StepStats {
            checked_versions: versions,
            repaired_key_count: stale_keys.len(),
        }))
    }
Returns a boolean flag indicating whether the task data was updated.
core/lib/merkle_tree/src/repair.rs