diff --git a/utils/host/src/block_range.rs b/utils/host/src/block_range.rs index fb829ae0..4f7cf49e 100644 --- a/utils/host/src/block_range.rs +++ b/utils/host/src/block_range.rs @@ -162,7 +162,7 @@ pub async fn split_range_based_on_safe_heads( // Loop over all of the safe heads and create ranges. for safe_head in safe_heads { - if safe_head > current_l2_start { + if safe_head > current_l2_start && current_l2_start < l2_end { let mut range_start = current_l2_start; while range_start + max_range_size < min(l2_end, safe_head) { ranges.push(SpanBatchRange { diff --git a/utils/host/src/fetcher.rs b/utils/host/src/fetcher.rs index 5ff96d4a..9a5cf461 100644 --- a/utils/host/src/fetcher.rs +++ b/utils/host/src/fetcher.rs @@ -767,7 +767,16 @@ impl OPSuccinctDataFetcher { }; let claimed_l2_output_root = keccak256(l2_claim_encoded.abi_encode()); - let (l1_head_hash, _) = self.get_l1_head(l2_end_block).await?; + let (_, l1_head_number) = self.get_l1_head(l2_end_block).await?; + + // FIXME: Investigate requirement for L1 head offset beyond batch posting block with safe head > L2 end block. + let l1_head_number = l1_head_number + 20; + // The new L1 header requested should not be greater than the latest L1 header. + let latest_l1_header = self.get_l1_header(BlockId::latest()).await?; + let l1_head_hash = match l1_head_number > latest_l1_header.number { + true => latest_l1_header.hash_slow(), + false => self.get_l1_header(l1_head_number.into()).await?.hash_slow(), + }; // Get the workspace root, which is where the data directory is. let data_directory = @@ -887,7 +896,7 @@ impl OPSuccinctDataFetcher { ) .await?; let l2_safe_head = result.safe_head.number; - // If the safe head is greater than or equal to the L2 end block at this L1 block, then we can derive the L2 end block from this L1 block. + // If the safe head is GTE to the L2 end block at this L1 block, then we can derive the L2 end block from this L1 block. if l2_safe_head >= l2_end_block { return Ok((result.l1_block.hash, result.l1_block.number)); }