@@ -211,12 +211,9 @@ impl<BaseLayerType: BaseLayerContract + Send + Sync + Debug> L1Scraper<BaseLayer
211211 . await
212212 . map_err ( L1ScraperError :: BaseLayerError ) ?;
213213
214- let Some ( latest_l1_block) = latest_l1_block else {
215- // TODO(guyn): get rid of finality_too_high, use a better error.
216- return Err (
217- L1ScraperError :: finality_too_high ( self . config . finality , & self . base_layer ) . await
218- ) ;
219- } ;
214+ let latest_l1_block = latest_l1_block
215+ . ok_or ( L1ScraperError :: MissingBlock { block_number : latest_l1_block_number } ) ?;
216+
220217 let Some ( scrape_from_this_l1_block) = self . scrape_from_this_l1_block else {
221218 panic ! ( "Should never fetch events without first getting the last processed L1 block." ) ;
222219 } ;
@@ -432,6 +429,8 @@ pub enum L1ScraperError<BaseLayerType: BaseLayerContract + Send + Sync + Debug>
432429 {latest_l1_block_no_finality:?}"
433430 ) ]
434431 FinalityTooHigh { finality : u64 , latest_l1_block_no_finality : L1BlockNumber } ,
432+ #[ error( "Block number {block_number} not found" ) ]
433+ MissingBlock { block_number : L1BlockNumber } ,
435434 #[ error( "Failed to calculate hash: {0}" ) ]
436435 HashCalculationError ( StarknetApiError ) ,
437436 // Leaky abstraction, these errors should not propagate here.
@@ -465,25 +464,6 @@ impl<BaseLayerType: BaseLayerContract + Send + Sync + Debug> PartialEq
465464 }
466465}
467466
468- // TODO(guyn): get rid of finality_too_high, just use the new error FinalityTooHigh.
469- impl < BaseLayerType : BaseLayerContract + Send + Sync + Debug > L1ScraperError < BaseLayerType > {
470- /// Pass any base layer errors. In the rare case that the finality is bigger than the latest L1
471- /// block number, return FinalityTooHigh.
472- pub async fn finality_too_high (
473- finality : u64 ,
474- base_layer : & BaseLayerType ,
475- ) -> L1ScraperError < BaseLayerType > {
476- let latest_l1_block_number_no_finality = base_layer. latest_l1_block_number ( ) . await ;
477-
478- let latest_l1_block_no_finality = match latest_l1_block_number_no_finality {
479- Ok ( block_number) => block_number,
480- Err ( error) => return Self :: BaseLayerError ( error) ,
481- } ;
482-
483- Self :: FinalityTooHigh { finality, latest_l1_block_no_finality }
484- }
485- }
486-
487467fn handle_client_error < BaseLayerType : BaseLayerContract + Send + Sync + Debug > (
488468 client_result : Result < ( ) , L1ProviderClientError > ,
489469) -> Result < ( ) , L1ScraperError < BaseLayerType > > {
0 commit comments