@@ -198,19 +198,24 @@ def import_blocks_until_done
198198
199199 begin
200200 loop do
201+ ImportProfiler . start ( "import_blocks_until_done_loop" )
201202 # Check for validation failures
203+ ImportProfiler . start ( "real_validation_failure_detected" )
202204 if real_validation_failure_detected?
203205 failed_block = get_validation_failure_block
204206 logger . error "Import stopped due to validation failure at block #{ failed_block } "
205207 raise ValidationFailureError . new ( "Validation failure detected at block #{ failed_block } " )
206208 end
209+ ImportProfiler . stop ( "real_validation_failure_detected" )
207210
208211 # Check if validation is stalled
212+ ImportProfiler . start ( "validation_stalled" )
209213 if validation_stalled?
210214 current_position = current_max_eth_block_number
211215 logger . warn "Import paused - validation is behind (current: #{ current_position } )"
212216 raise ValidationStalledError . new ( "Validation stalled - waiting for validation to catch up" )
213217 end
218+ ImportProfiler . stop ( "validation_stalled" )
214219
215220 block_number = next_block_to_import
216221
@@ -252,6 +257,8 @@ def import_blocks_until_done
252257 rescue => e
253258 logger . error "Import error: #{ e . message } "
254259 raise e
260+ ensure
261+ ImportProfiler . stop ( "import_blocks_until_done_loop" )
255262 end
256263 end
257264 end
@@ -383,9 +390,9 @@ def import_single_block(block_number)
383390 ValidationJob . perform_later ( block_number , l2_block_hashes )
384391 end
385392
386- ImportProfiler . stop ( "import_single_block" )
387-
388393 [ imported_ethscriptions_blocks , [ eth_block ] ]
394+ ensure
395+ ImportProfiler . stop ( "import_single_block" )
389396 end
390397
391398 def import_next_block
@@ -486,6 +493,8 @@ def cleanup_stale_validation_records
486493
487494 def report_import_stats ( blocks_imported_count :, stats_start_time :, stats_start_block :,
488495 total_gas_used :, total_transactions :, imported_l2_blocks :, recent_batch_time :)
496+ ImportProfiler . start ( "report_import_stats" )
497+
489498 elapsed_time = Time . current - stats_start_time
490499 current_block = current_max_eth_block_number
491500
@@ -521,7 +530,6 @@ def report_import_stats(blocks_imported_count:, stats_start_time:, stats_start_b
521530 if ENV . fetch ( 'VALIDATION_ENABLED' ) . casecmp? ( 'true' )
522531 last_validated = ValidationResult . last_validated_block || 0
523532 validation_lag = current_block - last_validated
524- validation_stats = ValidationResult . validation_stats ( since : 1 . hour . ago )
525533
526534 lag_status = case validation_lag
527535 when 0 ..5 then "✅ CURRENT"
@@ -530,11 +538,7 @@ def report_import_stats(blocks_imported_count:, stats_start_time:, stats_start_b
530538 else "🔴 VERY BEHIND"
531539 end
532540
533- if validation_stats [ :total ] > 0
534- validation_line = "🔍 VALIDATION: #{ lag_status } (#{ validation_lag } behind) | #{ validation_stats [ :passed ] } /#{ validation_stats [ :total ] } passed (#{ validation_stats [ :pass_rate ] } %)"
535- else
536- validation_line = "🔍 VALIDATION: #{ lag_status } (#{ validation_lag } behind) | No validations completed yet"
537- end
541+ validation_line = "🔍 VALIDATION: #{ lag_status } (#{ validation_lag } behind)"
538542 else
539543 validation_line = "🔍 Validation: DISABLED"
540544 end
@@ -558,6 +562,7 @@ def report_import_stats(blocks_imported_count:, stats_start_time:, stats_start_b
558562 if ImportProfiler . enabled?
559563 logger . info ""
560564 logger . info "🔍 DETAILED PROFILER STATS:"
565+ ImportProfiler . stop ( "report_import_stats" )
561566 ImportProfiler . report
562567 ImportProfiler . reset
563568 end
@@ -567,15 +572,6 @@ def report_import_stats(blocks_imported_count:, stats_start_time:, stats_start_b
567572
568573 public
569574
570- def validation_summary
571- return nil unless ENV . fetch ( 'VALIDATION_ENABLED' ) . casecmp? ( 'true' )
572-
573- stats = ValidationResult . validation_stats ( since : 1 . hour . ago )
574- return "No validations completed" if stats [ :total ] == 0
575-
576- "#{ stats [ :passed ] } /#{ stats [ :total ] } passed (#{ stats [ :pass_rate ] } %), #{ stats [ :failed ] } failed"
577- end
578-
579575 def shutdown
580576 @prefetcher &.shutdown
581577 end
0 commit comments