From e6ee05bb325f10826c17dd2d30be0bec1437d966 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Wed, 4 Jun 2025 17:42:22 +0200 Subject: [PATCH 1/4] All: fix wrong usage of context_root_dir -- use data_dir instead --- devtools/get_contracts/get_contracts.ml | 2 +- devtools/proto_context_du/main.ml | 2 +- .../safety_checker.ml | 2 +- .../simulation_scenario.ml | 10 +-- devtools/yes_wallet/yes_wallet_lib.ml | 2 +- docs/doc_gen/node_helpers.ml | 1 - src/bin_node/node_reconstruct_command.ml | 3 +- src/bin_node/node_replay_command.ml | 7 +- src/bin_node/node_run_command.ml | 3 +- src/bin_node/node_snapshot_command.ml | 8 +- src/bin_node/node_storage_command.ml | 54 ++++++------- .../context_ops/context_ops.ml | 32 ++++---- .../context_ops/context_ops.mli | 8 +- src/lib_rpc_process/head_daemon.ml | 4 +- src/lib_shell/node.ml | 7 +- src/lib_shell/node.mli | 1 - src/lib_shell/test/shell_test_helpers.ml | 4 +- src/lib_shell/test/test_node.ml | 1 - src/lib_shell/test/test_prevalidation.ml | 4 +- src/lib_shell_benchmarks/io_helpers.ml | 2 +- src/lib_store/mocked/store.ml | 17 ++-- src/lib_store/store.mli | 30 ++++--- src/lib_store/unix/reconstruction.ml | 4 +- src/lib_store/unix/reconstruction.mli | 9 +-- src/lib_store/unix/snapshots.ml | 80 +++++++++---------- src/lib_store/unix/snapshots.mli | 12 +-- src/lib_store/unix/store.ml | 16 ++-- src/lib_store/unix/store.mli | 44 +++++----- src/lib_store/unix/test/test_consistency.ml | 8 +- .../unix/test/test_history_mode_switch.ml | 8 +- src/lib_store/unix/test/test_locator.ml | 6 +- src/lib_store/unix/test/test_reconstruct.ml | 22 ++--- src/lib_store/unix/test/test_snapshots.ml | 30 +++---- src/lib_store/unix/test/test_store.ml | 4 +- src/lib_store/unix/test/test_utils.ml | 14 ++-- src/lib_validation/external_validation.ml | 10 +-- src/lib_validation/external_validation.mli | 1 - src/lib_validation/external_validator.ml | 12 +-- .../lib_delegate/baking_commands.ml | 2 +- 39 files changed, 225 insertions(+), 261 deletions(-) diff --git a/devtools/get_contracts/get_contracts.ml b/devtools/get_contracts/get_contracts.ml index a24386791ebf..a24a5def26ef 100644 --- a/devtools/get_contracts/get_contracts.ml +++ b/devtools/get_contracts/get_contracts.ml @@ -771,7 +771,7 @@ let commands = let* store = Tezos_store.Store.init ~store_dir:(Filename.concat data_dir "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:true ~readonly:true genesis diff --git a/devtools/proto_context_du/main.ml b/devtools/proto_context_du/main.ml index 9475e5e66ca9..c3313a9b2651 100644 --- a/devtools/proto_context_du/main.ml +++ b/devtools/proto_context_du/main.ml @@ -256,7 +256,7 @@ module Commands = struct let* store = Tezos_store.Store.init ~store_dir:(Filename.concat data_dir "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:true ~readonly:true genesis diff --git a/devtools/testnet_experiment_tools/safety_checker.ml b/devtools/testnet_experiment_tools/safety_checker.ml index 0af21d10ebd0..66852cba343d 100644 --- a/devtools/testnet_experiment_tools/safety_checker.ml +++ b/devtools/testnet_experiment_tools/safety_checker.ml @@ -574,7 +574,7 @@ let commands = Store.init ~readonly:true ~store_dir:(data_dir // "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:false config.blockchain_network.genesis in diff --git a/devtools/testnet_experiment_tools/simulation_scenario.ml b/devtools/testnet_experiment_tools/simulation_scenario.ml index e94df351ee37..1241177f8dbe 100644 --- a/devtools/testnet_experiment_tools/simulation_scenario.ml +++ b/devtools/testnet_experiment_tools/simulation_scenario.ml @@ -170,11 +170,11 @@ let extract_history ~data_dir ~output_dir = use_data_dir data_dir @@ fun () -> let* _, config = Shared_arg.resolve_data_dir_and_config_file ~data_dir () in let store_dir = data_dir // "store" in - let context_root_dir = data_dir in + let data_dir = data_dir in let* store = Store.init ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:false ~readonly:true config.blockchain_network.genesis @@ -196,7 +196,7 @@ let extract_history ~data_dir ~output_dir = ~rolling:true ~block:(`Hash (Store.Block.hash snapshotted_block, 0)) ~store_dir - ~context_root_dir + ~data_dir ~chain_name:config.blockchain_network.chain_name ~progress_display_mode:Animation.Auto Snapshots.Tar @@ -318,7 +318,7 @@ let patch_block_time ~data_dir ~block_time_target ~patch_max_op_ttl = Store.init ~readonly:false ~store_dir:(data_dir // "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:false config.blockchain_network.genesis in @@ -392,7 +392,7 @@ let commands = Store.init ~readonly:true ~store_dir:(data_dir // "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:false config.blockchain_network.genesis in diff --git a/devtools/yes_wallet/yes_wallet_lib.ml b/devtools/yes_wallet/yes_wallet_lib.ml index 303b67d2094e..9d3d283683b6 100644 --- a/devtools/yes_wallet/yes_wallet_lib.ml +++ b/devtools/yes_wallet/yes_wallet_lib.ml @@ -464,7 +464,7 @@ let get_context ?level ~network_opt base_dir = (fun () -> Tezos_store.Store.init ~store_dir:(Filename.concat base_dir "store") - ~context_root_dir:base_dir + ~data_dir:base_dir ~allow_testchains:true ~readonly:true genesis) diff --git a/docs/doc_gen/node_helpers.ml b/docs/doc_gen/node_helpers.ml index a70eb2d46a90..2b8c89ff25f0 100644 --- a/docs/doc_gen/node_helpers.ml +++ b/docs/doc_gen/node_helpers.ml @@ -51,7 +51,6 @@ let with_node f = patch_context = None; data_dir = dir; store_root = dir / "store"; - context_root_dir = dir; protocol_root = dir / "protocol"; p2p = None; target = None; diff --git a/src/bin_node/node_reconstruct_command.ml b/src/bin_node/node_reconstruct_command.ml index f014b4dbb022..e90c706fa8e3 100644 --- a/src/bin_node/node_reconstruct_command.ml +++ b/src/bin_node/node_reconstruct_command.ml @@ -73,14 +73,13 @@ module Term = struct ~filename:(Data_version.lock_file data_dir) @@ fun () -> let store_dir = Data_version.store_dir data_dir in - let context_root_dir = data_dir in let patch_context = Patch_context.patch_context genesis sandbox_parameters in Reconstruction.reconstruct ~patch_context ~store_dir - ~context_root_dir + ~data_dir genesis ~user_activated_upgrades: node_config.blockchain_network.user_activated_upgrades diff --git a/src/bin_node/node_replay_command.ml b/src/bin_node/node_replay_command.ml index 77e8651ea744..c483dc025a04 100644 --- a/src/bin_node/node_replay_command.ml +++ b/src/bin_node/node_replay_command.ml @@ -471,7 +471,7 @@ let replay ~internal_events ~singleprocess ~strict ~repeat ~stats_output ~operation_metadata_size_limit (config : Config_file.t) blocks = let open Lwt_result_syntax in let store_root = Data_version.store_dir config.data_dir in - let context_root_dir = config.data_dir in + let data_dir = config.data_dir in let protocol_root = Data_version.protocol_dir config.data_dir in let genesis = config.blockchain_network.genesis in let (validator_env : Block_validator_process.validator_environment) = @@ -488,7 +488,7 @@ let replay ~internal_events ~singleprocess ~strict ~repeat ~stats_output let* store = Store.init ~store_dir:store_root - ~context_root_dir + ~data_dir ~allow_testchains:false ~readonly genesis @@ -509,7 +509,6 @@ let replay ~internal_events ~singleprocess ~strict ~repeat ~stats_output data_dir = config.data_dir; readonly; genesis; - context_root_dir = config.data_dir; protocol_root; sandbox_parameters = None; user_activated_upgrades = @@ -528,7 +527,7 @@ let replay ~internal_events ~singleprocess ~strict ~repeat ~stats_output let* store = Store.init ~store_dir:store_root - ~context_root_dir + ~data_dir ~allow_testchains:false ~readonly ~commit_genesis diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index 3806283e111a..3e81ecf06a18 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -324,7 +324,6 @@ let init_node ?sandbox ?target ~identity ~singleprocess ~internal_events data_dir = config.data_dir; internal_events; store_root = Data_version.store_dir config.data_dir; - context_root_dir = config.data_dir; protocol_root = Data_version.protocol_dir config.data_dir; p2p = p2p_config; target; @@ -338,7 +337,7 @@ let init_node ?sandbox ?target ~identity ~singleprocess ~internal_events | Some history_mode when force_history_mode_switch -> Store.may_switch_history_mode ~store_dir:node_config.store_root - ~context_root_dir:config.data_dir + ~data_dir:config.data_dir genesis ~new_history_mode:history_mode | _ -> return_unit diff --git a/src/bin_node/node_snapshot_command.ml b/src/bin_node/node_snapshot_command.ml index 749ceeb969cb..b2da67dd9282 100644 --- a/src/bin_node/node_snapshot_command.ml +++ b/src/bin_node/node_snapshot_command.ml @@ -131,7 +131,6 @@ module Term = struct node_config.blockchain_network in let* () = Data_version.ensure_data_dir genesis data_dir in - let context_root_dir = data_dir in let store_dir = Data_version.store_dir data_dir in let* block = match block with @@ -148,7 +147,7 @@ module Term = struct (Option.value export_format ~default:Snapshots.Tar) ~rolling ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~block ~progress_display_mode @@ -207,7 +206,6 @@ module Term = struct tzfail (Node_run_command.Invalid_sandbox_file filename) | Ok json -> return_some ("sandbox_parameter", json)) in - let context_root = data_dir in let store_root = Data_version.store_dir data_dir in let patch_context = Patch_context.patch_context genesis sandbox_parameters @@ -234,7 +232,7 @@ module Term = struct ?block ~check_consistency ~dst_store_dir:store_root - ~dst_context_root_dir:context_root + ~dst_data_dir:data_dir ~chain_name:node_config.blockchain_network.chain_name ~configured_history_mode ~user_activated_upgrades: @@ -258,7 +256,7 @@ module Term = struct Reconstruction.reconstruct ~patch_context ~store_dir:store_root - ~context_root_dir:context_root + ~data_dir genesis ~user_activated_upgrades: node_config.blockchain_network.user_activated_upgrades diff --git a/src/bin_node/node_storage_command.ml b/src/bin_node/node_storage_command.ml index 048ac5347e81..5ec1dba9cbd0 100644 --- a/src/bin_node/node_storage_command.ml +++ b/src/bin_node/node_storage_command.ml @@ -106,17 +106,14 @@ module Term = struct genesis : Genesis.t; chain_id : Chain_id.t; data_dir : string; - context_root_dir : string; + context_dir : string; store_dir : string; } (* This is actually a weak check. The irmin command should take care of checking whether or not the directory is valid/initialized or not. *) - let ensure_context_dir context_root_dir = - let context_dir = - Tezos_context_ops.Context_ops.context_dir context_root_dir - in + let ensure_context_dir context_dir = let open Lwt_result_syntax in Lwt.catch (fun () -> @@ -145,10 +142,10 @@ module Term = struct in let chain_id = Chain_id.of_block_hash genesis.block in let* () = Data_version.ensure_data_dir genesis data_dir in - let context_root_dir = data_dir in - let* () = ensure_context_dir context_root_dir in + let context_dir = Tezos_context_ops.Context_ops.context_dir data_dir in + let* () = ensure_context_dir context_dir in let store_dir = Data_version.store_dir data_dir in - return {genesis; chain_id; data_dir; context_root_dir; store_dir} + return {genesis; chain_id; data_dir; context_dir; store_dir} let resolve_block chain_store block = let open Lwt_result_syntax in @@ -165,11 +162,11 @@ module Term = struct Shared_arg.process_command (let open Lwt_result_syntax in let*! () = Tezos_base_unix.Internal_event_unix.init () in - let* {genesis; chain_id; context_root_dir; store_dir; _} = + let* {genesis; chain_id; store_dir; data_dir; _} = resolve_config config_file data_dir in let* store = - Store.init ~store_dir ~context_root_dir ~allow_testchains:false genesis + Store.init ~store_dir ~data_dir ~allow_testchains:false genesis in let* chain_store = Store.get_chain_store store chain_id in let* block = resolve_block chain_store block in @@ -181,8 +178,7 @@ module Term = struct tzfail (Data_version.Invalid_data_dir { - data_dir = - Tezos_context_ops.Context_ops.context_dir context_root_dir; + data_dir = Tezos_context_ops.Context_ops.context_dir data_dir; msg = Some (Format.sprintf @@ -200,7 +196,7 @@ module Term = struct let*! () = Tezos_context.Context.Checks.Pack.Integrity_check.run ~ppf:Format.std_formatter - ~root:(Tezos_context_ops.Context_ops.context_dir context_root_dir) + ~root:(Tezos_context_ops.Context_ops.context_dir data_dir) ~auto_repair ~always:false ~heads:(Some [context_hash_str]) @@ -211,18 +207,18 @@ module Term = struct let stat_index config_file data_dir = Shared_arg.process_command (let open Lwt_result_syntax in - let* {context_root_dir; _} = resolve_config config_file data_dir in + let* {data_dir; _} = resolve_config config_file data_dir in Tezos_context.Context.Checks.Index.Stat.run - ~root:(Tezos_context_ops.Context_ops.context_dir context_root_dir) ; + ~root:(Tezos_context_ops.Context_ops.context_dir data_dir) ; return_unit) let stat_pack config_file data_dir = Shared_arg.process_command (let open Lwt_result_syntax in - let* {context_root_dir; _} = resolve_config config_file data_dir in + let* {data_dir; _} = resolve_config config_file data_dir in let*! () = Tezos_context.Context.Checks.Pack.Stat.run - ~root:(Tezos_context_ops.Context_ops.context_dir context_root_dir) + ~root:(Tezos_context_ops.Context_ops.context_dir data_dir) in return_unit) @@ -235,10 +231,8 @@ module Term = struct let reconstruct_index config_file data_dir output index_log_size = Shared_arg.process_command (let open Lwt_result_syntax in - let* {context_root_dir; _} = resolve_config config_file data_dir in - let context_dir = - Tezos_context_ops.Context_ops.context_dir context_root_dir - in + let* {data_dir; _} = resolve_config config_file data_dir in + let context_dir = Tezos_context_ops.Context_ops.context_dir data_dir in let* () = index_dir_exists context_dir output in Tezos_context.Context.Checks.Pack.Reconstruct_index.run ~root:context_dir @@ -251,11 +245,11 @@ module Term = struct Shared_arg.process_command (let open Lwt_result_syntax in let*! () = Tezos_base_unix.Internal_event_unix.init () in - let* {genesis; chain_id; context_root_dir; store_dir; _} = + let* {genesis; chain_id; data_dir; store_dir; _} = resolve_config config_file data_dir in let* store = - Store.init ~store_dir ~context_root_dir ~allow_testchains:false genesis + Store.init ~store_dir ~data_dir ~allow_testchains:false genesis in let* chain_store = Store.get_chain_store store chain_id in let* block = resolve_block chain_store block in @@ -270,7 +264,7 @@ module Term = struct in let*! () = Tezos_context.Context.Checks.Pack.Integrity_check_inodes.run - ~root:(Tezos_context_ops.Context_ops.context_dir context_root_dir) + ~root:(Tezos_context_ops.Context_ops.context_dir data_dir) ~heads:(Some [context_hash_str]) in return_unit) @@ -278,9 +272,9 @@ module Term = struct let check_index config_file data_dir auto_repair = Shared_arg.process_command (let open Lwt_result_syntax in - let* {context_root_dir; _} = resolve_config config_file data_dir in + let* {data_dir; _} = resolve_config config_file data_dir in Tezos_context.Context.Checks.Pack.Integrity_check_index.run - ~root:(Tezos_context_ops.Context_ops.context_dir context_root_dir) + ~root:(Tezos_context_ops.Context_ops.context_dir data_dir) ~auto_repair () ; return_unit) @@ -289,11 +283,11 @@ module Term = struct Shared_arg.process_command (let open Lwt_result_syntax in let*! () = Tezos_base_unix.Internal_event_unix.init () in - let* {genesis; chain_id; context_root_dir; store_dir; _} = + let* {genesis; chain_id; data_dir; store_dir; _} = resolve_config config_file data_dir in let* store = - Store.init ~store_dir ~context_root_dir ~allow_testchains:false genesis + Store.init ~store_dir ~data_dir ~allow_testchains:false genesis in let* chain_store = Store.get_chain_store store chain_id in let*! head = Store.Chain.current_head chain_store in @@ -435,14 +429,14 @@ module Term = struct Shared_arg.process_command (let open Lwt_result_syntax in let*! () = Tezos_base_unix.Internal_event_unix.init () in - let* {genesis; context_root_dir; store_dir; _} = + let* {genesis; data_dir; store_dir; _} = resolve_config config_file data_dir in let* store = Store.init ~readonly:true ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:false genesis in diff --git a/src/lib_protocol_environment/context_ops/context_ops.ml b/src/lib_protocol_environment/context_ops/context_ops.ml index ff4aafb3f9c9..a3091b3c0d9c 100644 --- a/src/lib_protocol_environment/context_ops/context_ops.ml +++ b/src/lib_protocol_environment/context_ops/context_ops.ml @@ -91,9 +91,9 @@ let do_not_use__is_duo () = | "duo" -> true | _ | (exception Not_found) -> false -let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = +let init ~kind ?patch_context ?readonly ?index_log_size ~data_dir () = let open Lwt_syntax in - let irmin_dir = irmin_context_dir context_root_dir in + let irmin_dir = irmin_context_dir data_dir in let init_context () = let* () = Events.(emit initializing_context) ("irmin", irmin_dir) in let patch_context = @@ -107,7 +107,7 @@ let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = Context.init ?patch_context ?readonly ?index_log_size irmin_dir in - let brassaia_dir = brassaia_context_dir context_root_dir in + let brassaia_dir = brassaia_context_dir data_dir in let init_brassaia_context () = let* () = Events.(emit initializing_context) ("brassaia", brassaia_dir) in let patch_context = @@ -153,8 +153,10 @@ let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = Duo_memory_index {irmin_index; brassaia_index} (* Wrapper over init that uses an environment variable ('TEZOS_CONTEXT_BACKEND') - to select the backend between Memory|Brassaia_memory and Disk|Brassaia *) -let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = + to select the backend between Memory|Brassaia_memory and Disk|Brassaia. + [data_dir] stands for the root directory in which the context directory is + expected to be find. *) +let init ~kind ?patch_context ?readonly ?index_log_size ~data_dir () = let open Lwt_syntax in (* Gather the initialisation profiling otherwise aggregates will behave like records and create a section for each call *) @@ -168,16 +170,17 @@ let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = ?patch_context ?readonly ?index_log_size - context_root_dir + ~data_dir + () | `Memory -> init ~kind:`Brassaia_memory ?patch_context ?readonly ?index_log_size - context_root_dir - | _ -> - init ~kind ?patch_context ?readonly ?index_log_size context_root_dir) + ~data_dir + () + | _ -> init ~kind ?patch_context ?readonly ?index_log_size ~data_dir ()) | "duo" -> ( match kind with | `Disk -> @@ -187,7 +190,8 @@ let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = ?patch_context ?readonly ?index_log_size - context_root_dir + ~data_dir + () | `Memory -> let* () = Events.(emit warning_experimental) () in init @@ -195,11 +199,11 @@ let init ~kind ?patch_context ?readonly ?index_log_size context_root_dir = ?patch_context ?readonly ?index_log_size - context_root_dir - | _ -> - init ~kind ?patch_context ?readonly ?index_log_size context_root_dir) + ~data_dir + () + | _ -> init ~kind ?patch_context ?readonly ?index_log_size ~data_dir ()) | _ | (exception Not_found) -> - init ~kind ?patch_context ?readonly ?index_log_size context_root_dir + init ~kind ?patch_context ?readonly ?index_log_size ~data_dir () let index (context : Environment_context.t) = match[@profiler.span_f {verbosity = Notice} ["context_ops"; "index"]] diff --git a/src/lib_protocol_environment/context_ops/context_ops.mli b/src/lib_protocol_environment/context_ops/context_ops.mli index b9a490e1b07f..7381806b1f42 100644 --- a/src/lib_protocol_environment/context_ops/context_ops.mli +++ b/src/lib_protocol_environment/context_ops/context_ops.mli @@ -43,8 +43,9 @@ val context_dir : string -> string to copy the imported "context" to "brassaia_context" in duo mode *) val do_not_use__brassaia_dir : string -> string -(** [init] uses an environment variable ('TEZOS_CONTEXT_BACKEND') - to select the `Disk backend between `Shell and `Brassaia *) +(** [init] uses an environment variable ('TEZOS_CONTEXT_BACKEND') to select the + `Disk backend between `Shell and `Brassaia. [data_dir] stands for the root + directory in which the context directory is expected to be find. *) val init : kind:[< `Brassaia | `Brassaia_memory | `Disk | `Memory > `Disk `Memory] -> ?patch_context: @@ -52,7 +53,8 @@ val init : (Tezos_protocol_environment.Context.t, tztrace) result Lwt.t) -> ?readonly:bool -> ?index_log_size:int -> - string -> + data_dir:string -> + unit -> index Lwt.t val index : t -> index diff --git a/src/lib_rpc_process/head_daemon.ml b/src/lib_rpc_process/head_daemon.ml index ced66333189e..539c16f9460e 100644 --- a/src/lib_rpc_process/head_daemon.ml +++ b/src/lib_rpc_process/head_daemon.ml @@ -117,11 +117,11 @@ let init_store ~allow_testchains ~readonly parameters = the consistency checks. *) let config = parameters.config in let store_dir = Data_version.store_dir config.data_dir in - let context_root_dir = config.data_dir in + let data_dir = config.data_dir in Store.init ?history_mode:config.shell.history_mode ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains ~readonly config.blockchain_network.genesis diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 40d97dcf3a34..dfeebe062655 100644 --- a/src/lib_shell/node.ml +++ b/src/lib_shell/node.ml @@ -128,7 +128,6 @@ type config = { data_dir : string; internal_events : Tezos_base.Internal_event_config.t; store_root : string; - context_root_dir : string; protocol_root : string; patch_context : (Tezos_protocol_environment.Context.t -> @@ -219,7 +218,6 @@ let create ?(sandboxed = false) ?sandbox_parameters data_dir; internal_events; store_root; - context_root_dir; protocol_root; patch_context; p2p = p2p_params; @@ -257,7 +255,7 @@ let create ?(sandboxed = false) ?sandbox_parameters ?patch_context ?history_mode ~store_dir:store_root - ~context_root_dir + ~data_dir ~allow_testchains:start_testchain ~readonly:false ~disable_context_pruning @@ -279,7 +277,6 @@ let create ?(sandboxed = false) ?sandbox_parameters data_dir; readonly = false; genesis; - context_root_dir; protocol_root; sandbox_parameters; user_activated_upgrades; @@ -299,7 +296,7 @@ let create ?(sandboxed = false) ?sandbox_parameters ?history_mode ~commit_genesis ~store_dir:store_root - ~context_root_dir + ~data_dir ~allow_testchains:start_testchain ~readonly:false ~disable_context_pruning diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index be0b6505eb9f..a974ffbe8468 100644 --- a/src/lib_shell/node.mli +++ b/src/lib_shell/node.mli @@ -21,7 +21,6 @@ type config = { data_dir : string; internal_events : Tezos_base.Internal_event_config.t; store_root : string; - context_root_dir : string; protocol_root : string; patch_context : (Tezos_protocol_environment.Context.t -> diff --git a/src/lib_shell/test/shell_test_helpers.ml b/src/lib_shell/test/shell_test_helpers.ml index d31e7ee37451..ddbfbd9be99e 100644 --- a/src/lib_shell/test/shell_test_helpers.ml +++ b/src/lib_shell/test/shell_test_helpers.ml @@ -77,11 +77,11 @@ let patch_context ctxt = let init_chain ?(history_mode = History_mode.Archive) base_dir = let open Lwt_syntax in let store_dir = base_dir // "store" in - let context_root_dir = base_dir in + let data_dir = base_dir in let* r = Store.init ~store_dir - ~context_root_dir + ~data_dir ~history_mode ~allow_testchains:true ~patch_context diff --git a/src/lib_shell/test/test_node.ml b/src/lib_shell/test/test_node.ml index 37d9752377fd..bae7ce50b68e 100644 --- a/src/lib_shell/test/test_node.ml +++ b/src/lib_shell/test/test_node.ml @@ -52,7 +52,6 @@ let init_config (* (f : 'a -> unit -> unit Lwt.t) *) f test_dir switch () : internal_events = Tezos_base.Internal_event_config.stdout; data_dir = test_dir; store_root = test_dir // "store"; - context_root_dir = test_dir; protocol_root = test_dir // "protocol"; patch_context = None; p2p = None; diff --git a/src/lib_shell/test/test_prevalidation.ml b/src/lib_shell/test/test_prevalidation.ml index 4128ee2f7774..9614f6449495 100644 --- a/src/lib_shell/test/test_prevalidation.ml +++ b/src/lib_shell/test/test_prevalidation.ml @@ -48,9 +48,9 @@ module Init = struct let wrap_tzresult_lwt_disk (f : Tezos_protocol_environment.Context.t -> unit tzresult Lwt.t) () : unit tzresult Lwt.t = - Lwt_utils_unix.with_tempdir "tezos_test_" (fun base_dir -> + Lwt_utils_unix.with_tempdir "tezos_test_" (fun data_dir -> let open Lwt_result_syntax in - let*! idx = Context_ops.init ~kind:`Disk base_dir in + let*! idx = Context_ops.init ~kind:`Disk ~data_dir () in let* genesis = Context_ops.commit_genesis idx diff --git a/src/lib_shell_benchmarks/io_helpers.ml b/src/lib_shell_benchmarks/io_helpers.ml index a6d2c1e182aa..96517efd71cc 100644 --- a/src/lib_shell_benchmarks/io_helpers.ml +++ b/src/lib_shell_benchmarks/io_helpers.ml @@ -339,7 +339,7 @@ let load_head_block data_dir = let* store = init ~store_dir:(Filename.concat data_dir "store") - ~context_root_dir:data_dir + ~data_dir ~allow_testchains:false genesis in diff --git a/src/lib_store/mocked/store.ml b/src/lib_store/mocked/store.ml index 2772155c47e1..ecb022b02a96 100644 --- a/src/lib_store/mocked/store.ml +++ b/src/lib_store/mocked/store.ml @@ -1824,10 +1824,8 @@ 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_root_dir ~allow_testchains genesis = - let context_dir = - Tezos_context_ops.Context_ops.context_dir context_root_dir - in + ~store_dir ~data_dir ~allow_testchains genesis = + let context_dir = Tezos_context_ops.Context_ops.context_dir data_dir in let open Lwt_result_syntax in if List.mem ~equal:String.equal context_dir !context_dirs then Format.kasprintf @@ -1845,16 +1843,13 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) ~kind:`Memory ~readonly:true ?patch_context - context_root_dir + ~data_dir + () in Lwt.return (context_index, commit_genesis) | None -> let*! context_index = - Context_ops.init - ~kind:`Memory - ~readonly - ?patch_context - context_root_dir + Context_ops.init ~kind:`Memory ~readonly ?patch_context ~data_dir () in let commit_genesis ~chain_id = Context_ops.commit_genesis @@ -1893,7 +1888,7 @@ let close_store global_store = Lwt_watcher.shutdown_input global_store.global_block_watcher ; Lwt.return_unit -let may_switch_history_mode ~store_dir:_ ~context_root_dir:_ _genesis +let may_switch_history_mode ~store_dir:_ ~data_dir:_ _genesis ~new_history_mode:_ = Stdlib.failwith "may_switch_history_mode: unimplemented" diff --git a/src/lib_store/store.mli b/src/lib_store/store.mli index 467064d26ad2..c764ea6c6c0e 100644 --- a/src/lib_store/store.mli +++ b/src/lib_store/store.mli @@ -176,17 +176,15 @@ type chain_store (** {3 Initialization} *) (** [init ?patch_context ?commit_genesis ?history_mode ?readonly - ?block_cache_limit ?disable_context_pruning ?maintenance_delay - ~store_dir ~context_root_dir ~allow_testchains genesis] initializes the - store and a main chain store. If [store_dir] (resp. [context_root_dir]) - does not exist, a fresh store (resp. context) is - created. Otherwise, it loads the store (resp. context) from - reading the adequate directory. If [allow_testchains] is passed, - the store will be able to fork chains and instantiate testchain's - sub chain stores, for all chains contained in the store. The chain - store created is based on the [genesis] provided. Its chain - identifier will be computed using the {!Chain_id.of_block_hash} - function. + ?block_cache_limit ?disable_context_pruning ?maintenance_delay ~store_dir + ~data_dir ~allow_testchains genesis] initializes the store and a main chain + store. If [store_dir] (resp. [data_dir]) does not exist, a fresh store + (resp. context) is created. Otherwise, it loads the store (resp. context) + from reading the adequate directory. If [allow_testchains] is passed, the + store will be able to fork chains and instantiate testchain's sub chain + stores, for all chains contained in the store. The chain store created is + based on the [genesis] provided. Its chain identifier will be computed using + the {!Chain_id.of_block_hash} function. @param patch_context the handle called when initializing the context. It usually is passed when creating a sandboxed chain. @@ -232,7 +230,7 @@ val init : ?disable_context_pruning:bool -> ?maintenance_delay:Storage_maintenance.delay -> store_dir:string -> - context_root_dir:string -> + data_dir:string -> allow_testchains:bool -> Genesis.t -> store tzresult Lwt.t @@ -257,12 +255,12 @@ val main_chain_store : store -> chain_store already closed, this function is idempotent. *) val close_store : store -> unit Lwt.t -(** [may_switch_history_mode ?patch_context ~store_dir ~context_root_dir - genesis ~new_history_mode] tries switching the store located at - [store_dir] (if present) to [new_history_mode] when possible. *) +(** [may_switch_history_mode ?patch_context ~store_dir ~data_dir genesis + ~new_history_mode] tries switching the store located at [store_dir] (if + present) to [new_history_mode] when possible. *) val may_switch_history_mode : store_dir:string -> - context_root_dir:string -> + data_dir:string -> Genesis.t -> new_history_mode:History_mode.t -> unit tzresult Lwt.t diff --git a/src/lib_store/unix/reconstruction.ml b/src/lib_store/unix/reconstruction.ml index faac5c4bd63a..120b4ee2e4f9 100644 --- a/src/lib_store/unix/reconstruction.ml +++ b/src/lib_store/unix/reconstruction.ml @@ -979,7 +979,7 @@ let may_commit_genesis chain_store context_index genesis = in return_unit -let reconstruct ?patch_context ~store_dir ~context_root_dir genesis +let reconstruct ?patch_context ~store_dir ~data_dir genesis ~user_activated_upgrades ~user_activated_protocol_overrides ~operation_metadata_size_limit ~progress_display_mode = let open Lwt_result_syntax in @@ -990,7 +990,7 @@ let reconstruct ?patch_context ~store_dir ~context_root_dir genesis ~block_cache_limit:1 ?patch_context ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:false genesis in diff --git a/src/lib_store/unix/reconstruction.mli b/src/lib_store/unix/reconstruction.mli index 0f894d71bb8a..d0308d2a374a 100644 --- a/src/lib_store/unix/reconstruction.mli +++ b/src/lib_store/unix/reconstruction.mli @@ -61,16 +61,15 @@ type error += Reconstruction_failure of failure_kind type error += Cannot_reconstruct of History_mode.t -(** [reconstruct ?patch_context ~store_dir ~context_root_dir genesis uau - uapo omsl] reconstructs the storage located in [store_dir] and - [context_root_dir]. The resulting storage will see its history mode - changed to archive. *) +(** [reconstruct ?patch_context ~store_dir ~data_dir genesis uau uapo + omsl] reconstructs the storage located in [store_dir] and [data_dir]. The + resulting storage will see its history mode changed to archive. *) val reconstruct : ?patch_context: (Tezos_protocol_environment.Context.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t) -> store_dir:string -> - context_root_dir:string -> + data_dir:string -> Genesis.t -> user_activated_upgrades:User_activated.upgrades -> user_activated_protocol_overrides:User_activated.protocol_overrides -> diff --git a/src/lib_store/unix/snapshots.ml b/src/lib_store/unix/snapshots.ml index 676442aa6711..cda624439e74 100644 --- a/src/lib_store/unix/snapshots.ml +++ b/src/lib_store/unix/snapshots.ml @@ -2016,7 +2016,7 @@ module type Snapshot_exporter = sig ?rolling:bool -> block:Block_services.block -> store_dir:string -> - context_root_dir:string -> + data_dir:string -> chain_name:Distributed_db_version.Name.t -> progress_display_mode:Animation.progress_display_mode -> Genesis.t -> @@ -2461,11 +2461,11 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct let* () = Event.(emit floating_blocks_exported) () in return_ok_unit - let export_context snapshot_exporter ~context_root_dir context_hash = + let export_context snapshot_exporter ~data_dir context_hash = let open Lwt_result_syntax in let*! () = Event.(emit exporting_context) () in let*! context_index = - Context_ops.init ~kind:`Disk ~readonly:true context_root_dir + Context_ops.init ~kind:`Disk ~readonly:true ~data_dir () in let is_gc_allowed = Context_ops.is_gc_allowed context_index in let* () = @@ -2483,8 +2483,8 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct let*! () = Event.(emit context_exported) () in return_unit - let export_rolling snapshot_exporter ~store_dir ~context_root_dir ~block - ~rolling genesis = + let export_rolling snapshot_exporter ~store_dir ~data_dir ~block ~rolling + genesis = let open Lwt_result_syntax in let export_rolling_f chain_store = let* () = check_history_mode chain_store ~rolling in @@ -2550,10 +2550,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct Store.Block.resulting_context_hash chain_store export_block in let* () = - export_context - snapshot_exporter - ~context_root_dir - pred_resulting_context_hash + export_context snapshot_exporter ~data_dir pred_resulting_context_hash in return ( export_mode, @@ -2571,7 +2568,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct (return_unit, floating_block_stream) ) = Store.Unsafe.open_for_snapshot_export ~store_dir - ~context_root_dir + ~data_dir genesis ~locked_f:export_rolling_f in @@ -2583,7 +2580,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct protocol_levels, (return_unit, floating_block_stream) ) - let export_full snapshot_exporter ~store_dir ~context_root_dir ~block ~rolling + let export_full snapshot_exporter ~store_dir ~data_dir ~block ~rolling ~progress_display_mode genesis = let open Lwt_result_syntax in let export_full_f chain_store = @@ -2655,7 +2652,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct let* () = export_context snapshot_exporter - ~context_root_dir + ~data_dir pred_resulting_context_hash in return @@ -2684,7 +2681,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct should_filter_indexes ) = Store.Unsafe.open_for_snapshot_export ~store_dir - ~context_root_dir + ~data_dir genesis ~locked_f:export_full_f in @@ -2738,8 +2735,8 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct tzfail (Invalid_chain_store_export (chain_id, Naming.dir_path store_dir)) - let export ?snapshot_path ?(rolling = false) ~block ~store_dir - ~context_root_dir ~chain_name ~progress_display_mode genesis = + let export ?snapshot_path ?(rolling = false) ~block ~store_dir ~data_dir + ~chain_name ~progress_display_mode genesis = let open Lwt_result_syntax in let chain_id = Chain_id.of_block_hash genesis.Genesis.block in let* () = ensure_valid_export_chain_dir store_dir chain_id in @@ -2763,7 +2760,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct export_rolling snapshot_exporter ~store_dir - ~context_root_dir + ~data_dir ~block ~rolling genesis @@ -2771,7 +2768,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct export_full snapshot_exporter ~store_dir - ~context_root_dir + ~data_dir ~block ~rolling ~progress_display_mode @@ -2987,7 +2984,7 @@ module type IMPORTER = sig val load_block_data : t -> block_data tzresult Lwt.t - val restore_context : t -> dst_context_root_dir:string -> unit tzresult Lwt.t + val restore_context : t -> dst_data_dir:string -> unit tzresult Lwt.t val load_protocol_table : t -> Protocol_levels.protocol_info Protocol_levels.t tzresult Lwt.t @@ -3076,7 +3073,7 @@ module Raw_importer : IMPORTER = struct | Some v -> return v | None -> tzfail (Cannot_read {kind = `Block_data; path = file})) - let restore_context t ~dst_context_root_dir = + let restore_context t ~dst_data_dir = let open Lwt_result_syntax in let context_file_path = Naming.(snapshot_context_file t.snapshot_dir |> file_path) @@ -3084,7 +3081,7 @@ module Raw_importer : IMPORTER = struct let*! () = Lwt_utils_unix.copy_dir context_file_path - (Tezos_context_ops.Context_ops.context_dir dst_context_root_dir) + (Tezos_context_ops.Context_ops.context_dir dst_data_dir) in return_unit @@ -3406,25 +3403,23 @@ module Tar_importer : IMPORTER = struct | None -> tzfail (Cannot_read {kind = `Block_data; path = filename})) | None -> tzfail (Cannot_read {kind = `Block_data; path = filename}) - let restore_context t ~dst_context_root_dir = + let restore_context t ~dst_data_dir = let open Lwt_result_syntax in let*! () = Lwt_unix.mkdir - (Tezos_context_ops.Context_ops.context_dir dst_context_root_dir) + (Tezos_context_ops.Context_ops.context_dir dst_data_dir) snapshot_dir_perm in let index = Filename.concat - (Tezos_context_ops.Context_ops.context_dir dst_context_root_dir) + (Tezos_context_ops.Context_ops.context_dir dst_data_dir) "index" in let*! () = Lwt_unix.mkdir index snapshot_dir_perm in let*! context_files = Onthefly.find_files_with_common_path t.tar ~pattern:"context" in - let dst_dir = - Tezos_context_ops.Context_ops.context_dir dst_context_root_dir - in + let dst_dir = Tezos_context_ops.Context_ops.context_dir dst_data_dir in let*! () = List.iter_s (fun file -> @@ -3687,7 +3682,7 @@ module type Snapshot_importer = sig ?block:Block_hash.t -> ?check_consistency:bool -> dst_store_dir:[`Store_dir] Naming.directory -> - dst_context_root_dir:string -> + dst_data_dir:string -> chain_name:Distributed_db_version.Name.t -> configured_history_mode:History_mode.t option -> user_activated_upgrades:User_activated.upgrades -> @@ -3905,7 +3900,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct return block_validation_result let restore_and_apply_context snapshot_importer protocol_levels - ?user_expected_block ~dst_context_root_dir ~user_activated_upgrades + ?user_expected_block ~dst_data_dir ~user_activated_upgrades ~user_activated_protocol_overrides ~operation_metadata_size_limit ~patch_context ~check_consistency snapshot_metadata genesis chain_id = let open Lwt_result_syntax in @@ -3955,8 +3950,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct Animation.three_dots ~progress_display_mode:Auto ~msg:"Importing context" - @@ fun () -> - Importer.restore_context snapshot_importer ~dst_context_root_dir + @@ fun () -> Importer.restore_context snapshot_importer ~dst_data_dir in let*! () = if Context_ops.do_not_use__is_duo () then @@ -3965,9 +3959,9 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct in "brassaia_context" *) Lwt_utils_unix.copy_dir (* Copy the context directory in the brassaia_context directory *) - (Tezos_context_ops.Context_ops.context_dir dst_context_root_dir) + (Tezos_context_ops.Context_ops.context_dir dst_data_dir) (Tezos_context_ops.Context_ops.do_not_use__brassaia_dir - dst_context_root_dir) + dst_data_dir) else Lwt.return_unit in let*! context_index = @@ -3976,7 +3970,8 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct ~readonly:false ~index_log_size:default_index_log_size ?patch_context - dst_context_root_dir + ~data_dir:dst_data_dir + () in let* genesis_ctxt_hash = Context_ops.commit_genesis @@ -3994,8 +3989,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct let*! () = Context_ops.integrity_check ?ppf:None - ~root: - (Tezos_context_ops.Context_ops.context_dir dst_context_root_dir) + ~root:(Tezos_context_ops.Context_ops.context_dir dst_data_dir) ~auto_repair:false ~always:false ~heads:(Some [Context_hash.to_b58check imported_context_hash]) @@ -4031,8 +4025,8 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct (* TODO parallelise in another process *) (* TODO? remove patch context *) let import ~snapshot_path ?patch_context ?block:user_expected_block - ?(check_consistency = true) ~dst_store_dir ~dst_context_root_dir - ~chain_name ~configured_history_mode ~user_activated_upgrades + ?(check_consistency = true) ~dst_store_dir ~dst_data_dir ~chain_name + ~configured_history_mode ~user_activated_upgrades ~user_activated_protocol_overrides ~operation_metadata_size_limit ~progress_display_mode (genesis : Genesis.t) = let open Lwt_result_syntax in @@ -4128,7 +4122,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct snapshot_importer protocol_levels ?user_expected_block - ~dst_context_root_dir + ~dst_data_dir ~user_activated_upgrades ~user_activated_protocol_overrides ~operation_metadata_size_limit @@ -4273,8 +4267,8 @@ let snapshot_file_kind ~snapshot_path = let* () = is_valid_uncompressed_snapshot snapshot_file in return Tar) -let export ?snapshot_path export_format ?rolling ~block ~store_dir - ~context_root_dir ~chain_name ~progress_display_mode genesis = +let export ?snapshot_path export_format ?rolling ~block ~store_dir ~data_dir + ~chain_name ~progress_display_mode genesis = let (module Exporter) = match export_format with | Tar -> (module Make_snapshot_exporter (Tar_exporter) : Snapshot_exporter) @@ -4285,7 +4279,7 @@ let export ?snapshot_path export_format ?rolling ~block ~store_dir ?rolling ~block ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~progress_display_mode genesis @@ -4301,7 +4295,7 @@ let read_snapshot_header ~snapshot_path = Loader.load_snapshot_header ~snapshot_path let import ~snapshot_path ?patch_context ?block ?check_consistency - ~dst_store_dir ~dst_context_root_dir ~chain_name ~configured_history_mode + ~dst_store_dir ~dst_data_dir ~chain_name ~configured_history_mode ~user_activated_upgrades ~user_activated_protocol_overrides ~operation_metadata_size_limit ~progress_display_mode genesis = let open Lwt_result_syntax in @@ -4318,7 +4312,7 @@ let import ~snapshot_path ?patch_context ?block ?check_consistency ?block ?check_consistency ~dst_store_dir - ~dst_context_root_dir + ~dst_data_dir ~chain_name ~configured_history_mode ~user_activated_upgrades diff --git a/src/lib_store/unix/snapshots.mli b/src/lib_store/unix/snapshots.mli index 00691cfe1ca3..90f8158824bf 100644 --- a/src/lib_store/unix/snapshots.mli +++ b/src/lib_store/unix/snapshots.mli @@ -163,8 +163,8 @@ val read_snapshot_header : snapshot_path:string -> Snapshot_header.t tzresult Lwt.t (** [export ?snapshot_path snapshot_format ?rolling ~block ~store_dir - ~context_root_dir ~chain_name genesis ~progress_display_mode] reads - from the [store_dir] and [context_root_dir] the current state of the + ~data_dir ~chain_name genesis ~progress_display_mode] reads + from the [store_dir] and [data_dir] the current state of the node and produces a snapshot, of the given [snapshot_format], in [snapshot_file] if it is provided. Otherwise, a snapshot file name is automatically generated using the target block as hint. If @@ -175,17 +175,17 @@ val export : ?rolling:bool -> block:Block_services.block -> store_dir:string -> - context_root_dir:string -> + data_dir:string -> chain_name:Distributed_db_version.Name.t -> progress_display_mode:Animation.progress_display_mode -> Genesis.t -> unit tzresult Lwt.t (** [import ~snapshot_path ?patch_context ?block ?check_consistency - ~dst_store_dir ~dst_context_root_dir chain_name + ~dst_store_dir ~dst_data_dir chain_name ~user_activated_upgrades ~user_activated_protocol_overrides ~ops_metadata_size_limit genesis] populates [dst_store_dir] and - [dst_context_root_dir] with the data contained in the + [dst_data_dir] with the data contained in the [snapshot_file]. If [check_consistency] is unset, less security checks will be made and the import process will be more efficient. If [block] is set, the import process will make sure @@ -202,7 +202,7 @@ val import : ?block:Block_hash.t -> ?check_consistency:bool -> dst_store_dir:string -> - dst_context_root_dir:string -> + dst_data_dir:string -> chain_name:Distributed_db_version.Name.t -> configured_history_mode:History_mode.t option -> user_activated_upgrades:User_activated.upgrades -> diff --git a/src/lib_store/unix/store.ml b/src/lib_store/unix/store.ml index c0beb42f5dd5..aba0007202d9 100644 --- a/src/lib_store/unix/store.ml +++ b/src/lib_store/unix/store.ml @@ -3100,7 +3100,7 @@ let check_history_mode_consistency chain_dir history_mode = let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) ?block_cache_limit ?(disable_context_pruning = false) - ?(maintenance_delay = Storage_maintenance.Auto) ~store_dir ~context_root_dir + ?(maintenance_delay = Storage_maintenance.Auto) ~store_dir ~data_dir ~allow_testchains genesis = let open Lwt_result_syntax in let*! () = @@ -3119,12 +3119,13 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) ~kind:`Disk ~readonly:true ?patch_context - context_root_dir + ~data_dir + () in Lwt.return (context_index, commit_genesis) | None -> let*! context_index = - Context_ops.init ~kind:`Disk ~readonly ?patch_context context_root_dir + Context_ops.init ~kind:`Disk ~readonly ?patch_context ~data_dir () in let commit_genesis ~chain_id = Context_ops.commit_genesis @@ -3283,8 +3284,7 @@ let close_store global_store = let* () = Chain.close_chain_store main_chain_store in Context_ops.close global_store.context_index -let may_switch_history_mode ~store_dir ~context_root_dir genesis - ~new_history_mode = +let may_switch_history_mode ~store_dir ~data_dir genesis ~new_history_mode = let open Lwt_result_syntax in let store_dir = Naming.store_dir ~dir_path:store_dir in let chain_id = Chain_id.of_block_hash genesis.Genesis.block in @@ -3296,7 +3296,7 @@ let may_switch_history_mode ~store_dir ~context_root_dir genesis return_unit else let*! context_index = - Context_ops.init ~kind:`Disk ~readonly:false context_root_dir + Context_ops.init ~kind:`Disk ~readonly:false ~data_dir () in let* store = load_store @@ -3660,7 +3660,7 @@ module Unsafe = struct let load_testchain = Chain.load_testchain - let open_for_snapshot_export ~store_dir ~context_root_dir genesis + let open_for_snapshot_export ~store_dir ~data_dir genesis ~(locked_f : chain_store -> 'a tzresult Lwt.t) = let open Lwt_result_syntax in let store_dir = Naming.store_dir ~dir_path:store_dir in @@ -3694,7 +3694,7 @@ module Unsafe = struct protect (fun () -> let*! context_index = - Context_ops.init ~kind:`Disk ~readonly:true context_root_dir + Context_ops.init ~kind:`Disk ~readonly:true ~data_dir () in let* store = load_store diff --git a/src/lib_store/unix/store.mli b/src/lib_store/unix/store.mli index c7a87c50f5e9..36d117727bff 100644 --- a/src/lib_store/unix/store.mli +++ b/src/lib_store/unix/store.mli @@ -176,17 +176,15 @@ type chain_store (** {3 Initialization} *) (** [init ?patch_context ?commit_genesis ?history_mode ?readonly - ?block_cache_limit ?disable_context_pruning ?maintenance_delay - ~store_dir ~context_root_dir ~allow_testchains genesis] initializes the - store and a main chain store. If [store_dir] (resp. [context_root_dir]) - does not exist, a fresh store (resp. context) is - created. Otherwise, it loads the store (resp. context) from - reading the adequate directory. If [allow_testchains] is passed, - the store will be able to fork chains and instantiate testchain's - sub chain stores, for all chains contained in the store. The chain - store created is based on the [genesis] provided. Its chain - identifier will be computed using the {!Chain_id.of_block_hash} - function. + ?block_cache_limit ?disable_context_pruning ?maintenance_delay ~store_dir + ~data_dir ~allow_testchains genesis] initializes the store and a main chain + store. If [store_dir] (resp. [data_dir]) does not exist, a fresh store + (resp. context) is created. Otherwise, it loads the store (resp. context) + from reading the adequate directory. If [allow_testchains] is passed, the + store will be able to fork chains and instantiate testchain's sub chain + stores, for all chains contained in the store. The chain store created is + based on the [genesis] provided. Its chain identifier will be computed using + the {!Chain_id.of_block_hash} function. @param patch_context the handle called when initializing the context. It usually is passed when creating a sandboxed chain. @@ -232,7 +230,7 @@ val init : ?disable_context_pruning:bool -> ?maintenance_delay:Storage_maintenance.delay -> store_dir:string -> - context_root_dir:string -> + data_dir:string -> allow_testchains:bool -> Genesis.t -> store tzresult Lwt.t @@ -257,12 +255,12 @@ val main_chain_store : store -> chain_store already closed, this function is idempotent. *) val close_store : store -> unit Lwt.t -(** [may_switch_history_mode ?patch_context ~store_dir ~context_root_dir - genesis ~new_history_mode] tries switching the store located at - [store_dir] (if present) to [new_history_mode] when possible. *) +(** [may_switch_history_mode ?patch_context ~store_dir ~data_dir genesis + ~new_history_mode] tries switching the store located at [store_dir] (if + present) to [new_history_mode] when possible. *) val may_switch_history_mode : store_dir:string -> - context_root_dir:string -> + data_dir:string -> Genesis.t -> new_history_mode:History_mode.t -> unit tzresult Lwt.t @@ -1119,19 +1117,19 @@ module Unsafe : sig (** Snapshots utility functions *) - (** [open_for_snapshot_export ~store_dir ~context_root_dir genesis - ~locked_f] opens the store (resp. context) located in [store_dir] - (resp. [context_root_dir]) and gives the [chain_store] whose - [chain_id] is computed using [genesis] and gives it to - [locked_f]. [locked_f] starts by taking a lock (using a lockfile) on - the store to prevent merge from happening during this function. + (** [open_for_snapshot_export ~store_dir ~data_dir genesis ~locked_f] opens + the store (resp. context) located in [store_dir] (resp. [data_dir]) and + gives the [chain_store] whose [chain_id] is computed using [genesis] and + gives it to [locked_f]. [locked_f] starts by taking a lock (using a + lockfile) on the store to prevent merge from happening during this + function. {b Warning} [locked_f] must not perform long computations or costly I/Os: if the store needs to perform a merge, it will be locked while [locked_f] is running. *) val open_for_snapshot_export : store_dir:string -> - context_root_dir:string -> + data_dir:string -> Genesis.t -> locked_f:(chain_store -> 'a tzresult Lwt.t) -> 'a tzresult Lwt.t diff --git a/src/lib_store/unix/test/test_consistency.ml b/src/lib_store/unix/test/test_consistency.ml index 49ac786a0989..854704b51f5d 100644 --- a/src/lib_store/unix/test/test_consistency.ml +++ b/src/lib_store/unix/test/test_consistency.ml @@ -135,7 +135,7 @@ let init_protocols store history_mode = return all_proto_levels let test_protocol_level_consistency_drop_one history_mode nth - (store_dir, context_root_dir) store = + (store_dir, data_dir) store = let open Lwt_result_syntax in assert (nth < 5) ; let* _ = init_protocols store history_mode in @@ -164,7 +164,7 @@ let test_protocol_level_consistency_drop_one history_mode nth ~patch_context:dummy_patch_context ~history_mode ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:true genesis in @@ -221,7 +221,7 @@ let check_protocol_levels_availability chain_store ~expected_protocols return_unit let test_protocol_level_consistency_remove_file history_mode - (store_dir, context_root_dir) store = + (store_dir, data_dir) store = let open Lwt_result_syntax in let* expected_protocols = init_protocols store history_mode in let open Store_types in @@ -244,7 +244,7 @@ let test_protocol_level_consistency_remove_file history_mode ~patch_context:dummy_patch_context ~history_mode ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:true genesis in diff --git a/src/lib_store/unix/test/test_history_mode_switch.ml b/src/lib_store/unix/test/test_history_mode_switch.ml index 0871c16ebb7d..01298613ca7f 100644 --- a/src/lib_store/unix/test/test_history_mode_switch.ml +++ b/src/lib_store/unix/test/test_history_mode_switch.ml @@ -319,8 +319,8 @@ let check_consistency_after_switch descr chain_store ~previous_mode ~target_mode | p, n when History_mode.equal p n -> return_unit | _ -> assert false -let test ~test_descr ~from_hm ~to_hm ~nb_blocks_to_bake - (store_dir, context_root_dir) store ~patch_context = +let test ~test_descr ~from_hm ~to_hm ~nb_blocks_to_bake (store_dir, data_dir) + store ~patch_context = let open Lwt_result_syntax in let chain_store = Store.main_chain_store store in let*! genesis_block = Store.Chain.genesis_block chain_store in @@ -338,7 +338,7 @@ let test ~test_descr ~from_hm ~to_hm ~nb_blocks_to_bake let* () = Store.may_switch_history_mode ~store_dir - ~context_root_dir + ~data_dir genesis ~new_history_mode:to_hm in @@ -365,7 +365,7 @@ let test ~test_descr ~from_hm ~to_hm ~nb_blocks_to_bake ~history_mode:to_hm ~patch_context ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:false genesis in diff --git a/src/lib_store/unix/test/test_locator.ml b/src/lib_store/unix/test/test_locator.ml index 5b318878ae41..06742af46c11 100644 --- a/src/lib_store/unix/test/test_locator.ml +++ b/src/lib_store/unix/test/test_locator.ml @@ -70,11 +70,11 @@ let init_chain ?(history_mode = History_mode.Archive) base_dir = let open Filename.Infix in let open Lwt_syntax in let store_dir = base_dir // "store" in - let context_root_dir = base_dir in + let data_dir = base_dir in let* r = Store.init ~store_dir - ~context_root_dir + ~data_dir ~history_mode ~allow_testchains:true ~patch_context @@ -478,7 +478,7 @@ let test_protocol_locator base_dir = let* () = Store.may_switch_history_mode ~store_dir:(base_dir // "store") - ~context_root_dir:base_dir + ~data_dir:base_dir genesis ~new_history_mode:(Rolling (Some {offset = 0})) in diff --git a/src/lib_store/unix/test/test_reconstruct.ml b/src/lib_store/unix/test/test_reconstruct.ml index b8f4066abd37..9f27d6a47b15 100644 --- a/src/lib_store/unix/test/test_reconstruct.ml +++ b/src/lib_store/unix/test/test_reconstruct.ml @@ -73,8 +73,8 @@ let check_flags descr store expected_head = (snd caboose) ; return_unit -let test_from_bootstrapped ~descr (store_dir, context_root_dir) store - ~nb_blocks_to_bake ~patch_context = +let test_from_bootstrapped ~descr (store_dir, data_dir) store ~nb_blocks_to_bake + ~patch_context = let open Lwt_result_syntax in let chain_store = Store.main_chain_store store in let genesis = Store.Chain.genesis chain_store in @@ -91,7 +91,7 @@ let test_from_bootstrapped ~descr (store_dir, context_root_dir) store Reconstruction.reconstruct ~patch_context ~store_dir - ~context_root_dir + ~data_dir genesis ~user_activated_upgrades:[] ~user_activated_protocol_overrides:[] @@ -130,7 +130,7 @@ let test_from_bootstrapped ~descr (store_dir, context_root_dir) store Store.init ~patch_context ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains:false genesis in @@ -189,8 +189,8 @@ let make_tests_bootstrapped speed patch_context = ~patch_context )) permutations -let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store - ~nb_blocks_to_bake ~patch_context = +let test_from_snapshot ~descr:_ (store_dir, data_dir) store ~nb_blocks_to_bake + ~patch_context = let open Lwt_result_syntax in let chain_store = Store.main_chain_store store in let*! genesis_block = Store.Chain.genesis_block chain_store in @@ -208,7 +208,7 @@ let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store let open Filename.Infix in let dir = store_dir // "imported_store" in let dst_store_dir = dir // "store" in - let dst_context_root_dir = dir in + let dst_data_dir = dir in let* expected_to_fail = Error_monad.protect (fun () -> @@ -221,7 +221,7 @@ let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store ~rolling:false ~block:(`Hash (last_hash, 0)) ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~snapshot_path ~progress_display_mode:Animation.Auto @@ -233,7 +233,7 @@ let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store ~block:last_hash ~snapshot_path ~dst_store_dir - ~dst_context_root_dir + ~dst_data_dir ~chain_name ~configured_history_mode:None ~user_activated_upgrades:[] @@ -246,7 +246,7 @@ let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store Reconstruction.reconstruct ~patch_context ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir genesis ~user_activated_upgrades:[] ~user_activated_protocol_overrides:[] @@ -284,7 +284,7 @@ let test_from_snapshot ~descr:_ (store_dir, context_root_dir) store let* store' = Store.init ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir ~allow_testchains:false genesis in diff --git a/src/lib_store/unix/test/test_snapshots.ml b/src/lib_store/unix/test/test_snapshots.ml index a91f2d70323b..97b761361478 100644 --- a/src/lib_store/unix/test/test_snapshots.ml +++ b/src/lib_store/unix/test/test_snapshots.ml @@ -105,7 +105,7 @@ let check_import_invariants ~test_descr ~rolling return_unit) let export_import ~test_descr ~previously_baked_blocks ?exported_block_hash - ~rolling ~export_mode (store_dir, context_root_dir) chain_store = + ~rolling ~export_mode (store_dir, data_dir) chain_store = let open Lwt_result_syntax in let* () = check_invariants chain_store in let open Filename.Infix in @@ -123,20 +123,20 @@ let export_import ~test_descr ~previously_baked_blocks ?exported_block_hash ~rolling ~block:exported_block ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~progress_display_mode:Animation.Auto genesis in let dir = store_dir // "imported_store" in let dst_store_dir = dir // "store" in - let dst_context_root_dir = dir in + let dst_data_dir = dir in let* () = Snapshots.import ?block:exported_block_hash ~snapshot_path ~dst_store_dir - ~dst_context_root_dir + ~dst_data_dir ~chain_name ~configured_history_mode:None ~user_activated_upgrades:[] @@ -148,7 +148,7 @@ let export_import ~test_descr ~previously_baked_blocks ?exported_block_hash let* store' = Store.init ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir ~allow_testchains:true genesis in @@ -500,7 +500,7 @@ let make_tests_export_import speed genesis_parameters = let test_rolling speed export_mode = let patch_context ctxt = Alpha_utils.default_patch_context ctxt in - let test (store_dir, context_root_dir) store = + let test (store_dir, data_dir) store = let open Lwt_result_syntax in let chain_store = Store.main_chain_store store in let*! genesis_block = Store.Chain.genesis_block chain_store in @@ -518,7 +518,7 @@ let test_rolling speed export_mode = let chain_name = Distributed_db_version.Name.of_string "test" in let dst_dir = store_dir // "imported_store" in let dst_store_dir = dst_dir // "store" in - let dst_context_root_dir = dst_dir in + let dst_data_dir = dst_dir in let* () = Snapshots.export ~snapshot_path @@ -526,7 +526,7 @@ let test_rolling speed export_mode = ~rolling:true ~block:(`Head 0) ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~progress_display_mode:Animation.Auto genesis @@ -535,7 +535,7 @@ let test_rolling speed export_mode = Snapshots.import ~snapshot_path ~dst_store_dir - ~dst_context_root_dir + ~dst_data_dir ~chain_name ~configured_history_mode:None ~user_activated_upgrades:[] @@ -550,7 +550,7 @@ let test_rolling speed export_mode = ~history_mode:History_mode.default_rolling ~readonly:false ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir ~allow_testchains:true genesis in @@ -623,7 +623,7 @@ let test_drag_after_import speed export_mode = ctxt ~json:(Default_parameters.json_of_parameters test_parameters) in - let test (store_dir, context_root_dir) store = + let test (store_dir, data_dir) store = let chain_store = Store.main_chain_store store in let*! genesis_block = Store.Chain.genesis_block chain_store in let nb_cycles_to_bake = 2 in @@ -640,7 +640,7 @@ let test_drag_after_import speed export_mode = let chain_name = Distributed_db_version.Name.of_string "test" in let dst_dir = store_dir // "imported_store" in let dst_store_dir = dst_dir // "store" in - let dst_context_root_dir = dst_dir in + let dst_data_dir = dst_dir in (* export distance is higer than the 120 max_op_tt*) let export_distance = 130 in let* export_block = @@ -657,7 +657,7 @@ let test_drag_after_import speed export_mode = ~rolling:true ~block:(`Hash (export_block_hash, 0)) ~store_dir - ~context_root_dir + ~data_dir ~chain_name ~progress_display_mode:Animation.Auto genesis @@ -666,7 +666,7 @@ let test_drag_after_import speed export_mode = Snapshots.import ~snapshot_path ~dst_store_dir - ~dst_context_root_dir + ~dst_data_dir ~chain_name ~configured_history_mode:None ~user_activated_upgrades:[] @@ -681,7 +681,7 @@ let test_drag_after_import speed export_mode = ~patch_context ~readonly:false ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir ~allow_testchains:true genesis in diff --git a/src/lib_store/unix/test/test_store.ml b/src/lib_store/unix/test/test_store.ml index ace85c0c6489..26b8d38e3a56 100644 --- a/src/lib_store/unix/test/test_store.ml +++ b/src/lib_store/unix/test/test_store.ml @@ -777,13 +777,13 @@ let test_live_blocks store_dir = ~json:(Default_parameters.json_of_parameters test_parameters) in let dst_store_dir = store_dir // "store" in - let dst_context_root_dir = store_dir in + let dst_data_dir = store_dir in let* store = Store.init ~patch_context ~readonly:false ~store_dir:dst_store_dir - ~context_root_dir:dst_context_root_dir + ~data_dir:dst_data_dir ~allow_testchains:false genesis in diff --git a/src/lib_store/unix/test/test_utils.ml b/src/lib_store/unix/test/test_utils.ml index 1bda6662059c..fb8d4c45421a 100644 --- a/src/lib_store/unix/test/test_utils.ml +++ b/src/lib_store/unix/test/test_utils.ml @@ -229,14 +229,14 @@ let wrap_store_init ?(patch_context = dummy_patch_context) let*! r = run (fun base_dir -> let store_dir = base_dir // "store" in - let context_root_dir = base_dir in + let data_dir = base_dir in let* store = Store.init ?block_cache_limit ~patch_context ~history_mode ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains genesis in @@ -252,7 +252,7 @@ let wrap_store_init ?(patch_context = dummy_patch_context) in Lwt.return (Error err)) (fun () -> - let* () = k (store_dir, context_root_dir) store in + let* () = k (store_dir, data_dir) store in Format.printf "Invariants check before closing@." ; let* () = if manual_close then return_unit @@ -265,7 +265,7 @@ let wrap_store_init ?(patch_context = dummy_patch_context) Store.init ~history_mode ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains genesis in @@ -315,13 +315,13 @@ let wrap_simple_store_init ?(patch_context = dummy_patch_context) let*! r = run (fun base_dir -> let store_dir = base_dir // "store" in - let context_root_dir = base_dir in + let data_dir = base_dir in let* store = Store.init ~history_mode ~patch_context ~store_dir - ~context_root_dir + ~data_dir ~allow_testchains ~maintenance_delay:Disabled genesis @@ -335,7 +335,7 @@ let wrap_simple_store_init ?(patch_context = dummy_patch_context) Lwt.return (Error err)) (fun () -> Lwt.finalize - (fun () -> k (store_dir, context_root_dir) store) + (fun () -> k (store_dir, data_dir) store) (fun () -> let*! () = Lwt.catch diff --git a/src/lib_validation/external_validation.ml b/src/lib_validation/external_validation.ml index 435a23f0a7fc..6b9b2f3c640f 100644 --- a/src/lib_validation/external_validation.ml +++ b/src/lib_validation/external_validation.ml @@ -27,7 +27,6 @@ let name = "validator" type parameters = { - context_root_dir : string; protocol_root : string; genesis : Genesis.t; readonly : bool; @@ -148,7 +147,6 @@ let parameters_encoding = let open Data_encoding in conv (fun { - context_root_dir; protocol_root; genesis; readonly; @@ -159,20 +157,19 @@ let parameters_encoding = sandbox_parameters; internal_events; } -> - ( (context_root_dir, protocol_root, genesis, readonly, data_dir), + ( (protocol_root, genesis, readonly, data_dir), ( user_activated_upgrades, user_activated_protocol_overrides, operation_metadata_size_limit, sandbox_parameters, internal_events ) )) - (fun ( (context_root_dir, protocol_root, genesis, readonly, data_dir), + (fun ( (protocol_root, genesis, readonly, data_dir), ( user_activated_upgrades, user_activated_protocol_overrides, operation_metadata_size_limit, sandbox_parameters, internal_events ) ) -> { - context_root_dir; protocol_root; genesis; readonly; @@ -184,8 +181,7 @@ let parameters_encoding = internal_events; }) @@ merge_objs - (obj5 - (req "context_root_dir" string) + (obj4 (req "protocol_root" string) (req "genesis" Genesis.encoding) (req "readonly" bool) diff --git a/src/lib_validation/external_validation.mli b/src/lib_validation/external_validation.mli index af46f602a19b..559872b732ce 100644 --- a/src/lib_validation/external_validation.mli +++ b/src/lib_validation/external_validation.mli @@ -25,7 +25,6 @@ (*****************************************************************************) type parameters = { - context_root_dir : string; protocol_root : string; genesis : Genesis.t; readonly : bool; diff --git a/src/lib_validation/external_validator.ml b/src/lib_validation/external_validator.ml index 83bfeafcad3d..59ab8bc280ac 100644 --- a/src/lib_validation/external_validator.ml +++ b/src/lib_validation/external_validator.ml @@ -90,13 +90,8 @@ module Processing = struct | _ -> Lwt.return r let initial_state - { - External_validation.context_root_dir; - genesis; - readonly; - sandbox_parameters; - _; - } = + ({genesis; readonly; sandbox_parameters; data_dir; _} : + External_validation.parameters) = let open Lwt_result_syntax in let sandbox_parameters = Option.map (fun p -> ("sandbox_parameter", p)) sandbox_parameters @@ -107,7 +102,8 @@ module Processing = struct ~patch_context:(fun ctxt -> Patch_context.patch_context genesis sandbox_parameters ctxt) ~readonly - context_root_dir + ~data_dir + () in let headless = Tezos_profiler.Profiler.instance diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index 8cb1cbd68229..06ac64c56bc0 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -800,7 +800,7 @@ let run_baker in let* () = check_dal_node without_dal dal_node_rpc_ctxt in let* delegates = get_delegates cctxt sources in - let context_path = + let data_dir_path = match baking_mode with | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None -- GitLab From ffaed997e6675dd95107d5995ac4d4d69aa48740 Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Thu, 5 Jun 2025 10:04:17 +0200 Subject: [PATCH 2/4] Proto: fix wrong usage of context_path -- use data_dir instead --- .../lib_delegate/baking_commands.ml | 24 +++++++++---------- .../lib_delegate/baking_configuration.ml | 13 ++++------ .../lib_delegate/baking_configuration.mli | 4 ++-- .../lib_delegate/baking_lib.ml | 8 +++---- .../lib_delegate/baking_lib.mli | 4 ++-- .../lib_delegate/baking_scheduling.ml | 4 ++-- .../lib_delegate/baking_simulator.ml | 6 ++--- .../lib_delegate/baking_simulator.mli | 3 +-- .../lib_delegate/client_daemon.ml | 6 ++--- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/baking_commands.ml | 12 +++++----- .../lib_delegate/baking_configuration.ml | 12 ++++------ .../lib_delegate/baking_configuration.mli | 4 ++-- .../lib_delegate/baking_lib.ml | 8 +++---- .../lib_delegate/baking_lib.mli | 4 ++-- .../lib_delegate/baking_scheduling.ml | 4 ++-- .../lib_delegate/baking_simulator.ml | 4 ++-- .../lib_delegate/baking_simulator.mli | 3 +-- .../lib_delegate/client_daemon.ml | 4 ++-- .../lib_delegate/client_daemon.mli | 2 +- .../lib_delegate/baking_commands.ml | 24 +++++++++---------- .../lib_delegate/baking_configuration.ml | 12 ++++------ .../lib_delegate/baking_configuration.mli | 4 ++-- src/proto_alpha/lib_delegate/baking_lib.ml | 8 +++---- src/proto_alpha/lib_delegate/baking_lib.mli | 4 ++-- .../lib_delegate/baking_scheduling.ml | 4 ++-- .../lib_delegate/baking_simulator.ml | 4 ++-- .../lib_delegate/baking_simulator.mli | 3 +-- src/proto_alpha/lib_delegate/client_daemon.ml | 4 ++-- .../lib_delegate/client_daemon.mli | 2 +- 30 files changed, 94 insertions(+), 106 deletions(-) diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml b/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml index c50621ba586f..3b9623b7208e 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml @@ -185,14 +185,14 @@ let operations_arg = Operations_source.(Local {filename = Uri.to_string uri})) uri_parameter) -let context_root_path_arg = +let data_dir_path_arg = Tezos_clic.arg ~long:"context" ~placeholder:"path" ~doc: - "When specified, the client will read in the local context at the \ - provided path in order to build the block, instead of relying on the \ - 'preapply' RPC." + "When specified, the client will load and read the context located in \ + the local data directory at the provided path, in order to build the \ + block, instead of relying on the 'preapply' RPC." string_parameter let force_apply_from_round_arg = @@ -510,7 +510,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round_arg force_switch operations_arg - context_root_path_arg + data_dir_path_arg adaptive_issuance_vote_arg do_not_monitor_node_mempool_arg endpoint_arg @@ -524,7 +524,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_root_path, + data_dir, adaptive_issuance_vote, do_not_monitor_node_mempool, dal_node_endpoint, @@ -543,7 +543,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ~force ~monitor_node_mempool:(not do_not_monitor_node_mempool) ?extra_operations - ?context_root_path + ?data_dir ?dal_node_endpoint ~count:block_count ?votes: @@ -583,7 +583,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round_arg force_switch operations_arg - context_root_path_arg + data_dir_path_arg state_recorder_switch_arg) (prefixes ["propose"; "for"] @@ sources_param) (fun ( minimal_fees, @@ -593,7 +593,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_root_path, + data_dir, state_recorder ) sources cctxt -> @@ -607,7 +607,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ?force_apply_from_round ~force ?extra_operations - ?context_root_path + ?data_dir ~state_recorder delegates); ] @@ -777,7 +777,7 @@ let run_baker in let* () = check_dal_node without_dal dal_node_rpc_ctxt in let* delegates = get_delegates cctxt sources in - let context_root_path = + let data_dir = match baking_mode with | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None @@ -794,7 +794,7 @@ let run_baker ?force_apply_from_round ?remote_calls_timeout ~chain:cctxt#chain - ?context_root_path + ?data_dir ~keep_alive ~state_recorder delegates diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_configuration.ml b/src/proto_021_PsQuebec/lib_delegate/baking_configuration.ml index c6339a00f9a4..d12210aafa76 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_configuration.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_configuration.ml @@ -68,7 +68,7 @@ type fees_config = { } type validation_config = - | Local of {context_root_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -158,7 +158,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) ?(minimal_nanotez_per_gas_unit = default_fees_config.minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_fees_config.minimal_nanotez_per_byte) - ?(nonce = default_nonce_config) ?context_root_path + ?(nonce = default_nonce_config) ?data_dir ?(retries_on_failure = default_retries_on_failure_config) ?(user_activated_upgrades = default_user_activated_upgrades) ?(votes = default_votes_config) ?force_apply_from_round @@ -170,9 +170,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) {minimal_fees; minimal_nanotez_per_gas_unit; minimal_nanotez_per_byte} in let validation = - match context_root_path with - | None -> Node - | Some context_root_path -> Local {context_root_path} + match data_dir with None -> Node | Some data_dir -> Local {data_dir} in let force_apply_from_round = match force_apply_from_round with @@ -222,9 +220,8 @@ let validation_config_encoding = ~title:"Local" (Tag 0) (obj1 (req "local" string)) - (function - | Local {context_root_path} -> Some context_root_path | _ -> None) - (fun context_root_path -> Local {context_root_path}); + (function Local {data_dir} -> Some data_dir | _ -> None) + (fun data_dir -> Local {data_dir}); case ~title:"Node" (Tag 1) diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_configuration.mli b/src/proto_021_PsQuebec/lib_delegate/baking_configuration.mli index 36ba8d85ac99..5dddeff405ef 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_configuration.mli +++ b/src/proto_021_PsQuebec/lib_delegate/baking_configuration.mli @@ -43,7 +43,7 @@ type fees_config = { } type validation_config = - | Local of {context_root_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -104,7 +104,7 @@ val make : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?nonce:nonce_config -> - ?context_root_path:string -> + ?data_dir:string -> ?retries_on_failure:int -> ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> ?votes:per_block_votes_config -> diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_lib.ml b/src/proto_021_PsQuebec/lib_delegate/baking_lib.ml index 278d12eb560a..658e3e2f5dab 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_lib.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_lib.ml @@ -371,7 +371,7 @@ let attestation_quorum state = let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?(force = false) ?(minimal_timestamp = false) - ?extra_operations ?context_root_path ?state_recorder delegates = + ?extra_operations ?data_dir ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in let cache = Baking_cache.Block_cache.create 10 in @@ -381,7 +381,7 @@ let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_root_path + ?data_dir ?force_apply_from_round ~force ?extra_operations @@ -772,7 +772,7 @@ let rec baking_minimal_timestamp ~count state let bake (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?force ?(minimal_timestamp = false) - ?extra_operations ?(monitor_node_mempool = true) ?context_root_path + ?extra_operations ?(monitor_node_mempool = true) ?data_dir ?dal_node_endpoint ?(count = 1) ?votes ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in @@ -781,7 +781,7 @@ let bake (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_root_path + ?data_dir ?force_apply_from_round ?force ?extra_operations diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_lib.mli b/src/proto_021_PsQuebec/lib_delegate/baking_lib.mli index a160c77dcb22..7383e6ae53ac 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_lib.mli +++ b/src/proto_021_PsQuebec/lib_delegate/baking_lib.mli @@ -37,7 +37,7 @@ val bake : ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> ?monitor_node_mempool:bool -> - ?context_root_path:string -> + ?data_dir:string -> ?dal_node_endpoint:Uri.t -> (* Number of baked blocks. Defaults to 1. *) ?count:int -> @@ -67,7 +67,7 @@ val propose : ?force:bool -> ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> - ?context_root_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> Baking_state.consensus_key list -> unit tzresult Lwt.t diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml b/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml index 378ac43910ba..602359517b7b 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_scheduling.ml @@ -632,8 +632,8 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config Baking_state.( match config.Baking_configuration.validation with | Node -> return Node - | Local {context_root_path} -> - let* index = Baking_simulator.load_context ~context_root_path in + | Local {data_dir} -> + let* index = Baking_simulator.load_context ~data_dir in return (Local index) | ContextIndex index -> return (Local index)) in diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_simulator.ml b/src/proto_021_PsQuebec/lib_delegate/baking_simulator.ml index dab4ef787bda..9dca2076ea91 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_simulator.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_simulator.ml @@ -18,12 +18,10 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -let load_context ~context_root_path = +let load_context ~data_dir = let open Lwt_result_syntax in protect (fun () -> - let*! index = - Context_ops.init ~kind:`Disk ~readonly:true context_root_path - in + let*! index = Context_ops.init ~kind:`Disk ~readonly:true ~data_dir () in return (Abstract_context_index.abstract index)) let check_context_consistency (abstract_index : Abstract_context_index.t) diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_simulator.mli b/src/proto_021_PsQuebec/lib_delegate/baking_simulator.mli index 3ec92592b1e8..83eed0e1ed44 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_simulator.mli +++ b/src/proto_021_PsQuebec/lib_delegate/baking_simulator.mli @@ -34,8 +34,7 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -val load_context : - context_root_path:string -> Abstract_context_index.t tzresult Lwt.t +val load_context : data_dir:string -> Abstract_context_index.t tzresult Lwt.t (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : diff --git a/src/proto_021_PsQuebec/lib_delegate/client_daemon.ml b/src/proto_021_PsQuebec/lib_delegate/client_daemon.ml index 0de8f744b461..1346ac805038 100644 --- a/src/proto_021_PsQuebec/lib_delegate/client_daemon.ml +++ b/src/proto_021_PsQuebec/lib_delegate/client_daemon.ml @@ -68,8 +68,8 @@ module Baker = struct let run (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?votes ?extra_operations ?dal_node_endpoint ?pre_emptive_forge_time - ?force_apply_from_round ?remote_calls_timeout ?context_root_path - ?state_recorder ~chain ~keep_alive delegates = + ?force_apply_from_round ?remote_calls_timeout ?data_dir ?state_recorder + ~chain ~keep_alive delegates = let open Lwt_result_syntax in let process () = let* user_activated_upgrades = @@ -122,7 +122,7 @@ module Baker = struct ~pre_emptive_forge_time ?force_apply_from_round ?remote_calls_timeout - ?context_root_path + ?data_dir ~user_activated_upgrades ?state_recorder () diff --git a/src/proto_021_PsQuebec/lib_delegate/client_daemon.mli b/src/proto_021_PsQuebec/lib_delegate/client_daemon.mli index e2c133dea69a..1967e8785305 100644 --- a/src/proto_021_PsQuebec/lib_delegate/client_daemon.mli +++ b/src/proto_021_PsQuebec/lib_delegate/client_daemon.mli @@ -38,7 +38,7 @@ module Baker : sig ?pre_emptive_forge_time:Q.t -> ?force_apply_from_round:int -> ?remote_calls_timeout:Q.t -> - ?context_root_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> chain:Shell_services.chain -> keep_alive:bool -> diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml b/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml index 46b48fc5c7e3..8132cd2e50a7 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml @@ -534,7 +534,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_path, + data_dir, adaptive_issuance_vote, do_not_monitor_node_mempool, dal_node_endpoint, @@ -557,7 +557,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ~force ~monitor_node_mempool:(not do_not_monitor_node_mempool) ?extra_operations - ?context_path + ?data_dir ~count:block_count ?votes: (Option.map @@ -606,7 +606,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_path, + data_dir, state_recorder ) sources cctxt -> @@ -620,7 +620,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ?force_apply_from_round ~force ?extra_operations - ?context_path + ?data_dir ~state_recorder delegates); ] @@ -790,7 +790,7 @@ let run_baker in let* () = check_dal_node without_dal dal_node_rpc_ctxt in let* delegates = get_delegates cctxt sources in - let context_path = + let data_dir = match baking_mode with | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None @@ -807,7 +807,7 @@ let run_baker ?force_apply_from_round ?remote_calls_timeout ~chain:cctxt#chain - ?context_path + ?data_dir ~keep_alive ~state_recorder delegates diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_configuration.ml b/src/proto_022_PsRiotum/lib_delegate/baking_configuration.ml index 5403393288df..2399e5254bd1 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_configuration.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_configuration.ml @@ -68,7 +68,7 @@ type fees_config = { } type validation_config = - | Local of {context_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -156,7 +156,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) ?(minimal_nanotez_per_gas_unit = default_fees_config.minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_fees_config.minimal_nanotez_per_byte) - ?(nonce = default_nonce_config) ?context_path + ?(nonce = default_nonce_config) ?data_dir ?(retries_on_failure = default_retries_on_failure_config) ?(user_activated_upgrades = default_user_activated_upgrades) ?(votes = default_votes_config) ?force_apply_from_round @@ -167,9 +167,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) {minimal_fees; minimal_nanotez_per_gas_unit; minimal_nanotez_per_byte} in let validation = - match context_path with - | None -> Node - | Some context_path -> Local {context_path} + match data_dir with None -> Node | Some data_dir -> Local {data_dir} in let force_apply_from_round = match force_apply_from_round with @@ -218,8 +216,8 @@ let validation_config_encoding = ~title:"Local" (Tag 0) (obj1 (req "local" string)) - (function Local {context_path} -> Some context_path | _ -> None) - (fun context_path -> Local {context_path}); + (function Local {data_dir} -> Some data_dir | _ -> None) + (fun data_dir -> Local {data_dir}); case ~title:"Node" (Tag 1) diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_configuration.mli b/src/proto_022_PsRiotum/lib_delegate/baking_configuration.mli index bc708e4bea70..608b6984fabe 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_configuration.mli +++ b/src/proto_022_PsRiotum/lib_delegate/baking_configuration.mli @@ -43,7 +43,7 @@ type fees_config = { } type validation_config = - | Local of {context_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -103,7 +103,7 @@ val make : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?nonce:nonce_config -> - ?context_path:string -> + ?data_dir:string -> ?retries_on_failure:int -> ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> ?votes:per_block_votes_config -> diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_lib.ml b/src/proto_022_PsRiotum/lib_delegate/baking_lib.ml index 8c241ee2186d..3b73590ee5de 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_lib.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_lib.ml @@ -365,7 +365,7 @@ let attestation_quorum state = let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?(force = false) ?(minimal_timestamp = false) - ?extra_operations ?context_path ?state_recorder delegates = + ?extra_operations ?data_dir ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in let cache = Baking_cache.Block_cache.create 10 in @@ -375,7 +375,7 @@ let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_path + ?data_dir ?force_apply_from_round ~force ?extra_operations @@ -766,7 +766,7 @@ let rec baking_minimal_timestamp ~count state let bake (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?force ?(minimal_timestamp = false) - ?extra_operations ?(monitor_node_mempool = true) ?context_path ?(count = 1) + ?extra_operations ?(monitor_node_mempool = true) ?data_dir ?(count = 1) ?votes ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in @@ -775,7 +775,7 @@ let bake (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_path + ?data_dir ?force_apply_from_round ?force ?extra_operations diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_lib.mli b/src/proto_022_PsRiotum/lib_delegate/baking_lib.mli index 20e2fd4c72c6..fd79f83651c9 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_lib.mli +++ b/src/proto_022_PsRiotum/lib_delegate/baking_lib.mli @@ -38,7 +38,7 @@ val bake : ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> ?monitor_node_mempool:bool -> - ?context_path:string -> + ?data_dir:string -> (* Number of baked blocks. Defaults to 1. *) ?count:int -> ?votes:Baking_configuration.per_block_votes_config -> @@ -67,7 +67,7 @@ val propose : ?force:bool -> ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> - ?context_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> Baking_state.Consensus_key.t list -> unit tzresult Lwt.t diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_scheduling.ml b/src/proto_022_PsRiotum/lib_delegate/baking_scheduling.ml index f0197c63e07c..6631fcc91b18 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_scheduling.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_scheduling.ml @@ -626,8 +626,8 @@ let create_initial_state cctxt ?dal_node_rpc_ctxt ?(synchronize = true) ~chain Baking_state.( match config.Baking_configuration.validation with | Node -> return Node - | Local {context_path} -> - let* index = Baking_simulator.load_context ~context_path in + | Local {data_dir} -> + let* index = Baking_simulator.load_context ~data_dir in return (Local index) | ContextIndex index -> return (Local index)) in diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_simulator.ml b/src/proto_022_PsRiotum/lib_delegate/baking_simulator.ml index a2e47c559bd2..9dca2076ea91 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_simulator.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_simulator.ml @@ -18,10 +18,10 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -let load_context ~context_path = +let load_context ~data_dir = let open Lwt_result_syntax in protect (fun () -> - let*! index = Context_ops.init ~kind:`Disk ~readonly:true context_path in + let*! index = Context_ops.init ~kind:`Disk ~readonly:true ~data_dir () in return (Abstract_context_index.abstract index)) let check_context_consistency (abstract_index : Abstract_context_index.t) diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_simulator.mli b/src/proto_022_PsRiotum/lib_delegate/baking_simulator.mli index c5155ac45ee0..83eed0e1ed44 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_simulator.mli +++ b/src/proto_022_PsRiotum/lib_delegate/baking_simulator.mli @@ -34,8 +34,7 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -val load_context : - context_path:string -> Abstract_context_index.t tzresult Lwt.t +val load_context : data_dir:string -> Abstract_context_index.t tzresult Lwt.t (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : diff --git a/src/proto_022_PsRiotum/lib_delegate/client_daemon.ml b/src/proto_022_PsRiotum/lib_delegate/client_daemon.ml index 59c1c82c6ced..303899929208 100644 --- a/src/proto_022_PsRiotum/lib_delegate/client_daemon.ml +++ b/src/proto_022_PsRiotum/lib_delegate/client_daemon.ml @@ -68,7 +68,7 @@ module Baker = struct let run (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?votes ?extra_operations ?pre_emptive_forge_time ?force_apply_from_round - ?remote_calls_timeout ?context_path ?state_recorder ~chain ~keep_alive + ?remote_calls_timeout ?data_dir ?state_recorder ~chain ~keep_alive delegates = let open Lwt_result_syntax in let process () = @@ -121,7 +121,7 @@ module Baker = struct ~pre_emptive_forge_time ?force_apply_from_round ?remote_calls_timeout - ?context_path + ?data_dir ~user_activated_upgrades ?state_recorder () diff --git a/src/proto_022_PsRiotum/lib_delegate/client_daemon.mli b/src/proto_022_PsRiotum/lib_delegate/client_daemon.mli index b0073a38c789..3a6e598f4467 100644 --- a/src/proto_022_PsRiotum/lib_delegate/client_daemon.mli +++ b/src/proto_022_PsRiotum/lib_delegate/client_daemon.mli @@ -38,7 +38,7 @@ module Baker : sig ?pre_emptive_forge_time:Q.t -> ?force_apply_from_round:int -> ?remote_calls_timeout:Q.t -> - ?context_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> chain:Shell_services.chain -> keep_alive:bool -> diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index 06ac64c56bc0..4b04665207da 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -185,14 +185,14 @@ let operations_arg = Operations_source.(Local {filename = Uri.to_string uri})) uri_parameter) -let context_path_arg = +let data_dir_path_arg = Tezos_clic.arg ~long:"context" ~placeholder:"path" ~doc: - "When specified, the client will read in the local context at the \ - provided path in order to build the block, instead of relying on the \ - 'preapply' RPC." + "When specified, the client will load and read the context located in \ + the local data directory at the provided path, in order to build the \ + block, instead of relying on the 'preapply' RPC." string_parameter let force_apply_from_round_arg = @@ -520,7 +520,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round_arg force_switch operations_arg - context_path_arg + data_dir_path_arg adaptive_issuance_vote_arg do_not_monitor_node_mempool_arg dal_node_endpoint_arg @@ -534,7 +534,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_path, + data_dir, adaptive_issuance_vote, do_not_monitor_node_mempool, dal_node_endpoint, @@ -557,7 +557,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ~force ~monitor_node_mempool:(not do_not_monitor_node_mempool) ?extra_operations - ?context_path + ?data_dir ~count:block_count ?votes: (Option.map @@ -596,7 +596,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round_arg force_switch operations_arg - context_path_arg + data_dir_path_arg state_recorder_switch_arg) (prefixes ["propose"; "for"] @@ sources_param) (fun ( minimal_fees, @@ -606,7 +606,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list force_apply_from_round, force, extra_operations, - context_path, + data_dir, state_recorder ) sources cctxt -> @@ -620,7 +620,7 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list ?force_apply_from_round ~force ?extra_operations - ?context_path + ?data_dir ~state_recorder delegates); ] @@ -800,7 +800,7 @@ let run_baker in let* () = check_dal_node without_dal dal_node_rpc_ctxt in let* delegates = get_delegates cctxt sources in - let data_dir_path = + let data_dir = match baking_mode with | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None @@ -817,7 +817,7 @@ let run_baker ?force_apply_from_round ?remote_calls_timeout ~chain:cctxt#chain - ?context_path + ?data_dir ~keep_alive ~state_recorder delegates diff --git a/src/proto_alpha/lib_delegate/baking_configuration.ml b/src/proto_alpha/lib_delegate/baking_configuration.ml index 5403393288df..2399e5254bd1 100644 --- a/src/proto_alpha/lib_delegate/baking_configuration.ml +++ b/src/proto_alpha/lib_delegate/baking_configuration.ml @@ -68,7 +68,7 @@ type fees_config = { } type validation_config = - | Local of {context_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -156,7 +156,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) ?(minimal_nanotez_per_gas_unit = default_fees_config.minimal_nanotez_per_gas_unit) ?(minimal_nanotez_per_byte = default_fees_config.minimal_nanotez_per_byte) - ?(nonce = default_nonce_config) ?context_path + ?(nonce = default_nonce_config) ?data_dir ?(retries_on_failure = default_retries_on_failure_config) ?(user_activated_upgrades = default_user_activated_upgrades) ?(votes = default_votes_config) ?force_apply_from_round @@ -167,9 +167,7 @@ let make ?(minimal_fees = default_fees_config.minimal_fees) {minimal_fees; minimal_nanotez_per_gas_unit; minimal_nanotez_per_byte} in let validation = - match context_path with - | None -> Node - | Some context_path -> Local {context_path} + match data_dir with None -> Node | Some data_dir -> Local {data_dir} in let force_apply_from_round = match force_apply_from_round with @@ -218,8 +216,8 @@ let validation_config_encoding = ~title:"Local" (Tag 0) (obj1 (req "local" string)) - (function Local {context_path} -> Some context_path | _ -> None) - (fun context_path -> Local {context_path}); + (function Local {data_dir} -> Some data_dir | _ -> None) + (fun data_dir -> Local {data_dir}); case ~title:"Node" (Tag 1) diff --git a/src/proto_alpha/lib_delegate/baking_configuration.mli b/src/proto_alpha/lib_delegate/baking_configuration.mli index bc708e4bea70..608b6984fabe 100644 --- a/src/proto_alpha/lib_delegate/baking_configuration.mli +++ b/src/proto_alpha/lib_delegate/baking_configuration.mli @@ -43,7 +43,7 @@ type fees_config = { } type validation_config = - | Local of {context_path : string} + | Local of {data_dir : string} | Node | ContextIndex of Abstract_context_index.t @@ -103,7 +103,7 @@ val make : ?minimal_nanotez_per_gas_unit:Q.t -> ?minimal_nanotez_per_byte:Q.t -> ?nonce:nonce_config -> - ?context_path:string -> + ?data_dir:string -> ?retries_on_failure:int -> ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> ?votes:per_block_votes_config -> diff --git a/src/proto_alpha/lib_delegate/baking_lib.ml b/src/proto_alpha/lib_delegate/baking_lib.ml index 8c241ee2186d..3b73590ee5de 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.ml +++ b/src/proto_alpha/lib_delegate/baking_lib.ml @@ -365,7 +365,7 @@ let attestation_quorum state = let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?(force = false) ?(minimal_timestamp = false) - ?extra_operations ?context_path ?state_recorder delegates = + ?extra_operations ?data_dir ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in let cache = Baking_cache.Block_cache.create 10 in @@ -375,7 +375,7 @@ let propose (cctxt : Protocol_client_context.full) ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_path + ?data_dir ?force_apply_from_round ~force ?extra_operations @@ -766,7 +766,7 @@ let rec baking_minimal_timestamp ~count state let bake (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?force_apply_from_round ?force ?(minimal_timestamp = false) - ?extra_operations ?(monitor_node_mempool = true) ?context_path ?(count = 1) + ?extra_operations ?(monitor_node_mempool = true) ?data_dir ?(count = 1) ?votes ?state_recorder delegates = let open Lwt_result_syntax in let*! () = Events.(emit Baking_events.Delegates.delegates_used delegates) in @@ -775,7 +775,7 @@ let bake (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte - ?context_path + ?data_dir ?force_apply_from_round ?force ?extra_operations diff --git a/src/proto_alpha/lib_delegate/baking_lib.mli b/src/proto_alpha/lib_delegate/baking_lib.mli index 20e2fd4c72c6..fd79f83651c9 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.mli +++ b/src/proto_alpha/lib_delegate/baking_lib.mli @@ -38,7 +38,7 @@ val bake : ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> ?monitor_node_mempool:bool -> - ?context_path:string -> + ?data_dir:string -> (* Number of baked blocks. Defaults to 1. *) ?count:int -> ?votes:Baking_configuration.per_block_votes_config -> @@ -67,7 +67,7 @@ val propose : ?force:bool -> ?minimal_timestamp:bool -> ?extra_operations:Baking_configuration.Operations_source.t -> - ?context_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> Baking_state.Consensus_key.t list -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/baking_scheduling.ml b/src/proto_alpha/lib_delegate/baking_scheduling.ml index f0197c63e07c..6631fcc91b18 100644 --- a/src/proto_alpha/lib_delegate/baking_scheduling.ml +++ b/src/proto_alpha/lib_delegate/baking_scheduling.ml @@ -626,8 +626,8 @@ let create_initial_state cctxt ?dal_node_rpc_ctxt ?(synchronize = true) ~chain Baking_state.( match config.Baking_configuration.validation with | Node -> return Node - | Local {context_path} -> - let* index = Baking_simulator.load_context ~context_path in + | Local {data_dir} -> + let* index = Baking_simulator.load_context ~data_dir in return (Local index) | ContextIndex index -> return (Local index)) in diff --git a/src/proto_alpha/lib_delegate/baking_simulator.ml b/src/proto_alpha/lib_delegate/baking_simulator.ml index a2e47c559bd2..9dca2076ea91 100644 --- a/src/proto_alpha/lib_delegate/baking_simulator.ml +++ b/src/proto_alpha/lib_delegate/baking_simulator.ml @@ -18,10 +18,10 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -let load_context ~context_path = +let load_context ~data_dir = let open Lwt_result_syntax in protect (fun () -> - let*! index = Context_ops.init ~kind:`Disk ~readonly:true context_path in + let*! index = Context_ops.init ~kind:`Disk ~readonly:true ~data_dir () in return (Abstract_context_index.abstract index)) let check_context_consistency (abstract_index : Abstract_context_index.t) diff --git a/src/proto_alpha/lib_delegate/baking_simulator.mli b/src/proto_alpha/lib_delegate/baking_simulator.mli index c5155ac45ee0..83eed0e1ed44 100644 --- a/src/proto_alpha/lib_delegate/baking_simulator.mli +++ b/src/proto_alpha/lib_delegate/baking_simulator.mli @@ -34,8 +34,7 @@ type incremental = { header : Tezos_base.Block_header.shell_header; } -val load_context : - context_path:string -> Abstract_context_index.t tzresult Lwt.t +val load_context : data_dir:string -> Abstract_context_index.t tzresult Lwt.t (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index 59c1c82c6ced..303899929208 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -68,7 +68,7 @@ module Baker = struct let run (cctxt : Protocol_client_context.full) ?dal_node_rpc_ctxt ?minimal_fees ?minimal_nanotez_per_gas_unit ?minimal_nanotez_per_byte ?votes ?extra_operations ?pre_emptive_forge_time ?force_apply_from_round - ?remote_calls_timeout ?context_path ?state_recorder ~chain ~keep_alive + ?remote_calls_timeout ?data_dir ?state_recorder ~chain ~keep_alive delegates = let open Lwt_result_syntax in let process () = @@ -121,7 +121,7 @@ module Baker = struct ~pre_emptive_forge_time ?force_apply_from_round ?remote_calls_timeout - ?context_path + ?data_dir ~user_activated_upgrades ?state_recorder () diff --git a/src/proto_alpha/lib_delegate/client_daemon.mli b/src/proto_alpha/lib_delegate/client_daemon.mli index b0073a38c789..3a6e598f4467 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.mli +++ b/src/proto_alpha/lib_delegate/client_daemon.mli @@ -38,7 +38,7 @@ module Baker : sig ?pre_emptive_forge_time:Q.t -> ?force_apply_from_round:int -> ?remote_calls_timeout:Q.t -> - ?context_path:string -> + ?data_dir:string -> ?state_recorder:Baking_configuration.state_recorder_config -> chain:Shell_services.chain -> keep_alive:bool -> -- GitLab From 15c1dac55d3b04d39ba86f0874bae4b0a27bbef3 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Tue, 27 May 2025 11:57:51 +0200 Subject: [PATCH 3/4] Snapshot: improve snapshot import progress UX --- src/lib_store/unix/snapshots.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_store/unix/snapshots.ml b/src/lib_store/unix/snapshots.ml index cda624439e74..eea031e7e4dd 100644 --- a/src/lib_store/unix/snapshots.ml +++ b/src/lib_store/unix/snapshots.ml @@ -3988,8 +3988,8 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct @@ fun () -> let*! () = Context_ops.integrity_check - ?ppf:None - ~root:(Tezos_context_ops.Context_ops.context_dir dst_data_dir) + ~ppf:Format.std_formatter + ~root:dst_data_dir ~auto_repair:false ~always:false ~heads:(Some [Context_hash.to_b58check imported_context_hash]) -- GitLab From 3a8e423b07daad1e38322b8749515d0b646ec9ad Mon Sep 17 00:00:00 2001 From: Victor Allombert Date: Tue, 27 May 2025 16:01:16 +0200 Subject: [PATCH 4/4] Store/snapshot: improve error at snapshot import --- src/lib_store/unix/snapshots.ml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/lib_store/unix/snapshots.ml b/src/lib_store/unix/snapshots.ml index eea031e7e4dd..baaffd481a85 100644 --- a/src/lib_store/unix/snapshots.ml +++ b/src/lib_store/unix/snapshots.ml @@ -91,6 +91,7 @@ type error += | Inconsistent_imported_block of Block_hash.t * Block_hash.t | Invalid_chain_store_export of Chain_id.t * string | Cannot_export_snapshot_format + | Cannot_checkout_imported_context of Context_hash.t let () = let open Data_encoding in @@ -592,7 +593,22 @@ let () = exports. ") unit (function Cannot_export_snapshot_format -> Some () | _ -> None) - (fun () -> Cannot_export_snapshot_format) + (fun () -> Cannot_export_snapshot_format) ; + register_error_kind + `Permanent + ~id:"Snapshot.cannot_checkout_imported_context" + ~title:"Cannot checkout imported context" + ~description:"Cannot checkout imported context" + ~pp:(fun ppf h -> + Format.fprintf + ppf + "Cannot checkout imported context %a. The imported data directory is \ + incorrect." + Context_hash.pp + h) + (obj1 (req "context_hash" Context_hash.encoding)) + (function Cannot_checkout_imported_context h -> Some h | _ -> None) + (fun h -> Cannot_checkout_imported_context h) (* This module handles snapshot's versioning system. *) module Version = struct @@ -3980,6 +3996,17 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct ~time:genesis.Genesis.time ~protocol:genesis.protocol in + let* () = + (* As Irmin's integrity check is not actively checking that the + requested context hash is well stored, we do it manually. *) + let*! ctxt_opt = + Context_ops.checkout context_index imported_context_hash + in + match ctxt_opt with + | Some (_ : Context_ops.t) -> return_unit + | None -> + tzfail (Cannot_checkout_imported_context imported_context_hash) + in let* () = if check_consistency then Animation.three_dots -- GitLab