diff --git a/CHANGES.rst b/CHANGES.rst index 14c1d9d1d53eb52fa7916618390859e19bc7e719..f6e509ae791fa2b30c5e483a7b8c81de730c6686 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -147,6 +147,14 @@ DAL node (``0.0.0.0:11733``). The new default value is ``None``, so no metrics are exported by default. +- **Feature** The DAL node stores now a peers.json file in its + directory when it is shutdown with SIGINT. This file is read if it + exists when starting the DAL node to restore previous known + connections quickly. + +- **Bugfix** When shutting down the DAL node using SIGINT, it does a + best effort to shutdown properly its running P2P connections + - **Breaking change** Removed the baker daemon's ``--dal-node-timeout-percentage`` argument. (MR :gl:`!15554`) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index d111a4a6d5e6913c1e30ed2407f8348688cced9d..c0db53c5a4d5eee3de61d8b6ef13a2b6dedfe2b0 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -1189,6 +1189,12 @@ let run ~data_dir ~configuration_override = p2p_limits ~network_name in + + let (_ : Lwt_exit.clean_up_callback_id) = + (* This is important to prevent stall connections. *) + Lwt_exit.register_clean_up_callback ~loc:__LOC__ (fun _exit_status -> + Gossipsub.Transport_layer.shutdown transport_layer) + in (* Initialize store *) let* store = Store.init config in let* last_processed_level = diff --git a/src/lib_dal_node/gossipsub/gossipsub.ml b/src/lib_dal_node/gossipsub/gossipsub.ml index 5bb7763d3886f6196f703a3b8cf6d36f50735693..b9feb70de058be9bad8794e81dce668b0131eb49 100644 --- a/src/lib_dal_node/gossipsub/gossipsub.ml +++ b/src/lib_dal_node/gossipsub/gossipsub.ml @@ -90,6 +90,8 @@ module Transport_layer = struct return_unit) additional_points + let shutdown p2p = P2p.shutdown p2p + let connect p2p ?timeout point = let open Lwt_result_syntax in match P2p.connect_handler p2p with diff --git a/src/lib_dal_node/gossipsub/gossipsub.mli b/src/lib_dal_node/gossipsub/gossipsub.mli index 3957724ddfe1e026ae2477b306fc8ad66e8a6b32..aff50c6c985e9edad9c25c17d5760ab8cc79b6db 100644 --- a/src/lib_dal_node/gossipsub/gossipsub.mli +++ b/src/lib_dal_node/gossipsub/gossipsub.mli @@ -92,6 +92,10 @@ module Transport_layer : sig P2p_limits.t -> t tzresult Lwt.t + (** [shutdown t] shutdowns the transport layer and ensures that + active connections are closed. *) + val shutdown : t -> unit Lwt.t + (** [activate ?additional_points t] activates the given transport layer [t]. It is a wrapper on top of {!P2p.activate}. If some [additional_points] are given, they are added to [t]'s known points. *)