diff --git a/devtools/get_contracts/sigs.ml b/devtools/get_contracts/sigs.ml index 20251cbea0b8567b9ca9b949fc0bb6badc7f6601..5d2640a51128b94465e6b17c01110450d217a8c3 100644 --- a/devtools/get_contracts/sigs.ml +++ b/devtools/get_contracts/sigs.ml @@ -28,7 +28,7 @@ module Time = Time.Protocol module type MAIN = sig val main : output_dir:string -> - Environment_context.Context.t -> + Tezos_protocol_environment.Context.t -> head:Tezos_store.Store.Block.t -> unit tzresult Lwt.t end @@ -41,7 +41,7 @@ module type PROTOCOL = sig level:Int32.t -> predecessor_timestamp:Time.t -> timestamp:Time.t -> - Environment_context.Context.t -> + Tezos_protocol_environment.Context.t -> t tzresult Lwt.t end diff --git a/manifest/main.ml b/manifest/main.ml index a76913efbe321ad2b795fd032a9d3e15fb4e07d0..c8950f83fe4f446f45a0a53cf808c3c2027a0e22 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1829,35 +1829,11 @@ protocols.|} octez_scoru_wasm; octez_event_logging; ] - ~wrapped:false - ~modules: - [ - "Tezos_protocol_environment"; - "Environment_V0"; - "Environment_V1"; - "Environment_V2"; - "Environment_V3"; - "Environment_V4"; - "Environment_V5"; - "Environment_V6"; - "Environment_cache"; - "Environment_context"; - "Environment_context_intf"; - "Environment_protocol_T"; - "Environment_protocol_T_V0"; - "Environment_protocol_T_V3"; - "Environment_protocol_T_V6"; - "Environment_protocol_T_test"; - "Dummy_context"; - "Memory_context"; - "Proxy_context"; - "Proxy_delegate"; - ] let octez_shell_context = public_lib "tezos-shell-context" - ~path:"src/lib_protocol_environment" + ~path:"src/lib_protocol_environment/shell_context" ~synopsis: "Tezos: economic-protocols environment implementation for `tezos-node`" ~deps: @@ -1866,7 +1842,6 @@ let octez_shell_context = octez_protocol_environment; octez_context; ] - ~modules:["Proxy_delegate_maker"; "Shell_context"] let _octez_protocol_environment_tests = tests @@ -1887,7 +1862,7 @@ let _octez_protocol_environment_tests = let octez_context_ops = public_lib "tezos-context-ops" - ~path:"src/lib_protocol_environment" + ~path:"src/lib_protocol_environment/context_ops" ~synopsis:"Tezos: backend-agnostic operations on contexts" ~deps: [ @@ -1897,7 +1872,6 @@ let octez_context_ops = octez_context |> open_; octez_shell_context |> open_; ] - ~modules:["Context_ops"] let _octez_protocol_shell_context_tests = tests diff --git a/manifest/manifest.ml b/manifest/manifest.ml index 7c1dc22546b90f45618ff9ecef82bbf783a8dc44..838d6d31f2527156467e45065c0eafa0e2a611a2 100644 --- a/manifest/manifest.ml +++ b/manifest/manifest.ml @@ -184,9 +184,9 @@ module Dune = struct ?library_flags ?link_flags ?(inline_tests = false) ?(preprocess = Stdlib.List.[]) ?(preprocessor_deps = Stdlib.List.[]) ?(virtual_modules = Stdlib.List.[]) ?default_implementation ?implements - ?(wrapped = true) ?modules ?modules_without_implementation ?modes - ?foreign_stubs ?c_library_flags ?(private_modules = Stdlib.List.[]) - ?js_of_ocaml (names : string list) = + ?modules ?modules_without_implementation ?modes ?foreign_stubs + ?c_library_flags ?(private_modules = Stdlib.List.[]) ?js_of_ocaml + (names : string list) = [ V [ @@ -249,7 +249,6 @@ module Dune = struct opt library_flags (fun x -> [S "library_flags"; x]); opt link_flags (fun l -> [V (of_list (List.cons (S "link_flags") l))]); opt flags (fun l -> [V (of_list (List.cons (S "flags") l))]); - (if not wrapped then [S "wrapped"; S "false"] else E); (match virtual_modules with | [] -> E | _ -> S "virtual_modules" :: of_atom_list virtual_modules); @@ -929,7 +928,6 @@ module Target = struct description : string option; virtual_modules : string list; default_implementation : string option; - wrapped : bool; npm_deps : Npm.t list; cram : bool; license : string option; @@ -1097,7 +1095,6 @@ module Target = struct But that would be more complex to implement. *) ?default_implementation:string -> - ?wrapped:bool -> ?cram:bool -> ?license:string -> ?extra_authors:string list -> @@ -1146,8 +1143,8 @@ module Target = struct ?opam ?(opam_with_test = Always) ?(preprocess = []) ?(preprocessor_deps = []) ?(private_modules = []) ?(opam_only_deps = []) ?release ?static ?synopsis ?description ?(time_measurement_ppx = false) - ?(virtual_modules = []) ?default_implementation ?(wrapped = true) - ?(cram = false) ?license ?(extra_authors = []) ~path names = + ?(virtual_modules = []) ?default_implementation ?(cram = false) ?license + ?(extra_authors = []) ~path names = let conflicts = List.filter_map Fun.id conflicts in let deps = List.filter_map Fun.id deps in let opam_only_deps = List.filter_map Fun.id opam_only_deps in @@ -1453,7 +1450,6 @@ module Target = struct npm_deps; virtual_modules; default_implementation; - wrapped; cram; license; extra_authors; @@ -1951,7 +1947,6 @@ let generate_dune (internal : Target.internal) = ~virtual_modules:internal.virtual_modules ?default_implementation:internal.default_implementation ?implements:(Option.map get_virtual_target_name internal.implements) - ~wrapped:internal.wrapped ?modules ?modules_without_implementation ?modes:internal.modes diff --git a/manifest/manifest.mli b/manifest/manifest.mli index b477d0dedb9299ff8416796d570151c2567425d1..b204c471e86083cf8ef0d5adf2289858accf98d1 100644 --- a/manifest/manifest.mli +++ b/manifest/manifest.mli @@ -630,10 +630,6 @@ type with_test = Always | Never | Only_on_64_arch The user should give the name of e.g. the public library that serves as default implementation. - - [wrapped]: if [false], add the [(wrapped false)] stanza in the [dune] file. - This causes the library to not come with a toplevel module with aliases to - all other modules. Not recommended (according to the dune documentation). - - [license]: specific license to use for that target. If omitted it will default to MIT. @@ -673,7 +669,6 @@ type 'a maker = ?time_measurement_ppx:bool -> ?virtual_modules:string list -> ?default_implementation:string -> - ?wrapped:bool -> ?cram:bool -> ?license:string -> ?extra_authors:string list -> diff --git a/src/bin_validation/validator.ml b/src/bin_validation/validator.ml index e924464ed10a77344a785e7d2c8e20574f4f6365..da9070f3ed8f7d7b9880becd9c64b896d8165c8c 100644 --- a/src/bin_validation/validator.ml +++ b/src/bin_validation/validator.ml @@ -202,7 +202,7 @@ let run input output = operation_metadata_size_limit ) = init input in - let rec loop (cache : Environment_context.Context.block_cache option) + let rec loop (cache : Tezos_protocol_environment.Context.block_cache option) cached_result = let*! recved = External_validation.recv input External_validation.request_encoding diff --git a/src/lib_mockup/test/test_persistence.ml b/src/lib_mockup/test/test_persistence.ml index 5dd100b0256721fa1af85f2cf938b74d9a099c7c..7991519f81efd9c7ec4017ca9651d88d0c157dbf 100644 --- a/src/lib_mockup/test/test_persistence.ml +++ b/src/lib_mockup/test/test_persistence.ml @@ -88,7 +88,8 @@ let test_classify_is_empty = check_base_dir "An empty directory" Base_dir_is_empty bd)) module Mock_protocol : Registration.PROTOCOL = struct - include Environment_protocol_T_test.Internal_for_tests.Mock_all_unit + open Tezos_protocol_environment.Internal_for_tests + include Environment_protocol_T_test.Mock_all_unit let hash = Protocol_hash.hash_string [""] end diff --git a/src/lib_protocol_environment/context_ops.ml b/src/lib_protocol_environment/context_ops/context_ops.ml similarity index 72% rename from src/lib_protocol_environment/context_ops.ml rename to src/lib_protocol_environment/context_ops/context_ops.ml index a65d2064a920c9d2b17389d59b105f846fc07024..ecc0b30ff280983b76015bc7521b450bfe11892c 100644 --- a/src/lib_protocol_environment/context_ops.ml +++ b/src/lib_protocol_environment/context_ops/context_ops.ml @@ -23,19 +23,22 @@ (* *) (*****************************************************************************) +module Environment_context = Tezos_protocol_environment.Context +module Memory_context = Tezos_protocol_environment.Memory_context + +let err_implementation_mismatch = + Tezos_protocol_environment.err_implementation_mismatch (* Backend-agnostic operations on the context *) -let mem (context : Environment_context.Context.t) key = +let mem (context : Environment_context.t) key = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.mem ctxt key | Context {kind = Memory_context.Context; ctxt; _} -> Tezos_context_memory.Context.mem ctxt key | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let add_protocol (context : Environment_context.Context.t) proto_hash = +let add_protocol (context : Environment_context.t) proto_hash = let open Lwt_syntax in match context with | Context {kind = Shell_context.Context; ctxt; _} -> @@ -45,22 +48,17 @@ let add_protocol (context : Environment_context.Context.t) proto_hash = let+ ctxt = Tezos_context_memory.Context.add_protocol ctxt proto_hash in Memory_context.wrap_memory_context ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let get_protocol (context : Environment_context.Context.t) = +let get_protocol (context : Environment_context.t) = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.get_protocol ctxt | Context {kind = Memory_context.Context; ctxt; _} -> Tezos_context_memory.Context.get_protocol ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let add_predecessor_block_metadata_hash - (context : Environment_context.Context.t) hash = +let add_predecessor_block_metadata_hash (context : Environment_context.t) hash = let open Lwt_syntax in match context with | Context {kind = Shell_context.Context; ctxt; _} -> @@ -74,12 +72,9 @@ let add_predecessor_block_metadata_hash in Memory_context.wrap_memory_context ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let add_predecessor_ops_metadata_hash (context : Environment_context.Context.t) - hash = +let add_predecessor_ops_metadata_hash (context : Environment_context.t) hash = let open Lwt_syntax in match context with | Context {kind = Shell_context.Context; ctxt; _} -> @@ -91,33 +86,27 @@ let add_predecessor_ops_metadata_hash (context : Environment_context.Context.t) in Memory_context.wrap_memory_context ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let hash ~time ?message (context : Environment_context.Context.t) = +let hash ~time ?message (context : Environment_context.t) = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.hash ~time ?message ctxt | Context {kind = Memory_context.Context; ctxt; _} -> Tezos_context_memory.Context.hash ~time ?message ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let get_test_chain (context : Environment_context.Context.t) = +let get_test_chain (context : Environment_context.t) = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.get_test_chain ctxt | Context {kind = Memory_context.Context; _} -> Lwt.return Test_chain_status.Not_running | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let add_test_chain (context : Environment_context.Context.t) status = +let add_test_chain (context : Environment_context.t) status = let open Lwt_syntax in match context with | Context {kind = Shell_context.Context; ctxt; _} -> @@ -127,41 +116,31 @@ let add_test_chain (context : Environment_context.Context.t) status = let+ ctxt = Tezos_context_memory.Context.add_test_chain ctxt status in Memory_context.wrap_memory_context ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let commit ~time ?message (context : Environment_context.Context.t) = +let commit ~time ?message (context : Environment_context.t) = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.commit ~time ?message ctxt | Context {kind = Memory_context.Context; ctxt; _} -> Tezos_context_memory.Context.commit ~time ?message ctxt | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let commit_test_chain_genesis (context : Environment_context.Context.t) - block_header = +let commit_test_chain_genesis (context : Environment_context.t) block_header = match context with | Context {kind = Shell_context.Context; ctxt; _} -> Context.commit_test_chain_genesis ctxt block_header | Context {kind = Memory_context.Context; ctxt; _} -> Tezos_context_memory.Context.commit_test_chain_genesis ctxt block_header | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name -let compute_testchain_genesis (context : Environment_context.Context.t) - block_hash = +let compute_testchain_genesis (context : Environment_context.t) block_hash = match context with | Context {kind = Shell_context.Context; _} -> Context.compute_testchain_genesis block_hash | Context {kind = Memory_context.Context; _} -> Tezos_context_memory.Context.compute_testchain_genesis block_hash | Context t -> - Environment_context.err_implementation_mismatch - ~expected:"shell or memory" - ~got:t.impl_name + err_implementation_mismatch ~expected:"shell or memory" ~got:t.impl_name diff --git a/src/lib_protocol_environment/context_ops/dune b/src/lib_protocol_environment/context_ops/dune new file mode 100644 index 0000000000000000000000000000000000000000..8a1e5b7a7320da283d880a0fc7c21b18705a5b8e --- /dev/null +++ b/src/lib_protocol_environment/context_ops/dune @@ -0,0 +1,19 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_context_ops) + (public_name tezos-context-ops) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezos-error-monad + tezos-protocol-environment + tezos-context + tezos-shell-context) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_error_monad + -open Tezos_context + -open Tezos_shell_context)) diff --git a/src/lib_protocol_environment/dummy_context.ml b/src/lib_protocol_environment/dummy_context.ml deleted file mode 100644 index f4d38d04b099bff9465d8c0b42b2c3adc4e8ecaf..0000000000000000000000000000000000000000 --- a/src/lib_protocol_environment/dummy_context.ml +++ /dev/null @@ -1,103 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -module M = struct - type t = unit - - type key = string list - - type value = Bytes.t - - type tree = | - - module Tree = struct - let pp _ _ = assert false - - let hash _ = assert false - - let empty _ = assert false - - let equal _ _ = assert false - - let is_empty _ = assert false - - let mem _ _ = assert false - - let kind _ = assert false - - let to_value _ = assert false - - let of_value _ _ = assert false - - let find _ _ = assert false - - let add _ _ _ = assert false - - let remove _ _ = assert false - - let mem_tree _ _ = assert false - - let find_tree _ _ = assert false - - let add_tree _ _ = assert false - - let clear ?depth:_ _ = assert false - - let list _ ?offset:_ ?length:_ _ = assert false - - let length _ _ = assert false - - let fold ?depth:_ _ _ ~order:_ ~init:_ ~f:_ = assert false - - let config _ = assert false - end - - include Tree - module Proof = Memory_context.M.Proof - - let set_protocol _ _ = assert false - - let get_protocol _ = assert false - - let fork_test_chain _ ~protocol:_ ~expiration:_ = assert false - - let set_hash_version _ _ = assert false - - let get_hash_version _ = assert false - - let verify_tree_proof _ _ = assert false - - let verify_stream_proof _ _ = assert false - - let equal_config _ _ = assert false - - let config _ = assert false -end - -open Tezos_protocol_environment -include Environment_context.Register (M) - -let empty = - Context.make ~ops ~ctxt:() ~kind:Context ~equality_witness ~impl_name:"dummy" diff --git a/src/lib_protocol_environment/dummy_context.mli b/src/lib_protocol_environment/dummy_context.mli deleted file mode 100644 index cba098afe6f9ff16dadc6988bfc730772db6b907..0000000000000000000000000000000000000000 --- a/src/lib_protocol_environment/dummy_context.mli +++ /dev/null @@ -1,30 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) -(* *) -(* Permission is hereby granted, free of charge, to any person obtaining a *) -(* copy of this software and associated documentation files (the "Software"),*) -(* to deal in the Software without restriction, including without limitation *) -(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) -(* and/or sell copies of the Software, and to permit persons to whom the *) -(* Software is furnished to do so, subject to the following conditions: *) -(* *) -(* The above copyright notice and this permission notice shall be included *) -(* in all copies or substantial portions of the Software. *) -(* *) -(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) -(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) -(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) -(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) -(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) -(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) -(* DEALINGS IN THE SOFTWARE. *) -(* *) -(*****************************************************************************) - -open Tezos_protocol_environment - -type _ Context.kind += Context : unit Context.kind - -val empty : Context.t diff --git a/src/lib_protocol_environment/dune b/src/lib_protocol_environment/dune index 188734a9fc291daaa155e21b6912e31ccd73f4d2..8f30295b46a24559d5a9acb7b3b03cbd057ca777 100644 --- a/src/lib_protocol_environment/dune +++ b/src/lib_protocol_environment/dune @@ -24,57 +24,4 @@ (flags (:standard) -open Tezos_base.TzPervasives - -open Tezos_micheline) - (wrapped false) - (modules - Tezos_protocol_environment - Environment_V0 - Environment_V1 - Environment_V2 - Environment_V3 - Environment_V4 - Environment_V5 - Environment_V6 - Environment_cache - Environment_context - Environment_context_intf - Environment_protocol_T - Environment_protocol_T_V0 - Environment_protocol_T_V3 - Environment_protocol_T_V6 - Environment_protocol_T_test - Dummy_context - Memory_context - Proxy_context - Proxy_delegate)) - -(library - (name tezos_shell_context) - (public_name tezos-shell-context) - (instrumentation (backend bisect_ppx)) - (libraries - tezos-base - tezos-protocol-environment - tezos-context) - (flags - (:standard) - -open Tezos_base.TzPervasives) - (modules Proxy_delegate_maker Shell_context)) - -(library - (name tezos_context_ops) - (public_name tezos-context-ops) - (instrumentation (backend bisect_ppx)) - (libraries - tezos-base - tezos-error-monad - tezos-protocol-environment - tezos-context - tezos-shell-context) - (flags - (:standard) - -open Tezos_base.TzPervasives - -open Tezos_error_monad - -open Tezos_context - -open Tezos_shell_context) - (modules Context_ops)) + -open Tezos_micheline)) diff --git a/src/lib_protocol_environment/environment_protocol_T_test.ml b/src/lib_protocol_environment/environment_protocol_T_test.ml index 95d39461036e579ab5c79d50b195c264eea8800b..750b6b8978fece37300722bd99e8abb79c72f085 100644 --- a/src/lib_protocol_environment/environment_protocol_T_test.ml +++ b/src/lib_protocol_environment/environment_protocol_T_test.ml @@ -23,88 +23,85 @@ (* *) (*****************************************************************************) -module Internal_for_tests = struct - (** An implementation of {!Tezos_protocol_environment.PROTOCOL} used +(** An implementation of {!Tezos_protocol_environment.PROTOCOL} used in tests. It sets all types to [unit] and implement all functions as [assert false]. Users of this module should [include] it and override the functions they need. *) - module Mock_all_unit : - Tezos_protocol_environment.PROTOCOL - with type block_header_data = unit - and type operation_data = unit - and type operation_receipt = unit - and type validation_state = unit = struct - type nonrec validation_state = unit +module Mock_all_unit : + Environment_protocol_T.PROTOCOL + with type block_header_data = unit + and type operation_data = unit + and type operation_receipt = unit + and type validation_state = unit = struct + type nonrec validation_state = unit - type block_header_data = unit + type block_header_data = unit - type operation = { - shell : Tezos_base.Operation.shell_header; - protocol_data : block_header_data; - } + type operation = { + shell : Tezos_base.Operation.shell_header; + protocol_data : block_header_data; + } - type operation_receipt = unit + type operation_receipt = unit - type operation_data = unit + type operation_data = unit - type block_header_metadata = unit + type block_header_metadata = unit - type block_header = { - shell : Tezos_base.Block_header.shell_header; - protocol_data : block_header_data; - } + type block_header = { + shell : Tezos_base.Block_header.shell_header; + protocol_data : block_header_data; + } - let environment_version = Protocol.V0 + let environment_version = Protocol.V0 - let init _ = assert false + let init _ = assert false - let rpc_services = RPC_directory.empty + let rpc_services = RPC_directory.empty - let finalize_block _ = assert false + let finalize_block _ = assert false - let apply_operation _ = assert false + let apply_operation _ = assert false - let begin_construction ~chain_id:_ ~predecessor_context:_ - ~predecessor_timestamp:_ ~predecessor_level:_ ~predecessor_fitness:_ - ~predecessor:_ ~timestamp:_ ?protocol_data:_ ~cache:_ _ = - assert false + let begin_construction ~chain_id:_ ~predecessor_context:_ + ~predecessor_timestamp:_ ~predecessor_level:_ ~predecessor_fitness:_ + ~predecessor:_ ~timestamp:_ ?protocol_data:_ ~cache:_ _ = + assert false - let begin_application ~chain_id:_ ~predecessor_context:_ - ~predecessor_timestamp:_ ~predecessor_fitness:_ ~cache:_ _ = - assert false + let begin_application ~chain_id:_ ~predecessor_context:_ + ~predecessor_timestamp:_ ~predecessor_fitness:_ ~cache:_ _ = + assert false - let begin_partial_application ~chain_id:_ ~ancestor_context:_ ~predecessor:_ - ~predecessor_hash:_ ~cache:_ _ = - assert false + let begin_partial_application ~chain_id:_ ~ancestor_context:_ ~predecessor:_ + ~predecessor_hash:_ ~cache:_ _ = + assert false - let relative_position_within_block _ = assert false + let relative_position_within_block _ = assert false - let acceptable_passes _ = assert false + let acceptable_passes _ = assert false - let operation_data_and_receipt_encoding = - Data_encoding.conv (Fun.const ()) (Fun.const ((), ())) Data_encoding.unit + let operation_data_and_receipt_encoding = + Data_encoding.conv (Fun.const ()) (Fun.const ((), ())) Data_encoding.unit - let operation_receipt_encoding = Data_encoding.unit + let operation_receipt_encoding = Data_encoding.unit - let operation_data_encoding = Data_encoding.unit + let operation_data_encoding = Data_encoding.unit - let block_header_metadata_encoding = Data_encoding.unit + let block_header_metadata_encoding = Data_encoding.unit - let block_header_data_encoding = Data_encoding.unit + let block_header_data_encoding = Data_encoding.unit - let validation_passes = [] + let validation_passes = [] - (* Size of the shell header + size of the encoding of {!block_header_data} - (unit, i.e. 0). *) - let max_operation_data_length = 32 + (* Size of the shell header + size of the encoding of {!block_header_data} + (unit, i.e. 0). *) + let max_operation_data_length = 32 - let max_block_length = 0 + let max_block_length = 0 - let value_of_key ~chain_id:_ ~predecessor_context:_ ~predecessor_timestamp:_ - ~predecessor_level:_ ~predecessor_fitness:_ ~predecessor:_ ~timestamp:_ - = - assert false + let value_of_key ~chain_id:_ ~predecessor_context:_ ~predecessor_timestamp:_ + ~predecessor_level:_ ~predecessor_fitness:_ ~predecessor:_ ~timestamp:_ = + assert false - let set_log_message_consumer _ = () - end + let set_log_message_consumer _ = () end diff --git a/src/lib_protocol_environment/memory_context.ml b/src/lib_protocol_environment/memory_context.ml index 7828a3b4709102c9fda7217738c4b0070c8d1d79..7401b463bd88507226a54f21dd83dc747c0041d3 100644 --- a/src/lib_protocol_environment/memory_context.ml +++ b/src/lib_protocol_environment/memory_context.ml @@ -32,7 +32,7 @@ module M = struct let fork_test_chain c ~protocol:_ ~expiration:_ = Lwt.return c end -open Tezos_protocol_environment +open Environment_context type t = M.t diff --git a/src/lib_protocol_environment/memory_context.mli b/src/lib_protocol_environment/memory_context.mli index 3ac3b6aa87e69283b640a5c852be94f98abc0ef8..98a810806b327920fa5e669a19600d4fc25c3b5f 100644 --- a/src/lib_protocol_environment/memory_context.mli +++ b/src/lib_protocol_environment/memory_context.mli @@ -42,7 +42,7 @@ are used by nodes), because they don't require access to a disk: they live completely in memory. That is why they are ideal for testing. *) -open Tezos_protocol_environment +open Environment_context (** The type of the context backing {!Memory_context}. Main use is the parameterization of {!Environment_context.Context.kind} below, diff --git a/src/lib_protocol_environment/proxy_context.ml b/src/lib_protocol_environment/proxy_context.ml index 50f8b9f54756cb7a7bc28b6ff755cac434347e1c..8e6aa836e7b1e01b40a7f0afa05abcc4c9bf6094 100644 --- a/src/lib_protocol_environment/proxy_context.ml +++ b/src/lib_protocol_environment/proxy_context.ml @@ -395,7 +395,7 @@ module C = struct let equal_config = Local.equal_config end -open Tezos_protocol_environment +open Environment_context include Environment_context.Register (C) let proxy_impl_name = "proxy" diff --git a/src/lib_protocol_environment/proxy_context.mli b/src/lib_protocol_environment/proxy_context.mli index e4e78a499b9c54583b8e724d115a4d4e56cd5f5c..108a5c7b334cbcdad0e726ff5cc3e5a86a5a4212 100644 --- a/src/lib_protocol_environment/proxy_context.mli +++ b/src/lib_protocol_environment/proxy_context.mli @@ -40,10 +40,10 @@ after having created an {!empty} value with an instance of [Proxy_Delegate.T], this value behaves as the distant endpoint it delegates to. *) -open Tezos_protocol_environment +open Environment_context (** The module by which to parameterize - {!Tezos_protocol_environment.Context.kind} below. + {!Environment_context.Context.kind} below. [Proxy_Delegate.T] is packed as the type [M.proxy_delegate], because it is used for obtaining pristine instances of [Proxy_context] diff --git a/src/lib_protocol_environment/shell_context/dune b/src/lib_protocol_environment/shell_context/dune new file mode 100644 index 0000000000000000000000000000000000000000..624fb9352e71b4c1a96c667e490f7f7f627246e1 --- /dev/null +++ b/src/lib_protocol_environment/shell_context/dune @@ -0,0 +1,14 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_shell_context) + (public_name tezos-shell-context) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezos-protocol-environment + tezos-context) + (flags + (:standard) + -open Tezos_base.TzPervasives)) diff --git a/src/lib_protocol_environment/proxy_delegate_maker.ml b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml similarity index 89% rename from src/lib_protocol_environment/proxy_delegate_maker.ml rename to src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml index 8b04ee6f1f992fa81bf2b2d43d40b558333a9665..c6110d343f4b9742be44b9774772be0037acd29e 100644 --- a/src/lib_protocol_environment/proxy_delegate_maker.ml +++ b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml @@ -23,7 +23,8 @@ (* *) (*****************************************************************************) -let of_memory_tree (t : Tezos_context_memory.Context.tree) : Proxy_delegate.t = +let of_memory_tree (t : Tezos_context_memory.Context.tree) : + Tezos_protocol_environment.Proxy_delegate.t = (module struct let proxy_dir_mem key = let open Lwt_syntax in @@ -39,9 +40,10 @@ let of_memory_tree (t : Tezos_context_memory.Context.tree) : Proxy_delegate.t = let open Lwt_syntax in let* v = Tezos_context_memory.Context.Tree.mem t key in return_ok v - end : Proxy_delegate.T) + end : Tezos_protocol_environment.Proxy_delegate.T) -let of_memory_context (m : Tezos_context_memory.Context.t) : Proxy_delegate.t = +let of_memory_context (m : Tezos_context_memory.Context.t) : + Tezos_protocol_environment.Proxy_delegate.t = (module struct let proxy_dir_mem key = let open Lwt_syntax in @@ -57,20 +59,20 @@ let of_memory_context (m : Tezos_context_memory.Context.t) : Proxy_delegate.t = let open Lwt_syntax in let* v = Tezos_context_memory.Context.mem m key in return_ok v - end : Proxy_delegate.T) + end : Tezos_protocol_environment.Proxy_delegate.T) let make_index ~(context_path : string) : Tezos_context.Context.index Lwt.t = Tezos_context.Context.init ~readonly:true context_path let of_index ~(index : Tezos_context.Context.index) (hash : Context_hash.t) : - Proxy_delegate.t tzresult Lwt.t = + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t = let open Lwt_syntax in let* ctxt = Tezos_context.Context.checkout index hash in match ctxt with | None -> failwith "Couldn't check out the hash %s" (Context_hash.to_string hash) | Some ctxt -> - let proxy_data_dir : Proxy_delegate.t = + let proxy_data_dir : Tezos_protocol_environment.Proxy_delegate.t = (module struct let proxy_dir_mem (key : Tezos_context.Context.key) : bool tzresult Lwt.t = diff --git a/src/lib_protocol_environment/proxy_delegate_maker.mli b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli similarity index 93% rename from src/lib_protocol_environment/proxy_delegate_maker.mli rename to src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli index 4b56b6dcd26e01524f69d6523484c1d3a62d310d..ccb913fd1fe21091097202ef6a5a65a3948ef5f0 100644 --- a/src/lib_protocol_environment/proxy_delegate_maker.mli +++ b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli @@ -32,7 +32,9 @@ This constructor is easier to use than {!of_memory_context}, because it requires only a tree of data; not a context. This constructor is typically useful for tests. *) -val of_memory_tree : Tezos_context_memory.Context.tree -> Proxy_delegate.t +val of_memory_tree : + Tezos_context_memory.Context.tree -> + Tezos_protocol_environment.Proxy_delegate.t (** [of_memory_context m] creates a delegate that is backed by the tree underlying [m]. This is an alternative to delegating to a distant endpoint by doing RPCs @@ -43,7 +45,8 @@ val of_memory_tree : Tezos_context_memory.Context.tree -> Proxy_delegate.t This constructor is slightly harder to use than {!of_memory_tree}, because it requires a full-fledged context instead of a tree (a context contains a tree, so a context is harder to obtain). *) -val of_memory_context : Tezos_context_memory.Context.t -> Proxy_delegate.t +val of_memory_context : + Tezos_context_memory.Context.t -> Tezos_protocol_environment.Proxy_delegate.t (** [make_index context_path] creates an index that is suitable for being passed to {!of_index}. *) @@ -58,4 +61,4 @@ val make_index : context_path:string -> Tezos_context.Context.index Lwt.t val of_index : index:Tezos_context.Context.index -> Context_hash.t -> - Proxy_delegate.t tzresult Lwt.t + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t diff --git a/src/lib_protocol_environment/shell_context.ml b/src/lib_protocol_environment/shell_context/shell_context.ml similarity index 94% rename from src/lib_protocol_environment/shell_context.ml rename to src/lib_protocol_environment/shell_context/shell_context.ml index 1d0646113f6ca4a0c9521118aa7bdad849246cf5..b24a189c27123712d20be7c6e682ae6c478c0799 100644 --- a/src/lib_protocol_environment/shell_context.ml +++ b/src/lib_protocol_environment/shell_context/shell_context.ml @@ -32,7 +32,7 @@ module C = struct let set_protocol = add_protocol end -include Environment_context.Register (C) +include Register (C) let impl_name = "shell" @@ -55,6 +55,4 @@ let wrap_disk_context ctxt = let unwrap_disk_context : t -> Tezos_context.Context.t = function | Context.Context {ctxt; kind = Context; _} -> ctxt | Context.Context t -> - Environment_context.err_implementation_mismatch - ~expected:impl_name - ~got:t.impl_name + err_implementation_mismatch ~expected:impl_name ~got:t.impl_name diff --git a/src/lib_protocol_environment/shell_context.mli b/src/lib_protocol_environment/shell_context/shell_context.mli similarity index 100% rename from src/lib_protocol_environment/shell_context.mli rename to src/lib_protocol_environment/shell_context/shell_context.mli diff --git a/src/lib_protocol_environment/test/test_cache.ml b/src/lib_protocol_environment/test/test_cache.ml index 4a71fca5f523a9d6b5fe2ab52a9fb04bba349e9f..5b13c7ba5d0bffae638ddb464d6824fcde631af9 100644 --- a/src/lib_protocol_environment/test/test_cache.ml +++ b/src/lib_protocol_environment/test/test_cache.ml @@ -32,7 +32,8 @@ Subject: Low-level operations on protocol cache *) -open Environment_cache +open Tezos_protocol_environment.Internal_for_tests.Environment_cache + open Lib_test.Qcheck2_helpers open QCheck2 module Test = QCheck2.Test @@ -653,8 +654,6 @@ let check_from_cache_with_same_domain_copies = implemented in {!Environment_context}. *) -open Environment_context - type Context.cache_value += Int of int let load_cache_correctly_restores_cache_in_memory builder mode diff --git a/src/lib_protocol_environment/test/test_mem_context.ml b/src/lib_protocol_environment/test/test_mem_context.ml index 18cad6c31d4112b69d142757a882f33d51ff140c..49bc72320c45a691e810eb78ddaa920510c08444 100644 --- a/src/lib_protocol_environment/test/test_mem_context.ml +++ b/src/lib_protocol_environment/test/test_mem_context.ml @@ -69,7 +69,7 @@ type t = { let wrap_context_init f _ () = let open Lwt_syntax in - let genesis = Memory_context.empty in + let genesis = Tezos_protocol_environment.Memory_context.empty in let* block2 = create_block2 genesis in let* block3a = create_block3a block2 in let* block3b = create_block3b block2 in @@ -415,7 +415,7 @@ let test_domain0 () = let k1 = ["a"] in let k2 = ["b"] in let k3 = ["c"] in - let ctxt = Memory_context.empty in + let ctxt = Tezos_protocol_environment.Memory_context.empty in let* ctxt = Context.add ctxt k1 b0 in let* ctxt = Context.add ctxt k2 b0 in let* ctxt = Context.add ctxt k3 b0 in @@ -430,7 +430,7 @@ let test_domain1 () = let b0 = Bytes.of_string "0" in let k1 = ["a"; "b"] in let k2 = ["a"; "c"; "d"] in - let ctxt = Memory_context.empty in + let ctxt = Tezos_protocol_environment.Memory_context.empty in let* ctxt = Context.add ctxt k1 b0 in let* ctxt = Context.add ctxt k2 b0 in let expected_domain = [k1; k2] |> StringListSet.of_list in @@ -446,7 +446,7 @@ let test_domain2 () = let k2 = ["a"; "c"; "d"] in let k3 = ["a"; "c"; "e"] in let k4 = ["x"] in - let ctxt = Memory_context.empty in + let ctxt = Tezos_protocol_environment.Memory_context.empty in let* ctxt = Context.add ctxt k1 b0 in let* ctxt = Context.add ctxt k2 b0 in let* ctxt = Context.add ctxt k3 b0 in diff --git a/src/lib_protocol_environment/test_shell_context/test_proxy_context.ml b/src/lib_protocol_environment/test_shell_context/test_proxy_context.ml index 22dc629ef26b3e7b0bff3d588358b8ab6e62d5ae..17de22cdf64aa131dab4bee94ee3f858751e7bf0 100644 --- a/src/lib_protocol_environment/test_shell_context/test_proxy_context.ml +++ b/src/lib_protocol_environment/test_shell_context/test_proxy_context.ml @@ -59,7 +59,7 @@ let init_contexts (f : Context.t -> unit Lwt.t) _ () : 'a Lwt.t = let ctxt = Tezos_context_memory.make_empty_context () in let* ctxt = create_block ctxt in let proxy : Context.t = - Proxy_context.empty + Tezos_protocol_environment.Proxy_context.empty (Some (Tezos_shell_context.Proxy_delegate_maker.of_memory_context ctxt)) in f proxy diff --git a/src/lib_protocol_environment/tezos_protocol_environment.ml b/src/lib_protocol_environment/tezos_protocol_environment.ml index 5b3122a5d9a5896f2512867e3f43927dbeea3111..b7429a0fc38da8b3f232fb4537cbca10d71bda44 100644 --- a/src/lib_protocol_environment/tezos_protocol_environment.ml +++ b/src/lib_protocol_environment/tezos_protocol_environment.ml @@ -33,3 +33,11 @@ include Environment_V3 include Environment_V4 include Environment_V5 include Environment_V6 +module Memory_context = Memory_context +module Proxy_context = Proxy_context +module Proxy_delegate = Proxy_delegate + +module Internal_for_tests = struct + module Environment_protocol_T_test = Environment_protocol_T_test + module Environment_cache = Environment_cache +end diff --git a/src/lib_protocol_environment/tezos_protocol_environment.mli b/src/lib_protocol_environment/tezos_protocol_environment.mli index 0a2daf9915fdc7f935762ac7770f805e143a9121..e326a8bf1f4fe4d768699189f22430f1e2a45042 100644 --- a/src/lib_protocol_environment/tezos_protocol_environment.mli +++ b/src/lib_protocol_environment/tezos_protocol_environment.mli @@ -35,3 +35,12 @@ include module type of struct include Environment_V5 include Environment_V6 end + +module Memory_context = Memory_context +module Proxy_context = Proxy_context +module Proxy_delegate = Proxy_delegate + +module Internal_for_tests : sig + module Environment_protocol_T_test = Environment_protocol_T_test + module Environment_cache = Environment_cache +end diff --git a/src/lib_proxy/README.md b/src/lib_proxy/README.md index e45c28fb1ae1c1423023966fd708dfafffa3a286..36207ee19f42df7d0a359eb8e99c75bf3dd40f53 100644 --- a/src/lib_proxy/README.md +++ b/src/lib_proxy/README.md @@ -56,9 +56,9 @@ The main protocol-dependent functions are: * `Proxy_sig`'s `init_env_rpc_context` function: it provides the instance of `Tezos_protocol_environment.rpc_context` to use when doing an RPC call. This record's main field is an instance of - `Environment_context.Context.t`. + `Tezos_protocol_environment.Context.t`. -The value of `Environment_context.Context.t` built by the instances of +The value of `Tezos_protocol_environment.Context.t` built by the instances of `Proxy_sig` is where the proxy's core logic lies. The values returned are capable of filling themselves in the `get` method, by performing the `/chains/main/blocks/head/context/raw/bytes` RPC. By _filling themselves_, diff --git a/src/lib_proxy/light_proto.ml b/src/lib_proxy/light_proto.ml index be48b1fe81f820c420cce8d0f429bc93b90c06b5..02a86909ba9a37443957816f3c3a44f2fc63ba18 100644 --- a/src/lib_proxy/light_proto.ml +++ b/src/lib_proxy/light_proto.ml @@ -28,7 +28,7 @@ module type PROTO_RPCS = sig val merkle_tree : Proxy.proxy_getter_input -> - Proxy_context.M.key -> + Tezos_protocol_environment.Proxy_context.M.key -> Tezos_shell_services.Block_services.merkle_leaf_kind -> Tezos_shell_services.Block_services.merkle_tree option tzresult Lwt.t end diff --git a/src/lib_proxy/proxy.ml b/src/lib_proxy/proxy.ml index 498579f7cc042ed30b4fb5a1e163969c0a517584..a6ab87bccb5c3143bc24fdc1bf709e41a2d2fefb 100644 --- a/src/lib_proxy/proxy.ml +++ b/src/lib_proxy/proxy.ml @@ -74,7 +74,8 @@ module type TREE = sig val empty : t (** [get t key] returns the tree of data mapped by [key], if any. *) - val get : t -> key -> Proxy_context.M.tree option Lwt.t + val get : + t -> key -> Tezos_protocol_environment.Proxy_context.M.tree option Lwt.t (** [add_leaf t key raw_ctxt] returns a variant of [t] where [key] is mapped to [raw_ctxt]. When this function is called, it transforms diff --git a/src/lib_proxy/proxy_getter.ml b/src/lib_proxy/proxy_getter.ml index 21498686e3b70c4cd3adbce90d35ca22d00060be..7713c1d54ab367737510c421f98cff66810114a4 100644 --- a/src/lib_proxy/proxy_getter.ml +++ b/src/lib_proxy/proxy_getter.ml @@ -122,7 +122,9 @@ type proxy_m = (module M) type proxy_builder = | Of_rpc of (Proxy_proto.proto_rpc -> proxy_m Lwt.t) - | Of_data_dir of (Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) + | Of_data_dir of + (Context_hash.t -> + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) type rpc_context_args = { printer : Tezos_client_base.Client_context.printer option; @@ -137,7 +139,7 @@ module StringMap = String.Map let make_delegate (ctx : rpc_context_args) (proto_rpc : (module Proxy_proto.PROTO_RPC)) (hash : Context_hash.t) : - Proxy_delegate.t tzresult Lwt.t = + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t = match ctx.proxy_builder with | Of_rpc f -> let open Lwt_result_syntax in @@ -157,7 +159,7 @@ let make_delegate (ctx : rpc_context_args) let proxy_get = Initial_context.proxy_get pgi let proxy_mem = Initial_context.proxy_mem pgi - end : Proxy_delegate.T) + end : Tezos_protocol_environment.Proxy_delegate.T) | Of_data_dir f -> f hash module Tree : Proxy.TREE with type t = Local.tree with type key = Local.key = diff --git a/src/lib_proxy/proxy_getter.mli b/src/lib_proxy/proxy_getter.mli index f912bb9db8400ddc1beb6c5be5fcf82cad85a247..f83028cda8c7cdb42c2d19d438d0e7118cbfe9bc 100644 --- a/src/lib_proxy/proxy_getter.mli +++ b/src/lib_proxy/proxy_getter.mli @@ -95,7 +95,9 @@ type proxy_m = (module M) type proxy_builder = | Of_rpc of (Proxy_proto.proto_rpc -> proxy_m Lwt.t) (** Build a proxy that uses network requests for all data. *) - | Of_data_dir of (Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) + | Of_data_dir of + (Context_hash.t -> + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) (** Build a proxy that looks up data in a running node's data dir. *) (** Input data required by the proxy mode to build a @@ -124,7 +126,7 @@ val make_delegate : rpc_context_args -> (module Proxy_proto.PROTO_RPC) -> Context_hash.t -> - Proxy_delegate.t tzresult Lwt.t + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t (** Functor to obtain the implementation of [M] for the proxy mode (as opposed to the light mode implementation) *) diff --git a/src/lib_proxy/proxy_proto.ml b/src/lib_proxy/proxy_proto.ml index 20cdf7101f05fe513856d8ad13193da03e3b3bdb..a66a76ca85dce69243c7e9e894379162c631f48d 100644 --- a/src/lib_proxy/proxy_proto.ml +++ b/src/lib_proxy/proxy_proto.ml @@ -55,19 +55,22 @@ module type PROTO_RPC = sig *) val split_key : Proxy.mode -> - Proxy_context.M.key -> - (Proxy_context.M.key * Proxy_context.M.key) option + Tezos_protocol_environment.Proxy_context.M.key -> + (Tezos_protocol_environment.Proxy_context.M.key + * Tezos_protocol_environment.Proxy_context.M.key) + option (** [failure_is_permanent key] means that, if the request [rpc get /chains//blocks//context/raw/bytes/key] fails once, then it should not be retried; because this key is known to be missing all the time. It is safe to return always [false]. Returning [true] for some keys will reduce the number of RPC calls. *) - val failure_is_permanent : Proxy_context.M.key -> bool + val failure_is_permanent : + Tezos_protocol_environment.Proxy_context.M.key -> bool val do_rpc : Proxy.proxy_getter_input -> - Proxy_context.M.key -> + Tezos_protocol_environment.Proxy_context.M.key -> Tezos_shell_services.Block_services.raw_context tzresult Lwt.t end diff --git a/src/lib_proxy/proxy_services.ml b/src/lib_proxy/proxy_services.ml index 05a33f64b0673bc9aece7ec5986ec6420a1e529e..bedf7502070f4977379743dd4b079f9fbfc16278 100644 --- a/src/lib_proxy/proxy_services.ml +++ b/src/lib_proxy/proxy_services.ml @@ -120,7 +120,9 @@ type mode = sleep : float -> unit Lwt.t; sym_block_caching_time : Ptime.span option; on_disk_proxy_builder : - (Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) option; + (Context_hash.t -> + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) + option; } let to_client_server_mode = function diff --git a/src/lib_proxy/proxy_services.mli b/src/lib_proxy/proxy_services.mli index aefe760dbfd3177ee2e54c4aa748788205549aae..6b98a4c455a05a6ced8d2462f59e14e8e0c20f50 100644 --- a/src/lib_proxy/proxy_services.mli +++ b/src/lib_proxy/proxy_services.mli @@ -42,7 +42,9 @@ type mode = sleep : float -> unit Lwt.t; sym_block_caching_time : Ptime.span option; on_disk_proxy_builder : - (Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) option; + (Context_hash.t -> + Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) + option; } (** [tezos-proxy-server] is running. The [sleep] field is implemented by {!Lwt_unix.sleep}. We don't want to depend on it directly diff --git a/src/lib_shell/block_validator_process.ml b/src/lib_shell/block_validator_process.ml index e6f41333302e7580fc608ef57ea79837170ce979..36cdc1cc18e11d6c9308ea656979c7aabf7975bf 100644 --- a/src/lib_shell/block_validator_process.ml +++ b/src/lib_shell/block_validator_process.ml @@ -152,9 +152,10 @@ module Internal_validator_process = struct validator process. For this reason, we maintain the collection of caches passed from one block to the next one here. *) - mutable cache : Environment_context.Context.block_cache option; + mutable cache : Tezos_protocol_environment.Context.block_cache option; mutable preapply_result : - (Block_validation.apply_result * Environment_context.Context.t) option; + (Block_validation.apply_result * Tezos_protocol_environment.Context.t) + option; } let init diff --git a/src/lib_shell/prevalidator_filters.ml b/src/lib_shell/prevalidator_filters.ml index 8ae30734bfe49b2a0500c6cd728b4d1c0c7a4c67..574d4ba9a3d35723c591138a757bf2829d954076 100644 --- a/src/lib_shell/prevalidator_filters.ml +++ b/src/lib_shell/prevalidator_filters.ml @@ -88,7 +88,8 @@ module type FILTER = sig end module RPC : sig - val rpc_services : Environment_context.rpc_context RPC_directory.directory + val rpc_services : + Tezos_protocol_environment.rpc_context RPC_directory.directory end end diff --git a/src/lib_shell/prevalidator_filters.mli b/src/lib_shell/prevalidator_filters.mli index 7906a177786b6309492ccbefcb0ecde4de33899c..921f0ae8512f9c1bea3799d7f281d1ccaa839106 100644 --- a/src/lib_shell/prevalidator_filters.mli +++ b/src/lib_shell/prevalidator_filters.mli @@ -135,7 +135,8 @@ module type FILTER = sig end module RPC : sig - val rpc_services : Environment_context.rpc_context RPC_directory.directory + val rpc_services : + Tezos_protocol_environment.rpc_context RPC_directory.directory end end diff --git a/src/lib_shell/test/generators.ml b/src/lib_shell/test/generators.ml index cc0ccc3fdf3222cfe017d18e7ca1ed211b3cced7..defea0e7286c45d5df98baa1a5c80bd4062f2095 100644 --- a/src/lib_shell/test/generators.ml +++ b/src/lib_shell/test/generators.ml @@ -104,9 +104,9 @@ let priority_gen () : Prevalidator_pending_operations.priority QCheck2.Gen.t = speaking. One can make sure that this generator generates parsable operations by assuming a protocol and using a custom [proto_gen]. As an example this is the case when using - {!Environment_protocol_T_test.Internal_for_tests.Mock_all_unit} as the - protocol and specifying [proto_gen] to be [string_size (return 0)] i.e. - to have both [operation_data = unit] and strings generated for + {!Tezos_protocol_environment.Internal_for_tests.Environment_protocol_T_test.Mock_all_unit} + as the protocol and specifying [proto_gen] to be [string_size (return 0)] + i.e. to have both [operation_data = unit] and strings generated for [operation_data] always empty. *) let operation_with_hash_gen ?proto_gen ?block_hash_t () : unit Prevalidation.operation QCheck2.Gen.t = diff --git a/src/lib_shell/test/test_prevalidation_t.ml b/src/lib_shell/test/test_prevalidation_t.ml index f9cf2e7491266f437591fcfbcb8b2e1f4423f304..97753a7f2203625729bedf1785ea4a444835d167 100644 --- a/src/lib_shell/test/test_prevalidation_t.ml +++ b/src/lib_shell/test/test_prevalidation_t.ml @@ -35,7 +35,8 @@ module Mock_protocol : with type operation_data = unit and type operation_receipt = unit and type validation_state = unit = struct - include Environment_protocol_T_test.Internal_for_tests.Mock_all_unit + open Tezos_protocol_environment.Internal_for_tests + include Environment_protocol_T_test.Mock_all_unit let begin_construction ~chain_id:_ ~predecessor_context:_ ~predecessor_timestamp:_ ~predecessor_level:_ ~predecessor_fitness:_ diff --git a/src/lib_store/test/alpha_utils.ml b/src/lib_store/test/alpha_utils.ml index 6369a58503c47fcefd89166aa203b2f64466de91..c886e6e65511cd8aefe64dc75a4ce4926af52c10 100644 --- a/src/lib_store/test/alpha_utils.ml +++ b/src/lib_store/test/alpha_utils.ml @@ -506,7 +506,7 @@ let apply ctxt chain_id ~policy ?(operations = empty_operations) pred = ~timestamp:shell.timestamp in let* predecessor_context = - Environment_context.Context.load_cache + Tezos_protocol_environment.Context.load_cache (Store.Block.hash pred) predecessor_context `Lazy @@ -628,7 +628,7 @@ let apply_and_store chain_store ?(synchronous_merge = true) ?policy { context_hash; timestamp = block_header.shell.timestamp; - message = validation.Environment_context.message; + message = validation.Tezos_protocol_environment.message; max_operations_ttl = validation.max_operations_ttl; last_allowed_fork_level = validation.last_allowed_fork_level; }; diff --git a/src/lib_validation/block_validation.ml b/src/lib_validation/block_validation.ml index f14067c4edbe067bb5ac87dd8baff48ac9f69aae..7550ea97bf1c7855501772a41368c536203cb67b 100644 --- a/src/lib_validation/block_validation.ml +++ b/src/lib_validation/block_validation.ml @@ -126,7 +126,10 @@ type result = { ops_metadata : ops_metadata; } -type apply_result = {result : result; cache : Environment_context.Context.cache} +type apply_result = { + result : result; + cache : Tezos_protocol_environment.Context.cache; +} let check_proto_environment_version_increasing block_hash before after = let open Result_syntax in @@ -235,7 +238,9 @@ let may_force_protocol_upgrade ~user_activated_upgrades ~level | None -> return validation_result | Some hash -> let* context = - Environment_context.Context.set_protocol validation_result.context hash + Tezos_protocol_environment.Context.set_protocol + validation_result.context + hash in return {validation_result with context} @@ -259,7 +264,7 @@ let may_patch_protocol ~user_activated_upgrades validation_result | Some replacement_protocol -> let* context = - Environment_context.Context.set_protocol + Tezos_protocol_environment.Context.set_protocol validation_result.context replacement_protocol in @@ -551,7 +556,7 @@ module Make (Proto : Registered_protocol.T) = struct let may_init_new_protocol chain_id new_protocol (block_header : Proto.block_header) block_hash - (validation_result : Environment_context.validation_result) = + (validation_result : Tezos_protocol_environment.validation_result) = let open Lwt_result_syntax in if Protocol_hash.equal new_protocol Proto.hash then return (validation_result, Proto.environment_version) @@ -984,7 +989,7 @@ module Make (Proto : Registered_protocol.T) = struct validation_result in let*! protocol = - Environment_context.Context.get_protocol validation_result.context + Tezos_protocol_environment.Context.get_protocol validation_result.context in let proto_level = if Protocol_hash.equal protocol Proto.hash then @@ -996,7 +1001,7 @@ module Make (Proto : Registered_protocol.T) = struct in let* validation_result, cache, new_protocol_env_version = if Protocol_hash.equal protocol Proto.hash then - let (Environment_context.Context.Context {cache; _}) = + let (Tezos_protocol_environment.Context.Context {cache; _}) = validation_result.context in return (validation_result, cache, Proto.environment_version) @@ -1018,7 +1023,7 @@ module Make (Proto : Registered_protocol.T) = struct let* validation_result = NewProto.init chain_id validation_result.context shell_header in - let (Environment_context.Context.Context {cache; _}) = + let (Tezos_protocol_environment.Context.Context {cache; _}) = validation_result.context in let*! () = @@ -1169,7 +1174,7 @@ type apply_environment = { max_operations_ttl : int; chain_id : Chain_id.t; predecessor_block_header : Block_header.t; - predecessor_context : Environment_context.Context.t; + predecessor_context : Tezos_protocol_environment.Context.t; predecessor_block_metadata_hash : Block_metadata_hash.t option; predecessor_ops_metadata_hash : Operation_metadata_list_list_hash.t option; user_activated_upgrades : User_activated.upgrades; @@ -1278,7 +1283,7 @@ let apply ?cached_result c ~cache block_header operations = "PtHangz2aRngywmSRGGvrcTyMbbdpWdpFKuS4uMWxg2RaH9i1qx" in if protocol_hash = hangzhou_hash then ( - Environment_context.Context + Tezos_protocol_environment.Context .reset_cache_cache_hangzhou_issue_do_not_use_except_if_you_know_what_you_are_doing () ; Lwt.return r) diff --git a/src/lib_validation/block_validation.mli b/src/lib_validation/block_validation.mli index 7197fa6f998d0da11d9c4466cc336c2a2f4dc195..a4cf27761a30a36e3eed41d64955c9752f9c7c55 100644 --- a/src/lib_validation/block_validation.mli +++ b/src/lib_validation/block_validation.mli @@ -46,10 +46,10 @@ val may_patch_protocol : Tezos_protocol_environment.validation_result Lwt.t val update_testchain_status : - Environment_context.Context.t -> + Tezos_protocol_environment.Context.t -> predecessor_hash:Block_hash.t -> Time.Protocol.t -> - Environment_context.Context.t Lwt.t + Tezos_protocol_environment.Context.t Lwt.t (** [check_proto_environment_version_increasing hash before after] returns successfully if the environment version stays the same or @@ -61,7 +61,7 @@ val check_proto_environment_version_increasing : (** [init_test_chain] must only be called on a forking block. *) val init_test_chain : Chain_id.t -> - Environment_context.Context.t -> + Tezos_protocol_environment.Context.t -> Block_header.t -> Block_header.t tzresult Lwt.t @@ -79,7 +79,10 @@ type result = { ops_metadata : ops_metadata; } -type apply_result = {result : result; cache : Environment_context.Context.cache} +type apply_result = { + result : result; + cache : Tezos_protocol_environment.Context.cache; +} val result_encoding : result Data_encoding.t @@ -100,7 +103,7 @@ type apply_environment = { chain_id : Chain_id.t; (** chain_id of the current branch *) predecessor_block_header : Block_header.t; (** header of the predecessor block being validated *) - predecessor_context : Environment_context.Context.t; + predecessor_context : Tezos_protocol_environment.Context.t; (** context associated to the predecessor block *) predecessor_block_metadata_hash : Block_metadata_hash.t option; (** hash of block header metadata of the predecessor block *) @@ -124,9 +127,9 @@ val default_operation_metadata_size_limit : int option 3. [P.finalize_block] *) val apply : - ?cached_result:apply_result * Environment_context.Context.t -> + ?cached_result:apply_result * Tezos_protocol_environment.Context.t -> apply_environment -> - cache:Environment_context.Context.source_of_cache -> + cache:Tezos_protocol_environment.Context.source_of_cache -> Block_header.t -> Operation.t list list -> apply_result tzresult Lwt.t @@ -140,8 +143,8 @@ val precheck : chain_id:Chain_id.t -> predecessor_block_header:Block_header.t -> predecessor_block_hash:Block_hash.t -> - predecessor_context:Environment_context.Context.t -> - cache:Environment_context.Context.source_of_cache -> + predecessor_context:Tezos_protocol_environment.Context.t -> + cache:Tezos_protocol_environment.Context.source_of_cache -> Block_header.t -> Operation.t list list -> unit tzresult Lwt.t @@ -155,7 +158,7 @@ val preapply : protocol_data:bytes -> live_blocks:Block_hash.Set.t -> live_operations:Operation_hash.Set.t -> - predecessor_context:Environment_context.Context.t -> + predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_shell_header:Block_header.shell_header -> predecessor_hash:Block_hash.t -> predecessor_max_operations_ttl:int -> @@ -163,17 +166,17 @@ val preapply : predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> Operation.t list list -> ((Block_header.shell_header * error Preapply_result.t list) - * (apply_result * Environment_context.Context.t)) + * (apply_result * Tezos_protocol_environment.Context.t)) tzresult Lwt.t val recompute_metadata : chain_id:Chain_id.t -> predecessor_block_header:Block_header.t -> - predecessor_context:Environment_context.Context.t -> + predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_block_metadata_hash:Block_metadata_hash.t option -> predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> block_header:Block_header.t -> operations:Operation.t trace trace -> - cache:Environment_context.Context.source_of_cache -> + cache:Tezos_protocol_environment.Context.source_of_cache -> ((bytes * Block_metadata_hash.t option) * ops_metadata) tzresult Lwt.t diff --git a/src/proto_011_PtHangz2/lib_client/mockup.ml b/src/proto_011_PtHangz2/lib_client/mockup.ml index 59c394d58b621d1e15f325442b12cf31674703ba..2e3c535bbb13fdf62f336cd3b12734ee139cedd4 100644 --- a/src/proto_011_PtHangz2/lib_client/mockup.ml +++ b/src/proto_011_PtHangz2/lib_client/mockup.ml @@ -805,7 +805,7 @@ let initial_context chain_id (header : Block_header.shell_header) Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt ["protocol_parameters"] proto_params) >>= fun ctxt -> diff --git a/src/proto_011_PtHangz2/lib_client/proxy.ml b/src/proto_011_PtHangz2/lib_client/proxy.ml index 6265f169ff7bce1245d0f531f735f5c27ce551bf..07912d33645279251cb4f1860ebe57df3423f98c 100644 --- a/src/proto_011_PtHangz2/lib_client/proxy.ml +++ b/src/proto_011_PtHangz2/lib_client/proxy.ml @@ -69,8 +69,11 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | "v1" :: tail -> Some (["v1"], tail) | _ -> None - let split_key (mode : Tezos_proxy.Proxy.mode) (key : Proxy_context.M.key) : - (Proxy_context.M.key * Proxy_context.M.key) option = + let split_key (mode : Tezos_proxy.Proxy.mode) + (key : Tezos_protocol_environment.Proxy_context.M.key) : + (Tezos_protocol_environment.Proxy_context.M.key + * Tezos_protocol_environment.Proxy_context.M.key) + option = match split_always key with | Some _ as res -> res (* No need to inspect the mode, this split is always done *) @@ -88,7 +91,7 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | _ -> false let do_rpc (pgi : Tezos_proxy.Proxy.proxy_getter_input) - (key : Proxy_context.M.key) = + (key : Tezos_protocol_environment.Proxy_context.M.key) = let chain = pgi.chain in let block = pgi.block in L.emit @@ -109,7 +112,8 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct end let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) - (hash : Context_hash.t) : Environment_context.Context.t tzresult Lwt.t = + (hash : Context_hash.t) : + Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = L.emit @@ -121,7 +125,10 @@ let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) let* (module ProxyDelegation) = Tezos_proxy.Proxy_getter.make_delegate ctx p_rpc hash in - let empty = Proxy_context.empty @@ Some (module ProxyDelegation) in + let empty = + Tezos_protocol_environment.Proxy_context.empty + @@ Some (module ProxyDelegation) + in let version_value = "hangzhou_011" in let*! ctxt = Tezos_protocol_environment.Context.add diff --git a/src/proto_012_Psithaca/lib_client/mockup.ml b/src/proto_012_Psithaca/lib_client/mockup.ml index bacbe9a595709b8d665530b09bf53cb6131745ad..7932f4aa5cdfa3697e653cf21f40c6cb0886ed24 100644 --- a/src/proto_012_Psithaca/lib_client/mockup.ml +++ b/src/proto_012_Psithaca/lib_client/mockup.ml @@ -907,7 +907,7 @@ let initial_context chain_id (header : Block_header.shell_header) Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt ["protocol_parameters"] proto_params) >>= fun ctxt -> diff --git a/src/proto_012_Psithaca/lib_client/proxy.ml b/src/proto_012_Psithaca/lib_client/proxy.ml index 9b910e9d6609e2a752edc4dfd2acf82f9b93a39b..85d52835f39c3d7e4918880a5c262ad0743e27b4 100644 --- a/src/proto_012_Psithaca/lib_client/proxy.ml +++ b/src/proto_012_Psithaca/lib_client/proxy.ml @@ -69,8 +69,11 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | "v1" :: tail -> Some (["v1"], tail) | _ -> None - let split_key (mode : Tezos_proxy.Proxy.mode) (key : Proxy_context.M.key) : - (Proxy_context.M.key * Proxy_context.M.key) option = + let split_key (mode : Tezos_proxy.Proxy.mode) + (key : Tezos_protocol_environment.Proxy_context.M.key) : + (Tezos_protocol_environment.Proxy_context.M.key + * Tezos_protocol_environment.Proxy_context.M.key) + option = match split_always key with | Some _ as res -> res (* No need to inspect the mode, this split is always done *) @@ -88,7 +91,7 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | _ -> false let do_rpc (pgi : Tezos_proxy.Proxy.proxy_getter_input) - (key : Proxy_context.M.key) = + (key : Tezos_protocol_environment.Proxy_context.M.key) = let chain = pgi.chain in let block = pgi.block in L.emit @@ -109,7 +112,8 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct end let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) - (hash : Context_hash.t) : Environment_context.Context.t tzresult Lwt.t = + (hash : Context_hash.t) : + Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = L.emit @@ -121,7 +125,10 @@ let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) let* (module ProxyDelegation) = Tezos_proxy.Proxy_getter.make_delegate ctx p_rpc hash in - let empty = Proxy_context.empty @@ Some (module ProxyDelegation) in + let empty = + Tezos_protocol_environment.Proxy_context.empty + @@ Some (module ProxyDelegation) + in let version_value = "ithaca_012" in let*! ctxt = Tezos_protocol_environment.Context.add diff --git a/src/proto_012_Psithaca/lib_delegate/abstract_context_index.ml b/src/proto_012_Psithaca/lib_delegate/abstract_context_index.ml index c714c2515946088556722f5eaabdfc5a226efb3a..da5a0d2167210486f3e8605b4a27fd768645cbdf 100644 --- a/src/proto_012_Psithaca/lib_delegate/abstract_context_index.ml +++ b/src/proto_012_Psithaca/lib_delegate/abstract_context_index.ml @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_012_Psithaca/lib_delegate/abstract_context_index.mli b/src/proto_012_Psithaca/lib_delegate/abstract_context_index.mli index 617739bd9124144bd47a43ecc91173759b287a5f..e6d262a8ad03d33d123805660f92d4a0b15a372d 100644 --- a/src/proto_012_Psithaca/lib_delegate/abstract_context_index.mli +++ b/src/proto_012_Psithaca/lib_delegate/abstract_context_index.mli @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_012_Psithaca/lib_delegate/block_forge.ml b/src/proto_012_Psithaca/lib_delegate/block_forge.ml index 9b72d39e16c77686d693f6c009aa14151634f3b0..ea8eb04769bc4d0f2ffcd64dd1656161db650a86 100644 --- a/src/proto_012_Psithaca/lib_delegate/block_forge.ml +++ b/src/proto_012_Psithaca/lib_delegate/block_forge.ml @@ -123,7 +123,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let hard_gas_limit_per_block = constants.Constants.hard_gas_limit_per_block in let chain = `Hash chain_id in let check_protocol_changed - ~(validation_result : Environment_context.validation_result) = + ~(validation_result : Tezos_protocol_environment.validation_result) = Context_ops.get_protocol validation_result.context >>= fun next_protocol -> let next_protocol = match diff --git a/src/proto_012_Psithaca/lib_delegate/operation_selection.ml b/src/proto_012_Psithaca/lib_delegate/operation_selection.ml index 7e47db4b79e41037497e757b17855408d44c8774..ce461e3f214753939bd4a2c679d7fe7e2276a155 100644 --- a/src/proto_012_Psithaca/lib_delegate/operation_selection.ml +++ b/src/proto_012_Psithaca/lib_delegate/operation_selection.ml @@ -189,7 +189,7 @@ let validate_operation inc op = | Some _b -> Lwt.return_some resulting_state) let filter_valid_operations_up_to_quota inc (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of (Baking_simulator.incremental * packed_operation list) in try @@ -262,7 +262,7 @@ let filter_operations_with_simulation initial_inc fees_config return {validation_result; block_header_metadata; operations; operations_hash} let filter_valid_operations_up_to_quota_without_simulation (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of packed_operation list in try List.fold_left diff --git a/src/proto_012_Psithaca/lib_delegate/operation_selection.mli b/src/proto_012_Psithaca/lib_delegate/operation_selection.mli index d261d6c8be066b577c6e13e682117058a74c28f2..78caab5c158c3d401e4c0f6d260c19a6e7621340 100644 --- a/src/proto_012_Psithaca/lib_delegate/operation_selection.mli +++ b/src/proto_012_Psithaca/lib_delegate/operation_selection.mli @@ -25,7 +25,7 @@ open Protocol open Alpha_context -open Environment_context +open Tezos_protocol_environment type simulation_result = { validation_result : validation_result; diff --git a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/faked_services.ml index 2ef5b0ef37f6f4b4428fb63a9bfe96b10156bde0..368059256aa38724b65d2bde6e80c728a2084d1d 100644 --- a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/faked_services.ml @@ -75,7 +75,8 @@ module type Mocked_services_hooks = sig RPCs (see local_services.ml). It should correspond to the rpc_context constructed from the context at the requested block. *) val rpc_context_callback : - Block_services.block -> Environment_context.rpc_context tzresult Lwt.t + Block_services.block -> + Tezos_protocol_environment.rpc_context tzresult Lwt.t (** Return raw protocol data as a block. *) val raw_protocol_data : Block_services.block -> Bytes.t tzresult Lwt.t diff --git a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 9388eb3d77d5918d19b98912b5d83dd465f76d9c..3b8acb2d6e1135efe3fcd7b51877d8a028370835 100644 --- a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -24,7 +24,7 @@ (*****************************************************************************) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; @@ -57,7 +57,7 @@ type state = { is used to find unknown predecessors. The real node can ask about an unknown block and receive it on request, this is supposed to emulate that functionality. *) - ctxt_table : Environment_context.rpc_context Context_hash.Table.t; + ctxt_table : Tezos_protocol_environment.rpc_context Context_hash.Table.t; (** The context table allows us to look up rpc_context by its hash. *) heads_pipe : (Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) @@ -176,7 +176,7 @@ let live_blocks (state : state) block = return (List.fold_left (fun set ({rpc_context; _} : block) -> - let hash = rpc_context.Environment_context.block_hash in + let hash = rpc_context.Tezos_protocol_environment.block_hash in Block_hash.Set.add hash set) (Block_hash.Set.singleton state.genesis_block_true_hash) segment) @@ -627,7 +627,7 @@ let rec process_block state block_hash (block_header : Block_header.t) Block_hash.Table.replace state.global_chain_table block_hash new_block ; Context_hash.Table.replace state.ctxt_table - rpc_context.Environment_context.block_header.context + rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; if Fitness.( @@ -684,7 +684,7 @@ let rec listener ~(user_hooks : (module Hooks)) ~state ~broadcast_pipe = (** Create a fake node state. *) let create_fake_node_state ~i ~live_depth - ~(genesis_block : Block_header.t * Environment_context.rpc_context) + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) ~global_chain_table ~broadcast_pipes = let block_header0, rpc_context0 = genesis_block in parse_protocol_data block_header0.protocol_data >>=? fun protocol_data -> @@ -726,7 +726,7 @@ let create_fake_node_state ~i ~live_depth Context_hash.Table.of_seq (List.to_seq [ - ( rpc_context0.Environment_context.block_header + ( rpc_context0.Tezos_protocol_environment.block_header .Block_header.context, rpc_context0 ); ]); @@ -739,8 +739,8 @@ let create_fake_node_state ~i ~live_depth (** Start baker process. *) let baker_process ~(delegates : Baking_state.delegate list) ~base_dir - ~(genesis_block : Block_header.t * Environment_context.rpc_context) ~i - ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) + ~i ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = let broadcast_pipe = List.nth broadcast_pipes i |> WithExceptions.Option.get ~loc:__LOC__ in @@ -784,7 +784,7 @@ let baker_process ~(delegates : Baking_state.delegate list) ~base_dir checkout_fun = (fun hash -> Context_hash.Table.find state.ctxt_table hash - |> Option.map (fun Environment_context.{context; _} -> context) + |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; } diff --git a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.mli index c538ab3a01b7e397d10a8d3a3c6e4340b81cbf37..47d54b8d3d9c7f051386e45fed6a2794b4820324 100644 --- a/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_012_Psithaca/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -25,7 +25,7 @@ (** Representation of a block in the simulator. *) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; diff --git a/src/proto_012_Psithaca/lib_protocol/test/helpers/block.ml b/src/proto_012_Psithaca/lib_protocol/test/helpers/block.ml index 2ff8169da265f8716758ceffa0ca0e431486e737..ac4d4d53ffd59084b11910887e1143f4950696b6 100644 --- a/src/proto_012_Psithaca/lib_protocol/test/helpers/block.ml +++ b/src/proto_012_Psithaca/lib_protocol/test/helpers/block.ml @@ -288,7 +288,7 @@ let prepare_main_init_params ?bootstrap_contracts commitments constants Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) @@ -378,7 +378,7 @@ let genesis_with_parameters parameters = Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> diff --git a/src/proto_012_Psithaca/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_012_Psithaca/lib_protocol/test/integration/gas/test_gas_levels.ml index 2023b274151279893a1d7d61e625daac716ca262..83b8284be65e2156a8e3ba7295e539b15bed170b 100644 --- a/src/proto_012_Psithaca/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_012_Psithaca/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -55,7 +55,7 @@ let dummy_context () = ~predecessor_timestamp:Time.Protocol.epoch ~timestamp:Time.Protocol.epoch (* ~fitness:[] *) - (block.context : Environment_context.Context.t) + (block.context : Tezos_protocol_environment.Context.t) >|= Environment.wrap_tzresult let consume_gas_lwt context gas = diff --git a/src/proto_013_PtJakart/lib_client/mockup.ml b/src/proto_013_PtJakart/lib_client/mockup.ml index 877cdeb58b37f6c96252f87029e8f46012c8913e..bd5c848edf191f140aae436c51aa2dfe61d4d069 100644 --- a/src/proto_013_PtJakart/lib_client/mockup.ml +++ b/src/proto_013_PtJakart/lib_client/mockup.ml @@ -1232,7 +1232,7 @@ let initial_context chain_id (header : Block_header.shell_header) Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt ["protocol_parameters"] proto_params) >>= fun ctxt -> diff --git a/src/proto_013_PtJakart/lib_client/proxy.ml b/src/proto_013_PtJakart/lib_client/proxy.ml index 232d15bb2b88bcf9ccf45d5f4ff1f1175ed6da8c..3d1f79798f53b681e97380d01eeac3ebd5c0ad11 100644 --- a/src/proto_013_PtJakart/lib_client/proxy.ml +++ b/src/proto_013_PtJakart/lib_client/proxy.ml @@ -69,8 +69,11 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | "v1" :: tail -> Some (["v1"], tail) | _ -> None - let split_key (mode : Tezos_proxy.Proxy.mode) (key : Proxy_context.M.key) : - (Proxy_context.M.key * Proxy_context.M.key) option = + let split_key (mode : Tezos_proxy.Proxy.mode) + (key : Tezos_protocol_environment.Proxy_context.M.key) : + (Tezos_protocol_environment.Proxy_context.M.key + * Tezos_protocol_environment.Proxy_context.M.key) + option = match split_always key with | Some _ as res -> res (* No need to inspect the mode, this split is always done *) @@ -88,7 +91,7 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | _ -> false let do_rpc (pgi : Tezos_proxy.Proxy.proxy_getter_input) - (key : Proxy_context.M.key) = + (key : Tezos_protocol_environment.Proxy_context.M.key) = let chain = pgi.chain in let block = pgi.block in L.emit @@ -109,7 +112,8 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct end let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) - (hash : Context_hash.t) : Environment_context.Context.t tzresult Lwt.t = + (hash : Context_hash.t) : + Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = L.emit @@ -121,7 +125,10 @@ let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) let* (module ProxyDelegation) = Tezos_proxy.Proxy_getter.make_delegate ctx p_rpc hash in - let empty = Proxy_context.empty @@ Some (module ProxyDelegation) in + let empty = + Tezos_protocol_environment.Proxy_context.empty + @@ Some (module ProxyDelegation) + in let version_value = "jakarta_013" in let*! ctxt = Tezos_protocol_environment.Context.add diff --git a/src/proto_013_PtJakart/lib_delegate/abstract_context_index.ml b/src/proto_013_PtJakart/lib_delegate/abstract_context_index.ml index c714c2515946088556722f5eaabdfc5a226efb3a..da5a0d2167210486f3e8605b4a27fd768645cbdf 100644 --- a/src/proto_013_PtJakart/lib_delegate/abstract_context_index.ml +++ b/src/proto_013_PtJakart/lib_delegate/abstract_context_index.ml @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_013_PtJakart/lib_delegate/abstract_context_index.mli b/src/proto_013_PtJakart/lib_delegate/abstract_context_index.mli index 617739bd9124144bd47a43ecc91173759b287a5f..e6d262a8ad03d33d123805660f92d4a0b15a372d 100644 --- a/src/proto_013_PtJakart/lib_delegate/abstract_context_index.mli +++ b/src/proto_013_PtJakart/lib_delegate/abstract_context_index.mli @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_013_PtJakart/lib_delegate/block_forge.ml b/src/proto_013_PtJakart/lib_delegate/block_forge.ml index 413f5f2eee5e5f3e4effd5edff9df9c4f8928519..9f8323b3a9d787e7f0abfb313784e6dd89938f25 100644 --- a/src/proto_013_PtJakart/lib_delegate/block_forge.ml +++ b/src/proto_013_PtJakart/lib_delegate/block_forge.ml @@ -123,7 +123,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let hard_gas_limit_per_block = constants.Constants.hard_gas_limit_per_block in let chain = `Hash chain_id in let check_protocol_changed - ~(validation_result : Environment_context.validation_result) = + ~(validation_result : Tezos_protocol_environment.validation_result) = Context_ops.get_protocol validation_result.context >>= fun next_protocol -> let next_protocol = match diff --git a/src/proto_013_PtJakart/lib_delegate/operation_selection.ml b/src/proto_013_PtJakart/lib_delegate/operation_selection.ml index 8fbf31e0d0c36007e446ff0d6bdd31b4638207db..7747a09a8aa26e0c75afa856dbcabbbe2b2861d5 100644 --- a/src/proto_013_PtJakart/lib_delegate/operation_selection.ml +++ b/src/proto_013_PtJakart/lib_delegate/operation_selection.ml @@ -187,7 +187,7 @@ let validate_operation inc op = | Some _b -> Lwt.return_some resulting_state) let filter_valid_operations_up_to_quota inc (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of (Baking_simulator.incremental * packed_operation list) in try @@ -260,7 +260,7 @@ let filter_operations_with_simulation initial_inc fees_config return {validation_result; block_header_metadata; operations; operations_hash} let filter_valid_operations_up_to_quota_without_simulation (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of packed_operation list in try List.fold_left diff --git a/src/proto_013_PtJakart/lib_delegate/operation_selection.mli b/src/proto_013_PtJakart/lib_delegate/operation_selection.mli index d261d6c8be066b577c6e13e682117058a74c28f2..78caab5c158c3d401e4c0f6d260c19a6e7621340 100644 --- a/src/proto_013_PtJakart/lib_delegate/operation_selection.mli +++ b/src/proto_013_PtJakart/lib_delegate/operation_selection.mli @@ -25,7 +25,7 @@ open Protocol open Alpha_context -open Environment_context +open Tezos_protocol_environment type simulation_result = { validation_result : validation_result; diff --git a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/faked_services.ml index 2ef5b0ef37f6f4b4428fb63a9bfe96b10156bde0..368059256aa38724b65d2bde6e80c728a2084d1d 100644 --- a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/faked_services.ml @@ -75,7 +75,8 @@ module type Mocked_services_hooks = sig RPCs (see local_services.ml). It should correspond to the rpc_context constructed from the context at the requested block. *) val rpc_context_callback : - Block_services.block -> Environment_context.rpc_context tzresult Lwt.t + Block_services.block -> + Tezos_protocol_environment.rpc_context tzresult Lwt.t (** Return raw protocol data as a block. *) val raw_protocol_data : Block_services.block -> Bytes.t tzresult Lwt.t diff --git a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 5194f4dd2cea398ab182799710190069b2c3b4a4..0af160aed4a363d0e7e9a5bffce657126e89accc 100644 --- a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -24,7 +24,7 @@ (*****************************************************************************) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; @@ -57,7 +57,7 @@ type state = { is used to find unknown predecessors. The real node can ask about an unknown block and receive it on request, this is supposed to emulate that functionality. *) - ctxt_table : Environment_context.rpc_context Context_hash.Table.t; + ctxt_table : Tezos_protocol_environment.rpc_context Context_hash.Table.t; (** The context table allows us to look up rpc_context by its hash. *) heads_pipe : (Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) @@ -176,7 +176,7 @@ let live_blocks (state : state) block = return (List.fold_left (fun set ({rpc_context; _} : block) -> - let hash = rpc_context.Environment_context.block_hash in + let hash = rpc_context.Tezos_protocol_environment.block_hash in Block_hash.Set.add hash set) (Block_hash.Set.singleton state.genesis_block_true_hash) segment) @@ -627,7 +627,7 @@ let rec process_block state block_hash (block_header : Block_header.t) Block_hash.Table.replace state.global_chain_table block_hash new_block ; Context_hash.Table.replace state.ctxt_table - rpc_context.Environment_context.block_header.context + rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; if Fitness.( @@ -684,7 +684,7 @@ let rec listener ~(user_hooks : (module Hooks)) ~state ~broadcast_pipe = (** Create a fake node state. *) let create_fake_node_state ~i ~live_depth - ~(genesis_block : Block_header.t * Environment_context.rpc_context) + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) ~global_chain_table ~broadcast_pipes = let block_header0, rpc_context0 = genesis_block in parse_protocol_data block_header0.protocol_data >>=? fun protocol_data -> @@ -726,7 +726,7 @@ let create_fake_node_state ~i ~live_depth Context_hash.Table.of_seq (List.to_seq [ - ( rpc_context0.Environment_context.block_header + ( rpc_context0.Tezos_protocol_environment.block_header .Block_header.context, rpc_context0 ); ]); @@ -739,8 +739,8 @@ let create_fake_node_state ~i ~live_depth (** Start baker process. *) let baker_process ~(delegates : Baking_state.delegate list) ~base_dir - ~(genesis_block : Block_header.t * Environment_context.rpc_context) ~i - ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) + ~i ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = let broadcast_pipe = List.nth broadcast_pipes i |> WithExceptions.Option.get ~loc:__LOC__ in @@ -784,7 +784,7 @@ let baker_process ~(delegates : Baking_state.delegate list) ~base_dir checkout_fun = (fun hash -> Context_hash.Table.find state.ctxt_table hash - |> Option.map (fun Environment_context.{context; _} -> context) + |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; } diff --git a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.mli index 25b73e0c61827aeb7d108b82d0579e3901a189ad..b2119bf6d1771d7db9446247d7ae4366af408d15 100644 --- a/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_013_PtJakart/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -25,7 +25,7 @@ (** Representation of a block in the simulator. *) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; diff --git a/src/proto_013_PtJakart/lib_protocol/test/helpers/block.ml b/src/proto_013_PtJakart/lib_protocol/test/helpers/block.ml index 367a5d67281cea4b49a63ed55a3878283b9106b4..f30240f6edfc10463d3d3def6a68b16c1284d4e5 100644 --- a/src/proto_013_PtJakart/lib_protocol/test/helpers/block.ml +++ b/src/proto_013_PtJakart/lib_protocol/test/helpers/block.ml @@ -291,7 +291,7 @@ let prepare_main_init_params ?bootstrap_contracts commitments constants Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) @@ -380,7 +380,7 @@ let genesis_with_parameters parameters = Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> diff --git a/src/proto_013_PtJakart/lib_protocol/test/helpers/context.ml b/src/proto_013_PtJakart/lib_protocol/test/helpers/context.ml index 3cefe2b8e492be73af63e378d043aa05be247047..97b7f2bed2d0a9f668a044864f5b5a03d5cfb1a0 100644 --- a/src/proto_013_PtJakart/lib_protocol/test/helpers/context.ml +++ b/src/proto_013_PtJakart/lib_protocol/test/helpers/context.ml @@ -490,7 +490,7 @@ let default_raw_context () = in let protocol_param_key = ["protocol_parameters"] in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun context -> diff --git a/src/proto_013_PtJakart/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_013_PtJakart/lib_protocol/test/integration/gas/test_gas_levels.ml index a1bb372837645a99d394a326f47995928269d47a..f53778dae3a571bd256666453e92fa935d7d8f03 100644 --- a/src/proto_013_PtJakart/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_013_PtJakart/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -55,7 +55,7 @@ let dummy_context () = ~predecessor_timestamp:Time.Protocol.epoch ~timestamp:Time.Protocol.epoch (* ~fitness:[] *) - (block.context : Environment_context.Context.t) + (block.context : Tezos_protocol_environment.Context.t) >|= Environment.wrap_tzresult let consume_gas_lwt context gas = diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 7b5fcb6e7446710b353850d606ef5030fe55f916..77d712cb1b866a81055f92a1629d05398a05ac73 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -1411,7 +1411,7 @@ let initial_context chain_id (header : Block_header.shell_header) Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt ["protocol_parameters"] proto_params) >>= fun ctxt -> diff --git a/src/proto_alpha/lib_client/proxy.ml b/src/proto_alpha/lib_client/proxy.ml index b7d7a7a97faaddbf9188e5afc0ed6f86d1156b38..0d6878171219c2ad4bd6643f7fa19f7a50695741 100644 --- a/src/proto_alpha/lib_client/proxy.ml +++ b/src/proto_alpha/lib_client/proxy.ml @@ -69,8 +69,11 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | "v1" :: tail -> Some (["v1"], tail) | _ -> None - let split_key (mode : Tezos_proxy.Proxy.mode) (key : Proxy_context.M.key) : - (Proxy_context.M.key * Proxy_context.M.key) option = + let split_key (mode : Tezos_proxy.Proxy.mode) + (key : Tezos_protocol_environment.Proxy_context.M.key) : + (Tezos_protocol_environment.Proxy_context.M.key + * Tezos_protocol_environment.Proxy_context.M.key) + option = match split_always key with | Some _ as res -> res (* No need to inspect the mode, this split is always done *) @@ -88,7 +91,7 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct | _ -> false let do_rpc (pgi : Tezos_proxy.Proxy.proxy_getter_input) - (key : Proxy_context.M.key) = + (key : Tezos_protocol_environment.Proxy_context.M.key) = let chain = pgi.chain in let block = pgi.block in L.emit @@ -109,7 +112,8 @@ module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC = struct end let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) - (hash : Context_hash.t) : Environment_context.Context.t tzresult Lwt.t = + (hash : Context_hash.t) : + Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = L.emit @@ -121,7 +125,10 @@ let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) let* (module ProxyDelegation) = Tezos_proxy.Proxy_getter.make_delegate ctx p_rpc hash in - let empty = Proxy_context.empty @@ Some (module ProxyDelegation) in + let empty = + Tezos_protocol_environment.Proxy_context.empty + @@ Some (module ProxyDelegation) + in let version_value = "alpha_current" in let*! ctxt = Tezos_protocol_environment.Context.add diff --git a/src/proto_alpha/lib_delegate/abstract_context_index.ml b/src/proto_alpha/lib_delegate/abstract_context_index.ml index c714c2515946088556722f5eaabdfc5a226efb3a..da5a0d2167210486f3e8605b4a27fd768645cbdf 100644 --- a/src/proto_alpha/lib_delegate/abstract_context_index.ml +++ b/src/proto_alpha/lib_delegate/abstract_context_index.ml @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_alpha/lib_delegate/abstract_context_index.mli b/src/proto_alpha/lib_delegate/abstract_context_index.mli index 617739bd9124144bd47a43ecc91173759b287a5f..e6d262a8ad03d33d123805660f92d4a0b15a372d 100644 --- a/src/proto_alpha/lib_delegate/abstract_context_index.mli +++ b/src/proto_alpha/lib_delegate/abstract_context_index.mli @@ -24,7 +24,8 @@ (*****************************************************************************) type t = { - checkout_fun : Context_hash.t -> Environment_context.Context.t option Lwt.t; + checkout_fun : + Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_alpha/lib_delegate/block_forge.ml b/src/proto_alpha/lib_delegate/block_forge.ml index 8efc10394526b8dc3f969c616d90c8a14978e375..a367b6b655c8952d2139f50afbfe78f279d10ba9 100644 --- a/src/proto_alpha/lib_delegate/block_forge.ml +++ b/src/proto_alpha/lib_delegate/block_forge.ml @@ -125,7 +125,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info in let chain = `Hash chain_id in let check_protocol_changed - ~(validation_result : Environment_context.validation_result) = + ~(validation_result : Tezos_protocol_environment.validation_result) = Context_ops.get_protocol validation_result.context >>= fun next_protocol -> let next_protocol = match diff --git a/src/proto_alpha/lib_delegate/operation_selection.ml b/src/proto_alpha/lib_delegate/operation_selection.ml index 8fbf31e0d0c36007e446ff0d6bdd31b4638207db..7747a09a8aa26e0c75afa856dbcabbbe2b2861d5 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.ml +++ b/src/proto_alpha/lib_delegate/operation_selection.ml @@ -187,7 +187,7 @@ let validate_operation inc op = | Some _b -> Lwt.return_some resulting_state) let filter_valid_operations_up_to_quota inc (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of (Baking_simulator.incremental * packed_operation list) in try @@ -260,7 +260,7 @@ let filter_operations_with_simulation initial_inc fees_config return {validation_result; block_header_metadata; operations; operations_hash} let filter_valid_operations_up_to_quota_without_simulation (ops, quota) = - let {Environment_context.max_size; max_op} = quota in + let {Tezos_protocol_environment.max_size; max_op} = quota in let exception Full of packed_operation list in try List.fold_left diff --git a/src/proto_alpha/lib_delegate/operation_selection.mli b/src/proto_alpha/lib_delegate/operation_selection.mli index d261d6c8be066b577c6e13e682117058a74c28f2..78caab5c158c3d401e4c0f6d260c19a6e7621340 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.mli +++ b/src/proto_alpha/lib_delegate/operation_selection.mli @@ -25,7 +25,7 @@ open Protocol open Alpha_context -open Environment_context +open Tezos_protocol_environment type simulation_result = { validation_result : validation_result; diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml index 2ef5b0ef37f6f4b4428fb63a9bfe96b10156bde0..368059256aa38724b65d2bde6e80c728a2084d1d 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_services.ml @@ -75,7 +75,8 @@ module type Mocked_services_hooks = sig RPCs (see local_services.ml). It should correspond to the rpc_context constructed from the context at the requested block. *) val rpc_context_callback : - Block_services.block -> Environment_context.rpc_context tzresult Lwt.t + Block_services.block -> + Tezos_protocol_environment.rpc_context tzresult Lwt.t (** Return raw protocol data as a block. *) val raw_protocol_data : Block_services.block -> Bytes.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 5194f4dd2cea398ab182799710190069b2c3b4a4..0af160aed4a363d0e7e9a5bffce657126e89accc 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -24,7 +24,7 @@ (*****************************************************************************) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; @@ -57,7 +57,7 @@ type state = { is used to find unknown predecessors. The real node can ask about an unknown block and receive it on request, this is supposed to emulate that functionality. *) - ctxt_table : Environment_context.rpc_context Context_hash.Table.t; + ctxt_table : Tezos_protocol_environment.rpc_context Context_hash.Table.t; (** The context table allows us to look up rpc_context by its hash. *) heads_pipe : (Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) @@ -176,7 +176,7 @@ let live_blocks (state : state) block = return (List.fold_left (fun set ({rpc_context; _} : block) -> - let hash = rpc_context.Environment_context.block_hash in + let hash = rpc_context.Tezos_protocol_environment.block_hash in Block_hash.Set.add hash set) (Block_hash.Set.singleton state.genesis_block_true_hash) segment) @@ -627,7 +627,7 @@ let rec process_block state block_hash (block_header : Block_header.t) Block_hash.Table.replace state.global_chain_table block_hash new_block ; Context_hash.Table.replace state.ctxt_table - rpc_context.Environment_context.block_header.context + rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; if Fitness.( @@ -684,7 +684,7 @@ let rec listener ~(user_hooks : (module Hooks)) ~state ~broadcast_pipe = (** Create a fake node state. *) let create_fake_node_state ~i ~live_depth - ~(genesis_block : Block_header.t * Environment_context.rpc_context) + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) ~global_chain_table ~broadcast_pipes = let block_header0, rpc_context0 = genesis_block in parse_protocol_data block_header0.protocol_data >>=? fun protocol_data -> @@ -726,7 +726,7 @@ let create_fake_node_state ~i ~live_depth Context_hash.Table.of_seq (List.to_seq [ - ( rpc_context0.Environment_context.block_header + ( rpc_context0.Tezos_protocol_environment.block_header .Block_header.context, rpc_context0 ); ]); @@ -739,8 +739,8 @@ let create_fake_node_state ~i ~live_depth (** Start baker process. *) let baker_process ~(delegates : Baking_state.delegate list) ~base_dir - ~(genesis_block : Block_header.t * Environment_context.rpc_context) ~i - ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = + ~(genesis_block : Block_header.t * Tezos_protocol_environment.rpc_context) + ~i ~global_chain_table ~broadcast_pipes ~(user_hooks : (module Hooks)) = let broadcast_pipe = List.nth broadcast_pipes i |> WithExceptions.Option.get ~loc:__LOC__ in @@ -784,7 +784,7 @@ let baker_process ~(delegates : Baking_state.delegate list) ~base_dir checkout_fun = (fun hash -> Context_hash.Table.find state.ctxt_table hash - |> Option.map (fun Environment_context.{context; _} -> context) + |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; } diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli index 25b73e0c61827aeb7d108b82d0579e3901a189ad..b2119bf6d1771d7db9446247d7ae4366af408d15 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -25,7 +25,7 @@ (** Representation of a block in the simulator. *) type block = { - rpc_context : Environment_context.rpc_context; + rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : Protocol.Alpha_context.Block_header.protocol_data; raw_protocol_data : Bytes.t; operations : Mockup.M.Block_services.operation list list; diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index 7e7360be40b841463f5fb55059d3c822ad1c2903..81808e933b58a0809d91fe6b21ed126b86e933da 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -302,7 +302,7 @@ let prepare_main_init_params ?bootstrap_contracts commitments constants Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) @@ -396,7 +396,7 @@ let genesis_with_parameters parameters = Data_encoding.Binary.to_bytes_exn Data_encoding.json json in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 92f4c0723f2287dd4ad21a8a4b40108b31371189..8102f559f9d23e5aae09dba5a194e5342752e6ef 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -501,7 +501,7 @@ let default_raw_context () = in let protocol_param_key = ["protocol_parameters"] in Tezos_protocol_environment.Context.( - let empty = Memory_context.empty in + let empty = Tezos_protocol_environment.Memory_context.empty in add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun context -> diff --git a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml index c33c298706d9172eb2ea113f9bf42353877c0bf7..1866f629aeade9ec731217af7e4e24bbd9fb5437 100644 --- a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -55,7 +55,7 @@ let dummy_context () = ~predecessor_timestamp:Time.Protocol.epoch ~timestamp:Time.Protocol.epoch (* ~fitness:[] *) - (block.context : Environment_context.Context.t) + (block.context : Tezos_protocol_environment.Context.t) >|= Environment.wrap_tzresult let consume_gas_lwt context gas =