diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index c552346a76ce84704b9a1bb48c460cb169f0544d..0bc02dfceff30add0327462aac8426ce0123163f 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) - ?disable_context_pruning:config.shell.disable_context_pruning + ?context_pruning:config.shell.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 bac8a814a8abac71054b88be92ec831da1a18048..a5752da8db8ae8bcb9f62be478bea33f4b4d9d9d 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 - ?disable_context_pruning ?storage_maintenance_delay cfg = + ?synchronisation_threshold ?history_mode ?network ?latency ?context_pruning + ?storage_maintenance_delay cfg = let open Lwt_result_syntax in let disable_config_validation = cfg.disable_config_validation || disable_config_validation @@ -1012,10 +1012,8 @@ let update ?(disable_config_validation = false) ?data_dir ?min_connections in {synchronisation}); history_mode = Option.either history_mode cfg.shell.history_mode; - disable_context_pruning = - Option.either - disable_context_pruning - cfg.shell.disable_context_pruning; + context_pruning = + Option.either context_pruning cfg.shell.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 e4a6a38b440ef68d563b551e0e68a3a876c32e26..0f68d4574ca69c2cd02c89f07c6afe44110de394 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 -> - ?disable_context_pruning:bool -> + ?context_pruning:Storage_maintenance.context_pruning -> ?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 6c7f86ae00ca551f807226eae84b60ae67070c11..b331308067baf9fd73af872cca305acd2b3b777f 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; - disable_context_pruning : bool option; + context_pruning : Storage_maintenance.context_pruning 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 - disable_context_pruning storage_maintenance_delay = + context_pruning storage_maintenance_delay = let actual_data_dir = Option.value ~default:Config_file.default_data_dir data_dir in @@ -205,9 +205,6 @@ 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; @@ -245,7 +242,7 @@ let wrap data_dir config_file network connections max_download_speed max_active_rpc_connections; metrics_addr; operation_metadata_size_limit; - disable_context_pruning; + context_pruning; storage_maintenance_delay; } @@ -755,9 +752,24 @@ module Term = struct Config_file.default_max_active_rpc_connections & info ~docs ~doc ~docv:"NUM" ["max-active-rpc-connections"]) - let disable_context_pruning = - let doc = "Disables the storage maintenance of the context" in - Arg.(value & flag & info ~docs ~doc ["disable-context-pruning"]) + 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 storage_maintenance_delay = let open Storage_maintenance in @@ -795,7 +807,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 - $ disable_context_pruning $ storage_maintenance_delay + $ context_pruning $ storage_maintenance_delay end let read_config_file args = @@ -943,7 +955,7 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) max_active_rpc_connections; metrics_addr; operation_metadata_size_limit; - disable_context_pruning; + context_pruning; storage_maintenance_delay; } = args @@ -1102,7 +1114,7 @@ let patch_config ?(may_override_network = false) ?(emit = Event.emit) ?synchronisation_threshold ?history_mode ?latency - ?disable_context_pruning + ?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 d85a77506408d075f79faa277e511f5d5f4ffd5d..00cb748ba56d9fe1a4b411c347808ac050a6221b 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 *) - disable_context_pruning : bool option; + context_pruning : Storage_maintenance.context_pruning option; storage_maintenance_delay : Storage_maintenance.delay option; } diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 40d3e1b6aadb734cae315bc39bf93f2bb9938087..0ab9410e170e5e0425d9ef44084dbef5719640ea 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 - ?(disable_context_pruning = false) ?history_mode ?maintenance_delay - ~singleprocess ~version ~commit_info + ?(context_pruning = Storage_maintenance.Enabled) ?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 - ~disable_context_pruning + ~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 - ~disable_context_pruning + ~context_pruning ?maintenance_delay genesis in diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index e759f7580c98e3ac1b12123035aa804c4582a362..121063baf9902e6fb56ac5b7d02dac39ecc1566c 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 -> - ?disable_context_pruning:bool -> + ?context_pruning:Storage_maintenance.context_pruning -> ?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 9620b1d714488e856a0dbb5c46e178fbc36d9cdf..f8e8589cf87001d3d4d9375a466478fca9835115 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_disable_context_pruning = false +let default_storage_maintenance_context_pruning = Storage_maintenance.Enabled 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; - disable_context_pruning : bool option; + context_pruning : Storage_maintenance.context_pruning 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; - disable_context_pruning = Some false; + context_pruning = Some Enabled; storage_maintenance_delay = Some Disabled; } @@ -279,7 +279,7 @@ let limits_encoding = prevalidator_limits; chain_validator_limits; history_mode; - disable_context_pruning; + context_pruning; storage_maintenance_delay; } -> ( peer_validator_limits, @@ -287,14 +287,14 @@ let limits_encoding = prevalidator_limits, chain_validator_limits, history_mode, - disable_context_pruning, + context_pruning, storage_maintenance_delay )) (fun ( peer_validator_limits, block_validator_limits, prevalidator_limits, chain_validator_limits, history_mode, - disable_context_pruning, + context_pruning, storage_maintenance_delay ) -> { peer_validator_limits; @@ -302,7 +302,7 @@ let limits_encoding = prevalidator_limits; chain_validator_limits; history_mode; - disable_context_pruning; + 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 "disable_context_pruning" bool) + (opt "context_pruning" Storage_maintenance.context_pruning_encoding) (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 991928a699c725f3ca2e93b7700622befde43505..86813499bc559c5befc86ec260fcc207b6918670 100644 --- a/src/lib_shell_services/shell_limits.mli +++ b/src/lib_shell_services/shell_limits.mli @@ -93,7 +93,8 @@ val default_chain_validator_limits : chain_validator_limits val chain_validator_limits_encoding : chain_validator_limits Data_encoding.t -val default_disable_context_pruning : bool +val default_storage_maintenance_context_pruning : + Storage_maintenance.context_pruning val default_storage_maintenance_delay : Storage_maintenance.delay @@ -103,7 +104,7 @@ type limits = { peer_validator_limits : peer_validator_limits; chain_validator_limits : chain_validator_limits; history_mode : History_mode.t option; - disable_context_pruning : bool option; + context_pruning : Storage_maintenance.context_pruning 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 49a8fb0ed020f00e4b2da9fa2d9f29dab1d2ff9d..009cf21d73e2909e40d1d15281d21515fda9e4ac 100644 --- a/src/lib_shell_services/storage_maintenance.ml +++ b/src/lib_shell_services/storage_maintenance.ml @@ -5,6 +5,40 @@ (* *) (*****************************************************************************) +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 67f895caea71384de2ed863cb6862129ad4466ef..8700ad0c7113cce8214577d53803fbd7ee156425 100644 --- a/src/lib_shell_services/storage_maintenance.mli +++ b/src/lib_shell_services/storage_maintenance.mli @@ -12,14 +12,21 @@ *) +(** 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 soon as possible, that is, at the very beginning of a new cycle dawn. - - [Custom n] will trigger the storage maintenance n blocks - subsequently to a new cycle dawn. *) + [Custom n] will trigger the storage maintenance n blocks after a + new cycle dawn. *) type delay = Disabled | Custom of Int32.t val delay_encoding : delay Data_encoding.t diff --git a/src/lib_store/mocked/store.ml b/src/lib_store/mocked/store.ml index 18e53724c2261f80e9dcb8f91f5b3bd922e7ae63..25637ea0e24e7dfa5c6bc007d139ce0f709bdae0 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 ?disable_context_pruning:_ ?maintenance_delay:_ - ~store_dir ~context_dir ~allow_testchains genesis = + ?block_cache_limit ?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/naming.ml b/src/lib_store/shared/naming.ml index 552a270ab3d15ac7136fa32cee88f42111e3bcb7..1619672296e6fc46557eb0b31e8ccf4f58326db0 100644 --- a/src/lib_store/shared/naming.ml +++ b/src/lib_store/shared/naming.ml @@ -172,13 +172,6 @@ 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 5a38a2a3e5f3319e314865dc40905ca6c6ab6f2c..b3af94856ead99a239a4c8e2ae7cb9f1354dcdbe 100644 --- a/src/lib_store/shared/naming.mli +++ b/src/lib_store/shared/naming.mli @@ -143,9 +143,6 @@ 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 diff --git a/src/lib_store/shared/store_events.ml b/src/lib_store/shared/store_events.ml index 5105f255d924105358f276a319acf3323cc1cebf..c84ff9926ca9307b01342063aa2d67d6abf9ac41 100644 --- a/src/lib_store/shared/store_events.ml +++ b/src/lib_store/shared/store_events.ml @@ -35,10 +35,11 @@ let init_store = ~level:Info ~name:"init_store" ~msg: - "initializing the store (readonly: {ro}, disable context pruning: \ - {disable_context_pruning})" + "initializing the store (readonly:{ro}, \ + context_pruning:{context_pruning})" ("ro", Data_encoding.bool) - ("disable_context_pruning", Data_encoding.bool) + ~pp2:Storage_maintenance.pp_context_pruning + ("context_pruning", Storage_maintenance.context_pruning_encoding) let end_init_store = declare_0 diff --git a/src/lib_store/store.mli b/src/lib_store/store.mli index a0509e7ec6cbf079d397f0fbc8ca135bd4aaea71..3450bb1bff04945c6b4ab0d0da824621e850346a 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 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 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 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 -> - ?disable_context_pruning:bool -> + ?context_pruning:Storage_maintenance.context_pruning -> ?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 e0381171825a5bc24e259b8faf9ebfee0c17c564..33e5e110bccede7c731569905a8f3178affc2e31 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 ~disable_context_pruning block_store history_mode - ~previous_savepoint ~new_savepoint = +let may_trigger_gc ~context_pruning block_store history_mode ~previous_savepoint + ~new_savepoint = let open Lwt_result_syntax in - if not disable_context_pruning then + if context_pruning = Storage_maintenance.Enabled then let savepoint_hash = fst new_savepoint in if History_mode.(equal history_mode Archive) @@ -1372,8 +1372,7 @@ 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 - ~disable_context_pruning = + ~new_head ~new_head_metadata ~cementing_highwatermark ~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 @@ -1464,7 +1463,7 @@ let merge_stores ?(cycle_size_limit = default_cycle_size_limit) block_store its end. *) let* () = may_trigger_gc - ~disable_context_pruning + ~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 7b499a8de6e3d6170ce5e64d1739cc0a35515005..2489f0456f9dd1ff513a59d8380e26ba2a91a53a 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 the [disable_context_pruning] flag, the context - pruning may be discarded. + depending on [context_pruning], 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 -> - disable_context_pruning:bool -> + context_pruning:Storage_maintenance.context_pruning -> 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 4b215436658a778c4a54b73c586409283af9ca59..f592e6ac98b71b560329f887d8dd5e651a3adf86 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; - disable_context_pruning : bool; + context_pruning : Storage_maintenance.context_pruning; 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 - [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 = + [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 + = let open Lwt_result_syntax in - if not disable_context_pruning then + if context_pruning = Storage_maintenance.Enabled then match history_mode chain_store with | Archive -> return_unit | Full _ | Rolling _ -> @@ -1665,7 +1665,7 @@ module Chain = struct in let* () = may_split_context - ~disable_context_pruning:chain_store.disable_context_pruning + ~context_pruning:chain_store.context_pruning chain_store new_head_lpbl previous_head @@ -1832,8 +1832,7 @@ module Chain = struct (WithExceptions.Option.get ~loc:__LOC__ cementing_highwatermark) - ~disable_context_pruning: - chain_store.disable_context_pruning + ~context_pruning:chain_store.context_pruning in (* The new memory highwatermark is new_head_lpbl, the disk value will be updated after the merge completion. *) @@ -2183,7 +2182,7 @@ module Chain = struct } let create_chain_store ?block_cache_limit global_store chain_dir ?target - ~chain_id ?(expiration = None) ~disable_context_pruning ~maintenance_delay + ~chain_id ?(expiration = None) ~context_pruning ~maintenance_delay ?genesis_block ~genesis ~genesis_context history_mode = let open Lwt_result_syntax in (* Chain directory *) @@ -2235,14 +2234,14 @@ module Chain = struct validated_block_watcher; block_rpc_directories; lockfile; - disable_context_pruning; + 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 ~disable_context_pruning ~maintenance_delay = + ~readonly ~context_pruning ~maintenance_delay = let open Lwt_result_syntax in let* chain_config_data = Stored_data.load (Naming.chain_config_file chain_dir) @@ -2280,7 +2279,7 @@ module Chain = struct validated_block_watcher; block_rpc_directories; lockfile; - disable_context_pruning; + context_pruning; storage_maintenance = {maintenance_delay; scheduled_maintenance}; } in @@ -2356,7 +2355,7 @@ module Chain = struct testchain_dir ~chain_id ~readonly:false - ~disable_context_pruning:false + ~context_pruning:Enabled ~maintenance_delay in let testchain = {forked_block; testchain_store} in @@ -2425,7 +2424,7 @@ module Chain = struct testchain_dir ~chain_id:testchain_id ~expiration:(Some expiration) - ~disable_context_pruning:false + ~context_pruning:Enabled ~maintenance_delay:Storage_maintenance.Disabled ~genesis_block ~genesis @@ -2715,7 +2714,7 @@ end let create_store ?block_cache_limit ~context_index ~chain_id ~genesis ~genesis_context ?(history_mode = History_mode.default) ~allow_testchains - ~disable_context_pruning ~maintenance_delay store_dir = + ~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 @@ -2741,7 +2740,7 @@ let create_store ?block_cache_limit ~context_index ~chain_id ~genesis chain_dir ~chain_id ~expiration:None - ~disable_context_pruning + ~context_pruning ~maintenance_delay ~genesis ~genesis_context @@ -2751,7 +2750,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 ~disable_context_pruning + ~genesis ~chain_id ~allow_testchains ~readonly ~context_pruning ~maintenance_delay () = let open Lwt_result_syntax in let chain_dir = Naming.chain_dir store_dir chain_id in @@ -2805,7 +2804,7 @@ let load_store ?history_mode ?block_cache_limit store_dir ~context_index chain_dir ~chain_id ~readonly - ~disable_context_pruning + ~context_pruning ~maintenance_delay in let stored_genesis = Chain.genesis main_chain_store in @@ -2845,13 +2844,11 @@ 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 ?(disable_context_pruning = false) + ?block_cache_limit ?(context_pruning = Storage_maintenance.Enabled) ?(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, disable_context_pruning) - in + let*! () = Store_events.(emit init_store) (readonly, context_pruning) in let patch_context = Option.map (fun f ctxt -> @@ -2900,7 +2897,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) ~chain_id ~allow_testchains ~readonly - ~disable_context_pruning + ~context_pruning ~maintenance_delay () else @@ -2911,7 +2908,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) store_dir ~context_index:(Context_ops.Disk_index context_index) ~chain_id - ~disable_context_pruning + ~context_pruning ~genesis ~genesis_context ?history_mode @@ -2968,7 +2965,7 @@ let may_switch_history_mode ~store_dir ~context_dir genesis ~new_history_mode = ~chain_id ~allow_testchains:true ~readonly:false - ~disable_context_pruning:false + ~context_pruning:Enabled ~maintenance_delay:Storage_maintenance.Disabled () in @@ -3370,7 +3367,7 @@ module Unsafe = struct ~chain_id ~allow_testchains:false ~readonly:true - ~disable_context_pruning:true + ~context_pruning:Disabled ~maintenance_delay:Storage_maintenance.Disabled () in diff --git a/src/lib_store/unix/store.mli b/src/lib_store/unix/store.mli index bb285a7508e707511eb9b300a5a34a7b2e9575b6..3f8c89347064f4df14ed40eed26b7baae385ab53 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 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 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 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 -> - ?disable_context_pruning:bool -> + ?context_pruning:Storage_maintenance.context_pruning -> ?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 23b79c2e02be5a3e0e7d9dd18cd7a7bf1b6be320..3d22203ba253668ee000404314e91f0b7a9531b6 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 - ~disable_context_pruning:false + ~context_pruning:Enabled 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 - ~disable_context_pruning:false + ~context_pruning:Enabled 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 - ~disable_context_pruning:false + ~context_pruning:Enabled 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 - ~disable_context_pruning:false + ~context_pruning:Enabled 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 - ~disable_context_pruning:false + ~context_pruning:Enabled in let*! () = Block_store.await_merging block_store in return cycles diff --git a/tezt/lib_tezos/node.ml b/tezt/lib_tezos/node.ml index 5cde2ccf270626ca5381c4b3677d84f0cb7cab30..df0e8f121abc6de161a65a80d187c3c9c667d359 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 - | Disable_context_pruning + | Context_pruning of string | 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] - | Disable_context_pruning -> ["--disable-context-pruning"] + | Context_pruning x -> ["--context-pruning"; x] | 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 _ - | Disable_context_pruning, Disable_context_pruning + | Context_pruning _, 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 _, _ - | Disable_context_pruning, _ + | Context_pruning _, _ | Storage_maintenance_delay _, _ -> false diff --git a/tezt/lib_tezos/node.mli b/tezt/lib_tezos/node.mli index 5981088bded99b652ca6fddf1bc808c0aea35423..08f925ff56affc1a7507bb45b874fe54c7b8920b 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] *) - | Disable_context_pruning (** [--disable_context-pruning] *) + | Context_pruning of string (** [--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 85e07cb0141186af0c20f01ffa4026d3b7d9100c..345a21b5e6620a637965e1225aef720c95ee0b62 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; Disable_context_pruning] + ~nodes_args:Node.[Synchronisation_threshold 0; Context_pruning "disabled"] `Client ~protocol ()