From 97a64cabdafec786152459c877ba64594f56f29c Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Wed, 17 Jul 2024 08:15:03 +0200 Subject: [PATCH 1/3] Store: allow custom maintenance delay --- src/lib_shell_services/storage_maintenance.mli | 5 +++-- src/lib_store/shared/naming.ml | 7 +++++++ src/lib_store/shared/naming.mli | 3 +++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib_shell_services/storage_maintenance.mli b/src/lib_shell_services/storage_maintenance.mli index 8700ad0c7113..40effb247c78 100644 --- a/src/lib_shell_services/storage_maintenance.mli +++ b/src/lib_shell_services/storage_maintenance.mli @@ -25,8 +25,9 @@ val pp_context_pruning : Format.formatter -> context_pruning -> unit Setting it to [Disabled] will trigger the storage maintenance as soon as possible, that is, at the very beginning of a new cycle dawn. - [Custom n] will trigger the storage maintenance n blocks after a - new cycle dawn. *) + + [Custom n] will trigger the storage maintenance n blocks + subsequently to a new cycle dawn. *) type delay = Disabled | Custom of Int32.t val delay_encoding : delay Data_encoding.t diff --git a/src/lib_store/shared/naming.ml b/src/lib_store/shared/naming.ml index 1619672296e6..552a270ab3d1 100644 --- a/src/lib_store/shared/naming.ml +++ b/src/lib_store/shared/naming.ml @@ -172,6 +172,13 @@ let scheduled_maintenance dir = Data_encoding.(option int32) (Option.equal Int32.equal) +let scheduled_maintenance dir = + make_encoded_file + dir + ~filename:"scheduled_maintenance" + Data_encoding.(option int32) + (Option.equal Int32.equal) + let cemented_blocks_dir dir = mk_dir dir "cemented" let cemented_blocks_level_index_dir dir = mk_dir dir "level_index" diff --git a/src/lib_store/shared/naming.mli b/src/lib_store/shared/naming.mli index b3af94856ead..5a38a2a3e5f3 100644 --- a/src/lib_store/shared/naming.mli +++ b/src/lib_store/shared/naming.mli @@ -143,6 +143,9 @@ val legacy_block_store_status_file : val scheduled_maintenance : [`Chain_dir] directory -> int32 option Stored_data.file +val scheduled_maintenance : + [`Chain_dir] directory -> int32 option Stored_data.file + val cemented_blocks_dir : [< `Chain_dir | `Snapshot_dir | `Snapshot_tmp_dir | `Tar_archive] directory -> [`Cemented_blocks_dir] directory -- GitLab From 8abf7c618a891f66d3ce646c1fce3de38a0f076c Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Tue, 6 Aug 2024 09:45:05 +0200 Subject: [PATCH 2/3] Node: simplify context pruning disabling cmd line arg --- src/bin_node/node_run_command.ml | 2 +- src/lib_node_config/config_file.ml | 10 ++-- src/lib_node_config/config_file.mli | 2 +- src/lib_node_config/shared_arg.ml | 36 +++++-------- src/lib_node_config/shared_arg.mli | 2 +- src/lib_shell/node.ml | 8 +-- src/lib_shell/node.mli | 2 +- src/lib_shell_services/shell_limits.ml | 16 +++--- src/lib_shell_services/shell_limits.mli | 5 +- src/lib_shell_services/storage_maintenance.ml | 34 ------------ .../storage_maintenance.mli | 8 --- src/lib_store/mocked/store.ml | 4 +- src/lib_store/shared/store_events.ml | 7 ++- src/lib_store/store.mli | 8 +-- src/lib_store/unix/block_store.ml | 11 ++-- src/lib_store/unix/block_store.mli | 6 +-- src/lib_store/unix/store.ml | 53 ++++++++++--------- src/lib_store/unix/store.mli | 8 +-- src/lib_store/unix/test/test_block_store.ml | 10 ++-- 19 files changed, 91 insertions(+), 141 deletions(-) diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index 0bc02dfceff3..c552346a76ce 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -349,7 +349,7 @@ let init_node ?sandbox ?target ~identity ~singleprocess ~internal_events Node.create ~sandboxed:(sandbox <> None) ?sandbox_parameters:(Option.map snd sandbox_param) - ?context_pruning:config.shell.context_pruning + ?disable_context_pruning:config.shell.disable_context_pruning ~singleprocess ~version ~commit_info diff --git a/src/lib_node_config/config_file.ml b/src/lib_node_config/config_file.ml index a5752da8db8a..bac8a814a8ab 100644 --- a/src/lib_node_config/config_file.ml +++ b/src/lib_node_config/config_file.ml @@ -889,8 +889,8 @@ let update ?(disable_config_validation = false) ?data_dir ?min_connections ?(disable_mempool = default_p2p.disable_mempool) ?(enable_testchain = default_p2p.enable_testchain) ?(cors_origins = []) ?(cors_headers = []) ?rpc_tls ?log_output ?log_coloring - ?synchronisation_threshold ?history_mode ?network ?latency ?context_pruning - ?storage_maintenance_delay cfg = + ?synchronisation_threshold ?history_mode ?network ?latency + ?disable_context_pruning ?storage_maintenance_delay cfg = let open Lwt_result_syntax in let disable_config_validation = cfg.disable_config_validation || disable_config_validation @@ -1012,8 +1012,10 @@ let update ?(disable_config_validation = false) ?data_dir ?min_connections in {synchronisation}); history_mode = Option.either history_mode cfg.shell.history_mode; - context_pruning = - Option.either context_pruning cfg.shell.context_pruning; + disable_context_pruning = + Option.either + disable_context_pruning + cfg.shell.disable_context_pruning; storage_maintenance_delay = Option.either storage_maintenance_delay diff --git a/src/lib_node_config/config_file.mli b/src/lib_node_config/config_file.mli index 0f68d4574ca6..e4a6a38b440e 100644 --- a/src/lib_node_config/config_file.mli +++ b/src/lib_node_config/config_file.mli @@ -140,7 +140,7 @@ val update : ?history_mode:History_mode.t -> ?network:blockchain_network -> ?latency:int -> - ?context_pruning:Storage_maintenance.context_pruning -> + ?disable_context_pruning:bool -> ?storage_maintenance_delay:Storage_maintenance.delay -> t -> t tzresult Lwt.t diff --git a/src/lib_node_config/shared_arg.ml b/src/lib_node_config/shared_arg.ml index b331308067ba..6c7f86ae00ca 100644 --- a/src/lib_node_config/shared_arg.ml +++ b/src/lib_node_config/shared_arg.ml @@ -70,7 +70,7 @@ type t = { metrics_addr : string list; operation_metadata_size_limit : Shell_limits.operation_metadata_size_limit option; - context_pruning : Storage_maintenance.context_pruning option; + disable_context_pruning : bool option; storage_maintenance_delay : Storage_maintenance.delay option; } @@ -193,7 +193,7 @@ let wrap data_dir config_file network connections max_download_speed log_coloring history_mode synchronisation_threshold latency disable_config_validation allow_all_rpc media_type max_active_rpc_connections metrics_addr operation_metadata_size_limit - context_pruning storage_maintenance_delay = + disable_context_pruning storage_maintenance_delay = let actual_data_dir = Option.value ~default:Config_file.default_data_dir data_dir in @@ -205,6 +205,9 @@ let wrap data_dir config_file network connections max_download_speed let rpc_tls = Option.map (fun (cert, key) -> {Config_file.cert; key}) rpc_tls in + let disable_context_pruning = + if disable_context_pruning then Some true else None + in { disable_config_validation; data_dir; @@ -242,7 +245,7 @@ let wrap data_dir config_file network connections max_download_speed max_active_rpc_connections; metrics_addr; operation_metadata_size_limit; - context_pruning; + disable_context_pruning; storage_maintenance_delay; } @@ -752,24 +755,9 @@ module Term = struct Config_file.default_max_active_rpc_connections & info ~docs ~doc ~docv:"NUM" ["max-active-rpc-connections"]) - let context_pruning = - let open Storage_maintenance in - let doc = - "Configures whether or not the storage maintenance of the context should \ - be enabled" - in - let parse str = - match str with - | "disabled" -> `Ok (Disabled : Storage_maintenance.context_pruning) - | "enabled" -> `Ok Enabled - | _ -> - `Error - "context-pruning only supports \"disabled\" and \"enabled\" modes" - in - Arg.( - value - & opt (some (parse, pp_context_pruning)) None - & info ~docs ~doc ["context-pruning"]) + let disable_context_pruning = + let doc = "Disables the storage maintenance of the context" in + Arg.(value & flag & info ~docs ~doc ["disable-context-pruning"]) let storage_maintenance_delay = let open Storage_maintenance in @@ -807,7 +795,7 @@ module Term = struct $ log_output $ log_coloring $ history_mode $ synchronisation_threshold $ latency $ disable_config_validation $ allow_all_rpc $ media_type $ max_active_rpc_connections $ metrics_addr $ operation_metadata_size_limit - $ context_pruning $ storage_maintenance_delay + $ disable_context_pruning $ storage_maintenance_delay end let read_config_file args = @@ -955,7 +943,7 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) max_active_rpc_connections; metrics_addr; operation_metadata_size_limit; - context_pruning; + disable_context_pruning; storage_maintenance_delay; } = args @@ -1114,7 +1102,7 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) ?synchronisation_threshold ?history_mode ?latency - ?context_pruning + ?disable_context_pruning ?storage_maintenance_delay cfg diff --git a/src/lib_node_config/shared_arg.mli b/src/lib_node_config/shared_arg.mli index 00cb748ba56d..d85a77506408 100644 --- a/src/lib_node_config/shared_arg.mli +++ b/src/lib_node_config/shared_arg.mli @@ -86,7 +86,7 @@ type t = { operation_metadata_size_limit : Shell_limits.operation_metadata_size_limit option; (** maximum operation metadata size allowed to be stored on disk *) - context_pruning : Storage_maintenance.context_pruning option; + disable_context_pruning : bool option; storage_maintenance_delay : Storage_maintenance.delay option; } diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 0ab9410e170e..40d3e1b6aadb 100644 --- a/src/lib_shell/node.ml +++ b/src/lib_shell/node.ml @@ -217,8 +217,8 @@ let check_context_consistency store = tzfail Non_recoverable_context let create ?(sandboxed = false) ?sandbox_parameters - ?(context_pruning = Storage_maintenance.Enabled) ?history_mode - ?maintenance_delay ~singleprocess ~version ~commit_info + ?(disable_context_pruning = false) ?history_mode ?maintenance_delay + ~singleprocess ~version ~commit_info { genesis; chain_name; @@ -270,7 +270,7 @@ let create ?(sandboxed = false) ?sandbox_parameters ~context_dir:context_root ~allow_testchains:start_testchain ~readonly:false - ~context_pruning + ~disable_context_pruning ?maintenance_delay genesis in @@ -313,7 +313,7 @@ let create ?(sandboxed = false) ?sandbox_parameters ~context_dir:context_root ~allow_testchains:start_testchain ~readonly:false - ~context_pruning + ~disable_context_pruning ?maintenance_delay genesis in diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index 121063baf990..e759f7580c98 100644 --- a/src/lib_shell/node.mli +++ b/src/lib_shell/node.mli @@ -56,7 +56,7 @@ type config = { val create : ?sandboxed:bool -> ?sandbox_parameters:Data_encoding.json -> - ?context_pruning:Storage_maintenance.context_pruning -> + ?disable_context_pruning:bool -> ?history_mode:History_mode.t -> ?maintenance_delay:Storage_maintenance.delay -> singleprocess:bool -> diff --git a/src/lib_shell_services/shell_limits.ml b/src/lib_shell_services/shell_limits.ml index f8e8589cf870..9620b1d71448 100644 --- a/src/lib_shell_services/shell_limits.ml +++ b/src/lib_shell_services/shell_limits.ml @@ -245,7 +245,7 @@ let chain_validator_limits_encoding = }); ]) -let default_storage_maintenance_context_pruning = Storage_maintenance.Enabled +let default_disable_context_pruning = false let default_storage_maintenance_delay = Storage_maintenance.Disabled @@ -255,7 +255,7 @@ type limits = { peer_validator_limits : peer_validator_limits; chain_validator_limits : chain_validator_limits; history_mode : History_mode.t option; - context_pruning : Storage_maintenance.context_pruning option; + disable_context_pruning : bool option; storage_maintenance_delay : Storage_maintenance.delay option; } @@ -266,7 +266,7 @@ let default_limits = peer_validator_limits = default_peer_validator_limits; chain_validator_limits = default_chain_validator_limits; history_mode = None; - context_pruning = Some Enabled; + disable_context_pruning = Some false; storage_maintenance_delay = Some Disabled; } @@ -279,7 +279,7 @@ let limits_encoding = prevalidator_limits; chain_validator_limits; history_mode; - context_pruning; + disable_context_pruning; storage_maintenance_delay; } -> ( peer_validator_limits, @@ -287,14 +287,14 @@ let limits_encoding = prevalidator_limits, chain_validator_limits, history_mode, - context_pruning, + disable_context_pruning, storage_maintenance_delay )) (fun ( peer_validator_limits, block_validator_limits, prevalidator_limits, chain_validator_limits, history_mode, - context_pruning, + disable_context_pruning, storage_maintenance_delay ) -> { peer_validator_limits; @@ -302,7 +302,7 @@ let limits_encoding = prevalidator_limits; chain_validator_limits; history_mode; - context_pruning; + disable_context_pruning; storage_maintenance_delay; }) (obj7 @@ -323,5 +323,5 @@ let limits_encoding = chain_validator_limits_encoding default_chain_validator_limits) (opt "history_mode" History_mode.encoding) - (opt "context_pruning" Storage_maintenance.context_pruning_encoding) + (opt "disable_context_pruning" bool) (opt "storage_maintenance_delay" Storage_maintenance.delay_encoding)) diff --git a/src/lib_shell_services/shell_limits.mli b/src/lib_shell_services/shell_limits.mli index 86813499bc55..991928a699c7 100644 --- a/src/lib_shell_services/shell_limits.mli +++ b/src/lib_shell_services/shell_limits.mli @@ -93,8 +93,7 @@ val default_chain_validator_limits : chain_validator_limits val chain_validator_limits_encoding : chain_validator_limits Data_encoding.t -val default_storage_maintenance_context_pruning : - Storage_maintenance.context_pruning +val default_disable_context_pruning : bool val default_storage_maintenance_delay : Storage_maintenance.delay @@ -104,7 +103,7 @@ type limits = { peer_validator_limits : peer_validator_limits; chain_validator_limits : chain_validator_limits; history_mode : History_mode.t option; - context_pruning : Storage_maintenance.context_pruning option; + disable_context_pruning : bool option; storage_maintenance_delay : Storage_maintenance.delay option; } diff --git a/src/lib_shell_services/storage_maintenance.ml b/src/lib_shell_services/storage_maintenance.ml index 009cf21d73e2..49a8fb0ed020 100644 --- a/src/lib_shell_services/storage_maintenance.ml +++ b/src/lib_shell_services/storage_maintenance.ml @@ -5,40 +5,6 @@ (* *) (*****************************************************************************) -type context_pruning = Enabled | Disabled - -let context_pruning_encoding = - let open Data_encoding in - def - "context_pruning" - ~title:"context_pruning" - ~description:"Context pruning status" - (union - ~tag_size:`Uint8 - [ - case - ~title:"disabled" - ~description: - "When disabled, the storage maintenance won't be triggered" - (Tag 0) - (constant "disabled") - (function Disabled -> Some () | _ -> None) - (fun () -> Disabled); - case - ~title:"enabled" - ~description: - "When enabled, the storage maintenance is triggered as soon as a \ - cycle dawn is encountered. This is the default value." - (Tag 1) - (constant "enabled") - (function Enabled -> Some () | _ -> None) - (fun () -> Enabled); - ]) - -let pp_context_pruning fmt = function - | Disabled -> Format.fprintf fmt "disabled" - | Enabled -> Format.fprintf fmt "enabled" - type delay = Disabled | Custom of Int32.t let delay_encoding = diff --git a/src/lib_shell_services/storage_maintenance.mli b/src/lib_shell_services/storage_maintenance.mli index 40effb247c78..67f895caea71 100644 --- a/src/lib_shell_services/storage_maintenance.mli +++ b/src/lib_shell_services/storage_maintenance.mli @@ -12,14 +12,6 @@ *) -(** The type [context_pruning] specifies whether or not a storage maintenance - should be triggered (if [Enabled]) or not (if [Disabled]). *) -type context_pruning = Enabled | Disabled - -val context_pruning_encoding : context_pruning Data_encoding.t - -val pp_context_pruning : Format.formatter -> context_pruning -> unit - (** The type [delay] specifies whether or not a storage maintenance should be delayed or not. Setting it to [Disabled] will trigger the storage maintenance as diff --git a/src/lib_store/mocked/store.ml b/src/lib_store/mocked/store.ml index 25637ea0e24e..18e53724c226 100644 --- a/src/lib_store/mocked/store.ml +++ b/src/lib_store/mocked/store.ml @@ -1824,8 +1824,8 @@ let store_dirs = ref [] let context_dirs = ref [] let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) - ?block_cache_limit ?context_pruning:_ ?maintenance_delay:_ ~store_dir - ~context_dir ~allow_testchains genesis = + ?block_cache_limit ?disable_context_pruning:_ ?maintenance_delay:_ + ~store_dir ~context_dir ~allow_testchains genesis = let open Lwt_result_syntax in if List.mem ~equal:String.equal context_dir !context_dirs then Format.kasprintf diff --git a/src/lib_store/shared/store_events.ml b/src/lib_store/shared/store_events.ml index c84ff9926ca9..5105f255d924 100644 --- a/src/lib_store/shared/store_events.ml +++ b/src/lib_store/shared/store_events.ml @@ -35,11 +35,10 @@ let init_store = ~level:Info ~name:"init_store" ~msg: - "initializing the store (readonly:{ro}, \ - context_pruning:{context_pruning})" + "initializing the store (readonly: {ro}, disable context pruning: \ + {disable_context_pruning})" ("ro", Data_encoding.bool) - ~pp2:Storage_maintenance.pp_context_pruning - ("context_pruning", Storage_maintenance.context_pruning_encoding) + ("disable_context_pruning", Data_encoding.bool) let end_init_store = declare_0 diff --git a/src/lib_store/store.mli b/src/lib_store/store.mli index 3450bb1bff04..a0509e7ec6cb 100644 --- a/src/lib_store/store.mli +++ b/src/lib_store/store.mli @@ -206,9 +206,9 @@ type chain_store @param block_cache_limit allows to override the size of the block cache to use. The minimal value is 1. - @param context_pruning specifies whether or not the context - pruning is expected to be run (if set to Enabled) or not (if set - to Disabled) during a storage maintenance. + @param disable_context_pruning specifies whether or not the + context pruning is expected to be run (if set to true) or not (if + set to false -- default) during a storage maintenance. @param maintenace_delay allows to introduce a delay prior to the trigger of the storage maintenance @@ -225,7 +225,7 @@ val init : ?history_mode:History_mode.t -> ?readonly:bool -> ?block_cache_limit:int -> - ?context_pruning:Storage_maintenance.context_pruning -> + ?disable_context_pruning:bool -> ?maintenance_delay:Storage_maintenance.delay -> store_dir:string -> context_dir:string -> diff --git a/src/lib_store/unix/block_store.ml b/src/lib_store/unix/block_store.ml index 33e5e110bcce..e0381171825a 100644 --- a/src/lib_store/unix/block_store.ml +++ b/src/lib_store/unix/block_store.ml @@ -1345,10 +1345,10 @@ let create_merging_thread block_store ~history_mode ~old_ro_store ~old_rw_store in return (new_ro_store, new_savepoint, new_caboose) -let may_trigger_gc ~context_pruning block_store history_mode ~previous_savepoint - ~new_savepoint = +let may_trigger_gc ~disable_context_pruning block_store history_mode + ~previous_savepoint ~new_savepoint = let open Lwt_result_syntax in - if context_pruning = Storage_maintenance.Enabled then + if not disable_context_pruning then let savepoint_hash = fst new_savepoint in if History_mode.(equal history_mode Archive) @@ -1372,7 +1372,8 @@ let split_context block_store new_head_lpbl = let merge_stores ?(cycle_size_limit = default_cycle_size_limit) block_store ~(on_error : tztrace -> unit tzresult Lwt.t) ~finalizer ~history_mode - ~new_head ~new_head_metadata ~cementing_highwatermark ~context_pruning = + ~new_head ~new_head_metadata ~cementing_highwatermark + ~disable_context_pruning = let open Lwt_result_syntax in let* () = fail_when block_store.readonly Cannot_write_in_readonly in (* Do not allow multiple merges: force waiting for a potential @@ -1463,7 +1464,7 @@ let merge_stores ?(cycle_size_limit = default_cycle_size_limit) block_store its end. *) let* () = may_trigger_gc - ~context_pruning + ~disable_context_pruning block_store history_mode ~previous_savepoint diff --git a/src/lib_store/unix/block_store.mli b/src/lib_store/unix/block_store.mli index 2489f0456f9d..7b499a8de6e3 100644 --- a/src/lib_store/unix/block_store.mli +++ b/src/lib_store/unix/block_store.mli @@ -286,8 +286,8 @@ val default_cycle_size_limit : int32 After the cementing, {!Cemented_block_store.trigger_gc} will be called with the given [history_mode]. When the merging thread succeeds, the callback [finalizer] will be called. Note that - depending on [context_pruning], the context pruning may be - discarded. + depending on the [disable_context_pruning] flag, the context + pruning may be discarded. If a merge thread is already occurring, this function will first wait for the previous merge to be done. @@ -308,7 +308,7 @@ val merge_stores : new_head:Block_repr.t -> new_head_metadata:Block_repr.metadata -> cementing_highwatermark:int32 -> - context_pruning:Storage_maintenance.context_pruning -> + disable_context_pruning:bool -> unit tzresult Lwt.t val get_merge_status : t -> merge_status diff --git a/src/lib_store/unix/store.ml b/src/lib_store/unix/store.ml index f592e6ac98b7..4b215436658a 100644 --- a/src/lib_store/unix/store.ml +++ b/src/lib_store/unix/store.ml @@ -96,7 +96,7 @@ and chain_store = { (chain_store * block) Tezos_rpc.Directory.t Protocol_hash.Map.t Protocol_hash.Table.t; lockfile : Lwt_unix.file_descr; - context_pruning : Storage_maintenance.context_pruning; + disable_context_pruning : bool; storage_maintenance : storage_maintenance; } @@ -1588,13 +1588,13 @@ module Chain = struct As the split is necessary in the scope of the context pruning only, it may be discarded depending on - [context_pruning]. However, it is mandatory that the split is not - delayed by the [maintenance_delay] argument as the split must - occur at the cycle start. *) - let may_split_context ~context_pruning chain_store new_head_lpbl previous_head - = + [disabled_context_pruning]. However, it is mandatory that the + split is not delayed by the [maintenance_delay] argument as the + split must occur at the cycle start. *) + let may_split_context ~disable_context_pruning chain_store new_head_lpbl + previous_head = let open Lwt_result_syntax in - if context_pruning = Storage_maintenance.Enabled then + if not disable_context_pruning then match history_mode chain_store with | Archive -> return_unit | Full _ | Rolling _ -> @@ -1665,7 +1665,7 @@ module Chain = struct in let* () = may_split_context - ~context_pruning:chain_store.context_pruning + ~disable_context_pruning:chain_store.disable_context_pruning chain_store new_head_lpbl previous_head @@ -1832,7 +1832,8 @@ module Chain = struct (WithExceptions.Option.get ~loc:__LOC__ cementing_highwatermark) - ~context_pruning:chain_store.context_pruning + ~disable_context_pruning: + chain_store.disable_context_pruning in (* The new memory highwatermark is new_head_lpbl, the disk value will be updated after the merge completion. *) @@ -2182,7 +2183,7 @@ module Chain = struct } let create_chain_store ?block_cache_limit global_store chain_dir ?target - ~chain_id ?(expiration = None) ~context_pruning ~maintenance_delay + ~chain_id ?(expiration = None) ~disable_context_pruning ~maintenance_delay ?genesis_block ~genesis ~genesis_context history_mode = let open Lwt_result_syntax in (* Chain directory *) @@ -2234,14 +2235,14 @@ module Chain = struct validated_block_watcher; block_rpc_directories; lockfile; - context_pruning; + disable_context_pruning; storage_maintenance = {maintenance_delay; scheduled_maintenance}; } in return chain_store let load_chain_store ?block_cache_limit global_store chain_dir ~chain_id - ~readonly ~context_pruning ~maintenance_delay = + ~readonly ~disable_context_pruning ~maintenance_delay = let open Lwt_result_syntax in let* chain_config_data = Stored_data.load (Naming.chain_config_file chain_dir) @@ -2279,7 +2280,7 @@ module Chain = struct validated_block_watcher; block_rpc_directories; lockfile; - context_pruning; + disable_context_pruning; storage_maintenance = {maintenance_delay; scheduled_maintenance}; } in @@ -2355,7 +2356,7 @@ module Chain = struct testchain_dir ~chain_id ~readonly:false - ~context_pruning:Enabled + ~disable_context_pruning:false ~maintenance_delay in let testchain = {forked_block; testchain_store} in @@ -2424,7 +2425,7 @@ module Chain = struct testchain_dir ~chain_id:testchain_id ~expiration:(Some expiration) - ~context_pruning:Enabled + ~disable_context_pruning:false ~maintenance_delay:Storage_maintenance.Disabled ~genesis_block ~genesis @@ -2714,7 +2715,7 @@ end let create_store ?block_cache_limit ~context_index ~chain_id ~genesis ~genesis_context ?(history_mode = History_mode.default) ~allow_testchains - ~context_pruning ~maintenance_delay store_dir = + ~disable_context_pruning ~maintenance_delay store_dir = let open Lwt_result_syntax in let store_dir_path = Naming.dir_path store_dir in let*! () = Lwt_utils_unix.create_dir store_dir_path in @@ -2740,7 +2741,7 @@ let create_store ?block_cache_limit ~context_index ~chain_id ~genesis chain_dir ~chain_id ~expiration:None - ~context_pruning + ~disable_context_pruning ~maintenance_delay ~genesis ~genesis_context @@ -2750,7 +2751,7 @@ let create_store ?block_cache_limit ~context_index ~chain_id ~genesis return global_store let load_store ?history_mode ?block_cache_limit store_dir ~context_index - ~genesis ~chain_id ~allow_testchains ~readonly ~context_pruning + ~genesis ~chain_id ~allow_testchains ~readonly ~disable_context_pruning ~maintenance_delay () = let open Lwt_result_syntax in let chain_dir = Naming.chain_dir store_dir chain_id in @@ -2804,7 +2805,7 @@ let load_store ?history_mode ?block_cache_limit store_dir ~context_index chain_dir ~chain_id ~readonly - ~context_pruning + ~disable_context_pruning ~maintenance_delay in let stored_genesis = Chain.genesis main_chain_store in @@ -2844,11 +2845,13 @@ let check_history_mode_consistency chain_dir history_mode = else (* Store is not yet initialized. *) return_unit let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) - ?block_cache_limit ?(context_pruning = Storage_maintenance.Enabled) + ?block_cache_limit ?(disable_context_pruning = false) ?(maintenance_delay = Storage_maintenance.Disabled) ~store_dir ~context_dir ~allow_testchains genesis = let open Lwt_result_syntax in - let*! () = Store_events.(emit init_store) (readonly, context_pruning) in + let*! () = + Store_events.(emit init_store) (readonly, disable_context_pruning) + in let patch_context = Option.map (fun f ctxt -> @@ -2897,7 +2900,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) ~chain_id ~allow_testchains ~readonly - ~context_pruning + ~disable_context_pruning ~maintenance_delay () else @@ -2908,7 +2911,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) store_dir ~context_index:(Context_ops.Disk_index context_index) ~chain_id - ~context_pruning + ~disable_context_pruning ~genesis ~genesis_context ?history_mode @@ -2965,7 +2968,7 @@ let may_switch_history_mode ~store_dir ~context_dir genesis ~new_history_mode = ~chain_id ~allow_testchains:true ~readonly:false - ~context_pruning:Enabled + ~disable_context_pruning:false ~maintenance_delay:Storage_maintenance.Disabled () in @@ -3367,7 +3370,7 @@ module Unsafe = struct ~chain_id ~allow_testchains:false ~readonly:true - ~context_pruning:Disabled + ~disable_context_pruning:true ~maintenance_delay:Storage_maintenance.Disabled () in diff --git a/src/lib_store/unix/store.mli b/src/lib_store/unix/store.mli index 3f8c89347064..bb285a7508e7 100644 --- a/src/lib_store/unix/store.mli +++ b/src/lib_store/unix/store.mli @@ -205,9 +205,9 @@ type chain_store @param block_cache_limit allows to override the size of the block cache to use. The minimal value is 1. - @param context_pruning specifies whether or not the context - pruning is expected to be run (if set to Enabled) or not (if set - to Disabled) during a storage maintenance. + @param disable_context_pruning specifies whether or not the + context pruning is expected to be run (if set to true) or not (if + set to false -- default) during a storage maintenance. @param maintenace_delay allows to introduce a delay prior to the trigger of the storage maintenance @@ -224,7 +224,7 @@ val init : ?history_mode:History_mode.t -> ?readonly:bool -> ?block_cache_limit:int -> - ?context_pruning:Storage_maintenance.context_pruning -> + ?disable_context_pruning:bool -> ?maintenance_delay:Storage_maintenance.delay -> store_dir:string -> context_dir:string -> diff --git a/src/lib_store/unix/test/test_block_store.ml b/src/lib_store/unix/test/test_block_store.ml index 3d22203ba253..23b79c2e02be 100644 --- a/src/lib_store/unix/test/test_block_store.ml +++ b/src/lib_store/unix/test/test_block_store.ml @@ -259,7 +259,7 @@ let test_simple_merge block_store = ~new_head:head ~new_head_metadata:head_metadata ~cementing_highwatermark:0l - ~context_pruning:Enabled + ~disable_context_pruning:false in let*! () = Block_store.await_merging block_store in assert_cemented_bound @@ -315,7 +315,7 @@ let test_consecutive_concurrent_merges block_store = ~new_head ~new_head_metadata ~cementing_highwatermark:previous_cycle_lpbl - ~context_pruning:Enabled + ~disable_context_pruning:false in let threads = List.map merge_cycle cycles_to_merge in let*! res = Lwt.all threads in @@ -360,7 +360,7 @@ let test_ten_cycles_merge block_store = (head |> Block_repr.metadata |> WithExceptions.Option.to_exn ~none:Not_found) ~cementing_highwatermark:0l - ~context_pruning:Enabled + ~disable_context_pruning:false in let* () = assert_presence_in_block_store ~with_metadata:true block_store all_blocks @@ -462,7 +462,7 @@ let test_merge_with_branches block_store = (head |> Block_repr.metadata |> WithExceptions.Option.to_exn ~none:Not_found) ~cementing_highwatermark:0l - ~context_pruning:Enabled + ~disable_context_pruning:false in let*! () = Block_store.await_merging block_store in let* () = @@ -501,7 +501,7 @@ let perform_n_cycles_merge ?(cycle_length = 10) (head |> Block_repr.metadata |> WithExceptions.Option.to_exn ~none:Not_found) ~cementing_highwatermark:0l - ~context_pruning:Enabled + ~disable_context_pruning:false in let*! () = Block_store.await_merging block_store in return cycles -- GitLab From d1bf59f96d594e2b2e36f174dfd6391a49a9e372 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Tue, 6 Aug 2024 09:45:16 +0200 Subject: [PATCH 3/3] Tezt: simplify context pruning disabling cmd line arg --- tezt/lib_tezos/node.ml | 8 ++++---- tezt/lib_tezos/node.mli | 2 +- tezt/tests/storage_maintenance.ml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tezt/lib_tezos/node.ml b/tezt/lib_tezos/node.ml index df0e8f121abc..5cde2ccf2706 100644 --- a/tezt/lib_tezos/node.ml +++ b/tezt/lib_tezos/node.ml @@ -59,7 +59,7 @@ type argument = | RPC_additional_addr of string | RPC_additional_addr_external of string | Max_active_rpc_connections of int - | Context_pruning of string + | Disable_context_pruning | Storage_maintenance_delay of string let make_argument = function @@ -94,7 +94,7 @@ let make_argument = function | RPC_additional_addr_external addr -> ["--external-rpc-addr"; addr] | Max_active_rpc_connections n -> ["--max-active-rpc-connections"; string_of_int n] - | Context_pruning x -> ["--context-pruning"; x] + | Disable_context_pruning -> ["--disable-context-pruning"] | Storage_maintenance_delay x -> ["--storage-maintenance-delay"; x] let make_arguments arguments = List.flatten (List.map make_argument arguments) @@ -119,7 +119,7 @@ let is_redundant = function | Metadata_size_limit _, Metadata_size_limit _ | Version, Version | Max_active_rpc_connections _, Max_active_rpc_connections _ - | Context_pruning _, Context_pruning _ + | Disable_context_pruning, Disable_context_pruning | Storage_maintenance_delay _, Storage_maintenance_delay _ -> true | Metrics_addr addr1, Metrics_addr addr2 -> addr1 = addr2 @@ -146,7 +146,7 @@ let is_redundant = function | RPC_additional_addr_external _, _ | Version, _ | Max_active_rpc_connections _, _ - | Context_pruning _, _ + | Disable_context_pruning, _ | Storage_maintenance_delay _, _ -> false diff --git a/tezt/lib_tezos/node.mli b/tezt/lib_tezos/node.mli index 08f925ff56af..5981088bded9 100644 --- a/tezt/lib_tezos/node.mli +++ b/tezt/lib_tezos/node.mli @@ -99,7 +99,7 @@ type argument = | RPC_additional_addr of string (** [--rpc-addr] *) | RPC_additional_addr_external of string (** [--external-rpc-addr] *) | Max_active_rpc_connections of int (** [--max-active-rpc-connections] *) - | Context_pruning of string (** [--context-pruning] *) + | Disable_context_pruning (** [--disable_context-pruning] *) | Storage_maintenance_delay of string (** [--storage-maintenance-delay]*) (** A TLS configuration for the node: paths to a [.crt] and a [.key] file. diff --git a/tezt/tests/storage_maintenance.ml b/tezt/tests/storage_maintenance.ml index 345a21b5e662..85e07cb01411 100644 --- a/tezt/tests/storage_maintenance.ml +++ b/tezt/tests/storage_maintenance.ml @@ -40,7 +40,7 @@ let test_context_pruning_call = @@ fun protocol -> let* node1, client = Client.init_with_protocol - ~nodes_args:Node.[Synchronisation_threshold 0; Context_pruning "disabled"] + ~nodes_args:Node.[Synchronisation_threshold 0; Disable_context_pruning] `Client ~protocol () -- GitLab