From b25d1e78b13c867a479081ab8d16f6d60902caae Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Mon, 24 Oct 2022 15:13:10 +0200 Subject: [PATCH 1/2] Store: do not consider additional cycles while importing a snapshot --- src/lib_shell_services/history_mode.ml | 5 +++++ src/lib_shell_services/history_mode.mli | 6 ++++++ src/lib_store/unix/snapshots.ml | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lib_shell_services/history_mode.ml b/src/lib_shell_services/history_mode.ml index e26a690abaae..b76f89b8912e 100644 --- a/src/lib_shell_services/history_mode.ml +++ b/src/lib_shell_services/history_mode.ml @@ -168,6 +168,11 @@ let equal hm1 hm2 = true | _ -> false +let mode_equality hm1 hm2 = + match (hm1, hm2) with + | Archive, Archive | Full _, Full _ | Rolling _, Rolling _ -> true + | _ -> false + let pp ppf = function | Archive -> Format.fprintf ppf "Archive mode" | Full None -> diff --git a/src/lib_shell_services/history_mode.mli b/src/lib_shell_services/history_mode.mli index e4489e69a161..502a52790578 100644 --- a/src/lib_shell_services/history_mode.mli +++ b/src/lib_shell_services/history_mode.mli @@ -72,8 +72,14 @@ val default : t val encoding : t Data_encoding.t +(** Returns true if the modes and the number of additional cycles are + equal. *) val equal : t -> t -> bool +(** Returns true if the modes are equal. The number of additional + cycles are not checked.*) +val mode_equality : t -> t -> bool + val pp : Format.formatter -> t -> unit val pp_short : Format.formatter -> t -> unit diff --git a/src/lib_store/unix/snapshots.ml b/src/lib_store/unix/snapshots.ml index 151d28f26d61..31f09c2223b5 100644 --- a/src/lib_store/unix/snapshots.ml +++ b/src/lib_store/unix/snapshots.ml @@ -3646,7 +3646,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct | Some stored -> let requested = snapshot_metadata.history_mode in fail_unless - (History_mode.equal requested stored) + (History_mode.mode_equality requested stored) (Inconsistent_history_mode_import {requested; stored}) | None -> return_unit in -- GitLab From 76650ef04dce9eb0d29c3c625f1bf37dce8d6ab1 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Mon, 24 Oct 2022 15:15:32 +0200 Subject: [PATCH 2/2] Changelog: do not consider add. cycles while importing a snapshot --- CHANGES.rst | 4 ++++ src/lib_shell_services/history_mode.ml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index df377a7601c1..9674eaefe0f7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -39,6 +39,10 @@ Node can still be used to override the data directory location from the configuration file, whether it is specified from the command-line or not. +- Fixed a bug that caused the ``snapshot import`` command to fail when + used on data directories configured with an explicit number + additional cycles. + Client ------ diff --git a/src/lib_shell_services/history_mode.ml b/src/lib_shell_services/history_mode.ml index b76f89b8912e..d8931e385a36 100644 --- a/src/lib_shell_services/history_mode.ml +++ b/src/lib_shell_services/history_mode.ml @@ -171,7 +171,7 @@ let equal hm1 hm2 = let mode_equality hm1 hm2 = match (hm1, hm2) with | Archive, Archive | Full _, Full _ | Rolling _, Rolling _ -> true - | _ -> false + | Archive, _ | Full _, _ | Rolling _, _ -> false let pp ppf = function | Archive -> Format.fprintf ppf "Archive mode" -- GitLab