From 9ce931336735f6106ed2e7885d9d4f55ebbde840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 18 Dec 2024 15:00:58 +0100 Subject: [PATCH 1/2] Bin/Node: Prevent stall connections --- src/bin_dal_node/daemon.ml | 6 ++++++ src/lib_dal_node/gossipsub/gossipsub.ml | 2 ++ src/lib_dal_node/gossipsub/gossipsub.mli | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index d111a4a6d5e6..c0db53c5a4d5 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 5bb7763d3886..b9feb70de058 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 3957724ddfe1..aff50c6c985e 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. *) -- GitLab From 55c58d0bb2d402f2556a262d2f724dc5eaaf9c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Fri, 20 Dec 2024 11:02:09 +0100 Subject: [PATCH 2/2] CHANGES: Update the CHANGES --- CHANGES.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 14c1d9d1d53e..f6e509ae791f 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`) -- GitLab