From fce48871bbf6a6ffb6c00edaffa817d4f2fbbf20 Mon Sep 17 00:00:00 2001 From: Eugen Zalinescu Date: Fri, 28 Jun 2024 16:00:09 +0200 Subject: [PATCH] DAL/Node: emit error when not able to fetch block in crawler --- src/bin_dal_node/crawler.ml | 35 +++++++++++++++++++++++++---------- src/bin_dal_node/event.ml | 17 +++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/bin_dal_node/crawler.ml b/src/bin_dal_node/crawler.ml index c115c8683db3..935a081cce07 100644 --- a/src/bin_dal_node/crawler.ml +++ b/src/bin_dal_node/crawler.ml @@ -77,16 +77,31 @@ let finalized_heads_monitor ~name ~last_notified_level crawler_lib cctxt (* This block header is already notified or not targetted by the user. *) return acc else - let* pred_hash, _level = - get_predecessor crawler_lib hash shell_header.level - in - let* pred_shell_header = - fetch_tezos_shell_header cctxt headers_cache pred_hash - in - catch_up_if_needed - pred_hash - pred_shell_header - ((hash, shell_header) :: acc) + let*! res = get_predecessor crawler_lib hash shell_header.level in + match res with + | Error err -> + let*! () = + Event.(emit failed_to_fetch_block) + ("hash", Int32.pred shell_header.level, !last_notified_level, err) + in + return acc + | Ok (pred_hash, _level) -> ( + let*! res = fetch_tezos_shell_header cctxt headers_cache pred_hash in + match res with + | Error err -> + let*! () = + Event.(emit failed_to_fetch_block) + ( "hash", + Int32.pred shell_header.level, + !last_notified_level, + err ) + in + return acc + | Ok pred_shell_header -> + catch_up_if_needed + pred_hash + pred_shell_header + ((hash, shell_header) :: acc)) in let process (hash, Block_header.{shell = shell_header; _}) = let shell_header_level = shell_header.level in diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 15257aa41d07..bc3f169f805a 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -176,6 +176,23 @@ let daemon_error = ~pp1:Error_monad.pp_print_trace ("error", Error_monad.trace_encoding) +let failed_to_fetch_block = + declare_4 + ~section + ~name:"dal_node_crawler_failed_to_fetch_header" + ~msg: + "the crawler failed to fetch the block {type} at level {level} (for \ + last_notified_level {last_notified}): {error}\n\ + If you're a rollup producer or observer, you may be not be able to \ + defend your rollup commitments involving DAL inputs in a refutation \ + game." + ~level:Warning + ~pp4:Error_monad.pp_print_trace + ("type", Data_encoding.string) + ("level", Data_encoding.int32) + ("last_notified", Data_encoding.int32) + ("error", Error_monad.trace_encoding) + let configuration_loaded = declare_0 ~section -- GitLab