From 79bf8b0b48e898166f57ee5824b6c81e92a80052 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 29 Jan 2025 11:54:21 +0100 Subject: [PATCH 1/2] DAL/Node: use labels for event emission --- src/bin_dal_node/RPC_server.ml | 63 +- src/bin_dal_node/accuser.ml | 46 +- src/bin_dal_node/amplificator.ml | 55 +- src/bin_dal_node/crawler.ml | 29 +- src/bin_dal_node/daemon.ml | 133 ++- src/bin_dal_node/event.ml | 1850 ++++++++++++++++------------- src/bin_dal_node/metrics.ml | 2 +- src/bin_dal_node/node_context.ml | 8 +- src/bin_dal_node/proto_plugins.ml | 4 +- src/bin_dal_node/slot_manager.ml | 14 +- src/bin_dal_node/store.ml | 59 +- 11 files changed, 1256 insertions(+), 1007 deletions(-) diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index 8cc2c94724f0..d0b2b1170cfd 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -319,12 +319,12 @@ module Profile_handlers = struct | Error `Not_found -> (* that is, it was not published *) Lwt.return_none - | Error (`Other tztrace) -> + | Error (`Other error) -> let* () = - Event.( - emit - slot_header_status_storage_error - (published_level, slot_index, tztrace)) + Event.emit_slot_header_status_storage_error + ~published_level + ~slot_index + ~error in Lwt.return_none | Ok res -> ( @@ -333,13 +333,11 @@ module Profile_handlers = struct Lwt.return_some (`Not_ok (slot_index, num_stored)) | status -> let* () = - Event.( - emit - unexpected_slot_header_status - ( published_level, - slot_index, - `Waiting_attestation, - status )) + Event.emit_unexpected_slot_header_status + ~published_level + ~slot_index + ~expected_status:`Waiting_attestation + ~got_status:status in Lwt.return_none)) number_of_stored_shards_per_slot @@ -354,11 +352,11 @@ module Profile_handlers = struct List.filter_map (function `Ok v -> Some v | `Not_ok _ -> None) ok in (* TODO: improve (do not go twice through the list) *) - let indexes, _ = List.split ok in - Event.( - emit - get_attestable_slots_ok_notice - (attester, published_level, indexes)) + let slots_indices, _ = List.split ok in + Event.emit_get_attestable_slots_ok_notice + ~attester + ~published_level + ~slots_indices in let* () = if List.is_empty not_ok then Lwt.return_unit @@ -376,13 +374,11 @@ module Profile_handlers = struct (fun (idx, _, _) -> idx) count_received_incomplete_shards_per_slot in - Event.( - emit - get_attestable_slots_not_ok_warning - ( attester, - published_level, - indexes, - count_received_incomplete_shards_per_slot )) + Event.emit_get_attestable_slots_not_ok_warning + ~attester + ~published_level + ~slots_indices:indexes + ~slot_indexes_with_details:count_received_incomplete_shards_per_slot in Lwt.return_unit @@ -405,10 +401,9 @@ module Profile_handlers = struct (* We check that the baker is not in advance wrt the DAL node, which would mean that the DAL node is lagging. We allow a slack of 1 level. *) if Int32.succ current_level < current_baker_level then - Event.( - emit - get_attestable_slots_future_level_warning - (current_level, current_baker_level)) + Event.emit_get_attestable_slots_future_level_warning + ~current_level + ~current_baker_level else Lwt.return_unit | _ -> (* We simply don't do anything if we couldn't obtain the @@ -431,12 +426,10 @@ module Profile_handlers = struct | Error _ -> (* assume the worst, that it is a trap *) let*! () = - Event.( - emit - trap_check_failure - ( slot_id.Types.Slot_id.slot_level, - slot_id.slot_index, - shard_index )) + Event.emit_trap_check_failure + ~published_level:slot_id.Types.Slot_id.slot_level + ~slot_index:slot_id.slot_index + ~shard_index in return false) assigned_shard_indexes @@ -834,5 +827,5 @@ let install_finalizer rpc_server = let open Lwt_syntax in Lwt_exit.register_clean_up_callback ~loc:__LOC__ @@ fun exit_status -> let* () = shutdown rpc_server in - let* () = Event.(emit shutdown_node exit_status) in + let* () = Event.emit_shutdown_node ~exit_status in Tezos_base_unix.Internal_event_unix.close () diff --git a/src/bin_dal_node/accuser.ml b/src/bin_dal_node/accuser.ml index 8313c20997aa..5bb89bca60bc 100644 --- a/src/bin_dal_node/accuser.ml +++ b/src/bin_dal_node/accuser.ml @@ -41,14 +41,12 @@ let filter_injectable_traps ~attested_level ~published_level attestation_map match attestation_opt with | None -> let*! () = - Event.( - emit - trap_delegate_attestation_not_found - ( delegate, - slot_index, - shard.Cryptobox.index, - published_level, - attested_level )) + Event.emit_trap_delegate_attestation_not_found + ~delegate + ~slot_index + ~shard_index:shard.Cryptobox.index + ~published_level + ~attested_level in Lwt.return_none | Some (_attestation, None) -> @@ -107,14 +105,12 @@ let inject_entrapment_evidences (type block_info) shard_proof ) -> if Plugin.is_attested dal_attestation slot_index then let*! () = - Event.( - emit - trap_injection - ( delegate, - published_level, - attested_level, - slot_index, - shard.Cryptobox.index )) + Event.emit_trap_injection + ~delegate + ~published_level + ~attested_level + ~shard_index:shard.Cryptobox.index + ~slot_index in let*! res = Plugin.inject_entrapment_evidence @@ -127,17 +123,15 @@ let inject_entrapment_evidences (type block_info) in match res with | Ok () -> return_unit - | Error err -> + | Error error -> let*! () = - Event.( - emit - trap_injection_failure - ( delegate, - published_level, - attested_level, - slot_index, - shard.Cryptobox.index, - err )) + Event.emit_trap_injection_failure + ~delegate + ~published_level + ~attested_level + ~slot_index + ~shard_index:shard.Cryptobox.index + ~error in return_unit else return_unit) diff --git a/src/bin_dal_node/amplificator.ml b/src/bin_dal_node/amplificator.ml index dcfd1a0401ce..de870bb215c2 100644 --- a/src/bin_dal_node/amplificator.ml +++ b/src/bin_dal_node/amplificator.ml @@ -187,7 +187,7 @@ module Reconstruction_process_worker = struct (* Read init message from parent with parameters required to initialize cryptobox *) let* () = read_init_message_from_parent ic in - let*! () = Event.(emit crypto_process_started (Unix.getpid ())) in + let*! () = Event.emit_crypto_process_started ~pid:(Unix.getpid ()) in let rec loop () = let*! query_id = Lwt_io.read_int ic in (* Read query from main dal process *) @@ -208,7 +208,7 @@ module Reconstruction_process_worker = struct |> List.to_seq in - let*! () = Event.(emit crypto_process_received_query query_id) in + let*! () = Event.emit_crypto_process_received_query ~query_id in (* crypto computation *) let* proved_shards_encoded = @@ -216,7 +216,7 @@ module Reconstruction_process_worker = struct in (* Sends back the proved_shards_encoded to the main dal process *) - let*! () = Event.(emit crypto_process_sending_reply query_id) in + let*! () = Event.emit_crypto_process_sending_reply ~query_id in let len = Bytes.length proved_shards_encoded in let*! () = Lwt_io.write_int oc query_id in let*! () = Lwt_io.write_int oc len in @@ -242,7 +242,7 @@ let query_sender_job {query_pipe; process; _} = Lwt_pipe.Unbounded.pop query_pipe in let oc = Process_worker.output_channel process in - let*! () = Event.(emit main_process_sending_query query_id) in + let*! () = Event.emit_main_process_sending_query ~query_id in (* Serialization: query_id, then shards *) let*! () = Lwt_io.write_int oc query_id in let* () = @@ -293,7 +293,7 @@ let reply_receiver_job {process; query_store; _} node_context = ] | `Message msg -> return msg in - let*! () = Event.(emit main_process_received_reply id) in + let*! () = Event.emit_main_process_received_reply ~query_id:id in let shards, shard_proofs = Data_encoding.Binary.of_bytes_exn proved_shards_encoding msg in @@ -314,7 +314,9 @@ let reply_receiver_job {process; query_store; _} node_context = gs_worker in let*! () = - Event.(emit reconstruct_finished (slot_id.slot_level, slot_id.slot_index)) + Event.emit_reconstruct_finished + ~level:slot_id.slot_level + ~slot_index:slot_id.slot_index in let duration = Unix.gettimeofday () -. reconstruction_start_time in Dal_metrics.update_amplification_complete_duration duration ; @@ -424,7 +426,7 @@ let enqueue_job_shards_proof amplificator commitment slot_id proto_parameters in let length = Query_store.length amplificator.query_store in let () = Dal_metrics.update_amplification_queue_length length in - let*! () = Event.(emit main_process_enqueue_query query_id) in + let*! () = Event.emit_main_process_enqueue_query ~query_id in let () = Lwt_pipe.Unbounded.push amplificator.query_pipe @@ -439,13 +441,11 @@ let amplify node_store commitment (slot_id : Types.slot_id) let reconstruction_start_time = Unix.gettimeofday () in Dal_metrics.reconstruction_started () ; let*! () = - Event.( - emit - reconstruct_started - ( slot_id.slot_level, - slot_id.slot_index, - number_of_already_stored_shards, - number_of_shards )) + Event.emit_reconstruct_started + ~level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~number_of_received_shards:number_of_already_stored_shards + ~number_of_shards in let shards = Store.Shards.read_all (Store.shards node_store) slot_id ~number_of_shards @@ -495,13 +495,11 @@ let try_amplification commitment slot_metrics slot_id amplificator = then return_unit else (* We have enough shards to reconstruct the whole slot. *) - with_amplification_lock - node_ctxt - slot_id - ~on_error: - Event.( - fun err -> - emit reconstruct_error (slot_id.slot_level, slot_id.slot_index, err)) + with_amplification_lock node_ctxt slot_id ~on_error:(fun error -> + Event.emit_reconstruct_error + ~level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~error) @@ fun () -> (* Wait a random delay between 1 and 2 seconds before starting the reconstruction; this is to give some slack to receive @@ -514,10 +512,10 @@ let try_amplification commitment slot_metrics slot_id amplificator = (amplification_random_delay_max -. amplification_random_delay_min)) in let*! () = - Event.( - emit - reconstruct_starting_in - (slot_id.slot_level, slot_id.slot_index, random_delay)) + Event.emit_reconstruct_starting_in + ~level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~delay:random_delay in let*! () = Lwt_unix.sleep random_delay in (* Count again the stored shards because we may have received @@ -532,10 +530,9 @@ let try_amplification commitment slot_metrics slot_id amplificator = if number_of_already_stored_shards = number_of_shards then ( Dal_metrics.update_amplification_abort_reconstruction_duration duration ; let*! () = - Event.( - emit - reconstruct_no_missing_shard - (slot_id.slot_level, slot_id.slot_index)) + Event.emit_reconstruct_no_missing_shard + ~level:slot_id.slot_level + ~slot_index:slot_id.slot_index in Dal_metrics.reconstruction_aborted () ; return_unit) diff --git a/src/bin_dal_node/crawler.ml b/src/bin_dal_node/crawler.ml index 935a081cce07..fbc5fe367243 100644 --- a/src/bin_dal_node/crawler.ml +++ b/src/bin_dal_node/crawler.ml @@ -79,22 +79,25 @@ let finalized_heads_monitor ~name ~last_notified_level crawler_lib cctxt else let*! res = get_predecessor crawler_lib hash shell_header.level in match res with - | Error err -> + | Error error -> let*! () = - Event.(emit failed_to_fetch_block) - ("hash", Int32.pred shell_header.level, !last_notified_level, err) + Event.emit_failed_to_fetch_block + ~type_:"hash" + ~level:(Int32.pred shell_header.level) + ~last_notified:!last_notified_level + ~error in return acc | Ok (pred_hash, _level) -> ( let*! res = fetch_tezos_shell_header cctxt headers_cache pred_hash in match res with - | Error err -> + | Error error -> let*! () = - Event.(emit failed_to_fetch_block) - ( "hash", - Int32.pred shell_header.level, - !last_notified_level, - err ) + Event.emit_failed_to_fetch_block + ~type_:"hash" + ~level:(Int32.pred shell_header.level) + ~last_notified:!last_notified_level + ~error in return acc | Ok pred_shell_header -> @@ -106,10 +109,10 @@ let finalized_heads_monitor ~name ~last_notified_level crawler_lib cctxt let process (hash, Block_header.{shell = shell_header; _}) = let shell_header_level = shell_header.level in let*! () = - Event.( - emit - layer1_node_new_head - (hash, shell_header_level, shell_header.fitness)) + Event.emit_layer1_node_new_head + ~hash + ~level:shell_header_level + ~fitness:shell_header.fitness in Dal_metrics.new_layer1_head ~head_level:shell_header_level ; cache_shell_header headers_cache hash shell_header ; diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 4883d8d264b8..4b39eb16b879 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -35,22 +35,20 @@ let fetch_dal_config cctxt = let delay = min delay_max (delay *. 2.) in let* () = if delay < delay_max then - Event.( - emit - retry_fetching_node_config_notice - (Uri.to_string cctxt#base, delay)) + Event.emit_retry_fetching_node_config_notice + ~endpoint:(Uri.to_string cctxt#base) + ~delay else - Event.( - emit - retry_fetching_node_config_warning - (Uri.to_string cctxt#base, delay)) + Event.emit_retry_fetching_node_config_warning + ~endpoint:(Uri.to_string cctxt#base) + ~delay in let* () = Lwt_unix.sleep delay in retry delay | Error err -> return_error err | Ok dal_config -> let* () = - Event.(emit fetched_config_success (Uri.to_string cctxt#base)) + Event.emit_fetched_config_success ~endpoint:(Uri.to_string cctxt#base) in return_ok dal_config in @@ -109,7 +107,7 @@ module Handler = struct match res with | Ok () -> `Valid | Error err -> - let err = + let validation_error = match err with | `Invalid_degree_strictly_less_than_expected {given; expected} -> Format.sprintf @@ -123,18 +121,16 @@ module Handler = struct | `Shard_length_mismatch -> "Shard_length_mismatch" | `Prover_SRS_not_loaded -> "Prover_SRS_not_loaded" in - Event.( - emit__dont_wait__use_with_care - message_validation_error - (message_id, err)) ; + Event.emit_dont_wait__message_validation_error + ~message_id + ~validation_error ; `Invalid | exception exn -> (* Don't crash if crypto raised an exception. *) - let err = Printexc.to_string exn in - Event.( - emit__dont_wait__use_with_care - message_validation_error - (message_id, err)) ; + let validation_error = Printexc.to_string exn in + Event.emit_dont_wait__message_validation_error + ~message_id + ~validation_error ; `Invalid let is_bootstrap_node ctxt = @@ -276,25 +272,28 @@ module Handler = struct let* res = Store.Shards.remove shards_store slot_id in match res with | Ok () -> - Event.( - emit removed_slot_shards (slot_id.slot_level, slot_id.slot_index)) - | Error err -> - Event.( - emit - removing_shards_failed - (slot_id.slot_level, slot_id.slot_index, err)) + Event.emit_removed_slot_shards + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + | Error error -> + Event.emit_removing_shards_failed + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~error in let* () = let slots_store = Store.slots store in let* res = Store.Slots.remove_slot slots_store ~slot_size slot_id in match res with | Ok () -> - Event.(emit removed_slot (slot_id.slot_level, slot_id.slot_index)) - | Error err -> - Event.( - emit - removing_slot_failed - (slot_id.slot_level, slot_id.slot_index, err)) + Event.emit_removed_slot + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + | Error error -> + Event.emit_removing_slot_failed + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~error in return_unit @@ -315,10 +314,11 @@ module Handler = struct Store.Skip_list_cells.remove store ~attested_level:oldest_level in match res with - | Ok () -> Event.(emit removed_skip_list_cells oldest_level) - | Error err -> - Event.( - emit removing_skip_list_cells_failed (oldest_level, err)) + | Ok () -> Event.emit_removed_skip_list_cells ~level:oldest_level + | Error error -> + Event.emit_removing_skip_list_cells_failed + ~level:oldest_level + ~error else return_unit in let number_of_slots = @@ -331,9 +331,9 @@ module Handler = struct (Store.slot_header_statuses store) in match res with - | Ok () -> Event.(emit removed_status oldest_level) - | Error err -> - Event.(emit removing_status_failed (oldest_level, err)) + | Ok () -> Event.emit_removed_status ~level:oldest_level + | Error error -> + Event.emit_removing_status_failed ~level:oldest_level ~error in List.iter_s (fun slot_index -> @@ -505,10 +505,9 @@ module Handler = struct | _ -> false in if in_committee then - Event.( - emit - warn_attester_not_dal_attesting - (delegate, block_level)) + Event.emit_warn_attester_not_dal_attesting + ~attester:delegate + ~attested_level:block_level else (* no assigned shards... *) Lwt.return_unit | Some bitset -> @@ -518,10 +517,10 @@ module Handler = struct should_be_attested index && not (is_attested bitset index) then - Event.( - emit - warn_attester_did_not_attest_slot - (delegate, index, block_level)) + Event.emit_warn_attester_did_not_attest_slot + ~attester:delegate + ~slot_index:index + ~attested_level:block_level else Lwt.return_unit) (0 -- (parameters.number_of_slots - 1))) | None | Some _ -> @@ -633,7 +632,7 @@ module Handler = struct Dal_metrics.layer1_block_finalized ~block_level ; Dal_metrics.layer1_block_finalized_round ~block_round ; let*! () = - Event.(emit layer1_node_final_block (block_level, block_round)) + Event.emit_layer1_node_final_block ~level:block_level ~round:block_round in (* This should be done at the end of the function. *) let last_processed_level_store = Store.last_processed_level store in @@ -723,7 +722,7 @@ module Handler = struct in loop () in - let*! () = Event.(emit layer1_node_tracking_started ()) in + let*! () = Event.emit_layer1_node_tracking_started () in loop () end @@ -844,7 +843,7 @@ let connect_gossipsub_with_p2p gs_worker transport_layer node_store node_ctxt when Operator_profile.is_observed_slot slot_index profile -> ( match amplificator with | None -> - let*! () = Event.(emit amplificator_uninitialized ()) in + let*! () = Event.emit_amplificator_uninitialized () in return_unit | Some amplificator -> Amplificator.try_amplification @@ -881,25 +880,27 @@ let resolve names = name in let*! () = - Event.(emit resolved_bootstrap_points (name, List.length points)) + Event.emit_resolved_bootstrap_points + ~domainname:name + ~number:(List.length points) in return points) names in let*! () = - if points = [] then Event.(emit resolved_bootstrap_no_points) () - else Event.(emit resolved_bootstrap_points_total (List.length points)) + if points = [] then Event.emit_resolved_bootstrap_no_points () + else Event.emit_resolved_bootstrap_points_total ~number:(List.length points) in return points let wait_for_l1_bootstrapped (cctxt : Rpc_context.t) = let open Lwt_result_syntax in - let*! () = Event.(emit waiting_l1_node_bootstrapped) () in + let*! () = Event.emit_waiting_l1_node_bootstrapped () in let* stream, _stop = Monitor_services.bootstrapped cctxt in let*! () = Lwt_stream.iter_s (fun (_hash, _timestamp) -> Lwt.return_unit) stream in - let*! () = Event.(emit l1_node_bootstrapped) () in + let*! () = Event.emit_l1_node_bootstrapped () in return_unit (* This function checks that in case the history mode is Rolling with a custom @@ -1029,8 +1030,8 @@ let build_profile_context config = ~lower_prio:config.Configuration_file.profile ~higher_prio:loaded_profile |> return - | Error err -> - let*! () = Event.(emit loading_profiles_failed err) in + | Error error -> + let*! () = Event.emit_loading_profiles_failed ~error in return config.Configuration_file.profile (* Registers the attester profile context once we have the protocol plugin. This is supposed @@ -1178,7 +1179,7 @@ let run ~data_dir ~configuration_override = let*! () = Tezos_base_unix.Internal_event_unix.init ~config:internal_events () in - let*! () = Event.(emit starting_node) () in + let*! () = Event.emit_starting_node () in let* ({ network_name; rpc_addr; @@ -1196,18 +1197,18 @@ let run ~data_dir ~configuration_override = match result with | Ok configuration -> return (configuration_override configuration) | Error _ -> - let*! () = Event.(emit data_dir_not_found data_dir) in + let*! () = Event.emit_data_dir_not_found ~path:data_dir in (* Store the default configuration if no configuration were found. *) let configuration = configuration_override Configuration_file.default in let* () = Configuration_file.save configuration in return configuration in - let*! () = Event.(emit configuration_loaded) () in + let*! () = Event.emit_configuration_loaded () in let cctxt = Rpc_context.make endpoint in let* dal_config = fetch_dal_config cctxt in let bootstrap_names = points @ dal_config.bootstrap_peers in let*! () = - if bootstrap_names = [] then Event.(emit config_error_no_bootstrap) () + if bootstrap_names = [] then Event.emit_config_error_no_bootstrap () else Lwt.return_unit in (* Resolve: @@ -1412,10 +1413,10 @@ let run ~data_dir ~configuration_override = let* () = match config.metrics_addr with | None -> - let*! () = Event.(emit metrics_server_not_starting ()) in + let*! () = Event.emit_metrics_server_not_starting () in return_unit | Some metrics_addr -> - let*! () = Event.(emit metrics_server_starting metrics_addr) in + let*! () = Event.emit_metrics_server_starting ~endpoint:metrics_addr in let*! _metrics_server = Metrics.launch metrics_addr in return_unit in @@ -1424,7 +1425,7 @@ let run ~data_dir ~configuration_override = will thus already respond to the baker about shards status if queried. *) let* rpc_server = RPC_server.(start config ctxt) in let _ = RPC_server.install_finalizer rpc_server in - let*! () = Event.(emit rpc_server_is_ready rpc_addr) in + let*! () = Event.emit_rpc_server_is_ready ~point:rpc_addr in (* Wait for the L1 node to be bootstrapped. *) let* () = wait_for_l1_bootstrapped cctxt in let* proto_plugins = @@ -1479,12 +1480,12 @@ let run ~data_dir ~configuration_override = let*! () = Gossipsub.Transport_layer.activate ~additional_points:points transport_layer in - let*! () = Event.(emit p2p_server_is_ready listen_addr) in + let*! () = Event.emit_p2p_server_is_ready ~point:listen_addr in (* Start collecting stats related to the Gossipsub worker. *) Dal_metrics.collect_gossipsub_metrics gs_worker ; (* Register topics with gossipsub worker. *) let* () = update_and_register_profiles ctxt in (* Start never-ending monitoring daemons *) - let*! () = Event.(emit node_is_ready ()) in + let*! () = Event.emit_node_is_ready () in let* () = daemonize [Handler.new_finalized_head ctxt cctxt crawler] in return_unit diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 0e7c1c158e33..35c299a80afc 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -25,807 +25,1049 @@ include Internal_event.Simple -let section = ["dal"; "node"] - -let starting_node = - declare_0 - ~section - ~name:"starting_dal_node" - ~msg:"starting the DAL node" - ~level:Notice - () - -let waiting_l1_node_bootstrapped = - declare_0 - ~section - ~name:"waiting_l1_node_to_be_bootstrapped" - ~msg:"waiting for the L1 node to be bootstrapped" - ~level:Notice - () - -let l1_node_bootstrapped = - declare_0 - ~section - ~name:"l1_node_is_bootstrapped" - ~msg:"the L1 node is bootstrapped" - ~level:Notice - () - -let shutdown_node = - declare_1 - ~section - ~name:"stopping_dal_node" - ~msg:"stopping DAL node" - ~level:Notice - ("exit_status", Data_encoding.int8) - -let dal_node_sqlite3_store_init = - declare_0 - ~section - ~name:"dal_node_sqlite3_store_init" - ~msg:"initializing the SQLite3 store" - ~level:Info - () - -let store_is_ready = - declare_0 - ~section - ~name:"dal_node_store_is_ready" - ~msg:"the DAL node store is ready" - ~level:Notice - () - -let node_is_ready = - declare_0 - ~section - ~name:"dal_node_is_ready" - ~msg:"the DAL node is ready" - ~level:Notice - () - -let data_dir_not_found = - declare_1 - ~section - ~name:"dal_node_no_data_dir" - ~msg: - "the DAL node configuration file does not exist in {path}, creating one" - ~level:Warning - ("path", Data_encoding.(string)) - -let retry_fetching_node_config level prefix = - declare_2 - ~section - ~name:(prefix ^ "retry_fetching_config") - ~msg:"cannot fetch config from l1 node at {endpoint}, retrying in {delay}s" - ~level - ("endpoint", Data_encoding.string) - ("delay", Data_encoding.float) - -let retry_fetching_node_config_notice = - retry_fetching_node_config Internal_event.Notice "notice" - -let retry_fetching_node_config_warning = - retry_fetching_node_config Internal_event.Warning "warning" - -let config_error_no_bootstrap = - declare_0 - ~section - ~name:"config_error_no_bootstrap" - ~msg: - "no bootstrap peers found in the configuration file or network settings" - ~level:Error - () - -let resolved_bootstrap_points = - declare_2 - ~section - ~name:"resolved_bootstrap_points" - ~msg: - "DNS resolution of {domainname} returned {number} bootstrap IP addresses" - ~level:Notice - ("domainname", Data_encoding.string) - ("number", Data_encoding.int31) - -let resolved_bootstrap_no_points = - declare_0 - ~section - ~name:"resolved_bootstrap_no_points" - ~msg:"DNS resolution returned no bootstrap IP address" - ~level:Error - () - -let resolved_bootstrap_points_total = - declare_1 - ~section - ~name:"resolved_bootstrap_points_total" - ~msg:"DNS resolution returned a total of {number} bootstrap IP addresses" - ~level:Notice - ("number", Data_encoding.int31) - -let fetched_config_success = - declare_1 - ~section - ~name:"fetched_config_success" - ~msg:"success fetching config from l1 node at {endpoint}" - ~level:Notice - ("endpoint", Data_encoding.string) - -let failed_to_persist_profiles = - declare_2 - ~section - ~name:"failed_to_persist_profiles" - ~msg:"failed to persist the profiles to the config file" - ~level:Error - ("profiles", Types.profile_encoding) - ("error", Error_monad.trace_encoding) - -let fetched_slot = - declare_2 - ~section - ~name:"reconstructed_slot" - ~msg:"reconstructed slot: size {size}, shards {shards}" - ~level:Info - ("size", Data_encoding.int31) - ("shards", Data_encoding.int31) - -let layer1_node_new_head = - declare_3 - ~section - ~name:"dal_node_layer_1_new_head" - ~msg: - "head of Layer 1 node updated to {hash} at level {level}, fitness \ - {fitness}" - ~level:Info - ("hash", Block_hash.encoding) - ("level", Data_encoding.int32) - ("fitness", Fitness.encoding) - -let layer1_node_final_block = - declare_2 - ~section - ~name:"dal_node_layer_1_new_final_block" - ~msg:"layer 1 node's block at level {level}, round {round} is final" - ~level:Notice - ("level", Data_encoding.int32) - ("round", Data_encoding.int32) - -let layer1_node_tracking_started = - declare_0 - ~section - ~name:"dal_node_layer_1_start_tracking" - ~msg:"started tracking layer 1's node" - ~level:Notice - () - -let protocol_plugin_resolved = - declare_1 - ~section - ~name:"dal_node_plugin_resolved" - ~msg:"resolved plugin on protocol {proto_hash}" - ~level:Notice - ~pp1:Protocol_hash.pp_short - ("proto_hash", Protocol_hash.encoding) - -let no_protocol_plugin = - declare_1 - ~section - ~name:"dal_node_no_plugin" - ~msg:"could not resolve plugin for protocol {proto_hash}" - ~level:Error - ~pp1:Protocol_hash.pp_short - ("proto_hash", Protocol_hash.encoding) - -let unexpected_protocol_plugin = - declare_0 - ~section - ~name:"dal_node_unexpected_plugin" - ~msg: - "found plugin for the current protocol, expected one for the next \ - protocol." - ~level:Error - () - -let daemon_error = - declare_1 - ~section - ~name:"dal_node_daemon_error" - ~msg:"daemon thrown an error: {error}" - ~level:Notice - ~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 history_mode_warning = - declare_2 - ~section - ~name:"dal_node_history_mode_warning" - ~msg: - "The node will only store data related to the last {stored_levels} \ - levels, but it should store data for {storage_period} levels in order \ - to be able to participate in refutation games" - ~level:Warning - ("stored_levels", Data_encoding.int31) - ("storage_period", Data_encoding.int31) - -let configuration_loaded = - declare_0 - ~section - ~name:"configuration_loaded" - ~msg:"configuration loaded successfully" - ~level:Notice - () - -let stored_slot_content = - declare_2 - ~section - ~name:"stored_slot_content" - ~msg:"stored slot for level {published_level} and index {slot_index}" - ~level:Info - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - -let stored_slot_shard = - declare_3 - ~section - ~name:"stored_slot_shard" - ~msg: - "stored shard {shard_index} for level {published_level} and index \ - {slot_index}" - ~level:Debug - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - -let stored_slot_status = - declare_3 - ~section - ~name:"stored_slot_status" - ~msg: - "stored slot status for level {published_level} and index {slot_index}: \ - {status}" - ~level:Debug - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("status", Types.header_status_encoding) - -let removed_slot_shards = - declare_2 - ~section - ~name:"removed_slot_shards" - ~msg:"removed shards for level {published_level} and index {slot_index}" - ~level:Debug - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - -let removed_slot = - declare_2 - ~section - ~name:"removed_slot" - ~msg:"removed slot for level {published_level} and index {slot_index}" - ~level:Debug - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - -let removed_status = - declare_1 - ~section - ~name:"removed_status" - ~msg:"removed statuses for level {level}" - ~level:Debug - ("level", Data_encoding.int32) - -let slot_header_status_storage_error = - declare_3 - ~section - ~name:"slot_header_status_storage_error" - ~msg: - "slot header status storage error for level {published_level}, slot \ - index {slot_index}: {error}" - ~level:Error - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("error", Error_monad.trace_encoding) - -let unexpected_slot_header_status = - declare_4 - ~section - ~name:"unexpected_slot_header_status" - ~msg: - "Internal error: unexpected slot header status {got_status}, expected \ - {expected_status}, for level {published_level}, slot index {slot_index}" - ~level:Error - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("expected_status", Types.header_status_encoding) - ("got_status", Types.header_status_encoding) - ~pp3:Types.pp_header_status - ~pp4:Types.pp_header_status - -let removed_skip_list_cells = - declare_1 - ~section - ~name:"removed_skip_list_cells" - ~msg:"removed skip list cells for level {level}" - ~level:Debug - ("level", Data_encoding.int32) - -let removing_shards_failed = - declare_3 - ~section - ~name:"removing_shards_failed" - ~level:Warning - ~msg: - "removing shards for level {published_level} and index {slot_index} \ - failed: {error}" - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("error", Error_monad.trace_encoding) - -let removing_slot_failed = - declare_3 - ~section - ~name:"removing_slot_failed" - ~level:Warning - ~msg: - "removing slot for level {published_level} and index {slot_index} \ - failed: {error}" - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("error", Error_monad.trace_encoding) - -let removing_status_failed = - declare_2 - ~section - ~name:"removing_status_failed" - ~level:Warning - ~msg:"removing status file for level {level} failed: {error}" - ("level", Data_encoding.int32) - ("error", Error_monad.trace_encoding) - -let removing_skip_list_cells_failed = - declare_2 - ~section - ~name:"removing_skip_list_cells_failed" - ~level:Warning - ~msg:"removing skip list cells for level {level} failed: {error}" - ("level", Data_encoding.int32) - ("error", Error_monad.trace_encoding) - -let decoding_data_failed = - declare_1 - ~section - ~name:"decoding_failed" - ~msg:"error while decoding a {data_kind} value" - ~level:Warning - ("data_kind", Types.Store.encoding) - -let message_validation_error = - declare_2 - ~section - ~name:"message_validation_failed" - ~msg: - "validating message with id {message_id} failed with error \ - {validation_error}" - ~level:Warning - ~pp1:Gossipsub.Worker.GS.Message_id.pp - ("message_id", Types.Message_id.encoding) - ("validation_error", Data_encoding.string) - -let p2p_server_is_ready = - declare_1 - ~section - ~name:"dal_node_p2p_server_is_ready" - ~msg:"P2P server is listening on {point}" - ~level:Notice - ("point", P2p_point.Id.encoding) - -let rpc_server_is_ready = - declare_1 - ~section - ~name:"dal_node_rpc_server_is_ready" - ~msg:"RPC server is listening on {point}" - ~level:Notice - ("point", P2p_point.Id.encoding) - -let metrics_server_starting = - declare_1 - ~section:(section @ ["metrics"]) - ~name:"metrics_service_start" - ~msg:"Starting metrics service at {endpoint}" - ~level:Notice - ("endpoint", P2p_point.Id.encoding) - -let metrics_server_not_starting = - declare_0 - ~section:(section @ ["metrics"]) - ~name:"metrics_service_no_start" - ~msg:"metrics service not enabled" - ~level:Notice - () - -let metrics_server_is_ready = - let open Internal_event.Simple in - declare_2 - ~section - ~name:"starting_metrics_server" - ~msg:"metrics server is listening on {host}:{port}" - ~level:Notice - ("host", Data_encoding.string) - ("port", Data_encoding.uint16) - -let loading_profiles_failed = - declare_1 - ~section - ~name:"loading_profiles_failed" - ~msg:"loading profiles failed: {error}" - ~level:Info - ("error", Error_monad.trace_encoding) - -let saving_profiles_failed = - declare_1 - ~section - ~name:"saving_profiles_failed" - ~msg:"saving profiles failed: {error}" - ~level:Error - ("error", Error_monad.trace_encoding) - -let reconstruct_starting_in = - declare_3 - ~section - ~name:"reconstruct_starting_in" - ~msg: - "For the level {level} and slot index {slot_index}, enough shards have \ - been received to reconstruct the slot. If the remaining shards are not \ - received in {delay} seconds, they will be reconstructed." - ~level:Info - ~pp1:(fun fmt -> Format.fprintf fmt "%ld") - ("level", Data_encoding.int32) - ~pp2:Format.pp_print_int - ("slot_index", Data_encoding.int31) - ~pp3:Format.pp_print_float - ("delay", Data_encoding.float) - -let reconstruct_started = - declare_4 - ~section - ~name:"reconstruct_started" - ~msg: - "For the level {level} and slot index {slot_index}, \ - {number_of_received_shards} out of {number_of_shards} shards were \ - received, starting a reconstruction of the missing shards." - ~level:Notice - ~pp1:(fun fmt -> Format.fprintf fmt "%ld") - ("level", Data_encoding.int32) - ~pp2:Format.pp_print_int - ("slot_index", Data_encoding.int31) - ~pp3:Format.pp_print_int - ("number_of_received_shards", Data_encoding.int31) - ~pp4:Format.pp_print_int - ("number_of_shards", Data_encoding.int31) - -let reconstruct_finished = - declare_2 - ~section - ~name:"reconstruct_finished" - ~msg: - "For the level {level} and slot index {slot_index}, missing shards have \ - been successfully reconstructed." - ~level:Notice - ~pp1:(fun fmt -> Format.fprintf fmt "%ld") - ("level", Data_encoding.int32) - ~pp2:Format.pp_print_int - ("slot_index", Data_encoding.int31) - -let reconstruct_no_missing_shard = - declare_2 - ~section - ~name:"reconstruct_no_missing_shard" - ~msg: - "For the level {level}, all shards for slot index {slot_index} were \ - received. The planned reconstruction has been cancelled." - ~level:Info - ~pp1:(fun fmt -> Format.fprintf fmt "%ld") - ("level", Data_encoding.int32) - ~pp2:Format.pp_print_int - ("slot_index", Data_encoding.int31) - -let reconstruct_error = - declare_3 - ~section - ~name:"reconstruct_error" - ~msg: - "For the level {level} and slot index {slot_index}, unexpected error \ - during reconstruction: {error}." - ~level:Error - ~pp1:(fun fmt -> Format.fprintf fmt "%ld") - ("level", Data_encoding.int32) - ~pp2:Format.pp_print_int - ("slot_index", Data_encoding.int31) - ("error", Error_monad.trace_encoding) - -let store_upgrade_error_moving_directory = - declare_3 - ~section - ~name:"store_upgrade_error_moving_directory" - ~msg:"There was an error trying to move {src} to {dst}: {exn}" - ~level:Warning - ("src", Data_encoding.string) - ("dst", Data_encoding.string) - ("exn", Data_encoding.string) - -let store_upgrade_error_creating_directory = - declare_2 - ~section - ~name:"store_upgrade_error_creating_directory" - ~msg:"There was an error trying to create directory {path}: {exn}" - ~level:Warning - ("path", Data_encoding.string) - ("exn", Data_encoding.string) - -let store_upgrade_start = - declare_2 - ~section - ~name:"store_upgrading" - ~msg: - "starting to upgrade the store from version {old_version} to \ - {new_version}" - ~level:Notice - ("old_version", Data_encoding.int31) - ("new_version", Data_encoding.int31) - -let store_upgraded = - declare_2 - ~section - ~name:"store_upgraded" - ~msg: - "the store has been upgraded from version {old_version} to {new_version}" - ~level:Notice - ("old_version", Data_encoding.int31) - ("new_version", Data_encoding.int31) - -let store_upgrade_error = - declare_0 - ~section - ~name:"store_upgrade_error" - ~msg:"Failed to upgrade the store." - ~level:Error - () - -let crypto_process_started = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"crypto_process_started" - ~msg:"cryptographic child process started (pid: {pid})" - ~level:Notice - ("pid", Data_encoding.int31) - -let amplificator_uninitialized = - declare_0 - ~section:(section @ ["crypto"]) - ~name:"amplificator_uninitialized" - ~msg:"the amplificator process worker is not initialized" - ~level:Warning - () - -let crypto_process_received_query = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"crypto_process_received_query" - ~msg:"cryptographic child process: received query #{query_id}." - ~level:Notice - ("query_id", Data_encoding.int31) - -let crypto_process_sending_reply = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"crypto_process_sending_reply" - ~msg:"cryptographic child process: sending reply #{query_id}." - ~level:Info - ("query_id", Data_encoding.int31) - -let main_process_sending_query = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"main_process_sending_query" - ~msg: - "main process: sending query #{query_id} to cryptographic child process." - ~level:Info - ("query_id", Data_encoding.int31) - -let main_process_received_reply = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"main_process_received_reply" - ~msg:"main process: received reply #{query_id}." - ~level:Info - ("query_id", Data_encoding.int31) - -let main_process_enqueue_query = - declare_1 - ~section:(section @ ["crypto"]) - ~name:"main_process_enqueue_query" - ~msg:"main process: enqueue query #{query_id}." - ~level:Info - ("query_id", Data_encoding.int31) - -let pp_int_list fmt l = - Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.pp_print_string fmt ", ") - Format.pp_print_int - fmt - l - -let get_attestable_slots_ok_notice = - declare_3 - ~section - ~name:"get_attestable_slots_ok_notice" - ~msg: - "For slots {slots_indices} published at level {published_level}, \ - {attester} got all its shards." - ~level:Notice - ("attester", Signature.Public_key_hash.encoding) - ("published_level", Data_encoding.int32) - ("slots_indices", Data_encoding.(list int31)) - ~pp1:Signature.Public_key_hash.pp_short - ~pp3:pp_int_list - -let get_attestable_slots_not_ok_warning = - declare_4 - ~section - ~name:"get_attestable_slots_missing_shards_warning" - ~msg: - "For slots {slots_indices} published at level {published_level}, \ - {attester} missed shards:\n\ - {slot_indexes_with_details}" - ~level:Warning - ("attester", Signature.Public_key_hash.encoding) - ("published_level", Data_encoding.int32) - ("slots_indices", Data_encoding.(list int31)) - ("slot_indexes_with_details", Data_encoding.(list (tup3 int31 int31 int31))) - ~pp1:Signature.Public_key_hash.pp_short - ~pp3:pp_int_list - ~pp4: - (Format.pp_print_list - ~pp_sep:(fun fmt () -> Format.fprintf fmt "\n") - (fun fmt (slot_index, stored_shards, expected_shards) -> - Format.fprintf - fmt - " For slot index %d, %d shards out of %d were received" - slot_index - stored_shards - expected_shards)) - -let get_attestable_slots_future_level_warning = - declare_2 - ~section - ~name:"get_attestable_slots_future_level_warning" - ~msg: - "It looks like the DAL node is lagging (its current level is \ - {current_level}, while the Layer1 node's level is \ - {current_baker_level})." - ~level:Warning - ("current_level", Data_encoding.int32) - ("current_baker_level", Data_encoding.int32) - -let warn_attester_not_dal_attesting = - declare_2 - ~section - ~name:"attester_not_dal_attesting" - ~msg: - "No DAL content was included by {attester} for attested level \ - {attested_level}" - ~level:Warning - ("attester", Signature.Public_key_hash.encoding) - ("attested_level", Data_encoding.int32) - ~pp1:Signature.Public_key_hash.pp_short - -let warn_attester_did_not_attest_slot = - declare_3 - ~section - ~name:"attester_did_not_attest_slot" - ~msg: - "At level {attested_level}, slot index {slot_index} was attested but \ - shards from {attester} are missing" - ~level:Warning - ("attester", Signature.Public_key_hash.encoding) - ("slot_index", Data_encoding.int31) - ("attested_level", Data_encoding.int32) - ~pp1:Signature.Public_key_hash.pp_short - -let trap_injection = - declare_5 - ~section - ~name:"trap_injection" - ~msg: - "Injecting entrapment evidence for delegate {delegate}, published level \ - {published_level}, attested level {attested_level}, slot index \ - {slot_index}, shard index {shard_index}" - ~level:Notice - ("delegate", Signature.Public_key_hash.encoding) - ("published_level", Data_encoding.int32) - ("attested_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - -let trap_injection_failure = - declare_6 - ~section - ~name:"trap_injection_failure" - ~msg: - "Failed to inject an entrapment evidence for delegate {delegate}, \ - published level {published_level}, attested level {attested_level}, \ - slot index {slot_index}, shard index {shard_index}: {error}" - ~level:Warning - ~pp6:pp_print_trace - ("delegate", Signature.Public_key_hash.encoding) - ("published_level", Data_encoding.int32) - ("attested_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - ("error", trace_encoding) - -let trap_check_failure = - declare_3 - ~section - ~name:"trap_check_failure" - ~msg: - "An error occurred when checking the trap for published level \ - {published_level}, slot index {slot_index}, shard index {shard_index}" - ~level:Warning - ("published_level", Data_encoding.int32) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - -let trap_registration_fail = - declare_3 - ~section - ~name:"trap_registration_fail" - ~msg: - "An error occurred when checking if the shard for delegate {delegate}, \ - slot index {slot_index} and shard index {shard_index} is a trap" - ~level:Warning - ("delegate", Signature.Public_key_hash.encoding) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - -let trap_delegate_attestation_not_found = - declare_5 - ~section - ~name:"trap_delegate_attestation_not_found" - ~msg: - "Unable to associate an attestation with delegate {delegate} for \ - attested level {attested_level}. Failed while injecting trap evidence \ - from published level {published_level} at slot index {slot_index} and \ - shard index {shard_index}" - ~level:Warning - ("delegate", Signature.Public_key_hash.encoding) - ("slot_index", Data_encoding.int31) - ("shard_index", Data_encoding.int31) - ("published_level", Data_encoding.int32) - ("attested_level", Data_encoding.int32) - -let registered_pkh_not_a_delegate = - declare_1 - ~section - ~name:"register_pkh_not_a_delegate" - ~msg: - "The public key hash {pkh} registered by PATCH /profiles is not a \ - delegate." - ~level:Warning - ("pkh", Signature.Public_key_hash.encoding) +(* DAL node event definitions *) + +open struct + let section = ["dal"; "node"] + + let starting_node = + declare_0 + ~section + ~name:"starting_dal_node" + ~msg:"starting the DAL node" + ~level:Notice + () + + let waiting_l1_node_bootstrapped = + declare_0 + ~section + ~name:"waiting_l1_node_to_be_bootstrapped" + ~msg:"waiting for the L1 node to be bootstrapped" + ~level:Notice + () + + let l1_node_bootstrapped = + declare_0 + ~section + ~name:"l1_node_is_bootstrapped" + ~msg:"the L1 node is bootstrapped" + ~level:Notice + () + + let shutdown_node = + declare_1 + ~section + ~name:"stopping_dal_node" + ~msg:"stopping DAL node" + ~level:Notice + ("exit_status", Data_encoding.int8) + + let dal_node_sqlite3_store_init = + declare_0 + ~section + ~name:"dal_node_sqlite3_store_init" + ~msg:"initializing the SQLite3 store" + ~level:Info + () + + let store_is_ready = + declare_0 + ~section + ~name:"dal_node_store_is_ready" + ~msg:"the DAL node store is ready" + ~level:Notice + () + + let node_is_ready = + declare_0 + ~section + ~name:"dal_node_is_ready" + ~msg:"the DAL node is ready" + ~level:Notice + () + + let data_dir_not_found = + declare_1 + ~section + ~name:"dal_node_no_data_dir" + ~msg: + "the DAL node configuration file does not exist in {path}, creating one" + ~level:Warning + ("path", Data_encoding.(string)) + + let retry_fetching_node_config level prefix = + declare_2 + ~section + ~name:(prefix ^ "retry_fetching_config") + ~msg: + "cannot fetch config from l1 node at {endpoint}, retrying in {delay}s" + ~level + ("endpoint", Data_encoding.string) + ("delay", Data_encoding.float) + + let retry_fetching_node_config_notice = + retry_fetching_node_config Internal_event.Notice "notice" + + let retry_fetching_node_config_warning = + retry_fetching_node_config Internal_event.Warning "warning" + + let config_error_no_bootstrap = + declare_0 + ~section + ~name:"config_error_no_bootstrap" + ~msg: + "no bootstrap peers found in the configuration file or network settings" + ~level:Error + () + + let resolved_bootstrap_points = + declare_2 + ~section + ~name:"resolved_bootstrap_points" + ~msg: + "DNS resolution of {domainname} returned {number} bootstrap IP \ + addresses" + ~level:Notice + ("domainname", Data_encoding.string) + ("number", Data_encoding.int31) + + let resolved_bootstrap_no_points = + declare_0 + ~section + ~name:"resolved_bootstrap_no_points" + ~msg:"DNS resolution returned no bootstrap IP address" + ~level:Error + () + + let resolved_bootstrap_points_total = + declare_1 + ~section + ~name:"resolved_bootstrap_points_total" + ~msg:"DNS resolution returned a total of {number} bootstrap IP addresses" + ~level:Notice + ("number", Data_encoding.int31) + + let fetched_config_success = + declare_1 + ~section + ~name:"fetched_config_success" + ~msg:"success fetching config from l1 node at {endpoint}" + ~level:Notice + ("endpoint", Data_encoding.string) + + let failed_to_persist_profiles = + declare_2 + ~section + ~name:"failed_to_persist_profiles" + ~msg:"failed to persist the profiles to the config file" + ~level:Error + ("profiles", Types.profile_encoding) + ("error", Error_monad.trace_encoding) + + let fetched_slot = + declare_2 + ~section + ~name:"reconstructed_slot" + ~msg:"reconstructed slot: size {size}, shards {shards}" + ~level:Info + ("size", Data_encoding.int31) + ("shards", Data_encoding.int31) + + let layer1_node_new_head = + declare_3 + ~section + ~name:"dal_node_layer_1_new_head" + ~msg: + "head of Layer 1 node updated to {hash} at level {level}, fitness \ + {fitness}" + ~level:Info + ("hash", Block_hash.encoding) + ("level", Data_encoding.int32) + ("fitness", Fitness.encoding) + + let layer1_node_final_block = + declare_2 + ~section + ~name:"dal_node_layer_1_new_final_block" + ~msg:"layer 1 node's block at level {level}, round {round} is final" + ~level:Notice + ("level", Data_encoding.int32) + ("round", Data_encoding.int32) + + let layer1_node_tracking_started = + declare_0 + ~section + ~name:"dal_node_layer_1_start_tracking" + ~msg:"started tracking layer 1's node" + ~level:Notice + () + + let protocol_plugin_resolved = + declare_1 + ~section + ~name:"dal_node_plugin_resolved" + ~msg:"resolved plugin on protocol {proto_hash}" + ~level:Notice + ~pp1:Protocol_hash.pp_short + ("proto_hash", Protocol_hash.encoding) + + let no_protocol_plugin = + declare_1 + ~section + ~name:"dal_node_no_plugin" + ~msg:"could not resolve plugin for protocol {proto_hash}" + ~level:Error + ~pp1:Protocol_hash.pp_short + ("proto_hash", Protocol_hash.encoding) + + let unexpected_protocol_plugin = + declare_0 + ~section + ~name:"dal_node_unexpected_plugin" + ~msg: + "found plugin for the current protocol, expected one for the next \ + protocol." + ~level:Error + () + + let daemon_error = + declare_1 + ~section + ~name:"dal_node_daemon_error" + ~msg:"daemon thrown an error: {error}" + ~level:Notice + ~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 history_mode_warning = + declare_2 + ~section + ~name:"dal_node_history_mode_warning" + ~msg: + "The node will only store data related to the last {stored_levels} \ + levels, but it should store data for {storage_period} levels in order \ + to be able to participate in refutation games" + ~level:Warning + ("stored_levels", Data_encoding.int31) + ("storage_period", Data_encoding.int31) + + let configuration_loaded = + declare_0 + ~section + ~name:"configuration_loaded" + ~msg:"configuration loaded successfully" + ~level:Notice + () + + let stored_slot_content = + declare_2 + ~section + ~name:"stored_slot_content" + ~msg:"stored slot for level {published_level} and index {slot_index}" + ~level:Info + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + + let stored_slot_shard = + declare_3 + ~section + ~name:"stored_slot_shard" + ~msg: + "stored shard {shard_index} for level {published_level} and index \ + {slot_index}" + ~level:Debug + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + + let stored_slot_status = + declare_3 + ~section + ~name:"stored_slot_status" + ~msg: + "stored slot status for level {published_level} and index \ + {slot_index}: {status}" + ~level:Debug + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("status", Types.header_status_encoding) + + let removed_slot_shards = + declare_2 + ~section + ~name:"removed_slot_shards" + ~msg:"removed shards for level {published_level} and index {slot_index}" + ~level:Debug + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + + let removed_slot = + declare_2 + ~section + ~name:"removed_slot" + ~msg:"removed slot for level {published_level} and index {slot_index}" + ~level:Debug + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + + let removed_status = + declare_1 + ~section + ~name:"removed_status" + ~msg:"removed statuses for level {level}" + ~level:Debug + ("level", Data_encoding.int32) + + let slot_header_status_storage_error = + declare_3 + ~section + ~name:"slot_header_status_storage_error" + ~msg: + "slot header status storage error for level {published_level}, slot \ + index {slot_index}: {error}" + ~level:Error + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("error", Error_monad.trace_encoding) + + let unexpected_slot_header_status = + declare_4 + ~section + ~name:"unexpected_slot_header_status" + ~msg: + "Internal error: unexpected slot header status {got_status}, expected \ + {expected_status}, for level {published_level}, slot index \ + {slot_index}" + ~level:Error + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("expected_status", Types.header_status_encoding) + ("got_status", Types.header_status_encoding) + ~pp3:Types.pp_header_status + ~pp4:Types.pp_header_status + + let removed_skip_list_cells = + declare_1 + ~section + ~name:"removed_skip_list_cells" + ~msg:"removed skip list cells for level {level}" + ~level:Debug + ("level", Data_encoding.int32) + + let removing_shards_failed = + declare_3 + ~section + ~name:"removing_shards_failed" + ~level:Warning + ~msg: + "removing shards for level {published_level} and index {slot_index} \ + failed: {error}" + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("error", Error_monad.trace_encoding) + + let removing_slot_failed = + declare_3 + ~section + ~name:"removing_slot_failed" + ~level:Warning + ~msg: + "removing slot for level {published_level} and index {slot_index} \ + failed: {error}" + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("error", Error_monad.trace_encoding) + + let removing_status_failed = + declare_2 + ~section + ~name:"removing_status_failed" + ~level:Warning + ~msg:"removing status file for level {level} failed: {error}" + ("level", Data_encoding.int32) + ("error", Error_monad.trace_encoding) + + let removing_skip_list_cells_failed = + declare_2 + ~section + ~name:"removing_skip_list_cells_failed" + ~level:Warning + ~msg:"removing skip list cells for level {level} failed: {error}" + ("level", Data_encoding.int32) + ("error", Error_monad.trace_encoding) + + let decoding_data_failed = + declare_1 + ~section + ~name:"decoding_failed" + ~msg:"error while decoding a {data_kind} value" + ~level:Warning + ("data_kind", Types.Store.encoding) + + let message_validation_error = + declare_2 + ~section + ~name:"message_validation_failed" + ~msg: + "validating message with id {message_id} failed with error \ + {validation_error}" + ~level:Warning + ~pp1:Gossipsub.Worker.GS.Message_id.pp + ("message_id", Types.Message_id.encoding) + ("validation_error", Data_encoding.string) + + let p2p_server_is_ready = + declare_1 + ~section + ~name:"dal_node_p2p_server_is_ready" + ~msg:"P2P server is listening on {point}" + ~level:Notice + ("point", P2p_point.Id.encoding) + + let rpc_server_is_ready = + declare_1 + ~section + ~name:"dal_node_rpc_server_is_ready" + ~msg:"RPC server is listening on {point}" + ~level:Notice + ("point", P2p_point.Id.encoding) + + let metrics_server_starting = + declare_1 + ~section:(section @ ["metrics"]) + ~name:"metrics_service_start" + ~msg:"Starting metrics service at {endpoint}" + ~level:Notice + ("endpoint", P2p_point.Id.encoding) + + let metrics_server_not_starting = + declare_0 + ~section:(section @ ["metrics"]) + ~name:"metrics_service_no_start" + ~msg:"metrics service not enabled" + ~level:Notice + () + + let metrics_server_is_ready = + let open Internal_event.Simple in + declare_2 + ~section + ~name:"starting_metrics_server" + ~msg:"metrics server is listening on {host}:{port}" + ~level:Notice + ("host", Data_encoding.string) + ("port", Data_encoding.uint16) + + let loading_profiles_failed = + declare_1 + ~section + ~name:"loading_profiles_failed" + ~msg:"loading profiles failed: {error}" + ~level:Info + ("error", Error_monad.trace_encoding) + + let saving_profiles_failed = + declare_1 + ~section + ~name:"saving_profiles_failed" + ~msg:"saving profiles failed: {error}" + ~level:Error + ("error", Error_monad.trace_encoding) + + let reconstruct_starting_in = + declare_3 + ~section + ~name:"reconstruct_starting_in" + ~msg: + "For the level {level} and slot index {slot_index}, enough shards have \ + been received to reconstruct the slot. If the remaining shards are \ + not received in {delay} seconds, they will be reconstructed." + ~level:Info + ~pp1:(fun fmt -> Format.fprintf fmt "%ld") + ("level", Data_encoding.int32) + ~pp2:Format.pp_print_int + ("slot_index", Data_encoding.int31) + ~pp3:Format.pp_print_float + ("delay", Data_encoding.float) + + let reconstruct_started = + declare_4 + ~section + ~name:"reconstruct_started" + ~msg: + "For the level {level} and slot index {slot_index}, \ + {number_of_received_shards} out of {number_of_shards} shards were \ + received, starting a reconstruction of the missing shards." + ~level:Notice + ~pp1:(fun fmt -> Format.fprintf fmt "%ld") + ("level", Data_encoding.int32) + ~pp2:Format.pp_print_int + ("slot_index", Data_encoding.int31) + ~pp3:Format.pp_print_int + ("number_of_received_shards", Data_encoding.int31) + ~pp4:Format.pp_print_int + ("number_of_shards", Data_encoding.int31) + + let reconstruct_finished = + declare_2 + ~section + ~name:"reconstruct_finished" + ~msg: + "For the level {level} and slot index {slot_index}, missing shards \ + have been successfully reconstructed." + ~level:Notice + ~pp1:(fun fmt -> Format.fprintf fmt "%ld") + ("level", Data_encoding.int32) + ~pp2:Format.pp_print_int + ("slot_index", Data_encoding.int31) + + let reconstruct_no_missing_shard = + declare_2 + ~section + ~name:"reconstruct_no_missing_shard" + ~msg: + "For the level {level}, all shards for slot index {slot_index} were \ + received. The planned reconstruction has been cancelled." + ~level:Info + ~pp1:(fun fmt -> Format.fprintf fmt "%ld") + ("level", Data_encoding.int32) + ~pp2:Format.pp_print_int + ("slot_index", Data_encoding.int31) + + let reconstruct_error = + declare_3 + ~section + ~name:"reconstruct_error" + ~msg: + "For the level {level} and slot index {slot_index}, unexpected error \ + during reconstruction: {error}." + ~level:Error + ~pp1:(fun fmt -> Format.fprintf fmt "%ld") + ("level", Data_encoding.int32) + ~pp2:Format.pp_print_int + ("slot_index", Data_encoding.int31) + ("error", Error_monad.trace_encoding) + + let store_upgrade_error_moving_directory = + declare_3 + ~section + ~name:"store_upgrade_error_moving_directory" + ~msg:"There was an error trying to move {src} to {dst}: {exn}" + ~level:Warning + ("src", Data_encoding.string) + ("dst", Data_encoding.string) + ("exn", Data_encoding.string) + + let store_upgrade_error_creating_directory = + declare_2 + ~section + ~name:"store_upgrade_error_creating_directory" + ~msg:"There was an error trying to create directory {path}: {exn}" + ~level:Warning + ("path", Data_encoding.string) + ("exn", Data_encoding.string) + + let store_upgrade_start = + declare_2 + ~section + ~name:"store_upgrading" + ~msg: + "starting to upgrade the store from version {old_version} to \ + {new_version}" + ~level:Notice + ("old_version", Data_encoding.int31) + ("new_version", Data_encoding.int31) + + let store_upgraded = + declare_2 + ~section + ~name:"store_upgraded" + ~msg: + "the store has been upgraded from version {old_version} to \ + {new_version}" + ~level:Notice + ("old_version", Data_encoding.int31) + ("new_version", Data_encoding.int31) + + let store_upgrade_error = + declare_0 + ~section + ~name:"store_upgrade_error" + ~msg:"Failed to upgrade the store." + ~level:Error + () + + let crypto_process_started = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"crypto_process_started" + ~msg:"cryptographic child process started (pid: {pid})" + ~level:Notice + ("pid", Data_encoding.int31) + + let amplificator_uninitialized = + declare_0 + ~section:(section @ ["crypto"]) + ~name:"amplificator_uninitialized" + ~msg:"the amplificator process worker is not initialized" + ~level:Warning + () + + let crypto_process_received_query = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"crypto_process_received_query" + ~msg:"cryptographic child process: received query #{query_id}." + ~level:Notice + ("query_id", Data_encoding.int31) + + let crypto_process_sending_reply = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"crypto_process_sending_reply" + ~msg:"cryptographic child process: sending reply #{query_id}." + ~level:Info + ("query_id", Data_encoding.int31) + + let main_process_sending_query = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"main_process_sending_query" + ~msg: + "main process: sending query #{query_id} to cryptographic child \ + process." + ~level:Info + ("query_id", Data_encoding.int31) + + let main_process_received_reply = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"main_process_received_reply" + ~msg:"main process: received reply #{query_id}." + ~level:Info + ("query_id", Data_encoding.int31) + + let main_process_enqueue_query = + declare_1 + ~section:(section @ ["crypto"]) + ~name:"main_process_enqueue_query" + ~msg:"main process: enqueue query #{query_id}." + ~level:Info + ("query_id", Data_encoding.int31) + + let pp_int_list fmt l = + Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.pp_print_string fmt ", ") + Format.pp_print_int + fmt + l + + let get_attestable_slots_ok_notice = + declare_3 + ~section + ~name:"get_attestable_slots_ok_notice" + ~msg: + "For slots {slots_indices} published at level {published_level}, \ + {attester} got all its shards." + ~level:Notice + ("attester", Signature.Public_key_hash.encoding) + ("published_level", Data_encoding.int32) + ("slots_indices", Data_encoding.(list int31)) + ~pp1:Signature.Public_key_hash.pp_short + ~pp3:pp_int_list + + let get_attestable_slots_not_ok_warning = + declare_4 + ~section + ~name:"get_attestable_slots_missing_shards_warning" + ~msg: + "For slots {slots_indices} published at level {published_level}, \ + {attester} missed shards:\n\ + {slot_indexes_with_details}" + ~level:Warning + ("attester", Signature.Public_key_hash.encoding) + ("published_level", Data_encoding.int32) + ("slots_indices", Data_encoding.(list int31)) + ( "slot_indexes_with_details", + Data_encoding.(list (tup3 int31 int31 int31)) ) + ~pp1:Signature.Public_key_hash.pp_short + ~pp3:pp_int_list + ~pp4: + (Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.fprintf fmt "\n") + (fun fmt (slot_index, stored_shards, expected_shards) -> + Format.fprintf + fmt + " For slot index %d, %d shards out of %d were received" + slot_index + stored_shards + expected_shards)) + + let get_attestable_slots_future_level_warning = + declare_2 + ~section + ~name:"get_attestable_slots_future_level_warning" + ~msg: + "It looks like the DAL node is lagging (its current level is \ + {current_level}, while the Layer1 node's level is \ + {current_baker_level})." + ~level:Warning + ("current_level", Data_encoding.int32) + ("current_baker_level", Data_encoding.int32) + + let warn_attester_not_dal_attesting = + declare_2 + ~section + ~name:"attester_not_dal_attesting" + ~msg: + "No DAL content was included by {attester} for attested level \ + {attested_level}" + ~level:Warning + ("attester", Signature.Public_key_hash.encoding) + ("attested_level", Data_encoding.int32) + ~pp1:Signature.Public_key_hash.pp_short + + let warn_attester_did_not_attest_slot = + declare_3 + ~section + ~name:"attester_did_not_attest_slot" + ~msg: + "At level {attested_level}, slot index {slot_index} was attested but \ + shards from {attester} are missing" + ~level:Warning + ("attester", Signature.Public_key_hash.encoding) + ("slot_index", Data_encoding.int31) + ("attested_level", Data_encoding.int32) + ~pp1:Signature.Public_key_hash.pp_short + + let trap_injection = + declare_5 + ~section + ~name:"trap_injection" + ~msg: + "Injecting entrapment evidence for delegate {delegate}, published \ + level {published_level}, attested level {attested_level}, slot index \ + {slot_index}, shard index {shard_index}" + ~level:Notice + ("delegate", Signature.Public_key_hash.encoding) + ("published_level", Data_encoding.int32) + ("attested_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + + let trap_injection_failure = + declare_6 + ~section + ~name:"trap_injection_failure" + ~msg: + "Failed to inject an entrapment evidence for delegate {delegate}, \ + published level {published_level}, attested level {attested_level}, \ + slot index {slot_index}, shard index {shard_index}: {error}" + ~level:Warning + ~pp6:pp_print_trace + ("delegate", Signature.Public_key_hash.encoding) + ("published_level", Data_encoding.int32) + ("attested_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + ("error", trace_encoding) + + let trap_check_failure = + declare_3 + ~section + ~name:"trap_check_failure" + ~msg: + "An error occurred when checking the trap for published level \ + {published_level}, slot index {slot_index}, shard index {shard_index}" + ~level:Warning + ("published_level", Data_encoding.int32) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + + let trap_registration_fail = + declare_3 + ~section + ~name:"trap_registration_fail" + ~msg: + "An error occurred when checking if the shard for delegate {delegate}, \ + slot index {slot_index} and shard index {shard_index} is a trap" + ~level:Warning + ("delegate", Signature.Public_key_hash.encoding) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + + let trap_delegate_attestation_not_found = + declare_5 + ~section + ~name:"trap_delegate_attestation_not_found" + ~msg: + "Unable to associate an attestation with delegate {delegate} for \ + attested level {attested_level}. Failed while injecting trap evidence \ + from published level {published_level} at slot index {slot_index} and \ + shard index {shard_index}" + ~level:Warning + ("delegate", Signature.Public_key_hash.encoding) + ("slot_index", Data_encoding.int31) + ("shard_index", Data_encoding.int31) + ("published_level", Data_encoding.int32) + ("attested_level", Data_encoding.int32) + + let registered_pkh_not_a_delegate = + declare_1 + ~section + ~name:"register_pkh_not_a_delegate" + ~msg: + "The public key hash {pkh} registered by PATCH /profiles is not a \ + delegate." + ~level:Warning + ("pkh", Signature.Public_key_hash.encoding) +end + +(* DAL node event emission functions *) + +let emit_starting_node () = emit starting_node () + +let emit_waiting_l1_node_bootstrapped () = emit waiting_l1_node_bootstrapped () + +let emit_l1_node_bootstrapped () = emit l1_node_bootstrapped () + +let emit_shutdown_node ~exit_status = emit shutdown_node exit_status + +let emit_dal_node_sqlite3_store_init () = emit dal_node_sqlite3_store_init () + +let emit_store_is_ready () = emit store_is_ready () + +let emit_node_is_ready () = emit node_is_ready () + +let emit_data_dir_not_found ~path = emit data_dir_not_found path + +let emit_retry_fetching_node_config_notice ~endpoint ~delay = + emit retry_fetching_node_config_notice (endpoint, delay) + +let emit_retry_fetching_node_config_warning ~endpoint ~delay = + emit retry_fetching_node_config_warning (endpoint, delay) + +let emit_config_error_no_bootstrap () = emit config_error_no_bootstrap () + +let emit_resolved_bootstrap_points ~domainname ~number = + emit resolved_bootstrap_points (domainname, number) + +let emit_resolved_bootstrap_no_points () = emit resolved_bootstrap_no_points () + +let emit_resolved_bootstrap_points_total ~number = + emit resolved_bootstrap_points_total number + +let emit_fetched_config_success ~endpoint = emit fetched_config_success endpoint + +let emit_failed_to_persist_profiles ~profiles ~error = + emit failed_to_persist_profiles (profiles, error) + +let emit_fetched_slot ~size ~shards = emit fetched_slot (size, shards) + +let emit_layer1_node_new_head ~hash ~level ~fitness = + emit layer1_node_new_head (hash, level, fitness) + +let emit_layer1_node_final_block ~level ~round = + emit layer1_node_final_block (level, round) + +let emit_layer1_node_tracking_started () = emit layer1_node_tracking_started () + +let emit_protocol_plugin_resolved ~proto_hash = + emit protocol_plugin_resolved proto_hash + +let emit_no_protocol_plugin ~proto_hash = emit no_protocol_plugin proto_hash + +let emit_unexpected_protocol_plugin () = emit unexpected_protocol_plugin () + +let emit_daemon_error ~error = emit daemon_error error + +let emit_failed_to_fetch_block ~type_ ~level ~last_notified ~error = + emit failed_to_fetch_block (type_, level, last_notified, error) + +let emit_history_mode_warning ~stored_levels ~storage_period = + emit history_mode_warning (stored_levels, storage_period) + +let emit_configuration_loaded () = emit configuration_loaded () + +let emit_stored_slot_content ~published_level ~slot_index = + emit stored_slot_content (published_level, slot_index) + +let emit_stored_slot_shard ~published_level ~slot_index ~shard_index = + emit stored_slot_shard (published_level, slot_index, shard_index) + +let emit_stored_slot_status ~published_level ~slot_index ~status = + emit stored_slot_status (published_level, slot_index, status) + +let emit_removed_slot_shards ~published_level ~slot_index = + emit removed_slot_shards (published_level, slot_index) + +let emit_removed_slot ~published_level ~slot_index = + emit removed_slot (published_level, slot_index) + +let emit_removed_status ~level = emit removed_status level + +let emit_slot_header_status_storage_error ~published_level ~slot_index ~error = + emit slot_header_status_storage_error (published_level, slot_index, error) + +let emit_unexpected_slot_header_status ~published_level ~slot_index + ~expected_status ~got_status = + emit + unexpected_slot_header_status + (published_level, slot_index, expected_status, got_status) + +let emit_removed_skip_list_cells ~level = emit removed_skip_list_cells level + +let emit_removing_shards_failed ~published_level ~slot_index ~error = + emit removing_shards_failed (published_level, slot_index, error) + +let emit_removing_slot_failed ~published_level ~slot_index ~error = + emit removing_slot_failed (published_level, slot_index, error) + +let emit_removing_status_failed ~level ~error = + emit removing_status_failed (level, error) + +let emit_removing_skip_list_cells_failed ~level ~error = + emit removing_skip_list_cells_failed (level, error) + +let emit_decoding_data_failed ~data_kind = emit decoding_data_failed data_kind + +let emit_dont_wait__message_validation_error ~message_id ~validation_error = + emit__dont_wait__use_with_care + message_validation_error + (message_id, validation_error) + +let emit_p2p_server_is_ready ~point = emit p2p_server_is_ready point + +let emit_rpc_server_is_ready ~point = emit rpc_server_is_ready point + +let emit_metrics_server_starting ~endpoint = + emit metrics_server_starting endpoint + +let emit_metrics_server_not_starting () = emit metrics_server_not_starting () + +let emit_metrics_server_is_ready ~host ~port = + emit metrics_server_is_ready (host, port) + +let emit_loading_profiles_failed ~error = emit loading_profiles_failed error + +let emit_saving_profiles_failed ~error = emit saving_profiles_failed error + +let emit_reconstruct_starting_in ~level ~slot_index ~delay = + emit reconstruct_starting_in (level, slot_index, delay) + +let emit_reconstruct_started ~level ~slot_index ~number_of_received_shards + ~number_of_shards = + emit + reconstruct_started + (level, slot_index, number_of_received_shards, number_of_shards) + +let emit_reconstruct_finished ~level ~slot_index = + emit reconstruct_finished (level, slot_index) + +let emit_reconstruct_no_missing_shard ~level ~slot_index = + emit reconstruct_no_missing_shard (level, slot_index) + +let emit_reconstruct_error ~level ~slot_index ~error = + emit reconstruct_error (level, slot_index, error) + +let emit_store_upgrade_error_moving_directory ~src ~dst ~exn = + emit store_upgrade_error_moving_directory (src, dst, exn) + +let emit_store_upgrade_error_creating_directory ~path ~exn = + emit store_upgrade_error_creating_directory (path, exn) + +let emit_store_upgrade_start ~old_version ~new_version = + emit store_upgrade_start (old_version, new_version) + +let emit_store_upgraded ~old_version ~new_version = + emit store_upgraded (old_version, new_version) + +let emit_store_upgrade_error () = emit store_upgrade_error () + +let emit_crypto_process_started ~pid = emit crypto_process_started pid + +let emit_amplificator_uninitialized () = emit amplificator_uninitialized () + +let emit_crypto_process_received_query ~query_id = + emit crypto_process_received_query query_id + +let emit_crypto_process_sending_reply ~query_id = + emit crypto_process_sending_reply query_id + +let emit_main_process_sending_query ~query_id = + emit main_process_sending_query query_id + +let emit_main_process_received_reply ~query_id = + emit main_process_received_reply query_id + +let emit_main_process_enqueue_query ~query_id = + emit main_process_enqueue_query query_id + +let emit_get_attestable_slots_ok_notice ~attester ~published_level + ~slots_indices = + emit get_attestable_slots_ok_notice (attester, published_level, slots_indices) + +let emit_get_attestable_slots_not_ok_warning ~attester ~published_level + ~slots_indices ~slot_indexes_with_details = + emit + get_attestable_slots_not_ok_warning + (attester, published_level, slots_indices, slot_indexes_with_details) + +let emit_get_attestable_slots_future_level_warning ~current_level + ~current_baker_level = + emit + get_attestable_slots_future_level_warning + (current_level, current_baker_level) + +let emit_warn_attester_not_dal_attesting ~attester ~attested_level = + emit warn_attester_not_dal_attesting (attester, attested_level) + +let emit_warn_attester_did_not_attest_slot ~attester ~slot_index ~attested_level + = + emit warn_attester_did_not_attest_slot (attester, slot_index, attested_level) + +let emit_trap_injection ~delegate ~published_level ~attested_level ~slot_index + ~shard_index = + emit + trap_injection + (delegate, published_level, attested_level, slot_index, shard_index) + +let emit_trap_injection_failure ~delegate ~published_level ~attested_level + ~slot_index ~shard_index ~error = + emit + trap_injection_failure + (delegate, published_level, attested_level, slot_index, shard_index, error) + +let emit_trap_check_failure ~published_level ~slot_index ~shard_index = + emit trap_check_failure (published_level, slot_index, shard_index) + +let emit_dont_wait__trap_registration_fail ~delegate ~slot_index ~shard_index = + emit__dont_wait__use_with_care + trap_registration_fail + (delegate, slot_index, shard_index) + +let emit_trap_delegate_attestation_not_found ~delegate ~slot_index ~shard_index + ~published_level ~attested_level = + emit + trap_delegate_attestation_not_found + (delegate, slot_index, shard_index, published_level, attested_level) + +let emit_registered_pkh_not_a_delegate ~pkh = + emit registered_pkh_not_a_delegate pkh diff --git a/src/bin_dal_node/metrics.ml b/src/bin_dal_node/metrics.ml index 5c383e953faf..3ec80812858c 100644 --- a/src/bin_dal_node/metrics.ml +++ b/src/bin_dal_node/metrics.ml @@ -52,5 +52,5 @@ let launch (addr, port) = in let t = {shutdown; server} in let (_ : Lwt_exit.clean_up_callback_id) = shutdown_on_exit t in - let* () = Event.(emit metrics_server_is_ready) (host, port) in + let* () = Event.emit_metrics_server_is_ready ~host ~port in Lwt.return t diff --git a/src/bin_dal_node/node_context.ml b/src/bin_dal_node/node_context.ml index 3447e0f97d9d..e8a47fe1c5c5 100644 --- a/src/bin_dal_node/node_context.ml +++ b/src/bin_dal_node/node_context.ml @@ -135,8 +135,8 @@ let load_profile_ctxt ctxt = let* res = Profile_manager.load_profile_ctxt ~base_dir in match res with | Ok pctxt -> return_some pctxt - | Error err -> - let* () = Event.(emit loading_profiles_failed err) in + | Error error -> + let* () = Event.emit_loading_profiles_failed ~error in return_none let set_profile_ctxt ctxt ?(save = true) pctxt = @@ -147,7 +147,7 @@ let set_profile_ctxt ctxt ?(save = true) pctxt = let* res = Profile_manager.save_profile_ctxt ctxt.profile_ctxt ~base_dir in match res with | Ok () -> return_unit - | Error err -> Event.(emit saving_profiles_failed err) + | Error error -> Event.emit_saving_profiles_failed ~error else return_unit let get_config ctxt = ctxt.config @@ -225,7 +225,7 @@ let warn_if_attesters_not_delegates ctxt ?level operator_profiles = (fun pkh -> let* is_delegate = Plugin.is_delegate cctxt ~pkh in if not is_delegate then - let*! () = Event.(emit registered_pkh_not_a_delegate pkh) in + let*! () = Event.emit_registered_pkh_not_a_delegate ~pkh in return_unit else return_unit) pkh_set) diff --git a/src/bin_dal_node/proto_plugins.ml b/src/bin_dal_node/proto_plugins.ml index 0f69eff1c59f..1740fcb102d1 100644 --- a/src/bin_dal_node/proto_plugins.ml +++ b/src/bin_dal_node/proto_plugins.ml @@ -52,10 +52,10 @@ let resolve_plugin_by_hash proto_hash = let plugin_opt = Dal_plugin.get proto_hash in match plugin_opt with | None -> - let*! () = Event.(emit no_protocol_plugin proto_hash) in + let*! () = Event.emit_no_protocol_plugin ~proto_hash in tzfail (No_plugin_for_proto {proto_hash}) | Some plugin -> - let*! () = Event.(emit protocol_plugin_resolved proto_hash) in + let*! () = Event.emit_protocol_plugin_resolved ~proto_hash in return plugin let resolve_plugin_for_level cctxt ~level = diff --git a/src/bin_dal_node/slot_manager.ml b/src/bin_dal_node/slot_manager.ml index 8c22250d0f47..228c5065e40d 100644 --- a/src/bin_dal_node/slot_manager.ml +++ b/src/bin_dal_node/slot_manager.ml @@ -142,7 +142,11 @@ let get_slot_content_from_shards cryptobox store slot_id = let slot = Cryptobox.polynomial_to_slot cryptobox polynomial in (* Store the slot so that next calls don't require a reconstruction. *) let* () = Store.Slots.add_slot (Store.slots store) ~slot_size slot slot_id in - let*! () = Event.(emit fetched_slot (Bytes.length slot, Seq.length shards)) in + let*! () = + Event.emit_fetched_slot + ~size:(Bytes.length slot) + ~shards:(Seq.length shards) + in return slot let get_slot_content ~reconstruct_if_missing ctxt slot_id = @@ -220,10 +224,10 @@ let maybe_register_trap ctxt message_id message = ~shard_proof | Ok false -> () | Error _ -> - Event.( - emit__dont_wait__use_with_care - trap_registration_fail - (delegate, slot_index, shard_index)) + Event.emit_dont_wait__trap_registration_fail + ~delegate + ~slot_index + ~shard_index let add_commitment_shards ~shards_proofs_precomputation node_store cryptobox commitment slot polynomial = diff --git a/src/bin_dal_node/store.ml b/src/bin_dal_node/store.ml index 6e5715a2e28d..8cf62ed8c265 100644 --- a/src/bin_dal_node/store.ml +++ b/src/bin_dal_node/store.ml @@ -195,10 +195,10 @@ module Shards = struct in let () = Dal_metrics.shard_stored () in let*! () = - Event.( - emit - stored_slot_shard - (slot_id.slot_level, slot_id.slot_index, index)) + Event.emit_stored_slot_shard + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~shard_index:index in return_unit) shards @@ -276,7 +276,9 @@ module Slots = struct |> Errors.other_lwt_result in let*! () = - Event.(emit stored_slot_content (slot_id.slot_level, slot_id.slot_index)) + Event.emit_stored_slot_content + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index in return_unit @@ -443,8 +445,10 @@ module Statuses = struct |> Errors.other_lwt_result in let*! () = - Event.( - emit stored_slot_status (slot_id.slot_level, slot_id.slot_index, status)) + Event.emit_stored_slot_status + ~published_level:slot_id.slot_level + ~slot_index:slot_id.slot_index + ~status in return_unit @@ -662,7 +666,7 @@ let init_sqlite_skip_list_cells_store ?(perm = `Read_write) data_dir = Lwt_utils_unix.create_dir skip_list_cells_data_dir else Lwt.return_unit in - let*! () = Event.(emit dal_node_sqlite3_store_init ()) in + let*! () = Event.emit_dal_node_sqlite3_store_init () in Dal_store_sqlite3.Skip_list_cells.init ~data_dir:skip_list_cells_data_dir ~perm @@ -717,7 +721,11 @@ let cache_entry node_store commitment slot shares shard_proofs = let upgrade_from_v0_to_v1 ~base_dir = let open Lwt_syntax in let ( // ) = Filename.Infix.( // ) in - let* () = Event.(emit store_upgrade_start (Version.make 0, Version.make 1)) in + let* () = + Event.emit_store_upgrade_start + ~old_version:(Version.make 0) + ~new_version:(Version.make 1) + in let rec move_directory_contents src dst = let stream = Lwt_unix.files_of_directory src in Lwt_stream.iter_s @@ -741,10 +749,10 @@ let upgrade_from_v0_to_v1 ~base_dir = let src_path = src // name in let dst_path = dst // name in let* () = - Event.( - emit - store_upgrade_error_moving_directory - (src_path, dst_path, Printexc.to_string exn)) + Event.emit_store_upgrade_error_moving_directory + ~src:src_path + ~dst:dst_path + ~exn:(Printexc.to_string exn) in Lwt.return_unit)) stream @@ -755,10 +763,9 @@ let upgrade_from_v0_to_v1 ~base_dir = (fun () -> Lwt_unix.mkdir new_path 0o700) (fun exn -> let* () = - Event.( - emit - store_upgrade_error_creating_directory - (new_path, Printexc.to_string exn)) + Event.emit_store_upgrade_error_creating_directory + ~path:new_path + ~exn:(Printexc.to_string exn) in Lwt.return ()) in @@ -790,12 +797,16 @@ let upgrade_from_v0_to_v1 ~base_dir = else Lwt.return ()) stream in - Event.(emit store_upgraded (Version.make 0, Version.make 1)) + Event.emit_store_upgraded + ~old_version:(Version.make 0) + ~new_version:(Version.make 1) let upgrade_from_v1_to_v2 ~base_dir = let open Lwt_result_syntax in let*! () = - Event.(emit store_upgrade_start (Version.make 1, Version.make 2)) + Event.emit_store_upgrade_start + ~old_version:(Version.make 1) + ~new_version:(Version.make 2) in (* Initialize both stores and migrate. *) let* storage_backend_store = Storage_backend.init ~root_dir:base_dir in @@ -852,7 +863,11 @@ let upgrade_from_v1_to_v2 ~base_dir = let*! () = Lwt_utils_unix.remove_dir (store_dir // "hashes") in let*! () = Lwt_utils_unix.remove_dir (store_dir // "cells") in (* The storage upgrade has been done. *) - let*! () = Event.(emit store_upgraded (Version.make 1, Version.make 2)) in + let*! () = + Event.emit_store_upgraded + ~old_version:(Version.make 1) + ~new_version:(Version.make 2) + in return_unit | Error err -> (* Clean the sqlite store unless the storage backend was already set to sqlite. *) @@ -871,7 +886,7 @@ let upgrade_from_v1_to_v2 ~base_dir = | Some SQLite3 -> Lwt.return_unit in (* The store upgrade failed. *) - let*! () = Event.(emit store_upgrade_error ()) in + let*! () = Event.emit_store_upgrade_error () in Format.eprintf "%a" Error_monad.pp_print_trace err ; fail err @@ -937,7 +952,7 @@ let init config = let* last_processed_level = Last_processed_level.init ~root_dir:base_dir in let* first_seen_level = First_seen_level.init ~root_dir:base_dir in let* skip_list_cells_store = init_sqlite_skip_list_cells_store base_dir in - let*! () = Event.(emit store_is_ready ()) in + let*! () = Event.emit_store_is_ready () in return { shards; -- GitLab From 5fff4f4d550d249a67f5c34632bc91f2e48ec912 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 29 Jan 2025 13:39:11 +0100 Subject: [PATCH 2/2] DAL/Node: open/include Internal_event.Simple --- src/bin_dal_node/event.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 35c299a80afc..02d96e292743 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -include Internal_event.Simple +open Internal_event.Simple (* DAL node event definitions *) -- GitLab