async fn detect_reorg(
        &self,
        known_valid_l1_batch: L1BatchNumber,
        diverged_l1_batch: L1BatchNumber,
    ) -> Result<L1BatchNumber, HashMatchError> {
        // TODO (BFT-176, BFT-181): We have to look through the whole history, since batch status updater may mark
        //   a block as executed even if the state diverges for it.
        binary_search_with(
            known_valid_l1_batch.0,
            diverged_l1_batch.0,
            |number| async move {
                match self
                    .root_hashes_and_contents_match(L1BatchNumber(number))
                    .await
                {
                    Err(HashMatchError::MissingData(_)) => Ok(true),
                    res => res,
                }
            },
        )
        .await
        .map(L1BatchNumber)
    }
Localizes a re-org: performs binary search to determine the last non-diverged L1 batch.
core/node/reorg_detector/src/lib.rs