From 8dfaddc49bd46657ef180adf0efd9cd593e25d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 17:35:23 +0200 Subject: [PATCH 01/30] Base: unopen Crypto, unexport Crypto --- manifest/main.ml | 4 ++-- src/lib_base/block_header.ml | 27 +++++++++++---------- src/lib_base/block_header.mli | 14 +++++------ src/lib_base/block_locator.ml | 36 +++++++++++++++------------- src/lib_base/block_locator.mli | 21 +++++++++------- src/lib_base/dune | 1 - src/lib_base/genesis.ml | 8 +++---- src/lib_base/genesis.mli | 4 ++-- src/lib_base/mempool.ml | 23 +++++++++++------- src/lib_base/mempool.mli | 9 +++---- src/lib_base/operation.ml | 25 ++++++++++++------- src/lib_base/operation.mli | 11 +++++---- src/lib_base/p2p_identity.ml | 28 ++++++++++++++-------- src/lib_base/p2p_identity.mli | 10 ++++---- src/lib_base/p2p_peer_id.ml | 2 +- src/lib_base/p2p_peer_id.mli | 3 ++- src/lib_base/protocol.ml | 8 +++---- src/lib_base/protocol.mli | 5 ++-- src/lib_base/test_chain_status.ml | 27 +++++++++++---------- src/lib_base/test_chain_status.mli | 11 +++++---- src/lib_base/tzPervasives.ml | 1 - src/lib_base/tzPervasives.mli | 3 --- src/lib_base/unix/dune | 1 - src/lib_base/unix/protocol_files.mli | 8 +++++-- src/lib_base/user_activated.ml | 11 +++++---- src/lib_base/user_activated.mli | 5 ++-- 26 files changed, 174 insertions(+), 132 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 3a581724b765..af3693c5d0d2 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1040,7 +1040,7 @@ let octez_base = ~deps: [ octez_stdlib |> open_; - octez_crypto |> open_; + octez_crypto; data_encoding |> open_; octez_error_monad |> open_ |> open_ ~m:"TzLwtreslib"; octez_rpc; @@ -1076,7 +1076,7 @@ let octez_base_unix = ~deps: [ octez_error_monad |> open_; - octez_crypto |> open_; + octez_crypto; octez_base |> open_; octez_hacl; octez_stdlib |> open_; diff --git a/src/lib_base/block_header.ml b/src/lib_base/block_header.ml index 60977443493f..792ba7381d8e 100644 --- a/src/lib_base/block_header.ml +++ b/src/lib_base/block_header.ml @@ -27,13 +27,13 @@ type shell_header = { level : Int32.t; proto_level : int; (* uint8 *) - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; validation_passes : int; (* uint8 *) - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; fitness : Fitness.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } let shell_header_encoding = @@ -84,12 +84,12 @@ let shell_header_encoding = (obj8 (req "level" int32) (req "proto" uint8) - (req "predecessor" Block_hash.encoding) + (req "predecessor" Tezos_crypto.Block_hash.encoding) (req "timestamp" Time.Protocol.encoding) (req "validation_pass" uint8) - (req "operations_hash" Operation_list_list_hash.encoding) + (req "operations_hash" Tezos_crypto.Operation_list_list_hash.encoding) (req "fitness" Fitness.encoding) - (req "context" Context_hash.encoding)) + (req "context" Tezos_crypto.Context_hash.encoding)) type t = {shell : shell_header; protocol_data : Bytes.t} @@ -105,9 +105,10 @@ include Compare.Make (struct | [], _ :: _ -> 1 | x :: xs, y :: ys -> compare x y >> fun () -> list compare xs ys in - Block_hash.compare b1.shell.predecessor b2.shell.predecessor >> fun () -> + Tezos_crypto.Block_hash.compare b1.shell.predecessor b2.shell.predecessor + >> fun () -> compare b1.protocol_data b2.protocol_data >> fun () -> - Operation_list_list_hash.compare + Tezos_crypto.Operation_list_list_hash.compare b1.shell.operations_hash b2.shell.operations_hash >> fun () -> @@ -145,15 +146,15 @@ let of_bytes b = Data_encoding.Binary.of_bytes_opt encoding b let of_bytes_exn b = Data_encoding.Binary.of_bytes_exn encoding b -let to_b58check v = Base58.safe_encode (to_string v) +let to_b58check v = Tezos_crypto.Base58.safe_encode (to_string v) let of_b58check b = - Option.bind (Base58.safe_decode b) (fun s -> + Option.bind (Tezos_crypto.Base58.safe_decode b) (fun s -> Data_encoding.Binary.of_string_opt encoding s) -let hash block = Block_hash.hash_bytes [to_bytes block] +let hash block = Tezos_crypto.Block_hash.hash_bytes [to_bytes block] -let hash_raw bytes = Block_hash.hash_bytes [bytes] +let hash_raw bytes = Tezos_crypto.Block_hash.hash_bytes [bytes] module LevelMap = Map.Make (struct type t = Int32.t @@ -172,7 +173,7 @@ let get_forced_protocol_upgrade ~user_activated_upgrades = let get_voted_protocol_overrides ~user_activated_protocol_overrides proto_hash = List.assoc_opt - ~equal:Protocol_hash.equal + ~equal:Tezos_crypto.Protocol_hash.equal proto_hash user_activated_protocol_overrides diff --git a/src/lib_base/block_header.mli b/src/lib_base/block_header.mli index 67b777f73e37..07903fc29c31 100644 --- a/src/lib_base/block_header.mli +++ b/src/lib_base/block_header.mli @@ -27,12 +27,12 @@ type shell_header = { level : Int32.t; (** Height of the block, from the genesis block. *) proto_level : int; (** Number (uint8) of protocol changes since genesis modulo 256. *) - predecessor : Block_hash.t; (** Hash of the preceding block. *) + predecessor : Tezos_crypto.Block_hash.t; (** Hash of the preceding block. *) timestamp : Time.Protocol.t; (** Timestamp at which the block is claimed to have been created. *) validation_passes : int; (** Number (uint8) of validation passes (also number of lists of operations). *) - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; (** Hash of the list of lists (actually root hashes of merkle trees) of operations included in the block. There is one list of operations per validation pass. *) @@ -40,7 +40,7 @@ type shell_header = { (** A sequence of sequences of unsigned bytes, ordered by length and then lexicographically. It represents the claimed fitness of the chain ending in this block. *) - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; (** Hash of the state of the context after application of this block. *) } @@ -48,7 +48,7 @@ val shell_header_encoding : shell_header Data_encoding.t type t = {shell : shell_header; protocol_data : Bytes.t} -include S.HASHABLE with type t := t and type hash := Block_hash.t +include S.HASHABLE with type t := t and type hash := Tezos_crypto.Block_hash.t val of_bytes_exn : Bytes.t -> t @@ -61,9 +61,9 @@ val bounded_encoding : ?max_size:int -> unit -> t Data_encoding.t val get_forced_protocol_upgrade : user_activated_upgrades:User_activated.upgrades -> level:Int32.t -> - Protocol_hash.t option + Tezos_crypto.Protocol_hash.t option val get_voted_protocol_overrides : user_activated_protocol_overrides:User_activated.protocol_overrides -> - Protocol_hash.t -> - Protocol_hash.t option + Tezos_crypto.Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t option diff --git a/src/lib_base/block_locator.ml b/src/lib_base/block_locator.ml index a47d59729c23..0cc57d2eacc5 100644 --- a/src/lib_base/block_locator.ml +++ b/src/lib_base/block_locator.ml @@ -25,9 +25,9 @@ (*****************************************************************************) type t = { - head_hash : Block_hash.t; + head_hash : Tezos_crypto.Block_hash.t; head_header : Block_header.t; - history : Block_hash.t list; + history : Tezos_crypto.Block_hash.t list; } let pp ppf {head_hash; history; _} = @@ -43,7 +43,7 @@ let pp ppf {head_hash; history; _} = Format.fprintf ppf "%a (%i)\n%a" - Block_hash.pp + Tezos_crypto.Block_hash.pp hd acc pp_hash_list @@ -52,7 +52,7 @@ let pp ppf {head_hash; history; _} = Format.fprintf ppf "%a (head)\n%a" - Block_hash.pp + Tezos_crypto.Block_hash.pp head_hash pp_hash_list (history, -1, 1, repeats - 1) @@ -61,7 +61,7 @@ let pp_short ppf {head_hash; history; _} = Format.fprintf ppf "head: %a, %d predecessors" - Block_hash.pp + Tezos_crypto.Block_hash.pp head_hash (List.length history) @@ -78,7 +78,7 @@ let encoding = encoding_inj (obj2 (req "current_head" (dynamic_size Block_header.encoding)) - (req "history" (Variable.list Block_hash.encoding))) + (req "history" (Variable.list Tezos_crypto.Block_hash.encoding))) let bounded_encoding ~max_header_size ~max_length () = let open Data_encoding in @@ -90,7 +90,9 @@ let bounded_encoding ~max_header_size ~max_length () = "current_head" (dynamic_size (Block_header.bounded_encoding ~max_size:max_header_size ()))) - (req "history" (Variable.list ~max_length Block_hash.encoding))) + (req + "history" + (Variable.list ~max_length Tezos_crypto.Block_hash.encoding))) type seed = {sender_id : P2p_peer.Id.t; receiver_id : P2p_peer.Id.t} @@ -106,7 +108,7 @@ type seed = {sender_id : P2p_peer.Id.t; receiver_id : P2p_peer.Id.t} module Step : sig type state - val init : seed -> Block_hash.t -> state + val init : seed -> Tezos_crypto.Block_hash.t -> state val next : state -> int * state end = struct @@ -114,22 +116,23 @@ end = struct The seed is stored in a bigstring and should be mlocked *) type state = Int32.t * int * Bytes.t - let update st b = Hacl.Hash.SHA256.update st b + let update st b = Tezos_crypto.Hacl.Hash.SHA256.update st b let init seed head = - let open Hacl.Hash in + let open Tezos_crypto.Hacl.Hash in let st = SHA256.init () in List.iter (update st) [ P2p_peer.Id.to_bytes seed.sender_id; P2p_peer.Id.to_bytes seed.receiver_id; - Block_hash.to_bytes head; + Tezos_crypto.Block_hash.to_bytes head; ] ; (1l, 9, SHA256.finish st) let draw seed n = - (Int32.rem (TzEndian.get_int32 seed 0) n, Hacl.Hash.SHA256.digest seed) + ( Int32.rem (TzEndian.get_int32 seed 0) n, + Tezos_crypto.Hacl.Hash.SHA256.digest seed ) let next (step, counter, seed) = let random_gap, seed = @@ -166,8 +169,8 @@ let fold ~f ~init {head_hash; history; _} seed = loop state init (head_hash :: history) type step = { - block : Block_hash.t; - predecessor : Block_hash.t; + block : Tezos_crypto.Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; step : int; strict_step : bool; } @@ -213,10 +216,11 @@ let compute ~get_predecessor ~caboose ~size head_hash head_header seed = let* o = get_predecessor current_block_hash step in match o with | None -> - if Block_hash.equal caboose current_block_hash then Lwt.return acc + if Tezos_crypto.Block_hash.equal caboose current_block_hash then + Lwt.return acc else Lwt.return (caboose :: acc) | Some predecessor -> - if Block_hash.equal predecessor current_block_hash then + if Tezos_crypto.Block_hash.equal predecessor current_block_hash then (* caboose or genesis reached *) Lwt.return acc else loop (predecessor :: acc) (pred size) state predecessor diff --git a/src/lib_base/block_locator.mli b/src/lib_base/block_locator.mli index edc0da693b27..7ace8b3296b7 100644 --- a/src/lib_base/block_locator.mli +++ b/src/lib_base/block_locator.mli @@ -54,9 +54,9 @@ (** Type for sparse block locators (/à la/ Bitcoin). *) type t = { - head_hash : Block_hash.t; + head_hash : Tezos_crypto.Block_hash.t; head_header : Block_header.t; - history : Block_hash.t list; + history : Tezos_crypto.Block_hash.t list; } val pp : Format.formatter -> t -> unit @@ -82,10 +82,11 @@ val estimated_length : seed -> t -> int sparse block. The sparse block locator contains at most [size + 1] elements, including the caboose. *) val compute : - get_predecessor:(Block_hash.t -> int -> Block_hash.t option Lwt.t) -> - caboose:Block_hash.t -> + get_predecessor: + (Tezos_crypto.Block_hash.t -> int -> Tezos_crypto.Block_hash.t option Lwt.t) -> + caboose:Tezos_crypto.Block_hash.t -> size:int -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> seed -> t Lwt.t @@ -94,8 +95,8 @@ val compute : locator, and the expected difference of level between the two blocks (or an upper bounds when [strict_step = false]). *) type step = { - block : Block_hash.t; - predecessor : Block_hash.t; + block : Tezos_crypto.Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; step : int; strict_step : bool; } @@ -115,7 +116,7 @@ val to_steps : seed -> t -> step list [predecessor] of the last step as [save_point] and its field [strict] to [false]. *) val to_steps_truncate : - limit:int -> save_point:Block_hash.t -> seed -> t -> step list + limit:int -> save_point:Tezos_crypto.Block_hash.t -> seed -> t -> step list (** A block can either be known valid, invalid or unknown. *) type validity = Unknown | Known_valid | Known_invalid @@ -135,4 +136,6 @@ type validity = Unknown | Known_valid | Known_invalid - [(Unknown, (h, hist))] when no block is known valid nor invalid (w.r.t. [is_known]), where [(h, hist)] is the given [locator]. *) val unknown_prefix : - is_known:(Block_hash.t -> validity Lwt.t) -> t -> (validity * t) Lwt.t + is_known:(Tezos_crypto.Block_hash.t -> validity Lwt.t) -> + t -> + (validity * t) Lwt.t diff --git a/src/lib_base/dune b/src/lib_base/dune index 999f72e627b9..21c08c1a527c 100644 --- a/src/lib_base/dune +++ b/src/lib_base/dune @@ -25,7 +25,6 @@ (flags (:standard) -open Tezos_stdlib - -open Tezos_crypto -open Data_encoding -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib diff --git a/src/lib_base/genesis.ml b/src/lib_base/genesis.ml index 1145b8b14442..dfaf5f5ac71f 100644 --- a/src/lib_base/genesis.ml +++ b/src/lib_base/genesis.ml @@ -1,8 +1,8 @@ (** The chain starts from a genesis block associated to a seed protocol *) type t = { time : Time.Protocol.t; - block : Block_hash.t; - protocol : Protocol_hash.t; + block : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; } let encoding = @@ -12,8 +12,8 @@ let encoding = (fun (time, block, protocol) -> {time; block; protocol}) (obj3 (req "timestamp" Time.Protocol.encoding) - (req "block" Block_hash.encoding) - (req "protocol" Protocol_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding)) let pp ppf genesis = Data_encoding.Json.pp ppf (Data_encoding.Json.construct encoding genesis) diff --git a/src/lib_base/genesis.mli b/src/lib_base/genesis.mli index 2710ef443ef6..ed3d911a3670 100644 --- a/src/lib_base/genesis.mli +++ b/src/lib_base/genesis.mli @@ -1,8 +1,8 @@ (** The chain starts from a genesis block associated to a seed protocol *) type t = { time : Time.Protocol.t; - block : Block_hash.t; - protocol : Protocol_hash.t; + block : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; } val encoding : t Data_encoding.t diff --git a/src/lib_base/mempool.ml b/src/lib_base/mempool.ml index 7780a5332b43..5aec011c52c1 100644 --- a/src/lib_base/mempool.ml +++ b/src/lib_base/mempool.ml @@ -23,7 +23,10 @@ (* *) (*****************************************************************************) -type t = {known_valid : Operation_hash.t list; pending : Operation_hash.Set.t} +type t = { + known_valid : Tezos_crypto.Operation_hash.t list; + pending : Tezos_crypto.Operation_hash.Set.t; +} type mempool = t @@ -38,27 +41,31 @@ let encoding = (fun {known_valid; pending} -> (known_valid, pending)) (fun (known_valid, pending) -> {known_valid; pending}) (obj2 - (req "known_valid" (list Operation_hash.encoding)) - (req "pending" (dynamic_size Operation_hash.Set.encoding))) + (req "known_valid" (list Tezos_crypto.Operation_hash.encoding)) + (req + "pending" + (dynamic_size Tezos_crypto.Operation_hash.Set.encoding))) let bounded_encoding ?max_operations () = match max_operations with | None -> encoding | Some max_operations -> Data_encoding.check_size - (8 + (max_operations * Operation_hash.size)) + (8 + (max_operations * Tezos_crypto.Operation_hash.size)) encoding -let empty = {known_valid = []; pending = Operation_hash.Set.empty} +let empty = {known_valid = []; pending = Tezos_crypto.Operation_hash.Set.empty} let is_empty {known_valid; pending} = - known_valid = [] && Operation_hash.Set.is_empty pending + known_valid = [] && Tezos_crypto.Operation_hash.Set.is_empty pending let remove oph {known_valid; pending} = { known_valid = - List.filter (fun x -> not (Operation_hash.equal x oph)) known_valid; - pending = Operation_hash.Set.remove oph pending; + List.filter + (fun x -> not (Tezos_crypto.Operation_hash.equal x oph)) + known_valid; + pending = Tezos_crypto.Operation_hash.Set.remove oph pending; } let cons_valid oph t = {t with known_valid = oph :: t.known_valid} diff --git a/src/lib_base/mempool.mli b/src/lib_base/mempool.mli index ae0caffd0376..7eecaec22964 100644 --- a/src/lib_base/mempool.mli +++ b/src/lib_base/mempool.mli @@ -26,9 +26,10 @@ (** Tezos Shell Module - Mempool, a.k.a. the operations safe to be broadcast. *) type t = { - known_valid : Operation_hash.t list; + known_valid : Tezos_crypto.Operation_hash.t list; (** A valid sequence of operations on top of the current head. *) - pending : Operation_hash.Set.t; (** Set of known not-invalid operation. *) + pending : Tezos_crypto.Operation_hash.Set.t; + (** Set of known not-invalid operation. *) } type mempool = t @@ -44,7 +45,7 @@ val empty : mempool val is_empty : mempool -> bool (** [cons_valid oph t] prepends [oph] to the [known_valid] field of [t]. *) -val cons_valid : Operation_hash.t -> mempool -> mempool +val cons_valid : Tezos_crypto.Operation_hash.t -> mempool -> mempool (** Remove an operation from all the fields of a mempool. *) -val remove : Operation_hash.t -> mempool -> mempool +val remove : Tezos_crypto.Operation_hash.t -> mempool -> mempool diff --git a/src/lib_base/operation.ml b/src/lib_base/operation.ml index bc37a3282c5f..7654a800dc99 100644 --- a/src/lib_base/operation.ml +++ b/src/lib_base/operation.ml @@ -23,9 +23,10 @@ (* *) (*****************************************************************************) -type shell_header = {branch : Block_hash.t} +type shell_header = {branch : Tezos_crypto.Block_hash.t} -let equal_shell_header {branch = b1} {branch = b2} = Block_hash.equal b1 b2 +let equal_shell_header {branch = b1} {branch = b2} = + Tezos_crypto.Block_hash.equal b1 b2 let shell_header_encoding = let open Data_encoding in @@ -33,7 +34,7 @@ let shell_header_encoding = @@ conv (fun {branch} -> branch) (fun branch -> {branch}) - (obj1 (req "branch" Block_hash.encoding)) + (obj1 (req "branch" Tezos_crypto.Block_hash.encoding)) type t = {shell : shell_header; proto : Bytes.t} @@ -42,7 +43,7 @@ include Compare.Make (struct let compare o1 o2 = Compare.or_else - (Block_hash.compare o1.shell.branch o2.shell.branch) + (Tezos_crypto.Block_hash.compare o1.shell.branch o2.shell.branch) (fun () -> Bytes.compare o1.proto o2.proto) end) @@ -79,7 +80,9 @@ let bounded_list_encoding ?max_length ?max_size ?max_operation_size ?max_pass () obj2 (req "operation_hashes_path" - (Operation_list_list_hash.bounded_path_encoding ?max_length:max_pass ())) + (Tezos_crypto.Operation_list_list_hash.bounded_path_encoding + ?max_length:max_pass + ())) (req "operations" op_list_encoding) let bounded_hash_list_encoding ?max_length ?max_pass () = @@ -87,8 +90,12 @@ let bounded_hash_list_encoding ?max_length ?max_pass () = obj2 (req "operation_hashes_path" - (Operation_list_list_hash.bounded_path_encoding ?max_length:max_pass ())) - (req "operation_hashes" (Variable.list ?max_length Operation_hash.encoding)) + (Tezos_crypto.Operation_list_list_hash.bounded_path_encoding + ?max_length:max_pass + ())) + (req + "operation_hashes" + (Variable.list ?max_length Tezos_crypto.Operation_hash.encoding)) let pp fmt op = Data_encoding.Json.pp fmt (Data_encoding.Json.construct encoding op) @@ -99,9 +106,9 @@ let of_bytes b = Data_encoding.Binary.of_bytes_opt encoding b let of_bytes_exn b = Data_encoding.Binary.of_bytes_exn encoding b -let hash op = Operation_hash.hash_bytes [to_bytes op] +let hash op = Tezos_crypto.Operation_hash.hash_bytes [to_bytes op] -let hash_raw bytes = Operation_hash.hash_bytes [bytes] +let hash_raw bytes = Tezos_crypto.Operation_hash.hash_bytes [bytes] let () = Data_encoding.Registration.register ~pp encoding ; diff --git a/src/lib_base/operation.mli b/src/lib_base/operation.mli index e80583583438..54b75685215b 100644 --- a/src/lib_base/operation.mli +++ b/src/lib_base/operation.mli @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type shell_header = {branch : Block_hash.t} +type shell_header = {branch : Tezos_crypto.Block_hash.t} val equal_shell_header : shell_header -> shell_header -> bool @@ -31,7 +31,8 @@ val shell_header_encoding : shell_header Data_encoding.t type t = {shell : shell_header; proto : Bytes.t} -include S.HASHABLE with type t := t and type hash := Operation_hash.t +include + S.HASHABLE with type t := t and type hash := Tezos_crypto.Operation_hash.t val of_bytes_exn : Bytes.t -> t @@ -43,10 +44,12 @@ val bounded_list_encoding : ?max_operation_size:int -> ?max_pass:int -> unit -> - (Operation_list_list_hash.path * t list) Data_encoding.t + (Tezos_crypto.Operation_list_list_hash.path * t list) Data_encoding.t val bounded_hash_list_encoding : ?max_length:int -> ?max_pass:int -> unit -> - (Operation_list_list_hash.path * Operation_hash.t list) Data_encoding.t + (Tezos_crypto.Operation_list_list_hash.path + * Tezos_crypto.Operation_hash.t list) + Data_encoding.t diff --git a/src/lib_base/p2p_identity.ml b/src/lib_base/p2p_identity.ml index 27898bf52ca9..7d8d2298d2c2 100644 --- a/src/lib_base/p2p_identity.ml +++ b/src/lib_base/p2p_identity.ml @@ -25,9 +25,9 @@ type t = { peer_id : P2p_peer.Id.t; - public_key : Crypto_box.public_key; - secret_key : Crypto_box.secret_key; - proof_of_work_stamp : Crypto_box.nonce; + public_key : Tezos_crypto.Crypto_box.public_key; + secret_key : Tezos_crypto.Crypto_box.secret_key; + proof_of_work_stamp : Tezos_crypto.Crypto_box.nonce; } let encoding = @@ -49,15 +49,21 @@ let encoding = {peer_id; public_key; secret_key; proof_of_work_stamp}) (obj4 (opt "peer_id" P2p_peer_id.encoding) - (req "public_key" Crypto_box.public_key_encoding) - (req "secret_key" Crypto_box.secret_key_encoding) - (req "proof_of_work_stamp" Crypto_box.nonce_encoding)) + (req "public_key" Tezos_crypto.Crypto_box.public_key_encoding) + (req "secret_key" Tezos_crypto.Crypto_box.secret_key_encoding) + (req "proof_of_work_stamp" Tezos_crypto.Crypto_box.nonce_encoding)) let generate_with_bound ?yield_every ?max pow_target = let open Error_monad.Lwt_syntax in - let secret_key, public_key, peer_id = Crypto_box.random_keypair () in + let secret_key, public_key, peer_id = + Tezos_crypto.Crypto_box.random_keypair () + in let+ proof_of_work_stamp = - Crypto_box.generate_proof_of_work ?yield_every ?max public_key pow_target + Tezos_crypto.Crypto_box.generate_proof_of_work + ?yield_every + ?max + public_key + pow_target in {peer_id; public_key; secret_key; proof_of_work_stamp} @@ -65,9 +71,11 @@ let generate ?yield_every pow_target = generate_with_bound ?yield_every pow_target let generate_with_pow_target_0 () = - let secret_key, public_key, peer_id = Crypto_box.random_keypair () in + let secret_key, public_key, peer_id = + Tezos_crypto.Crypto_box.random_keypair () + in let proof_of_work_stamp = - Crypto_box.generate_proof_of_work_with_target_0 public_key + Tezos_crypto.Crypto_box.generate_proof_of_work_with_target_0 public_key in {peer_id; public_key; secret_key; proof_of_work_stamp} diff --git a/src/lib_base/p2p_identity.mli b/src/lib_base/p2p_identity.mli index c99811fe8789..3d683def5e9f 100644 --- a/src/lib_base/p2p_identity.mli +++ b/src/lib_base/p2p_identity.mli @@ -28,9 +28,9 @@ accept this identity as genuine. *) type t = { peer_id : P2p_peer.Id.t; - public_key : Crypto_box.public_key; - secret_key : Crypto_box.secret_key; - proof_of_work_stamp : Crypto_box.nonce; + public_key : Tezos_crypto.Crypto_box.public_key; + secret_key : Tezos_crypto.Crypto_box.secret_key; + proof_of_work_stamp : Tezos_crypto.Crypto_box.nonce; } val encoding : t Data_encoding.t @@ -40,7 +40,7 @@ val encoding : t Data_encoding.t The argument [yield_every] (defaults to [500]) introduces a call to [Lwt.pause] every that many operations. *) -val generate : ?yield_every:int -> Crypto_box.pow_target -> t Lwt.t +val generate : ?yield_every:int -> Tezos_crypto.Crypto_box.pow_target -> t Lwt.t (** [generate_with_bound pow_target] is a freshly minted identity whose proof of work stamp difficulty is at least equal to [pow_target]. @@ -49,7 +49,7 @@ val generate : ?yield_every:int -> Crypto_box.pow_target -> t Lwt.t attempts are made without finding a successful pow, the function fails with [Not_found]. *) val generate_with_bound : - ?yield_every:int -> ?max:int -> Crypto_box.pow_target -> t Lwt.t + ?yield_every:int -> ?max:int -> Tezos_crypto.Crypto_box.pow_target -> t Lwt.t (** [generate_with_pow_target_0 pk] generates a proof of work for the public key [pk] following a (hard-coded) 0 proof-of-work target. diff --git a/src/lib_base/p2p_peer_id.ml b/src/lib_base/p2p_peer_id.ml index 0708085a080f..9acee9dbe64e 100644 --- a/src/lib_base/p2p_peer_id.ml +++ b/src/lib_base/p2p_peer_id.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -include Crypto_box.Public_key_hash +include Tezos_crypto.Crypto_box.Public_key_hash let rpc_arg = Tezos_rpc.Arg.like diff --git a/src/lib_base/p2p_peer_id.mli b/src/lib_base/p2p_peer_id.mli index c39a0ab8efe3..47d585ba83fe 100644 --- a/src/lib_base/p2p_peer_id.mli +++ b/src/lib_base/p2p_peer_id.mli @@ -23,4 +23,5 @@ (* *) (*****************************************************************************) -include Tezos_crypto.S.HASH with type t = Crypto_box.Public_key_hash.t +include + Tezos_crypto.S.HASH with type t = Tezos_crypto.Crypto_box.Public_key_hash.t diff --git a/src/lib_base/protocol.ml b/src/lib_base/protocol.ml index 7d48f919b72f..fe503d15e12e 100644 --- a/src/lib_base/protocol.ml +++ b/src/lib_base/protocol.ml @@ -142,13 +142,13 @@ let of_bytes_exn b = Data_encoding.Binary.of_bytes_exn encoding b let of_string_exn b = Data_encoding.Binary.of_string_exn encoding b -let hash proto = Protocol_hash.hash_bytes [to_bytes proto] +let hash proto = Tezos_crypto.Protocol_hash.hash_bytes [to_bytes proto] -let hash_raw proto = Protocol_hash.hash_bytes [proto] +let hash_raw proto = Tezos_crypto.Protocol_hash.hash_bytes [proto] module Meta = struct type t = { - hash : Protocol_hash.t option; + hash : Tezos_crypto.Protocol_hash.t option; expected_env_version : env_version option; modules : string list; } @@ -169,7 +169,7 @@ module Meta = struct (opt "hash" ~description:"Used to force the hash of the protocol" - Protocol_hash.encoding) + Tezos_crypto.Protocol_hash.encoding) (opt "expected_env_version" env_version_encoding) (req "modules" diff --git a/src/lib_base/protocol.mli b/src/lib_base/protocol.mli index 4325574c7895..5963f8b90faa 100644 --- a/src/lib_base/protocol.mli +++ b/src/lib_base/protocol.mli @@ -50,7 +50,8 @@ val env_version_encoding : env_version Data_encoding.t val pp_ocaml : Format.formatter -> t -> unit -include S.HASHABLE with type t := t and type hash := Protocol_hash.t +include + S.HASHABLE with type t := t and type hash := Tezos_crypto.Protocol_hash.t val of_bytes_exn : Bytes.t -> t @@ -64,7 +65,7 @@ val module_name_of_env_version : env_version -> string module Meta : sig type t = { - hash : Protocol_hash.t option; + hash : Tezos_crypto.Protocol_hash.t option; expected_env_version : env_version option; modules : string list; } diff --git a/src/lib_base/test_chain_status.ml b/src/lib_base/test_chain_status.ml index f6cdf41a7974..ff3620bb8ae1 100644 --- a/src/lib_base/test_chain_status.ml +++ b/src/lib_base/test_chain_status.ml @@ -25,11 +25,14 @@ type t = | Not_running - | Forking of {protocol : Protocol_hash.t; expiration : Time.Protocol.t} + | Forking of { + protocol : Tezos_crypto.Protocol_hash.t; + expiration : Time.Protocol.t; + } | Running of { - chain_id : Chain_id.t; - genesis : Block_hash.t; - protocol : Protocol_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + genesis : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; expiration : Time.Protocol.t; } @@ -54,7 +57,7 @@ let encoding = ~title:"Forking" (obj3 (req "status" (constant "forking")) - (req "protocol" Protocol_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) (req "expiration" Time.Protocol.encoding)) (function | Forking {protocol; expiration} -> Some ((), protocol, expiration) @@ -65,9 +68,9 @@ let encoding = ~title:"Running" (obj5 (req "status" (constant "running")) - (req "chain_id" Chain_id.encoding) - (req "genesis" Block_hash.encoding) - (req "protocol" Protocol_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "genesis" Tezos_crypto.Block_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) (req "expiration" Time.Protocol.encoding)) (function | Running {chain_id; genesis; protocol; expiration} -> @@ -83,7 +86,7 @@ let pp ppf = function Format.fprintf ppf "@[Forking %a (expires %a)@]" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol Time.System.pp_hum (Time.System.of_protocol_exn expiration) @@ -91,11 +94,11 @@ let pp ppf = function Format.fprintf ppf "@[Running %a@ Genesis: %a@ Net id: %a@ Expiration: %a@]" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol - Block_hash.pp + Tezos_crypto.Block_hash.pp genesis - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id Time.System.pp_hum (Time.System.of_protocol_exn expiration) diff --git a/src/lib_base/test_chain_status.mli b/src/lib_base/test_chain_status.mli index c4a873600db1..d01bfe8baa2b 100644 --- a/src/lib_base/test_chain_status.mli +++ b/src/lib_base/test_chain_status.mli @@ -25,11 +25,14 @@ type t = | Not_running - | Forking of {protocol : Protocol_hash.t; expiration : Time.Protocol.t} + | Forking of { + protocol : Tezos_crypto.Protocol_hash.t; + expiration : Time.Protocol.t; + } | Running of { - chain_id : Chain_id.t; - genesis : Block_hash.t; - protocol : Protocol_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + genesis : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; expiration : Time.Protocol.t; } diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index 66a69fe7646c..c50349f1a1cd 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -25,7 +25,6 @@ include Tezos_stdlib module Error_monad = Tezos_error_monad.Error_monad -include Tezos_crypto include Tezos_micheline module Data_encoding = Data_encoding include Tezos_error_monad.TzLwtreslib diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index 8bf4e9ec28c1..ddfd7baeb794 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -28,9 +28,6 @@ include module type of struct end module Error_monad = Tezos_error_monad.Error_monad - -include module type of Tezos_crypto - module Data_encoding = Data_encoding (** The following modules are part of [TzLwtreslib]. We just remove diff --git a/src/lib_base/unix/dune b/src/lib_base/unix/dune index e46577c92752..3bcd6d4eb8e0 100644 --- a/src/lib_base/unix/dune +++ b/src/lib_base/unix/dune @@ -17,7 +17,6 @@ (flags (:standard) -open Tezos_error_monad - -open Tezos_crypto -open Tezos_base -open Tezos_stdlib -open Tezos_stdlib_unix diff --git a/src/lib_base/unix/protocol_files.mli b/src/lib_base/unix/protocol_files.mli index c7830a1ace57..91ae5a57a959 100644 --- a/src/lib_base/unix/protocol_files.mli +++ b/src/lib_base/unix/protocol_files.mli @@ -1,6 +1,10 @@ open Error_monad -val read_dir : string -> (Protocol_hash.t option * Protocol.t) tzresult Lwt.t +val read_dir : + string -> (Tezos_crypto.Protocol_hash.t option * Protocol.t) tzresult Lwt.t val write_dir : - string -> ?hash:Protocol_hash.t -> Protocol.t -> unit tzresult Lwt.t + string -> + ?hash:Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + unit tzresult Lwt.t diff --git a/src/lib_base/user_activated.ml b/src/lib_base/user_activated.ml index a9c4a5df331d..bfdbd1f4df83 100644 --- a/src/lib_base/user_activated.ml +++ b/src/lib_base/user_activated.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type upgrades = (Int32.t * Protocol_hash.t) list +type upgrades = (Int32.t * Tezos_crypto.Protocol_hash.t) list let upgrades_encoding = let open Data_encoding in @@ -35,9 +35,10 @@ let upgrades_encoding = (list (obj2 (req "level" int32) - (req "replacement_protocol" Protocol_hash.encoding))) + (req "replacement_protocol" Tezos_crypto.Protocol_hash.encoding))) -type protocol_overrides = (Protocol_hash.t * Protocol_hash.t) list +type protocol_overrides = + (Tezos_crypto.Protocol_hash.t * Tezos_crypto.Protocol_hash.t) list let protocol_overrides_encoding = let open Data_encoding in @@ -49,8 +50,8 @@ let protocol_overrides_encoding = another." @@ list (obj2 - (req "replaced_protocol" Protocol_hash.encoding) - (req "replacement_protocol" Protocol_hash.encoding)) + (req "replaced_protocol" Tezos_crypto.Protocol_hash.encoding) + (req "replacement_protocol" Tezos_crypto.Protocol_hash.encoding)) let () = Data_encoding.Registration.register upgrades_encoding ; diff --git a/src/lib_base/user_activated.mli b/src/lib_base/user_activated.mli index 48d6f4b226fd..8daffbdcdba1 100644 --- a/src/lib_base/user_activated.mli +++ b/src/lib_base/user_activated.mli @@ -24,7 +24,7 @@ (*****************************************************************************) (** User activated upgrades: at given level, switch to given protocol. *) -type upgrades = (Int32.t * Protocol_hash.t) list +type upgrades = (Int32.t * Tezos_crypto.Protocol_hash.t) list val upgrades_encoding : upgrades Data_encoding.t @@ -32,6 +32,7 @@ val upgrades_encoding : upgrades Data_encoding.t An override [(a, b)] denotes that if [a] is to be activated at the end of the promotion phase, [b] shall be activated instead. *) -type protocol_overrides = (Protocol_hash.t * Protocol_hash.t) list +type protocol_overrides = + (Tezos_crypto.Protocol_hash.t * Tezos_crypto.Protocol_hash.t) list val protocol_overrides_encoding : protocol_overrides Data_encoding.t -- GitLab From 24a1900fdc72b516368786d1c123c96bff0eb6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 17:42:17 +0200 Subject: [PATCH 02/30] Sapling: unopen Crypto --- manifest/main.ml | 4 +- src/lib_sapling/core.ml | 80 +++++++++++++++++----------- src/lib_sapling/core_sig.ml | 4 +- src/lib_sapling/dune | 1 - src/lib_sapling/forge.ml | 4 +- src/lib_sapling/test/dune | 1 - src/lib_sapling/test/test_merkle.ml | 8 ++- src/lib_sapling/test/test_roots.ml | 4 +- src/lib_sapling/test/test_sapling.ml | 12 ++--- 9 files changed, 69 insertions(+), 49 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index af3693c5d0d2..bc3b8919bcdd 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1795,7 +1795,7 @@ let octez_sapling = ctypes_stubs_js; data_encoding; octez_stdlib |> open_; - octez_crypto |> open_; + octez_crypto; octez_error_monad |> open_ |> open_ ~m:"TzLwtreslib"; tezos_rust_lib; octez_lwt_result_stdlib; @@ -1849,7 +1849,7 @@ let _octez_sapling_tests = ~deps: [ octez_sapling |> open_; - octez_crypto |> open_; + octez_crypto; str; octez_base; octez_base_unix; diff --git a/src/lib_sapling/core.ml b/src/lib_sapling/core.ml index d0e067927fab..ccb8274b2f02 100644 --- a/src/lib_sapling/core.ml +++ b/src/lib_sapling/core.ml @@ -96,19 +96,20 @@ module Raw = struct (req "expsk" expsk_encoding) (req "dk" (Fixed.bytes 32))) - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t let b58check_encoding = let to_raw sk = Bytes.to_string @@ to_bytes sk in let of_raw str = of_bytes (Bytes.of_string str) in - Base58.register_encoding - ~prefix:Base58.Prefix.sapling_spending_key + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.sapling_spending_key ~length:169 ~to_raw ~of_raw ~wrap:(fun x -> Data x) - let () = Base58.check_encoded_prefix b58check_encoding "sask" 241 + let () = + Tezos_crypto.Base58.check_encoded_prefix b58check_encoding "sask" 241 let of_seed = R.zip32_xsk_master @@ -259,7 +260,7 @@ module Raw = struct (req "diversifier" diversifier_encoding) (req "pkd" (Fixed.bytes 32))) - type Base58.data += Data of address + type Tezos_crypto.Base58.data += Data of address let address_b58check_encoding = let to_raw address = @@ -268,14 +269,18 @@ module Raw = struct let of_raw str = Data_encoding.Binary.of_string_opt address_encoding str in - Base58.register_encoding - ~prefix:Base58.Prefix.sapling_address + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.sapling_address ~length:43 ~to_raw ~of_raw ~wrap:(fun x -> Data x) - let () = Base58.check_encoded_prefix address_b58check_encoding "zet1" 69 + let () = + Tezos_crypto.Base58.check_encoded_prefix + address_b58check_encoding + "zet1" + 69 let new_address vk j = match R.zip32_xfvk_address vk j with @@ -289,7 +294,7 @@ module Raw = struct (* NOTE: the density of valid diversifiers is roughly half. This loop is likely to be short. *) let rec random_diversifier () = - match R.to_diversifier @@ Hacl.Rand.gen 11 with + match R.to_diversifier @@ Tezos_crypto.Hacl.Rand.gen 11 with | Some diversifier -> diversifier | None -> random_diversifier () in @@ -298,7 +303,7 @@ module Raw = struct endian). As ivk is encoded in little endian, we apply the mask on the last byte. *) - let rand = Hacl.Rand.gen 32 in + let rand = Tezos_crypto.Hacl.Rand.gen 32 in let mask = 0b00000111 in let int = Char.code @@ Bytes.get rand (32 - 1) in let int_masked = int land mask in @@ -338,26 +343,30 @@ module Raw = struct let symkey = Bytes.unsafe_to_string @@ R.of_symkey @@ R.ka_agree_sender pkd esk in - let hash = Blake2B.(to_bytes @@ hash_string ~key:kdf_key [symkey]) in - Crypto_box.Secretbox.unsafe_of_bytes hash + let hash = + Tezos_crypto.Blake2B.(to_bytes @@ hash_string ~key:kdf_key [symkey]) + in + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes hash let symkey_receiver epk ivk = let symkey = Bytes.unsafe_to_string @@ R.of_symkey @@ R.ka_agree_receiver epk ivk in - let hash = Blake2B.(to_bytes @@ hash_string ~key:kdf_key [symkey]) in - Crypto_box.Secretbox.unsafe_of_bytes hash + let hash = + Tezos_crypto.Blake2B.(to_bytes @@ hash_string ~key:kdf_key [symkey]) + in + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes hash let symkey_out ovk (cv, cm, epk) = let key = Bytes.of_string "OCK_keystringderivation_TEZOS" in let ock = - Blake2B.( + Tezos_crypto.Blake2B.( to_bytes (hash_bytes ~key [R.of_cv cv; R.of_commitment cm; R.of_epk epk; R.of_ovk ovk])) in - Crypto_box.Secretbox.unsafe_of_bytes ock + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes ock end module Rcm = struct @@ -441,12 +450,12 @@ module Raw = struct memo *) payload_enc : Bytes.t; (* nonce for the authenticated encryption of payload_enc *) - nonce_enc : Crypto_box.nonce; + nonce_enc : Tezos_crypto.Crypto_box.nonce; (* authenticated encryption of pkd and esk, allows to recover the symkey with symkey_sender *) payload_out : Bytes.t; (* nonce for the authenticated encryption of payload_out *) - nonce_out : Crypto_box.nonce; + nonce_out : Tezos_crypto.Crypto_box.nonce; } let encoding = @@ -457,7 +466,7 @@ module Raw = struct @@ fixed_length DH.esk_encoding) + (WithExceptions.Option.get ~loc:__LOC__ @@ fixed_length DH.epk_encoding) - + Crypto_box.tag_length) + + Tezos_crypto.Crypto_box.tag_length) in def "sapling.transaction.ciphertext" @@ conv @@ -474,9 +483,9 @@ module Raw = struct (req "cv" CV.encoding) (req "epk" DH.epk_encoding) (req "payload_enc" bytes) - (req "nonce_enc" Crypto_box.nonce_encoding) + (req "nonce_enc" Tezos_crypto.Crypto_box.nonce_encoding) (req "payload_out" (Fixed.bytes payload_out_size)) - (req "nonce_out" Crypto_box.nonce_encoding)) + (req "nonce_out" Tezos_crypto.Crypto_box.nonce_encoding)) type plaintext = { diversifier : Viewing_key.diversifier; @@ -514,7 +523,7 @@ module Raw = struct + (WithExceptions.Option.get ~loc:__LOC__ @@ Binary.fixed_length int64) + (WithExceptions.Option.get ~loc:__LOC__ @@ Binary.fixed_length Rcm.encoding) - + Crypto_box.tag_length + 4 + + Tezos_crypto.Crypto_box.tag_length + 4 in payload_size - size_besides_memo @@ -528,7 +537,7 @@ module Raw = struct let encrypt_aux key_agreed_out amount address rcm memo esk cv = let epk = DH.derive_ephemeral address esk in - let nonce_enc = Crypto_box.random_nonce () in + let nonce_enc = Tezos_crypto.Crypto_box.random_nonce () in let payload_enc = let key_agreed_enc = DH.symkey_sender esk address.pkd in let plaintext_enc = @@ -536,14 +545,20 @@ module Raw = struct plaintext_encoding {diversifier = Viewing_key.(address.diversifier); amount; rcm; memo} in - Crypto_box.Secretbox.secretbox key_agreed_enc plaintext_enc nonce_enc + Tezos_crypto.Crypto_box.Secretbox.secretbox + key_agreed_enc + plaintext_enc + nonce_enc in - let nonce_out = Crypto_box.random_nonce () in + let nonce_out = Tezos_crypto.Crypto_box.random_nonce () in let payload_out = let plaintext_out = Bytes.cat (R.of_pkd Viewing_key.(address.pkd)) (R.of_esk esk) in - Crypto_box.Secretbox.secretbox key_agreed_out plaintext_out nonce_out + Tezos_crypto.Crypto_box.Secretbox.secretbox + key_agreed_out + plaintext_out + nonce_out in {epk; payload_enc; nonce_enc; payload_out; nonce_out; cv} @@ -557,7 +572,8 @@ module Raw = struct output *) let encrypt_without_ovk amount address rcm memo esk cv = let key_agreed_out = - Crypto_box.Secretbox.unsafe_of_bytes @@ Hacl.Rand.gen 32 + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes + @@ Tezos_crypto.Hacl.Rand.gen 32 in encrypt_aux key_agreed_out amount address rcm memo esk cv @@ -568,7 +584,7 @@ module Raw = struct let ivk = Viewing_key.to_ivk xfvk in let symkey = DH.symkey_receiver ciphertext.epk ivk in let ( >?? ) = Option.bind in - Crypto_box.Secretbox.secretbox_open + Tezos_crypto.Crypto_box.Secretbox.secretbox_open symkey ciphertext.payload_enc ciphertext.nonce_enc @@ -585,7 +601,7 @@ module Raw = struct (* symkey for payload_out *) let symkey = DH.symkey_out ovk (ciphertext.cv, cm, epk) in let ( >?? ) = Option.bind in - Crypto_box.Secretbox.secretbox_open + Tezos_crypto.Crypto_box.Secretbox.secretbox_open symkey ciphertext.payload_out ciphertext.nonce_out @@ -593,7 +609,7 @@ module Raw = struct let pkd, esk = decompose_plaintext_out plaintext in (* symkey for payload_enc *) let symkey = DH.symkey_sender esk pkd in - Crypto_box.Secretbox.secretbox_open + Tezos_crypto.Crypto_box.Secretbox.secretbox_open symkey ciphertext.payload_enc ciphertext.nonce_enc @@ -649,7 +665,7 @@ module Raw = struct let hash_input cv nf rk proof key_string = let key = Bytes.of_string key_string in let h = - Blake2B.( + Tezos_crypto.Blake2B.( to_bytes (hash_bytes ~key @@ -739,7 +755,7 @@ module Raw = struct List.map (Data_encoding.Binary.to_string_exn output_encoding) outputs in let h = - Blake2B.( + Tezos_crypto.Blake2B.( to_bytes (hash_string ~key (input_bytes @ output_bytes @ [bound_data]))) in diff --git a/src/lib_sapling/core_sig.ml b/src/lib_sapling/core_sig.ml index 56c27d20ac3d..bb994cd12429 100644 --- a/src/lib_sapling/core_sig.ml +++ b/src/lib_sapling/core_sig.ml @@ -84,7 +84,7 @@ module type Spending_key = sig (** Returns the next available index from a key **) val child_index : t -> int32 - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end (** Viewing keys allow to see incoming and outgoing transactions without @@ -125,7 +125,7 @@ module type Viewing_key = sig val address_encoding : address Data_encoding.t - val address_b58check_encoding : address Base58.encoding + val address_b58check_encoding : address Tezos_crypto.Base58.encoding (** Returns a new address and a new index to be used for the next address generation. **) diff --git a/src/lib_sapling/dune b/src/lib_sapling/dune index 33e0912d7a87..2b9107077673 100644 --- a/src/lib_sapling/dune +++ b/src/lib_sapling/dune @@ -21,7 +21,6 @@ (flags (:standard) -open Tezos_stdlib - -open Tezos_crypto -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib) (foreign_stubs diff --git a/src/lib_sapling/forge.ml b/src/lib_sapling/forge.ml index 12a07c28a4e4..fc0c1afafa8f 100644 --- a/src/lib_sapling/forge.ml +++ b/src/lib_sapling/forge.ml @@ -71,7 +71,7 @@ let make_output address amount memo = Core.Forge.Output.{address; amount; memo} let dummy_input anti_replay ctx dummy_witness root = let rcm = Core.Rcm.random () in - let seed = Hacl.Rand.gen 32 in + let seed = Tezos_crypto.Hacl.Rand.gen 32 in let sk = Core.Spending_key.of_seed seed in let vk = Core.Viewing_key.of_sk sk in let addr = Core.Viewing_key.dummy_address () in @@ -112,7 +112,7 @@ let create_dummy_inputs n state anti_replay ctx = let dummy_output pctx ~memo_size = let addr = Core.Viewing_key.dummy_address () in let amount = 0L in - let o = make_output addr amount (Hacl.Rand.gen memo_size) in + let o = make_output addr amount (Tezos_crypto.Hacl.Rand.gen memo_size) in let rcm = Core.Rcm.random () in let esk = Core.DH.esk_random () in let cv_o, proof_o = Core.Proving.output_proof pctx esk addr rcm ~amount in diff --git a/src/lib_sapling/test/dune b/src/lib_sapling/test/dune index 19028be5b4a5..cbda583e54d6 100644 --- a/src/lib_sapling/test/dune +++ b/src/lib_sapling/test/dune @@ -19,7 +19,6 @@ (flags (:standard) -open Tezos_sapling - -open Tezos_crypto -open Tezos_stdlib -open Data_encoding -open Tezos_base_test_helpers) diff --git a/src/lib_sapling/test/test_merkle.ml b/src/lib_sapling/test/test_merkle.ml index 0af890b6eaa6..2a5d0dd479de 100644 --- a/src/lib_sapling/test/test_merkle.ml +++ b/src/lib_sapling/test/test_merkle.ml @@ -315,7 +315,9 @@ let test_merkle3 () = (* Test batch insertions against indviduals ones. *) let test_batch_insertion () = let open Storage.Tree in - let random_cm () = Core.Commitment.of_bytes_exn (Hacl.Rand.gen 32) in + let random_cm () = + Core.Commitment.of_bytes_exn (Tezos_crypto.Hacl.Rand.gen 32) + in let random_cms = List.init 33 (fun _ -> random_cm ()) in (* List of trees with tree i having the first i commitments inserted one at the time *) @@ -366,7 +368,9 @@ let test_batch_insertion () = (* with a 10k long list: batch 4.504671 once 127.857964 *) let bench_batch_insertion () = let open Storage.Tree in - let random_cm () = Core.Commitment.of_bytes_exn (Hacl.Rand.gen 32) in + let random_cm () = + Core.Commitment.of_bytes_exn (Tezos_crypto.Hacl.Rand.gen 32) + in let random_cms = List.init 33 (fun _ -> random_cm ()) in let start = Unix.gettimeofday () in let single_insert = diff --git a/src/lib_sapling/test/test_roots.ml b/src/lib_sapling/test/test_roots.ml index bd40d2b47bf2..90962747a9e3 100644 --- a/src/lib_sapling/test/test_roots.ml +++ b/src/lib_sapling/test/test_roots.ml @@ -8,7 +8,9 @@ module Storage = Storage.Make_Storage (Core) *) let test_add_mem () = let open Storage.Roots in - let random_hashes () = Core.Hash.of_bytes_exn (Hacl.Rand.gen 32) in + let random_hashes () = + Core.Hash.of_bytes_exn (Tezos_crypto.Hacl.Rand.gen 32) + in (* List of 10 random hashes *) let first_10_hashes = List.init 10 (fun _ -> random_hashes ()) in (* List of [size] random hashes *) diff --git a/src/lib_sapling/test/test_sapling.ml b/src/lib_sapling/test/test_sapling.ml index 07f7fb3c587a..dd2b590f7b3d 100644 --- a/src/lib_sapling/test/test_sapling.ml +++ b/src/lib_sapling/test/test_sapling.ml @@ -9,8 +9,8 @@ let test_get_memo_size () = let rcm = Rcm.random () in let memo = Bytes.empty in let esk = DH.esk_random () in - let cv = Stdlib.Option.get (CV.of_bytes (Hacl.Rand.gen 32)) in - let cm = Commitment.of_bytes_exn (Hacl.Rand.gen 32) in + let cv = Stdlib.Option.get (CV.of_bytes (Tezos_crypto.Hacl.Rand.gen 32)) in + let cm = Commitment.of_bytes_exn (Tezos_crypto.Hacl.Rand.gen 32) in let epk = DH.derive_ephemeral address esk in let cipher = Ciphertext.encrypt 0L address vk rcm memo (cv, cm, epk) esk in assert (Ciphertext.get_memo_size cipher = 0) @@ -35,7 +35,7 @@ let test_proof_raw () = let witness = Stdlib.Option.get @@ T.get_witness tree 0L in let tohash = Bytes.make 32 '1' in let hash = - Blake2B.( + Tezos_crypto.Blake2B.( to_bytes (hash_bytes ~key:(Bytes.of_string "Sighash_Tezos") [tohash])) in let sighash = R.to_sighash hash in @@ -150,7 +150,7 @@ let test_full_transaction () = (* Signature of the input *) let signature_1 = R.spend_sig xsk1.expsk.ask ar_1 sighash_2 in (* encryption of the ciphertext *) - let nonce_1 = Crypto_box.random_nonce () in + let nonce_1 = Tezos_crypto.Crypto_box.random_nonce () in let plaintext = Data_encoding.Binary.to_bytes_exn Ciphertext.plaintext_encoding @@ -163,7 +163,7 @@ let test_full_transaction () = in let key_agreed = DH.symkey_sender esk_1 addr1.pkd in let ciphertext_1 = - Crypto_box.Secretbox.secretbox key_agreed plaintext nonce_1 + Tezos_crypto.Crypto_box.Secretbox.secretbox key_agreed plaintext nonce_1 in (* Hash of the whole transaction *) let tohash_all = @@ -184,7 +184,7 @@ let test_full_transaction () = in let sighash_1 = R.to_sighash - Blake2B.( + Tezos_crypto.Blake2B.( to_bytes (hash_bytes ~key:(Bytes.of_string "SaplingForTezosV1") [tohash_all])) in -- GitLab From c4d2770cf439bcc6834bc81a2a13db6c31b64d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 17:56:35 +0200 Subject: [PATCH 03/30] P2p: unopen Crypto --- src/lib_p2p/p2p.ml | 2 +- src/lib_p2p/p2p.mli | 2 +- src/lib_p2p/p2p_acl.ml | 3 +- src/lib_p2p/p2p_connect_handler.ml | 8 ++-- src/lib_p2p/p2p_connect_handler.mli | 4 +- src/lib_p2p/p2p_socket.ml | 56 ++++++++++++++++----------- src/lib_p2p/p2p_socket.mli | 2 +- src/lib_p2p/test/node.ml | 2 +- src/lib_p2p/test/p2p_test_utils.ml | 2 +- src/lib_p2p/test/p2p_test_utils.mli | 6 +-- src/lib_p2p/test/test_p2p_socket.ml | 44 ++++++++++++--------- src/lib_p2p_services/p2p_services.mli | 2 +- 12 files changed, 75 insertions(+), 58 deletions(-) diff --git a/src/lib_p2p/p2p.ml b/src/lib_p2p/p2p.ml index 7cb9a1405951..5434f962e361 100644 --- a/src/lib_p2p/p2p.ml +++ b/src/lib_p2p/p2p.ml @@ -36,7 +36,7 @@ type config = { peers_file : string; private_mode : bool; identity : P2p_identity.t; - proof_of_work_target : Crypto_box.pow_target; + proof_of_work_target : Tezos_crypto.Crypto_box.pow_target; trust_discovered_peers : bool; reconnection_config : Point_reconnection_config.t; } diff --git a/src/lib_p2p/p2p.mli b/src/lib_p2p/p2p.mli index 4d6d6fa1a5c6..b1c4337df3cd 100644 --- a/src/lib_p2p/p2p.mli +++ b/src/lib_p2p/p2p.mli @@ -101,7 +101,7 @@ type config = { these peers that the identity of this node should not be revealed to the rest of the network. *) identity : P2p_identity.t; (** Cryptographic identity of the peer. *) - proof_of_work_target : Crypto_box.pow_target; + proof_of_work_target : Tezos_crypto.Crypto_box.pow_target; (** Expected level of proof of work of peers' identity. *) trust_discovered_peers : bool; (** If [true], peers discovered on the local network will be trusted. *) diff --git a/src/lib_p2p/p2p_acl.ml b/src/lib_p2p/p2p_acl.ml index 261749c1e260..851354eec335 100644 --- a/src/lib_p2p/p2p_acl.ml +++ b/src/lib_p2p/p2p_acl.ml @@ -82,7 +82,8 @@ let create ~peer_id_size ~ip_size ~ip_cleanup_delay = if ip_size <= 0 then invalid_arg "P2p_acl.create: bad value for ip_size" ; let bloomer = Bloomer.create (* 512KiB *) - ~hash:(fun x -> Blake2B.(to_bytes (hash_string [Ipaddr.V6.to_octets x]))) + ~hash:(fun x -> + Tezos_crypto.Blake2B.(to_bytes (hash_string [Ipaddr.V6.to_octets x]))) ~hashes:5 (* fixed, good for reasonable values of [ip_size] *) ~countdown_bits:4 (* 16 steps to 0, fixed discrete split of the cleanup delay *) diff --git a/src/lib_p2p/p2p_connect_handler.ml b/src/lib_p2p/p2p_connect_handler.ml index ebdee7e3a5aa..e117dff7636a 100644 --- a/src/lib_p2p/p2p_connect_handler.ml +++ b/src/lib_p2p/p2p_connect_handler.ml @@ -39,7 +39,7 @@ type config = { connection_timeout : Time.System.Span.t; authentication_timeout : Time.System.Span.t; reconnection_config : Point_reconnection_config.t; - proof_of_work_target : Crypto_box.pow_target; + proof_of_work_target : Tezos_crypto.Crypto_box.pow_target; listening_port : P2p_addr.port option; advertised_port : P2p_addr.port option; } @@ -65,7 +65,7 @@ type ('msg, 'peer_meta, 'conn_meta) dependencies = { (** [P2p_fd.connect] *) socket_authenticate : canceler:Lwt_canceler.t -> - proof_of_work_target:Crypto_box.pow_target -> + proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> incoming:bool -> P2p_io_scheduler.connection -> P2p_point.Id.t -> @@ -699,7 +699,7 @@ module Internal_for_tests = struct (unit, [`Unexpected_error of exn | `Connection_refused]) result Lwt.t; socket_authenticate : canceler:Lwt_canceler.t -> - proof_of_work_target:Crypto_box.pow_target -> + proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> incoming:bool -> P2p_io_scheduler.connection -> P2p_point.Id.t -> @@ -769,7 +769,7 @@ module Internal_for_tests = struct let connection_timeout = Time.System.Span.of_seconds_exn 10. in let authentication_timeout = Time.System.Span.of_seconds_exn 5. in let reconnection_config = Point_reconnection_config.default in - let proof_of_work_target = Crypto_box.make_pow_target 0. in + let proof_of_work_target = Tezos_crypto.Crypto_box.make_pow_target 0. in let listening_port = Some 9732 in let advertised_port = None in { diff --git a/src/lib_p2p/p2p_connect_handler.mli b/src/lib_p2p/p2p_connect_handler.mli index c74ebd894ee9..09a624cb55eb 100644 --- a/src/lib_p2p/p2p_connect_handler.mli +++ b/src/lib_p2p/p2p_connect_handler.mli @@ -74,7 +74,7 @@ type config = { (** Maximum time allowed to the establishment of a connection. *) reconnection_config : Point_reconnection_config.t; (** Delay granted to a peer to perform authentication. *) - proof_of_work_target : Crypto_box.pow_target; + proof_of_work_target : Tezos_crypto.Crypto_box.pow_target; (** The proof of work target we require from peers. *) listening_port : P2p_addr.port option; (** The TCP port on which the peer can be reached. *) @@ -158,7 +158,7 @@ module Internal_for_tests : sig (** [P2p_fd.connect] *) socket_authenticate : canceler:Lwt_canceler.t -> - proof_of_work_target:Crypto_box.pow_target -> + proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> incoming:bool -> P2p_io_scheduler.connection -> P2p_point.Id.t -> diff --git a/src/lib_p2p/p2p_socket.ml b/src/lib_p2p/p2p_socket.ml index 4efcd9d1b40c..c7a881097865 100644 --- a/src/lib_p2p/p2p_socket.ml +++ b/src/lib_p2p/p2p_socket.ml @@ -34,7 +34,7 @@ module Crypto = struct let header_length = 2 (* The size of extra data added by encryption. *) - let tag_length = Crypto_box.tag_length + let tag_length = Tezos_crypto.Crypto_box.tag_length (* The number of bytes added by encryption + header *) let extrabytes = header_length + tag_length @@ -42,9 +42,9 @@ module Crypto = struct let max_content_length = bufsize - extrabytes type data = { - channel_key : Crypto_box.channel_key; - mutable local_nonce : Crypto_box.nonce; - mutable remote_nonce : Crypto_box.nonce; + channel_key : Tezos_crypto.Crypto_box.channel_key; + mutable local_nonce : Tezos_crypto.Crypto_box.nonce; + mutable remote_nonce : Tezos_crypto.Crypto_box.nonce; } (* We do the following assumptions on the NaCl library. Note that @@ -66,8 +66,13 @@ module Crypto = struct let payload_length = header_length + encrypted_length in let tag = Bytes.create tag_length in let local_nonce = cryptobox_data.local_nonce in - cryptobox_data.local_nonce <- Crypto_box.increment_nonce local_nonce ; - Crypto_box.fast_box_noalloc cryptobox_data.channel_key local_nonce tag msg ; + cryptobox_data.local_nonce <- + Tezos_crypto.Crypto_box.increment_nonce local_nonce ; + Tezos_crypto.Crypto_box.fast_box_noalloc + cryptobox_data.channel_key + local_nonce + tag + msg ; let payload = Bytes.create payload_length in TzEndian.set_uint16 payload 0 encrypted_length ; Bytes.blit tag 0 payload header_length tag_length ; @@ -92,9 +97,10 @@ module Crypto = struct let msg = Bytes.create msg_length in let* () = read_full ?canceler fd @@ mk_buffer_safe msg in let remote_nonce = cryptobox_data.remote_nonce in - cryptobox_data.remote_nonce <- Crypto_box.increment_nonce remote_nonce ; + cryptobox_data.remote_nonce <- + Tezos_crypto.Crypto_box.increment_nonce remote_nonce ; match - Crypto_box.fast_box_open_noalloc + Tezos_crypto.Crypto_box.fast_box_open_noalloc cryptobox_data.channel_key remote_nonce tag @@ -118,9 +124,9 @@ let check_binary_chunks_size size = module Connection_message = struct type t = { port : int option; - public_key : Crypto_box.public_key; - proof_of_work_stamp : Crypto_box.nonce; - message_nonce : Crypto_box.nonce; + public_key : Tezos_crypto.Crypto_box.public_key; + proof_of_work_stamp : Tezos_crypto.Crypto_box.nonce; + message_nonce : Tezos_crypto.Crypto_box.nonce; version : Network_version.t; } @@ -135,9 +141,9 @@ module Connection_message = struct {port; public_key; proof_of_work_stamp; message_nonce; version}) (obj5 (req "port" uint16) - (req "pubkey" Crypto_box.public_key_encoding) - (req "proof_of_work_stamp" Crypto_box.nonce_encoding) - (req "message_nonce" Crypto_box.nonce_encoding) + (req "pubkey" Tezos_crypto.Crypto_box.public_key_encoding) + (req "proof_of_work_stamp" Tezos_crypto.Crypto_box.nonce_encoding) + (req "message_nonce" Tezos_crypto.Crypto_box.nonce_encoding) (req "version" Network_version.encoding)) let write ~canceler fd message = @@ -363,7 +369,7 @@ let authenticate ~canceler ~proof_of_work_target ~incoming scheduled_conn ((remote_addr, remote_socket_port) as point) ?advertised_port identity announced_version metadata_config = let open Lwt_result_syntax in - let local_nonce_seed = Crypto_box.random_nonce () in + let local_nonce_seed = Tezos_crypto.Crypto_box.random_nonce () in let*! () = Events.(emit sending_authentication) point in let* sent_msg = Connection_message.write @@ -390,7 +396,7 @@ let authenticate ~canceler ~proof_of_work_target ~incoming scheduled_conn if incoming then msg.port else Some remote_socket_port in let id_point = (remote_addr, remote_listening_port) in - let remote_peer_id = Crypto_box.hash msg.public_key in + let remote_peer_id = Tezos_crypto.Crypto_box.hash msg.public_key in let* () = fail_unless (remote_peer_id <> identity.P2p_identity.peer_id) @@ -398,17 +404,19 @@ let authenticate ~canceler ~proof_of_work_target ~incoming scheduled_conn in let* () = fail_unless - (Crypto_box.check_proof_of_work + (Tezos_crypto.Crypto_box.check_proof_of_work msg.public_key msg.proof_of_work_stamp proof_of_work_target) (P2p_errors.Not_enough_proof_of_work remote_peer_id) in let channel_key = - Crypto_box.precompute identity.P2p_identity.secret_key msg.public_key + Tezos_crypto.Crypto_box.precompute + identity.P2p_identity.secret_key + msg.public_key in let local_nonce, remote_nonce = - Crypto_box.generate_nonces ~incoming ~sent_msg ~recv_msg + Tezos_crypto.Crypto_box.generate_nonces ~incoming ~sent_msg ~recv_msg in let cryptobox_data = {Crypto.channel_key; local_nonce; remote_nonce} in let local_metadata = metadata_config.P2p_params.conn_meta_value () in @@ -818,13 +826,15 @@ module Internal_for_tests = struct let raw_write_sync = raw_write_sync let mock_authenticated_connection default_metadata = - let secret_key, public_key, _pkh = Crypto_box.random_keypair () in + let secret_key, public_key, _pkh = + Tezos_crypto.Crypto_box.random_keypair () + in let cryptobox_data = Crypto. { - channel_key = Crypto_box.precompute secret_key public_key; - local_nonce = Crypto_box.zero_nonce; - remote_nonce = Crypto_box.zero_nonce; + channel_key = Tezos_crypto.Crypto_box.precompute secret_key public_key; + local_nonce = Tezos_crypto.Crypto_box.zero_nonce; + remote_nonce = Tezos_crypto.Crypto_box.zero_nonce; } in let scheduled_conn = diff --git a/src/lib_p2p/p2p_socket.mli b/src/lib_p2p/p2p_socket.mli index a4dcecf268f3..b9c2cb55fe7a 100644 --- a/src/lib_p2p/p2p_socket.mli +++ b/src/lib_p2p/p2p_socket.mli @@ -108,7 +108,7 @@ val private_node : ('msg, 'meta) t -> bool - [P2p_errors.Connection_closed] if the remote peer closes the connection *) val authenticate : canceler:Lwt_canceler.t -> - proof_of_work_target:Crypto_box.pow_target -> + proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> incoming:bool -> P2p_io_scheduler.connection -> P2p_point.Id.t -> diff --git a/src/lib_p2p/test/node.ml b/src/lib_p2p/test/node.ml index 45c7da7eb66c..eebe3c6bd1fd 100644 --- a/src/lib_p2p/test/node.ml +++ b/src/lib_p2p/test/node.ml @@ -151,7 +151,7 @@ let detach_node ?(prefix = "") ?timeout ?(min_connections : int option) (fun p -> not (P2p_point.Id.equal (addr, port) p)) trusted_points in - let proof_of_work_target = Crypto_box.make_pow_target 0. in + let proof_of_work_target = Tezos_crypto.Crypto_box.make_pow_target 0. in let identity = P2p_identity.generate_with_pow_target_0 () in let private_mode = false in let nb_points = List.length trusted_points in diff --git a/src/lib_p2p/test/p2p_test_utils.ml b/src/lib_p2p/test/p2p_test_utils.ml index d3dddd3a4da1..afcf44fbff7d 100644 --- a/src/lib_p2p/test/p2p_test_utils.ml +++ b/src/lib_p2p/test/p2p_test_utils.ml @@ -111,7 +111,7 @@ let close_active_conns pool = let canceler = Lwt_canceler.create () (* unused *) -let proof_of_work_target = Crypto_box.make_pow_target 1. +let proof_of_work_target = Tezos_crypto.Crypto_box.make_pow_target 1. let id1 = P2p_identity.generate proof_of_work_target diff --git a/src/lib_p2p/test/p2p_test_utils.mli b/src/lib_p2p/test/p2p_test_utils.mli index a6bd20fbd57d..26de6ba726da 100644 --- a/src/lib_p2p/test/p2p_test_utils.mli +++ b/src/lib_p2p/test/p2p_test_utils.mli @@ -74,7 +74,7 @@ val addr : Ipaddr.V6.t ref val canceler : Lwt_canceler.t -val proof_of_work_target : Crypto_box.pow_target +val proof_of_work_target : Tezos_crypto.Crypto_box.pow_target val id1 : P2p_identity.t Lwt.t @@ -102,7 +102,7 @@ val raw_accept : val accept : ?id:P2p_identity.t Lwt.t -> - ?proof_of_work_target:Crypto_box.pow_target -> + ?proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> P2p_io_scheduler.t -> Lwt_unix.file_descr -> ( unit P2p_connection.Info.t * unit P2p_socket.authenticated_connection, @@ -120,7 +120,7 @@ val raw_connect : Lwt.t val connect : - ?proof_of_work_target:Crypto_box.pow_target -> + ?proof_of_work_target:Tezos_crypto.Crypto_box.pow_target -> P2p_io_scheduler.t -> P2p_addr.t -> int -> diff --git a/src/lib_p2p/test/test_p2p_socket.ml b/src/lib_p2p/test/test_p2p_socket.ml index 81ad778b87e2..db6c16d22cad 100644 --- a/src/lib_p2p/test/test_p2p_socket.ml +++ b/src/lib_p2p/test/test_p2p_socket.ml @@ -43,7 +43,7 @@ let tzassert b pos = let p (file, lnum, cnum, _) = (file, lnum, cnum) in if b then return_unit else fail_with_exn (Assert_failure (p pos)) -let high_pow_target = Crypto_box.make_pow_target 100. +let high_pow_target = Tezos_crypto.Crypto_box.make_pow_target 100. let sync ch = let open Lwt_result_syntax in @@ -91,7 +91,7 @@ module Crypto_test = struct let header_length = 2 (* The size of extra data added by encryption. *) - let tag_length = Crypto_box.tag_length + let tag_length = Tezos_crypto.Crypto_box.tag_length (* The number of bytes added by encryption + header *) let extrabytes = header_length + tag_length @@ -99,9 +99,9 @@ module Crypto_test = struct let max_content_length = bufsize - extrabytes type data = { - channel_key : Crypto_box.channel_key; - mutable local_nonce : Crypto_box.nonce; - mutable remote_nonce : Crypto_box.nonce; + channel_key : Tezos_crypto.Crypto_box.channel_key; + mutable local_nonce : Tezos_crypto.Crypto_box.nonce; + mutable remote_nonce : Tezos_crypto.Crypto_box.nonce; } let () = assert (tag_length >= header_length) @@ -119,8 +119,13 @@ module Crypto_test = struct let tag = Bytes.make tag_length '\x00' in let cmsg = Bytes.copy msg in let local_nonce = cryptobox_data.local_nonce in - cryptobox_data.local_nonce <- Crypto_box.increment_nonce local_nonce ; - Crypto_box.fast_box_noalloc cryptobox_data.channel_key local_nonce tag cmsg ; + cryptobox_data.local_nonce <- + Tezos_crypto.Crypto_box.increment_nonce local_nonce ; + Tezos_crypto.Crypto_box.fast_box_noalloc + cryptobox_data.channel_key + local_nonce + tag + cmsg ; let payload = Bytes.make payload_length '\x00' in TzEndian.set_int16 payload 0 encrypted_length ; Bytes.blit tag 0 payload header_length tag_length ; @@ -146,10 +151,11 @@ module Crypto_test = struct in let* () = tzassert (msg_length = i) __POS__ in let remote_nonce = cryptobox_data.remote_nonce in - cryptobox_data.remote_nonce <- Crypto_box.increment_nonce remote_nonce ; + cryptobox_data.remote_nonce <- + Tezos_crypto.Crypto_box.increment_nonce remote_nonce ; let*? () = error_unless - (Crypto_box.fast_box_open_noalloc + (Tezos_crypto.Crypto_box.fast_box_open_noalloc cryptobox_data.channel_key remote_nonce tag @@ -158,11 +164,11 @@ module Crypto_test = struct in return msg - let sk, pk, _pkh = Crypto_box.random_keypair () + let sk, pk, _pkh = Tezos_crypto.Crypto_box.random_keypair () - let zero_nonce = Crypto_box.zero_nonce + let zero_nonce = Tezos_crypto.Crypto_box.zero_nonce - let channel_key = Crypto_box.precompute sk pk + let channel_key = Tezos_crypto.Crypto_box.precompute sk pk let in_fd, out_fd = Unix.pipe () @@ -215,7 +221,7 @@ end and identical. *) module Low_level = struct - let simple_msg = Rand.generate (1 lsl 4) + let simple_msg = Tezos_crypto.Rand.generate (1 lsl 4) let client ch sched addr port = let open Lwt_result_syntax in @@ -317,9 +323,9 @@ end module Simple_message = struct let encoding = Data_encoding.bytes - let simple_msg = Rand.generate (1 lsl 4) + let simple_msg = Tezos_crypto.Rand.generate (1 lsl 4) - let simple_msg2 = Rand.generate (1 lsl 4) + let simple_msg2 = Tezos_crypto.Rand.generate (1 lsl 4) let server ch sched socket = let open Lwt_result_syntax in @@ -355,9 +361,9 @@ end module Chunked_message = struct let encoding = Data_encoding.bytes - let simple_msg = Rand.generate (1 lsl 8) + let simple_msg = Tezos_crypto.Rand.generate (1 lsl 8) - let simple_msg2 = Rand.generate (1 lsl 8) + let simple_msg2 = Tezos_crypto.Rand.generate (1 lsl 8) let server ch sched socket = let open Lwt_result_syntax in @@ -396,7 +402,7 @@ module Oversized_message = struct let encoding = Data_encoding.bytes let rec rand_gen () = - try Rand.generate (1 lsl 17) + try Tezos_crypto.Rand.generate (1 lsl 17) with _ -> log_error "Not enough entropy, retrying to generate random data" ; rand_gen () @@ -467,7 +473,7 @@ end module Close_on_write = struct let encoding = Data_encoding.bytes - let simple_msg = Rand.generate (1 lsl 4) + let simple_msg = Tezos_crypto.Rand.generate (1 lsl 4) let server ch sched socket = let open Lwt_result_syntax in diff --git a/src/lib_p2p_services/p2p_services.mli b/src/lib_p2p_services/p2p_services.mli index 05fec7faef01..ef1c135a0f78 100644 --- a/src/lib_p2p_services/p2p_services.mli +++ b/src/lib_p2p_services/p2p_services.mli @@ -282,7 +282,7 @@ module Peers : sig val patch : ( [`PATCH], unit, - unit * Crypto_box.Public_key_hash.t, + unit * Tezos_crypto.Crypto_box.Public_key_hash.t, unit, [`Ban | `Open | `Trust] option, (Peer_metadata.t, Connection_metadata.t) P2p_peer.Info.t ) -- GitLab From e52e5ab9b5f07e4510b95a950020e54d62cab172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 18:01:03 +0200 Subject: [PATCH 04/30] Context: unopen Crypto --- src/lib_context/disk/context.ml | 112 ++++++++++++------ src/lib_context/disk/context.mli | 6 +- src/lib_context/encoding/context.ml | 14 ++- src/lib_context/encoding/context.mli | 4 +- src/lib_context/helpers/context.ml | 8 +- src/lib_context/helpers/context.mli | 3 +- src/lib_context/memory/context.ml | 51 ++++---- src/lib_context/memory/context.mli | 4 +- src/lib_context/memory/test/test.ml | 12 +- .../merkle_proof_encoding.ml | 2 +- src/lib_context/sigs/context.ml | 87 ++++++++------ src/lib_context/test/test_context.ml | 41 ++++--- src/lib_context/test/test_merkle_proof.ml | 16 ++- 13 files changed, 216 insertions(+), 144 deletions(-) diff --git a/src/lib_context/disk/context.ml b/src/lib_context/disk/context.ml index 223fc413b267..6cd41bd65867 100644 --- a/src/lib_context/disk/context.ml +++ b/src/lib_context/disk/context.ml @@ -34,7 +34,7 @@ module Proof = Tezos_context_sigs.Context.Proof_types type error += | Cannot_create_file of string | Cannot_open_file of string - | Cannot_retrieve_commit_info of Context_hash.t + | Cannot_retrieve_commit_info of Tezos_crypto.Context_hash.t | Cannot_find_protocol | Suspicious_file of int @@ -74,9 +74,9 @@ let () = Format.fprintf ppf "@[Cannot retrieve commit info associated to context hash %a@]" - Context_hash.pp + Tezos_crypto.Context_hash.pp hash) - Data_encoding.(obj1 (req "context_hash" Context_hash.encoding)) + Data_encoding.(obj1 (req "context_hash" Tezos_crypto.Context_hash.encoding)) (function Cannot_retrieve_commit_info e -> Some e | _ -> None) (fun e -> Cannot_retrieve_commit_info e) ; register_error_kind @@ -106,7 +106,7 @@ module type TEZOS_CONTEXT_UNIX = sig type error += | Cannot_create_file of string | Cannot_open_file of string - | Cannot_retrieve_commit_info of Context_hash.t + | Cannot_retrieve_commit_info of Tezos_crypto.Context_hash.t | Cannot_find_protocol | Suspicious_file of int @@ -124,7 +124,7 @@ module type TEZOS_CONTEXT_UNIX = sig val dump_context : index -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> fd:Lwt_unix.file_descr -> on_disk:bool -> progress_display_mode:Animation.progress_display_mode -> @@ -133,7 +133,7 @@ module type TEZOS_CONTEXT_UNIX = sig (** Rebuild a context from a given snapshot. *) val restore_context : index -> - expected_context_hash:Context_hash.t -> + expected_context_hash:Tezos_crypto.Context_hash.t -> nb_context_elements:int -> fd:Lwt_unix.file_descr -> legacy:bool -> @@ -192,8 +192,8 @@ module Events = struct ~level:Info ~name:"starting_gc" ~msg:"starting context garbage collection for commit {context_hash}" - ~pp1:Context_hash.pp - ("context_hash", Context_hash.encoding) + ~pp1:Tezos_crypto.Context_hash.pp + ("context_hash", Tezos_crypto.Context_hash.encoding) let ending_gc = declare_2 @@ -337,11 +337,11 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct ()) children) - let get_hash_version _c = Context_hash.Version.of_int 0 + let get_hash_version _c = Tezos_crypto.Context_hash.Version.of_int 0 let set_hash_version c v = let open Lwt_result_syntax in - if Context_hash.Version.(of_int 0 = v) then return c + if Tezos_crypto.Context_hash.Version.(of_int 0 = v) then return c else tzfail (Tezos_context_helpers.Context.Unsupported_context_hash_version v) @@ -380,11 +380,17 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct in match commit_opt with | None -> - Fmt.failwith "%a: unknown context hash" Context_hash.pp context_hash + Fmt.failwith + "%a: unknown context hash" + Tezos_crypto.Context_hash.pp + context_hash | Some commit -> ( let* () = Events.(emit starting_gc) context_hash in Logs.info (fun m -> - m "Launch GC for commit %a@." Context_hash.pp context_hash) ; + m + "Launch GC for commit %a@." + Tezos_crypto.Context_hash.pp + context_hash) ; let finished = function | Ok (stats : Store.Gc.stats) -> Events.(emit ending_gc) @@ -643,10 +649,10 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let data = WithExceptions.Option.to_exn_f ~none:(fun () -> assert false) o in - Protocol_hash.of_bytes_exn data + Tezos_crypto.Protocol_hash.of_bytes_exn data let add_protocol t v = - let v = Protocol_hash.to_bytes v in + let v = Tezos_crypto.Protocol_hash.to_bytes v in Tree.add t current_protocol_key v let get_test_chain t = @@ -679,7 +685,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct | None -> return_none | Some data -> ( match - Data_encoding.Binary.of_bytes_opt Block_metadata_hash.encoding data + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.Block_metadata_hash.encoding + data with | None -> raise @@ -690,7 +698,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let add_predecessor_block_metadata_hash t hash = let data = - Data_encoding.Binary.to_bytes_exn Block_metadata_hash.encoding hash + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Block_metadata_hash.encoding + hash in Tree.add t current_predecessor_block_metadata_hash_key data @@ -702,7 +712,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct | Some data -> ( match Data_encoding.Binary.of_bytes_opt - Operation_metadata_list_list_hash.encoding + Tezos_crypto.Operation_metadata_list_list_hash.encoding data with | None -> @@ -715,7 +725,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let add_predecessor_ops_metadata_hash t hash = let data = Data_encoding.Binary.to_bytes_exn - Operation_metadata_list_list_hash.encoding + Tezos_crypto.Operation_metadata_list_list_hash.encoding hash in Tree.add t current_predecessor_ops_metadata_hash_key data @@ -787,7 +797,8 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let _interrupted_gc = Store.Gc.cancel index.repo in Store.Repo.close index.repo - let get_branch chain_id = Format.asprintf "%a" Chain_id.pp chain_id + let get_branch chain_id = + Format.asprintf "%a" Tezos_crypto.Chain_id.pp chain_id let empty index = {index; tree = Store.Tree.empty (); parents = []; ops = 0} @@ -808,11 +819,17 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct return (Hash.to_context_hash (Store.Commit.hash commit)) let compute_testchain_chain_id genesis = - let genesis_hash = Block_hash.hash_bytes [Block_hash.to_bytes genesis] in - Chain_id.of_block_hash genesis_hash + let genesis_hash = + Tezos_crypto.Block_hash.hash_bytes + [Tezos_crypto.Block_hash.to_bytes genesis] + in + Tezos_crypto.Chain_id.of_block_hash genesis_hash let compute_testchain_genesis forked_block = - let genesis = Block_hash.hash_bytes [Block_hash.to_bytes forked_block] in + let genesis = + Tezos_crypto.Block_hash.hash_bytes + [Tezos_crypto.Block_hash.to_bytes forked_block] + in genesis let commit_test_chain_genesis ctxt (forked_header : Block_header.t) = @@ -829,9 +846,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct { forked_header.shell with proto_level = succ forked_header.shell.proto_level; - predecessor = Block_hash.zero; + predecessor = Tezos_crypto.Block_hash.zero; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; context = Hash.to_context_hash (Store.Commit.hash commit); } in @@ -887,13 +904,21 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let kind_encoding = string_enum [("node", `Node); ("blob", `Blob)] in conv (function - | `Blob h -> (`Blob, Context_hash.to_bytes (Hash.to_context_hash h)) - | `Node h -> (`Node, Context_hash.to_bytes (Hash.to_context_hash h))) + | `Blob h -> + ( `Blob, + Tezos_crypto.Context_hash.to_bytes (Hash.to_context_hash h) ) + | `Node h -> + ( `Node, + Tezos_crypto.Context_hash.to_bytes (Hash.to_context_hash h) )) (function | `Blob, h -> - `Blob (Hash.of_context_hash (Context_hash.of_bytes_exn h)) + `Blob + (Hash.of_context_hash + (Tezos_crypto.Context_hash.of_bytes_exn h)) | `Node, h -> - `Node (Hash.of_context_hash (Context_hash.of_bytes_exn h))) + `Node + (Hash.of_context_hash + (Tezos_crypto.Context_hash.of_bytes_exn h))) (obj2 (req "kind" kind_encoding) (req "value" bytes)) end @@ -928,7 +953,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct (fun k -> P.Commit.Key.to_hash k |> Hash.to_context_hash) parents in - List.sort Context_hash.compare parents + List.sort Tezos_crypto.Context_hash.compare parents | _ -> assert false let context_info = function @@ -939,7 +964,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let set_context ~info ~parents ctxt context_hash = let open Lwt_syntax in - let parents = List.sort Context_hash.compare parents in + let parents = List.sort Tezos_crypto.Context_hash.compare parents in let parents = (* All commit objects in the context are indexed, so it's safe to build a hash-only key referencing them. *) @@ -950,7 +975,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct in let+ c = Store.Commit.v ctxt.index.repo ~info ~parents ctxt.tree in let h = Store.Commit.hash c in - Context_hash.equal context_hash (Hash.to_context_hash h) + Tezos_crypto.Context_hash.equal context_hash (Hash.to_context_hash h) let context_tree ctxt = ctxt.tree @@ -965,21 +990,30 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct conv (function | Contents (h, ()) -> - (`Contents, Context_hash.to_bytes (Hash.to_context_hash h)) - | Node h -> (`Node, Context_hash.to_bytes (Hash.to_context_hash h))) + ( `Contents, + Tezos_crypto.Context_hash.to_bytes (Hash.to_context_hash h) ) + | Node h -> + ( `Node, + Tezos_crypto.Context_hash.to_bytes (Hash.to_context_hash h) )) (function | `Contents, h -> - let h = Hash.of_context_hash (Context_hash.of_bytes_exn h) in + let h = + Hash.of_context_hash + (Tezos_crypto.Context_hash.of_bytes_exn h) + in Contents (h, ()) | `Node, h -> - Node (Hash.of_context_hash (Context_hash.of_bytes_exn h))) + Node + (Hash.of_context_hash + (Tezos_crypto.Context_hash.of_bytes_exn h))) (obj2 (req "kind" kind_encoding) (req "value" bytes)) let hash_encoding : hash Data_encoding.t = let open Data_encoding in conv - (fun h -> Context_hash.to_bytes (Hash.to_context_hash h)) - (fun h -> Hash.of_context_hash (Context_hash.of_bytes_exn h)) + (fun h -> Tezos_crypto.Context_hash.to_bytes (Hash.to_context_hash h)) + (fun h -> + Hash.of_context_hash (Tezos_crypto.Context_hash.of_bytes_exn h)) bytes let entry_encoding : entry Data_encoding.t = @@ -1108,7 +1142,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let*! _ = Store.save_tree ~clear:true repo x y tree in return_some tree - module Commit_hash = Context_hash + module Commit_hash = Tezos_crypto.Context_hash module Block_header = Block_header end @@ -1183,7 +1217,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct P.Commit_portable.v ~info ~parents ~node |> Commit_hash.hash |> Hash.to_context_hash in - Context_hash.equal ctxt_h expected_context_hash + Tezos_crypto.Context_hash.equal ctxt_h expected_context_hash (* Context dumper *) diff --git a/src/lib_context/disk/context.mli b/src/lib_context/disk/context.mli index 310c54b6eb20..6a6368c96c07 100644 --- a/src/lib_context/disk/context.mli +++ b/src/lib_context/disk/context.mli @@ -30,7 +30,7 @@ module type TEZOS_CONTEXT_UNIX = sig type error += | Cannot_create_file of string | Cannot_open_file of string - | Cannot_retrieve_commit_info of Context_hash.t + | Cannot_retrieve_commit_info of Tezos_crypto.Context_hash.t | Cannot_find_protocol | Suspicious_file of int @@ -53,7 +53,7 @@ module type TEZOS_CONTEXT_UNIX = sig (** [dump_context] is used to export snapshots of the context at given hashes. *) val dump_context : index -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> fd:Lwt_unix.file_descr -> on_disk:bool -> progress_display_mode:Animation.progress_display_mode -> @@ -62,7 +62,7 @@ module type TEZOS_CONTEXT_UNIX = sig (** Rebuild a context from a given snapshot. *) val restore_context : index -> - expected_context_hash:Context_hash.t -> + expected_context_hash:Tezos_crypto.Context_hash.t -> nb_context_elements:int -> fd:Lwt_unix.file_descr -> legacy:bool -> diff --git a/src/lib_context/encoding/context.ml b/src/lib_context/encoding/context.ml index 9463ecf42874..aae455d198c7 100644 --- a/src/lib_context/encoding/context.ml +++ b/src/lib_context/encoding/context.ml @@ -44,9 +44,9 @@ module Hash : sig val to_raw_string : t -> string - val to_context_hash : t -> Context_hash.t + val to_context_hash : t -> Tezos_crypto.Context_hash.t - val of_context_hash : Context_hash.t -> t + val of_context_hash : Tezos_crypto.Context_hash.t -> t end = struct module H = Digestif.Make_BLAKE2B (struct let digest_size = 32 @@ -58,14 +58,16 @@ end = struct let unsafe_of_raw_string s = H.of_raw_string s - let of_context_hash s = H.of_raw_string (Context_hash.to_string s) + let of_context_hash s = + H.of_raw_string (Tezos_crypto.Context_hash.to_string s) - let to_context_hash h = Context_hash.of_string_exn (H.to_raw_string h) + let to_context_hash h = + Tezos_crypto.Context_hash.of_string_exn (H.to_raw_string h) - let pp ppf t = Context_hash.pp ppf (to_context_hash t) + let pp ppf t = Tezos_crypto.Context_hash.pp ppf (to_context_hash t) let of_string x = - match Context_hash.of_b58check x with + match Tezos_crypto.Context_hash.of_b58check x with | Ok x -> Ok (of_context_hash x) | Error err -> Error diff --git a/src/lib_context/encoding/context.mli b/src/lib_context/encoding/context.mli index 68cfe1ff6bab..bb28ea240ac1 100644 --- a/src/lib_context/encoding/context.mli +++ b/src/lib_context/encoding/context.mli @@ -30,9 +30,9 @@ module Hash : sig val to_raw_string : t -> string - val to_context_hash : t -> Context_hash.t + val to_context_hash : t -> Tezos_crypto.Context_hash.t - val of_context_hash : Context_hash.t -> t + val of_context_hash : Tezos_crypto.Context_hash.t -> t end module Conf : Irmin_pack.Conf.S diff --git a/src/lib_context/helpers/context.ml b/src/lib_context/helpers/context.ml index 73125bd95b0b..aec343981c41 100644 --- a/src/lib_context/helpers/context.ml +++ b/src/lib_context/helpers/context.ml @@ -386,7 +386,8 @@ struct Store.Tree.verify_stream proof f end -type error += Unsupported_context_hash_version of Context_hash.Version.t +type error += + | Unsupported_context_hash_version of Tezos_crypto.Context_hash.Version.t let () = register_error_kind @@ -399,9 +400,10 @@ let () = ppf "@[Context hash version %a is not supported.@,\ You might need to update the shell.@]" - Context_hash.Version.pp + Tezos_crypto.Context_hash.Version.pp version) - Data_encoding.(obj1 (req "version" Context_hash.Version.encoding)) + Data_encoding.( + obj1 (req "version" Tezos_crypto.Context_hash.Version.encoding)) (function | Unsupported_context_hash_version version -> Some version | _ -> None) (fun version -> Unsupported_context_hash_version version) diff --git a/src/lib_context/helpers/context.mli b/src/lib_context/helpers/context.mli index 5fc7e5951cfb..2f86bb923849 100644 --- a/src/lib_context/helpers/context.mli +++ b/src/lib_context/helpers/context.mli @@ -111,7 +111,8 @@ module Make_config (Conf : Irmin_pack.Conf.S) : sig val config : 'a -> Tezos_context_sigs.Config.t end -type error += Unsupported_context_hash_version of Context_hash.Version.t +type error += + | Unsupported_context_hash_version of Tezos_crypto.Context_hash.Version.t (** See [Tezos_context_sigs.Context.Proof_types.t] *) type proof_version_expanded = {is_stream : bool; is_binary : bool} diff --git a/src/lib_context/memory/context.ml b/src/lib_context/memory/context.ml index 90bae31ae387..3e78b9860c80 100644 --- a/src/lib_context/memory/context.ml +++ b/src/lib_context/memory/context.ml @@ -33,8 +33,8 @@ module type TEZOS_CONTEXT_MEMORY = sig Tezos_context_sigs.Context.TEZOS_CONTEXT with type memory_context_tree := tree and type tree := tree - and type value_key = Context_hash.t - and type node_key = Context_hash.t + and type value_key = Tezos_crypto.Context_hash.t + and type node_key = Tezos_crypto.Context_hash.t (** Exception raised by [find_tree] and [add_tree] when applied to shallow trees. It is exposed so that it can be catched by the proxy where such @@ -56,9 +56,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct module Info = Store.Info module P = Store.Backend - type node_key = Context_hash.t + type node_key = Tezos_crypto.Context_hash.t - type value_key = Context_hash.t + type value_key = Tezos_crypto.Context_hash.t type kinded_key = [`Value of value_key | `Node of node_key] @@ -156,11 +156,11 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct ()) children) - let get_hash_version _c = Context_hash.Version.of_int 0 + let get_hash_version _c = Tezos_crypto.Context_hash.Version.of_int 0 let set_hash_version c v = let open Lwt_result_syntax in - if Context_hash.Version.(of_int 0 = v) then return c + if Tezos_crypto.Context_hash.Version.(of_int 0 = v) then return c else tzfail (Tezos_context_helpers.Context.Unsupported_context_hash_version v) @@ -401,10 +401,10 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let data = WithExceptions.Option.to_exn_f ~none:(fun () -> assert false) o in - Protocol_hash.of_bytes_exn data + Tezos_crypto.Protocol_hash.of_bytes_exn data let add_protocol t v = - let v = Protocol_hash.to_bytes v in + let v = Tezos_crypto.Protocol_hash.to_bytes v in Tree.add t current_protocol_key v let get_test_chain t = @@ -437,7 +437,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct | None -> return_none | Some data -> ( match - Data_encoding.Binary.of_bytes_opt Block_metadata_hash.encoding data + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.Block_metadata_hash.encoding + data with | None -> raise @@ -448,7 +450,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let add_predecessor_block_metadata_hash t hash = let data = - Data_encoding.Binary.to_bytes_exn Block_metadata_hash.encoding hash + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Block_metadata_hash.encoding + hash in Tree.add t current_predecessor_block_metadata_hash_key data @@ -460,7 +464,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct | Some data -> ( match Data_encoding.Binary.of_bytes_opt - Operation_metadata_list_list_hash.encoding + Tezos_crypto.Operation_metadata_list_list_hash.encoding data with | None -> @@ -473,7 +477,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let add_predecessor_ops_metadata_hash t hash = let data = Data_encoding.Binary.to_bytes_exn - Operation_metadata_list_list_hash.encoding + Tezos_crypto.Operation_metadata_list_list_hash.encoding hash in Tree.add t current_predecessor_ops_metadata_hash_key data @@ -526,7 +530,8 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct let is_empty t = Tree.is_empty t.tree - let get_branch chain_id = Format.asprintf "%a" Chain_id.pp chain_id + let get_branch chain_id = + Format.asprintf "%a" Tezos_crypto.Chain_id.pp chain_id let commit_genesis index ~chain_id ~time ~protocol = let open Lwt_result_syntax in @@ -587,11 +592,17 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct concrete_encoding let compute_testchain_chain_id genesis = - let genesis_hash = Block_hash.hash_bytes [Block_hash.to_bytes genesis] in - Chain_id.of_block_hash genesis_hash + let genesis_hash = + Tezos_crypto.Block_hash.hash_bytes + [Tezos_crypto.Block_hash.to_bytes genesis] + in + Tezos_crypto.Chain_id.of_block_hash genesis_hash let compute_testchain_genesis forked_block = - let genesis = Block_hash.hash_bytes [Block_hash.to_bytes forked_block] in + let genesis = + Tezos_crypto.Block_hash.hash_bytes + [Tezos_crypto.Block_hash.to_bytes forked_block] + in genesis let commit_test_chain_genesis ctxt (forked_header : Block_header.t) = @@ -608,9 +619,9 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct { forked_header.shell with proto_level = succ forked_header.shell.proto_level; - predecessor = Block_hash.zero; + predecessor = Tezos_crypto.Block_hash.zero; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; context = Hash.to_context_hash (Store.Commit.hash commit); } in @@ -658,7 +669,7 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct (fun k -> P.Commit.Key.to_hash k |> Hash.to_context_hash) parents in - List.sort Context_hash.compare parents + List.sort Tezos_crypto.Context_hash.compare parents | _ -> assert false let context_info = function @@ -729,5 +740,5 @@ module Make (Encoding : module type of Tezos_context_encoding.Context) = struct P.Commit_portable.v ~info ~parents ~node |> Commit_hash.hash |> Hash.to_context_hash in - Context_hash.equal ctxt_h expected_context_hash + Tezos_crypto.Context_hash.equal ctxt_h expected_context_hash end diff --git a/src/lib_context/memory/context.mli b/src/lib_context/memory/context.mli index f7bf64f66eab..6be42e538ad7 100644 --- a/src/lib_context/memory/context.mli +++ b/src/lib_context/memory/context.mli @@ -31,8 +31,8 @@ module type TEZOS_CONTEXT_MEMORY = sig Tezos_context_sigs.Context.TEZOS_CONTEXT with type memory_context_tree := tree and type tree := tree - and type value_key = Context_hash.t - and type node_key = Context_hash.t + and type value_key = Tezos_crypto.Context_hash.t + and type node_key = Tezos_crypto.Context_hash.t (** Exception raised by [find_tree] and [add_tree] when applied to shallow trees. It is exposed so that it can be catched by the proxy where such diff --git a/src/lib_context/memory/test/test.ml b/src/lib_context/memory/test/test.ml index 1b15b7a4d746..30ba771aa714 100644 --- a/src/lib_context/memory/test/test.ml +++ b/src/lib_context/memory/test/test.ml @@ -30,16 +30,16 @@ module C = struct (** Basic blocks *) let genesis_block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisGeneskvg68z" let genesis_protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" let genesis_time = Time.Protocol.of_seconds 0L - let chain_id = Chain_id.of_block_hash genesis_block + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis_block let make_context () = (* there is no simple way to build a context *) @@ -97,14 +97,14 @@ let test_hash = let module M = Make (M) in let* ch = C.hash_of_dir n in let* mh = M.hash_of_dir n in - if not @@ Context_hash.equal ch mh then + if not @@ Tezos_crypto.Context_hash.equal ch mh then Stdlib.failwith (Format.asprintf "hash mismatch: n=%d context: %a memory: %a" n - Context_hash.pp + Tezos_crypto.Context_hash.pp ch - Context_hash.pp + Tezos_crypto.Context_hash.pp mh) else Lwt.return () in diff --git a/src/lib_context/merkle_proof_encoding/merkle_proof_encoding.ml b/src/lib_context/merkle_proof_encoding/merkle_proof_encoding.ml index 42bdc6d940e6..eb4a800746c3 100644 --- a/src/lib_context/merkle_proof_encoding/merkle_proof_encoding.ml +++ b/src/lib_context/merkle_proof_encoding/merkle_proof_encoding.ml @@ -48,7 +48,7 @@ struct Bytes.unsafe_to_string (Bounded.bytes 255 (* 1 byte for the length *)) - let hash_encoding = Context_hash.encoding + let hash_encoding = Tezos_crypto.Context_hash.encoding let index_encoding = uint8 diff --git a/src/lib_context/sigs/context.ml b/src/lib_context/sigs/context.ml index 1e8535e8d12e..8bd5c0800f28 100644 --- a/src/lib_context/sigs/context.ml +++ b/src/lib_context/sigs/context.ml @@ -169,7 +169,7 @@ module type TREE = sig val of_value : t -> value -> tree Lwt.t (** [hash t] is [t]'s Merkle hash. *) - val hash : tree -> Context_hash.t + val hash : tree -> Tezos_crypto.Context_hash.t (** [equal x y] is true iff [x] and [y] have the same Merkle hash. *) val equal : tree -> tree -> bool @@ -186,9 +186,9 @@ module type HASH_VERSION = sig (** The type for context views. *) type t - val get_hash_version : t -> Context_hash.Version.t + val get_hash_version : t -> Tezos_crypto.Context_hash.Version.t - val set_hash_version : t -> Context_hash.Version.t -> t Lwt.t + val set_hash_version : t -> Tezos_crypto.Context_hash.Version.t -> t Lwt.t end (** Tezos-specific proof types, as opposed to proofs provided by Irmin. @@ -263,7 +263,7 @@ module Proof_types = struct type index = int (** The type for hashes. *) - type hash = Context_hash.t + type hash = Tezos_crypto.Context_hash.t (** The type for (internal) inode proofs. @@ -676,9 +676,11 @@ module type TEZOS_CONTEXT = sig (** Close the index. Does not fail when the context is already closed. *) val close : index -> unit Lwt.t - val compute_testchain_chain_id : Block_hash.t -> Chain_id.t + val compute_testchain_chain_id : + Tezos_crypto.Block_hash.t -> Tezos_crypto.Chain_id.t - val compute_testchain_genesis : Block_hash.t -> Block_hash.t + val compute_testchain_genesis : + Tezos_crypto.Block_hash.t -> Tezos_crypto.Block_hash.t (** Build an empty context from an index. The resulting context should not be committed. *) @@ -689,10 +691,10 @@ module type TEZOS_CONTEXT = sig val commit_genesis : index -> - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> time:Time.Protocol.t -> - protocol:Protocol_hash.t -> - Context_hash.t tzresult Lwt.t + protocol:Tezos_crypto.Protocol_hash.t -> + Tezos_crypto.Context_hash.t tzresult Lwt.t val commit_test_chain_genesis : context -> Block_header.t -> Block_header.t Lwt.t @@ -723,22 +725,26 @@ module type TEZOS_CONTEXT = sig (** {2 Accessing and Updating Versions} *) - val exists : index -> Context_hash.t -> bool Lwt.t + val exists : index -> Tezos_crypto.Context_hash.t -> bool Lwt.t - val checkout : index -> Context_hash.t -> context option Lwt.t + val checkout : index -> Tezos_crypto.Context_hash.t -> context option Lwt.t - val checkout_exn : index -> Context_hash.t -> context Lwt.t + val checkout_exn : index -> Tezos_crypto.Context_hash.t -> context Lwt.t - val hash : time:Time.Protocol.t -> ?message:string -> t -> Context_hash.t + val hash : + time:Time.Protocol.t -> ?message:string -> t -> Tezos_crypto.Context_hash.t val commit : - time:Time.Protocol.t -> ?message:string -> context -> Context_hash.t Lwt.t + time:Time.Protocol.t -> + ?message:string -> + context -> + Tezos_crypto.Context_hash.t Lwt.t (** [gc t h] removes from disk all the data older than the commit [hash]. Every operations working on checkouts greater or equal to [h] will continue to work. Calling [checkout h'] on GC-ed commits will return [None]. *) - val gc : index -> Context_hash.t -> unit Lwt.t + val gc : index -> Tezos_crypto.Context_hash.t -> unit Lwt.t (** Sync the context with disk. Only useful for read-only instances. Does not fail when the context is not in read-only mode. *) @@ -750,26 +756,30 @@ module type TEZOS_CONTEXT = sig strategy mode "always", which is not suitable for GC.*) val is_gc_allowed : index -> bool - val set_head : index -> Chain_id.t -> Context_hash.t -> unit Lwt.t + val set_head : + index -> + Tezos_crypto.Chain_id.t -> + Tezos_crypto.Context_hash.t -> + unit Lwt.t - val set_master : index -> Context_hash.t -> unit Lwt.t + val set_master : index -> Tezos_crypto.Context_hash.t -> unit Lwt.t (** {2 Hash version} *) (** Get the hash version used for the context *) - val get_hash_version : context -> Context_hash.Version.t + val get_hash_version : context -> Tezos_crypto.Context_hash.Version.t (** Set the hash version used for the context. It may recalculate the hashes of the whole context, which can be a long process. Returns an [Error] if the hash version is unsupported. *) val set_hash_version : - context -> Context_hash.Version.t -> context tzresult Lwt.t + context -> Tezos_crypto.Context_hash.Version.t -> context tzresult Lwt.t (** {2 Predefined Fields} *) - val get_protocol : context -> Protocol_hash.t Lwt.t + val get_protocol : context -> Tezos_crypto.Protocol_hash.t Lwt.t - val add_protocol : context -> Protocol_hash.t -> context Lwt.t + val add_protocol : context -> Tezos_crypto.Protocol_hash.t -> context Lwt.t val get_test_chain : context -> Test_chain_status.t Lwt.t @@ -779,50 +789,51 @@ module type TEZOS_CONTEXT = sig val fork_test_chain : context -> - protocol:Protocol_hash.t -> + protocol:Tezos_crypto.Protocol_hash.t -> expiration:Time.Protocol.t -> context Lwt.t - val clear_test_chain : index -> Chain_id.t -> unit Lwt.t + val clear_test_chain : index -> Tezos_crypto.Chain_id.t -> unit Lwt.t val find_predecessor_block_metadata_hash : - context -> Block_metadata_hash.t option Lwt.t + context -> Tezos_crypto.Block_metadata_hash.t option Lwt.t val add_predecessor_block_metadata_hash : - context -> Block_metadata_hash.t -> context Lwt.t + context -> Tezos_crypto.Block_metadata_hash.t -> context Lwt.t val find_predecessor_ops_metadata_hash : - context -> Operation_metadata_list_list_hash.t option Lwt.t + context -> Tezos_crypto.Operation_metadata_list_list_hash.t option Lwt.t val add_predecessor_ops_metadata_hash : - context -> Operation_metadata_list_list_hash.t -> context Lwt.t + context -> Tezos_crypto.Operation_metadata_list_list_hash.t -> context Lwt.t val retrieve_commit_info : index -> Block_header.t -> - (Protocol_hash.t + (Tezos_crypto.Protocol_hash.t * string * string * Time.Protocol.t * Test_chain_status.t - * Context_hash.t - * Block_metadata_hash.t option - * Operation_metadata_list_list_hash.t option - * Context_hash.t list) + * Tezos_crypto.Context_hash.t + * Tezos_crypto.Block_metadata_hash.t option + * Tezos_crypto.Operation_metadata_list_list_hash.t option + * Tezos_crypto.Context_hash.t list) tzresult Lwt.t val check_protocol_commit_consistency : - expected_context_hash:Context_hash.t -> - given_protocol_hash:Protocol_hash.t -> + expected_context_hash:Tezos_crypto.Context_hash.t -> + given_protocol_hash:Tezos_crypto.Protocol_hash.t -> author:string -> message:string -> timestamp:Time.Protocol.t -> test_chain_status:Test_chain_status.t -> - predecessor_block_metadata_hash:Block_metadata_hash.t option -> - predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> - data_merkle_root:Context_hash.t -> - parents_contexts:Context_hash.t list -> + predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> + predecessor_ops_metadata_hash: + Tezos_crypto.Operation_metadata_list_list_hash.t option -> + data_merkle_root:Tezos_crypto.Context_hash.t -> + parents_contexts:Tezos_crypto.Context_hash.t list -> bool Lwt.t end diff --git a/src/lib_context/test/test_context.ml b/src/lib_context/test/test_context.ml index 902d0b36f592..0fd11c9c1456 100644 --- a/src/lib_context/test/test_context.ml +++ b/src/lib_context/test/test_context.ml @@ -34,7 +34,13 @@ module Assert_lib = Lib_test_extra.Assert_lib module Assert = Lib_test.Assert let equal_context_hash ?loc ?msg l1 l2 = - Assert.equal ?loc ~eq:Context_hash.( = ) ~pp:Context_hash.pp ?msg l1 l2 + Assert.equal + ?loc + ~eq:Tezos_crypto.Context_hash.( = ) + ~pp:Tezos_crypto.Context_hash.pp + ?msg + l1 + l2 let ( let* ) = Lwt.bind @@ -54,16 +60,16 @@ open Filename.Infix (** Basic blocks *) let genesis_block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisGeneskvg68z" let genesis_protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" let genesis_time = Time.Protocol.of_seconds 0L -let chain_id = Chain_id.of_block_hash genesis_block +let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis_block (** Test functors *) @@ -113,10 +119,10 @@ struct type t = { idx : Context.index; - genesis : Context_hash.t; - block2 : Context_hash.t; - block3a : Context_hash.t; - block3b : Context_hash.t; + genesis : Tezos_crypto.Context_hash.t; + block2 : Tezos_crypto.Context_hash.t; + block3a : Tezos_crypto.Context_hash.t; + block3b : Tezos_crypto.Context_hash.t; } type init_config = {indexing_strategy : [`Always | `Minimal]} @@ -487,14 +493,14 @@ struct let* h = commit ctxt in equal_context_hash ~loc:__LOC__ - (Context_hash.of_b58check_exn + (Tezos_crypto.Context_hash.of_b58check_exn "CoWJsL2ehZ39seTr8inBCJb5tVjW8KGNweJ5cvuVq51mAASrRmim") h ; let* ctxt = add ctxt [string 255] foo2 in let* h = commit ctxt in equal_context_hash ~loc:__LOC__ - (Context_hash.of_b58check_exn + (Tezos_crypto.Context_hash.of_b58check_exn "CoVexcEHMXmSA2k42aNc5MCDtVJFRs3CC6vcQWYwFoj7EFsBPw1c") h ; Lwt.return () @@ -548,7 +554,8 @@ struct (fun wrong_version -> let* ctxt = Context.checkout_exn idx block2 in let+ r = - set_hash_version ctxt @@ Context_hash.Version.of_int wrong_version + set_hash_version ctxt + @@ Tezos_crypto.Context_hash.Version.of_int wrong_version in match r with | Ok _ -> @@ -724,10 +731,10 @@ struct type t = { idx : Context.index; - genesis : Context_hash.t; - block2 : Context_hash.t; - block3a : Context_hash.t; - block3b : Context_hash.t; + genesis : Tezos_crypto.Context_hash.t; + block2 : Tezos_crypto.Context_hash.t; + block3a : Tezos_crypto.Context_hash.t; + block3b : Tezos_crypto.Context_hash.t; } type init_config = {indexing_strategy : [`Always | `Minimal]} @@ -769,10 +776,10 @@ struct { level = 0l; proto_level = 0; - predecessor = Block_hash.zero; + predecessor = Tezos_crypto.Block_hash.zero; timestamp = Time.Protocol.epoch; validation_passes = 0; - operations_hash = Operation_list_list_hash.zero; + operations_hash = Tezos_crypto.Operation_list_list_hash.zero; fitness = []; context; }; diff --git a/src/lib_context/test/test_merkle_proof.ml b/src/lib_context/test/test_merkle_proof.ml index c8db714682ce..49b347780bd1 100644 --- a/src/lib_context/test/test_merkle_proof.ml +++ b/src/lib_context/test/test_merkle_proof.ml @@ -37,8 +37,8 @@ module Gen = struct Bytes.unsafe_of_string s let hash = - let+ s = string_size ~gen:char (return Context_hash.size) in - Context_hash.of_string_exn s + let+ s = string_size ~gen:char (return Tezos_crypto.Context_hash.size) in + Tezos_crypto.Context_hash.of_string_exn s let rec comb n xs = match (n, xs) with @@ -194,7 +194,8 @@ module Proof32 (Encoding : Tezos_context_sigs.Context.PROOF_ENCODING) = struct let bytes s = Bytes.of_string s in let tree_a : tree = Value (bytes "a") in let ch = - Context_hash.of_bytes_exn (bytes "01234567890123456789012345678901") + Tezos_crypto.Context_hash.of_bytes_exn + (bytes "01234567890123456789012345678901") in let tree_b = Extender @@ -224,7 +225,8 @@ module Proof32 (Encoding : Tezos_context_sigs.Context.PROOF_ENCODING) = struct let bytes s = Bytes.of_string s in let tree_a c : tree = Value (bytes @@ "a" ^ c) in let ch = - Context_hash.of_bytes_exn (bytes "01234567890123456789012345678901") + Tezos_crypto.Context_hash.of_bytes_exn + (bytes "01234567890123456789012345678901") in let inode_tree i : inode_tree = let c = string_of_int i in @@ -411,7 +413,8 @@ module Proof2 (Encoding : Tezos_context_sigs.Context.PROOF_ENCODING) = struct let bytes s = Bytes.of_string s in let tree_a : tree = Value (bytes "a") in let ch = - Context_hash.of_bytes_exn (bytes "01234567890123456789012345678901") + Tezos_crypto.Context_hash.of_bytes_exn + (bytes "01234567890123456789012345678901") in let tree_b = Extender @@ -448,7 +451,8 @@ module Proof2 (Encoding : Tezos_context_sigs.Context.PROOF_ENCODING) = struct let bytes s = Bytes.of_string s in let tree_a c : tree = Value (bytes @@ "a" ^ c) in let ch = - Context_hash.of_bytes_exn (bytes "01234567890123456789012345678901") + Tezos_crypto.Context_hash.of_bytes_exn + (bytes "01234567890123456789012345678901") in let inode_tree i : inode_tree = let c = string_of_int i in -- GitLab From 6b566364a081275914d769738b552448408415d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 18:03:04 +0200 Subject: [PATCH 05/30] Tree-encoding: unopen Crypto --- src/lib_tree_encoding/tezos_tree_encoding.mli | 2 +- src/lib_tree_encoding/tree.ml | 4 ++-- src/lib_tree_encoding/tree.mli | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib_tree_encoding/tezos_tree_encoding.mli b/src/lib_tree_encoding/tezos_tree_encoding.mli index f2f4fc01a63d..443e9248c17c 100644 --- a/src/lib_tree_encoding/tezos_tree_encoding.mli +++ b/src/lib_tree_encoding/tezos_tree_encoding.mli @@ -269,7 +269,7 @@ module type TREE = sig val find_tree : tree -> key -> tree option Lwt.t - val hash : tree -> Context_hash.t + val hash : tree -> Tezos_crypto.Context_hash.t val length : tree -> key -> int Lwt.t diff --git a/src/lib_tree_encoding/tree.ml b/src/lib_tree_encoding/tree.ml index 297c7c02b8d9..94a9d8539694 100644 --- a/src/lib_tree_encoding/tree.ml +++ b/src/lib_tree_encoding/tree.ml @@ -47,7 +47,7 @@ module type S = sig val find_tree : tree -> key -> tree option Lwt.t - val hash : tree -> Context_hash.t + val hash : tree -> Tezos_crypto.Context_hash.t val length : tree -> key -> int Lwt.t @@ -80,7 +80,7 @@ let find : type tree. tree backend -> tree -> key -> value option Lwt.t = let find_tree : type tree. tree backend -> tree -> key -> tree option Lwt.t = fun (module T) tree key -> T.find_tree tree key -let hash : type tree. tree backend -> tree -> Context_hash.t = +let hash : type tree. tree backend -> tree -> Tezos_crypto.Context_hash.t = fun (module T) tree -> T.hash tree let length : type tree. tree backend -> tree -> key -> int Lwt.t = diff --git a/src/lib_tree_encoding/tree.mli b/src/lib_tree_encoding/tree.mli index 48873f112af4..8dc408a5dffd 100644 --- a/src/lib_tree_encoding/tree.mli +++ b/src/lib_tree_encoding/tree.mli @@ -51,7 +51,7 @@ module type S = sig val find_tree : tree -> key -> tree option Lwt.t - val hash : tree -> Context_hash.t + val hash : tree -> Tezos_crypto.Context_hash.t val length : tree -> key -> int Lwt.t -- GitLab From 9cb295c6b97c1adf6cfd16066aef9b2b43bb672b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 23 Sep 2022 18:04:06 +0200 Subject: [PATCH 06/30] Scoru-wasm: unopen Crypto --- src/lib_scoru_wasm/durable.mli | 4 ++-- src/lib_scoru_wasm/test/test_fast.ml | 2 +- src/lib_scoru_wasm/test/test_hash_consistency.ml | 3 ++- src/lib_scoru_wasm/test/test_wasm_pvm.ml | 14 ++++++++++---- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lib_scoru_wasm/durable.mli b/src/lib_scoru_wasm/durable.mli index 3cc60c80f0d4..ca2db83f115c 100644 --- a/src/lib_scoru_wasm/durable.mli +++ b/src/lib_scoru_wasm/durable.mli @@ -112,14 +112,14 @@ val delete : ?edit_readonly:bool -> t -> key -> t Lwt.t (** [hash durable key] retrieves the tree hash of the value at the given [key]. This is not the same as the hash of the value. *) -val hash : t -> key -> Context_hash.t option Lwt.t +val hash : t -> key -> Tezos_crypto.Context_hash.t option Lwt.t (** [hash_exn durable key] retrieves the tree hash of the value at the given [key]. This is not the same as the hash of the value. @raise Not_found when [key] is not found *) -val hash_exn : t -> key -> Context_hash.t Lwt.t +val hash_exn : t -> key -> Tezos_crypto.Context_hash.t Lwt.t (** [write_value ?edit_readonly durable key offset bytes] writes [bytes] to [key], starting at the given [offset]. diff --git a/src/lib_scoru_wasm/test/test_fast.ml b/src/lib_scoru_wasm/test/test_fast.ml index efdd88bc6917..d730de5c86a2 100644 --- a/src/lib_scoru_wasm/test/test_fast.ml +++ b/src/lib_scoru_wasm/test/test_fast.ml @@ -83,7 +83,7 @@ let test_against_both ~from_binary ~kernel ~messages = let* fast_hashes = run_with apply_fast in let* slow_hashes = run_with (fun _ tree -> apply_slow tree) in - assert (List.equal Context_hash.equal slow_hashes fast_hashes) ; + assert (List.equal Tezos_crypto.Context_hash.equal slow_hashes fast_hashes) ; Lwt_result_syntax.return_unit diff --git a/src/lib_scoru_wasm/test/test_hash_consistency.ml b/src/lib_scoru_wasm/test/test_hash_consistency.ml index 594269d1b121..0261e92caaa1 100644 --- a/src/lib_scoru_wasm/test/test_hash_consistency.ml +++ b/src/lib_scoru_wasm/test/test_hash_consistency.ml @@ -50,7 +50,8 @@ let test_execution_correspondance skip count () = let*! tree_ref, _ = Wasm.compute_step_many ~max_steps:n tree in let*! tree' = Wasm.compute_step tree' in assert ( - Context_hash.(Context.Tree.hash tree_ref = Context.Tree.hash tree')) ; + Tezos_crypto.Context_hash.( + Context.Tree.hash tree_ref = Context.Tree.hash tree')) ; if n < count then explore tree' (Int64.succ n) else return_unit in explore tree 1L) diff --git a/src/lib_scoru_wasm/test/test_wasm_pvm.ml b/src/lib_scoru_wasm/test/test_wasm_pvm.ml index be0e909097d5..dd963d33438f 100644 --- a/src/lib_scoru_wasm/test/test_wasm_pvm.ml +++ b/src/lib_scoru_wasm/test/test_wasm_pvm.ml @@ -697,7 +697,8 @@ let test_rebuild_snapshotable_state () = (* Both hash should be exactly the same. *) let hash_tree_after_eval = Test_encodings_util.Tree.hash tree_after_eval in let hash_rebuilded_tree = Test_encodings_util.Tree.hash rebuilded_tree in - assert (Context_hash.equal hash_tree_after_eval hash_rebuilded_tree) ; + assert ( + Tezos_crypto.Context_hash.equal hash_tree_after_eval hash_rebuilded_tree) ; (* The hash of the tree rebuilded from the evaluated one without the "wasm" part should also be exactly the same. *) @@ -705,7 +706,9 @@ let test_rebuild_snapshotable_state () = Test_encodings_util.Tree.hash rebuilded_tree_without_wasm in assert ( - Context_hash.equal hash_tree_after_eval hash_rebuilded_tree_without_wasm) ; + Tezos_crypto.Context_hash.equal + hash_tree_after_eval + hash_rebuilded_tree_without_wasm) ; (* To be sure, let's try to evaluate a new input from these two, either by the regular tree or the snapshoted one. *) @@ -726,7 +729,9 @@ let test_rebuild_snapshotable_state () = in assert ( - Context_hash.equal hash_input_tree_after_eval hash_input_rebuilded_tree) ; + Tezos_crypto.Context_hash.equal + hash_input_tree_after_eval + hash_input_rebuilded_tree) ; return_unit let test_unkown_host_function_truncated () = @@ -794,7 +799,8 @@ let test_bulk_noops () = let* tree_fast, _ = Wasm.compute_step_many ~max_steps:ticks base_tree in let* tree_slow = Wasm.compute_step tree_slow in assert ( - Context_hash.(Test_encodings_util.Tree.(hash tree_fast = hash tree_slow))) ; + Tezos_crypto.Context_hash.( + Test_encodings_util.Tree.(hash tree_fast = hash tree_slow))) ; let* stuck_flag = has_stuck_flag tree_fast in assert (not stuck_flag) ; -- GitLab From f4b9224f317a6d109d221cbc2ec77e39da3215bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 08:57:52 +0200 Subject: [PATCH 07/30] Proto-env: unopen Crypto --- .../environment_V0.ml | 55 +++++----- .../environment_V0.mli | 44 ++++---- .../environment_V1.ml | 61 ++++++----- .../environment_V1.mli | 44 ++++---- .../environment_V2.ml | 61 ++++++----- .../environment_V2.mli | 44 ++++---- .../environment_V3.ml | 95 ++++++++-------- .../environment_V3.mli | 52 +++++---- .../environment_V4.ml | 95 ++++++++-------- .../environment_V4.mli | 52 +++++---- .../environment_V5.ml | 95 ++++++++-------- .../environment_V5.mli | 52 +++++---- .../environment_V6.ml | 95 ++++++++-------- .../environment_V6.mli | 52 +++++---- .../environment_V7.ml | 103 +++++++++--------- .../environment_V7.mli | 58 +++++----- .../environment_V8.ml | 103 +++++++++--------- .../environment_V8.mli | 58 +++++----- .../environment_context.ml | 18 +-- .../environment_context.mli | 12 +- .../environment_context_intf.ml | 16 ++- .../environment_protocol_T.ml | 24 ++-- .../environment_protocol_T_V0.ml | 8 +- .../environment_protocol_T_V3.ml | 12 +- .../environment_protocol_T_V6.ml | 14 +-- .../environment_protocol_T_V7.ml | 42 +++---- .../environment_protocol_T_test.ml | 16 +-- .../shell_context/proxy_delegate_maker.ml | 7 +- .../shell_context/proxy_delegate_maker.mli | 2 +- .../test/test_cache.ml | 4 +- .../tezos_protocol_environment.ml | 2 +- 31 files changed, 748 insertions(+), 648 deletions(-) diff --git a/src/lib_protocol_environment/environment_V0.ml b/src/lib_protocol_environment/environment_V0.ml index 79ee56de0300..9f3e857eeccc 100644 --- a/src/lib_protocol_environment/environment_V0.ml +++ b/src/lib_protocol_environment/environment_V0.ml @@ -35,14 +35,15 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type MBytes.t = Tezos_protocol_environment_structs.V0.MBytes.t and type Operation.shell_header = Operation.shell_header @@ -50,19 +51,22 @@ module type T = sig and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node @@ -135,11 +139,12 @@ struct module MBytes = MBytes module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) end module Z = struct @@ -193,9 +198,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig diff --git a/src/lib_protocol_environment/environment_V0.mli b/src/lib_protocol_environment/environment_V0.mli index 71ec9503218f..5e31b3574097 100644 --- a/src/lib_protocol_environment/environment_V0.mli +++ b/src/lib_protocol_environment/environment_V0.mli @@ -35,14 +35,15 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type MBytes.t = Tezos_protocol_environment_structs.V0.MBytes.t and type Operation.shell_header = Operation.shell_header @@ -50,19 +51,22 @@ module type T = sig and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node diff --git a/src/lib_protocol_environment/environment_V1.ml b/src/lib_protocol_environment/environment_V1.ml index 3a3208428126..1b40214ac966 100644 --- a/src/lib_protocol_environment/environment_V1.ml +++ b/src/lib_protocol_environment/environment_V1.ml @@ -36,33 +36,37 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node @@ -128,17 +132,18 @@ struct module Option = Option module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -179,9 +184,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig diff --git a/src/lib_protocol_environment/environment_V1.mli b/src/lib_protocol_environment/environment_V1.mli index 29ced82a11e3..560a57cf0d86 100644 --- a/src/lib_protocol_environment/environment_V1.mli +++ b/src/lib_protocol_environment/environment_V1.mli @@ -35,33 +35,37 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node diff --git a/src/lib_protocol_environment/environment_V2.ml b/src/lib_protocol_environment/environment_V2.ml index fadad959e535..9c60fee46ad7 100644 --- a/src/lib_protocol_environment/environment_V2.ml +++ b/src/lib_protocol_environment/environment_V2.ml @@ -36,33 +36,37 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node @@ -134,17 +138,18 @@ struct module Option = Tezos_error_monad.TzLwtreslib.Option module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -185,9 +190,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig diff --git a/src/lib_protocol_environment/environment_V2.mli b/src/lib_protocol_environment/environment_V2.mli index c280d3f38a12..a4b1e9d41736 100644 --- a/src/lib_protocol_environment/environment_V2.mli +++ b/src/lib_protocol_environment/environment_V2.mli @@ -35,33 +35,37 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t - and type Context_hash.t = Context_hash.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node diff --git a/src/lib_protocol_environment/environment_V3.ml b/src/lib_protocol_environment/environment_V3.ml index 1c318b4d27c4..9905a5b8c1f6 100644 --- a/src/lib_protocol_environment/environment_V3.ml +++ b/src/lib_protocol_environment/environment_V3.ml @@ -36,36 +36,40 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node @@ -76,9 +80,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator_legacy type error += Ecoproto_error of Error_monad.error @@ -239,17 +243,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -266,11 +271,11 @@ struct module Time = Time.Protocol module Bls12_381 = Bls12_381 - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module S = struct module type T = Tezos_base.S.T @@ -290,9 +295,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -675,14 +680,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V3.mli b/src/lib_protocol_environment/environment_V3.mli index abc612bbe70c..1e1ed5e2b3aa 100644 --- a/src/lib_protocol_environment/environment_V3.mli +++ b/src/lib_protocol_environment/environment_V3.mli @@ -35,36 +35,40 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t and type ('a, 'b) Micheline.node = ('a, 'b) Micheline.node @@ -75,9 +79,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator_legacy (** An [Ecoproto_error e] is a shell error that carry a protocol error. diff --git a/src/lib_protocol_environment/environment_V4.ml b/src/lib_protocol_environment/environment_V4.ml index 421706fdcab8..c883b5052f5c 100644 --- a/src/lib_protocol_environment/environment_V4.ml +++ b/src/lib_protocol_environment/environment_V4.ml @@ -40,36 +40,40 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -81,9 +85,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator_legacy and type Bls_signature.pk = Bls12_381_signature.MinPk.pk @@ -239,17 +243,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -300,11 +305,11 @@ struct (List.map Bls12_381_signature.MinPk.unsafe_signature_of_bytes sigs) end - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module S = struct module type T = Tezos_base.S.T @@ -324,9 +329,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -706,14 +711,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V4.mli b/src/lib_protocol_environment/environment_V4.mli index 2eeb58dfaf35..771f5ddbea36 100644 --- a/src/lib_protocol_environment/environment_V4.mli +++ b/src/lib_protocol_environment/environment_V4.mli @@ -35,36 +35,40 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t - and type Protocol_hash.t = Protocol_hash.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -76,9 +80,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator_legacy and type Bls_signature.pk = Bls12_381_signature.MinPk.pk diff --git a/src/lib_protocol_environment/environment_V5.ml b/src/lib_protocol_environment/environment_V5.ml index ca24ac21d033..8da55b05f452 100644 --- a/src/lib_protocol_environment/environment_V5.ml +++ b/src/lib_protocol_environment/environment_V5.ml @@ -43,38 +43,42 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -86,9 +90,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type Bls_signature.pk = Bls12_381_signature.MinPk.pk and type Bls_signature.signature = Bls12_381_signature.MinPk.signature @@ -224,17 +228,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -265,11 +270,11 @@ struct let aggregate_verify = Aug.aggregate_verify end - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module S = struct module type T = Tezos_base.S.T @@ -289,9 +294,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -679,14 +684,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V5.mli b/src/lib_protocol_environment/environment_V5.mli index b051f57aaf2a..5bb9c81581d1 100644 --- a/src/lib_protocol_environment/environment_V5.mli +++ b/src/lib_protocol_environment/environment_V5.mli @@ -44,38 +44,42 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -87,9 +91,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type Bls_signature.pk = Bls12_381_signature.MinPk.pk and type Bls_signature.signature = Bls12_381_signature.MinPk.signature diff --git a/src/lib_protocol_environment/environment_V6.ml b/src/lib_protocol_environment/environment_V6.ml index 88781ba16fa8..e835c768610c 100644 --- a/src/lib_protocol_environment/environment_V6.ml +++ b/src/lib_protocol_environment/environment_V6.ml @@ -43,38 +43,42 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -86,9 +90,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type Bls_signature.pk = Bls12_381_signature.MinPk.pk and type Bls_signature.signature = Bls12_381_signature.MinPk.signature @@ -230,17 +234,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -271,11 +276,11 @@ struct let aggregate_verify = Aug.aggregate_verify end - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module Vdf = Class_group_vdf.Vdf_self_contained module S = struct @@ -296,9 +301,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -686,14 +691,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V6.mli b/src/lib_protocol_environment/environment_V6.mli index b024ffc0ae20..15a1bc7e9dbc 100644 --- a/src/lib_protocol_environment/environment_V6.mli +++ b/src/lib_protocol_environment/environment_V6.mli @@ -44,38 +44,42 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -87,9 +91,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type Bls_signature.pk = Bls12_381_signature.MinPk.pk and type Bls_signature.signature = Bls12_381_signature.MinPk.signature diff --git a/src/lib_protocol_environment/environment_V7.ml b/src/lib_protocol_environment/environment_V7.ml index 5623c0ddb38a..ec83aded0726 100644 --- a/src/lib_protocol_environment/environment_V7.ml +++ b/src/lib_protocol_environment/environment_V7.ml @@ -43,41 +43,45 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Bls.Public_key_hash.t = Bls.Public_key_hash.t - and type Bls.Public_key.t = Bls.Public_key.t - and type Bls.t = Bls.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Bls.Public_key_hash.t = Tezos_crypto.Bls.Public_key_hash.t + and type Bls.Public_key.t = Tezos_crypto.Bls.Public_key.t + and type Bls.t = Tezos_crypto.Bls.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -90,9 +94,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type ('a, 'b) Either.t = ('a, 'b) Stdlib.Either.t and type Bls.Primitive.Fr.t = Bls12_381.Fr.t @@ -238,17 +242,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -265,12 +270,12 @@ struct end module Time = Time.Protocol - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Bls = Bls - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Bls = Tezos_crypto.Bls + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module Vdf = Class_group_vdf.Vdf_self_contained module S = struct @@ -291,9 +296,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -690,14 +695,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V7.mli b/src/lib_protocol_environment/environment_V7.mli index 3a6e101e307e..a0149fa22f08 100644 --- a/src/lib_protocol_environment/environment_V7.mli +++ b/src/lib_protocol_environment/environment_V7.mli @@ -43,41 +43,45 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Bls.Public_key_hash.t = Bls.Public_key_hash.t - and type Bls.Public_key.t = Bls.Public_key.t - and type Bls.t = Bls.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Bls.Public_key_hash.t = Tezos_crypto.Bls.Public_key_hash.t + and type Bls.Public_key.t = Tezos_crypto.Bls.Public_key.t + and type Bls.t = Tezos_crypto.Bls.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -90,9 +94,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type ('a, 'b) Either.t = ('a, 'b) Stdlib.Either.t and type Bls.Primitive.Fr.t = Bls12_381.Fr.t diff --git a/src/lib_protocol_environment/environment_V8.ml b/src/lib_protocol_environment/environment_V8.ml index 58374cfafca8..608df862270c 100644 --- a/src/lib_protocol_environment/environment_V8.ml +++ b/src/lib_protocol_environment/environment_V8.ml @@ -43,41 +43,45 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Bls.Public_key_hash.t = Bls.Public_key_hash.t - and type Bls.Public_key.t = Bls.Public_key.t - and type Bls.t = Bls.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Bls.Public_key_hash.t = Tezos_crypto.Bls.Public_key_hash.t + and type Bls.Public_key.t = Tezos_crypto.Bls.Public_key.t + and type Bls.t = Tezos_crypto.Bls.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -90,9 +94,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type ('a, 'b) Either.t = ('a, 'b) Stdlib.Either.t and type Bls.Primitive.Fr.t = Bls12_381.Fr.t @@ -245,17 +249,18 @@ struct end module Raw_hashes = struct - let sha256 = Hacl.Hash.SHA256.digest + let sha256 = Tezos_crypto.Hacl.Hash.SHA256.digest - let sha512 = Hacl.Hash.SHA512.digest + let sha512 = Tezos_crypto.Hacl.Hash.SHA512.digest - let blake2b msg = Blake2B.to_bytes (Blake2B.hash_bytes [msg]) + let blake2b msg = + Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [msg]) - let keccak256 msg = Hacl.Hash.Keccak_256.digest msg + let keccak256 msg = Tezos_crypto.Hacl.Hash.Keccak_256.digest msg - let sha3_256 msg = Hacl.Hash.SHA3_256.digest msg + let sha3_256 msg = Tezos_crypto.Hacl.Hash.SHA3_256.digest msg - let sha3_512 msg = Hacl.Hash.SHA3_512.digest msg + let sha3_512 msg = Tezos_crypto.Hacl.Hash.SHA3_512.digest msg end module Z = Z @@ -272,12 +277,12 @@ struct end module Time = Time.Protocol - module Ed25519 = Ed25519 - module Secp256k1 = Secp256k1 - module P256 = P256 - module Bls = Bls - module Signature = Signature - module Timelock = Timelock + module Ed25519 = Tezos_crypto.Ed25519 + module Secp256k1 = Tezos_crypto.Secp256k1 + module P256 = Tezos_crypto.P256 + module Bls = Tezos_crypto.Bls + module Signature = Tezos_crypto.Signature + module Timelock = Tezos_crypto.Timelock module Vdf = Class_group_vdf.Vdf_self_contained module S = struct @@ -298,9 +303,9 @@ struct val of_b58check_opt : string -> t option - type Base58.data += Data of t + type Tezos_crypto.Base58.data += Data of t - val b58check_encoding : t Base58.encoding + val b58check_encoding : t Tezos_crypto.Base58.encoding end module type RAW_DATA = sig @@ -697,14 +702,14 @@ struct let wrap_tzresult r = Result.map_error wrap_tztrace r - module Chain_id = Chain_id - module Block_hash = Block_hash - module Operation_hash = Operation_hash - module Operation_list_hash = Operation_list_hash - module Operation_list_list_hash = Operation_list_list_hash - module Context_hash = Context_hash - module Protocol_hash = Protocol_hash - module Blake2B = Blake2B + module Chain_id = Tezos_crypto.Chain_id + module Block_hash = Tezos_crypto.Block_hash + module Operation_hash = Tezos_crypto.Operation_hash + module Operation_list_hash = Tezos_crypto.Operation_list_hash + module Operation_list_list_hash = Tezos_crypto.Operation_list_list_hash + module Context_hash = Tezos_crypto.Context_hash + module Protocol_hash = Tezos_crypto.Protocol_hash + module Blake2B = Tezos_crypto.Blake2B module Fitness = Fitness module Operation = Operation module Block_header = Block_header diff --git a/src/lib_protocol_environment/environment_V8.mli b/src/lib_protocol_environment/environment_V8.mli index e5b4772a3794..f44710bb601a 100644 --- a/src/lib_protocol_environment/environment_V8.mli +++ b/src/lib_protocol_environment/environment_V8.mli @@ -43,41 +43,45 @@ module type T = sig and type 'a Data_encoding.lazy_t = 'a Data_encoding.lazy_t and type 'a Lwt.t = 'a Lwt.t and type ('a, 'b) Pervasives.result = ('a, 'b) result - and type Chain_id.t = Chain_id.t - and type Block_hash.t = Block_hash.t - and type Operation_hash.t = Operation_hash.t - and type Operation_list_hash.t = Operation_list_hash.t - and type Operation_list_list_hash.t = Operation_list_list_hash.t + and type Chain_id.t = Tezos_crypto.Chain_id.t + and type Block_hash.t = Tezos_crypto.Block_hash.t + and type Operation_hash.t = Tezos_crypto.Operation_hash.t + and type Operation_list_hash.t = Tezos_crypto.Operation_list_hash.t + and type Operation_list_list_hash.t = + Tezos_crypto.Operation_list_list_hash.t and type Context.t = Context.t and type Context.cache_key = Environment_context.Context.cache_key and type Context.cache_value = Environment_context.Context.cache_value - and type Context_hash.t = Context_hash.t - and type Context_hash.Version.t = Context_hash.Version.t + and type Context_hash.t = Tezos_crypto.Context_hash.t + and type Context_hash.Version.t = Tezos_crypto.Context_hash.Version.t and type Context.config = Tezos_context_sigs.Config.t and module Context.Proof = Environment_context.Context.Proof - and type Protocol_hash.t = Protocol_hash.t + and type Protocol_hash.t = Tezos_crypto.Protocol_hash.t and type Time.t = Time.Protocol.t and type Operation.shell_header = Operation.shell_header and type Operation.t = Operation.t and type Block_header.shell_header = Block_header.shell_header and type Block_header.t = Block_header.t and type 'a RPC_directory.t = 'a Tezos_rpc.Directory.t - and type Ed25519.Public_key_hash.t = Ed25519.Public_key_hash.t - and type Ed25519.Public_key.t = Ed25519.Public_key.t - and type Ed25519.t = Ed25519.t - and type Secp256k1.Public_key_hash.t = Secp256k1.Public_key_hash.t - and type Secp256k1.Public_key.t = Secp256k1.Public_key.t - and type Secp256k1.t = Secp256k1.t - and type P256.Public_key_hash.t = P256.Public_key_hash.t - and type P256.Public_key.t = P256.Public_key.t - and type P256.t = P256.t - and type Bls.Public_key_hash.t = Bls.Public_key_hash.t - and type Bls.Public_key.t = Bls.Public_key.t - and type Bls.t = Bls.t - and type Signature.public_key_hash = Signature.public_key_hash - and type Signature.public_key = Signature.public_key - and type Signature.t = Signature.t - and type Signature.watermark = Signature.watermark + and type Ed25519.Public_key_hash.t = + Tezos_crypto.Ed25519.Public_key_hash.t + and type Ed25519.Public_key.t = Tezos_crypto.Ed25519.Public_key.t + and type Ed25519.t = Tezos_crypto.Ed25519.t + and type Secp256k1.Public_key_hash.t = + Tezos_crypto.Secp256k1.Public_key_hash.t + and type Secp256k1.Public_key.t = Tezos_crypto.Secp256k1.Public_key.t + and type Secp256k1.t = Tezos_crypto.Secp256k1.t + and type P256.Public_key_hash.t = Tezos_crypto.P256.Public_key_hash.t + and type P256.Public_key.t = Tezos_crypto.P256.Public_key.t + and type P256.t = Tezos_crypto.P256.t + and type Bls.Public_key_hash.t = Tezos_crypto.Bls.Public_key_hash.t + and type Bls.Public_key.t = Tezos_crypto.Bls.Public_key.t + and type Bls.t = Tezos_crypto.Bls.t + and type Signature.public_key_hash = + Tezos_crypto.Signature.public_key_hash + and type Signature.public_key = Tezos_crypto.Signature.public_key + and type Signature.t = Tezos_crypto.Signature.t + and type Signature.watermark = Tezos_crypto.Signature.watermark and type Micheline.canonical_location = Micheline.canonical_location and type 'a Micheline.canonical = 'a Micheline.canonical and type Z.t = Z.t @@ -90,9 +94,9 @@ module type T = sig ('m, 'pr, 'p, 'q, 'i, 'o) Tezos_rpc.Service.t and type Error_monad.shell_tztrace = Error_monad.tztrace and type 'a Error_monad.shell_tzresult = ('a, Error_monad.tztrace) result - and type Timelock.chest = Timelock.chest - and type Timelock.chest_key = Timelock.chest_key - and type Timelock.opening_result = Timelock.opening_result + and type Timelock.chest = Tezos_crypto.Timelock.chest + and type Timelock.chest_key = Tezos_crypto.Timelock.chest_key + and type Timelock.opening_result = Tezos_crypto.Timelock.opening_result and module Sapling = Tezos_sapling.Core.Validator and type ('a, 'b) Either.t = ('a, 'b) Stdlib.Either.t and type Bls.Primitive.Fr.t = Bls12_381.Fr.t diff --git a/src/lib_protocol_environment/environment_context.ml b/src/lib_protocol_environment/environment_context.ml index 16d9a2825d9d..4064d8ec5e0f 100644 --- a/src/lib_protocol_environment/environment_context.ml +++ b/src/lib_protocol_environment/environment_context.ml @@ -385,10 +385,13 @@ module Context = struct type cache_key = Environment_cache.key - type block_cache = {context_hash : Context_hash.t; cache : cache} + type block_cache = {context_hash : Tezos_crypto.Context_hash.t; cache : cache} type source_of_cache = - [`Force_load | `Load | `Lazy | `Inherited of block_cache * Context_hash.t] + [ `Force_load + | `Load + | `Lazy + | `Inherited of block_cache * Tezos_crypto.Context_hash.t ] type builder = Environment_cache.key -> cache_value tzresult Lwt.t @@ -654,7 +657,8 @@ module Context = struct let open Lwt_syntax in match mode with | `Inherited ({context_hash; cache}, predecessor_context_hash) -> - if Context_hash.equal context_hash predecessor_context_hash then + if Tezos_crypto.Context_hash.equal context_hash predecessor_context_hash + then (* We can safely reuse the cache of the predecessor block. @@ -699,11 +703,11 @@ module Context = struct *) module Cache_cache = Ringo_lwt.Functors.Make_result_presized (Ringo.SingletonMap (struct - type t = Block_hash.t + type t = Tezos_crypto.Block_hash.t - let equal = Block_hash.equal + let equal = Tezos_crypto.Block_hash.equal - let hash = Block_hash.hash + let hash = Tezos_crypto.Block_hash.hash end)) let cache_cache : (cache, error trace) Cache_cache.t = Cache_cache.create () @@ -768,7 +772,7 @@ type validation_result = { type quota = {max_size : int; max_op : int option} type rpc_context = { - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; block_header : Block_header.shell_header; context : Context.t; } diff --git a/src/lib_protocol_environment/environment_context.mli b/src/lib_protocol_environment/environment_context.mli index 656e797c8625..afa6a7d4b686 100644 --- a/src/lib_protocol_environment/environment_context.mli +++ b/src/lib_protocol_environment/environment_context.mli @@ -122,7 +122,7 @@ module Context : sig (** A cache is a block-dependent value: to know whether a cache can be reused or recycled in a given block, we need the block that produces it. *) - type block_cache = {context_hash : Context_hash.t; cache : cache} + type block_cache = {context_hash : Tezos_crypto.Context_hash.t; cache : cache} (** During its loading, a cache can be populated in two different ways: @@ -171,7 +171,7 @@ module Context : sig and the cache cannot be inherited (as in the next case). *) - | `Inherited of block_cache * Context_hash.t + | `Inherited of block_cache * Tezos_crypto.Context_hash.t (** When we already have some [block_cache.cache] in memory coming from the validation of some block [block_cache.context_hash], we can reuse or recycle its entries to reconstruct a cache to @@ -203,7 +203,11 @@ module Context : sig key. In other words, the construction of cache should be reproducible. For this reason, an error in [builder] is fatal. *) val load_cache : - Block_hash.t -> t -> source_of_cache -> builder -> t tzresult Lwt.t + Tezos_crypto.Block_hash.t -> + t -> + source_of_cache -> + builder -> + t tzresult Lwt.t end module Register (C : S) : sig @@ -225,7 +229,7 @@ type validation_result = { type quota = {max_size : int; max_op : int option} type rpc_context = { - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; block_header : Block_header.shell_header; context : Context.t; } diff --git a/src/lib_protocol_environment/environment_context_intf.ml b/src/lib_protocol_environment/environment_context_intf.ml index 23cdf67fe958..66dca648998c 100644 --- a/src/lib_protocol_environment/environment_context_intf.ml +++ b/src/lib_protocol_environment/environment_context_intf.ml @@ -98,16 +98,20 @@ end module type CORE = sig type t - val set_protocol : t -> Protocol_hash.t -> t Lwt.t + val set_protocol : t -> Tezos_crypto.Protocol_hash.t -> t Lwt.t - val get_protocol : t -> Protocol_hash.t Lwt.t + val get_protocol : t -> Tezos_crypto.Protocol_hash.t Lwt.t val fork_test_chain : - t -> protocol:Protocol_hash.t -> expiration:Time.Protocol.t -> t Lwt.t + t -> + protocol:Tezos_crypto.Protocol_hash.t -> + expiration:Time.Protocol.t -> + t Lwt.t - val set_hash_version : t -> Context_hash.Version.t -> t tzresult Lwt.t + val set_hash_version : + t -> Tezos_crypto.Context_hash.Version.t -> t tzresult Lwt.t - val get_hash_version : t -> Context_hash.Version.t + val get_hash_version : t -> Tezos_crypto.Context_hash.Version.t end module type TREE_CORE = sig @@ -127,7 +131,7 @@ module type TREE_CORE = sig val of_value : t -> value -> tree Lwt.t - val hash : tree -> Context_hash.t + val hash : tree -> Tezos_crypto.Context_hash.t val equal : tree -> tree -> bool diff --git a/src/lib_protocol_environment/environment_protocol_T.ml b/src/lib_protocol_environment/environment_protocol_T.ml index f888482a8069..61b207bfb12e 100644 --- a/src/lib_protocol_environment/environment_protocol_T.ml +++ b/src/lib_protocol_environment/environment_protocol_T.ml @@ -86,12 +86,12 @@ module V0toV7 | Application of block_header | Partial_validation of block_header | Construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; block_header_data : block_header_data; } | Partial_construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; } @@ -188,19 +188,19 @@ module V0toV7 type validation_info = unit type conflict_handler = - existing_operation:Operation_hash.t * operation -> - new_operation:Operation_hash.t * operation -> + existing_operation:Tezos_crypto.Operation_hash.t * operation -> + new_operation:Tezos_crypto.Operation_hash.t * operation -> [`Keep | `Replace] type operation_conflict = | Operation_conflict of { - existing : Operation_hash.t; - new_operation : Operation_hash.t; + existing : Tezos_crypto.Operation_hash.t; + new_operation : Tezos_crypto.Operation_hash.t; } type add_result = | Added - | Replaced of {removed : Operation_hash.t} + | Replaced of {removed : Tezos_crypto.Operation_hash.t} | Unchanged type add_error = @@ -222,7 +222,7 @@ module V0toV7 let merge ?conflict_handler:_ () () = Ok () - let operations () = Operation_hash.Map.empty + let operations () = Tezos_crypto.Operation_hash.Map.empty end end @@ -251,7 +251,7 @@ module type PROTOCOL = sig val begin_validation : Context.t -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> mode -> predecessor:Block_header.shell_header -> cache:Context.source_of_cache -> @@ -259,7 +259,7 @@ module type PROTOCOL = sig val begin_application : Context.t -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> mode -> predecessor:Block_header.shell_header -> cache:Context.source_of_cache -> @@ -270,8 +270,8 @@ module type PROTOCOL = sig val init : Context.t -> - Chain_id.t -> - head_hash:Block_hash.t -> + Tezos_crypto.Chain_id.t -> + head_hash:Tezos_crypto.Block_hash.t -> head:Block_header.shell_header -> cache:Context.source_of_cache -> (validation_info * t) tzresult Lwt.t diff --git a/src/lib_protocol_environment/environment_protocol_T_V0.ml b/src/lib_protocol_environment/environment_protocol_T_V0.ml index 1824b3c6437b..2fbe1c6ab1b9 100644 --- a/src/lib_protocol_environment/environment_protocol_T_V0.ml +++ b/src/lib_protocol_environment/environment_protocol_T_V0.ml @@ -81,7 +81,7 @@ module type T = sig val current_context : validation_state -> context tzresult Lwt.t val begin_partial_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ancestor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -89,7 +89,7 @@ module type T = sig validation_state tzresult Lwt.t val begin_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -97,12 +97,12 @@ module type T = sig validation_state tzresult Lwt.t val begin_construction : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> ?protocol_data:block_header_data -> unit -> diff --git a/src/lib_protocol_environment/environment_protocol_T_V3.ml b/src/lib_protocol_environment/environment_protocol_T_V3.ml index 12f3043421c9..2757418214d2 100644 --- a/src/lib_protocol_environment/environment_protocol_T_V3.ml +++ b/src/lib_protocol_environment/environment_protocol_T_V3.ml @@ -80,7 +80,7 @@ module type T = sig type validation_state val begin_partial_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ancestor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -88,7 +88,7 @@ module type T = sig validation_state tzresult Lwt.t val begin_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -96,12 +96,12 @@ module type T = sig validation_state tzresult Lwt.t val begin_construction : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> ?protocol_data:block_header_data -> unit -> @@ -127,12 +127,12 @@ module type T = sig type cache_key val value_of_key : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> (cache_key -> cache_value tzresult Lwt.t) tzresult Lwt.t end diff --git a/src/lib_protocol_environment/environment_protocol_T_V6.ml b/src/lib_protocol_environment/environment_protocol_T_V6.ml index dda6a500ce6f..100cdee8acb2 100644 --- a/src/lib_protocol_environment/environment_protocol_T_V6.ml +++ b/src/lib_protocol_environment/environment_protocol_T_V6.ml @@ -80,7 +80,7 @@ module type T = sig type validation_state val begin_partial_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ancestor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -88,7 +88,7 @@ module type T = sig validation_state tzresult Lwt.t val begin_application : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_fitness:Fitness.t -> @@ -96,12 +96,12 @@ module type T = sig validation_state tzresult Lwt.t val begin_construction : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> ?protocol_data:block_header_data -> unit -> @@ -120,7 +120,7 @@ module type T = sig val rpc_services : rpc_context Tezos_rpc.Directory.t val init : - Chain_id.t -> + Tezos_crypto.Chain_id.t -> context -> Block_header.shell_header -> validation_result tzresult Lwt.t @@ -130,12 +130,12 @@ module type T = sig type cache_key val value_of_key : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> (cache_key -> cache_value tzresult Lwt.t) tzresult Lwt.t end diff --git a/src/lib_protocol_environment/environment_protocol_T_V7.ml b/src/lib_protocol_environment/environment_protocol_T_V7.ml index 91fc34d8c451..2d419e840417 100644 --- a/src/lib_protocol_environment/environment_protocol_T_V7.ml +++ b/src/lib_protocol_environment/environment_protocol_T_V7.ml @@ -78,7 +78,9 @@ module type T = sig val acceptable_pass : operation -> int option val compare_operations : - Operation_hash.t * operation -> Operation_hash.t * operation -> int + Tezos_crypto.Operation_hash.t * operation -> + Tezos_crypto.Operation_hash.t * operation -> + int type validation_state @@ -88,18 +90,18 @@ module type T = sig | Application of block_header | Partial_validation of block_header | Construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; block_header_data : block_header_data; } | Partial_construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; } val begin_validation : context -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> mode -> predecessor:Block_header.shell_header -> validation_state tzresult Lwt.t @@ -107,7 +109,7 @@ module type T = sig val validate_operation : ?check_signature:bool -> validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> operation -> validation_state tzresult Lwt.t @@ -115,14 +117,14 @@ module type T = sig val begin_application : context -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> mode -> predecessor:Block_header.shell_header -> application_state tzresult Lwt.t val apply_operation : application_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> operation -> (application_state * operation_receipt) tzresult Lwt.t @@ -134,7 +136,7 @@ module type T = sig val rpc_services : rpc_context Tezos_rpc.Directory.t val init : - Chain_id.t -> + Tezos_crypto.Chain_id.t -> context -> Block_header.shell_header -> validation_result tzresult Lwt.t @@ -144,12 +146,12 @@ module type T = sig type cache_key val value_of_key : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_context:context -> predecessor_timestamp:Time.Protocol.t -> predecessor_level:Int32.t -> predecessor_fitness:Fitness.t -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> (cache_key -> cache_value tzresult Lwt.t) tzresult Lwt.t @@ -159,19 +161,19 @@ module type T = sig type validation_info type conflict_handler = - existing_operation:Operation_hash.t * operation -> - new_operation:Operation_hash.t * operation -> + existing_operation:Tezos_crypto.Operation_hash.t * operation -> + new_operation:Tezos_crypto.Operation_hash.t * operation -> [`Keep | `Replace] type operation_conflict = | Operation_conflict of { - existing : Operation_hash.t; - new_operation : Operation_hash.t; + existing : Tezos_crypto.Operation_hash.t; + new_operation : Tezos_crypto.Operation_hash.t; } type add_result = | Added - | Replaced of {removed : Operation_hash.t} + | Replaced of {removed : Tezos_crypto.Operation_hash.t} | Unchanged type add_error = @@ -184,8 +186,8 @@ module type T = sig val init : context -> - Chain_id.t -> - head_hash:Block_hash.t -> + Tezos_crypto.Chain_id.t -> + head_hash:Tezos_crypto.Block_hash.t -> head:Block_header.shell_header -> (validation_info * t) tzresult Lwt.t @@ -196,14 +198,14 @@ module type T = sig ?conflict_handler:conflict_handler -> validation_info -> t -> - Operation_hash.t * operation -> + Tezos_crypto.Operation_hash.t * operation -> (t * add_result, add_error) result Lwt.t - val remove_operation : t -> Operation_hash.t -> t + val remove_operation : t -> Tezos_crypto.Operation_hash.t -> t val merge : ?conflict_handler:conflict_handler -> t -> t -> (t, merge_error) result - val operations : t -> operation Operation_hash.Map.t + val operations : t -> operation Tezos_crypto.Operation_hash.Map.t end end diff --git a/src/lib_protocol_environment/environment_protocol_T_test.ml b/src/lib_protocol_environment/environment_protocol_T_test.ml index 763dced9acd2..336d26ffa578 100644 --- a/src/lib_protocol_environment/environment_protocol_T_test.ml +++ b/src/lib_protocol_environment/environment_protocol_T_test.ml @@ -64,12 +64,12 @@ module Mock_all_unit : | Application of block_header | Partial_validation of block_header | Construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; block_header_data : block_header_data; } | Partial_construction of { - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; timestamp : Time.Protocol.t; } @@ -123,19 +123,19 @@ module Mock_all_unit : type validation_info = unit type conflict_handler = - existing_operation:Operation_hash.t * operation -> - new_operation:Operation_hash.t * operation -> + existing_operation:Tezos_crypto.Operation_hash.t * operation -> + new_operation:Tezos_crypto.Operation_hash.t * operation -> [`Keep | `Replace] type operation_conflict = | Operation_conflict of { - existing : Operation_hash.t; - new_operation : Operation_hash.t; + existing : Tezos_crypto.Operation_hash.t; + new_operation : Tezos_crypto.Operation_hash.t; } type add_result = | Added - | Replaced of {removed : Operation_hash.t} + | Replaced of {removed : Tezos_crypto.Operation_hash.t} | Unchanged type add_error = @@ -157,6 +157,6 @@ module Mock_all_unit : let merge ?conflict_handler:_ () () = Ok () - let operations () = Operation_hash.Map.empty + let operations () = Tezos_crypto.Operation_hash.Map.empty end end diff --git a/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml index c6110d343f4b..3934e5be4040 100644 --- a/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml +++ b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.ml @@ -64,13 +64,16 @@ let of_memory_context (m : Tezos_context_memory.Context.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) : +let of_index ~(index : Tezos_context.Context.index) + (hash : Tezos_crypto.Context_hash.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) + failwith + "Couldn't check out the hash %s" + (Tezos_crypto.Context_hash.to_string hash) | Some ctxt -> let proxy_data_dir : Tezos_protocol_environment.Proxy_delegate.t = (module struct diff --git a/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli index ccb913fd1fe2..00abaf304edb 100644 --- a/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli +++ b/src/lib_protocol_environment/shell_context/proxy_delegate_maker.mli @@ -60,5 +60,5 @@ val make_index : context_path:string -> Tezos_context.Context.index Lwt.t to obtain an [index], you need a full-fledged context on disk. *) val of_index : index:Tezos_context.Context.index -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t diff --git a/src/lib_protocol_environment/test/test_cache.ml b/src/lib_protocol_environment/test/test_cache.ml index 45769ed8cc7e..38eff2606153 100644 --- a/src/lib_protocol_environment/test/test_cache.ml +++ b/src/lib_protocol_environment/test/test_cache.ml @@ -676,7 +676,9 @@ let load_cache_correctly_restores_cache_in_memory builder mode in let*! ctxt0 = Context.Cache.sync ctxt ~cache_nonce:Bytes.empty in (* We want to avoid a cache hit in the cache of caches. *) - let block = Block_hash.hash_string [string_of_int (Random.bits ())] in + let block = + Tezos_crypto.Block_hash.hash_string [string_of_int (Random.bits ())] + in let ctxt0 = Context.Cache.clear ctxt0 in let* ctxt1 = Context.load_cache block ctxt0 mode (builder entries) in (* We force the execution of [value_of_key] even in Lazy mode by diff --git a/src/lib_protocol_environment/tezos_protocol_environment.ml b/src/lib_protocol_environment/tezos_protocol_environment.ml index 75d36392769e..44c68831a059 100644 --- a/src/lib_protocol_environment/tezos_protocol_environment.ml +++ b/src/lib_protocol_environment/tezos_protocol_environment.ml @@ -41,7 +41,7 @@ type validation_result = Environment_context.validation_result = { type quota = Environment_context.quota = {max_size : int; max_op : int option} type rpc_context = Environment_context.rpc_context = { - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; block_header : Block_header.shell_header; context : Context.t; } -- GitLab From 231cd4d5e649c9ba759b48fa06021534023d37a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:07:04 +0200 Subject: [PATCH 08/30] Shell_services: unopen Crypto --- src/lib_shell_services/block_services.ml | 149 +++++++------- src/lib_shell_services/block_services.mli | 107 +++++++---- .../block_validator_errors.ml | 98 +++++----- .../block_validator_errors.mli | 37 ++-- .../block_validator_worker_state.ml | 18 +- .../block_validator_worker_state.mli | 6 +- src/lib_shell_services/chain_services.ml | 26 +-- src/lib_shell_services/chain_services.mli | 64 +++++-- .../chain_validator_worker_state.ml | 6 +- .../chain_validator_worker_state.mli | 2 +- src/lib_shell_services/injection_services.ml | 26 ++- src/lib_shell_services/injection_services.mli | 29 +-- src/lib_shell_services/monitor_services.ml | 33 ++-- src/lib_shell_services/monitor_services.mli | 48 +++-- .../peer_validator_worker_state.ml | 13 +- .../peer_validator_worker_state.mli | 4 +- src/lib_shell_services/preapply_result.ml | 29 +-- src/lib_shell_services/preapply_result.mli | 12 +- .../prevalidator_worker_state.ml | 70 ++++--- .../prevalidator_worker_state.mli | 12 +- src/lib_shell_services/protocol_services.ml | 4 +- src/lib_shell_services/protocol_services.mli | 29 ++- src/lib_shell_services/state_events.ml | 8 +- src/lib_shell_services/store_errors.ml | 181 ++++++++++-------- src/lib_shell_services/validation_errors.ml | 75 ++++---- src/lib_shell_services/validation_errors.mli | 26 ++- src/lib_shell_services/validation_events.ml | 8 +- src/lib_shell_services/worker_services.ml | 4 +- src/lib_shell_services/worker_services.mli | 8 +- 29 files changed, 660 insertions(+), 472 deletions(-) diff --git a/src/lib_shell_services/block_services.ml b/src/lib_shell_services/block_services.ml index 988789d57f31..13c4d368cfc1 100644 --- a/src/lib_shell_services/block_services.ml +++ b/src/lib_shell_services/block_services.ml @@ -31,7 +31,7 @@ module Proof = Tezos_context_sigs.Context.Proof_types module Merkle_proof_encoding = Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree32 -type chain = [`Main | `Test | `Hash of Chain_id.t] +type chain = [`Main | `Test | `Hash of Tezos_crypto.Chain_id.t] let metadata_rpc_arg = let construct = function `Always -> "always" | `Never -> "never" in @@ -54,13 +54,13 @@ let parse_chain s = match s with | "main" -> Ok `Main | "test" -> Ok `Test - | h -> Ok (`Hash (Chain_id.of_b58check_exn h)) + | h -> Ok (`Hash (Tezos_crypto.Chain_id.of_b58check_exn h)) with _ -> Error "Cannot parse chain identifier." let chain_to_string = function | `Main -> "main" | `Test -> "test" - | `Hash h -> Chain_id.to_b58check h + | `Hash h -> Tezos_crypto.Chain_id.to_b58check h let chain_arg = let name = "chain_id" in @@ -76,7 +76,7 @@ type block = [ `Genesis | `Head of int | `Alias of [`Caboose | `Checkpoint | `Savepoint] * int - | `Hash of Block_hash.t * int + | `Hash of Tezos_crypto.Block_hash.t * int | `Level of Int32.t ] let parse_block s = @@ -132,17 +132,17 @@ let parse_block s = Ok (`Alias (`Caboose, int_of_string n)) | ["caboose"; n], '+' -> Ok (`Alias (`Caboose, -int_of_string n)) | [hol], _ -> ( - match Block_hash.of_b58check_opt hol with + match Tezos_crypto.Block_hash.of_b58check_opt hol with | Some h -> Ok (`Hash (h, 0)) | None -> to_level (to_valid_level_id s)) | [hol; n], '~' | [hol; n], '-' -> ( - match Block_hash.of_b58check_opt hol with + match Tezos_crypto.Block_hash.of_b58check_opt hol with | Some h -> Ok (`Hash (h, int_of_string n)) | None -> let offset = to_valid_level_id n in to_level ~offset (to_valid_level_id hol)) | [hol; n], '+' -> ( - match Block_hash.of_b58check_opt hol with + match Tezos_crypto.Block_hash.of_b58check_opt hol with | Some h -> Ok (`Hash (h, -int_of_string n)) | None -> let offset = Int32.neg (to_valid_level_id n) in @@ -189,10 +189,11 @@ let to_string = function | `Head 0 -> "head" | `Head n when n < 0 -> Printf.sprintf "head+%d" (-n) | `Head n -> Printf.sprintf "head~%d" n - | `Hash (h, 0) -> Block_hash.to_b58check h + | `Hash (h, 0) -> Tezos_crypto.Block_hash.to_b58check h | `Hash (h, n) when n < 0 -> - Printf.sprintf "%s+%d" (Block_hash.to_b58check h) (-n) - | `Hash (h, n) -> Printf.sprintf "%s~%d" (Block_hash.to_b58check h) n + Printf.sprintf "%s+%d" (Tezos_crypto.Block_hash.to_b58check h) (-n) + | `Hash (h, n) -> + Printf.sprintf "%s~%d" (Tezos_crypto.Block_hash.to_b58check h) n | `Level i -> Printf.sprintf "%d" (Int32.to_int i) let blocks_arg = @@ -335,7 +336,7 @@ let merkle_tree_encoding : Proof.merkle_tree Data_encoding.t = ])) module type PROTO = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t type block_header_data @@ -363,8 +364,8 @@ module type PROTO = sig end type protocols = { - current_protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + current_protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; } let raw_protocol_encoding = @@ -372,13 +373,14 @@ let raw_protocol_encoding = (fun {current_protocol; next_protocol} -> (current_protocol, next_protocol)) (fun (current_protocol, next_protocol) -> {current_protocol; next_protocol}) (obj2 - (req "protocol" Protocol_hash.encoding) - (req "next_protocol" Protocol_hash.encoding)) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) + (req "next_protocol" Tezos_crypto.Protocol_hash.encoding)) module Make (Proto : PROTO) (Next_proto : PROTO) = struct - let protocol_hash = Protocol_hash.to_b58check Proto.hash + let protocol_hash = Tezos_crypto.Protocol_hash.to_b58check Proto.hash - let next_protocol_hash = Protocol_hash.to_b58check Next_proto.hash + let next_protocol_hash = + Tezos_crypto.Protocol_hash.to_b58check Next_proto.hash type raw_block_header = { shell : Block_header.shell_header; @@ -395,8 +397,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct Proto.block_header_data_encoding) type block_header = { - chain_id : Chain_id.t; - hash : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; protocol_data : Proto.block_header_data; } @@ -411,8 +413,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (merge_objs (obj3 (req "protocol" (constant protocol_hash)) - (req "chain_id" Chain_id.encoding) - (req "hash" Block_hash.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding)) raw_block_header_encoding) type block_metadata = { @@ -491,8 +493,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct | Receipt of Proto.operation_receipt type operation = { - chain_id : Chain_id.t; - hash : Operation_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Operation_hash.t; shell : Operation.shell_header; protocol_data : Proto.operation_data; receipt : operation_receipt; @@ -541,15 +543,15 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (merge_objs (obj3 (req "protocol" (constant protocol_hash)) - (req "chain_id" Chain_id.encoding) - (req "hash" Operation_hash.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "hash" Tezos_crypto.Operation_hash.encoding)) (merge_objs (dynamic_size Operation.shell_header_encoding) (dynamic_size operation_data_encoding))) type block_info = { - chain_id : Chain_id.t; - hash : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Block_hash.t; header : raw_block_header; metadata : block_metadata option; operations : operation list list; @@ -563,8 +565,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct {chain_id; hash; header; metadata; operations}) (obj6 (req "protocol" (constant protocol_hash)) - (req "chain_id" Chain_id.encoding) - (req "hash" Block_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "header" (dynamic_size raw_block_header_encoding)) (opt "metadata" (dynamic_size block_metadata_encoding)) (req "operations" (list (dynamic_size (list operation_encoding))))) @@ -576,7 +578,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct Tezos_rpc.Service.get_service ~description:"The block's hash, its unique identifier." ~query:Tezos_rpc.Query.empty - ~output:Block_hash.encoding + ~output:Tezos_crypto.Block_hash.encoding Tezos_rpc.Path.(path / "hash") let header = @@ -606,7 +608,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "Hash of the metadata associated to the block. This is only set on \ blocks starting from environment V1." ~query:Tezos_rpc.Query.empty - ~output:Block_metadata_hash.encoding + ~output:Tezos_crypto.Block_metadata_hash.encoding Tezos_rpc.Path.(path / "metadata_hash") let protocols = @@ -731,7 +733,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct Tezos_rpc.Service.get_service ~description:"The hashes of all the operations included in the block." ~query:Tezos_rpc.Query.empty - ~output:(list (list Operation_hash.encoding)) + ~output:(list (list Tezos_crypto.Operation_hash.encoding)) path let operation_hashes_in_pass = @@ -740,7 +742,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "All the operations included in `n-th` validation pass of the \ block." ~query:Tezos_rpc.Query.empty - ~output:(list Operation_hash.encoding) + ~output:(list Tezos_crypto.Operation_hash.encoding) Tezos_rpc.Path.(path /: Operations.list_arg) let operation_hash = @@ -749,7 +751,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "The hash of then `m-th` operation in the `n-th` validation pass \ of the block." ~query:Tezos_rpc.Query.empty - ~output:Operation_hash.encoding + ~output:Tezos_crypto.Operation_hash.encoding Tezos_rpc.Path.(path /: Operations.list_arg /: Operations.offset_arg) end @@ -760,7 +762,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "The root hash of the operations metadata from the block. This is \ only set on blocks starting from environment V1." ~query:Tezos_rpc.Query.empty - ~output:Operation_metadata_list_list_hash.encoding + ~output:Tezos_crypto.Operation_metadata_list_list_hash.encoding Tezos_rpc.Path.(path / "operations_metadata_hash") let path = Tezos_rpc.Path.(path / "operation_metadata_hashes") @@ -771,7 +773,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "The hashes of all the operation metadata included in the block. \ This is only set on blocks starting from environment V1." ~query:Tezos_rpc.Query.empty - ~output:(list (list Operation_metadata_hash.encoding)) + ~output:(list (list Tezos_crypto.Operation_metadata_hash.encoding)) path let operation_metadata_hashes_in_pass = @@ -781,7 +783,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct the block. This is only set on blocks starting from environment \ V1." ~query:Tezos_rpc.Query.empty - ~output:(list Operation_metadata_hash.encoding) + ~output:(list Tezos_crypto.Operation_metadata_hash.encoding) Tezos_rpc.Path.(path /: Operations.list_arg) let operation_metadata_hash = @@ -791,7 +793,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct validation pass of the block. This is only set on blocks starting \ from environment V1." ~query:Tezos_rpc.Query.empty - ~output:Operation_metadata_hash.encoding + ~output:Tezos_crypto.Operation_metadata_hash.encoding Tezos_rpc.Path.(path /: Operations.list_arg /: Operations.offset_arg) end @@ -974,14 +976,16 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct module Mempool = struct type t = { - applied : (Operation_hash.t * Next_proto.operation) list; - refused : (Next_proto.operation * error list) Operation_hash.Map.t; - outdated : (Next_proto.operation * error list) Operation_hash.Map.t; + applied : (Tezos_crypto.Operation_hash.t * Next_proto.operation) list; + refused : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + outdated : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; branch_refused : - (Next_proto.operation * error list) Operation_hash.Map.t; + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; branch_delayed : - (Next_proto.operation * error list) Operation_hash.Map.t; - unprocessed : Next_proto.operation Operation_hash.Map.t; + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + unprocessed : Next_proto.operation Tezos_crypto.Operation_hash.Map.t; } let version_0_encoding = @@ -1025,36 +1029,37 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (hash, {shell; protocol_data})) (merge_objs (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 + (req "hash" Tezos_crypto.Operation_hash.encoding)) (dynamic_size Operation.shell_header_encoding)) (dynamic_size Next_proto.operation_data_encoding))))) (req "refused" - (Operation_hash.Map.encoding + (Tezos_crypto.Operation_hash.Map.encoding (merge_objs (dynamic_size next_operation_encoding) (obj1 (req "error" Tezos_rpc.Error.encoding))))) (req "outdated" - (Operation_hash.Map.encoding + (Tezos_crypto.Operation_hash.Map.encoding (merge_objs (dynamic_size next_operation_encoding) (obj1 (req "error" Tezos_rpc.Error.encoding))))) (req "branch_refused" - (Operation_hash.Map.encoding + (Tezos_crypto.Operation_hash.Map.encoding (merge_objs (dynamic_size next_operation_encoding) (obj1 (req "error" Tezos_rpc.Error.encoding))))) (req "branch_delayed" - (Operation_hash.Map.encoding + (Tezos_crypto.Operation_hash.Map.encoding (merge_objs (dynamic_size next_operation_encoding) (obj1 (req "error" Tezos_rpc.Error.encoding))))) (req "unprocessed" - (Operation_hash.Map.encoding + (Tezos_crypto.Operation_hash.Map.encoding (dynamic_size next_operation_encoding)))) let version_1_encoding = @@ -1062,11 +1067,12 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct req kind (conv - (fun map -> Operation_hash.Map.bindings map) - (fun list -> list |> List.to_seq |> Operation_hash.Map.of_seq) + (fun map -> Tezos_crypto.Operation_hash.Map.bindings map) + (fun list -> + list |> List.to_seq |> Tezos_crypto.Operation_hash.Map.of_seq) (list (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Operation_hash.encoding)) (merge_objs next_operation_encoding (obj1 (req "error" Tezos_rpc.Error.encoding)))))) @@ -1111,7 +1117,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (hash, {shell; protocol_data})) (merge_objs (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 + (req "hash" Tezos_crypto.Operation_hash.encoding)) Operation.shell_header_encoding) (dynamic_size Next_proto.operation_data_encoding))))) (operations_with_error_encoding "refused") @@ -1121,12 +1128,14 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct (req "unprocessed" (conv - (fun map -> Operation_hash.Map.bindings map) + (fun map -> Tezos_crypto.Operation_hash.Map.bindings map) (fun list -> - list |> List.to_seq |> Operation_hash.Map.of_seq) + list |> List.to_seq + |> Tezos_crypto.Operation_hash.Map.of_seq) (list (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 + (req "hash" Tezos_crypto.Operation_hash.encoding)) next_operation_encoding))))) (* This encoding should be always the one by default. *) @@ -1243,7 +1252,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct future. Note: If the baker has already received the operation, \ then it's necessary to restart it to flush the operation from it." ~query:Tezos_rpc.Query.empty - ~input:Operation_hash.encoding + ~input:Tezos_crypto.Operation_hash.encoding ~output:unit Tezos_rpc.Path.(path / "ban_operation") @@ -1253,7 +1262,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct "Remove an operation from the set of banned operations (nothing \ happens if it was not banned)." ~query:Tezos_rpc.Query.empty - ~input:Operation_hash.encoding + ~input:Tezos_crypto.Operation_hash.encoding ~output:unit Tezos_rpc.Path.(path / "unban_operation") @@ -1316,7 +1325,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct let processed_operation_encoding = merge_objs (merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Operation_hash.encoding)) next_operation_encoding) (obj1 (dft "error" Tezos_rpc.Error.opt_encoding None)) @@ -1385,7 +1394,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct branch in an operation header, are recent enough for that operation \ to be included in the current block." ~query:Tezos_rpc.Query.empty - ~output:Block_hash.Set.encoding + ~output:Tezos_crypto.Block_hash.Set.encoding Tezos_rpc.Path.(live_blocks_path open_root) end @@ -1615,12 +1624,16 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct module Mempool = struct type t = S.Mempool.t = { - applied : (Operation_hash.t * Next_proto.operation) list; - refused : (Next_proto.operation * error list) Operation_hash.Map.t; - outdated : (Next_proto.operation * error list) Operation_hash.Map.t; - branch_refused : (Next_proto.operation * error list) Operation_hash.Map.t; - branch_delayed : (Next_proto.operation * error list) Operation_hash.Map.t; - unprocessed : Next_proto.operation Operation_hash.Map.t; + applied : (Tezos_crypto.Operation_hash.t * Next_proto.operation) list; + refused : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + outdated : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + branch_refused : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + branch_delayed : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + unprocessed : Next_proto.operation Tezos_crypto.Operation_hash.Map.t; } type t_with_version = S.Mempool.t_with_version = @@ -1710,7 +1723,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) = struct end module Fake_protocol = struct - let hash = Protocol_hash.zero + let hash = Tezos_crypto.Protocol_hash.zero type block_header_data = unit diff --git a/src/lib_shell_services/block_services.mli b/src/lib_shell_services/block_services.mli index 1bf52f765469..f06a70c8f13b 100644 --- a/src/lib_shell_services/block_services.mli +++ b/src/lib_shell_services/block_services.mli @@ -26,7 +26,7 @@ module Proof = Tezos_context_sigs.Context.Proof_types -type chain = [`Main | `Test | `Hash of Chain_id.t] +type chain = [`Main | `Test | `Hash of Tezos_crypto.Chain_id.t] type chain_prefix = unit * chain @@ -51,7 +51,7 @@ type block = (** The [n]th predecessor of the [caboose], the [checkpoint] or the [savepoint] if [n > 0]. If [n = 0], represents the block itself. If [n < 0], represents the [n]th successor. *) - | `Hash of Block_hash.t * int + | `Hash of Tezos_crypto.Block_hash.t * int (** The [n]th predecessor of the block of given [hash] if [n > 0]. If [n = 0], represents the block itself. Otherwise, if [n < 0], represents the [n]th successor.*) @@ -91,7 +91,7 @@ val raw_context_insert : string list * Proof.raw_context -> Proof.raw_context -> Proof.raw_context module type PROTO = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t type block_header_data @@ -119,8 +119,8 @@ module type PROTO = sig end type protocols = { - current_protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + current_protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; } val protocols : @@ -139,8 +139,8 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig } type block_header = { - chain_id : Chain_id.t; - hash : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; protocol_data : Proto.block_header_data; } @@ -160,16 +160,16 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig | Receipt of Proto.operation_receipt type operation = { - chain_id : Chain_id.t; - hash : Operation_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Operation_hash.t; shell : Operation.shell_header; protocol_data : Proto.operation_data; receipt : operation_receipt; } type block_info = { - chain_id : Chain_id.t; - hash : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + hash : Tezos_crypto.Block_hash.t; header : raw_block_header; metadata : block_metadata option; operations : operation list list; @@ -193,7 +193,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?chain:chain -> ?block:block -> unit -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t val raw_header : #simple -> ?chain:chain -> ?block:block -> unit -> Bytes.t tzresult Lwt.t @@ -217,7 +217,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?chain:chain -> ?block:block -> unit -> - Block_metadata_hash.t tzresult Lwt.t + Tezos_crypto.Block_metadata_hash.t tzresult Lwt.t module Header : sig val shell_header : @@ -274,14 +274,14 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?chain:chain -> ?block:block -> unit -> - Operation_hash.t list list tzresult Lwt.t + Tezos_crypto.Operation_hash.t list list tzresult Lwt.t val operation_hashes_in_pass : #simple -> ?chain:chain -> ?block:block -> int -> - Operation_hash.t list tzresult Lwt.t + Tezos_crypto.Operation_hash.t list tzresult Lwt.t val operation_hash : #simple -> @@ -289,7 +289,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?block:block -> int -> int -> - Operation_hash.t tzresult Lwt.t + Tezos_crypto.Operation_hash.t tzresult Lwt.t end module Operation_metadata_hashes : sig @@ -298,21 +298,21 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?chain:chain -> ?block:block -> unit -> - Operation_metadata_list_list_hash.t tzresult Lwt.t + Tezos_crypto.Operation_metadata_list_list_hash.t tzresult Lwt.t val operation_metadata_hashes : #simple -> ?chain:chain -> ?block:block -> unit -> - Operation_metadata_hash.t list list tzresult Lwt.t + Tezos_crypto.Operation_metadata_hash.t list list tzresult Lwt.t val operation_metadata_hashes_in_pass : #simple -> ?chain:chain -> ?block:block -> int -> - Operation_metadata_hash.t list tzresult Lwt.t + Tezos_crypto.Operation_metadata_hash.t list tzresult Lwt.t val operation_metadata_hash : #simple -> @@ -320,7 +320,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?block:block -> int -> int -> - Operation_metadata_hash.t tzresult Lwt.t + Tezos_crypto.Operation_metadata_hash.t tzresult Lwt.t end module Context : sig @@ -382,12 +382,16 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig module Mempool : sig type t = { - applied : (Operation_hash.t * Next_proto.operation) list; - refused : (Next_proto.operation * error list) Operation_hash.Map.t; - outdated : (Next_proto.operation * error list) Operation_hash.Map.t; - branch_refused : (Next_proto.operation * error list) Operation_hash.Map.t; - branch_delayed : (Next_proto.operation * error list) Operation_hash.Map.t; - unprocessed : Next_proto.operation Operation_hash.Map.t; + applied : (Tezos_crypto.Operation_hash.t * Next_proto.operation) list; + refused : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + outdated : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + branch_refused : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + branch_delayed : + (Next_proto.operation * error list) Tezos_crypto.Operation_hash.Map.t; + unprocessed : Next_proto.operation Tezos_crypto.Operation_hash.Map.t; } type t_with_version @@ -419,14 +423,14 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig val ban_operation : #simple -> ?chain:chain -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t (** Call RPC POST /chains/[chain]/mempool/unban_operation *) val unban_operation : #simple -> ?chain:chain -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t (** Call RPC POST /chains/[chain]/mempool/unban_all_operations *) @@ -446,7 +450,9 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?refused:bool -> ?outdated:bool -> unit -> - (((Operation_hash.t * Next_proto.operation) * error trace option) list + (((Tezos_crypto.Operation_hash.t * Next_proto.operation) + * error trace option) + list Lwt_stream.t * stopper) tzresult @@ -466,11 +472,17 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ?chain:chain -> ?block:block -> unit -> - Block_hash.Set.t tzresult Lwt.t + Tezos_crypto.Block_hash.Set.t tzresult Lwt.t module S : sig val hash : - ([`GET], prefix, prefix, unit, unit, Block_hash.t) Tezos_rpc.Service.t + ( [`GET], + prefix, + prefix, + unit, + unit, + Tezos_crypto.Block_hash.t ) + Tezos_rpc.Service.t val info : ( [`GET], @@ -496,7 +508,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig prefix, unit, unit, - Block_metadata_hash.t ) + Tezos_crypto.Block_metadata_hash.t ) Tezos_rpc.Service.t val protocols : @@ -590,7 +602,7 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig prefix, unit, unit, - Operation_metadata_list_list_hash.t ) + Tezos_crypto.Operation_metadata_list_list_hash.t ) Tezos_rpc.Service.t val operation_metadata_hashes : @@ -719,12 +731,24 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig (** Define RPC POST /chains/[chain]/mempool/ban_operation *) val ban_operation : ('a, 'b) Tezos_rpc.Path.t -> - ([`POST], 'a, 'b, unit, Operation_hash.t, unit) Tezos_rpc.Service.t + ( [`POST], + 'a, + 'b, + unit, + Tezos_crypto.Operation_hash.t, + unit ) + Tezos_rpc.Service.t (** Define RPC POST /chains/[chain]/mempool/unban_operation *) val unban_operation : ('a, 'b) Tezos_rpc.Path.t -> - ([`POST], 'a, 'b, unit, Operation_hash.t, unit) Tezos_rpc.Service.t + ( [`POST], + 'a, + 'b, + unit, + Tezos_crypto.Operation_hash.t, + unit ) + Tezos_rpc.Service.t (** Define RPC POST /chains/[chain]/mempool/unban_all_operations *) val unban_all_operations : @@ -743,8 +767,9 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig ; refused : bool ; outdated : bool >, unit, - ((Operation_hash.t * Next_proto.operation) * error trace option) list - ) + ((Tezos_crypto.Operation_hash.t * Next_proto.operation) + * error trace option) + list ) Tezos_rpc.Service.t (** Define RPC GET /chains/[chain]/mempool/filter *) @@ -782,7 +807,13 @@ module Make (Proto : PROTO) (Next_proto : PROTO) : sig end val live_blocks : - ([`GET], prefix, prefix, unit, unit, Block_hash.Set.t) Tezos_rpc.Service.t + ( [`GET], + prefix, + prefix, + unit, + unit, + Tezos_crypto.Block_hash.Set.t ) + Tezos_rpc.Service.t end end diff --git a/src/lib_shell_services/block_validator_errors.ml b/src/lib_shell_services/block_validator_errors.ml index daff109909e8..72815b0d53a6 100644 --- a/src/lib_shell_services/block_validator_errors.ml +++ b/src/lib_shell_services/block_validator_errors.ml @@ -25,27 +25,31 @@ (*****************************************************************************) type block_error = - | Cannot_parse_operation of Operation_hash.t + | Cannot_parse_operation of Tezos_crypto.Operation_hash.t | Invalid_fitness of {expected : Fitness.t; found : Fitness.t} | Non_increasing_timestamp | Non_increasing_fitness | Invalid_level of {expected : Int32.t; found : Int32.t} | Invalid_proto_level of {expected : int; found : int} - | Replayed_operation of Operation_hash.t + | Replayed_operation of Tezos_crypto.Operation_hash.t | Outdated_operation of { - operation : Operation_hash.t; - originating_block : Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; + originating_block : Tezos_crypto.Block_hash.t; } | Expired_chain of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; expiration : Time.Protocol.t; timestamp : Time.Protocol.t; } | Unexpected_number_of_validation_passes of int (* uint8 *) | Too_many_operations of {pass : int; found : int; max : int} - | Oversized_operation of {operation : Operation_hash.t; size : int; max : int} + | Oversized_operation of { + operation : Tezos_crypto.Operation_hash.t; + size : int; + max : int; + } | Unallowed_pass of { - operation : Operation_hash.t; + operation : Tezos_crypto.Operation_hash.t; pass : int; allowed_pass : int option; } @@ -63,7 +67,7 @@ let block_error_encoding = ~title:"Cannot_parse_operation" (obj2 (req "error" (constant "cannot_parse_operation")) - (req "operation" Operation_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding)) (function | Cannot_parse_operation operation -> Some ((), operation) | _ -> None) (fun ((), operation) -> Cannot_parse_operation operation); @@ -117,7 +121,7 @@ let block_error_encoding = ~title:"Replayed_operation" (obj2 (req "error" (constant "replayed_operation")) - (req "operation" Operation_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding)) (function | Replayed_operation operation -> Some ((), operation) | _ -> None) (fun ((), operation) -> Replayed_operation operation); @@ -126,8 +130,8 @@ let block_error_encoding = ~title:"Outdated_operation" (obj3 (req "error" (constant "outdated_operation")) - (req "operation" Operation_hash.encoding) - (req "originating_block" Block_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding) + (req "originating_block" Tezos_crypto.Block_hash.encoding)) (function | Outdated_operation {operation; originating_block} -> Some ((), operation, originating_block) @@ -139,7 +143,7 @@ let block_error_encoding = ~title:"Expired_chain" (obj4 (req "error" (constant "expired_chain")) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "expiration" Time.Protocol.encoding) (req "timestamp" Time.Protocol.encoding)) (function @@ -174,7 +178,7 @@ let block_error_encoding = ~title:"Oversized_operation" (obj4 (req "error" (constant "oversized_operation")) - (req "operation" Operation_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding) (req "found" int31) (req "max" int31)) (function @@ -188,7 +192,7 @@ let block_error_encoding = ~title:"Unallowed_pass" (obj4 (req "error" (constant "invalid_pass")) - (req "operation" Operation_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding) (req "pass" uint8) (req "allowed_pass" (option uint8))) (function @@ -229,7 +233,7 @@ let pp_block_error ppf = function Format.fprintf ppf "Failed to parse the operation %a." - Operation_hash.pp_short + Tezos_crypto.Operation_hash.pp_short oph | Invalid_fitness {expected; found} -> Format.fprintf @@ -257,15 +261,15 @@ let pp_block_error ppf = function Format.fprintf ppf "The operation %a was previously included in the chain." - Operation_hash.pp_short + Tezos_crypto.Operation_hash.pp_short oph | Outdated_operation {operation; originating_block} -> Format.fprintf ppf "The operation %a is outdated (originated in block: %a)" - Operation_hash.pp_short + Tezos_crypto.Operation_hash.pp_short operation - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short originating_block | Expired_chain {chain_id; expiration; timestamp} -> Format.fprintf @@ -276,7 +280,7 @@ let pp_block_error ppf = function (Time.System.of_protocol_exn timestamp) Time.System.pp_hum (Time.System.of_protocol_exn expiration) - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id | Unexpected_number_of_validation_passes n -> Format.fprintf ppf "Invalid number of validation passes (found: %d)" n @@ -291,7 +295,7 @@ let pp_block_error ppf = function Format.fprintf ppf "Oversized operation %a (size: %d, max: %d)" - Operation_hash.pp_short + Tezos_crypto.Operation_hash.pp_short operation size max @@ -300,7 +304,7 @@ let pp_block_error ppf = function ppf "Operation %a included in validation pass %d, while only the \ following passes are allowed: @[%a@]" - Operation_hash.pp_short + Tezos_crypto.Operation_hash.pp_short operation pass (fun fmt -> function @@ -398,16 +402,19 @@ let pp_validation_process_error ppf = function msg type error += - | Invalid_block of {block : Block_hash.t; error : block_error} - | Unavailable_protocol of {block : Block_hash.t; protocol : Protocol_hash.t} + | Invalid_block of {block : Tezos_crypto.Block_hash.t; error : block_error} + | Unavailable_protocol of { + block : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + } | Inconsistent_operations_hash of { - block : Block_hash.t; - expected : Operation_list_list_hash.t; - found : Operation_list_list_hash.t; + block : Tezos_crypto.Block_hash.t; + expected : Tezos_crypto.Operation_list_list_hash.t; + found : Tezos_crypto.Operation_list_list_hash.t; } - | Failed_to_checkout_context of Context_hash.t + | Failed_to_checkout_context of Tezos_crypto.Context_hash.t | System_error of {errno : string; fn : string; msg : string} - | Missing_test_protocol of Protocol_hash.t + | Missing_test_protocol of Tezos_crypto.Protocol_hash.t | Validation_process_failed of validation_process_error | Cannot_validate_while_shutting_down @@ -421,13 +428,13 @@ let () = Format.fprintf ppf "@[Invalid block %a@ %a@]" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block pp_block_error error) Data_encoding.( obj2 - (req "invalid_block" Block_hash.encoding) + (req "invalid_block" Tezos_crypto.Block_hash.encoding) (req "error" block_error_encoding)) (function Invalid_block {block; error} -> Some (block, error) | _ -> None) (fun (block, error) -> Invalid_block {block; error}) ; @@ -440,14 +447,14 @@ let () = Format.fprintf ppf "Missing protocol (%a) when validating the block %a." - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block) Data_encoding.( obj2 - (req "block" Block_hash.encoding) - (req "missing_protocol" Protocol_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "missing_protocol" Tezos_crypto.Protocol_hash.encoding)) (function | Unavailable_protocol {block; protocol} -> Some (block, protocol) | _ -> None) @@ -463,17 +470,17 @@ let () = ppf "@[The provided list of operations for block %a is inconsistent \ with the block header@ expected: %a@ found: %a@]" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block - Operation_list_list_hash.pp_short + Tezos_crypto.Operation_list_list_hash.pp_short expected - Operation_list_list_hash.pp_short + Tezos_crypto.Operation_list_list_hash.pp_short found) Data_encoding.( obj3 - (req "block" Block_hash.encoding) - (req "expected" Operation_list_list_hash.encoding) - (req "found" Operation_list_list_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "expected" Tezos_crypto.Operation_list_list_hash.encoding) + (req "found" Tezos_crypto.Operation_list_list_hash.encoding)) (function | Inconsistent_operations_hash {block; expected; found} -> Some (block, expected, found) @@ -485,13 +492,13 @@ let () = ~id:"Block_validator_process.failed_to_checkout_context" ~title:"Fail during checkout context" ~description:"The context checkout failed using a given hash" - ~pp:(fun ppf (hash : Context_hash.t) -> + ~pp:(fun ppf (hash : Tezos_crypto.Context_hash.t) -> Format.fprintf ppf "@[Failed to checkout the context with hash %a@]" - Context_hash.pp_short + Tezos_crypto.Context_hash.pp_short hash) - Data_encoding.(obj1 (req "hash" Context_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Context_hash.encoding)) (function Failed_to_checkout_context h -> Some h | _ -> None) (fun h -> Failed_to_checkout_context h) ; Error_monad.register_error_kind @@ -520,9 +527,10 @@ let () = Format.fprintf ppf "Missing test protocol %a when forking the test chain." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol) - Data_encoding.(obj1 (req "test_protocol" Protocol_hash.encoding)) + Data_encoding.( + obj1 (req "test_protocol" Tezos_crypto.Protocol_hash.encoding)) (function Missing_test_protocol protocol -> Some protocol | _ -> None) (fun protocol -> Missing_test_protocol protocol) ; Error_monad.register_error_kind diff --git a/src/lib_shell_services/block_validator_errors.mli b/src/lib_shell_services/block_validator_errors.mli index 81464f6a9289..e7da3cdea94a 100644 --- a/src/lib_shell_services/block_validator_errors.mli +++ b/src/lib_shell_services/block_validator_errors.mli @@ -25,27 +25,31 @@ (*****************************************************************************) type block_error = - | Cannot_parse_operation of Operation_hash.t + | Cannot_parse_operation of Tezos_crypto.Operation_hash.t | Invalid_fitness of {expected : Fitness.t; found : Fitness.t} | Non_increasing_timestamp | Non_increasing_fitness | Invalid_level of {expected : Int32.t; found : Int32.t} | Invalid_proto_level of {expected : int; found : int} - | Replayed_operation of Operation_hash.t + | Replayed_operation of Tezos_crypto.Operation_hash.t | Outdated_operation of { - operation : Operation_hash.t; - originating_block : Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; + originating_block : Tezos_crypto.Block_hash.t; } | Expired_chain of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; expiration : Time.Protocol.t; timestamp : Time.Protocol.t; } | Unexpected_number_of_validation_passes of int (* uint8 *) | Too_many_operations of {pass : int; found : int; max : int} - | Oversized_operation of {operation : Operation_hash.t; size : int; max : int} + | Oversized_operation of { + operation : Tezos_crypto.Operation_hash.t; + size : int; + max : int; + } | Unallowed_pass of { - operation : Operation_hash.t; + operation : Tezos_crypto.Operation_hash.t; pass : int; allowed_pass : int option; } @@ -63,17 +67,20 @@ type validation_process_error = | Cannot_run_external_validator of string type error += - | Invalid_block of {block : Block_hash.t; error : block_error} - | Unavailable_protocol of {block : Block_hash.t; protocol : Protocol_hash.t} + | Invalid_block of {block : Tezos_crypto.Block_hash.t; error : block_error} + | Unavailable_protocol of { + block : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + } | Inconsistent_operations_hash of { - block : Block_hash.t; - expected : Operation_list_list_hash.t; - found : Operation_list_list_hash.t; + block : Tezos_crypto.Block_hash.t; + expected : Tezos_crypto.Operation_list_list_hash.t; + found : Tezos_crypto.Operation_list_list_hash.t; } - | Failed_to_checkout_context of Context_hash.t + | Failed_to_checkout_context of Tezos_crypto.Context_hash.t | System_error of {errno : string; fn : string; msg : string} - | Missing_test_protocol of Protocol_hash.t + | Missing_test_protocol of Tezos_crypto.Protocol_hash.t | Validation_process_failed of validation_process_error | Cannot_validate_while_shutting_down -val invalid_block : Block_hash.t -> block_error -> error +val invalid_block : Tezos_crypto.Block_hash.t -> block_error -> error diff --git a/src/lib_shell_services/block_validator_worker_state.ml b/src/lib_shell_services/block_validator_worker_state.ml index 40a69a775ece..f1da6c91eb5f 100644 --- a/src/lib_shell_services/block_validator_worker_state.ml +++ b/src/lib_shell_services/block_validator_worker_state.ml @@ -25,8 +25,8 @@ module Request = struct type validation_view = { - chain_id : Chain_id.t; - block : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + block : Tezos_crypto.Block_hash.t; peer : P2p_peer.Id.t option; } @@ -36,18 +36,18 @@ module Request = struct (fun {block; chain_id; peer} -> (block, chain_id, peer)) (fun (block, chain_id, peer) -> {block; chain_id; peer}) (obj3 - (req "block" Block_hash.encoding) - (req "chain_id" Chain_id.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "peer" P2p_peer.Id.encoding)) - type preapplication_view = {chain_id : Chain_id.t; level : int32} + type preapplication_view = {chain_id : Tezos_crypto.Chain_id.t; level : int32} let preapplication_view_encoding = let open Data_encoding in conv (fun {chain_id; level} -> (chain_id, level)) (fun (chain_id, level) -> {chain_id; level}) - (obj2 (req "chain_id" Chain_id.encoding) (req "level" int32)) + (obj2 (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "level" int32)) type view = | Validation of validation_view @@ -80,9 +80,9 @@ module Request = struct Format.fprintf ppf "Validation of %a (chain: %a)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id ; match peer with | None -> () @@ -93,6 +93,6 @@ module Request = struct ppf "Pre-application at level %ld (chain: %a)" level - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id end diff --git a/src/lib_shell_services/block_validator_worker_state.mli b/src/lib_shell_services/block_validator_worker_state.mli index fc0cce8985a0..16b2e8ac749b 100644 --- a/src/lib_shell_services/block_validator_worker_state.mli +++ b/src/lib_shell_services/block_validator_worker_state.mli @@ -25,12 +25,12 @@ module Request : sig type validation_view = { - chain_id : Chain_id.t; - block : Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + block : Tezos_crypto.Block_hash.t; peer : P2p_peer.Id.t option; } - type preapplication_view = {chain_id : Chain_id.t; level : int32} + type preapplication_view = {chain_id : Tezos_crypto.Chain_id.t; level : int32} type view = | Validation of validation_view diff --git a/src/lib_shell_services/chain_services.ml b/src/lib_shell_services/chain_services.ml index b5d11f60eba2..72e205ee42e2 100644 --- a/src/lib_shell_services/chain_services.ml +++ b/src/lib_shell_services/chain_services.ml @@ -26,7 +26,7 @@ open Data_encoding -type chain = [`Main | `Test | `Hash of Chain_id.t] +type chain = [`Main | `Test | `Hash of Tezos_crypto.Chain_id.t] let chain_arg = Block_services.chain_arg @@ -34,7 +34,11 @@ let to_string = Block_services.chain_to_string let parse_chain = Block_services.parse_chain -type invalid_block = {hash : Block_hash.t; level : Int32.t; errors : error list} +type invalid_block = { + hash : Tezos_crypto.Block_hash.t; + level : Int32.t; + errors : error list; +} type prefix = Block_services.chain_prefix @@ -48,14 +52,14 @@ let checkpoint_encoding = (req "history_mode" History_mode.encoding) let block_descriptor_encoding = - obj2 (req "block_hash" Block_hash.encoding) (req "level" int32) + obj2 (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "level" int32) let invalid_block_encoding = conv (fun {hash; level; errors} -> (hash, level, errors)) (fun (hash, level, errors) -> {hash; level; errors}) (obj3 - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "level" int32) (req "errors" Tezos_rpc.Error.encoding)) @@ -71,7 +75,7 @@ module S = struct Tezos_rpc.Service.get_service ~description:"The chain unique identifier." ~query:Tezos_rpc.Query.empty - ~output:Chain_id.encoding + ~output:Tezos_crypto.Chain_id.encoding Tezos_rpc.Path.(path / "chain_id") (* DEPRECATED: use `chains//levels/{checkpoint, savepoint, @@ -153,7 +157,7 @@ module S = struct "An empty argument requests blocks starting with the current \ head. A non empty list allows to request one or more specific \ fragments of the chain." - Block_hash.rpc_arg + Tezos_crypto.Block_hash.rpc_arg (fun x -> x#heads) |+ opt_field "min_date" @@ -177,7 +181,7 @@ module S = struct head of the chain. Optional arguments allow to return the list of \ predecessors of a given block or of a set of blocks." ~query:list_query - ~output:(list (list Block_hash.encoding)) + ~output:(list (list Tezos_crypto.Block_hash.encoding)) path end @@ -198,14 +202,14 @@ module S = struct ~description:"The errors that appears during the block (in)validation." ~query:Tezos_rpc.Query.empty ~output:invalid_block_encoding - Tezos_rpc.Path.(path /: Block_hash.rpc_arg) + Tezos_rpc.Path.(path /: Tezos_crypto.Block_hash.rpc_arg) let delete = Tezos_rpc.Service.delete_service ~description:"Remove an invalid block for the tezos storage" ~query:Tezos_rpc.Query.empty ~output:Data_encoding.empty - Tezos_rpc.Path.(path /: Block_hash.rpc_arg) + Tezos_rpc.Path.(path /: Tezos_crypto.Block_hash.rpc_arg) end end @@ -254,8 +258,8 @@ module Blocks = struct include Block_services.Empty type protocols = Block_services.protocols = { - current_protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + current_protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; } let protocols = Block_services.protocols diff --git a/src/lib_shell_services/chain_services.mli b/src/lib_shell_services/chain_services.mli index 365e8dcb3479..c114b9c98d6b 100644 --- a/src/lib_shell_services/chain_services.mli +++ b/src/lib_shell_services/chain_services.mli @@ -24,7 +24,7 @@ (* *) (*****************************************************************************) -type chain = [`Main | `Test | `Hash of Chain_id.t] +type chain = [`Main | `Test | `Hash of Tezos_crypto.Chain_id.t] val parse_chain : string -> (chain, string) result @@ -32,7 +32,11 @@ val to_string : chain -> string val chain_arg : chain Tezos_rpc.Arg.t -type invalid_block = {hash : Block_hash.t; level : Int32.t; errors : error list} +type invalid_block = { + hash : Tezos_crypto.Block_hash.t; + level : Int32.t; + errors : error list; +} type prefix = unit * chain @@ -40,7 +44,8 @@ val path : (unit, prefix) Tezos_rpc.Path.path open Tezos_rpc.Context -val chain_id : #simple -> ?chain:chain -> unit -> Chain_id.t tzresult Lwt.t +val chain_id : + #simple -> ?chain:chain -> unit -> Tezos_crypto.Chain_id.t tzresult Lwt.t val checkpoint : #simple -> @@ -52,30 +57,39 @@ module Mempool = Block_services.Empty.Mempool module Levels : sig val checkpoint : - #simple -> ?chain:chain -> unit -> (Block_hash.t * int32) tzresult Lwt.t + #simple -> + ?chain:chain -> + unit -> + (Tezos_crypto.Block_hash.t * int32) tzresult Lwt.t val savepoint : - #simple -> ?chain:chain -> unit -> (Block_hash.t * int32) tzresult Lwt.t + #simple -> + ?chain:chain -> + unit -> + (Tezos_crypto.Block_hash.t * int32) tzresult Lwt.t val caboose : - #simple -> ?chain:chain -> unit -> (Block_hash.t * int32) tzresult Lwt.t + #simple -> + ?chain:chain -> + unit -> + (Tezos_crypto.Block_hash.t * int32) tzresult Lwt.t end module Blocks : sig val list : #simple -> ?chain:chain -> - ?heads:Block_hash.t list -> + ?heads:Tezos_crypto.Block_hash.t list -> ?length:int -> ?min_date:Time.Protocol.t -> unit -> - Block_hash.t list list tzresult Lwt.t + Tezos_crypto.Block_hash.t list list tzresult Lwt.t include module type of Block_services.Empty type protocols = { - current_protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + current_protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; } val protocols : @@ -91,14 +105,24 @@ module Invalid_blocks : sig #simple -> ?chain:chain -> unit -> invalid_block list tzresult Lwt.t val get : - #simple -> ?chain:chain -> Block_hash.t -> invalid_block tzresult Lwt.t + #simple -> + ?chain:chain -> + Tezos_crypto.Block_hash.t -> + invalid_block tzresult Lwt.t - val delete : #simple -> ?chain:chain -> Block_hash.t -> unit tzresult Lwt.t + val delete : + #simple -> ?chain:chain -> Tezos_crypto.Block_hash.t -> unit tzresult Lwt.t end module S : sig val chain_id : - ([`GET], prefix, prefix, unit, unit, Chain_id.t) Tezos_rpc.Service.t + ( [`GET], + prefix, + prefix, + unit, + unit, + Tezos_crypto.Chain_id.t ) + Tezos_rpc.Service.t val checkpoint : ( [`GET], @@ -128,7 +152,7 @@ module S : sig prefix, unit, unit, - Block_hash.t * int32 ) + Tezos_crypto.Block_hash.t * int32 ) Tezos_rpc.Service.t val savepoint : @@ -137,7 +161,7 @@ module S : sig prefix, unit, unit, - Block_hash.t * int32 ) + Tezos_crypto.Block_hash.t * int32 ) Tezos_rpc.Service.t val caboose : @@ -146,7 +170,7 @@ module S : sig prefix, unit, unit, - Block_hash.t * int32 ) + Tezos_crypto.Block_hash.t * int32 ) Tezos_rpc.Service.t end @@ -157,11 +181,11 @@ module S : sig ( [`GET], prefix, prefix, - < heads : Block_hash.t list + < heads : Tezos_crypto.Block_hash.t list ; length : int option ; min_date : Time.Protocol.t option >, unit, - Block_hash.t list list ) + Tezos_crypto.Block_hash.t list list ) Tezos_rpc.Service.t end @@ -178,7 +202,7 @@ module S : sig val get : ( [`GET], prefix, - prefix * Block_hash.t, + prefix * Tezos_crypto.Block_hash.t, unit, unit, invalid_block ) @@ -187,7 +211,7 @@ module S : sig val delete : ( [`DELETE], prefix, - prefix * Block_hash.t, + prefix * Tezos_crypto.Block_hash.t, unit, unit, unit ) diff --git a/src/lib_shell_services/chain_validator_worker_state.ml b/src/lib_shell_services/chain_validator_worker_state.ml index c0b8c5a7a048..63edc1a4e5a7 100644 --- a/src/lib_shell_services/chain_validator_worker_state.ml +++ b/src/lib_shell_services/chain_validator_worker_state.ml @@ -25,7 +25,7 @@ (*****************************************************************************) module Request = struct - type view = Hash of Block_hash.t | PeerId of P2p_peer.Id.t + type view = Hash of Tezos_crypto.Block_hash.t | PeerId of P2p_peer.Id.t let encoding = let open Data_encoding in @@ -34,7 +34,7 @@ module Request = struct case (Tag 0) ~title:"Hash" - (obj1 (req "hash" Block_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Hash h -> Some h | _ -> None) (fun h -> Hash h); case @@ -46,7 +46,7 @@ module Request = struct ] let pp ppf = function - | Hash h -> Block_hash.pp ppf h + | Hash h -> Tezos_crypto.Block_hash.pp ppf h | PeerId pid -> P2p_peer.Id.pp ppf pid end diff --git a/src/lib_shell_services/chain_validator_worker_state.mli b/src/lib_shell_services/chain_validator_worker_state.mli index 77467fa78565..98ef6d6a724f 100644 --- a/src/lib_shell_services/chain_validator_worker_state.mli +++ b/src/lib_shell_services/chain_validator_worker_state.mli @@ -25,7 +25,7 @@ (*****************************************************************************) module Request : sig - type view = Hash of Block_hash.t | PeerId of P2p_peer.Id.t + type view = Hash of Tezos_crypto.Block_hash.t | PeerId of P2p_peer.Id.t val encoding : view Data_encoding.encoding diff --git a/src/lib_shell_services/injection_services.ml b/src/lib_shell_services/injection_services.ml index 9b451c8a6945..95fbc16adab3 100644 --- a/src/lib_shell_services/injection_services.ml +++ b/src/lib_shell_services/injection_services.ml @@ -25,9 +25,11 @@ type Error_monad.error += Injection_operations_error -type Error_monad.error += Injection_operation_succeed_case of Operation_hash.t +type Error_monad.error += + | Injection_operation_succeed_case of Tezos_crypto.Operation_hash.t -type Error_monad.error += Injection_operation_error_case of Operation_hash.t +type Error_monad.error += + | Injection_operation_error_case of Tezos_crypto.Operation_hash.t let () = let open Data_encoding in @@ -54,8 +56,12 @@ let () = "The injection of this operation succeed among a list of injections \ containing at least one error." ~pp:(fun ppf oph -> - Format.fprintf ppf "Injection of %a succeeded." Operation_hash.pp oph) - (obj1 (req "oph" Operation_hash.encoding)) + Format.fprintf + ppf + "Injection of %a succeeded." + Tezos_crypto.Operation_hash.pp + oph) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) (function Injection_operation_succeed_case oph -> Some oph | _ -> None) (function oph -> Injection_operation_succeed_case oph) ; register_error_kind @@ -69,9 +75,9 @@ let () = Format.fprintf ppf "Injection of %a failed. Error is next." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) - (obj1 (req "oph" Operation_hash.encoding)) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) (function Injection_operation_error_case oph -> Some oph | _ -> None) (function oph -> Injection_operation_error_case oph) @@ -117,7 +123,7 @@ module S = struct main chain." ~query:block_query ~input:block_param - ~output:Block_hash.encoding + ~output:Tezos_crypto.Block_hash.encoding Tezos_rpc.Path.(path / "block") let operation_query = @@ -167,7 +173,7 @@ module S = struct or the main chain." ~query:operation_query ~input:bytes - ~output:Operation_hash.encoding + ~output:Tezos_crypto.Operation_hash.encoding (if private_ then Tezos_rpc.Path.(root / "private" / "injection" / "operation") else Tezos_rpc.Path.(path / "operation")) @@ -192,7 +198,7 @@ module S = struct specific to this injection)." ~query:operations_query ~input:(list (dynamic_size bytes)) - ~output:(list Operation_hash.encoding) + ~output:(list Tezos_crypto.Operation_hash.encoding) Tezos_rpc.Path.(root / "private" / "injection" / "operations") let private_operation = operation ~private_:true @@ -216,7 +222,7 @@ module S = struct will be validated before the result is returned." ~query:protocol_query ~input:Protocol.encoding - ~output:Protocol_hash.encoding + ~output:Tezos_crypto.Protocol_hash.encoding Tezos_rpc.Path.(path / "protocol") end diff --git a/src/lib_shell_services/injection_services.mli b/src/lib_shell_services/injection_services.mli index 532acb97fe6e..de2eca18ec9c 100644 --- a/src/lib_shell_services/injection_services.mli +++ b/src/lib_shell_services/injection_services.mli @@ -39,9 +39,11 @@ open Tezos_rpc.Context [Injection_operation_error_case oph] followed by [err]. *) type Error_monad.error += Injection_operations_error -type Error_monad.error += Injection_operation_succeed_case of Operation_hash.t +type Error_monad.error += + | Injection_operation_succeed_case of Tezos_crypto.Operation_hash.t -type Error_monad.error += Injection_operation_error_case of Operation_hash.t +type Error_monad.error += + | Injection_operation_error_case of Tezos_crypto.Operation_hash.t (** [block cctxt ?async ?force raw_block] tries to inject [raw_block] inside the node. If [?async] is [true], [raw_block] @@ -55,21 +57,21 @@ val block : ?chain:Chain_services.chain -> Bytes.t -> Operation.t list list -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t val operation : #simple -> ?async:bool -> ?chain:Chain_services.chain -> Bytes.t -> - Operation_hash.t tzresult Lwt.t + Tezos_crypto.Operation_hash.t tzresult Lwt.t val private_operation : #simple -> ?async:bool -> ?chain:Chain_services.chain -> Bytes.t -> - Operation_hash.t tzresult Lwt.t + Tezos_crypto.Operation_hash.t tzresult Lwt.t (** [private_operations] injects multiple operations. The [private_] prefix is because the service is bound to the /private/ path-prefix @@ -81,10 +83,13 @@ val private_operations : ?force:bool -> ?chain:Chain_services.chain -> Bytes.t list -> - Operation_hash.t list tzresult Lwt.t + Tezos_crypto.Operation_hash.t list tzresult Lwt.t val protocol : - #simple -> ?async:bool -> Protocol.t -> Protocol_hash.t tzresult Lwt.t + #simple -> + ?async:bool -> + Protocol.t -> + Tezos_crypto.Protocol_hash.t tzresult Lwt.t module S : sig val block : @@ -93,7 +98,7 @@ module S : sig unit, < async : bool ; force : bool ; chain : Chain_services.chain option >, Bytes.t * Operation.t list list, - Block_hash.t ) + Tezos_crypto.Block_hash.t ) Tezos_rpc.Service.t val operation : @@ -102,7 +107,7 @@ module S : sig unit, < async : bool ; chain : Chain_services.chain option >, Bytes.t, - Operation_hash.t ) + Tezos_crypto.Operation_hash.t ) Tezos_rpc.Service.t val private_operation : @@ -111,7 +116,7 @@ module S : sig unit, < async : bool ; chain : Chain_services.chain option >, Bytes.t, - Operation_hash.t ) + Tezos_crypto.Operation_hash.t ) Tezos_rpc.Service.t val private_operations : @@ -120,7 +125,7 @@ module S : sig unit, < async : bool ; force : bool ; chain : Chain_services.chain option >, Bytes.t list, - Operation_hash.t list ) + Tezos_crypto.Operation_hash.t list ) Tezos_rpc.Service.t val protocol : @@ -129,6 +134,6 @@ module S : sig unit, < async : bool >, Protocol.t, - Protocol_hash.t ) + Tezos_crypto.Protocol_hash.t ) Tezos_rpc.Service.t end diff --git a/src/lib_shell_services/monitor_services.ml b/src/lib_shell_services/monitor_services.ml index f409c78c3b52..e6d5bbdc79d5 100644 --- a/src/lib_shell_services/monitor_services.ml +++ b/src/lib_shell_services/monitor_services.ml @@ -24,13 +24,13 @@ (*****************************************************************************) type chain_status = - | Active_main of Chain_id.t + | Active_main of Tezos_crypto.Chain_id.t | Active_test of { - chain : Chain_id.t; - protocol : Protocol_hash.t; + chain : Tezos_crypto.Chain_id.t; + protocol : Tezos_crypto.Protocol_hash.t; expiration_date : Time.Protocol.t; } - | Stopping of Chain_id.t + | Stopping of Tezos_crypto.Chain_id.t let chain_status_encoding = let open Data_encoding in @@ -40,15 +40,15 @@ let chain_status_encoding = case (Tag 0) ~title:"Main" - (obj1 (req "chain_id" Chain_id.encoding)) + (obj1 (req "chain_id" Tezos_crypto.Chain_id.encoding)) (function Active_main chain_id -> Some chain_id | _ -> None) (fun chain_id -> Active_main chain_id); case (Tag 1) ~title:"Test" (obj3 - (req "chain_id" Chain_id.encoding) - (req "test_protocol" Protocol_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "test_protocol" Tezos_crypto.Protocol_hash.encoding) (req "expiration_date" Time.Protocol.encoding)) (function | Active_test {chain; protocol; expiration_date} -> @@ -59,7 +59,7 @@ let chain_status_encoding = case (Tag 2) ~title:"Stopping" - (obj1 (req "stopping" Chain_id.encoding)) + (obj1 (req "stopping" Tezos_crypto.Chain_id.encoding)) (function Stopping chain_id -> Some chain_id | _ -> None) (fun chain_id -> Stopping chain_id); ] @@ -80,7 +80,7 @@ module S = struct ~query:Tezos_rpc.Query.empty ~output: (obj2 - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "timestamp" Time.Protocol.encoding)) Tezos_rpc.Path.(path / "bootstrapped") @@ -94,8 +94,9 @@ module S = struct method chains = chains end) - |+ multi_field "protocol" Protocol_hash.rpc_arg (fun t -> t#protocols) - |+ multi_field "next_protocol" Protocol_hash.rpc_arg (fun t -> + |+ multi_field "protocol" Tezos_crypto.Protocol_hash.rpc_arg (fun t -> + t#protocols) + |+ multi_field "next_protocol" Tezos_crypto.Protocol_hash.rpc_arg (fun t -> t#next_protocols) |+ multi_field "chain" Chain_services.chain_arg (fun t -> t#chains) |> seal @@ -109,8 +110,8 @@ module S = struct ~output: (merge_objs (obj2 - (req "chain_id" Chain_id.encoding) - (req "hash" Block_hash.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding)) Block_header.encoding) Tezos_rpc.Path.(path / "valid_blocks") @@ -120,7 +121,7 @@ module S = struct object method next_protocols = next_protocols end) - |+ multi_field "next_protocol" Protocol_hash.rpc_arg (fun t -> + |+ multi_field "next_protocol" Tezos_crypto.Protocol_hash.rpc_arg (fun t -> t#next_protocols) |> seal @@ -132,7 +133,7 @@ module S = struct ~query:heads_query ~output: (merge_objs - (obj1 (req "hash" Block_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) Block_header.encoding) Tezos_rpc.Path.(path / "heads" /: Chain_services.chain_arg) @@ -142,7 +143,7 @@ module S = struct "Monitor all economic protocols that are retrieved and successfully \ loaded and compiled by the node." ~query:Tezos_rpc.Query.empty - ~output:Protocol_hash.encoding + ~output:Tezos_crypto.Protocol_hash.encoding Tezos_rpc.Path.(path / "protocols") (* DEPRECATED: use [version] from "version_services" instead. *) diff --git a/src/lib_shell_services/monitor_services.mli b/src/lib_shell_services/monitor_services.mli index 47aee81f5f52..b74609efb1ab 100644 --- a/src/lib_shell_services/monitor_services.mli +++ b/src/lib_shell_services/monitor_services.mli @@ -26,36 +26,42 @@ open Tezos_rpc.Context type chain_status = - | Active_main of Chain_id.t + | Active_main of Tezos_crypto.Chain_id.t | Active_test of { - chain : Chain_id.t; - protocol : Protocol_hash.t; + chain : Tezos_crypto.Chain_id.t; + protocol : Tezos_crypto.Protocol_hash.t; expiration_date : Time.Protocol.t; } - | Stopping of Chain_id.t + | Stopping of Tezos_crypto.Chain_id.t val bootstrapped : #streamed -> - ((Block_hash.t * Time.Protocol.t) Lwt_stream.t * stopper) tzresult Lwt.t + ((Tezos_crypto.Block_hash.t * Time.Protocol.t) Lwt_stream.t * stopper) + tzresult + Lwt.t val valid_blocks : #streamed -> ?chains:Chain_services.chain list -> - ?protocols:Protocol_hash.t list -> - ?next_protocols:Protocol_hash.t list -> + ?protocols:Tezos_crypto.Protocol_hash.t list -> + ?next_protocols:Tezos_crypto.Protocol_hash.t list -> unit -> - (((Chain_id.t * Block_hash.t) * Block_header.t) Lwt_stream.t * stopper) + (((Tezos_crypto.Chain_id.t * Tezos_crypto.Block_hash.t) * Block_header.t) + Lwt_stream.t + * stopper) tzresult Lwt.t val heads : #streamed -> - ?next_protocols:Protocol_hash.t list -> + ?next_protocols:Tezos_crypto.Protocol_hash.t list -> Chain_services.chain -> - ((Block_hash.t * Block_header.t) Lwt_stream.t * stopper) tzresult Lwt.t + ((Tezos_crypto.Block_hash.t * Block_header.t) Lwt_stream.t * stopper) tzresult + Lwt.t val protocols : - #streamed -> (Protocol_hash.t Lwt_stream.t * stopper) tzresult Lwt.t + #streamed -> + (Tezos_crypto.Protocol_hash.t Lwt_stream.t * stopper) tzresult Lwt.t val commit_hash : #simple -> string tzresult Lwt.t @@ -69,7 +75,7 @@ module S : sig unit, unit, unit, - Block_hash.t * Time.Protocol.t ) + Tezos_crypto.Block_hash.t * Time.Protocol.t ) Tezos_rpc.Service.t val valid_blocks : @@ -77,23 +83,29 @@ module S : sig unit, unit, < chains : Chain_services.chain list - ; next_protocols : Protocol_hash.t list - ; protocols : Protocol_hash.t list >, + ; next_protocols : Tezos_crypto.Protocol_hash.t list + ; protocols : Tezos_crypto.Protocol_hash.t list >, unit, - (Chain_id.t * Block_hash.t) * Block_header.t ) + (Tezos_crypto.Chain_id.t * Tezos_crypto.Block_hash.t) * Block_header.t ) Tezos_rpc.Service.t val heads : ( [`GET], unit, unit * Chain_services.chain, - < next_protocols : Protocol_hash.t list >, + < next_protocols : Tezos_crypto.Protocol_hash.t list >, unit, - Block_hash.t * Block_header.t ) + Tezos_crypto.Block_hash.t * Block_header.t ) Tezos_rpc.Service.t val protocols : - ([`GET], unit, unit, unit, unit, Protocol_hash.t) Tezos_rpc.Service.t + ( [`GET], + unit, + unit, + unit, + unit, + Tezos_crypto.Protocol_hash.t ) + Tezos_rpc.Service.t val commit_hash : ([`GET], unit, unit, unit, unit, string) Tezos_rpc.Service.t diff --git a/src/lib_shell_services/peer_validator_worker_state.ml b/src/lib_shell_services/peer_validator_worker_state.ml index 099d11dc11ba..e7d112d50c66 100644 --- a/src/lib_shell_services/peer_validator_worker_state.ml +++ b/src/lib_shell_services/peer_validator_worker_state.ml @@ -24,7 +24,9 @@ (*****************************************************************************) module Request = struct - type view = New_head of Block_hash.t | New_branch of Block_hash.t * int + type view = + | New_head of Tezos_crypto.Block_hash.t + | New_branch of Tezos_crypto.Block_hash.t * int let encoding = let open Data_encoding in @@ -35,7 +37,7 @@ module Request = struct ~title:"New_head" (obj2 (req "request" (constant "new_head")) - (req "block" Block_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding)) (function New_head h -> Some ((), h) | _ -> None) (fun ((), h) -> New_head h); case @@ -43,19 +45,20 @@ module Request = struct ~title:"New_branch" (obj3 (req "request" (constant "new_branch")) - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "locators" int31)) (function New_branch (h, l) -> Some ((), h, l) | _ -> None) (fun ((), h, l) -> New_branch (h, l)); ] let pp ppf = function - | New_head hash -> Format.fprintf ppf "New head %a" Block_hash.pp hash + | New_head hash -> + Format.fprintf ppf "New head %a" Tezos_crypto.Block_hash.pp hash | New_branch (hash, len) -> Format.fprintf ppf "New branch %a, locator length %d" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash len end diff --git a/src/lib_shell_services/peer_validator_worker_state.mli b/src/lib_shell_services/peer_validator_worker_state.mli index 71b0593df9fc..36f870f80406 100644 --- a/src/lib_shell_services/peer_validator_worker_state.mli +++ b/src/lib_shell_services/peer_validator_worker_state.mli @@ -24,7 +24,9 @@ (*****************************************************************************) module Request : sig - type view = New_head of Block_hash.t | New_branch of Block_hash.t * int + type view = + | New_head of Tezos_crypto.Block_hash.t + | New_branch of Tezos_crypto.Block_hash.t * int val encoding : view Data_encoding.encoding diff --git a/src/lib_shell_services/preapply_result.ml b/src/lib_shell_services/preapply_result.ml index 04d0f3501964..df8f2e405e36 100644 --- a/src/lib_shell_services/preapply_result.ml +++ b/src/lib_shell_services/preapply_result.ml @@ -24,42 +24,43 @@ (*****************************************************************************) type 'error t = { - applied : (Operation_hash.t * Operation.t) list; - refused : (Operation.t * 'error list) Operation_hash.Map.t; - outdated : (Operation.t * 'error list) Operation_hash.Map.t; - branch_refused : (Operation.t * 'error list) Operation_hash.Map.t; - branch_delayed : (Operation.t * 'error list) Operation_hash.Map.t; + applied : (Tezos_crypto.Operation_hash.t * Operation.t) list; + refused : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; + outdated : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; + branch_refused : + (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; + branch_delayed : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; } let empty = { applied = []; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; } let encoding error_encoding = let open Data_encoding in let operation_encoding = merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Operation_hash.encoding)) (dynamic_size Operation.encoding) in let refused_encoding = merge_objs - (obj1 (req "hash" Operation_hash.encoding)) + (obj1 (req "hash" Tezos_crypto.Operation_hash.encoding)) (merge_objs (dynamic_size Operation.encoding) (obj1 (req "error" error_encoding))) in - let build_list map = Operation_hash.Map.bindings map in + let build_list map = Tezos_crypto.Operation_hash.Map.bindings map in let build_map list = List.fold_right - (fun (k, e) m -> Operation_hash.Map.add k e m) + (fun (k, e) m -> Tezos_crypto.Operation_hash.Map.add k e m) list - Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.empty in conv (fun {applied; refused; outdated; branch_refused; branch_delayed} -> diff --git a/src/lib_shell_services/preapply_result.mli b/src/lib_shell_services/preapply_result.mli index 0ae05104776b..ef2ae2f536f3 100644 --- a/src/lib_shell_services/preapply_result.mli +++ b/src/lib_shell_services/preapply_result.mli @@ -25,14 +25,16 @@ (** A container for classified operations *) type 'error t = { - applied : (Operation_hash.t * Operation.t) list; (** Applied operations *) - refused : (Operation.t * 'error list) Operation_hash.Map.t; + applied : (Tezos_crypto.Operation_hash.t * Operation.t) list; + (** Applied operations *) + refused : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; (** Refused operations, for example because of an invalid signature *) - outdated : (Operation.t * 'error list) Operation_hash.Map.t; + outdated : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; (** Outdated operations, for example a late endorsement *) - branch_refused : (Operation.t * 'error list) Operation_hash.Map.t; + branch_refused : + (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; (** Branch refused operations, for example because of insufficient balance *) - branch_delayed : (Operation.t * 'error list) Operation_hash.Map.t; + branch_delayed : (Operation.t * 'error list) Tezos_crypto.Operation_hash.Map.t; (** Branch delayed operations, for example because of a timestamp in the future *) } diff --git a/src/lib_shell_services/prevalidator_worker_state.ml b/src/lib_shell_services/prevalidator_worker_state.ml index 374918071935..8e3e5686c21a 100644 --- a/src/lib_shell_services/prevalidator_worker_state.ml +++ b/src/lib_shell_services/prevalidator_worker_state.ml @@ -27,17 +27,17 @@ module Request = struct type ('a, 'b) t = | Flush : - Block_hash.t + Tezos_crypto.Block_hash.t * Chain_validator_worker_state.update - * Block_hash.Set.t - * Operation_hash.Set.t + * Tezos_crypto.Block_hash.Set.t + * Tezos_crypto.Operation_hash.Set.t -> (unit, error trace) t | Notify : P2p_peer.Id.t * Mempool.t -> (unit, Empty.t) t | Leftover : (unit, Empty.t) t | Inject : {op : Operation.t; force : bool} -> (unit, error trace) t - | Arrived : Operation_hash.t * Operation.t -> (unit, Empty.t) t + | Arrived : Tezos_crypto.Operation_hash.t * Operation.t -> (unit, Empty.t) t | Advertise : (unit, Empty.t) t - | Ban : Operation_hash.t -> (unit, error trace) t + | Ban : Tezos_crypto.Operation_hash.t -> (unit, error trace) t type view = View : _ t -> view @@ -52,7 +52,7 @@ module Request = struct ~title:"Flush" (obj3 (req "request" (constant "flush")) - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "event" Chain_validator_worker_state.update_encoding)) (function | View (Flush (hash, event, _, _)) -> Some ((), hash, event) @@ -60,7 +60,10 @@ module Request = struct (fun ((), hash, event) -> View (Flush - (hash, event, Block_hash.Set.empty, Operation_hash.Set.empty))); + ( hash, + event, + Tezos_crypto.Block_hash.Set.empty, + Tezos_crypto.Operation_hash.Set.empty ))); case (Tag 1) ~title:"Notify" @@ -87,7 +90,7 @@ module Request = struct ~title:"Arrived" (obj3 (req "request" (constant "arrived")) - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation" Operation.encoding)) (function | View (Arrived (oph, op)) -> Some ((), oph, op) | _ -> None) @@ -109,7 +112,7 @@ module Request = struct ~title:"Ban" (obj2 (req "request" (constant "ban")) - (req "operation_hash" Operation_hash.encoding)) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding)) (function View (Ban oph) -> Some ((), oph) | _ -> None) (fun ((), oph) -> View (Ban oph)); ] @@ -117,7 +120,11 @@ module Request = struct let pp ppf (View r) = match r with | Flush (hash, _, _, _) -> - Format.fprintf ppf "switching to new head %a" Block_hash.pp hash + Format.fprintf + ppf + "switching to new head %a" + Tezos_crypto.Block_hash.pp + hash | Notify (id, {Mempool.known_valid; pending}) -> Format.fprintf ppf @@ -125,24 +132,43 @@ module Request = struct P2p_peer.Id.pp id ; List.iter - (fun oph -> Format.fprintf ppf "@,%a (applied)" Operation_hash.pp oph) + (fun oph -> + Format.fprintf + ppf + "@,%a (applied)" + Tezos_crypto.Operation_hash.pp + oph) known_valid ; List.iter - (fun oph -> Format.fprintf ppf "@,%a (pending)" Operation_hash.pp oph) - (Operation_hash.Set.elements pending) ; + (fun oph -> + Format.fprintf + ppf + "@,%a (pending)" + Tezos_crypto.Operation_hash.pp + oph) + (Tezos_crypto.Operation_hash.Set.elements pending) ; Format.fprintf ppf "@]" | Leftover -> Format.fprintf ppf "process next batch of operation" | Inject {op; force} -> Format.fprintf ppf "injecting operation %a (force:%b)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op) force | Arrived (oph, _) -> - Format.fprintf ppf "operation %a arrived" Operation_hash.pp oph + Format.fprintf + ppf + "operation %a arrived" + Tezos_crypto.Operation_hash.pp + oph | Advertise -> Format.fprintf ppf "advertising pending operations" - | Ban oph -> Format.fprintf ppf "banning operation %a" Operation_hash.pp oph + | Ban oph -> + Format.fprintf + ppf + "banning operation %a" + Tezos_crypto.Operation_hash.pp + oph end module Operation_encountered = struct @@ -152,7 +178,7 @@ module Operation_encountered = struct | Notified of P2p_peer_id.t option | Other - type t = situation * Operation_hash.t + type t = situation * Tezos_crypto.Operation_hash.t let encoding = let open Data_encoding in @@ -164,7 +190,7 @@ module Operation_encountered = struct ~title:"injected" (obj2 (req "situation" (constant "injected")) - (req "operation" Operation_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Injected, oph -> Some ((), oph) | _ -> None) (fun ((), oph) -> (Injected, oph)); case @@ -172,7 +198,7 @@ module Operation_encountered = struct ~title:"arrived" (obj2 (req "situation" (constant "arrived")) - (req "operation" Operation_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Arrived, oph -> Some ((), oph) | _ -> None) (fun ((), oph) -> (Arrived, oph)); case @@ -180,7 +206,7 @@ module Operation_encountered = struct ~title:"notified" (obj3 (req "situation" (constant "notified")) - (req "operation" Operation_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding) (req "peer" (option P2p_peer_id.encoding))) (function Notified peer, oph -> Some ((), oph, peer) | _ -> None) (fun ((), oph, peer) -> (Notified peer, oph)); @@ -189,7 +215,7 @@ module Operation_encountered = struct ~title:"other" (obj2 (req "situation" (constant "other")) - (req "operation" Operation_hash.encoding)) + (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Other, hash -> Some ((), hash) | _ -> None) (fun ((), oph) -> (Other, oph)); ] @@ -208,7 +234,7 @@ module Operation_encountered = struct "operation %a: %a" situation_pp situation - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph end diff --git a/src/lib_shell_services/prevalidator_worker_state.mli b/src/lib_shell_services/prevalidator_worker_state.mli index 32458e857abc..6653c396030e 100644 --- a/src/lib_shell_services/prevalidator_worker_state.mli +++ b/src/lib_shell_services/prevalidator_worker_state.mli @@ -27,10 +27,10 @@ module Request : sig type ('a, 'b) t = | Flush : - Block_hash.t + Tezos_crypto.Block_hash.t * Chain_validator_worker_state.update - * Block_hash.Set.t - * Operation_hash.Set.t + * Tezos_crypto.Block_hash.Set.t + * Tezos_crypto.Operation_hash.Set.t -> (unit, error trace) t (** The chain changed, the mempool is being notified of the new state. *) | Notify : P2p_peer.Id.t * Mempool.t -> (unit, Empty.t) t @@ -39,11 +39,11 @@ module Request : sig (** Operations not yet processed should be processed. *) | Inject : {op : Operation.t; force : bool} -> (unit, error trace) t (** Operation has been locally injected (sent) to the node. *) - | Arrived : Operation_hash.t * Operation.t -> (unit, Empty.t) t + | Arrived : Tezos_crypto.Operation_hash.t * Operation.t -> (unit, Empty.t) t (** Operation was fetched by the node. *) | Advertise : (unit, Empty.t) t (** Current mempool should be advertised to all known peers. *) - | Ban : Operation_hash.t -> (unit, error trace) t + | Ban : Tezos_crypto.Operation_hash.t -> (unit, error trace) t (** User requested the node to ban operation with this hash. *) type view = View : _ t -> view @@ -74,7 +74,7 @@ module Operation_encountered : sig | Notified of P2p_peer_id.t option | Other - type t = situation * Operation_hash.t + type t = situation * Tezos_crypto.Operation_hash.t val encoding : t Data_encoding.t diff --git a/src/lib_shell_services/protocol_services.ml b/src/lib_shell_services/protocol_services.ml index 3420784d0c67..92e7e2ad8ed2 100644 --- a/src/lib_shell_services/protocol_services.ml +++ b/src/lib_shell_services/protocol_services.ml @@ -26,7 +26,7 @@ open Data_encoding module S = struct - let protocols_arg = Protocol_hash.rpc_arg + let protocols_arg = Tezos_crypto.Protocol_hash.rpc_arg let contents = Tezos_rpc.Service.get_service @@ -43,7 +43,7 @@ module S = struct let list = Tezos_rpc.Service.get_service ~query:Tezos_rpc.Query.empty - ~output:(list Protocol_hash.encoding) + ~output:(list Tezos_crypto.Protocol_hash.encoding) Tezos_rpc.Path.(root / "protocols") let fetch = diff --git a/src/lib_shell_services/protocol_services.mli b/src/lib_shell_services/protocol_services.mli index eaaed856b5af..40e6e010b4c9 100644 --- a/src/lib_shell_services/protocol_services.mli +++ b/src/lib_shell_services/protocol_services.mli @@ -25,20 +25,21 @@ open Tezos_rpc.Context -val contents : #simple -> Protocol_hash.t -> Protocol.t tzresult Lwt.t +val contents : + #simple -> Tezos_crypto.Protocol_hash.t -> Protocol.t tzresult Lwt.t val environment : - #simple -> Protocol_hash.t -> Protocol.env_version tzresult Lwt.t + #simple -> Tezos_crypto.Protocol_hash.t -> Protocol.env_version tzresult Lwt.t -val list : #simple -> Protocol_hash.t list tzresult Lwt.t +val list : #simple -> Tezos_crypto.Protocol_hash.t list tzresult Lwt.t -val fetch : #simple -> Protocol_hash.t -> unit tzresult Lwt.t +val fetch : #simple -> Tezos_crypto.Protocol_hash.t -> unit tzresult Lwt.t module S : sig val contents : ( [`GET], unit, - unit * Protocol_hash.t, + unit * Tezos_crypto.Protocol_hash.t, unit, unit, Protocol.t ) @@ -47,15 +48,27 @@ module S : sig val environment : ( [`GET], unit, - unit * Protocol_hash.t, + unit * Tezos_crypto.Protocol_hash.t, unit, unit, Protocol.env_version ) Tezos_rpc.Service.t val list : - ([`GET], unit, unit, unit, unit, Protocol_hash.t list) Tezos_rpc.Service.t + ( [`GET], + unit, + unit, + unit, + unit, + Tezos_crypto.Protocol_hash.t list ) + Tezos_rpc.Service.t val fetch : - ([`GET], unit, unit * Protocol_hash.t, unit, unit, unit) Tezos_rpc.Service.t + ( [`GET], + unit, + unit * Tezos_crypto.Protocol_hash.t, + unit, + unit, + unit ) + Tezos_rpc.Service.t end diff --git a/src/lib_shell_services/state_events.ml b/src/lib_shell_services/state_events.ml index 9b68a3e2b096..c0e6d9db9531 100644 --- a/src/lib_shell_services/state_events.ml +++ b/src/lib_shell_services/state_events.ml @@ -33,7 +33,7 @@ let missing_pruned_contents = ~name:"missing_pruned_contents" ~msg:"cannot find pruned contents of block {block_hash}" ~level:Error - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let pop_block = declare_1 @@ -41,7 +41,7 @@ let pop_block = ~name:"pop_block" ~msg:"pop_block {block_hash}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let push_block = declare_1 @@ -49,7 +49,7 @@ let push_block = ~name:"push_block" ~msg:"push_block {block_hash}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let destroy_state = declare_1 @@ -57,4 +57,4 @@ let destroy_state = ~name:"destroy_state" ~msg:"destroy {chain_id}" ~level:Debug - ("chain_id", Chain_id.encoding) + ("chain_id", Tezos_crypto.Chain_id.encoding) diff --git a/src/lib_shell_services/store_errors.ml b/src/lib_shell_services/store_errors.ml index 3596afd60b97..0daa5b87751a 100644 --- a/src/lib_shell_services/store_errors.ml +++ b/src/lib_shell_services/store_errors.ml @@ -24,21 +24,21 @@ (*****************************************************************************) type error += - | Block_not_found of {hash : Block_hash.t; distance : int} + | Block_not_found of {hash : Tezos_crypto.Block_hash.t; distance : int} | Bad_level of {head_level : Int32.t; given_level : Int32.t} - | Block_metadata_not_found of Block_hash.t + | Block_metadata_not_found of Tezos_crypto.Block_hash.t | Cannot_switch_history_mode of { previous_mode : History_mode.t; next_mode : History_mode.t; } | Invalid_head_switch of { checkpoint_level : int32; - given_head : Block_hash.t * int32; + given_head : Tezos_crypto.Block_hash.t * int32; } | Inconsistent_store_state of string | Inconsistent_operations_hash of { - expected : Operation_list_list_hash.t; - got : Operation_list_list_hash.t; + expected : Tezos_crypto.Operation_list_list_hash.t; + got : Tezos_crypto.Operation_list_list_hash.t; } let () = @@ -52,10 +52,10 @@ let () = ppf "Cannot find block at distance %d from block %a." distance - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash) Data_encoding.( - obj1 (req "block_not_found" @@ tup2 Block_hash.encoding int8)) + obj1 (req "block_not_found" @@ tup2 Tezos_crypto.Block_hash.encoding int8)) (function | Block_not_found {hash; distance} -> Some (hash, distance) | _ -> None) (fun (hash, distance) -> Block_not_found {hash; distance}) ; @@ -84,9 +84,10 @@ let () = Format.fprintf ppf "Unable to find block %a's metadata." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash) - Data_encoding.(obj1 (req "block_metadata_not_found" Block_hash.encoding)) + Data_encoding.( + obj1 (req "block_metadata_not_found" Tezos_crypto.Block_hash.encoding)) (function | Block_metadata_not_found block_hash -> Some block_hash | _ -> None) (fun block_hash -> Block_metadata_not_found block_hash) ; @@ -124,14 +125,14 @@ let () = Format.fprintf ppf "The given head %a (%ld) is below the minimum allowed level %ld." - Block_hash.pp + Tezos_crypto.Block_hash.pp head_hash head_level minimum_allowed_level) Data_encoding.( obj2 (req "minimum_allowed_level" int32) - (req "given_head" @@ tup2 Block_hash.encoding int32)) + (req "given_head" @@ tup2 Tezos_crypto.Block_hash.encoding int32)) (function | Invalid_head_switch {checkpoint_level; given_head} -> Some (checkpoint_level, given_head) @@ -147,14 +148,18 @@ let () = Format.fprintf ppf "Inconsistent operation hashes. Expected: %a, got %a." - Operation_list_list_hash.pp + Tezos_crypto.Operation_list_list_hash.pp oph - Operation_list_list_hash.pp + Tezos_crypto.Operation_list_list_hash.pp oph') Data_encoding.( obj2 - (req "expected_operation_hashes" Operation_list_list_hash.encoding) - (req "received_operation_hashes" Operation_list_list_hash.encoding)) + (req + "expected_operation_hashes" + Tezos_crypto.Operation_list_list_hash.encoding) + (req + "received_operation_hashes" + Tezos_crypto.Operation_list_list_hash.encoding)) (function | Inconsistent_operations_hash {expected; got} -> Some (expected, got) | _ -> None) @@ -168,11 +173,11 @@ type cemented_store_inconsistency = } | Bad_offset of {level : int; cycle : string} | Unexpected_level of { - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; expected : Int32.t; got : Int32.t; } - | Corrupted_index of Block_hash.t + | Corrupted_index of Tezos_crypto.Block_hash.t | Inconsistent_highest_cemented_level of { highest_cemented_level : Int32.t; cementing_highwatermark : Int32.t; @@ -211,7 +216,7 @@ let cemented_store_inconsistency_encoding = (Tag 3) ~title:"Unexpected level" (obj3 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "expected" int32) (req "got" int32)) (function @@ -223,7 +228,7 @@ let cemented_store_inconsistency_encoding = case (Tag 4) ~title:"Corrupted index" - (obj1 (req "block_hash" Block_hash.encoding)) + (obj1 (req "block_hash" Tezos_crypto.Block_hash.encoding)) (function Corrupted_index h -> Some h | _ -> None) (fun h -> Corrupted_index h); case @@ -301,7 +306,7 @@ let store_block_error_encoding = type error += | Cannot_write_in_readonly - | Wrong_predecessor of Block_hash.t * int + | Wrong_predecessor of Tezos_crypto.Block_hash.t * int | Invalid_blocks_to_cement | Wrong_floating_kind_swap | Cannot_update_floating_store @@ -319,31 +324,34 @@ type error += | Missing_last_allowed_fork_level_block | Inconsistent_block_hash of { level : Int32.t; - expected_hash : Block_hash.t; - computed_hash : Block_hash.t; + expected_hash : Tezos_crypto.Block_hash.t; + computed_hash : Tezos_crypto.Block_hash.t; } | Inconsistent_block_predecessor of { - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; level : Int32.t; - expected_hash : Block_hash.t; - computed_hash : Block_hash.t; + expected_hash : Tezos_crypto.Block_hash.t; + computed_hash : Tezos_crypto.Block_hash.t; } - | Cannot_encode_block of Block_hash.t - | Cannot_store_block of Block_hash.t * store_block_error - | Cannot_checkout_context of Block_hash.t * Context_hash.t + | Cannot_encode_block of Tezos_crypto.Block_hash.t + | Cannot_store_block of Tezos_crypto.Block_hash.t * store_block_error + | Cannot_checkout_context of + Tezos_crypto.Block_hash.t * Tezos_crypto.Context_hash.t | Cannot_find_protocol of int | Invalid_genesis_marking | Cannot_retrieve_savepoint of Int32.t - | Cannot_set_target of (Block_hash.t * Int32.t) + | Cannot_set_target of (Tezos_crypto.Block_hash.t * Int32.t) | Missing_commit_info of string | Inconsistent_chain_store | Fork_testchain_not_allowed - | Cannot_fork_testchain of Chain_id.t + | Cannot_fork_testchain of Tezos_crypto.Chain_id.t | Cannot_load_testchain of string - | Missing_activation_block of Block_hash.t * Protocol_hash.t * History_mode.t - | Inconsistent_protocol_commit_info of Block_hash.t * Protocol_hash.t + | Missing_activation_block of + Tezos_crypto.Block_hash.t * Tezos_crypto.Protocol_hash.t * History_mode.t + | Inconsistent_protocol_commit_info of + Tezos_crypto.Block_hash.t * Tezos_crypto.Protocol_hash.t | Missing_stored_data of string - | Failed_to_get_live_blocks of Block_hash.t + | Failed_to_get_live_blocks of Tezos_crypto.Block_hash.t | Target_mismatch | Bad_head_invariant @@ -367,10 +375,11 @@ let () = Format.fprintf ppf "Failed to get the nth predecessor of %a. The offset is invalid: %d." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash offset) - Data_encoding.(obj2 (req "hash" Block_hash.encoding) (req "offset" int31)) + Data_encoding.( + obj2 (req "hash" Tezos_crypto.Block_hash.encoding) (req "offset" int31)) (function | Wrong_predecessor (hash, offset) -> Some (hash, offset) | _ -> None) (fun (hash, offset) -> Wrong_predecessor (hash, offset)) ; @@ -579,14 +588,14 @@ let () = | Unexpected_level {block_hash; expected; got} -> Format.asprintf "bad level found for block %a - expected %ld got %ld" - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash expected got | Corrupted_index h -> Format.asprintf "%a was not found in the imported store" - Block_hash.pp + Tezos_crypto.Block_hash.pp h | Inconsistent_highest_cemented_level {highest_cemented_level; cementing_highwatermark} -> @@ -626,15 +635,15 @@ let () = "Inconsistent block: inconsistent hash found for block %ld. Expected \ %a, got %a." level - Block_hash.pp + Tezos_crypto.Block_hash.pp expected_hash - Block_hash.pp + Tezos_crypto.Block_hash.pp computed_hash) Data_encoding.( obj3 (req "level" int32) - (req "expected_hash" Block_hash.encoding) - (req "computed_hash" Block_hash.encoding)) + (req "expected_hash" Tezos_crypto.Block_hash.encoding) + (req "computed_hash" Tezos_crypto.Block_hash.encoding)) (function | Inconsistent_block_hash {level; expected_hash; computed_hash} -> Some (level, expected_hash, computed_hash) @@ -651,19 +660,19 @@ let () = ppf "Inconsistent block: inconsistent predecessor found for block %a (%ld) \ - expected: %a vs got: %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash level - Block_hash.pp + Tezos_crypto.Block_hash.pp expected_hash - Block_hash.pp + Tezos_crypto.Block_hash.pp computed_hash) Data_encoding.( obj4 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "level" int32) - (req "expected_hash" Block_hash.encoding) - (req "computed_hash" Block_hash.encoding)) + (req "expected_hash" Tezos_crypto.Block_hash.encoding) + (req "computed_hash" Tezos_crypto.Block_hash.encoding)) (function | Inconsistent_block_predecessor {block_hash; level; expected_hash; computed_hash} -> @@ -681,9 +690,9 @@ let () = Format.fprintf ppf "Failed to write block in floating store: cannot encode block %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash) - Data_encoding.(obj1 (req "hash" Block_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Cannot_encode_block hash -> Some hash | _ -> None) (fun hash -> Cannot_encode_block hash) ; Error_monad.register_error_kind @@ -695,7 +704,7 @@ let () = Format.fprintf ppf "Failed to store block %a: %s." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash (match err with | Invalid_block -> "the block is marked as invalid" @@ -724,7 +733,7 @@ let () = genesis_level)) Data_encoding.( obj2 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "err" store_block_error_encoding)) (function Cannot_store_block (hash, err) -> Some (hash, err) | _ -> None) (fun (hash, err) -> Cannot_store_block (hash, err)) ; @@ -737,14 +746,14 @@ let () = Format.fprintf ppf "Failed to checkout the context (%a) for block %a." - Context_hash.pp + Tezos_crypto.Context_hash.pp ch - Block_hash.pp + Tezos_crypto.Block_hash.pp bh) Data_encoding.( obj2 - (req "block_hash" Block_hash.encoding) - (req "context_hash" Context_hash.encoding)) + (req "block_hash" Tezos_crypto.Block_hash.encoding) + (req "context_hash" Tezos_crypto.Context_hash.encoding)) (function Cannot_checkout_context (bh, ch) -> Some (bh, ch) | _ -> None) (fun (bh, ch) -> Cannot_checkout_context (bh, ch)) ; Error_monad.register_error_kind @@ -791,10 +800,11 @@ let () = ppf "Failed to set the given target %a (%ld): it is either invalid, or not \ a predecessor of the checkpoint." - Block_hash.pp + Tezos_crypto.Block_hash.pp given_target_hash given_target_level) - Data_encoding.(obj1 (req "given_target" (tup2 Block_hash.encoding int32))) + Data_encoding.( + obj1 (req "given_target" (tup2 Tezos_crypto.Block_hash.encoding int32))) (function Cannot_set_target given_target -> Some given_target | _ -> None) (fun given_target -> Cannot_set_target given_target) ; Error_monad.register_error_kind @@ -844,9 +854,9 @@ let () = Format.fprintf ppf "Failed to fork the testchain: the testchain %a already exists." - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id) - Data_encoding.(obj1 (req "chain_id" Chain_id.encoding)) + Data_encoding.(obj1 (req "chain_id" Tezos_crypto.Chain_id.encoding)) (function Cannot_fork_testchain chain_id -> Some chain_id | _ -> None) (fun chain_id -> Cannot_fork_testchain chain_id) ; Error_monad.register_error_kind @@ -872,16 +882,16 @@ let () = ppf "Failed to restore snapshot: the expected activation block %a \ originating the protocol %a was not found for %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp bh - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp ph History_mode.pp hm) Data_encoding.( obj3 - (req "block_hash" Block_hash.encoding) - (req "protocol_hash" Protocol_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) + (req "protocol_hash" Tezos_crypto.Protocol_hash.encoding) (req "history_mode" History_mode.encoding)) (function | Missing_activation_block (bh, ph, hm) -> Some (bh, ph, hm) | _ -> None) @@ -896,14 +906,14 @@ let () = ppf "Failed to restore snapshot: inconsistent commit info found for \ transition block %a activating protocol %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp bh - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp ph) Data_encoding.( obj2 - (req "block_hash" Block_hash.encoding) - (req "protocol_hash" Protocol_hash.encoding)) + (req "block_hash" Tezos_crypto.Block_hash.encoding) + (req "protocol_hash" Tezos_crypto.Protocol_hash.encoding)) (function | Inconsistent_protocol_commit_info (bh, ph) -> Some (bh, ph) | _ -> None) (fun (bh, ph) -> Inconsistent_protocol_commit_info (bh, ph)) ; @@ -925,13 +935,13 @@ let () = ~id:"store.failed_to_get_live_blocks" ~title:"Fail to get live blocks" ~description:"Unable to compute live blocks from a given block." - ~pp:(fun ppf (hash : Block_hash.t) -> + ~pp:(fun ppf (hash : Tezos_crypto.Block_hash.t) -> Format.fprintf ppf "Failed to get live blocks from block %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash) - Data_encoding.(obj1 (req "hash" Block_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Failed_to_get_live_blocks h -> Some h | _ -> None) (fun h -> Failed_to_get_live_blocks h) ; Error_monad.register_error_kind @@ -959,11 +969,14 @@ type error += | Unexpected_missing_block of {block_name : string} | Unexpected_missing_block_metadata of {block_name : string} | Unexpected_missing_activation_block of { - block : Block_hash.t; - protocol : Protocol_hash.t; + block : Tezos_crypto.Block_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; } | Unexpected_missing_protocol of {protocol_level : int} - | Inconsistent_genesis of {expected : Block_hash.t; got : Block_hash.t} + | Inconsistent_genesis of { + expected : Tezos_crypto.Block_hash.t; + got : Tezos_crypto.Block_hash.t; + } | Inconsistent_cementing_highwatermark of { highest_cemented_level : Int32.t; cementing_highwatermark : Int32.t; @@ -1018,14 +1031,14 @@ let () = ppf "The block %a activating protocol %a is unexpectedly missing from the \ store." - Block_hash.pp + Tezos_crypto.Block_hash.pp block - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto) Data_encoding.( obj2 - (req "block" Block_hash.encoding) - (req "protocol" Protocol_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding)) (function | Unexpected_missing_activation_block {block; protocol} -> Some (block, protocol) @@ -1056,12 +1069,14 @@ let () = Format.fprintf ppf "The genesis (%a) found in the store is not the one expected (%a)." - Block_hash.pp + Tezos_crypto.Block_hash.pp got - Block_hash.pp + Tezos_crypto.Block_hash.pp expected) Data_encoding.( - obj2 (req "expected" Block_hash.encoding) (req "got" Block_hash.encoding)) + obj2 + (req "expected" Tezos_crypto.Block_hash.encoding) + (req "got" Tezos_crypto.Block_hash.encoding)) (function | Inconsistent_genesis {expected; got} -> Some (expected, got) | _ -> None) (fun (expected, got) -> Inconsistent_genesis {expected; got}) ; @@ -1164,7 +1179,7 @@ let () = {genesis; caboose; savepoint; cementing_highwatermark; checkpoint; head}) type corruption_kind = - | Inferred_head of Block_hash.t * Int32.t + | Inferred_head of Tezos_crypto.Block_hash.t * Int32.t | Cannot_find_floating_savepoint | Cannot_find_savepoint_candidate | Cannot_find_floating_caboose @@ -1180,7 +1195,7 @@ let corruption_kind_encoding = case (Tag 0) ~title:"Inferred_head" - (obj2 (req "hash" Block_hash.encoding) (req "level" int32)) + (obj2 (req "hash" Tezos_crypto.Block_hash.encoding) (req "level" int32)) (function | Inferred_head (hash, level) -> Some (hash, level) | _ -> None) (fun (hash, level) -> Inferred_head (hash, level)); @@ -1235,7 +1250,7 @@ let pp_corruption_kind ppf = function Format.fprintf ppf "inferred head (%a, %ld) must have metadata" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash level | Cannot_find_floating_savepoint -> diff --git a/src/lib_shell_services/validation_errors.ml b/src/lib_shell_services/validation_errors.ml index 596f91b897a1..c4b605a405ca 100644 --- a/src/lib_shell_services/validation_errors.ml +++ b/src/lib_shell_services/validation_errors.ml @@ -34,7 +34,7 @@ type error += Oversized_operation of {size : int; max : int} type error += | Future_block_header of { - block : Block_hash.t; + block : Tezos_crypto.Block_hash.t; block_time : Time.Protocol.t; time : Time.System.t; } @@ -87,7 +87,7 @@ let () = Format.fprintf ppf "Future block header (block: %a, block_time: %a, time: %a)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block Time.System.pp_hum (Time.System.of_protocol_exn block_time) @@ -95,7 +95,7 @@ let () = time) Data_encoding.( obj3 - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "block_time" Time.Protocol.encoding) (req "time" Time.System.encoding)) (function @@ -117,11 +117,11 @@ let () = (************************* State errors ***********************************) -type error += Unknown_chain of Chain_id.t +type error += Unknown_chain of Tezos_crypto.Chain_id.t type error += Bad_data_dir -type error += Block_not_invalid of Block_hash.t +type error += Block_not_invalid of Tezos_crypto.Block_hash.t let () = (* Unknown network *) @@ -131,8 +131,9 @@ let () = ~title:"Unknown chain" ~description: "The chain identifier could not be found in the chain identifiers table." - ~pp:(fun ppf id -> Format.fprintf ppf "Unknown chain %a" Chain_id.pp id) - Data_encoding.(obj1 (req "chain" Chain_id.encoding)) + ~pp:(fun ppf id -> + Format.fprintf ppf "Unknown chain %a" Tezos_crypto.Chain_id.pp id) + Data_encoding.(obj1 (req "chain" Tezos_crypto.Chain_id.encoding)) (function Unknown_chain x -> Some x | _ -> None) (fun x -> Unknown_chain x) ; register_error_kind @@ -157,19 +158,21 @@ let () = Format.fprintf ppf "Block %a was expected to be invalid, but was not actually invalid." - Block_hash.pp + Tezos_crypto.Block_hash.pp block) - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function Block_not_invalid block -> Some block | _ -> None) (fun block -> Block_not_invalid block) (* Block database error *) -type error += Inconsistent_hash of Context_hash.t * Context_hash.t +type error += + | Inconsistent_hash of + Tezos_crypto.Context_hash.t * Tezos_crypto.Context_hash.t -type error += Missing_block_metadata_hash of Block_hash.t +type error += Missing_block_metadata_hash of Tezos_crypto.Block_hash.t -type error += Missing_operation_metadata_hashes of Block_hash.t +type error += Missing_operation_metadata_hashes of Tezos_crypto.Block_hash.t let () = (* Inconsistent hash *) @@ -184,14 +187,14 @@ let () = Format.fprintf ppf "@[Inconsistent hash:@ got: %a@ expected: %a" - Context_hash.pp + Tezos_crypto.Context_hash.pp got - Context_hash.pp + Tezos_crypto.Context_hash.pp exp) Data_encoding.( obj2 - (req "wrong_context_hash" Context_hash.encoding) - (req "expected_context_hash" Context_hash.encoding)) + (req "wrong_context_hash" Tezos_crypto.Context_hash.encoding) + (req "expected_context_hash" Tezos_crypto.Context_hash.encoding)) (function Inconsistent_hash (got, exp) -> Some (got, exp) | _ -> None) (fun (got, exp) -> Inconsistent_hash (got, exp)) ; register_error_kind @@ -205,9 +208,9 @@ let () = Format.fprintf ppf "@[Missing block metadata hash at block: %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp block) - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function Missing_block_metadata_hash block -> Some block | _ -> None) (fun block -> Missing_block_metadata_hash block) ; register_error_kind @@ -221,9 +224,9 @@ let () = Format.fprintf ppf "@[Missing operation metadata hashes at block: %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp block) - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function | Missing_operation_metadata_hashes block -> Some block | _ -> None) (fun block -> Missing_operation_metadata_hashes block) @@ -281,7 +284,10 @@ let () = type protocol_error = Compilation_failed | Dynlinking_failed type error += - | Invalid_protocol of {hash : Protocol_hash.t; error : protocol_error} + | Invalid_protocol of { + hash : Tezos_crypto.Protocol_hash.t; + error : protocol_error; + } let protocol_error_encoding = let open Data_encoding in @@ -316,19 +322,19 @@ let () = Format.fprintf ppf "@[Invalid protocol %a@ %a@]" - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol pp_protocol_error error) Data_encoding.( merge_objs - (obj1 (req "invalid_protocol" Protocol_hash.encoding)) + (obj1 (req "invalid_protocol" Tezos_crypto.Protocol_hash.encoding)) protocol_error_encoding) (function | Invalid_protocol {hash; error} -> Some (hash, error) | _ -> None) (fun (hash, error) -> Invalid_protocol {hash; error}) -type error += Cannot_load_protocol of Protocol_hash.t +type error += Cannot_load_protocol of Tezos_crypto.Protocol_hash.t let () = register_error_kind @@ -341,9 +347,9 @@ let () = ppf "Failed to load the protocol %a from disk: the corresponding files \ might be missing or corrupted." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol) - Data_encoding.(obj1 (req "protocol" Protocol_hash.encoding)) + Data_encoding.(obj1 (req "protocol" Tezos_crypto.Protocol_hash.encoding)) (function Cannot_load_protocol protocol -> Some protocol | _ -> None) (fun protocol -> Cannot_load_protocol protocol) @@ -375,9 +381,10 @@ let () = (************************ Validator errors ********************************) -type error += Inactive_chain of Chain_id.t +type error += Inactive_chain of Tezos_crypto.Chain_id.t -type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option +type error += + | Checkpoint_error of Tezos_crypto.Block_hash.t * P2p_peer.Id.t option let () = (* Inactive network *) @@ -391,9 +398,9 @@ let () = ppf "Tried to validate a block from chain %a, that is not currently \ considered active." - Chain_id.pp + Tezos_crypto.Chain_id.pp chain) - Data_encoding.(obj1 (req "inactive_chain" Chain_id.encoding)) + Data_encoding.(obj1 (req "inactive_chain" Tezos_crypto.Chain_id.encoding)) (function Inactive_chain chain -> Some chain | _ -> None) (fun chain -> Inactive_chain chain) ; register_error_kind @@ -409,7 +416,7 @@ let () = Format.fprintf ppf "The block %a is incompatible with the current checkpoint." - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block | Some peer -> Format.fprintf @@ -418,10 +425,12 @@ let () = checkpoint (%a)." P2p_peer.Id.pp peer - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block) Data_encoding.( - obj2 (req "block" Block_hash.encoding) (opt "peer" P2p_peer.Id.encoding)) + obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (opt "peer" P2p_peer.Id.encoding)) (function | Checkpoint_error (block, peer) -> Some (block, peer) | _ -> None) (fun (block, peer) -> Checkpoint_error (block, peer)) diff --git a/src/lib_shell_services/validation_errors.mli b/src/lib_shell_services/validation_errors.mli index b182a73cce9c..df095c309ee2 100644 --- a/src/lib_shell_services/validation_errors.mli +++ b/src/lib_shell_services/validation_errors.mli @@ -34,7 +34,7 @@ type error += Oversized_operation of {size : int; max : int} type error += | Future_block_header of { - block : Block_hash.t; + block : Tezos_crypto.Block_hash.t; block_time : Time.Protocol.t; time : Time.System.t; } @@ -43,19 +43,21 @@ type error += Cannot_serialize_operation_metadata (************************* State errors ***********************************) -type error += Unknown_chain of Chain_id.t +type error += Unknown_chain of Tezos_crypto.Chain_id.t type error += Bad_data_dir -type error += Block_not_invalid of Block_hash.t +type error += Block_not_invalid of Tezos_crypto.Block_hash.t (* Block database error *) -type error += Inconsistent_hash of Context_hash.t * Context_hash.t +type error += + | Inconsistent_hash of + Tezos_crypto.Context_hash.t * Tezos_crypto.Context_hash.t -type error += Missing_block_metadata_hash of Block_hash.t +type error += Missing_block_metadata_hash of Tezos_crypto.Block_hash.t -type error += Missing_operation_metadata_hashes of Block_hash.t +type error += Missing_operation_metadata_hashes of Tezos_crypto.Block_hash.t (******************* Bootstrap pipeline errors ****************************) @@ -68,9 +70,12 @@ type error += Too_short_locator of P2p_peer.Id.t * Block_locator.t type protocol_error = Compilation_failed | Dynlinking_failed type error += - | Invalid_protocol of {hash : Protocol_hash.t; error : protocol_error} + | Invalid_protocol of { + hash : Tezos_crypto.Protocol_hash.t; + error : protocol_error; + } -type error += Cannot_load_protocol of Protocol_hash.t +type error += Cannot_load_protocol of Tezos_crypto.Protocol_hash.t (********************* Peer validator errors ******************************) @@ -78,6 +83,7 @@ type error += Unknown_ancestor | Known_invalid (************************ Validator errors ********************************) -type error += Inactive_chain of Chain_id.t +type error += Inactive_chain of Tezos_crypto.Chain_id.t -type error += Checkpoint_error of Block_hash.t * P2p_peer.Id.t option +type error += + | Checkpoint_error of Tezos_crypto.Block_hash.t * P2p_peer.Id.t option diff --git a/src/lib_shell_services/validation_events.ml b/src/lib_shell_services/validation_events.ml index 338aa7533694..fb9e03d5ecfb 100644 --- a/src/lib_shell_services/validation_events.ml +++ b/src/lib_shell_services/validation_events.ml @@ -33,8 +33,8 @@ let new_protocol_initialisation = ~name:"new_protocol_initialisation" ~msg:"initializing protocol {proto_hash}..." ~level:Notice - ~pp1:Protocol_hash.pp_short - ("proto_hash", Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp_short + ("proto_hash", Tezos_crypto.Protocol_hash.encoding) let using_preapply_result = declare_1 @@ -42,5 +42,5 @@ let using_preapply_result = ~name:"using_preapply_result" ~msg:"using pre-application result for block {block_hash} application" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) diff --git a/src/lib_shell_services/worker_services.ml b/src/lib_shell_services/worker_services.ml index bf47950fbcba..3245dfba8354 100644 --- a/src/lib_shell_services/worker_services.ml +++ b/src/lib_shell_services/worker_services.ml @@ -34,7 +34,7 @@ module Prevalidators = struct ~output: (list (obj4 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "status" (Worker_types.worker_status_encoding @@ -137,7 +137,7 @@ module Chain_validators = struct ~output: (list (obj4 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "status" (Worker_types.worker_status_encoding diff --git a/src/lib_shell_services/worker_services.mli b/src/lib_shell_services/worker_services.mli index 03290b29b86a..4d753030145b 100644 --- a/src/lib_shell_services/worker_services.mli +++ b/src/lib_shell_services/worker_services.mli @@ -30,7 +30,7 @@ module Prevalidators : sig val list : #simple -> - (Chain_id.t + (Tezos_crypto.Chain_id.t * Worker_types.worker_status * Worker_types.worker_information * int) @@ -50,7 +50,7 @@ module Prevalidators : sig unit, unit, unit, - (Chain_id.t + (Tezos_crypto.Chain_id.t * Worker_types.worker_status * Worker_types.worker_information * int) @@ -135,7 +135,7 @@ module Chain_validators : sig val list : #simple -> - (Chain_id.t + (Tezos_crypto.Chain_id.t * Worker_types.worker_status * Worker_types.worker_information * int) @@ -158,7 +158,7 @@ module Chain_validators : sig unit, unit, unit, - (Chain_id.t + (Tezos_crypto.Chain_id.t * Worker_types.worker_status * Worker_types.worker_information * int) -- GitLab From 0168c1a20bee4852186464c96d95bc6452f664d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 26 Oct 2022 09:23:53 +0200 Subject: [PATCH 09/30] Proto-meta-bins: unopen Crypto --- .../bin/main_embedded_packer.ml | 2 +- src/lib_protocol_compiler/compiler.ml | 15 ++++----- src/lib_protocol_compiler/packer.ml | 2 +- src/lib_protocol_compiler/packer.mli | 3 +- .../registerer/tezos_protocol_registerer.ml | 4 +-- .../registerer/tezos_protocol_registerer.mli | 4 +-- .../registered_protocol.ml | 31 ++++++++++--------- .../registered_protocol.mli | 30 +++++++++--------- src/lib_protocol_updater/updater.ml | 12 ++++--- src/lib_protocol_updater/updater.mli | 2 +- src/lib_protocol_updater/updater_events.ml | 2 +- 11 files changed, 57 insertions(+), 50 deletions(-) diff --git a/src/lib_protocol_compiler/bin/main_embedded_packer.ml b/src/lib_protocol_compiler/bin/main_embedded_packer.ml index 6d80cfb27bec..bdc40c1cb8fc 100644 --- a/src/lib_protocol_compiler/bin/main_embedded_packer.ml +++ b/src/lib_protocol_compiler/bin/main_embedded_packer.ml @@ -78,7 +78,7 @@ module Source = struct let sources = Tezos_base.Protocol.%a end @.|} - (Protocol_hash.to_b58check hash) + (Tezos_crypto.Protocol_hash.to_b58check hash) Protocol.pp_ocaml sources diff --git a/src/lib_protocol_compiler/compiler.ml b/src/lib_protocol_compiler/compiler.ml index d606156c0942..515bb2052f89 100644 --- a/src/lib_protocol_compiler/compiler.ml +++ b/src/lib_protocol_compiler/compiler.ml @@ -206,21 +206,22 @@ let main {compile_ml; pack_objects; link_shared} = in let computed_hash = Protocol.hash protocol in if !hash_only then ( - Format.printf "%a@." Protocol_hash.pp computed_hash ; + Format.printf "%a@." Tezos_crypto.Protocol_hash.pp computed_hash ; exit 0) ; let hash = match stored_hash_opt with | None -> computed_hash | Some stored_hash when !check_protocol_hash - && not (Protocol_hash.equal computed_hash stored_hash) -> + && not (Tezos_crypto.Protocol_hash.equal computed_hash stored_hash) + -> Format.eprintf "Inconsistent hash for protocol in TEZOS_PROTOCOL.@\n\ Computed hash: %a@\n\ Stored in TEZOS_PROTOCOL: %a@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp computed_hash - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp stored_hash ; exit 2 | Some hash -> hash @@ -236,7 +237,7 @@ let main {compile_ml; pack_objects; link_shared} = let output = match !output_file with | Some output -> output - | None -> Format.asprintf "proto_%a" Protocol_hash.pp hash + | None -> Format.asprintf "proto_%a" Tezos_crypto.Protocol_hash.pp hash in Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 build_dir) ; Lwt_main.run (Lwt_utils_unix.create_dir ~perm:0o755 (Filename.dirname output)) ; @@ -280,7 +281,7 @@ let main {compile_ml; pack_objects; link_shared} = "module Name = struct let name = %S end\n\ \ let () = Tezos_protocol_registerer.register Name.name (%s (module \ %s.Make))" - (Protocol_hash.to_b58check hash) + (Tezos_crypto.Protocol_hash.to_b58check hash) (Protocol.module_name_of_env_version protocol.expected_env) functor_unit) ; let register_object = compile_ml ~for_pack register_file in @@ -303,4 +304,4 @@ let main {compile_ml; pack_objects; link_shared} = Format.printf "let src_digest = %S ;;\n" (Digest.to_hex dsrc) ; Format.printf "let impl_digest = %S ;;\n" (Digest.to_hex dimpl) ; Format.printf "let intf_digest = %S ;;\n" (Digest.to_hex dintf)) ; - Format.printf "Success: %a.@." Protocol_hash.pp hash + Format.printf "Success: %a.@." Tezos_crypto.Protocol_hash.pp hash diff --git a/src/lib_protocol_compiler/packer.ml b/src/lib_protocol_compiler/packer.ml index 552dbec1f7b8..2fe279833e46 100644 --- a/src/lib_protocol_compiler/packer.ml +++ b/src/lib_protocol_compiler/packer.ml @@ -120,7 +120,7 @@ let dump oc version hash files = Printf.fprintf oc "let hash = Protocol_hash.of_b58check_exn %S;;\n" - (Protocol_hash.to_b58check hash) ; + (Tezos_crypto.Protocol_hash.to_b58check hash) ; for i = 0 to Array.length files - 1 do include_ml oc files.(i) done ; diff --git a/src/lib_protocol_compiler/packer.mli b/src/lib_protocol_compiler/packer.mli index 421565c695a2..83818e77f3ca 100644 --- a/src/lib_protocol_compiler/packer.mli +++ b/src/lib_protocol_compiler/packer.mli @@ -23,4 +23,5 @@ (* *) (*****************************************************************************) -val dump : out_channel -> string -> Protocol_hash.t -> string array -> unit +val dump : + out_channel -> string -> Tezos_crypto.Protocol_hash.t -> string array -> unit diff --git a/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.ml b/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.ml index 0f036e4608c2..fb7ba81216d0 100644 --- a/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.ml +++ b/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.ml @@ -59,7 +59,7 @@ module type PROTOCOL_V8 = functor (Env : Tezos_protocol_environment_sigs.V8.T) -> Env.Updater.PROTOCOL -module VersionTable = Protocol_hash.Table +module VersionTable = Tezos_crypto.Protocol_hash.Table type proto_env = | V0 of (module PROTOCOL_V0) @@ -75,7 +75,7 @@ type proto_env = let versions : proto_env VersionTable.t = VersionTable.create 20 let register hash proto = - let hash = Protocol_hash.of_b58check_exn hash in + let hash = Tezos_crypto.Protocol_hash.of_b58check_exn hash in VersionTable.add versions hash proto let mem hash = VersionTable.mem versions hash diff --git a/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.mli b/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.mli index 739936b9415c..71b169772cbc 100644 --- a/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.mli +++ b/src/lib_protocol_compiler/registerer/tezos_protocol_registerer.mli @@ -72,6 +72,6 @@ type proto_env = val register : string -> proto_env -> unit -val mem : Protocol_hash.t -> bool +val mem : Tezos_crypto.Protocol_hash.t -> bool -val get : Protocol_hash.t -> proto_env option +val get : Tezos_crypto.Protocol_hash.t -> proto_env option diff --git a/src/lib_protocol_updater/registered_protocol.ml b/src/lib_protocol_updater/registered_protocol.ml index 2ccbf31f2ff0..55a376e91b0d 100644 --- a/src/lib_protocol_updater/registered_protocol.ml +++ b/src/lib_protocol_updater/registered_protocol.ml @@ -24,7 +24,7 @@ (*****************************************************************************) module type T = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t include Tezos_protocol_environment.PROTOCOL @@ -40,7 +40,7 @@ let build hash = | Some (V0 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V0.Make (Name) () in Some @@ -60,7 +60,7 @@ let build hash = | Some (V1 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V1.Make (Name) () in Some @@ -80,7 +80,7 @@ let build hash = | Some (V2 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V2.Make (Name) () in Some @@ -100,7 +100,7 @@ let build hash = | Some (V3 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V3.Make (Name) () in Some @@ -120,7 +120,7 @@ let build hash = | Some (V4 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V4.Make (Name) () in Some @@ -140,7 +140,7 @@ let build hash = | Some (V5 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V5.Make (Name) () in Some @@ -160,7 +160,7 @@ let build hash = | Some (V6 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V6.Make (Name) () in Some @@ -180,7 +180,7 @@ let build hash = | Some (V7 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V7.Make (Name) () in Some @@ -200,7 +200,7 @@ let build hash = | Some (V8 protocol) -> let (module F) = protocol in let module Name = struct - let name = Protocol_hash.to_b58check hash + let name = Tezos_crypto.Protocol_hash.to_b58check hash end in let module Env = Tezos_protocol_environment.V8.Make (Name) () in Some @@ -218,7 +218,7 @@ let build hash = let complete_b58prefix = Env.Context.complete end : T) -module VersionTable = Protocol_hash.Table +module VersionTable = Tezos_crypto.Protocol_hash.Table let versions : (module T) VersionTable.t = VersionTable.create 20 @@ -245,7 +245,7 @@ let get hash = Some proto | None -> None) -type error += Unregistered_protocol of Protocol_hash.t +type error += Unregistered_protocol of Tezos_crypto.Protocol_hash.t let () = register_error_kind @@ -257,9 +257,10 @@ let () = Format.fprintf fmt "@[No registered protocol with hash:@ %a@]" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp hash) - Data_encoding.(obj1 (req "protocol_hash" Protocol_hash.encoding)) + Data_encoding.( + obj1 (req "protocol_hash" Tezos_crypto.Protocol_hash.encoding)) (function Unregistered_protocol hash -> Some hash | _ -> None) (fun hash -> Unregistered_protocol hash) @@ -276,7 +277,7 @@ let seq_embedded () = VersionTable.to_seq_keys sources let get_embedded_sources hash = VersionTable.find sources hash module type Source_sig = sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end diff --git a/src/lib_protocol_updater/registered_protocol.mli b/src/lib_protocol_updater/registered_protocol.mli index 06f3e71fccb2..3c1a0b40195e 100644 --- a/src/lib_protocol_updater/registered_protocol.mli +++ b/src/lib_protocol_updater/registered_protocol.mli @@ -24,7 +24,7 @@ (*****************************************************************************) module type T = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t include Tezos_protocol_environment.PROTOCOL @@ -34,26 +34,26 @@ end type t = (module T) -val mem : Protocol_hash.t -> bool +val mem : Tezos_crypto.Protocol_hash.t -> bool val seq : unit -> t Seq.t (** [get hash] searches the protocol of the given hash in the registered protocols. This function also activates the logging facilty of the returned protocol. *) -val get : Protocol_hash.t -> t option +val get : Tezos_crypto.Protocol_hash.t -> t option (** Same as [get] but with the result return type. *) -val get_result : Protocol_hash.t -> t tzresult Lwt.t +val get_result : Tezos_crypto.Protocol_hash.t -> t tzresult Lwt.t -val seq_embedded : unit -> Protocol_hash.t Seq.t +val seq_embedded : unit -> Tezos_crypto.Protocol_hash.t Seq.t -val get_embedded_sources : Protocol_hash.t -> Protocol.t option +val get_embedded_sources : Tezos_crypto.Protocol_hash.t -> Protocol.t option module Register_embedded_V0 (Env : Tezos_protocol_environment.V0.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -66,7 +66,7 @@ module Register_embedded_V0 module Register_embedded_V1 (Env : Tezos_protocol_environment.V1.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -79,7 +79,7 @@ module Register_embedded_V1 module Register_embedded_V2 (Env : Tezos_protocol_environment.V2.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -93,7 +93,7 @@ module Register_embedded_V2 module Register_embedded_V3 (Env : Tezos_protocol_environment.V3.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -107,7 +107,7 @@ module Register_embedded_V3 module Register_embedded_V4 (Env : Tezos_protocol_environment.V4.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -121,7 +121,7 @@ module Register_embedded_V4 module Register_embedded_V5 (Env : Tezos_protocol_environment.V5.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -135,7 +135,7 @@ module Register_embedded_V5 module Register_embedded_V6 (Env : Tezos_protocol_environment.V6.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -149,7 +149,7 @@ module Register_embedded_V6 module Register_embedded_V7 (Env : Tezos_protocol_environment.V7.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : @@ -163,7 +163,7 @@ module Register_embedded_V7 module Register_embedded_V8 (Env : Tezos_protocol_environment.V8.T) (Proto : Env.Updater.PROTOCOL) (Source : sig - val hash : Protocol_hash.t option + val hash : Tezos_crypto.Protocol_hash.t option val sources : Protocol.t end) : diff --git a/src/lib_protocol_updater/updater.ml b/src/lib_protocol_updater/updater.ml index a5df1be3ff53..0251b8f254c0 100644 --- a/src/lib_protocol_updater/updater.ml +++ b/src/lib_protocol_updater/updater.ml @@ -45,12 +45,16 @@ let compiler_name = "octez-protocol-compiler" let do_compile hash p = let open Lwt_syntax in let* datadir = get_datadir () in - let source_dir = datadir // Protocol_hash.to_short_b58check hash // "src" in - let log_file = datadir // Protocol_hash.to_short_b58check hash // "LOG" in + let source_dir = + datadir // Tezos_crypto.Protocol_hash.to_short_b58check hash // "src" + in + let log_file = + datadir // Tezos_crypto.Protocol_hash.to_short_b58check hash // "LOG" + in let plugin_file = datadir - // Protocol_hash.to_short_b58check hash - // Format.asprintf "protocol_%a" Protocol_hash.pp hash + // Tezos_crypto.Protocol_hash.to_short_b58check hash + // Format.asprintf "protocol_%a" Tezos_crypto.Protocol_hash.pp hash in let* r = Tezos_base_unix.Protocol_files.write_dir source_dir ~hash p in match r with diff --git a/src/lib_protocol_updater/updater.mli b/src/lib_protocol_updater/updater.mli index d0cb5d5f5d4d..73e8998bd594 100644 --- a/src/lib_protocol_updater/updater.mli +++ b/src/lib_protocol_updater/updater.mli @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -val compile : Protocol_hash.t -> Protocol.t -> bool Lwt.t +val compile : Tezos_crypto.Protocol_hash.t -> Protocol.t -> bool Lwt.t val init : string -> unit diff --git a/src/lib_protocol_updater/updater_events.ml b/src/lib_protocol_updater/updater_events.ml index 2db933671b27..5849472ab694 100644 --- a/src/lib_protocol_updater/updater_events.ml +++ b/src/lib_protocol_updater/updater_events.ml @@ -87,4 +87,4 @@ let internal_error = ~level ~name:"internal_error" ~msg:"internal error while compiling {protocol}" - ("protocol", Protocol_hash.encoding) + ("protocol", Tezos_crypto.Protocol_hash.encoding) -- GitLab From e95b4320ce91156fa4a57c1a2c48b35815610a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:11:54 +0200 Subject: [PATCH 10/30] Validation: unopen Crypto --- src/lib_validation/block_validation.ml | 92 +++++++++++++--------- src/lib_validation/block_validation.mli | 56 +++++++------ src/lib_validation/external_validation.ml | 92 ++++++++++++---------- src/lib_validation/external_validation.mli | 34 ++++---- 4 files changed, 156 insertions(+), 118 deletions(-) diff --git a/src/lib_validation/block_validation.ml b/src/lib_validation/block_validation.ml index 2e35c463c926..b458e20815cf 100644 --- a/src/lib_validation/block_validation.ml +++ b/src/lib_validation/block_validation.ml @@ -37,12 +37,12 @@ module Event = struct ~name:"block_validation_inconsistent_cache" ~msg:"applied block {hash} with an inconsistent cache: reloading cache" ~level:Warning - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) end type validation_store = { - context_hash : Context_hash.t; + context_hash : Tezos_crypto.Context_hash.t; timestamp : Time.Protocol.t; message : string option; max_operations_ttl : int; @@ -77,7 +77,7 @@ let validation_store_encoding = last_allowed_fork_level; }) (obj5 - (req "context_hash" Context_hash.encoding) + (req "context_hash" Tezos_crypto.Context_hash.encoding) (req "timestamp" Time.Protocol.encoding) (req "message" (option string)) (req "max_operations_ttl" int31) @@ -114,11 +114,12 @@ let operation_metadata_encoding = type ops_metadata = | No_metadata_hash of operation_metadata list list - | Metadata_hash of (operation_metadata * Operation_metadata_hash.t) list list + | Metadata_hash of + (operation_metadata * Tezos_crypto.Operation_metadata_hash.t) list list type result = { validation_store : validation_store; - block_metadata : Bytes.t * Block_metadata_hash.t option; + block_metadata : Bytes.t * Tezos_crypto.Block_metadata_hash.t option; ops_metadata : ops_metadata; } @@ -149,7 +150,7 @@ let update_testchain_status ctxt ~predecessor_hash timestamp = let genesis = Context_ops.compute_testchain_genesis ctxt predecessor_hash in - let chain_id = Chain_id.of_block_hash genesis in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis in (* legacy semantics *) Context_ops.add_test_chain ctxt @@ -198,7 +199,7 @@ let result_encoding = (list (tup2 operation_metadata_encoding - Operation_metadata_hash.encoding))) + Tezos_crypto.Operation_metadata_hash.encoding))) (function | Metadata_hash ops_metadata -> Some ops_metadata | _ -> None) (fun ops_metadata -> Metadata_hash ops_metadata); @@ -211,7 +212,9 @@ let result_encoding = {validation_store; block_metadata; ops_metadata}) (obj3 (req "validation_store" validation_store_encoding) - (req "block_metadata" (tup2 bytes (option Block_metadata_hash.encoding))) + (req + "block_metadata" + (tup2 bytes (option Tezos_crypto.Block_metadata_hash.encoding))) (req "ops_metadata" ops_metadata_encoding)) let preapply_result_encoding : @@ -266,7 +269,7 @@ let may_patch_protocol ~user_activated_upgrades module Make (Proto : Registered_protocol.T) = struct type 'operation_data preapplied_operation = { - hash : Operation_hash.t; + hash : Tezos_crypto.Operation_hash.t; raw : Operation.t; protocol_data : 'operation_data; } @@ -276,8 +279,8 @@ module Make (Proto : Registered_protocol.T) = struct application_state : Proto.application_state; applied : (Proto.operation_data preapplied_operation * Proto.operation_receipt) list; - live_blocks : Block_hash.Set.t; - live_operations : Operation_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; } type preapply_result = @@ -437,7 +440,7 @@ module Make (Proto : Registered_protocol.T) = struct in let metadata_hash_opt = if should_include_metadata_hashes then - Some (Block_metadata_hash.hash_bytes [metadata]) + Some (Tezos_crypto.Block_metadata_hash.hash_bytes [metadata]) else None in (metadata, metadata_hash_opt) @@ -476,7 +479,7 @@ module Make (Proto : Registered_protocol.T) = struct (List.map (List.map (fun (bytes, metadata) -> let metadata_hash = - Operation_metadata_hash.hash_bytes [bytes] + Tezos_crypto.Operation_metadata_hash.hash_bytes [bytes] in (metadata, metadata_hash))) metadata_list_list)) @@ -559,7 +562,7 @@ module Make (Proto : Registered_protocol.T) = struct (block_header : Proto.block_header) block_hash (validation_result : Tezos_protocol_environment.validation_result) = let open Lwt_result_syntax in - if Protocol_hash.equal new_protocol Proto.hash then + if Tezos_crypto.Protocol_hash.equal new_protocol Proto.hash then return (validation_result, Proto.environment_version) else match Registered_protocol.get new_protocol with @@ -591,7 +594,7 @@ module Make (Proto : Registered_protocol.T) = struct let block_hash = Block_header.hash block_header in match cached_result with | Some (({result; _} as cached_result), context) - when Context_hash.equal + when Tezos_crypto.Context_hash.equal result.validation_store.context_hash block_header.shell.context && Time.Protocol.equal @@ -612,7 +615,9 @@ module Make (Proto : Registered_protocol.T) = struct context in assert ( - Context_hash.equal context_hash result.validation_store.context_hash) ; + Tezos_crypto.Context_hash.equal + context_hash + result.validation_store.context_hash) ; return cached_result | Some _ | None -> let* () = @@ -654,7 +659,7 @@ module Make (Proto : Registered_protocol.T) = struct let context = validation_result.context in let*! new_protocol = Context_ops.get_protocol context in let expected_proto_level = - if Protocol_hash.equal new_protocol Proto.hash then + if Tezos_crypto.Protocol_hash.equal new_protocol Proto.hash then predecessor_block_header.shell.proto_level else (predecessor_block_header.shell.proto_level + 1) mod 256 in @@ -718,7 +723,9 @@ module Make (Proto : Registered_protocol.T) = struct in let* () = fail_unless - (Context_hash.equal context_hash block_header.shell.context) + (Tezos_crypto.Context_hash.equal + context_hash + block_header.shell.context) (Validation_errors.Inconsistent_hash (context_hash, block_header.shell.context)) in @@ -781,7 +788,8 @@ module Make (Proto : Registered_protocol.T) = struct let preapply_operation pv op = let open Lwt_syntax in - if Operation_hash.Set.mem op.hash pv.live_operations then return Outdated + if Tezos_crypto.Operation_hash.Set.mem op.hash pv.live_operations then + return Outdated else let+ r = protect (fun () -> @@ -806,7 +814,7 @@ module Make (Proto : Registered_protocol.T) = struct applied = (op, receipt) :: pv.applied; live_blocks = pv.live_blocks; live_operations = - Operation_hash.Set.add op.hash pv.live_operations; + Tezos_crypto.Operation_hash.Set.add op.hash pv.live_operations; } in match @@ -929,7 +937,7 @@ module Make (Proto : Registered_protocol.T) = struct Lwt.return ({preapp with applied}, t, receipt :: receipts) | Branch_delayed errors -> let branch_delayed = - Operation_hash.Map.add + Tezos_crypto.Operation_hash.Map.add op.hash (op.raw, errors) preapp.branch_delayed @@ -937,7 +945,7 @@ module Make (Proto : Registered_protocol.T) = struct Lwt.return ({preapp with branch_delayed}, t, receipts) | Branch_refused errors -> let branch_refused = - Operation_hash.Map.add + Tezos_crypto.Operation_hash.Map.add op.hash (op.raw, errors) preapp.branch_refused @@ -945,7 +953,10 @@ module Make (Proto : Registered_protocol.T) = struct Lwt.return ({preapp with branch_refused}, t, receipts) | Refused errors -> let refused = - Operation_hash.Map.add op.hash (op.raw, errors) preapp.refused + Tezos_crypto.Operation_hash.Map.add + op.hash + (op.raw, errors) + preapp.refused in Lwt.return ({preapp with refused}, t, receipts) | Outdated -> Lwt.return (preapp, t, receipts) @@ -996,10 +1007,10 @@ module Make (Proto : Registered_protocol.T) = struct let applied_ops_metadata = List.rev receipts_rev in let preapply_state = validation_state in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.rev_map (fun r -> - Operation_list_hash.compute + Tezos_crypto.Operation_list_hash.compute (List.map fst r.Preapply_result.applied)) validation_result_list_rev) in @@ -1012,7 +1023,7 @@ module Make (Proto : Registered_protocol.T) = struct timestamp; validation_passes; operations_hash; - context = Context_hash.zero (* place holder *); + context = Tezos_crypto.Context_hash.zero (* place holder *); fitness = []; } in @@ -1033,7 +1044,7 @@ module Make (Proto : Registered_protocol.T) = struct Tezos_protocol_environment.Context.get_protocol validation_result.context in let proto_level = - if Protocol_hash.equal protocol Proto.hash then + if Tezos_crypto.Protocol_hash.equal protocol Proto.hash then predecessor_shell_header.proto_level else (predecessor_shell_header.proto_level + 1) mod 256 in @@ -1041,7 +1052,7 @@ module Make (Proto : Registered_protocol.T) = struct {shell_header with proto_level; fitness = validation_result.fitness} in let* validation_result, cache, new_protocol_env_version = - if Protocol_hash.equal protocol Proto.hash then + if Tezos_crypto.Protocol_hash.equal protocol Proto.hash then let (Tezos_protocol_environment.Context.Context {cache; _}) = validation_result.context in @@ -1055,7 +1066,7 @@ module Make (Proto : Registered_protocol.T) = struct | Some (module NewProto) -> let*? () = check_proto_environment_version_increasing - Block_hash.zero + Tezos_crypto.Block_hash.zero Proto.environment_version NewProto.environment_version in @@ -1172,9 +1183,9 @@ let assert_no_duplicate_operations block_hash live_operations operations = (List.fold_left (List.fold_left (fun live_operations op -> let oph = Operation.hash op in - if Operation_hash.Set.mem oph live_operations then + if Tezos_crypto.Operation_hash.Set.mem oph live_operations then raise (Duplicate (Replayed_operation oph)) - else Operation_hash.Set.add oph live_operations)) + else Tezos_crypto.Operation_hash.Set.add oph live_operations)) live_operations operations) with Duplicate err -> tzfail (invalid_block block_hash err) @@ -1186,7 +1197,11 @@ let assert_operation_liveness block_hash live_blocks operations = return (List.iter (List.iter (fun op -> - if not (Block_hash.Set.mem op.Operation.shell.branch live_blocks) + if + not + (Tezos_crypto.Block_hash.Set.mem + op.Operation.shell.branch + live_blocks) then let error = Outdated_operation @@ -1203,18 +1218,19 @@ let assert_operation_liveness block_hash live_blocks operations = once by [Block_validator_process] *) let check_liveness ~live_blocks ~live_operations block_hash operations = let open Result_syntax in - let* (_ : Operation_hash.Set.t) = + let* (_ : Tezos_crypto.Operation_hash.Set.t) = assert_no_duplicate_operations block_hash live_operations operations in assert_operation_liveness block_hash live_blocks operations type apply_environment = { max_operations_ttl : int; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; predecessor_block_header : Block_header.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; + predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + predecessor_ops_metadata_hash : + Tezos_crypto.Operation_metadata_list_list_hash.t option; user_activated_upgrades : User_activated.upgrades; user_activated_protocol_overrides : User_activated.protocol_overrides; operation_metadata_size_limit : Shell_limits.operation_metadata_size_limit; @@ -1369,7 +1385,7 @@ let preapply ~chain_id ~user_activated_upgrades (* This should not happen: it should be handled in the validator. *) failwith "Prevalidation: missing protocol '%a' for the current block." - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol | Some protocol -> return protocol in diff --git a/src/lib_validation/block_validation.mli b/src/lib_validation/block_validation.mli index 13681d7a4e43..03ba74ddb0e0 100644 --- a/src/lib_validation/block_validation.mli +++ b/src/lib_validation/block_validation.mli @@ -30,7 +30,7 @@ the protocol. *) type validation_store = { - context_hash : Context_hash.t; + context_hash : Tezos_crypto.Context_hash.t; timestamp : Time.Protocol.t; message : string option; max_operations_ttl : int; @@ -47,7 +47,7 @@ val may_patch_protocol : val update_testchain_status : Tezos_protocol_environment.Context.t -> - predecessor_hash:Block_hash.t -> + predecessor_hash:Tezos_crypto.Block_hash.t -> Time.Protocol.t -> Tezos_protocol_environment.Context.t Lwt.t @@ -56,11 +56,14 @@ val update_testchain_status : increases from [before] to [after]. Otherwise, an [Invalid_protocol_environment_transition] error is returned. *) val check_proto_environment_version_increasing : - Block_hash.t -> Protocol.env_version -> Protocol.env_version -> unit tzresult + Tezos_crypto.Block_hash.t -> + Protocol.env_version -> + Protocol.env_version -> + unit tzresult (** [init_test_chain] must only be called on a forking block. *) val init_test_chain : - Chain_id.t -> + Tezos_crypto.Chain_id.t -> Tezos_protocol_environment.Context.t -> Block_header.t -> Block_header.t tzresult Lwt.t @@ -71,11 +74,12 @@ val operation_metadata_encoding : operation_metadata Data_encoding.t type ops_metadata = | No_metadata_hash of operation_metadata list list - | Metadata_hash of (operation_metadata * Operation_metadata_hash.t) list list + | Metadata_hash of + (operation_metadata * Tezos_crypto.Operation_metadata_hash.t) list list type result = { validation_store : validation_store; - block_metadata : bytes * Block_metadata_hash.t option; + block_metadata : bytes * Tezos_crypto.Block_metadata_hash.t option; ops_metadata : ops_metadata; } @@ -92,22 +96,23 @@ val preapply_result_encoding : (** [check_liveness live_blocks live_operations hash ops] checks there is no duplicate operation and that is not out-of-date *) val check_liveness : - live_blocks:Block_hash.Set.t -> - live_operations:Operation_hash.Set.t -> - Block_hash.t -> + live_blocks:Tezos_crypto.Block_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> + Tezos_crypto.Block_hash.t -> Operation.t list list -> unit tzresult type apply_environment = { max_operations_ttl : int; (** time to live of an operation *) - chain_id : Chain_id.t; (** chain_id of the current branch *) + chain_id : Tezos_crypto.Chain_id.t; (** chain_id of the current branch *) predecessor_block_header : Block_header.t; (** header of the predecessor block being validated *) predecessor_context : Tezos_protocol_environment.Context.t; (** context associated to the predecessor block *) - predecessor_block_metadata_hash : Block_metadata_hash.t option; + predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; (** hash of block header metadata of the predecessor block *) - predecessor_ops_metadata_hash : Operation_metadata_list_list_hash.t option; + predecessor_ops_metadata_hash : + Tezos_crypto.Operation_metadata_list_list_hash.t option; (** hash of operation metadata of the predecessor block *) user_activated_upgrades : User_activated.upgrades; (** user activated upgrades *) @@ -146,9 +151,9 @@ val apply : 2. [P.validate_operation] 3. [P.finalize_validation] *) val precheck : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_block_header:Block_header.t -> - predecessor_block_hash:Block_hash.t -> + predecessor_block_hash:Tezos_crypto.Block_hash.t -> predecessor_context:Tezos_protocol_environment.Context.t -> cache:Tezos_protocol_environment.Context.source_of_cache -> Block_header.t -> @@ -156,20 +161,21 @@ val precheck : unit tzresult Lwt.t val preapply : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> user_activated_upgrades:Tezos_base.User_activated.upgrades -> user_activated_protocol_overrides:Tezos_base.User_activated.protocol_overrides -> operation_metadata_size_limit:Shell_limits.operation_metadata_size_limit -> timestamp:Time.Protocol.t -> protocol_data:bytes -> - live_blocks:Block_hash.Set.t -> - live_operations:Operation_hash.Set.t -> + live_blocks:Tezos_crypto.Block_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> predecessor_context:Tezos_protocol_environment.Context.t -> predecessor_shell_header:Block_header.shell_header -> - predecessor_hash:Block_hash.t -> + predecessor_hash:Tezos_crypto.Block_hash.t -> predecessor_max_operations_ttl:int -> - predecessor_block_metadata_hash:Block_metadata_hash.t option -> - predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> + predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> + predecessor_ops_metadata_hash: + Tezos_crypto.Operation_metadata_list_list_hash.t option -> Operation.t list list -> ((Block_header.shell_header * error Preapply_result.t list) * (apply_result * Tezos_protocol_environment.Context.t)) @@ -179,12 +185,14 @@ val preapply : (** Hypothesis: we assume that the given block has already been validated -- E.g. by calling [precheck]. *) val recompute_metadata : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> predecessor_block_header:Block_header.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 -> + predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> + predecessor_ops_metadata_hash: + Tezos_crypto.Operation_metadata_list_list_hash.t option -> block_header:Block_header.t -> operations:Operation.t trace trace -> cache:Tezos_protocol_environment.Context.source_of_cache -> - ((bytes * Block_metadata_hash.t option) * ops_metadata) tzresult Lwt.t + ((bytes * Tezos_crypto.Block_metadata_hash.t option) * ops_metadata) tzresult + Lwt.t diff --git a/src/lib_validation/external_validation.ml b/src/lib_validation/external_validation.ml index c988ea53c5cd..c12924d48b15 100644 --- a/src/lib_validation/external_validation.ml +++ b/src/lib_validation/external_validation.ml @@ -37,45 +37,47 @@ type parameters = { type request = | Init | Validate of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; block_header : Block_header.t; predecessor_block_header : Block_header.t; - predecessor_block_metadata_hash : Block_metadata_hash.t option; + predecessor_block_metadata_hash : + Tezos_crypto.Block_metadata_hash.t option; predecessor_ops_metadata_hash : - Operation_metadata_list_list_hash.t option; + Tezos_crypto.Operation_metadata_list_list_hash.t option; operations : Operation.t list list; max_operations_ttl : int; simulate : bool; } | Preapply of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; timestamp : Time.Protocol.t; protocol_data : bytes; - live_blocks : Block_hash.Set.t; - live_operations : Operation_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; predecessor_shell_header : Block_header.shell_header; - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; predecessor_max_operations_ttl : int; - predecessor_block_metadata_hash : Block_metadata_hash.t option; + predecessor_block_metadata_hash : + Tezos_crypto.Block_metadata_hash.t option; predecessor_ops_metadata_hash : - Operation_metadata_list_list_hash.t option; + Tezos_crypto.Operation_metadata_list_list_hash.t option; operations : Operation.t list list; } | Precheck of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; predecessor_block_header : Block_header.t; - predecessor_block_hash : Block_hash.t; + predecessor_block_hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.t list list; - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; } - | Commit_genesis of {chain_id : Chain_id.t} + | Commit_genesis of {chain_id : Tezos_crypto.Chain_id.t} | Fork_test_chain of { - chain_id : Chain_id.t; - context_hash : Context_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + context_hash : Tezos_crypto.Context_hash.t; forked_header : Block_header.t; } - | Context_garbage_collection of {context_hash : Context_hash.t} + | Context_garbage_collection of {context_hash : Tezos_crypto.Context_hash.t} | Terminate | Reconfigure_event_logging of Tezos_base_unix.Internal_event_unix.Configuration.t @@ -86,38 +88,42 @@ let request_pp ppf = function Format.fprintf ppf "block validation %a for chain %a" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short (Block_header.hash block_header) - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id | Preapply {predecessor_hash; chain_id; _} -> Format.fprintf ppf "preapply block ontop of %a for chain %a" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short predecessor_hash - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id | Precheck {hash; _} -> - Format.fprintf ppf "precheck block %a" Block_hash.pp_short hash + Format.fprintf + ppf + "precheck block %a" + Tezos_crypto.Block_hash.pp_short + hash | Commit_genesis {chain_id} -> Format.fprintf ppf "commit genesis block for chain %a" - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id | Fork_test_chain {forked_header; _} -> Format.fprintf ppf "test chain fork on block %a" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short (Block_header.hash forked_header) | Terminate -> Format.fprintf ppf "terminate validation process" | Context_garbage_collection {context_hash} -> Format.fprintf ppf "garbage collecting context below %a" - Context_hash.pp + Tezos_crypto.Context_hash.pp context_hash | Reconfigure_event_logging _ -> Format.fprintf ppf "reconfigure event logging" @@ -178,11 +184,15 @@ let case_validate tag = tag ~title:"validate" (obj8 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "block_header" (dynamic_size Block_header.encoding)) (req "pred_header" (dynamic_size Block_header.encoding)) - (opt "pred_block_metadata_hash" Block_metadata_hash.encoding) - (opt "pred_ops_metadata_hash" Operation_metadata_list_list_hash.encoding) + (opt + "pred_block_metadata_hash" + Tezos_crypto.Block_metadata_hash.encoding) + (opt + "pred_ops_metadata_hash" + Tezos_crypto.Operation_metadata_list_list_hash.encoding) (req "max_operations_ttl" int31) (req "operations" (list (list (dynamic_size Operation.encoding)))) (req "simulate" bool)) @@ -235,18 +245,20 @@ let case_preapply tag = ~title:"preapply" (merge_objs (obj10 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "timestamp" Time.Protocol.encoding) (req "protocol_data" bytes) - (req "live_blocks" Block_hash.Set.encoding) - (req "live_operations" Operation_hash.Set.encoding) + (req "live_blocks" Tezos_crypto.Block_hash.Set.encoding) + (req "live_operations" Tezos_crypto.Operation_hash.Set.encoding) (req "predecessor_shell_header" Block_header.shell_header_encoding) - (req "predecessor_hash" Block_hash.encoding) + (req "predecessor_hash" Tezos_crypto.Block_hash.encoding) (req "predecessor_max_operations_ttl" int31) - (opt "predecessor_block_metadata_hash" Block_metadata_hash.encoding) + (opt + "predecessor_block_metadata_hash" + Tezos_crypto.Block_metadata_hash.encoding) (opt "predecessor_ops_metadata_hash" - Operation_metadata_list_list_hash.encoding)) + Tezos_crypto.Operation_metadata_list_list_hash.encoding)) (obj1 (req "operations" (list (list (dynamic_size Operation.encoding)))))) (function | Preapply @@ -308,11 +320,11 @@ let case_precheck tag = tag ~title:"precheck" (obj6 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "predecessor_block_header" (dynamic_size Block_header.encoding)) - (req "predecessor_block_hash" Block_hash.encoding) + (req "predecessor_block_hash" Tezos_crypto.Block_hash.encoding) (req "header" (dynamic_size Block_header.encoding)) - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "operations" (list (list (dynamic_size Operation.encoding))))) (function | Precheck @@ -353,7 +365,7 @@ let case_context_gc tag = case tag ~title:"context_gc" - (obj1 (req "context_hash" Context_hash.encoding)) + (obj1 (req "context_hash" Tezos_crypto.Context_hash.encoding)) (function | Context_garbage_collection {context_hash} -> Some context_hash | _ -> None) @@ -373,15 +385,15 @@ let request_encoding = case (Tag 2) ~title:"commit_genesis" - (obj1 (req "chain_id" Chain_id.encoding)) + (obj1 (req "chain_id" Tezos_crypto.Chain_id.encoding)) (function Commit_genesis {chain_id} -> Some chain_id | _ -> None) (fun chain_id -> Commit_genesis {chain_id}); case (Tag 3) ~title:"fork_test_chain" (obj3 - (req "chain_id" Chain_id.encoding) - (req "context_hash" Context_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "context_hash" Tezos_crypto.Context_hash.encoding) (req "forked_header" Block_header.encoding)) (function | Fork_test_chain {chain_id; context_hash; forked_header} -> diff --git a/src/lib_validation/external_validation.mli b/src/lib_validation/external_validation.mli index 7cd454befaa8..70c3f5ebc8ca 100644 --- a/src/lib_validation/external_validation.mli +++ b/src/lib_validation/external_validation.mli @@ -37,45 +37,47 @@ type parameters = { type request = | Init | Validate of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; block_header : Block_header.t; predecessor_block_header : Block_header.t; - predecessor_block_metadata_hash : Block_metadata_hash.t option; + predecessor_block_metadata_hash : + Tezos_crypto.Block_metadata_hash.t option; predecessor_ops_metadata_hash : - Operation_metadata_list_list_hash.t option; + Tezos_crypto.Operation_metadata_list_list_hash.t option; operations : Operation.t list list; max_operations_ttl : int; simulate : bool; } | Preapply of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; timestamp : Time.Protocol.t; protocol_data : bytes; - live_blocks : Block_hash.Set.t; - live_operations : Operation_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; predecessor_shell_header : Block_header.shell_header; - predecessor_hash : Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; predecessor_max_operations_ttl : int; - predecessor_block_metadata_hash : Block_metadata_hash.t option; + predecessor_block_metadata_hash : + Tezos_crypto.Block_metadata_hash.t option; predecessor_ops_metadata_hash : - Operation_metadata_list_list_hash.t option; + Tezos_crypto.Operation_metadata_list_list_hash.t option; operations : Operation.t list list; } | Precheck of { - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; predecessor_block_header : Block_header.t; - predecessor_block_hash : Block_hash.t; + predecessor_block_hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.t list list; - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; } - | Commit_genesis of {chain_id : Chain_id.t} + | Commit_genesis of {chain_id : Tezos_crypto.Chain_id.t} | Fork_test_chain of { - chain_id : Chain_id.t; - context_hash : Context_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + context_hash : Tezos_crypto.Context_hash.t; forked_header : Block_header.t; } - | Context_garbage_collection of {context_hash : Context_hash.t} + | Context_garbage_collection of {context_hash : Tezos_crypto.Context_hash.t} | Terminate | Reconfigure_event_logging of Tezos_base_unix.Internal_event_unix.Configuration.t -- GitLab From d4854f8134c30059bb669e074e52831d564ff55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:23:11 +0200 Subject: [PATCH 11/30] Store: unopen Crypto --- devtools/yes_wallet/test/dune | 1 - manifest/main.ml | 2 +- src/lib_store/mocked/block_store.ml | 4 +- src/lib_store/mocked/block_store.mli | 5 +- src/lib_store/mocked/protocol_store.ml | 8 +- src/lib_store/mocked/protocol_store.mli | 18 +- src/lib_store/mocked/store.ml | 165 ++++++++------ src/lib_store/shared/block_key.ml | 12 +- src/lib_store/shared/block_key.mli | 4 +- src/lib_store/shared/block_repr.ml | 32 +-- src/lib_store/shared/block_repr.mli | 29 +-- src/lib_store/shared/naming.ml | 10 +- src/lib_store/shared/naming.mli | 10 +- src/lib_store/shared/store_events.ml | 24 +-- src/lib_store/shared/store_types.ml | 31 +-- src/lib_store/shared/store_types.mli | 27 +-- src/lib_store/store.mli | 158 +++++++++----- src/lib_store/unix/block_repr_unix.ml | 15 +- src/lib_store/unix/block_repr_unix.mli | 4 +- src/lib_store/unix/block_store.ml | 35 +-- src/lib_store/unix/block_store.mli | 7 +- src/lib_store/unix/cemented_block_store.ml | 3 +- src/lib_store/unix/cemented_block_store.mli | 13 +- src/lib_store/unix/consistency.ml | 18 +- src/lib_store/unix/floating_block_index.ml | 24 ++- src/lib_store/unix/floating_block_index.mli | 10 +- src/lib_store/unix/floating_block_store.ml | 2 +- src/lib_store/unix/floating_block_store.mli | 33 +-- src/lib_store/unix/protocol_store.ml | 15 +- src/lib_store/unix/protocol_store.mli | 18 +- src/lib_store/unix/reconstruction.ml | 31 +-- src/lib_store/unix/reconstruction.mli | 5 +- src/lib_store/unix/snapshots.ml | 157 ++++++++------ src/lib_store/unix/snapshots.mli | 21 +- src/lib_store/unix/snapshots_events.ml | 4 +- src/lib_store/unix/store.ml | 203 +++++++++++------- src/lib_store/unix/store.mli | 164 ++++++++------ src/lib_store/unix/test/alpha_utils.ml | 78 ++++--- src/lib_store/unix/test/test_block_store.ml | 11 +- .../unix/test/test_cemented_store.ml | 4 +- src/lib_store/unix/test/test_consistency.ml | 4 +- src/lib_store/unix/test/test_locator.ml | 23 +- src/lib_store/unix/test/test_snapshots.ml | 6 +- src/lib_store/unix/test/test_store.ml | 37 ++-- src/lib_store/unix/test/test_testchain.ml | 10 +- src/lib_store/unix/test/test_utils.ml | 27 +-- 46 files changed, 910 insertions(+), 612 deletions(-) diff --git a/devtools/yes_wallet/test/dune b/devtools/yes_wallet/test/dune index b7c7161b8018..449e1e7df115 100644 --- a/devtools/yes_wallet/test/dune +++ b/devtools/yes_wallet/test/dune @@ -18,5 +18,4 @@ (flags (:standard) -open Tezos_error_monad.TzLwtreslib - -open Tezos_crypto -open Data_encoding)) diff --git a/manifest/main.ml b/manifest/main.ml index bc3b8919bcdd..d7800d37ac46 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -5503,7 +5503,7 @@ let _yes_wallet_test = ~deps: [ octez_error_monad |> open_ ~m:"TzLwtreslib"; - octez_crypto |> open_; + octez_crypto; zarith; zarith_stubs_js; data_encoding |> open_; diff --git a/src/lib_store/mocked/block_store.ml b/src/lib_store/mocked/block_store.ml index aa77977052ce..d7ba071c6bc9 100644 --- a/src/lib_store/mocked/block_store.ml +++ b/src/lib_store/mocked/block_store.ml @@ -25,9 +25,9 @@ type merge_status = Not_running | Running | Merge_failed of tztrace -type key = Block of (Block_hash.t * int) +type key = Block of (Tezos_crypto.Block_hash.t * int) -module Block_table = Block_hash.Table +module Block_table = Tezos_crypto.Block_hash.Table module Level_table = Hashtbl.Make (struct type t = int32 diff --git a/src/lib_store/mocked/block_store.mli b/src/lib_store/mocked/block_store.mli index 346f432f48e2..f929bd132b59 100644 --- a/src/lib_store/mocked/block_store.mli +++ b/src/lib_store/mocked/block_store.mli @@ -157,7 +157,7 @@ type t = block_store A block key may represent an invalid block (wrong hash and/or offset) as it is not ensured to be valid by construction.*) -type key = Block of (Block_hash.t * int) +type key = Block of (Tezos_crypto.Block_hash.t * int) (** The status of the merging thread *) type merge_status = Not_running | Running | Merge_failed of tztrace @@ -181,7 +181,8 @@ val mem : block_store -> key -> bool tzresult Lwt.t (** [get_hash block_store key] retrieves the hash corresponding to the given [key] in [block_store]. Return [None] if the block is unknown. *) -val get_hash : block_store -> key -> Block_hash.t option tzresult Lwt.t +val get_hash : + block_store -> key -> Tezos_crypto.Block_hash.t option tzresult Lwt.t (** [read_block ~read_metadata block_store key] reads the block [key] in [block_store] if present. Return [None] if the block is diff --git a/src/lib_store/mocked/protocol_store.ml b/src/lib_store/mocked/protocol_store.ml index ee693aa962f0..72fcb4225f65 100644 --- a/src/lib_store/mocked/protocol_store.ml +++ b/src/lib_store/mocked/protocol_store.ml @@ -23,13 +23,15 @@ (* *) (*****************************************************************************) -module Protocol_table = Protocol_hash.Table +module Protocol_table = Tezos_crypto.Protocol_hash.Table type t = Protocol.t Protocol_table.t -let mem table protocol_hash = Protocol_hash.Table.mem table protocol_hash +let mem table protocol_hash = + Tezos_crypto.Protocol_hash.Table.mem table protocol_hash -let all table = Protocol_table.to_seq_keys table |> Protocol_hash.Set.of_seq +let all table = + Protocol_table.to_seq_keys table |> Tezos_crypto.Protocol_hash.Set.of_seq let raw_store store protocol_hash bytes = if mem store protocol_hash then Lwt.return_none diff --git a/src/lib_store/mocked/protocol_store.mli b/src/lib_store/mocked/protocol_store.mli index c8d281e5e33e..505203ee6bac 100644 --- a/src/lib_store/mocked/protocol_store.mli +++ b/src/lib_store/mocked/protocol_store.mli @@ -30,25 +30,33 @@ type t (** [mem pstore proto_hash] tests the existence of the protocol indexed by [proto_hash] in the store. *) -val mem : t -> Protocol_hash.t -> bool +val mem : t -> Tezos_crypto.Protocol_hash.t -> bool (** [all pstore] returns the set of all stored protocols in [pstore]. *) -val all : t -> Protocol_hash.Set.t +val all : t -> Tezos_crypto.Protocol_hash.Set.t (** [raw_store pstore proto_hash proto_bytes] stores on disk the protocol [proto_bytes] (encoded bytes) indexed as [proto_hash]. Returns [None] if the protocol already exists. *) -val raw_store : t -> Protocol_hash.t -> bytes -> Protocol_hash.t option Lwt.t +val raw_store : + t -> + Tezos_crypto.Protocol_hash.t -> + bytes -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [store pstore proto_hash protocol] stores on disk the protocol [protocol] indexed as [proto_hash]. Returns [None] if the protocol already exists. *) -val store : t -> Protocol_hash.t -> Protocol.t -> Protocol_hash.t option Lwt.t +val store : + t -> + Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [read pstore proto_hash] reads from [pstore] and returns the protocol indexed by [proto_hash]. Returns [None] if the protocol cannot be read. *) -val read : t -> Protocol_hash.t -> Protocol.t option Lwt.t +val read : t -> Tezos_crypto.Protocol_hash.t -> Protocol.t option Lwt.t (** [init store_dir] creates a store relatively to [store_dir] path or loads it if it already exists. *) diff --git a/src/lib_store/mocked/store.ml b/src/lib_store/mocked/store.ml index 41445770d379..046a64101462 100644 --- a/src/lib_store/mocked/store.ml +++ b/src/lib_store/mocked/store.ml @@ -60,13 +60,13 @@ type store = { context_index : Context_ops.index; protocol_store : Protocol_store.t; allow_testchains : bool; - protocol_watcher : Protocol_hash.t Lwt_watcher.input; + protocol_watcher : Tezos_crypto.Protocol_hash.t Lwt_watcher.input; global_block_watcher : (chain_store * block) Lwt_watcher.input; } and chain_store = { global_store : store; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; chain_dir : [`Chain_dir] Naming.directory; chain_config : chain_config; block_store : Block_store.t; @@ -75,8 +75,8 @@ and chain_store = { genesis_block_data : block Stored_data.t; block_watcher : block Lwt_watcher.input; block_rpc_directories : - (chain_store * block) Tezos_rpc.Directory.t Protocol_hash.Map.t - Protocol_hash.Table.t; + (chain_store * block) Tezos_rpc.Directory.t Tezos_crypto.Protocol_hash.Map.t + Tezos_crypto.Protocol_hash.Table.t; } and chain_state = { @@ -90,20 +90,26 @@ and chain_state = { (* Following fields are safe to update directly *) protocol_levels_data : Protocol_levels.activation_block Protocol_levels.t Stored_data.t; - invalid_blocks_data : invalid_block Block_hash.Map.t Stored_data.t; - forked_chains_data : Block_hash.t Chain_id.Map.t Stored_data.t; + invalid_blocks_data : + invalid_block Tezos_crypto.Block_hash.Map.t Stored_data.t; + forked_chains_data : + Tezos_crypto.Block_hash.t Tezos_crypto.Chain_id.Map.t Stored_data.t; (* In memory-only: *) current_head : Block_repr.t; active_testchain : testchain option; mempool : Mempool.t; - live_blocks : Block_hash.Set.t; - live_operations : Operation_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; mutable live_data_cache : - (Block_hash.t * Operation_hash.Set.t) Ringo.Ring.t option; + (Tezos_crypto.Block_hash.t * Tezos_crypto.Operation_hash.Set.t) Ringo.Ring.t + option; prechecked_blocks : Block_repr.t Block_lru_cache.t; } -and testchain = {forked_block : Block_hash.t; testchain_store : chain_store} +and testchain = { + forked_block : Tezos_crypto.Block_hash.t; + testchain_store : chain_store; +} and block = Block_repr.t @@ -149,7 +155,7 @@ let locked_is_acceptable_block chain_state (hash, level) = | None -> Lwt.return_true | Some (target_hash, target_level) -> if Compare.Int32.(level = target_level) then - Lwt.return @@ Block_hash.equal hash target_hash + Lwt.return @@ Tezos_crypto.Block_hash.equal hash target_hash else Lwt.return_true module Block = struct @@ -165,7 +171,8 @@ module Block = struct operations_metadata : Block_validation.operation_metadata list list; } - let equal b b' = Block_hash.equal (Block_repr.hash b) (Block_repr.hash b') + let equal b b' = + Tezos_crypto.Block_hash.equal (Block_repr.hash b) (Block_repr.hash b') let descriptor blk = Block_repr.descriptor blk @@ -183,7 +190,7 @@ module Block = struct let locked_is_known_invalid chain_state hash = let open Lwt_syntax in let* invalid_blocks = Stored_data.get chain_state.invalid_blocks_data in - Lwt.return (Block_hash.Map.mem hash invalid_blocks) + Lwt.return (Tezos_crypto.Block_hash.Map.mem hash invalid_blocks) let is_known_invalid {chain_state; _} hash = Shared.use chain_state (fun chain_state -> @@ -216,7 +223,7 @@ module Block = struct let is_genesis chain_store hash = let genesis = genesis chain_store in - Block_hash.equal hash genesis.Genesis.block + Tezos_crypto.Block_hash.equal hash genesis.Genesis.block let read_block {block_store; _} ?(distance = 0) hash = let open Lwt_result_syntax in @@ -415,7 +422,7 @@ module Block = struct in let*! genesis_block = Stored_data.get chain_store.genesis_block_data in let is_main_chain = - Chain_id.equal + Tezos_crypto.Chain_id.equal chain_store.chain_id (WithExceptions.Option.get ~loc:__LOC__ @@ -468,7 +475,9 @@ module Block = struct in let* () = fail_unless - (Context_hash.equal block_header.shell.context context_hash) + (Tezos_crypto.Context_hash.equal + block_header.shell.context + context_hash) (Validation_errors.Inconsistent_hash (context_hash, block_header.shell.context)) in @@ -612,7 +621,7 @@ module Block = struct let open Lwt_syntax in Shared.use chain_state (fun chain_state -> let* invalid_blocks = Stored_data.get chain_state.invalid_blocks_data in - Lwt.return (Block_hash.Map.find hash invalid_blocks)) + Lwt.return (Tezos_crypto.Block_hash.Map.find hash invalid_blocks)) let read_invalid_blocks {chain_state; _} = Shared.use chain_state (fun chain_state -> @@ -628,7 +637,10 @@ module Block = struct chain_state.invalid_blocks_data (fun invalid_blocks -> Lwt.return - (Block_hash.Map.add hash {level; errors} invalid_blocks))) + (Tezos_crypto.Block_hash.Map.add + hash + {level; errors} + invalid_blocks))) in return_unit @@ -637,7 +649,7 @@ module Block = struct Stored_data.update_with chain_state.invalid_blocks_data (fun invalid_blocks -> - Lwt.return (Block_hash.Map.remove hash invalid_blocks))) + Lwt.return (Tezos_crypto.Block_hash.Map.remove hash invalid_blocks))) (** Accessors *) @@ -684,8 +696,8 @@ module Block = struct else Option.map (fun ll -> - Operation_metadata_list_list_hash.compute - (List.map Operation_metadata_list_hash.compute ll)) + Tezos_crypto.Operation_metadata_list_list_hash.compute + (List.map Tezos_crypto.Operation_metadata_list_hash.compute ll)) (Block_repr.operations_metadata_hashes blk) (** Metadata accessors *) @@ -702,8 +714,10 @@ module Block = struct let operations_metadata metadata = Block_repr.operations_metadata metadata let compute_operation_path hashes = - let list_hashes = List.map Operation_list_hash.compute hashes in - Operation_list_list_hash.compute_path list_hashes + let list_hashes = + List.map Tezos_crypto.Operation_list_hash.compute hashes + in + Tezos_crypto.Operation_list_list_hash.compute_path list_hashes let operations_path block i = if i < 0 || validation_passes block <= i then invalid_arg "operations_path" ; @@ -779,22 +793,27 @@ module Chain_traversal = struct let live_blocks chain_store block n = let fold (bacc, oacc) (head_hash, op_hashes) = - let bacc = Block_hash.Set.add head_hash bacc in + let bacc = Tezos_crypto.Block_hash.Set.add head_hash bacc in let oacc = List.fold_left - (List.fold_left (fun oacc op -> Operation_hash.Set.add op oacc)) + (List.fold_left (fun oacc op -> + Tezos_crypto.Operation_hash.Set.add op oacc)) oacc op_hashes in (bacc, oacc) in - let init = (Block_hash.Set.empty, Operation_hash.Set.empty) in + let init = + (Tezos_crypto.Block_hash.Set.empty, Tezos_crypto.Operation_hash.Set.empty) + in folder chain_store block n fold init let live_blocks_with_ring chain_store block n ring = let open Lwt_syntax in let fold acc (head_hash, op_hashes) = - let op_hash_set = Operation_hash.Set.(of_list (List.flatten op_hashes)) in + let op_hash_set = + Tezos_crypto.Operation_hash.Set.(of_list (List.flatten op_hashes)) + in (head_hash, op_hash_set) :: acc in let* l = folder chain_store block n fold [] in @@ -893,7 +912,7 @@ module Chain = struct let*! current_head_descr = Stored_data.get chain_state.current_head_data in - if Block_hash.equal head (fst current_head_descr) then + if Tezos_crypto.Block_hash.equal head (fst current_head_descr) then return (Some {chain_state with mempool}, ()) else return (None, ())) @@ -915,20 +934,22 @@ module Chain = struct match live_data_cache with | Some live_data_cache when update_cache - && Block_hash.equal + && Tezos_crypto.Block_hash.equal (Block.predecessor block) (Block.hash current_head) && Ringo.Ring.capacity live_data_cache = expected_capacity -> ( let most_recent_block = Block.hash block in let most_recent_ops = Block.all_operation_hashes block - |> List.flatten |> Operation_hash.Set.of_list + |> List.flatten |> Tezos_crypto.Operation_hash.Set.of_list in let new_live_blocks = - Block_hash.Set.add most_recent_block live_blocks + Tezos_crypto.Block_hash.Set.add most_recent_block live_blocks in let new_live_operations = - Operation_hash.Set.union most_recent_ops live_operations + Tezos_crypto.Operation_hash.Set.union + most_recent_ops + live_operations in match Ringo.Ring.add_and_return_erased @@ -938,10 +959,12 @@ module Chain = struct | None -> Lwt.return (new_live_blocks, new_live_operations) | Some (last_block, last_ops) -> let diffed_new_live_blocks = - Block_hash.Set.remove last_block new_live_blocks + Tezos_crypto.Block_hash.Set.remove last_block new_live_blocks in let diffed_new_live_operations = - Operation_hash.Set.diff new_live_operations last_ops + Tezos_crypto.Operation_hash.Set.diff + new_live_operations + last_ops in Lwt.return (diffed_new_live_blocks, diffed_new_live_operations)) | _ when update_cache -> @@ -957,9 +980,12 @@ module Chain = struct let live_blocks, live_ops = Ringo.Ring.fold new_cache - ~init:(Block_hash.Set.empty, Operation_hash.Set.empty) + ~init: + ( Tezos_crypto.Block_hash.Set.empty, + Tezos_crypto.Operation_hash.Set.empty ) ~f:(fun (bhs, opss) (bh, ops) -> - (Block_hash.Set.add bh bhs, Operation_hash.Set.union ops opss)) + ( Tezos_crypto.Block_hash.Set.add bh bhs, + Tezos_crypto.Operation_hash.Set.union ops opss )) in Lwt.return (live_blocks, live_ops) | _ -> Chain_traversal.live_blocks chain_store block expected_capacity @@ -982,7 +1008,7 @@ module Chain = struct let open Lwt_syntax in if Compare.Int32.(lvl' > lvl) then Lwt.return_false else if Compare.Int32.(lvl = lvl') then - Lwt.return (Block_hash.equal hash hash') + Lwt.return (Tezos_crypto.Block_hash.equal hash hash') else let* o = Block.read_ancestor_hash_opt @@ -992,7 +1018,8 @@ module Chain = struct in match o with | None -> Lwt.return_false - | Some hash_found -> Lwt.return (Block_hash.equal hash' hash_found) + | Some hash_found -> + Lwt.return (Tezos_crypto.Block_hash.equal hash' hash_found) let is_in_chain chain_store (hash, level) = let open Lwt_syntax in @@ -1299,7 +1326,7 @@ module Chain = struct chain_state.invalid_blocks_data (fun invalid_blocks -> Lwt.return - (Block_hash.Map.filter + (Tezos_crypto.Block_hash.Map.filter (fun _k {level; _} -> level > snd new_checkpoint) invalid_blocks)) in @@ -1382,7 +1409,8 @@ module Chain = struct in match o with | None -> tzfail Missing_last_allowed_fork_level_block - | Some lafl_hash -> return (Block_hash.equal lafl_hash ancestor))) + | Some lafl_hash -> + return (Tezos_crypto.Block_hash.equal lafl_hash ancestor))) let is_valid_for_checkpoint chain_store given_checkpoint = let open Lwt_syntax in @@ -1517,7 +1545,10 @@ module Chain = struct ( best_head, List.filter (fun (hash, _) -> - not (Block_hash.equal (Block.hash best_head) hash)) + not + (Tezos_crypto.Block_hash.equal + (Block.hash best_head) + hash)) all_heads ) in (* Case 1 *) @@ -1622,18 +1653,20 @@ module Chain = struct let* invalid_blocks_data = Stored_data.init (Naming.invalid_blocks_file chain_dir) - ~initial_data:Block_hash.Map.empty + ~initial_data:Tezos_crypto.Block_hash.Map.empty in let* forked_chains_data = Stored_data.init (Naming.forked_chains_file chain_dir) - ~initial_data:Chain_id.Map.empty + ~initial_data:Tezos_crypto.Chain_id.Map.empty in let current_head = genesis_block in let active_testchain = None in let mempool = Mempool.empty in - let live_blocks = Block_hash.Set.singleton genesis_block.hash in - let live_operations = Operation_hash.Set.empty in + let live_blocks = + Tezos_crypto.Block_hash.Set.singleton genesis_block.hash + in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let live_data_cache = None in let prechecked_blocks = Block_lru_cache.create 10 in return @@ -1711,7 +1744,7 @@ module Chain = struct in let chain_state = Shared.create chain_state in let block_watcher = Lwt_watcher.create_input () in - let block_rpc_directories = Protocol_hash.Table.create 7 in + let block_rpc_directories = Tezos_crypto.Protocol_hash.Table.create 7 in let chain_store : chain_store = { global_store; @@ -1822,7 +1855,7 @@ module Chain = struct let*! o = find_activation_block chain_store ~protocol_level in match o with | Some {block = bh, _; _} -> - if Block_hash.(bh <> Block.hash block) then + if Tezos_crypto.Block_hash.(bh <> Block.hash block) then set_protocol_level chain_store ~protocol_level (block, protocol_hash) else return_unit | None -> @@ -1874,7 +1907,8 @@ module Chain = struct let* o = Block.read_predecessor_opt chain_store block in match o with | None -> Lwt.return_none (* genesis *) - | Some pred when Block_hash.equal (Block.hash pred) (Block.hash block) -> + | Some pred + when Tezos_crypto.Block_hash.equal (Block.hash pred) (Block.hash block) -> Lwt.return_none (* genesis *) | Some pred -> ( let* _, save_point_level = savepoint chain_store in @@ -1891,25 +1925,27 @@ module Chain = struct else Block.protocol_hash_exn chain_store pred in match - Protocol_hash.Table.find chain_store.block_rpc_directories protocol + Tezos_crypto.Protocol_hash.Table.find + chain_store.block_rpc_directories + protocol with | None -> Lwt.return_none | Some map -> let* next_protocol = Block.protocol_hash_exn chain_store block in - Lwt.return (Protocol_hash.Map.find next_protocol map)) + Lwt.return (Tezos_crypto.Protocol_hash.Map.find next_protocol map)) let set_rpc_directory chain_store ~protocol_hash ~next_protocol_hash dir = let map = Option.value - ~default:Protocol_hash.Map.empty - (Protocol_hash.Table.find + ~default:Tezos_crypto.Protocol_hash.Map.empty + (Tezos_crypto.Protocol_hash.Table.find chain_store.block_rpc_directories protocol_hash) in - Protocol_hash.Table.replace + Tezos_crypto.Protocol_hash.Table.replace chain_store.block_rpc_directories protocol_hash - (Protocol_hash.Map.add next_protocol_hash dir map) ; + (Tezos_crypto.Protocol_hash.Map.add next_protocol_hash dir map) ; Lwt.return_unit (* Not implemented as both the store and context garbage collection @@ -2011,7 +2047,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) patch_context in let store_dir = Naming.store_dir ~dir_path:store_dir in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let*! context_index, commit_genesis = let open Tezos_context_memory in match commit_genesis with @@ -2067,7 +2103,7 @@ let get_chain_store store chain_id = let chain_store = main_chain_store store in let rec loop chain_store = let open Lwt_result_syntax in - if Chain_id.equal (Chain.chain_id chain_store) chain_id then + if Tezos_crypto.Chain_id.equal (Chain.chain_id chain_store) chain_id then return chain_store else Shared.use chain_store.chain_state (fun {active_testchain; _} -> @@ -2172,7 +2208,7 @@ let rec make_pp_chain_store (chain_store : chain_store) = proto_level pp_block_descriptor block - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol (option_pp ~default:"n/a" (fun fmt _ -> Format.fprintf fmt "available")) commit_info @@ -2192,7 +2228,7 @@ let rec make_pp_chain_store (chain_store : chain_store) = highwatermark: %a@ caboose: %a@ target: %a@ @[protocol levels:@ \ %a@]@ @[invalid blocks:@ %a@]@ @[forked chains:@ %a@]@ @[active testchain: %a@]@]" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id (Naming.dir_path chain_dir) Data_encoding.Json.pp @@ -2226,19 +2262,22 @@ let rec make_pp_chain_store (chain_store : chain_store) = target (Format.pp_print_list ~pp_sep:Format.pp_print_cut pp_protocol_level) (Protocol_levels.bindings protocol_levels_data) - (Format.pp_print_list ~pp_sep:Format.pp_print_cut Block_hash.pp) - (Block_hash.Map.bindings invalid_blocks_data |> List.map fst) + (Format.pp_print_list + ~pp_sep:Format.pp_print_cut + Tezos_crypto.Block_hash.pp) + (Tezos_crypto.Block_hash.Map.bindings invalid_blocks_data + |> List.map fst) (Format.pp_print_list ~pp_sep:Format.pp_print_cut (fun fmt (chain_id, block_hash) -> Format.fprintf fmt "testchain's chain id: %a, forked block: %a" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash)) - (Chain_id.Map.bindings forked_chains_data) + (Tezos_crypto.Chain_id.Map.bindings forked_chains_data) pp_testchain_opt ()) diff --git a/src/lib_store/shared/block_key.ml b/src/lib_store/shared/block_key.ml index 63fa6ee5a781..6f0c77a72433 100644 --- a/src/lib_store/shared/block_key.ml +++ b/src/lib_store/shared/block_key.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -include Block_hash +include Tezos_crypto.Block_hash let hash_size = 31 @@ -31,13 +31,13 @@ let t = let open Repr in map (bytes_of (`Fixed hash_size)) - (fun b -> Block_hash.of_bytes_exn b) - (fun bh -> Block_hash.to_bytes bh) + (fun b -> Tezos_crypto.Block_hash.of_bytes_exn b) + (fun bh -> Tezos_crypto.Block_hash.to_bytes bh) -let encode bh = Block_hash.to_string bh +let encode bh = Tezos_crypto.Block_hash.to_string bh -let encoded_size = Block_hash.size (* in bytes *) +let encoded_size = Tezos_crypto.Block_hash.size (* in bytes *) let decode str off = let str = String.sub str off encoded_size in - Block_hash.of_string_exn str + Tezos_crypto.Block_hash.of_string_exn str diff --git a/src/lib_store/shared/block_key.mli b/src/lib_store/shared/block_key.mli index 684d58d70366..3ddac652e166 100644 --- a/src/lib_store/shared/block_key.mli +++ b/src/lib_store/shared/block_key.mli @@ -23,9 +23,9 @@ (* *) (*****************************************************************************) -(** Super-set of {!Block_hash} to satisfy {!Index.Key} interface. *) +(** Super-set of {!Tezos_crypto.Block_hash} to satisfy {!Index.Key} interface. *) -include module type of Block_hash +include module type of Tezos_crypto.Block_hash val t : t Repr.t diff --git a/src/lib_store/shared/block_repr.ml b/src/lib_store/shared/block_repr.ml index 498cfe792361..7e8de39e81ca 100644 --- a/src/lib_store/shared/block_repr.ml +++ b/src/lib_store/shared/block_repr.ml @@ -28,8 +28,9 @@ open Store_errors type contents = { header : Block_header.t; operations : Operation.t list list; - block_metadata_hash : Block_metadata_hash.t option; - operations_metadata_hashes : Operation_metadata_hash.t list list option; + block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + operations_metadata_hashes : + Tezos_crypto.Operation_metadata_hash.t list list option; } type metadata = { @@ -49,14 +50,14 @@ type legacy_metadata = { } type legacy_block = { - legacy_hash : Block_hash.t; + legacy_hash : Tezos_crypto.Block_hash.t; legacy_contents : contents; mutable legacy_metadata : legacy_metadata option; (* allows updating metadata field when loading cemented metadata *) } type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; contents : contents; mutable metadata : metadata option; (* allows updating metadata field when loading cemented metadata *) @@ -74,7 +75,7 @@ let create_genesis_block ~genesis context = timestamp = genesis.Genesis.time; fitness = []; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; context; } in @@ -116,10 +117,10 @@ let contents_encoding = (obj4 (req "header" (dynamic_size Block_header.encoding)) (req "operations" (list (list (dynamic_size Operation.encoding)))) - (opt "block_metadata_hash" Block_metadata_hash.encoding) + (opt "block_metadata_hash" Tezos_crypto.Block_metadata_hash.encoding) (opt "operations_metadata_hashes" - (list (list Operation_metadata_hash.encoding)))) + (list (list Tezos_crypto.Operation_metadata_hash.encoding)))) let metadata_encoding : metadata Data_encoding.t = let open Data_encoding in @@ -202,7 +203,7 @@ let encoding = (dynamic_size ~kind:`Uint30 (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "contents" contents_encoding) (varopt "metadata" metadata_encoding))) @@ -217,7 +218,7 @@ let legacy_encoding = (dynamic_size ~kind:`Uint30 (obj3 - (req "legacy_hash" Block_hash.encoding) + (req "legacy_hash" Tezos_crypto.Block_hash.encoding) (req "legacy_contents" contents_encoding) (varopt "legacy_metadata" legacy_metadata_encoding))) @@ -281,10 +282,11 @@ let check_block_consistency ?genesis_hash ?pred_block block = let result_hash = Block_header.hash block_header in let* () = fail_unless - (Block_hash.equal block_hash result_hash + (Tezos_crypto.Block_hash.equal block_hash result_hash || match genesis_hash with - | Some genesis_hash -> Block_hash.equal block_hash genesis_hash + | Some genesis_hash -> + Tezos_crypto.Block_hash.equal block_hash genesis_hash | None -> false) (Inconsistent_block_hash { @@ -298,7 +300,7 @@ let check_block_consistency ?genesis_hash ?pred_block block = | None -> return_unit | Some pred_block -> fail_unless - (Block_hash.equal (hash pred_block) (predecessor block) + (Tezos_crypto.Block_hash.equal (hash pred_block) (predecessor block) && Compare.Int32.(level block = Int32.succ (level pred_block))) (Inconsistent_block_predecessor { @@ -309,14 +311,14 @@ let check_block_consistency ?genesis_hash ?pred_block block = }) in let computed_operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map - Operation_list_hash.compute + Tezos_crypto.Operation_list_hash.compute (List.map (List.map Operation.hash) (operations block))) in let* () = fail_unless - (Operation_list_list_hash.equal + (Tezos_crypto.Operation_list_list_hash.equal computed_operations_hash (operations_hash block)) (Store_errors.Inconsistent_operations_hash diff --git a/src/lib_store/shared/block_repr.mli b/src/lib_store/shared/block_repr.mli index 7df90d4183c4..eb1aa25d928a 100644 --- a/src/lib_store/shared/block_repr.mli +++ b/src/lib_store/shared/block_repr.mli @@ -35,8 +35,9 @@ open Store_types type contents = { header : Block_header.t; operations : Operation.t list list; - block_metadata_hash : Block_metadata_hash.t option; - operations_metadata_hashes : Operation_metadata_hash.t list list option; + block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + operations_metadata_hashes : + Tezos_crypto.Operation_metadata_hash.t list list option; } (** The type for a block's [metadata] stored on disk. This @@ -66,7 +67,7 @@ type metadata = { users to re-use the same structure to store freshly loaded metadata. *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; contents : contents; mutable metadata : metadata option; } @@ -84,7 +85,7 @@ type legacy_metadata = { } type legacy_block = { - legacy_hash : Block_hash.t; + legacy_hash : Tezos_crypto.Block_hash.t; legacy_contents : contents; mutable legacy_metadata : legacy_metadata option; } @@ -100,7 +101,7 @@ val legacy_encoding : legacy_block Data_encoding.t (** [create_genesis_block ~genesis context_hash] creates a default genesis block for the given [genesis] and its [context_hash] that contains metadata. *) -val create_genesis_block : genesis:Genesis.t -> Context_hash.t -> t +val create_genesis_block : genesis:Genesis.t -> Tezos_crypto.Context_hash.t -> t (** Encoding for {!contents}. *) val contents_encoding : contents Data_encoding.t @@ -127,7 +128,7 @@ val descriptor : t -> block_descriptor (** [hash block] returns the stored [block]'s hash. It is not guaranteed to be the same as [Block_header.hash (header block)] (e.g. in sandbox, the genesis block might have a fake hash). *) -val hash : t -> Block_hash.t +val hash : t -> Tezos_crypto.Block_hash.t (** [operations block] returns the list of list of operations contained in the [block]. *) @@ -143,23 +144,24 @@ val level : t -> Int32.t val proto_level : t -> int -val predecessor : t -> Block_hash.t +val predecessor : t -> Tezos_crypto.Block_hash.t val timestamp : t -> Time.Protocol.t val validation_passes : t -> int -val operations_hash : t -> Operation_list_list_hash.t +val operations_hash : t -> Tezos_crypto.Operation_list_list_hash.t val fitness : t -> Fitness.t -val context : t -> Context_hash.t +val context : t -> Tezos_crypto.Context_hash.t val protocol_data : t -> Bytes.t -val block_metadata_hash : t -> Block_metadata_hash.t option +val block_metadata_hash : t -> Tezos_crypto.Block_metadata_hash.t option -val operations_metadata_hashes : t -> Operation_metadata_hash.t list list option +val operations_metadata_hashes : + t -> Tezos_crypto.Operation_metadata_hash.t list list option (** {2 Metadata accessors} *) @@ -188,7 +190,10 @@ val operations_metadata : - Are the stored operations hashes consistent regarding the stored operations hashes? *) val check_block_consistency : - ?genesis_hash:Block_hash.t -> ?pred_block:t -> t -> unit tzresult Lwt.t + ?genesis_hash:Tezos_crypto.Block_hash.t -> + ?pred_block:t -> + t -> + unit tzresult Lwt.t (** [decode_metadata data] decodes metadata from [data] encoded either with the new encoding or the legacy one. *) diff --git a/src/lib_store/shared/naming.ml b/src/lib_store/shared/naming.ml index 50822947d8a5..7f2ffde233e8 100644 --- a/src/lib_store/shared/naming.ml +++ b/src/lib_store/shared/naming.ml @@ -60,10 +60,12 @@ let store_dir ~dir_path = {dir_path} let protocol_store_dir base_dir = mk_dir base_dir "protocols" let protocol_file dir proto_hash = - mk_file dir (Protocol_hash.to_b58check proto_hash) + mk_file dir (Tezos_crypto.Protocol_hash.to_b58check proto_hash) let chain_dir dir chain_id = - mk_dir dir (Format.asprintf "chain_%a" Chain_id.pp_short chain_id) + mk_dir + dir + (Format.asprintf "chain_%a" Tezos_crypto.Chain_id.pp_short chain_id) let chain_config_file dir = make_encoded_file ~json:true dir ~filename:"config.json" chain_config_encoding @@ -108,13 +110,13 @@ let invalid_blocks_file dir = make_encoded_file dir ~filename:"invalid_blocks" - (Block_hash.Map.encoding invalid_block_encoding) + (Tezos_crypto.Block_hash.Map.encoding invalid_block_encoding) let forked_chains_file dir = make_encoded_file dir ~filename:"forked_chains" - (Chain_id.Map.encoding Block_hash.encoding) + (Tezos_crypto.Chain_id.Map.encoding Tezos_crypto.Block_hash.encoding) let savepoint_file dir = make_encoded_file dir ~filename:"savepoint" block_descriptor_encoding diff --git a/src/lib_store/shared/naming.mli b/src/lib_store/shared/naming.mli index 6c974e22ec31..63dc914de62d 100644 --- a/src/lib_store/shared/naming.mli +++ b/src/lib_store/shared/naming.mli @@ -62,13 +62,13 @@ val protocol_store_dir : (** Protocol file *) val protocol_file : - [`Protocol_dir] directory -> Protocol_hash.t -> [`Protocol] file + [`Protocol_dir] directory -> Tezos_crypto.Protocol_hash.t -> [`Protocol] file (** {2 Chain directory} *) val chain_dir : [< `Store_dir | `Testchains_dir] directory -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> [`Chain_dir] directory val lock_file : [`Chain_dir] directory -> [`Lockfile] file @@ -111,11 +111,13 @@ val target_file : val invalid_blocks_file : [`Chain_dir] directory -> - ([`Invalid_blocks], invalid_block Block_hash.Map.t) encoded_file + ([`Invalid_blocks], invalid_block Tezos_crypto.Block_hash.Map.t) encoded_file val forked_chains_file : [`Chain_dir] directory -> - ([`Forked_chains], Block_hash.t Chain_id.Map.t) encoded_file + ( [`Forked_chains], + Tezos_crypto.Block_hash.t Tezos_crypto.Chain_id.Map.t ) + encoded_file (** {2 Block store} *) diff --git a/src/lib_store/shared/store_events.ml b/src/lib_store/shared/store_events.ml index d39527dc145b..02c3af17231a 100644 --- a/src/lib_store/shared/store_events.ml +++ b/src/lib_store/shared/store_events.ml @@ -182,12 +182,12 @@ let fork_testchain = "the test chain {chain_id} for protocol {protocol_hash} with genesis \ block hash {genesis_hash} was initialized from {fork_block} and is now \ registered in the store" - ~pp1:Chain_id.pp - ("chain_id", Chain_id.encoding) - ~pp2:Protocol_hash.pp - ("protocol_hash", Protocol_hash.encoding) - ~pp3:Block_hash.pp - ("genesis_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Chain_id.pp + ("chain_id", Tezos_crypto.Chain_id.encoding) + ~pp2:Tezos_crypto.Protocol_hash.pp + ("protocol_hash", Tezos_crypto.Protocol_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("genesis_hash", Tezos_crypto.Block_hash.encoding) ~pp4:pp_block_descriptor ("fork_block", block_descriptor_encoding) @@ -384,8 +384,8 @@ let restore_protocol_activation = ~name:"restore_protocol_activation" ~msg:"protocol {protocol_level} ({protocol_hash}) was successfully restored" ("protocol_level", Data_encoding.int31) - ~pp2:Protocol_hash.pp - ("protocol_hash", Protocol_hash.encoding) + ~pp2:Tezos_crypto.Protocol_hash.pp + ("protocol_hash", Tezos_crypto.Protocol_hash.encoding) let update_protocol_table = declare_4 @@ -396,11 +396,11 @@ let update_protocol_table = "the protocol table was updated: protocol {proto_hash} (level \ {proto_level}) was activated on block {block_hash} (level \ {block_level})" - ("proto_hash", Protocol_hash.encoding) - ~pp1:Protocol_hash.pp_short + ("proto_hash", Tezos_crypto.Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp_short ("proto_level", Data_encoding.int31) - ("block_hash", Block_hash.encoding) - ~pp3:Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp ("block_level", Data_encoding.int32) ~pp4:pp_int32 diff --git a/src/lib_store/shared/store_types.ml b/src/lib_store/shared/store_types.ml index 3c7f42f15324..a1571e36fcdd 100644 --- a/src/lib_store/shared/store_types.ml +++ b/src/lib_store/shared/store_types.ml @@ -23,14 +23,14 @@ (* *) (*****************************************************************************) -type block_descriptor = Block_hash.t * int32 +type block_descriptor = Tezos_crypto.Block_hash.t * int32 let block_descriptor_encoding = let open Data_encoding in - tup2 Block_hash.encoding int32 + tup2 Tezos_crypto.Block_hash.encoding int32 let pp_block_descriptor fmt (hash, level) = - Format.fprintf fmt "%a (level: %ld)" Block_hash.pp hash level + Format.fprintf fmt "%a (level: %ld)" Tezos_crypto.Block_hash.pp hash level type chain_config = { history_mode : History_mode.t; @@ -63,7 +63,7 @@ module Block_lru_cache = Ringo_lwt.Functors.Make_opt ((val Ringo.( map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash)) + (Tezos_crypto.Block_hash)) module Protocol_levels = struct include Map.Make (struct @@ -76,10 +76,11 @@ module Protocol_levels = struct author : string; message : string; test_chain_status : Test_chain_status.t; - predecessor_block_metadata_hash : Block_metadata_hash.t option; - predecessor_ops_metadata_hash : Operation_metadata_list_list_hash.t option; - data_merkle_root : Context_hash.t; - parents_contexts : Context_hash.t list; + predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + predecessor_ops_metadata_hash : + Tezos_crypto.Operation_metadata_list_list_hash.t option; + data_merkle_root : Tezos_crypto.Context_hash.t; + parents_contexts : Tezos_crypto.Context_hash.t list; } let commit_info_of_tuple @@ -141,16 +142,18 @@ module Protocol_levels = struct (req "author" string) (req "message" string) (req "test_chain_status" Test_chain_status.encoding) - (req "data_merkle_root" Context_hash.encoding) - (opt "predecessor_block_metadata_hash" Block_metadata_hash.encoding) + (req "data_merkle_root" Tezos_crypto.Context_hash.encoding) + (opt + "predecessor_block_metadata_hash" + Tezos_crypto.Block_metadata_hash.encoding) (opt "predecessor_ops_metadata_hash" - Operation_metadata_list_list_hash.encoding) - (req "parents_contexts" (list Context_hash.encoding))) + Tezos_crypto.Operation_metadata_list_list_hash.encoding) + (req "parents_contexts" (list Tezos_crypto.Context_hash.encoding))) type activation_block = { block : block_descriptor; - protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; commit_info : commit_info option; } @@ -161,7 +164,7 @@ module Protocol_levels = struct (fun (block, protocol, commit_info) -> {block; protocol; commit_info}) (obj3 (req "block" block_descriptor_encoding) - (req "protocol" Protocol_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) (opt "commit_info" commit_info_encoding)) let encoding = diff --git a/src/lib_store/shared/store_types.mli b/src/lib_store/shared/store_types.mli index 1197e6b32319..894ed2d0df98 100644 --- a/src/lib_store/shared/store_types.mli +++ b/src/lib_store/shared/store_types.mli @@ -26,7 +26,7 @@ (** {1 Global types used in the store library} *) (** The type used to describe a block pointer i.e. its hash and level. *) -type block_descriptor = Block_hash.t * int32 +type block_descriptor = Tezos_crypto.Block_hash.t * int32 (** Encoding for {!block_descriptor}. *) val block_descriptor_encoding : block_descriptor Data_encoding.t @@ -55,7 +55,7 @@ val invalid_block_encoding : invalid_block Data_encoding.t (** Module [Block_lru_cache] implements a lwt LRU cache map indexed by block hashes. *) module Block_lru_cache : - Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Block_hash.t + Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Tezos_crypto.Block_hash.t (** Module [Protocol_levels] represents an associative map of protocol levels to corresponding blocks which supposedly activate new @@ -65,7 +65,7 @@ module Protocol_levels : sig include Map.S with type key = int (** The type representing a subset of the commit information. These - are used to easily check that a given [Context_hash.t], with the + are used to easily check that a given [Tezos_crypto.Context_hash.t], with the associated context not present on disk, is consistent. It is used to verify that an announced protocol is indeed the one that was committed on disk. Fields are: @@ -88,22 +88,23 @@ module Protocol_levels : sig author : string; message : string; test_chain_status : Test_chain_status.t; - predecessor_block_metadata_hash : Block_metadata_hash.t option; - predecessor_ops_metadata_hash : Operation_metadata_list_list_hash.t option; - data_merkle_root : Context_hash.t; - parents_contexts : Context_hash.t list; + predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + predecessor_ops_metadata_hash : + Tezos_crypto.Operation_metadata_list_list_hash.t option; + data_merkle_root : Tezos_crypto.Context_hash.t; + parents_contexts : Tezos_crypto.Context_hash.t list; } val commit_info_of_tuple : - Protocol_hash.t + Tezos_crypto.Protocol_hash.t * string * string * Time.Protocol.t * Test_chain_status.t - * Context_hash.t - * Block_metadata_hash.t option - * Operation_metadata_list_list_hash.t option - * Context_hash.t list -> + * Tezos_crypto.Context_hash.t + * Tezos_crypto.Block_metadata_hash.t option + * Tezos_crypto.Operation_metadata_list_list_hash.t option + * Tezos_crypto.Context_hash.t list -> commit_info (** Encoding for {!commit_info}. *) @@ -132,7 +133,7 @@ module Protocol_levels : sig allowing us to remove the option. *) type activation_block = { block : block_descriptor; - protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; commit_info : commit_info option; } diff --git a/src/lib_store/store.mli b/src/lib_store/store.mli index 7f2ba3917629..ce41bba5d834 100644 --- a/src/lib_store/store.mli +++ b/src/lib_store/store.mli @@ -184,7 +184,7 @@ type chain_store chains and instantiate testchain's sub chain stores, for all chains contained in the store. The chain store created is based on the [genesis] provided. Its chain identifier will be computed - using the {!Tezos_crypto.Chain_id.of_block_hash} function. + using the {!Tezos_crypto.Tezos_crypto.Chain_id.of_block_hash} function. @param patch_context the handle called when initializing the context. It usually is passed when creating a sandboxed chain. @@ -213,7 +213,9 @@ val init : ?patch_context: (Tezos_protocol_environment.Context.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t) -> - ?commit_genesis:(chain_id:Chain_id.t -> Context_hash.t tzresult Lwt.t) -> + ?commit_genesis: + (chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Context_hash.t tzresult Lwt.t) -> ?history_mode:History_mode.t -> ?readonly:bool -> ?block_cache_limit:int -> @@ -265,11 +267,13 @@ val all_chain_stores : store -> chain_store list Lwt.t (** [get_chain_store global_store chain_id] returns the initialized chain store in [global_store] associated to [chain_id]. *) -val get_chain_store : store -> Chain_id.t -> chain_store tzresult Lwt.t +val get_chain_store : + store -> Tezos_crypto.Chain_id.t -> chain_store tzresult Lwt.t (** [get_chain_store_opt global_store chain_id] optional version of [get_chain_store]. *) -val get_chain_store_opt : store -> Chain_id.t -> chain_store option Lwt.t +val get_chain_store_opt : + store -> Tezos_crypto.Chain_id.t -> chain_store option Lwt.t val make_pp_store : store -> (Format.formatter -> unit -> unit) Lwt.t @@ -303,41 +307,49 @@ module Block : sig (** [is_known_valid chain_store bh] tests that the block [bh] is known and valid in [chain_store] (i.e. the block is present in the block store). *) - val is_known_valid : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_valid : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known_invalid chain_store bh] tests that the block [bh] is invalid in [chain_store] (i.e. the block is present in the invalid blocks file). *) - val is_known_invalid : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_invalid : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known_prechecked chain_store bh] tests that the block [bh] is prechecked in [chain_store] (i.e. the block is present in the prechecked block cache). *) - val is_known_prechecked : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_prechecked : + chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known chain_store bh] tests that the block [bh] is either known valid or known invalid in [chain_store]. *) - val is_known : chain_store -> Block_hash.t -> bool Lwt.t + val is_known : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_genesis chain_store bh] tests that the block [bh] is the genesis initialized in [chain_store]. *) - val is_genesis : chain_store -> Block_hash.t -> bool + val is_genesis : chain_store -> Tezos_crypto.Block_hash.t -> bool (** [validity chain_store bh] computes the {!Block_locator.validity} ([Unknown], [Known_valid] or [Known_invalid]) for the block [bh] in [chain_store]. *) - val validity : chain_store -> Block_hash.t -> Block_locator.validity Lwt.t + val validity : + chain_store -> Tezos_crypto.Block_hash.t -> Block_locator.validity Lwt.t (** [read_block chain_store ?distance bh] tries to read in the [chain_store] the block [bh] or the predecessing block at the offset [distance] of [bh]. By default, [distance] is 0.*) val read_block : - chain_store -> ?distance:int -> Block_hash.t -> block tzresult Lwt.t + chain_store -> + ?distance:int -> + Tezos_crypto.Block_hash.t -> + block tzresult Lwt.t (** [read_block_opt chain_store ?distance bh] optional version of [read_block]. *) val read_block_opt : - chain_store -> ?distance:int -> Block_hash.t -> block option Lwt.t + chain_store -> + ?distance:int -> + Tezos_crypto.Block_hash.t -> + block option Lwt.t (** [read_block_by_level chain_store level] reads in the [chain_store] the block at [level]. The block retrieved will be @@ -359,13 +371,16 @@ module Block : sig val read_block_metadata : ?distance:int -> chain_store -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> metadata option tzresult Lwt.t (** [read_block_metadata_opt ?distance chain_store bh] same as [read_block_metadata] but returns [None] in case of errors. *) val read_block_metadata_opt : - ?distance:int -> chain_store -> Block_hash.t -> metadata option Lwt.t + ?distance:int -> + chain_store -> + Tezos_crypto.Block_hash.t -> + metadata option Lwt.t (** [get_block_metadata chain_store block] reads in the [chain_store] the metadata associated to the [block]. Returns @@ -390,7 +405,7 @@ module Block : sig (** [read_predecessor_of_hash chain_store bh] reads in [chain_store] the predecessor's block of [bh]. *) val read_predecessor_of_hash : - chain_store -> Block_hash.t -> block tzresult Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block tzresult Lwt.t (** [read_ancestor_hash chain_store ~distance bh] retrieves in the [chain_store] the hash of the ancestor of the block [bh] at @@ -398,28 +413,31 @@ module Block : sig val read_ancestor_hash : chain_store -> distance:int -> - Block_hash.t -> - Block_hash.t option tzresult Lwt.t + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Block_hash.t option tzresult Lwt.t (** [read_ancestor_hash_opt chain_store ~distance bh] same as [read_ancestor_hash] but returns [None] on errors. *) val read_ancestor_hash_opt : - chain_store -> distance:int -> Block_hash.t -> Block_hash.t option Lwt.t + chain_store -> + distance:int -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Block_hash.t option Lwt.t (** [read_ancestor_opt chain_store block] optional version of [read_ancestor]. *) val read_predecessor_of_hash_opt : - chain_store -> Block_hash.t -> block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block option Lwt.t (** [read_prechecked_block chain_store bh] tries to read in the [chain_store]'s prechecked block cache the block [bh].*) val read_prechecked_block : - chain_store -> Block_hash.t -> block tzresult Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block tzresult Lwt.t (** [read_prechecked_block_opt chain_store bh] optional version of [read_prechecked_block].*) val read_prechecked_block_opt : - chain_store -> Block_hash.t -> block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block option Lwt.t (** [store_block chain_store ~block_header ~operations validation_result] stores in [chain_store] the block with its @@ -445,7 +463,7 @@ module Block : sig its [block_header] and [operations]. *) val store_prechecked_block : chain_store -> - hash:Block_hash.t -> + hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t trace trace -> unit tzresult Lwt.t @@ -475,46 +493,50 @@ module Block : sig val testchain_status : chain_store -> block -> - (Test_chain_status.t * Block_hash.t option) tzresult Lwt.t + (Test_chain_status.t * Tezos_crypto.Block_hash.t option) tzresult Lwt.t (** [protocol_hash_exn chain_store block] reads the protocol associated to [block] in its associated context. Fails when the context is unknown. *) - val protocol_hash_exn : chain_store -> block -> Protocol_hash.t Lwt.t + val protocol_hash_exn : + chain_store -> block -> Tezos_crypto.Protocol_hash.t Lwt.t (** [protocol_hash chain_store block] error monad version of [protocol_hash_exn]. *) - val protocol_hash : chain_store -> block -> Protocol_hash.t tzresult Lwt.t + val protocol_hash : + chain_store -> block -> Tezos_crypto.Protocol_hash.t tzresult Lwt.t (** [read_invalid_block_opt chain_store bh] reads in the [chain_store] the invalid block [bh] if it exists. *) val read_invalid_block_opt : - chain_store -> Block_hash.t -> invalid_block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> invalid_block option Lwt.t (** [read_invalid_blocks chain_store] returns the map of all invalid blocks of [chain_store]. *) - val read_invalid_blocks : chain_store -> invalid_block Block_hash.Map.t Lwt.t + val read_invalid_blocks : + chain_store -> invalid_block Tezos_crypto.Block_hash.Map.t Lwt.t (** [mark_invalid chain_store bh ~level errors] stores the block [bh] at [level] with the given [errors]. Fails when trying to mark the genesis block as invalid. *) val mark_invalid : chain_store -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> level:int32 -> error list -> unit tzresult Lwt.t (** [unmark_invalid chain_store bh] unmarks invalid the block [bh] in the [chain_store]. *) - val unmark_invalid : chain_store -> Block_hash.t -> unit tzresult Lwt.t + val unmark_invalid : + chain_store -> Tezos_crypto.Block_hash.t -> unit tzresult Lwt.t (** [descriptor block] returns the pair (hash x level) of [block]. *) val descriptor : block -> block_descriptor (** {3 Block field accessors} *) - val hash : block -> Block_hash.t + val hash : block -> Tezos_crypto.Block_hash.t val header : block -> Block_header.t @@ -526,30 +548,30 @@ module Block : sig val proto_level : block -> int - val predecessor : block -> Block_hash.t + val predecessor : block -> Tezos_crypto.Block_hash.t val timestamp : block -> Time.Protocol.t val validation_passes : block -> int - val operations_hash : block -> Operation_list_list_hash.t + val operations_hash : block -> Tezos_crypto.Operation_list_list_hash.t val fitness : block -> Fitness.t - val context_hash : block -> Context_hash.t + val context_hash : block -> Tezos_crypto.Context_hash.t val protocol_data : block -> bytes - val block_metadata_hash : block -> Block_metadata_hash.t option + val block_metadata_hash : block -> Tezos_crypto.Block_metadata_hash.t option val operations_metadata_hashes : - block -> Operation_metadata_hash.t list list option + block -> Tezos_crypto.Operation_metadata_hash.t list list option val operations_metadata_hashes_path : - block -> int -> Operation_metadata_hash.t list option + block -> int -> Tezos_crypto.Operation_metadata_hash.t list option val all_operations_metadata_hash : - block -> Operation_metadata_list_list_hash.t option + block -> Tezos_crypto.Operation_metadata_list_list_hash.t option (** {3 Block metadata field accessors} *) @@ -567,16 +589,21 @@ module Block : sig (** [operations_path block nth] computes the [nth] operations list of [block] along with the hash of all operations. *) val operations_path : - block -> int -> Operation.t list * Operation_list_list_hash.path + block -> + int -> + Operation.t list * Tezos_crypto.Operation_list_list_hash.path (** [operations_hashes_path block nth] computes the [nth] operations hash list of [block] along with the hash of all operations. *) val operations_hashes_path : - block -> int -> Operation_hash.t list * Operation_list_list_hash.path + block -> + int -> + Tezos_crypto.Operation_hash.t list + * Tezos_crypto.Operation_list_list_hash.path (** [all_operation_hashes block] computes the hash of all operations in [block]. *) - val all_operation_hashes : block -> Operation_hash.t list list + val all_operation_hashes : block -> Tezos_crypto.Operation_hash.t list list end (** The module for handling chain-related operations such as setting @@ -600,7 +627,7 @@ module Chain : sig val global_store : chain_store -> store (** [chain_id chain_store] returns chain id of [chain_store]. *) - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t (** [chain_dir chain_store] returns the path of directory of [chain_store].*) @@ -714,12 +741,16 @@ module Chain : sig which might happen when a new head concurrently arrives just before this operation being called. *) val set_mempool : - chain_store -> head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t + chain_store -> + head:Tezos_crypto.Block_hash.t -> + Mempool.t -> + unit tzresult Lwt.t (** [live_blocks chain_store] returns the set of previously computed live blocks for the current_head's [chain_store]. *) val live_blocks : - chain_store -> (Block_hash.Set.t * Operation_hash.Set.t) Lwt.t + chain_store -> + (Tezos_crypto.Block_hash.Set.t * Tezos_crypto.Operation_hash.Set.t) Lwt.t (** [compute_live_blocks ~block chain_store] computes the set of live blocks and live operations relative to [block]. Does nothing @@ -731,7 +762,8 @@ module Chain : sig val compute_live_blocks : chain_store -> block:Block.t -> - (Block_hash.Set.t * Operation_hash.Set.t) tzresult Lwt.t + (Tezos_crypto.Block_hash.Set.t * Tezos_crypto.Operation_hash.Set.t) tzresult + Lwt.t (** [set_head chain_store block] promotes the [block] as head of the [chain_store] and triggers an asynchronous store merge if a @@ -832,7 +864,7 @@ module Chain : sig (** [testchain_forked_block testchain] returns the hash of the forked block of its parent chain.*) - val testchain_forked_block : testchain -> Block_hash.t + val testchain_forked_block : testchain -> Tezos_crypto.Block_hash.t (** [testchain_store testchain] returns the chain store associated to this [testchain]. *) @@ -846,11 +878,11 @@ module Chain : sig registers this chain in the set of activated testchains. *) val fork_testchain : chain_store -> - testchain_id:Chain_id.t -> + testchain_id:Tezos_crypto.Chain_id.t -> forked_block:Block.t -> - genesis_hash:Block_hash.t -> + genesis_hash:Tezos_crypto.Block_hash.t -> genesis_header:Block_header.t -> - test_protocol:Protocol_hash.t -> + test_protocol:Tezos_crypto.Protocol_hash.t -> expiration:Time.Protocol.t -> testchain tzresult Lwt.t @@ -871,7 +903,9 @@ module Chain : sig (** [find_protocol chain_store ~protocol_level] returns the protocol with the level [protocol_level]. *) val find_protocol : - chain_store -> protocol_level:int -> Protocol_hash.t option Lwt.t + chain_store -> + protocol_level:int -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [all_protocol_levels chain_store] returns all the protocols registered in [chain_store]. *) @@ -890,7 +924,7 @@ module Chain : sig chain_store -> ?pred:Block.block -> ?protocol_level:int -> - Block.block * Protocol_hash.t -> + Block.block * Tezos_crypto.Protocol_hash.t -> unit tzresult Lwt.t (** [may_update_ancestor_protocol_level chain_store ~head] tries to @@ -917,8 +951,8 @@ module Chain : sig in [chain_store]. *) val set_rpc_directory : chain_store -> - protocol_hash:Protocol_hash.t -> - next_protocol_hash:Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> + next_protocol_hash:Tezos_crypto.Protocol_hash.t -> (chain_store * Block.t) Tezos_rpc.Directory.t -> unit Lwt.t @@ -926,7 +960,7 @@ module Chain : sig [callback] that may be triggered during a block store merge in order to garbage-collect old contexts. *) val register_gc_callback : - chain_store -> (Context_hash.t -> unit tzresult Lwt.t) -> unit + chain_store -> (Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t) -> unit end (** [global_block_watcher global_store] instantiates a new block @@ -938,15 +972,15 @@ val global_block_watcher : module Protocol : sig (** [mem global_store ph] checks the existence of the protocol [ph] in [global_store]. *) - val mem : store -> Protocol_hash.t -> bool + val mem : store -> Tezos_crypto.Protocol_hash.t -> bool (** [all global_store ph] returns the set of all stored protocol in [global_store]. *) - val all : store -> Protocol_hash.Set.t + val all : store -> Tezos_crypto.Protocol_hash.Set.t (** [read global_store ph] reads the protocol [ph] from the [global_store]. Returns [None] if it does not exist. *) - val read : store -> Protocol_hash.t -> Protocol.t option Lwt.t + val read : store -> Tezos_crypto.Protocol_hash.t -> Protocol.t option Lwt.t (** [store global_store ph protocol] stores the [protocol] under the hash [ph] in the [global_store]. Returns [None] if it already @@ -955,16 +989,22 @@ module Protocol : sig {b Warning} No hash check is made, the caller must be careful when storing protocols. *) val store : - store -> Protocol_hash.t -> Protocol.t -> Protocol_hash.t option Lwt.t + store -> + Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [store_raw global_store ph bytes] raw version of [store]. *) val store_raw : - store -> Protocol_hash.t -> bytes -> Protocol_hash.t option Lwt.t + store -> + Tezos_crypto.Protocol_hash.t -> + bytes -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [protocol_watcher global_store] instantiates a new protocol watcher in [global_store]. *) val protocol_watcher : - store -> Protocol_hash.t Lwt_stream.t * Lwt_watcher.stopper + store -> Tezos_crypto.Protocol_hash.t Lwt_stream.t * Lwt_watcher.stopper end (** The utility module used to traverse the chain. *) diff --git a/src/lib_store/unix/block_repr_unix.ml b/src/lib_store/unix/block_repr_unix.ml index bf9fc0c565b3..92ed377f8c88 100644 --- a/src/lib_store/unix/block_repr_unix.ml +++ b/src/lib_store/unix/block_repr_unix.ml @@ -107,7 +107,7 @@ let pread_block fd ~file_offset = let raw_pruned_block_length bytes = (* Hypothesis: (Int32.to_int total_len + 4 <= Bytes.length bytes) *) let offset = 4 in - let offset = offset + Block_hash.size (* hash *) in + let offset = offset + Tezos_crypto.Block_hash.size (* hash *) in let header_length = Bytes.get_int32_be bytes offset in let offset = offset + 4 + Int32.to_int header_length in let operations_length = Bytes.get_int32_be bytes offset in @@ -115,7 +115,7 @@ let raw_pruned_block_length bytes = let offset = (* block metadata hash *) if Bytes.get_uint8 bytes offset = 0xff then - offset + 1 + Block_metadata_hash.size + offset + 1 + Tezos_crypto.Block_metadata_hash.size else offset + 1 in let offset = @@ -137,21 +137,22 @@ let prune_raw_block_bytes bytes = let hash_offset = 4 -let header_length_offset = hash_offset + Block_hash.size +let header_length_offset = hash_offset + Tezos_crypto.Block_hash.size let level_offset = header_length_offset + 4 let predecessor_offset = level_offset + 4 (* level *) + 1 (* proto_level *) let raw_get_block_hash block_bytes = - Block_hash.of_bytes_exn (Bytes.sub block_bytes hash_offset Block_hash.size) + Tezos_crypto.Block_hash.of_bytes_exn + (Bytes.sub block_bytes hash_offset Tezos_crypto.Block_hash.size) let raw_get_block_level block_bytes = Bytes.get_int32_be block_bytes level_offset let raw_get_block_predecessor block_bytes = - Block_hash.of_bytes_exn - (Bytes.sub block_bytes predecessor_offset Block_hash.size) + Tezos_crypto.Block_hash.of_bytes_exn + (Bytes.sub block_bytes predecessor_offset Tezos_crypto.Block_hash.size) let raw_get_last_allowed_fork_level block_bytes total_block_length = let header_length = Bytes.get_int32_be block_bytes header_length_offset in @@ -167,7 +168,7 @@ let raw_get_last_allowed_fork_level block_bytes total_block_length = let operation_metadata_hashes_offset = (* block metadata hash *) if Bytes.get_uint8 block_bytes block_metadata_hash_offset = 0xff then - block_metadata_hash_offset + 1 + Block_metadata_hash.size + block_metadata_hash_offset + 1 + Tezos_crypto.Block_metadata_hash.size else block_metadata_hash_offset + 1 in let metadata_offset = diff --git a/src/lib_store/unix/block_repr_unix.mli b/src/lib_store/unix/block_repr_unix.mli index 58826411ec3d..1ee336e92f52 100644 --- a/src/lib_store/unix/block_repr_unix.mli +++ b/src/lib_store/unix/block_repr_unix.mli @@ -63,7 +63,7 @@ val prune_raw_block_bytes : bytes -> int (** [raw_get_block_hash block_buffer] introspects the hash of the block contained in [block_buffer]. *) -val raw_get_block_hash : bytes -> Block_hash.t +val raw_get_block_hash : bytes -> Tezos_crypto.Block_hash.t (** [raw_get_block_level block_buffer] introspects the level of the block contained in [block_buffer]. *) @@ -71,7 +71,7 @@ val raw_get_block_level : bytes -> int32 (** [raw_get_block_predecessor block_buffer] introspects the predecessor's hash of the block contained in [block_buffer]. *) -val raw_get_block_predecessor : bytes -> Block_hash.t +val raw_get_block_predecessor : bytes -> Tezos_crypto.Block_hash.t (** [raw_get_last_allowed_fork_level block_buffer] introspects the last allowed fork level of the block's metadata contained in diff --git a/src/lib_store/unix/block_store.ml b/src/lib_store/unix/block_store.ml index 0cf5727f284a..48bb5816615d 100644 --- a/src/lib_store/unix/block_store.ml +++ b/src/lib_store/unix/block_store.ml @@ -44,7 +44,8 @@ type block_store = { savepoint : block_descriptor Stored_data.t; status_data : status Stored_data.t; block_cache : Block_repr.t Block_lru_cache.t; - mutable gc_callback : (Context_hash.t -> unit tzresult Lwt.t) option; + mutable gc_callback : + (Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t) option; merge_mutex : Lwt_mutex.t; merge_scheduler : Lwt_idle_waiter.t; (* Target level x Merging thread *) @@ -53,7 +54,7 @@ type block_store = { type t = block_store -type key = Block of (Block_hash.t * int) +type key = Block of (Tezos_crypto.Block_hash.t * int) let status_encoding = let open Data_encoding in @@ -168,7 +169,7 @@ let compute_predecessors block_store block = | Some pred' -> loop (pred' :: predecessors_acc) pred' (dist + 1) in let predecessor = predecessor block in - if Block_hash.equal block.hash predecessor then + if Tezos_crypto.Block_hash.equal block.hash predecessor then (* genesis *) Lwt.return [block.hash] else @@ -225,7 +226,9 @@ let mem block_store key = match o with | None -> return_false | Some predecessor_hash - when Block_hash.equal block_store.genesis_block.hash predecessor_hash -> + when Tezos_crypto.Block_hash.equal + block_store.genesis_block.hash + predecessor_hash -> return_true | Some predecessor_hash -> let*! is_known_in_floating = @@ -248,8 +251,11 @@ let read_block ~read_metadata block_store key_kind = match o with | None -> return_none | Some adjusted_hash -> - if Block_hash.equal block_store.genesis_block.hash adjusted_hash then - return_some block_store.genesis_block + if + Tezos_crypto.Block_hash.equal + block_store.genesis_block.hash + adjusted_hash + then return_some block_store.genesis_block else let fetch_block adjusted_hash = (* First look in the floating stores *) @@ -290,8 +296,11 @@ let read_block_metadata block_store key_kind = match o with | None -> return_none | Some adjusted_hash -> ( - if Block_hash.equal block_store.genesis_block.hash adjusted_hash then - return (Block_repr.metadata block_store.genesis_block) + if + Tezos_crypto.Block_hash.equal + block_store.genesis_block.hash + adjusted_hash + then return (Block_repr.metadata block_store.genesis_block) else (* First look in the floating stores *) let*! o = @@ -866,7 +875,9 @@ let update_floating_stores block_store ~history_mode ~ro_store ~rw_store {stores}. cementing_highwatermark < b.lafl <= new_head_lafl HYPOTHESIS: all blocks at a given level have the same lafl. *) - let visited = ref (Block_hash.Set.singleton (Block_repr.hash lafl_block)) in + let visited = + ref (Tezos_crypto.Block_hash.Set.singleton (Block_repr.hash lafl_block)) + in let blocks_lafl = ref BlocksLAFL.empty in let*! () = Store_events.(emit start_retreiving_cycles) () in let* () = @@ -899,8 +910,8 @@ let update_floating_stores block_store ~history_mode ~ro_store ~rw_store Block_repr_unix.raw_get_block_predecessor block_bytes in let block_hash = Block_repr_unix.raw_get_block_hash block_bytes in - if Block_hash.Set.mem block_predecessor !visited then ( - visited := Block_hash.Set.add block_hash !visited ; + if Tezos_crypto.Block_hash.Set.mem block_predecessor !visited then ( + visited := Tezos_crypto.Block_hash.Set.add block_hash !visited ; let*! predecessors = let*! pred_opt = Floating_block_store.find_predecessors store block_hash @@ -1225,7 +1236,7 @@ let may_trigger_gc block_store history_mode ~previous_savepoint ~new_savepoint = let savepoint_hash = fst new_savepoint in if History_mode.(equal history_mode Archive) - || Block_hash.(savepoint_hash = fst previous_savepoint) + || Tezos_crypto.Block_hash.(savepoint_hash = fst previous_savepoint) then (* No GC required *) return_unit else match block_store.gc_callback with diff --git a/src/lib_store/unix/block_store.mli b/src/lib_store/unix/block_store.mli index c6d21cc09bed..c0ffdfe1eab5 100644 --- a/src/lib_store/unix/block_store.mli +++ b/src/lib_store/unix/block_store.mli @@ -159,7 +159,7 @@ type t = block_store A block key may represent an invalid block (wrong hash and/or offset) as it is not ensured to be valid by construction.*) -type key = Block of (Block_hash.t * int) +type key = Block of (Tezos_crypto.Block_hash.t * int) (** The status of the merging thread *) type merge_status = Not_running | Running | Merge_failed of tztrace @@ -206,7 +206,8 @@ val mem : block_store -> key -> bool tzresult Lwt.t (** [get_hash block_store key] retrieves the hash corresponding to the given [key] in [block_store]. Return [None] if the block is unknown. *) -val get_hash : block_store -> key -> Block_hash.t option tzresult Lwt.t +val get_hash : + block_store -> key -> Tezos_crypto.Block_hash.t option tzresult Lwt.t (** [read_block ~read_metadata block_store key] reads the block [key] in [block_store] if present. Return [None] if the block is @@ -339,7 +340,7 @@ val load : that may be triggered during a block store merge in order to garbage-collect old contexts. *) val register_gc_callback : - block_store -> (Context_hash.t -> unit tzresult Lwt.t) -> unit + block_store -> (Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t) -> unit (** [close block_store] closes the [block_store] and every underlying opened stores. diff --git a/src/lib_store/unix/cemented_block_store.ml b/src/lib_store/unix/cemented_block_store.ml index 25d42bfb7cdb..1fb654bcfe91 100644 --- a/src/lib_store/unix/cemented_block_store.ml +++ b/src/lib_store/unix/cemented_block_store.ml @@ -61,7 +61,8 @@ type t = { type chunk_iterator = { chunk_length : int; - reading_sequence : (Block_hash.t * int * bytes) tzresult Lwt.t Seq.t; + reading_sequence : + (Tezos_crypto.Block_hash.t * int * bytes) tzresult Lwt.t Seq.t; } let make_chunk_iterator bl = diff --git a/src/lib_store/unix/cemented_block_store.mli b/src/lib_store/unix/cemented_block_store.mli index ad6d6b70ed29..9144bb59e7e8 100644 --- a/src/lib_store/unix/cemented_block_store.mli +++ b/src/lib_store/unix/cemented_block_store.mli @@ -176,17 +176,17 @@ val find_block_file : t -> int32 -> cemented_blocks_file option (** [is_cemented cemented_store block_hash] checks if the [block_hash] is stored in the [cemented_store]. *) -val is_cemented : t -> Block_hash.t -> bool +val is_cemented : t -> Tezos_crypto.Block_hash.t -> bool (** [get_cemented_block_level cemented_store block_hash] returns the level of the [block_hash] if present in [cemented_store]. Returns [None] otherwise. *) -val get_cemented_block_level : t -> Block_hash.t -> int32 option +val get_cemented_block_level : t -> Tezos_crypto.Block_hash.t -> int32 option (** [get_cemented_block_hash cemented_store block_level] returns the hash of the block at [block_level] if present in [cemented_store]. Returns [None] otherwise. *) -val get_cemented_block_hash : t -> int32 -> Block_hash.t option +val get_cemented_block_hash : t -> int32 -> Tezos_crypto.Block_hash.t option (** [read_block_metadata cemented_store block_level] returns the metadata of the block at [block_level] if present in @@ -227,14 +227,15 @@ val get_cemented_block_by_level : val get_cemented_block_by_hash : read_metadata:bool -> t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_repr.block option tzresult Lwt.t (** The type used to describe reading sequences used to perform buffered block cementing. *) type chunk_iterator = { chunk_length : int; - reading_sequence : (Block_hash.t * int * bytes) tzresult Lwt.t Seq.t; + reading_sequence : + (Tezos_crypto.Block_hash.t * int * bytes) tzresult Lwt.t Seq.t; } (** [make_chunk_iterator bl] is an utility function that transforms a @@ -295,6 +296,6 @@ val raw_iter_cemented_file : snapshot imports. *) val check_indexes_consistency : ?post_step:(unit -> unit Lwt.t) -> - ?genesis_hash:Block_hash.t -> + ?genesis_hash:Tezos_crypto.Block_hash.t -> t -> unit tzresult Lwt.t diff --git a/src/lib_store/unix/consistency.ml b/src/lib_store/unix/consistency.ml index 64f697f8c919..a201dc1b023e 100644 --- a/src/lib_store/unix/consistency.ml +++ b/src/lib_store/unix/consistency.ml @@ -166,7 +166,9 @@ let check_consistency chain_dir genesis = let*! genesis_block = Stored_data.get genesis_data in let* () = fail_unless - (Block_hash.equal (Block_repr.hash genesis_block) genesis.Genesis.block) + (Tezos_crypto.Block_hash.equal + (Block_repr.hash genesis_block) + genesis.Genesis.block) (Inconsistent_genesis {expected = genesis.block; got = Block_repr.hash genesis_block}) in @@ -314,7 +316,7 @@ let fix_head chain_dir block_store genesis_block = cemented block known. *) if cemented_block_files <> [] - && Block_hash.equal + && Tezos_crypto.Block_hash.equal (Block_repr.hash genesis_block) (Block_repr.hash floating_head) then @@ -738,7 +740,7 @@ let check_block_protocol_hash context_index ~expected block = protect @@ fun () -> let*! ctxt = Context.checkout_exn context_index (Block_repr.context block) in let*! got = Context.get_protocol ctxt in - return Protocol_hash.(got = expected) + return Tezos_crypto.Protocol_hash.(got = expected) (** Look into the cemented store for the lowest block with an associated proto level that is above the savepoint. *) @@ -1102,7 +1104,7 @@ let fix_chain_state chain_dir block_store ~head ~cementing_highwatermark let* () = Stored_data.write_file (Naming.invalid_blocks_file chain_dir) - Block_hash.Map.empty + Tezos_crypto.Block_hash.Map.empty in let* () = Stored_data.write_file (Naming.forked_chains_file chain_dir) forked_chains @@ -1143,12 +1145,12 @@ let infer_history_mode chain_dir block_store genesis caboose savepoint = in let history_mode = (* Caboose is not genesis: we sure are in rolling*) - if not (Block_hash.equal (fst caboose) genesis.Genesis.block) then - History_mode.Rolling offset + if not (Tezos_crypto.Block_hash.equal (fst caboose) genesis.Genesis.block) + then History_mode.Rolling offset else if (* Caboose is genesis and savepoint is not genesis: we can be in both rolling and full. We choose full as the less destructive. *) - not (Block_hash.equal (fst savepoint) genesis.block) + not (Tezos_crypto.Block_hash.equal (fst savepoint) genesis.block) then Full offset else if (* Caboose is genesis and savepoint is genesis and there are as @@ -1271,7 +1273,7 @@ let fix_consistency ?history_mode chain_dir context_index genesis = ~savepoint ~caboose ~alternate_heads:[] - ~forked_chains:Chain_id.Map.empty + ~forked_chains:Tezos_crypto.Chain_id.Map.empty ~protocol_levels ~chain_config ~genesis diff --git a/src/lib_store/unix/floating_block_index.ml b/src/lib_store/unix/floating_block_index.ml index 67735faa0e59..b3c7113f4375 100644 --- a/src/lib_store/unix/floating_block_index.ml +++ b/src/lib_store/unix/floating_block_index.ml @@ -27,19 +27,19 @@ time: if a block has fewer than 12 predecessors then it is padded so its size remain constant. *) module Block_info = struct - type t = {offset : int; predecessors : Block_hash.t list} + type t = {offset : int; predecessors : Tezos_crypto.Block_hash.t list} let max_predecessors = 12 let encoded_list_size = - let r = max_predecessors * Block_hash.size (* uint16 *) in + let r = max_predecessors * Tezos_crypto.Block_hash.size (* uint16 *) in assert (r < 1 lsl 16) ; r let encoded_size = 8 + 1 + encoded_list_size (* Format: - (8) + (1) + (list_size * Block_hash.size) *) + (8) + (1) + (list_size * Tezos_crypto.Block_hash.size) *) let t = let open Repr in @@ -58,11 +58,11 @@ module Block_info = struct (fun i h -> (* Start reading after the (8) + (1) *) Bytes.blit - (Block_hash.to_bytes h) + (Tezos_crypto.Block_hash.to_bytes h) 0 bytes - (8 + 1 + (i * Block_hash.size)) - Block_hash.size) + (8 + 1 + (i * Tezos_crypto.Block_hash.size)) + Tezos_crypto.Block_hash.size) v.predecessors ; Bytes.unsafe_to_string bytes @@ -80,13 +80,13 @@ module Block_info = struct current_offset := !current_offset + 1 ; let predecessors = ref [] in let limit = !current_offset in - current_offset := limit + ((list_size - 1) * Block_hash.size) ; + current_offset := limit + ((list_size - 1) * Tezos_crypto.Block_hash.size) ; while !current_offset >= limit do predecessors := - (String.sub str !current_offset Block_hash.size - |> Block_hash.of_string_exn) + (String.sub str !current_offset Tezos_crypto.Block_hash.size + |> Tezos_crypto.Block_hash.of_string_exn) :: !predecessors ; - current_offset := !current_offset - Block_hash.size + current_offset := !current_offset - Tezos_crypto.Block_hash.size done ; {offset; predecessors = !predecessors} @@ -96,7 +96,9 @@ module Block_info = struct fmt "@[offset: %d, predecessors : [ @[%a @]]@]" v.offset - (pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt " ;@,") Block_hash.pp) + (pp_print_list + ~pp_sep:(fun fmt () -> fprintf fmt " ;@,") + Tezos_crypto.Block_hash.pp) v.predecessors end diff --git a/src/lib_store/unix/floating_block_index.mli b/src/lib_store/unix/floating_block_index.mli index 17b9afa5f040..3645bf29508f 100644 --- a/src/lib_store/unix/floating_block_index.mli +++ b/src/lib_store/unix/floating_block_index.mli @@ -37,7 +37,8 @@ module Block_info : sig (** The type for storing the block's info. *) type t = { offset : int; (** offset in the file *) - predecessors : Block_hash.t list; (** predecessors of the block *) + predecessors : Tezos_crypto.Block_hash.t list; + (** predecessors of the block *) } (** Pretty-printer for {!t} *) @@ -45,5 +46,8 @@ module Block_info : sig end (** Key/value index associated to a floating block store where the key - is a {!Block_hash.t} and the value is {!Block_info.t}. *) -include Index.S with type key = Block_hash.t and type value = Block_info.t + is a {!Tezos_crypto.Block_hash.t} and the value is {!Block_info.t}. *) +include + Index.S + with type key = Tezos_crypto.Block_hash.t + and type value = Block_info.t diff --git a/src/lib_store/unix/floating_block_store.ml b/src/lib_store/unix/floating_block_store.ml index 4917c7e4f3b4..a648198d2c37 100644 --- a/src/lib_store/unix/floating_block_store.ml +++ b/src/lib_store/unix/floating_block_store.ml @@ -128,7 +128,7 @@ let append_block ?(flush = true) ?(log_metrics = false) floating_store return_unit) let append_all floating_store - (blocks : (Block_hash.t list * Block_repr.t) Seq.t) = + (blocks : (Tezos_crypto.Block_hash.t list * Block_repr.t) Seq.t) = let open Lwt_result_syntax in Lwt_idle_waiter.force_idle floating_store.scheduler (fun () -> let*! eof_offset = Lwt_unix.lseek floating_store.fd 0 Unix.SEEK_END in diff --git a/src/lib_store/unix/floating_block_store.mli b/src/lib_store/unix/floating_block_store.mli index 4425e89b121c..0d4c04056763 100644 --- a/src/lib_store/unix/floating_block_store.mli +++ b/src/lib_store/unix/floating_block_store.mli @@ -27,7 +27,7 @@ The floating block store is an append-only store where blocks are stored arbitrarily. This structure possess an indexed map - {!Block_hash.t} -> (offset × predecessors) which points to its + {!Tezos_crypto.Block_hash.t} -> (offset × predecessors) which points to its offset in the associated file along with an exponential list of predecessors block hashes (as implemented in {!Block_store.compute_predecessors}). The structure @@ -77,23 +77,26 @@ val kind : t -> floating_kind (** [mem floating_store hash] tests whether [hash] is stored in [floating_store]. *) -val mem : t -> Block_hash.t -> bool Lwt.t +val mem : t -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [find_predecessors floating_store block_hash] reads from the index the list of [block_hash]'s predecessors if the block is stored in [floating_store], returns [None] otherwise. *) -val find_predecessors : t -> Block_hash.t -> Block_hash.t list option Lwt.t +val find_predecessors : + t -> Tezos_crypto.Block_hash.t -> Tezos_crypto.Block_hash.t list option Lwt.t (** [read_block floating_store hash] reads from the file the block of [hash] if the block is stored in [floating_store], returns [None] otherwise. *) -val read_block : t -> Block_hash.t -> Block_repr.t option Lwt.t +val read_block : t -> Tezos_crypto.Block_hash.t -> Block_repr.t option Lwt.t (** [read_block_and_predecessors floating_store hash] same as [read_block] but also returns the block's predecessors. Returns [None] if it fails to resolve the given [hash].*) val read_block_and_predecessors : - t -> Block_hash.t -> (Block_repr.t * Block_hash.t list) option Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + (Block_repr.t * Tezos_crypto.Block_hash.t list) option Lwt.t (** [append_block floating_store ?flush preds block] stores the [block] in [floating_store] updating its index with the given @@ -104,7 +107,7 @@ val append_block : ?flush:bool -> ?log_metrics:bool -> t -> - Block_hash.t trace -> + Tezos_crypto.Block_hash.t trace -> Block_repr.block -> unit tzresult Lwt.t @@ -112,7 +115,9 @@ val append_block : (predecessors × blocks) in [floating_store] updating its index accordingly. *) val append_all : - t -> (Block_hash.t list * Block_repr.t) Seq.t -> unit tzresult Lwt.t + t -> + (Tezos_crypto.Block_hash.t list * Block_repr.t) Seq.t -> + unit tzresult Lwt.t (** [iter_s_raw_fd f fd] unsafe sequential iterator on a file descriptor [fd]. Applies [f] on every block encountered. @@ -134,7 +139,7 @@ val fold_left_s : element. The function [f] is given the last read block along with its predecessors. *) val fold_left_with_pred_s : - ('a -> Block_repr.block * Block_hash.t list -> 'a tzresult Lwt.t) -> + ('a -> Block_repr.block * Tezos_crypto.Block_hash.t list -> 'a tzresult Lwt.t) -> 'a -> t -> 'a tzresult Lwt.t @@ -147,7 +152,7 @@ val iter_s : (Block_repr.t -> unit tzresult Lwt.t) -> t -> unit tzresult Lwt.t [floating_store]. Applies [f] on every block with its predecessors read. *) val iter_with_pred_s : - (Block_repr.t * Block_hash.t list -> unit tzresult Lwt.t) -> + (Block_repr.t * Tezos_crypto.Block_hash.t list -> unit tzresult Lwt.t) -> t -> unit tzresult Lwt.t @@ -198,14 +203,16 @@ val fix_integrity : appends a block with its [hash] in [dst_store] contained in the [buffer]. *) val raw_append : - t -> Block_hash.t * bytes * int * Block_hash.t list -> unit tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t * bytes * int * Tezos_crypto.Block_hash.t list -> + unit tzresult Lwt.t (** [raw_copy_all src_stores block_hashes dst_store] retrieves [block_hashes] from [src_stores] and copy them (without decoding) to [dst_store] with a buffering mechanism. *) val raw_copy_all : src_floating_stores:t list -> - block_hashes:Block_hash.t list -> + block_hashes:Tezos_crypto.Block_hash.t list -> dst_floating_store:t -> unit tzresult Lwt.t @@ -222,8 +229,8 @@ val raw_copy_all : during the iteration. *) val raw_retrieve_blocks_seq : src_floating_stores:t list -> - block_hashes:Block_hash.t list -> - (Block_hash.t * int * bytes) tzresult Lwt.t Seq.t + block_hashes:Tezos_crypto.Block_hash.t list -> + (Tezos_crypto.Block_hash.t * int * bytes) tzresult Lwt.t Seq.t (** [raw_iterate f store] iterate over all blocks in a store and calling [f] providing it with a [buffer] and the diff --git a/src/lib_store/unix/protocol_store.ml b/src/lib_store/unix/protocol_store.ml index a094ef4919db..edd4706cf9be 100644 --- a/src/lib_store/unix/protocol_store.ml +++ b/src/lib_store/unix/protocol_store.ml @@ -25,10 +25,11 @@ type t = { protocol_store_dir : [`Protocol_dir] Naming.directory; - mutable protocols : Protocol_hash.Set.t; + mutable protocols : Tezos_crypto.Protocol_hash.Set.t; } -let mem t protocol_hash = Protocol_hash.Set.mem protocol_hash t.protocols +let mem t protocol_hash = + Tezos_crypto.Protocol_hash.Set.mem protocol_hash t.protocols let all {protocols; _} = protocols @@ -47,7 +48,8 @@ let raw_store store protocol_hash bytes = in let* () = Lwt_utils_unix.write_bytes fd bytes in let* _ = Lwt_utils_unix.safe_close fd in - store.protocols <- Protocol_hash.Set.add protocol_hash store.protocols ; + store.protocols <- + Tezos_crypto.Protocol_hash.Set.add protocol_hash store.protocols ; Lwt.return_some protocol_hash let store store protocol_hash protocol = @@ -78,11 +80,12 @@ let init store_dir = Lwt.try_bind (fun () -> Lwt_unix.readdir dir) (fun file -> - match Protocol_hash.of_b58check_opt file with - | Some protocol_hash -> loop (Protocol_hash.Set.add protocol_hash set) + match Tezos_crypto.Protocol_hash.of_b58check_opt file with + | Some protocol_hash -> + loop (Tezos_crypto.Protocol_hash.Set.add protocol_hash set) | None -> loop set) (function End_of_file -> Lwt.return set | _ -> loop set) in - let* protocols = loop Protocol_hash.Set.empty in + let* protocols = loop Tezos_crypto.Protocol_hash.Set.empty in let* () = Lwt_unix.closedir dir in Lwt.return {protocol_store_dir; protocols} diff --git a/src/lib_store/unix/protocol_store.mli b/src/lib_store/unix/protocol_store.mli index c8d281e5e33e..505203ee6bac 100644 --- a/src/lib_store/unix/protocol_store.mli +++ b/src/lib_store/unix/protocol_store.mli @@ -30,25 +30,33 @@ type t (** [mem pstore proto_hash] tests the existence of the protocol indexed by [proto_hash] in the store. *) -val mem : t -> Protocol_hash.t -> bool +val mem : t -> Tezos_crypto.Protocol_hash.t -> bool (** [all pstore] returns the set of all stored protocols in [pstore]. *) -val all : t -> Protocol_hash.Set.t +val all : t -> Tezos_crypto.Protocol_hash.Set.t (** [raw_store pstore proto_hash proto_bytes] stores on disk the protocol [proto_bytes] (encoded bytes) indexed as [proto_hash]. Returns [None] if the protocol already exists. *) -val raw_store : t -> Protocol_hash.t -> bytes -> Protocol_hash.t option Lwt.t +val raw_store : + t -> + Tezos_crypto.Protocol_hash.t -> + bytes -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [store pstore proto_hash protocol] stores on disk the protocol [protocol] indexed as [proto_hash]. Returns [None] if the protocol already exists. *) -val store : t -> Protocol_hash.t -> Protocol.t -> Protocol_hash.t option Lwt.t +val store : + t -> + Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [read pstore proto_hash] reads from [pstore] and returns the protocol indexed by [proto_hash]. Returns [None] if the protocol cannot be read. *) -val read : t -> Protocol_hash.t -> Protocol.t option Lwt.t +val read : t -> Tezos_crypto.Protocol_hash.t -> Protocol.t option Lwt.t (** [init store_dir] creates a store relatively to [store_dir] path or loads it if it already exists. *) diff --git a/src/lib_store/unix/reconstruction.ml b/src/lib_store/unix/reconstruction.ml index e7419926917b..8dae68df1add 100644 --- a/src/lib_store/unix/reconstruction.ml +++ b/src/lib_store/unix/reconstruction.ml @@ -25,8 +25,9 @@ type failure_kind = | Nothing_to_reconstruct - | Context_hash_mismatch of Block_header.t * Context_hash.t * Context_hash.t - | Cannot_read_block_hash of Block_hash.t + | Context_hash_mismatch of + Block_header.t * Tezos_crypto.Context_hash.t * Tezos_crypto.Context_hash.t + | Cannot_read_block_hash of Tezos_crypto.Block_hash.t | Cannot_read_block_level of Int32.t let failure_kind_encoding = @@ -44,15 +45,15 @@ let failure_kind_encoding = ~title:"context_hash_mismatch" (obj3 (req "block_header" Block_header.encoding) - (req "expected" Context_hash.encoding) - (req "got" Context_hash.encoding)) + (req "expected" Tezos_crypto.Context_hash.encoding) + (req "got" Tezos_crypto.Context_hash.encoding)) (function | Context_hash_mismatch (h, e, g) -> Some (h, e, g) | _ -> None) (fun (h, e, g) -> Context_hash_mismatch (h, e, g)); case (Tag 2) ~title:"cannot_read_block_hash" - Block_hash.encoding + Tezos_crypto.Block_hash.encoding (function Cannot_read_block_hash h -> Some h | _ -> None) (fun h -> Cannot_read_block_hash h); case @@ -70,15 +71,19 @@ let failure_kind_pp ppf = function ppf "resulting context hash for block %a (level %ld) does not match. \ Context hash expected %a, got %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash h) h.shell.level - Context_hash.pp + Tezos_crypto.Context_hash.pp e - Context_hash.pp + Tezos_crypto.Context_hash.pp g | Cannot_read_block_hash h -> - Format.fprintf ppf "Unexpected missing block in store: %a" Block_hash.pp h + Format.fprintf + ppf + "Unexpected missing block in store: %a" + Tezos_crypto.Block_hash.pp + h | Cannot_read_block_level l -> Format.fprintf ppf "Unexpected missing block in store at level %ld" l @@ -160,13 +165,13 @@ let check_context_hash_consistency block_validation_result block_header = let expected = block_header.Block_header.shell.context in let got = block_validation_result.Block_validation.context_hash in fail_unless - (Context_hash.equal expected got) + (Tezos_crypto.Context_hash.equal expected got) (Reconstruction_failure (Context_hash_mismatch (block_header, expected, got))) (* We assume that the given list is not empty. *) let compute_block_metadata_hash block_metadata = - Some (Block_metadata_hash.hash_bytes [block_metadata]) + Some (Tezos_crypto.Block_metadata_hash.hash_bytes [block_metadata]) let split_operations_metadata = function | Block_validation.No_metadata_hash metadata -> (metadata, None) @@ -186,8 +191,8 @@ let compute_all_operations_metadata_hash block = else Option.map (fun ll -> - Operation_metadata_list_list_hash.compute - (List.map Operation_metadata_list_hash.compute ll)) + Tezos_crypto.Operation_metadata_list_list_hash.compute + (List.map Tezos_crypto.Operation_metadata_list_hash.compute ll)) (Block_repr.operations_metadata_hashes block) let apply_context context_index chain_id ~user_activated_upgrades diff --git a/src/lib_store/unix/reconstruction.mli b/src/lib_store/unix/reconstruction.mli index 05a3b296ca49..e55f0cac4a09 100644 --- a/src/lib_store/unix/reconstruction.mli +++ b/src/lib_store/unix/reconstruction.mli @@ -53,8 +53,9 @@ type failure_kind = | Nothing_to_reconstruct - | Context_hash_mismatch of Block_header.t * Context_hash.t * Context_hash.t - | Cannot_read_block_hash of Block_hash.t + | Context_hash_mismatch of + Block_header.t * Tezos_crypto.Context_hash.t * Tezos_crypto.Context_hash.t + | Cannot_read_block_hash of Tezos_crypto.Block_hash.t | Cannot_read_block_level of Int32.t type error += Reconstruction_failure of failure_kind diff --git a/src/lib_store/unix/snapshots.ml b/src/lib_store/unix/snapshots.ml index 5ef5af218b7f..5093fe7f15c5 100644 --- a/src/lib_store/unix/snapshots.ml +++ b/src/lib_store/unix/snapshots.ml @@ -32,7 +32,7 @@ type error += stored : History_mode.t; } | Invalid_export_block of { - block : Block_hash.t option; + block : Tezos_crypto.Block_hash.t option; reason : [ `Pruned | `Pruned_pred @@ -45,15 +45,15 @@ type error += | Invalid_export_path of string | Snapshot_file_not_found of string | Inconsistent_protocol_hash of { - expected : Protocol_hash.t; - got : Protocol_hash.t; + expected : Tezos_crypto.Protocol_hash.t; + got : Tezos_crypto.Protocol_hash.t; } | Inconsistent_context_hash of { - expected : Context_hash.t; - got : Context_hash.t; + expected : Tezos_crypto.Context_hash.t; + got : Tezos_crypto.Context_hash.t; } - | Inconsistent_context of Context_hash.t - | Cannot_decode_protocol of Protocol_hash.t + | Inconsistent_context of Tezos_crypto.Context_hash.t + | Cannot_decode_protocol of Tezos_crypto.Protocol_hash.t | Cannot_write_metadata of string | Cannot_read of { kind : @@ -74,7 +74,7 @@ type error += | Missing_cemented_file of string | Corrupted_floating_store | Invalid_protocol_file of string - | Target_block_validation_failed of Block_hash.t * string + | Target_block_validation_failed of Tezos_crypto.Block_hash.t * string | Directory_already_exists of string | Empty_floating_store | Cannot_remove_tmp_export_directory of string @@ -87,9 +87,10 @@ type error += requested : History_mode.t; stored : History_mode.t; } - | Inconsistent_imported_block of Block_hash.t * Block_hash.t + | Inconsistent_imported_block of + Tezos_crypto.Block_hash.t * Tezos_crypto.Block_hash.t | Wrong_snapshot_file of {filename : string} - | Invalid_chain_store_export of Chain_id.t * string + | Invalid_chain_store_export of Tezos_crypto.Chain_id.t * string let () = let open Data_encoding in @@ -127,7 +128,7 @@ let () = "The selected block %a is invalid: %s." (Format.pp_print_option ~none:(fun fmt () -> Format.fprintf fmt "(n/a)") - Block_hash.pp) + Tezos_crypto.Block_hash.pp) hash (match reason with | `Pruned -> "the block is too old and has been pruned" @@ -138,7 +139,7 @@ let () = | `Caboose -> "the caboose block is not a valid export point" | `Not_enough_pred -> "not enough of the block's predecessors are known")) (obj2 - (opt "block" Block_hash.encoding) + (opt "block" Tezos_crypto.Block_hash.encoding) (req "reason" (string_enum @@ -186,13 +187,13 @@ let () = Format.fprintf ppf "Inconsistent protocol_hash. Expected: %a, got %a." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp oph - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp oph') (obj2 - (req "expected" Protocol_hash.encoding) - (req "got" Protocol_hash.encoding)) + (req "expected" Tezos_crypto.Protocol_hash.encoding) + (req "got" Tezos_crypto.Protocol_hash.encoding)) (function | Inconsistent_protocol_hash {expected; got} -> Some (expected, got) | _ -> None) @@ -206,13 +207,13 @@ let () = Format.fprintf ppf "Inconsistent context_hash. Expected: %a, got %a." - Context_hash.pp + Tezos_crypto.Context_hash.pp oph - Context_hash.pp + Tezos_crypto.Context_hash.pp oph') (obj2 - (req "expected" Context_hash.encoding) - (req "got" Context_hash.encoding)) + (req "expected" Tezos_crypto.Context_hash.encoding) + (req "got" Tezos_crypto.Context_hash.encoding)) (function | Inconsistent_context_hash {expected; got} -> Some (expected, got) | _ -> None) @@ -226,9 +227,9 @@ let () = Format.fprintf ppf "Failed to checkout context %a after restoring it." - Context_hash.pp + Tezos_crypto.Context_hash.pp h) - (obj1 (req "context_hash" Context_hash.encoding)) + (obj1 (req "context_hash" Tezos_crypto.Context_hash.encoding)) (function Inconsistent_context h -> Some h | _ -> None) (fun h -> Inconsistent_context h) ; register_error_kind @@ -240,9 +241,9 @@ let () = Format.fprintf ppf "Cannot decode the protocol in file: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp hash) - (obj1 (req "filename" Protocol_hash.encoding)) + (obj1 (req "filename" Tezos_crypto.Protocol_hash.encoding)) (function Cannot_decode_protocol hash -> Some hash | _ -> None) (fun hash -> Cannot_decode_protocol hash) ; register_error_kind @@ -407,8 +408,13 @@ let () = ~title:"target block validation failed" ~description:"Failed to validate the target block." ~pp:(fun ppf (h, errs) -> - Format.fprintf ppf "Failed to validate block %a: %s" Block_hash.pp h errs) - (obj2 (req "block" Block_hash.encoding) (req "errors" string)) + Format.fprintf + ppf + "Failed to validate block %a: %s" + Tezos_crypto.Block_hash.pp + h + errs) + (obj2 (req "block" Tezos_crypto.Block_hash.encoding) (req "errors" string)) (function | Target_block_validation_failed (h, errs) -> Some (h, errs) | _ -> None) (fun (h, errs) -> Target_block_validation_failed (h, errs)) ; @@ -532,13 +538,13 @@ let () = Format.fprintf ppf "The block contained in the file is %a instead of %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp got - Block_hash.pp + Tezos_crypto.Block_hash.pp exp) (obj2 - (req "block_hash" Block_hash.encoding) - (req "block_hash_expected" Block_hash.encoding)) + (req "block_hash" Tezos_crypto.Block_hash.encoding) + (req "block_hash_expected" Tezos_crypto.Block_hash.encoding)) (function | Inconsistent_imported_block (got, exp) -> Some (got, exp) | _ -> None) (fun (got, exp) -> Inconsistent_imported_block (got, exp)) ; @@ -566,11 +572,13 @@ let () = ppf "Failed to export snapshot. Cannot find chain %a from store located at \ directory %s." - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id store_dir) Data_encoding.( - obj2 (req "chain_id" Chain_id.encoding) (req "store_dir" string)) + obj2 + (req "chain_id" Tezos_crypto.Chain_id.encoding) + (req "store_dir" string)) (function | Invalid_chain_store_export (chain_id, store_dir) -> Some (chain_id, store_dir) @@ -626,7 +634,7 @@ let default_index_log_size = 30_000_000 type metadata = { chain_name : Distributed_db_version.Name.t; history_mode : History_mode.t; - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; level : Int32.t; timestamp : Time.Protocol.t; context_elements : int; @@ -654,7 +662,7 @@ let metadata_encoding = (obj6 (req "chain_name" Distributed_db_version.Name.encoding) (req "mode" History_mode.encoding) - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "level" int32) (req "timestamp" Time.Protocol.encoding) (req "context_elements" int31)) @@ -676,7 +684,7 @@ let pp_snapshot_header ppf = function version %d)" Distributed_db_version.Name.pp chain_name - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash level Time.Protocol.pp_hum @@ -704,8 +712,9 @@ type block_data = { block_header : Block_header.t; operations : Operation.t list list; predecessor_header : Block_header.t; - predecessor_block_metadata_hash : Block_metadata_hash.t option; - predecessor_ops_metadata_hash : Operation_metadata_list_list_hash.t option; + predecessor_block_metadata_hash : Tezos_crypto.Block_metadata_hash.t option; + predecessor_ops_metadata_hash : + Tezos_crypto.Operation_metadata_list_list_hash.t option; } let block_data_encoding = @@ -739,10 +748,12 @@ let block_data_encoding = (req "operations" (list (list (dynamic_size Operation.encoding)))) (req "block_header" (dynamic_size Block_header.encoding)) (req "predecessor_header" (dynamic_size Block_header.encoding)) - (opt "predecessor_block_metadata_hash" Block_metadata_hash.encoding) + (opt + "predecessor_block_metadata_hash" + Tezos_crypto.Block_metadata_hash.encoding) (opt "predecessor_ops_metadata_hash" - Operation_metadata_list_list_hash.encoding)) + Tezos_crypto.Operation_metadata_list_list_hash.encoding)) let default_snapshot_filename metadata = let {chain_name; block_hash; level; history_mode; _} = metadata in @@ -753,7 +764,7 @@ let default_snapshot_filename metadata = "%a-%a-%ld.%a" Distributed_db_version.Name.pp chain_name - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash level History_mode.pp_short @@ -1318,15 +1329,16 @@ module type EXPORTER = sig val write_block_data : t -> predecessor_header:Block_header.t -> - predecessor_block_metadata_hash:Block_metadata_hash.t option -> - predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> + predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> + predecessor_ops_metadata_hash: + Tezos_crypto.Operation_metadata_list_list_hash.t option -> export_block:Store.Block.t -> unit Lwt.t val dump_context : t -> Context.index -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> on_disk:bool -> Animation.progress_display_mode -> int tzresult Lwt.t @@ -1349,7 +1361,8 @@ module type EXPORTER = sig val write_protocols_table : t -> f:(Lwt_unix.file_descr -> 'a Lwt.t) -> 'a Lwt.t - val copy_protocol : t -> src:string -> dst_ph:Protocol_hash.t -> unit Lwt.t + val copy_protocol : + t -> src:string -> dst_ph:Tezos_crypto.Protocol_hash.t -> unit Lwt.t val write_metadata : t -> metadata -> unit tzresult Lwt.t @@ -1789,7 +1802,7 @@ module Tar_exporter : EXPORTER = struct Filename.( concat (Naming.dir_path t.snapshot_protocol_dir) - (Protocol_hash.to_b58check dst_ph)) + (Tezos_crypto.Protocol_hash.to_b58check dst_ph)) in Onthefly.add_file_and_finalize t.tar ~file:src ~filename:dst @@ -1963,7 +1976,8 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct (* FIXME: we also write potential branches, it will eventually be GCed *) if Compare.Int32.(Block_repr.level block >= limit_level) then - if Block_hash.equal limit_hash (Block_repr.hash block) then raise Done + if Tezos_crypto.Block_hash.equal limit_hash (Block_repr.hash block) + then raise Done else return_unit else let block = (* Prune everything *) {block with metadata = None} in @@ -2034,7 +2048,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct || filename = Filename.parent_dir_name -> copy_protocols () | filename -> ( - match Protocol_hash.of_b58check_opt filename with + match Tezos_crypto.Protocol_hash.of_b58check_opt filename with | None -> return_ok_unit | Some ph -> let src_protocol_file = @@ -2042,7 +2056,10 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct in let* () = if - List.mem ~equal:Protocol_hash.equal ph proto_to_export + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + ph + proto_to_export then let* () = Exporter.copy_protocol @@ -2496,7 +2513,7 @@ module Make_snapshot_exporter (Exporter : EXPORTER) : Snapshot_exporter = struct let export ?snapshot_path ?(rolling = false) ~block ~store_dir ~context_dir ~chain_name ~on_disk ~progress_display_mode genesis = let open Lwt_result_syntax in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let* () = ensure_valid_export_chain_dir store_dir chain_id in let* snapshot_exporter = init snapshot_path in (* Register a clean up callback to prevent export cancellation not @@ -2740,7 +2757,7 @@ module type IMPORTER = sig val init : snapshot_path:string -> dst_store_dir:[`Store_dir] Naming.directory -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> t Lwt.t val load_snapshot_header : t -> header tzresult Lwt.t @@ -2750,7 +2767,7 @@ module type IMPORTER = sig val restore_context : t -> Context.index -> - expected_context_hash:Context_hash.t -> + expected_context_hash:Tezos_crypto.Context_hash.t -> nb_context_elements:int -> legacy:bool -> in_memory:bool -> @@ -2761,10 +2778,12 @@ module type IMPORTER = sig t -> Protocol_levels.activation_block Protocol_levels.t tzresult Lwt.t val load_and_validate_protocol_filenames : - t -> Protocol_hash.t list tzresult Lwt.t + t -> Tezos_crypto.Protocol_hash.t list tzresult Lwt.t val copy_and_validate_protocol : - t -> protocol_hash:Protocol_hash.t -> (unit, error trace) result Lwt.t + t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> + (unit, error trace) result Lwt.t val restore_cemented_indexes : t -> unit Lwt.t @@ -2774,7 +2793,7 @@ module type IMPORTER = sig val restore_floating_blocks : t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> (unit tzresult Lwt.t * Block_repr.block Lwt_stream.t) tzresult Lwt.t val close : t -> unit Lwt.t @@ -2906,7 +2925,7 @@ module Raw_importer : IMPORTER = struct in List.map_es (fun file -> - match Protocol_hash.of_b58check_opt file with + match Tezos_crypto.Protocol_hash.of_b58check_opt file with | Some ph -> return ph | None -> tzfail (Invalid_protocol_file file)) protocol_files @@ -2916,12 +2935,12 @@ module Raw_importer : IMPORTER = struct let src = Filename.concat (Naming.dir_path t.snapshot_protocol_dir) - (Protocol_hash.to_b58check protocol_hash) + (Tezos_crypto.Protocol_hash.to_b58check protocol_hash) in let dst = Filename.concat (Naming.dir_path t.dst_protocol_dir) - (Protocol_hash.to_b58check protocol_hash) + (Tezos_crypto.Protocol_hash.to_b58check protocol_hash) in let*! () = Lwt_utils_unix.copy_file ~src ~dst in let*! protocol_sources = Lwt_utils_unix.read_file dst in @@ -2930,7 +2949,7 @@ module Raw_importer : IMPORTER = struct | Some p -> let hash = Protocol.hash p in fail_unless - (Protocol_hash.equal protocol_hash hash) + (Tezos_crypto.Protocol_hash.equal protocol_hash hash) (Inconsistent_protocol_hash {expected = protocol_hash; got = hash}) let restore_cemented_indexes t = @@ -3166,7 +3185,7 @@ module Tar_importer : IMPORTER = struct in List.map_es (fun file -> - match Protocol_hash.of_b58check_opt file with + match Tezos_crypto.Protocol_hash.of_b58check_opt file with | Some ph -> return ph | None -> tzfail (Invalid_protocol_file file)) protocol_files @@ -3177,7 +3196,7 @@ module Tar_importer : IMPORTER = struct Filename.( concat Naming.(protocol_store_dir t.snapshot_tar |> dir_path) - (Protocol_hash.to_b58check protocol_hash)) + (Tezos_crypto.Protocol_hash.to_b58check protocol_hash)) in let* file = let*! o = Onthefly.get_file t.tar ~filename:src in @@ -3189,7 +3208,7 @@ module Tar_importer : IMPORTER = struct Filename.( concat (Naming.dir_path t.dst_protocol_dir) - (Protocol_hash.to_b58check protocol_hash)) + (Tezos_crypto.Protocol_hash.to_b58check protocol_hash)) in let*! () = Onthefly.copy_to_file t.tar file ~dst in let*! protocol_sources = Lwt_utils_unix.read_file dst in @@ -3198,7 +3217,7 @@ module Tar_importer : IMPORTER = struct | Some p -> let hash = Protocol.hash p in fail_unless - (Protocol_hash.equal protocol_hash hash) + (Tezos_crypto.Protocol_hash.equal protocol_hash hash) (Inconsistent_protocol_hash {expected = protocol_hash; got = hash}) let restore_cemented_indexes t = @@ -3337,7 +3356,7 @@ module type Snapshot_importer = sig ?patch_context: (Tezos_protocol_environment.Context.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t) -> - ?block:Block_hash.t -> + ?block:Tezos_crypto.Block_hash.t -> ?check_consistency:bool -> dst_store_dir:[`Store_dir] Naming.directory -> dst_context_dir:string -> @@ -3485,7 +3504,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct let check_context_hash_consistency validation_store block_header = fail_unless - (Context_hash.equal + (Tezos_crypto.Context_hash.equal validation_store.Tezos_validation.Block_validation.context_hash block_header.Block_header.shell.context) (Inconsistent_context_hash @@ -3523,7 +3542,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct match user_expected_block with | Some bh -> fail_unless - (Block_hash.equal bh block_header_hash) + (Tezos_crypto.Block_hash.equal bh block_header_hash) (Inconsistent_imported_block (block_header_hash, bh)) | None -> return_unit in @@ -3531,7 +3550,9 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct expected one *) let* () = fail_unless - (Block_hash.equal snapshot_metadata.block_hash block_header_hash) + (Tezos_crypto.Block_hash.equal + snapshot_metadata.block_hash + block_header_hash) (Inconsistent_imported_block (block_header_hash, snapshot_metadata.block_hash)) in @@ -3605,7 +3626,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct ~user_activated_protocol_overrides ~operation_metadata_size_limit ~in_memory ~progress_display_mode (genesis : Genesis.t) = let open Lwt_result_syntax in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let*! snapshot_importer = init ~snapshot_path ~dst_store_dir chain_id in let dst_store_dir = Naming.dir_path dst_store_dir in let* () = @@ -3615,7 +3636,7 @@ module Make_snapshot_importer (Importer : IMPORTER) : Snapshot_importer = struct in let dst_store_dir = Naming.store_dir ~dir_path:dst_store_dir in let dst_protocol_dir = Naming.protocol_store_dir dst_store_dir in - let chain_id = Chain_id.of_block_hash genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.block in let dst_chain_dir = Naming.chain_dir dst_store_dir chain_id in let dst_cemented_dir = Naming.cemented_blocks_dir dst_chain_dir in (* Create directories *) diff --git a/src/lib_store/unix/snapshots.mli b/src/lib_store/unix/snapshots.mli index 2642e94fd20c..5f4f2d38de11 100644 --- a/src/lib_store/unix/snapshots.mli +++ b/src/lib_store/unix/snapshots.mli @@ -86,7 +86,7 @@ type error += stored : History_mode.t; } | Invalid_export_block of { - block : Block_hash.t option; + block : Tezos_crypto.Block_hash.t option; reason : [ `Pruned | `Pruned_pred @@ -99,15 +99,15 @@ type error += | Invalid_export_path of string | Snapshot_file_not_found of string | Inconsistent_protocol_hash of { - expected : Protocol_hash.t; - got : Protocol_hash.t; + expected : Tezos_crypto.Protocol_hash.t; + got : Tezos_crypto.Protocol_hash.t; } | Inconsistent_context_hash of { - expected : Context_hash.t; - got : Context_hash.t; + expected : Tezos_crypto.Context_hash.t; + got : Tezos_crypto.Context_hash.t; } - | Inconsistent_context of Context_hash.t - | Cannot_decode_protocol of Protocol_hash.t + | Inconsistent_context of Tezos_crypto.Context_hash.t + | Cannot_decode_protocol of Tezos_crypto.Protocol_hash.t | Cannot_write_metadata of string | Cannot_read of { kind : @@ -128,7 +128,7 @@ type error += | Missing_cemented_file of string | Corrupted_floating_store | Invalid_protocol_file of string - | Target_block_validation_failed of Block_hash.t * string + | Target_block_validation_failed of Tezos_crypto.Block_hash.t * string | Directory_already_exists of string | Empty_floating_store | Cannot_remove_tmp_export_directory of string @@ -136,7 +136,8 @@ type error += expected : Distributed_db_version.Name.t; got : Distributed_db_version.Name.t; } - | Inconsistent_imported_block of Block_hash.t * Block_hash.t + | Inconsistent_imported_block of + Tezos_crypto.Block_hash.t * Tezos_crypto.Block_hash.t | Wrong_snapshot_file of {filename : string} (** Current version of snapshots *) @@ -203,7 +204,7 @@ val import : ?patch_context: (Tezos_protocol_environment.Context.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t) -> - ?block:Block_hash.t -> + ?block:Tezos_crypto.Block_hash.t -> ?check_consistency:bool -> dst_store_dir:string -> dst_context_dir:string -> diff --git a/src/lib_store/unix/snapshots_events.ml b/src/lib_store/unix/snapshots_events.ml index 994ebc65c574..69f21844964a 100644 --- a/src/lib_store/unix/snapshots_events.ml +++ b/src/lib_store/unix/snapshots_events.ml @@ -138,6 +138,6 @@ module Event = struct ~level:Notice ~name:"validate_protocol_sources" ~msg:"validating protocol {hash} against sources" - ~pp1:Protocol_hash.pp - ("hash", Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp + ("hash", Tezos_crypto.Protocol_hash.encoding) end diff --git a/src/lib_store/unix/store.ml b/src/lib_store/unix/store.ml index ccc1e084dc49..c5578f5f46f7 100644 --- a/src/lib_store/unix/store.ml +++ b/src/lib_store/unix/store.ml @@ -63,13 +63,13 @@ type store = { context_index : Context_ops.index; protocol_store : Protocol_store.t; allow_testchains : bool; - protocol_watcher : Protocol_hash.t Lwt_watcher.input; + protocol_watcher : Tezos_crypto.Protocol_hash.t Lwt_watcher.input; global_block_watcher : (chain_store * block) Lwt_watcher.input; } and chain_store = { global_store : store; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; chain_dir : [`Chain_dir] Naming.directory; chain_config : chain_config; block_store : Block_store.t; @@ -78,8 +78,8 @@ and chain_store = { genesis_block_data : block Stored_data.t; block_watcher : block Lwt_watcher.input; block_rpc_directories : - (chain_store * block) Tezos_rpc.Directory.t Protocol_hash.Map.t - Protocol_hash.Table.t; + (chain_store * block) Tezos_rpc.Directory.t Tezos_crypto.Protocol_hash.Map.t + Tezos_crypto.Protocol_hash.Table.t; lockfile : Lwt_unix.file_descr; } @@ -94,20 +94,26 @@ and chain_state = { (* Following fields are safe to update directly *) protocol_levels_data : Protocol_levels.activation_block Protocol_levels.t Stored_data.t; - invalid_blocks_data : invalid_block Block_hash.Map.t Stored_data.t; - forked_chains_data : Block_hash.t Chain_id.Map.t Stored_data.t; + invalid_blocks_data : + invalid_block Tezos_crypto.Block_hash.Map.t Stored_data.t; + forked_chains_data : + Tezos_crypto.Block_hash.t Tezos_crypto.Chain_id.Map.t Stored_data.t; (* In memory-only: *) current_head : Block_repr.t; active_testchain : testchain option; mempool : Mempool.t; - live_blocks : Block_hash.Set.t; - live_operations : Operation_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; mutable live_data_cache : - (Block_hash.t * Operation_hash.Set.t) Ringo.Ring.t option; + (Tezos_crypto.Block_hash.t * Tezos_crypto.Operation_hash.Set.t) Ringo.Ring.t + option; prechecked_blocks : Block_repr.t Block_lru_cache.t; } -and testchain = {forked_block : Block_hash.t; testchain_store : chain_store} +and testchain = { + forked_block : Tezos_crypto.Block_hash.t; + testchain_store : chain_store; +} and block = Block_repr.t @@ -159,7 +165,7 @@ let locked_is_acceptable_block chain_state (hash, level) = | None -> Lwt.return_true | Some (target_hash, target_level) -> if Compare.Int32.(level = target_level) then - Lwt.return @@ Block_hash.equal hash target_hash + Lwt.return @@ Tezos_crypto.Block_hash.equal hash target_hash else Lwt.return_true let create_lockfile chain_dir = @@ -202,7 +208,8 @@ module Block = struct operations_metadata : Block_validation.operation_metadata list list; } - let equal b b' = Block_hash.equal (Block_repr.hash b) (Block_repr.hash b') + let equal b b' = + Tezos_crypto.Block_hash.equal (Block_repr.hash b) (Block_repr.hash b') let descriptor blk = Block_repr.descriptor blk @@ -220,7 +227,7 @@ module Block = struct let locked_is_known_invalid chain_state hash = let open Lwt_syntax in let* invalid_blocks = Stored_data.get chain_state.invalid_blocks_data in - Lwt.return (Block_hash.Map.mem hash invalid_blocks) + Lwt.return (Tezos_crypto.Block_hash.Map.mem hash invalid_blocks) let is_known_invalid {chain_state; _} hash = Shared.use chain_state (fun chain_state -> @@ -253,7 +260,7 @@ module Block = struct let is_genesis chain_store hash = let genesis = genesis chain_store in - Block_hash.equal hash genesis.Genesis.block + Tezos_crypto.Block_hash.equal hash genesis.Genesis.block let read_block {block_store; _} ?(distance = 0) hash = let open Lwt_result_syntax in @@ -452,7 +459,7 @@ module Block = struct in let*! genesis_block = Stored_data.get chain_store.genesis_block_data in let is_main_chain = - Chain_id.equal + Tezos_crypto.Chain_id.equal chain_store.chain_id (WithExceptions.Option.get ~loc:__LOC__ @@ -505,7 +512,9 @@ module Block = struct in let* () = fail_unless - (Context_hash.equal block_header.shell.context context_hash) + (Tezos_crypto.Context_hash.equal + block_header.shell.context + context_hash) (Validation_errors.Inconsistent_hash (context_hash, block_header.shell.context)) in @@ -628,7 +637,7 @@ module Block = struct in let testchain_id = Context.compute_testchain_chain_id genesis in let forked_hash_opt = - Chain_id.Map.find testchain_id forked_chains + Tezos_crypto.Chain_id.Map.find testchain_id forked_chains in return (status, forked_hash_opt)) | Forking _ -> return (status, Some (Block_repr.hash block)) @@ -657,7 +666,7 @@ module Block = struct let open Lwt_syntax in Shared.use chain_state (fun chain_state -> let* invalid_blocks = Stored_data.get chain_state.invalid_blocks_data in - Lwt.return (Block_hash.Map.find hash invalid_blocks)) + Lwt.return (Tezos_crypto.Block_hash.Map.find hash invalid_blocks)) let read_invalid_blocks {chain_state; _} = Shared.use chain_state (fun chain_state -> @@ -674,7 +683,10 @@ module Block = struct (fun invalid_blocks -> Prometheus.Gauge.inc_one Store_metrics.metrics.invalid_blocks ; Lwt.return - (Block_hash.Map.add hash {level; errors} invalid_blocks))) + (Tezos_crypto.Block_hash.Map.add + hash + {level; errors} + invalid_blocks))) in return_unit @@ -684,7 +696,7 @@ module Block = struct chain_state.invalid_blocks_data (fun invalid_blocks -> Prometheus.Gauge.dec_one Store_metrics.metrics.invalid_blocks ; - Lwt.return (Block_hash.Map.remove hash invalid_blocks))) + Lwt.return (Tezos_crypto.Block_hash.Map.remove hash invalid_blocks))) (** Accessors *) @@ -731,8 +743,8 @@ module Block = struct else Option.map (fun ll -> - Operation_metadata_list_list_hash.compute - (List.map Operation_metadata_list_hash.compute ll)) + Tezos_crypto.Operation_metadata_list_list_hash.compute + (List.map Tezos_crypto.Operation_metadata_list_hash.compute ll)) (Block_repr.operations_metadata_hashes blk) (** Metadata accessors *) @@ -749,8 +761,10 @@ module Block = struct let operations_metadata metadata = Block_repr.operations_metadata metadata let compute_operation_path hashes = - let list_hashes = List.map Operation_list_hash.compute hashes in - Operation_list_list_hash.compute_path list_hashes + let list_hashes = + List.map Tezos_crypto.Operation_list_hash.compute hashes + in + Tezos_crypto.Operation_list_list_hash.compute_path list_hashes let operations_path block i = if i < 0 || validation_passes block <= i then invalid_arg "operations_path" ; @@ -826,22 +840,27 @@ module Chain_traversal = struct let live_blocks chain_store block n = let fold (bacc, oacc) (head_hash, op_hashes) = - let bacc = Block_hash.Set.add head_hash bacc in + let bacc = Tezos_crypto.Block_hash.Set.add head_hash bacc in let oacc = List.fold_left - (List.fold_left (fun oacc op -> Operation_hash.Set.add op oacc)) + (List.fold_left (fun oacc op -> + Tezos_crypto.Operation_hash.Set.add op oacc)) oacc op_hashes in (bacc, oacc) in - let init = (Block_hash.Set.empty, Operation_hash.Set.empty) in + let init = + (Tezos_crypto.Block_hash.Set.empty, Tezos_crypto.Operation_hash.Set.empty) + in folder chain_store block n fold init let live_blocks_with_ring chain_store block n ring = let open Lwt_syntax in let fold acc (head_hash, op_hashes) = - let op_hash_set = Operation_hash.Set.(of_list (List.flatten op_hashes)) in + let op_hash_set = + Tezos_crypto.Operation_hash.Set.(of_list (List.flatten op_hashes)) + in (head_hash, op_hash_set) :: acc in let* l = folder chain_store block n fold [] in @@ -952,7 +971,7 @@ module Chain = struct let*! current_head_descr = Stored_data.get chain_state.current_head_data in - if Block_hash.equal head (fst current_head_descr) then + if Tezos_crypto.Block_hash.equal head (fst current_head_descr) then return (Some {chain_state with mempool}, ()) else return (None, ())) @@ -974,20 +993,22 @@ module Chain = struct match live_data_cache with | Some live_data_cache when update_cache - && Block_hash.equal + && Tezos_crypto.Block_hash.equal (Block.predecessor block) (Block.hash current_head) && Ringo.Ring.capacity live_data_cache = expected_capacity -> ( let most_recent_block = Block.hash block in let most_recent_ops = Block.all_operation_hashes block - |> List.flatten |> Operation_hash.Set.of_list + |> List.flatten |> Tezos_crypto.Operation_hash.Set.of_list in let new_live_blocks = - Block_hash.Set.add most_recent_block live_blocks + Tezos_crypto.Block_hash.Set.add most_recent_block live_blocks in let new_live_operations = - Operation_hash.Set.union most_recent_ops live_operations + Tezos_crypto.Operation_hash.Set.union + most_recent_ops + live_operations in match Ringo.Ring.add_and_return_erased @@ -997,10 +1018,12 @@ module Chain = struct | None -> Lwt.return (new_live_blocks, new_live_operations) | Some (last_block, last_ops) -> let diffed_new_live_blocks = - Block_hash.Set.remove last_block new_live_blocks + Tezos_crypto.Block_hash.Set.remove last_block new_live_blocks in let diffed_new_live_operations = - Operation_hash.Set.diff new_live_operations last_ops + Tezos_crypto.Operation_hash.Set.diff + new_live_operations + last_ops in Lwt.return (diffed_new_live_blocks, diffed_new_live_operations)) | _ when update_cache -> @@ -1016,9 +1039,12 @@ module Chain = struct let live_blocks, live_ops = Ringo.Ring.fold new_cache - ~init:(Block_hash.Set.empty, Operation_hash.Set.empty) + ~init: + ( Tezos_crypto.Block_hash.Set.empty, + Tezos_crypto.Operation_hash.Set.empty ) ~f:(fun (bhs, opss) (bh, ops) -> - (Block_hash.Set.add bh bhs, Operation_hash.Set.union ops opss)) + ( Tezos_crypto.Block_hash.Set.add bh bhs, + Tezos_crypto.Operation_hash.Set.union ops opss )) in Lwt.return (live_blocks, live_ops) | _ -> Chain_traversal.live_blocks chain_store block expected_capacity @@ -1041,7 +1067,7 @@ module Chain = struct let open Lwt_syntax in if Compare.Int32.(lvl' > lvl) then Lwt.return_false else if Compare.Int32.(lvl = lvl') then - Lwt.return (Block_hash.equal hash hash') + Lwt.return (Tezos_crypto.Block_hash.equal hash hash') else let* o = Block.read_ancestor_hash_opt @@ -1051,7 +1077,8 @@ module Chain = struct in match o with | None -> Lwt.return_false - | Some hash_found -> Lwt.return (Block_hash.equal hash' hash_found) + | Some hash_found -> + Lwt.return (Tezos_crypto.Block_hash.equal hash' hash_found) let is_in_chain chain_store (hash, level) = let open Lwt_syntax in @@ -1535,7 +1562,7 @@ module Chain = struct chain_state.invalid_blocks_data (fun invalid_blocks -> Lwt.return - (Block_hash.Map.filter + (Tezos_crypto.Block_hash.Map.filter (fun _k {level; _} -> if level > snd new_checkpoint then ( Prometheus.Gauge.inc_one @@ -1623,7 +1650,8 @@ module Chain = struct in match o with | None -> tzfail Missing_last_allowed_fork_level_block - | Some lafl_hash -> return (Block_hash.equal lafl_hash ancestor))) + | Some lafl_hash -> + return (Tezos_crypto.Block_hash.equal lafl_hash ancestor))) let is_valid_for_checkpoint chain_store given_checkpoint = let open Lwt_syntax in @@ -1759,7 +1787,10 @@ module Chain = struct ( best_head, List.filter (fun (hash, _) -> - not (Block_hash.equal (Block.hash best_head) hash)) + not + (Tezos_crypto.Block_hash.equal + (Block.hash best_head) + hash)) all_heads ) in (* Case 1 *) @@ -1886,18 +1917,20 @@ module Chain = struct let* invalid_blocks_data = Stored_data.init (Naming.invalid_blocks_file chain_dir) - ~initial_data:Block_hash.Map.empty + ~initial_data:Tezos_crypto.Block_hash.Map.empty in let* forked_chains_data = Stored_data.init (Naming.forked_chains_file chain_dir) - ~initial_data:Chain_id.Map.empty + ~initial_data:Tezos_crypto.Chain_id.Map.empty in let current_head = genesis_block in let active_testchain = None in let mempool = Mempool.empty in - let live_blocks = Block_hash.Set.singleton genesis_block.hash in - let live_operations = Operation_hash.Set.empty in + let live_blocks = + Tezos_crypto.Block_hash.Set.singleton genesis_block.hash + in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let live_data_cache = None in let prechecked_blocks = Block_lru_cache.create 10 in return @@ -1996,8 +2029,8 @@ module Chain = struct | Some current_head -> let active_testchain = None in let mempool = Mempool.empty in - let live_blocks = Block_hash.Set.empty in - let live_operations = Operation_hash.Set.empty in + let live_blocks = Tezos_crypto.Block_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let live_data_cache = None in let prechecked_blocks = Block_lru_cache.create 10 in return @@ -2075,7 +2108,7 @@ module Chain = struct in let chain_state = Shared.create chain_state in let block_watcher = Lwt_watcher.create_input () in - let block_rpc_directories = Protocol_hash.Table.create 7 in + let block_rpc_directories = Tezos_crypto.Protocol_hash.Table.create 7 in let* lockfile = create_lockfile chain_dir in let chain_store : chain_store = { @@ -2110,7 +2143,7 @@ module Chain = struct let* chain_state = load_chain_state chain_dir block_store in let chain_state = Shared.create chain_state in let block_watcher = Lwt_watcher.create_input () in - let block_rpc_directories = Protocol_hash.Table.create 7 in + let block_rpc_directories = Tezos_crypto.Protocol_hash.Table.create 7 in let* lockfile = create_lockfile chain_dir in let chain_store = { @@ -2182,14 +2215,16 @@ module Chain = struct let {forked_chains_data; active_testchain; _} = chain_state in match active_testchain with | Some testchain - when Chain_id.equal chain_id testchain.testchain_store.chain_id -> + when Tezos_crypto.Chain_id.equal + chain_id + testchain.testchain_store.chain_id -> return_some testchain | _ -> ( let chain_dir = chain_store.chain_dir in let testchains_dir = Naming.testchains_dir chain_dir in let testchain_dir = Naming.chain_dir testchains_dir chain_id in let*! forked_chains = Stored_data.get forked_chains_data in - match Chain_id.Map.find chain_id forked_chains with + match Tezos_crypto.Chain_id.Map.find chain_id forked_chains with | None -> return_none | Some forked_block -> let* testchain_store = @@ -2207,7 +2242,7 @@ module Chain = struct let open Lwt_result_syntax in let forked_block_hash = Block.hash forked_block in let genesis_hash' = Context.compute_testchain_genesis forked_block_hash in - assert (Block_hash.equal genesis_hash genesis_hash') ; + assert (Tezos_crypto.Block_hash.equal genesis_hash genesis_hash') ; let* () = fail_unless chain_store.global_store.allow_testchains @@ -2219,8 +2254,10 @@ module Chain = struct match active_testchain with | Some ({testchain_store; forked_block} as testchain) -> (* Already forked and active *) - if Chain_id.equal testchain_store.chain_id testchain_id then ( - assert (Block_hash.equal forked_block forked_block_hash) ; + if Tezos_crypto.Chain_id.equal testchain_store.chain_id testchain_id + then ( + assert ( + Tezos_crypto.Block_hash.equal forked_block forked_block_hash) ; return (None, testchain)) else tzfail (Cannot_fork_testchain testchain_id) | None -> @@ -2274,7 +2311,7 @@ module Chain = struct chain_state.forked_chains_data (fun forked_chains -> Lwt.return - (Chain_id.Map.add + (Tezos_crypto.Chain_id.Map.add testchain_id forked_block_hash forked_chains)) @@ -2380,7 +2417,7 @@ module Chain = struct let*! o = find_activation_block chain_store ~protocol_level in match o with | Some {block = bh, _; _} -> - if Block_hash.(bh <> Block.hash block) then + if Tezos_crypto.Block_hash.(bh <> Block.hash block) then set_protocol_level chain_store ~protocol_level (block, protocol_hash) else return_unit | None -> @@ -2459,7 +2496,8 @@ module Chain = struct let* o = Block.read_predecessor_opt chain_store block in match o with | None -> Lwt.return_none (* genesis *) - | Some pred when Block_hash.equal (Block.hash pred) (Block.hash block) -> + | Some pred + when Tezos_crypto.Block_hash.equal (Block.hash pred) (Block.hash block) -> Lwt.return_none (* genesis *) | Some pred -> ( let* _, save_point_level = savepoint chain_store in @@ -2476,25 +2514,27 @@ module Chain = struct else Block.protocol_hash_exn chain_store pred in match - Protocol_hash.Table.find chain_store.block_rpc_directories protocol + Tezos_crypto.Protocol_hash.Table.find + chain_store.block_rpc_directories + protocol with | None -> Lwt.return_none | Some map -> let* next_protocol = Block.protocol_hash_exn chain_store block in - Lwt.return (Protocol_hash.Map.find next_protocol map)) + Lwt.return (Tezos_crypto.Protocol_hash.Map.find next_protocol map)) let set_rpc_directory chain_store ~protocol_hash ~next_protocol_hash dir = let map = Option.value - ~default:Protocol_hash.Map.empty - (Protocol_hash.Table.find + ~default:Tezos_crypto.Protocol_hash.Map.empty + (Tezos_crypto.Protocol_hash.Table.find chain_store.block_rpc_directories protocol_hash) in - Protocol_hash.Table.replace + Tezos_crypto.Protocol_hash.Table.replace chain_store.block_rpc_directories protocol_hash - (Protocol_hash.Map.add next_protocol_hash dir map) ; + (Tezos_crypto.Protocol_hash.Map.add next_protocol_hash dir map) ; Lwt.return_unit let register_gc_callback chain_store callback = @@ -2628,7 +2668,7 @@ let load_store ?history_mode ?block_cache_limit store_dir ~context_index let stored_genesis = Chain.genesis main_chain_store in let* () = fail_unless - (Block_hash.equal genesis.Genesis.block stored_genesis.block) + (Tezos_crypto.Block_hash.equal genesis.Genesis.block stored_genesis.block) (Inconsistent_genesis {expected = stored_genesis.block; got = genesis.block}) in @@ -2664,7 +2704,7 @@ let init ?patch_context ?commit_genesis ?history_mode ?(readonly = false) patch_context in let store_dir = Naming.store_dir ~dir_path:store_dir in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let*! context_index, commit_genesis = match commit_genesis with | Some commit_genesis -> @@ -2738,7 +2778,7 @@ let close_store global_store = let may_switch_history_mode ~store_dir ~context_dir genesis ~new_history_mode = let open Lwt_result_syntax in let store_dir = Naming.store_dir ~dir_path:store_dir in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let chain_dir = Naming.chain_dir store_dir chain_id in let chain_dir_path = Naming.dir_path chain_dir in if not (Sys.file_exists chain_dir_path && Sys.is_directory chain_dir_path) @@ -2809,7 +2849,7 @@ let get_chain_store store chain_id = let chain_store = main_chain_store store in let rec loop chain_store = let open Lwt_result_syntax in - if Chain_id.equal (Chain.chain_id chain_store) chain_id then + if Tezos_crypto.Chain_id.equal (Chain.chain_id chain_store) chain_id then return chain_store else Shared.use chain_store.chain_state (fun {active_testchain; _} -> @@ -2966,7 +3006,7 @@ let rec make_pp_chain_store (chain_store : chain_store) = proto_level pp_block_descriptor block - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol (option_pp ~default:"n/a" (fun fmt _ -> Format.fprintf fmt "available")) commit_info @@ -2988,7 +3028,7 @@ let rec make_pp_chain_store (chain_store : chain_store) = %a@ target: %a@ @[protocol levels:@ %a@]@ @[invalid \ blocks:@ %a@]@ @[forked chains:@ %a@]@ @[active testchain: \ %a@]@]" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id (Naming.dir_path chain_dir) Data_encoding.Json.pp @@ -3032,19 +3072,22 @@ let rec make_pp_chain_store (chain_store : chain_store) = target (Format.pp_print_list ~pp_sep:Format.pp_print_cut pp_protocol_level) (Protocol_levels.bindings protocol_levels_data) - (Format.pp_print_list ~pp_sep:Format.pp_print_cut Block_hash.pp) - (Block_hash.Map.bindings invalid_blocks_data |> List.map fst) + (Format.pp_print_list + ~pp_sep:Format.pp_print_cut + Tezos_crypto.Block_hash.pp) + (Tezos_crypto.Block_hash.Map.bindings invalid_blocks_data + |> List.map fst) (Format.pp_print_list ~pp_sep:Format.pp_print_cut (fun fmt (chain_id, block_hash) -> Format.fprintf fmt "testchain's chain id: %a, forked block: %a" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash)) - (Chain_id.Map.bindings forked_chains_data) + (Tezos_crypto.Chain_id.Map.bindings forked_chains_data) pp_testchain_opt ()) @@ -3110,7 +3153,7 @@ module Unsafe = struct ~(locked_f : chain_store -> 'a tzresult Lwt.t) = let open Lwt_result_syntax in let store_dir = Naming.store_dir ~dir_path:store_dir in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let chain_dir = Naming.chain_dir store_dir chain_id in let* lockfile = create_lockfile chain_dir in let*! () = lock_for_read lockfile in @@ -3139,7 +3182,7 @@ module Unsafe = struct ~genesis ~genesis_context_hash ~floating_blocks_stream ~new_head_with_metadata ~protocol_levels ~history_mode = let open Lwt_result_syntax in - let chain_id = Chain_id.of_block_hash genesis.Genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.Genesis.block in let chain_dir = Naming.chain_dir store_dir chain_id in let genesis_block = Block_repr.create_genesis_block ~genesis genesis_context_hash @@ -3211,12 +3254,12 @@ module Unsafe = struct let* () = Stored_data.write_file (Naming.invalid_blocks_file chain_dir) - Block_hash.Map.empty + Tezos_crypto.Block_hash.Map.empty in let* () = Stored_data.write_file (Naming.forked_chains_file chain_dir) - Chain_id.Map.empty + Tezos_crypto.Chain_id.Map.empty in let* () = Stored_data.write_file (Naming.genesis_block_file chain_dir) genesis_block @@ -3259,7 +3302,7 @@ module Unsafe = struct return_unit | _ -> fail_unless - (Block_hash.equal real_genesis_hash bh) + (Tezos_crypto.Block_hash.equal real_genesis_hash bh) (Missing_activation_block (bh, protocol, history_mode))) | Some _block, None -> return_unit | Some block, Some commit_info -> diff --git a/src/lib_store/unix/store.mli b/src/lib_store/unix/store.mli index aa4d8d5f4500..e05a3df52243 100644 --- a/src/lib_store/unix/store.mli +++ b/src/lib_store/unix/store.mli @@ -213,7 +213,9 @@ val init : ?patch_context: (Tezos_protocol_environment.Context.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t) -> - ?commit_genesis:(chain_id:Chain_id.t -> Context_hash.t tzresult Lwt.t) -> + ?commit_genesis: + (chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Context_hash.t tzresult Lwt.t) -> ?history_mode:History_mode.t -> ?readonly:bool -> ?block_cache_limit:int -> @@ -265,11 +267,13 @@ val all_chain_stores : store -> chain_store list Lwt.t (** [get_chain_store global_store chain_id] returns the initialized chain store in [global_store] associated to [chain_id]. *) -val get_chain_store : store -> Chain_id.t -> chain_store tzresult Lwt.t +val get_chain_store : + store -> Tezos_crypto.Chain_id.t -> chain_store tzresult Lwt.t (** [get_chain_store_opt global_store chain_id] optional version of [get_chain_store]. *) -val get_chain_store_opt : store -> Chain_id.t -> chain_store option Lwt.t +val get_chain_store_opt : + store -> Tezos_crypto.Chain_id.t -> chain_store option Lwt.t val make_pp_store : store -> (Format.formatter -> unit -> unit) Lwt.t @@ -303,41 +307,49 @@ module Block : sig (** [is_known_valid chain_store bh] tests that the block [bh] is known and valid in [chain_store] (i.e. the block is present in the block store). *) - val is_known_valid : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_valid : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known_invalid chain_store bh] tests that the block [bh] is invalid in [chain_store] (i.e. the block is present in the invalid blocks file). *) - val is_known_invalid : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_invalid : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known_prechecked chain_store bh] tests that the block [bh] is prechecked in [chain_store] (i.e. the block is present in the prechecked block cache). *) - val is_known_prechecked : chain_store -> Block_hash.t -> bool Lwt.t + val is_known_prechecked : + chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_known chain_store bh] tests that the block [bh] is either known valid or known invalid in [chain_store]. *) - val is_known : chain_store -> Block_hash.t -> bool Lwt.t + val is_known : chain_store -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [is_genesis chain_store bh] tests that the block [bh] is the genesis initialized in [chain_store]. *) - val is_genesis : chain_store -> Block_hash.t -> bool + val is_genesis : chain_store -> Tezos_crypto.Block_hash.t -> bool (** [validity chain_store bh] computes the {!Block_locator.validity} ([Unknown], [Known_valid] or [Known_invalid]) for the block [bh] in [chain_store]. *) - val validity : chain_store -> Block_hash.t -> Block_locator.validity Lwt.t + val validity : + chain_store -> Tezos_crypto.Block_hash.t -> Block_locator.validity Lwt.t (** [read_block chain_store ?distance bh] tries to read in the [chain_store] the block [bh] or the predecessing block at the offset [distance] of [bh]. By default, [distance] is 0.*) val read_block : - chain_store -> ?distance:int -> Block_hash.t -> block tzresult Lwt.t + chain_store -> + ?distance:int -> + Tezos_crypto.Block_hash.t -> + block tzresult Lwt.t (** [read_block_opt chain_store ?distance bh] optional version of [read_block]. *) val read_block_opt : - chain_store -> ?distance:int -> Block_hash.t -> block option Lwt.t + chain_store -> + ?distance:int -> + Tezos_crypto.Block_hash.t -> + block option Lwt.t (** [read_block_by_level chain_store level] reads in the [chain_store] the block at [level]. The block retrieved will be @@ -359,13 +371,16 @@ module Block : sig val read_block_metadata : ?distance:int -> chain_store -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> metadata option tzresult Lwt.t (** [read_block_metadata_opt ?distance chain_store bh] same as [read_block_metadata] but returns [None] in case of errors. *) val read_block_metadata_opt : - ?distance:int -> chain_store -> Block_hash.t -> metadata option Lwt.t + ?distance:int -> + chain_store -> + Tezos_crypto.Block_hash.t -> + metadata option Lwt.t (** [get_block_metadata chain_store block] reads in the [chain_store] the metadata associated to the [block]. Returns @@ -390,7 +405,7 @@ module Block : sig (** [read_predecessor_of_hash chain_store bh] reads in [chain_store] the predecessor's block of [bh]. *) val read_predecessor_of_hash : - chain_store -> Block_hash.t -> block tzresult Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block tzresult Lwt.t (** [read_ancestor_hash chain_store ~distance bh] retrieves in the [chain_store] the hash of the ancestor of the block [bh] at @@ -398,28 +413,31 @@ module Block : sig val read_ancestor_hash : chain_store -> distance:int -> - Block_hash.t -> - Block_hash.t option tzresult Lwt.t + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Block_hash.t option tzresult Lwt.t (** [read_ancestor_hash_opt chain_store ~distance bh] same as [read_ancestor_hash] but returns [None] on errors. *) val read_ancestor_hash_opt : - chain_store -> distance:int -> Block_hash.t -> Block_hash.t option Lwt.t + chain_store -> + distance:int -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Block_hash.t option Lwt.t (** [read_ancestor_opt chain_store block] optional version of [read_ancestor]. *) val read_predecessor_of_hash_opt : - chain_store -> Block_hash.t -> block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block option Lwt.t (** [read_prechecked_block chain_store bh] tries to read in the [chain_store]'s prechecked block cache the block [bh].*) val read_prechecked_block : - chain_store -> Block_hash.t -> block tzresult Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block tzresult Lwt.t (** [read_prechecked_block_opt chain_store bh] optional version of [read_prechecked_block].*) val read_prechecked_block_opt : - chain_store -> Block_hash.t -> block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> block option Lwt.t (** [store_block chain_store ~block_header ~operations validation_result] stores in [chain_store] the block with its @@ -445,7 +463,7 @@ module Block : sig its [block_header] and [operations]. *) val store_prechecked_block : chain_store -> - hash:Block_hash.t -> + hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t trace trace -> unit tzresult Lwt.t @@ -475,46 +493,50 @@ module Block : sig val testchain_status : chain_store -> block -> - (Test_chain_status.t * Block_hash.t option) tzresult Lwt.t + (Test_chain_status.t * Tezos_crypto.Block_hash.t option) tzresult Lwt.t (** [protocol_hash_exn chain_store block] reads the protocol associated to [block] in its associated context. Fails when the context is unknown. *) - val protocol_hash_exn : chain_store -> block -> Protocol_hash.t Lwt.t + val protocol_hash_exn : + chain_store -> block -> Tezos_crypto.Protocol_hash.t Lwt.t (** [protocol_hash chain_store block] error monad version of [protocol_hash_exn]. *) - val protocol_hash : chain_store -> block -> Protocol_hash.t tzresult Lwt.t + val protocol_hash : + chain_store -> block -> Tezos_crypto.Protocol_hash.t tzresult Lwt.t (** [read_invalid_block_opt chain_store bh] reads in the [chain_store] the invalid block [bh] if it exists. *) val read_invalid_block_opt : - chain_store -> Block_hash.t -> invalid_block option Lwt.t + chain_store -> Tezos_crypto.Block_hash.t -> invalid_block option Lwt.t (** [read_invalid_blocks chain_store] returns the map of all invalid blocks of [chain_store]. *) - val read_invalid_blocks : chain_store -> invalid_block Block_hash.Map.t Lwt.t + val read_invalid_blocks : + chain_store -> invalid_block Tezos_crypto.Block_hash.Map.t Lwt.t (** [mark_invalid chain_store bh ~level errors] stores the block [bh] at [level] with the given [errors]. Fails when trying to mark the genesis block as invalid. *) val mark_invalid : chain_store -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> level:int32 -> error list -> unit tzresult Lwt.t (** [unmark_invalid chain_store bh] unmarks invalid the block [bh] in the [chain_store]. *) - val unmark_invalid : chain_store -> Block_hash.t -> unit tzresult Lwt.t + val unmark_invalid : + chain_store -> Tezos_crypto.Block_hash.t -> unit tzresult Lwt.t (** [descriptor block] returns the pair (hash x level) of [block]. *) val descriptor : block -> block_descriptor (** {3 Block field accessors} *) - val hash : block -> Block_hash.t + val hash : block -> Tezos_crypto.Block_hash.t val header : block -> Block_header.t @@ -526,30 +548,30 @@ module Block : sig val proto_level : block -> int - val predecessor : block -> Block_hash.t + val predecessor : block -> Tezos_crypto.Block_hash.t val timestamp : block -> Time.Protocol.t val validation_passes : block -> int - val operations_hash : block -> Operation_list_list_hash.t + val operations_hash : block -> Tezos_crypto.Operation_list_list_hash.t val fitness : block -> Fitness.t - val context_hash : block -> Context_hash.t + val context_hash : block -> Tezos_crypto.Context_hash.t val protocol_data : block -> bytes - val block_metadata_hash : block -> Block_metadata_hash.t option + val block_metadata_hash : block -> Tezos_crypto.Block_metadata_hash.t option val operations_metadata_hashes : - block -> Operation_metadata_hash.t list list option + block -> Tezos_crypto.Operation_metadata_hash.t list list option val operations_metadata_hashes_path : - block -> int -> Operation_metadata_hash.t list option + block -> int -> Tezos_crypto.Operation_metadata_hash.t list option val all_operations_metadata_hash : - block -> Operation_metadata_list_list_hash.t option + block -> Tezos_crypto.Operation_metadata_list_list_hash.t option (** {3 Block metadata field accessors} *) @@ -567,16 +589,21 @@ module Block : sig (** [operations_path block nth] computes the [nth] operations list of [block] along with the hash of all operations. *) val operations_path : - block -> int -> Operation.t list * Operation_list_list_hash.path + block -> + int -> + Operation.t list * Tezos_crypto.Operation_list_list_hash.path (** [operations_hashes_path block nth] computes the [nth] operations hash list of [block] along with the hash of all operations. *) val operations_hashes_path : - block -> int -> Operation_hash.t list * Operation_list_list_hash.path + block -> + int -> + Tezos_crypto.Operation_hash.t list + * Tezos_crypto.Operation_list_list_hash.path (** [all_operation_hashes block] computes the hash of all operations in [block]. *) - val all_operation_hashes : block -> Operation_hash.t list list + val all_operation_hashes : block -> Tezos_crypto.Operation_hash.t list list end (** The module for handling chain-related operations such as setting @@ -600,7 +627,7 @@ module Chain : sig val global_store : chain_store -> store (** [chain_id chain_store] returns chain id of [chain_store]. *) - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t (** [chain_dir chain_store] returns the path of directory of [chain_store].*) @@ -714,12 +741,16 @@ module Chain : sig which might happen when a new head concurrently arrives just before this operation being called. *) val set_mempool : - chain_store -> head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t + chain_store -> + head:Tezos_crypto.Block_hash.t -> + Mempool.t -> + unit tzresult Lwt.t (** [live_blocks chain_store] returns the set of previously computed live blocks for the current_head's [chain_store]. *) val live_blocks : - chain_store -> (Block_hash.Set.t * Operation_hash.Set.t) Lwt.t + chain_store -> + (Tezos_crypto.Block_hash.Set.t * Tezos_crypto.Operation_hash.Set.t) Lwt.t (** [compute_live_blocks ~block chain_store] computes the set of live blocks and live operations relative to [block]. Does nothing @@ -731,7 +762,8 @@ module Chain : sig val compute_live_blocks : chain_store -> block:Block.t -> - (Block_hash.Set.t * Operation_hash.Set.t) tzresult Lwt.t + (Tezos_crypto.Block_hash.Set.t * Tezos_crypto.Operation_hash.Set.t) tzresult + Lwt.t (** [set_head ?trigger_gc_callback chain_store block] promotes the [block] as head of the [chain_store] and triggers an @@ -836,7 +868,7 @@ module Chain : sig (** [testchain_forked_block testchain] returns the hash of the forked block of its parent chain.*) - val testchain_forked_block : testchain -> Block_hash.t + val testchain_forked_block : testchain -> Tezos_crypto.Block_hash.t (** [testchain_store testchain] returns the chain store associated to this [testchain]. *) @@ -850,11 +882,11 @@ module Chain : sig registers this chain in the set of activated testchains. *) val fork_testchain : chain_store -> - testchain_id:Chain_id.t -> + testchain_id:Tezos_crypto.Chain_id.t -> forked_block:Block.t -> - genesis_hash:Block_hash.t -> + genesis_hash:Tezos_crypto.Block_hash.t -> genesis_header:Block_header.t -> - test_protocol:Protocol_hash.t -> + test_protocol:Tezos_crypto.Protocol_hash.t -> expiration:Time.Protocol.t -> testchain tzresult Lwt.t @@ -875,7 +907,9 @@ module Chain : sig (** [find_protocol chain_store ~protocol_level] returns the protocol with the level [protocol_level]. *) val find_protocol : - chain_store -> protocol_level:int -> Protocol_hash.t option Lwt.t + chain_store -> + protocol_level:int -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [all_protocol_levels chain_store] returns all the protocols registered in [chain_store]. *) @@ -894,7 +928,7 @@ module Chain : sig chain_store -> ?pred:Block.block -> ?protocol_level:int -> - Block.block * Protocol_hash.t -> + Block.block * Tezos_crypto.Protocol_hash.t -> unit tzresult Lwt.t (** [may_update_ancestor_protocol_level chain_store ~head] tries to @@ -921,8 +955,8 @@ module Chain : sig in [chain_store]. *) val set_rpc_directory : chain_store -> - protocol_hash:Protocol_hash.t -> - next_protocol_hash:Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> + next_protocol_hash:Tezos_crypto.Protocol_hash.t -> (chain_store * Block.t) Tezos_rpc.Directory.t -> unit Lwt.t @@ -930,7 +964,7 @@ module Chain : sig [callback] that may be triggered during a block store merge in order to garbage-collect old contexts. *) val register_gc_callback : - chain_store -> (Context_hash.t -> unit tzresult Lwt.t) -> unit + chain_store -> (Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t) -> unit end (** [global_block_watcher global_store] instantiates a new block @@ -942,15 +976,15 @@ val global_block_watcher : module Protocol : sig (** [mem global_store ph] checks the existence of the protocol [ph] in [global_store]. *) - val mem : store -> Protocol_hash.t -> bool + val mem : store -> Tezos_crypto.Protocol_hash.t -> bool (** [all global_store ph] returns the set of all stored protocol in [global_store]. *) - val all : store -> Protocol_hash.Set.t + val all : store -> Tezos_crypto.Protocol_hash.Set.t (** [read global_store ph] reads the protocol [ph] from the [global_store]. Returns [None] if it does not exist. *) - val read : store -> Protocol_hash.t -> Protocol.t option Lwt.t + val read : store -> Tezos_crypto.Protocol_hash.t -> Protocol.t option Lwt.t (** [store global_store ph protocol] stores the [protocol] under the hash [ph] in the [global_store]. Returns [None] if it already @@ -959,16 +993,22 @@ module Protocol : sig {b Warning} No hash check is made, the caller must be careful when storing protocols. *) val store : - store -> Protocol_hash.t -> Protocol.t -> Protocol_hash.t option Lwt.t + store -> + Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [store_raw global_store ph bytes] raw version of [store]. *) val store_raw : - store -> Protocol_hash.t -> bytes -> Protocol_hash.t option Lwt.t + store -> + Tezos_crypto.Protocol_hash.t -> + bytes -> + Tezos_crypto.Protocol_hash.t option Lwt.t (** [protocol_watcher global_store] instantiates a new protocol watcher in [global_store]. *) val protocol_watcher : - store -> Protocol_hash.t Lwt_stream.t * Lwt_watcher.stopper + store -> Tezos_crypto.Protocol_hash.t Lwt_stream.t * Lwt_watcher.stopper end (** The utility module used to traverse the chain. *) @@ -1017,7 +1057,9 @@ module Unsafe : sig val get_block_store : chain_store -> Block_store.block_store val load_testchain : - chain_store -> chain_id:Chain_id.t -> Chain.testchain option tzresult Lwt.t + chain_store -> + chain_id:Tezos_crypto.Chain_id.t -> + Chain.testchain option tzresult Lwt.t (** [set_head chain_store block] sets the block as the current head of [chain_store] without checks. *) @@ -1051,7 +1093,7 @@ module Unsafe : sig val set_protocol_level : chain_store -> protocol_level:int -> - Block.block * Protocol_hash.t -> + Block.block * Tezos_crypto.Protocol_hash.t -> unit tzresult Lwt.t (** Snapshots utility functions *) @@ -1082,7 +1124,7 @@ module Unsafe : sig ?notify:(unit -> unit Lwt.t) -> [`Store_dir] Naming.directory -> genesis:Genesis.t -> - genesis_context_hash:Context_hash.t -> + genesis_context_hash:Tezos_crypto.Context_hash.t -> floating_blocks_stream:Block_repr.block Lwt_stream.t -> new_head_with_metadata:Block_repr.block -> protocol_levels:Protocol_levels.activation_block Protocol_levels.t -> diff --git a/src/lib_store/unix/test/alpha_utils.ml b/src/lib_store/unix/test/alpha_utils.ml index f058b708b63c..f8e8e3239404 100644 --- a/src/lib_store/unix/test/alpha_utils.ml +++ b/src/lib_store/unix/test/alpha_utils.ml @@ -59,49 +59,58 @@ end module Account = struct type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } let pp fmt {pkh; pk; sk} = Format.fprintf fmt "pkh: %a@ pk: %a@ nsk: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp pk - Signature.Secret_key.pp + Tezos_crypto.Signature.Secret_key.pp sk type account = t - let known_accounts = Signature.Public_key_hash.Table.create 17 + let known_accounts = Tezos_crypto.Signature.Public_key_hash.Table.create 17 let new_account ?seed () = - let pkh, pk, sk = Signature.generate_key ?seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ?seed () in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account ; account let add_account ({pkh; _} as account) = - Signature.Public_key_hash.Table.replace known_accounts pkh account + Tezos_crypto.Signature.Public_key_hash.Table.replace + known_accounts + pkh + account let activator_account = new_account () let find pkh = let open Lwt_result_syntax in - match Signature.Public_key_hash.Table.find known_accounts pkh with + match + Tezos_crypto.Signature.Public_key_hash.Table.find known_accounts pkh + with | Some v -> return v - | None -> failwith "Missing account: %a" Signature.Public_key_hash.pp pkh + | None -> + failwith + "Missing account: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let find_alternate pkh = let exception Found of t in try - Signature.Public_key_hash.Table.iter + Tezos_crypto.Signature.Public_key_hash.Table.iter (fun pkh' account -> - if not (Signature.Public_key_hash.equal pkh pkh') then + if not (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') then raise (Found account)) known_accounts ; raise Not_found @@ -127,7 +136,9 @@ module Account = struct let new_commitment ?seed () = let open Lwt_result_syntax in - let pkh, pk, sk = Signature.generate_key ?seed ~algo:Ed25519 () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ?seed ~algo:Ed25519 () + in let unactivated_account = {pkh; pk; sk} in let open Commitment in let pkh = match pkh with Ed25519 pkh -> pkh | _ -> assert false in @@ -232,7 +243,11 @@ let get_next_baker_excluding rpc_ctxt excludes block = let {Plugin.RPC.Baking_rights.delegate = pkh; timestamp; round; _} = List.find (fun {Plugin.RPC.Baking_rights.delegate; _} -> - not (List.mem ~equal:Signature.Public_key_hash.equal delegate excludes)) + not + (List.mem + ~equal:Tezos_crypto.Signature.Public_key_hash.equal + delegate + excludes)) bakers |> WithExceptions.Option.get ~loc:__LOC__ in @@ -284,7 +299,7 @@ module Forge = struct operations_hash; proto_level; validation_passes = List.length Main.validation_passes; - context = Context_hash.zero (* to update later *); + context = Tezos_crypto.Context_hash.zero (* to update later *); } let set_seed_nonce_hash seed_nonce_hash {baker; shell; contents} = @@ -301,7 +316,7 @@ module Forge = struct (shell, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark:Block_header.(to_watermark (Block_header chain_id)) delegate.sk unsigned_bytes @@ -336,9 +351,9 @@ module Forge = struct | {expected_commitment = false; _} -> None in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map - Operation_list_hash.compute + Tezos_crypto.Operation_list_hash.compute (List.map (List.map Operation.hash_packed) operations)) in let shell = @@ -411,9 +426,9 @@ let default_accounts = let open Account in let to_account (pkh, pk, sk) = { - pkh = Signature.Public_key_hash.of_b58check_exn pkh; - pk = Signature.Public_key.of_b58check_exn pk; - sk = Signature.Secret_key.of_b58check_exn sk; + pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh; + pk = Tezos_crypto.Signature.Public_key.of_b58check_exn pk; + sk = Tezos_crypto.Signature.Secret_key.of_b58check_exn sk; } in let accounts = List.map to_account initial_accounts in @@ -440,9 +455,9 @@ let patch_context ctxt ~json = predecessor = Test_utils.genesis.block; timestamp = Test_utils.genesis.time; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; fitness = []; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } in let proto_params = @@ -450,7 +465,7 @@ let patch_context ctxt ~json = in let* ctxt = Context_ops.add ctxt ["version"] (Bytes.of_string "genesis") in let* ctxt = Context_ops.add ctxt protocol_param_key proto_params in - let* r = Main.init Chain_id.zero ctxt shell in + let* r = Main.init Tezos_crypto.Chain_id.zero ctxt shell in match r with | Error e -> failwith "%a" Environment.Error_monad.pp_trace e | Ok {context; _} -> return_ok context @@ -516,7 +531,9 @@ let apply ctxt chain_id ~policy ?(operations = empty_operations) pred = let* {shell; contents; baker} = Forge.forge_header rpc_ctxt ?policy ~operations pred in - let protocol_data = {Block_header.contents; signature = Signature.zero} in + let protocol_data = + {Block_header.contents; signature = Tezos_crypto.Signature.zero} + in let*! context = match Store.Block.block_metadata_hash pred with | None -> Lwt.return ctxt @@ -607,7 +624,7 @@ let apply ctxt chain_id ~policy ?(operations = empty_operations) pred = header.protocol_data in let block_hash_metadata = - Some (Block_metadata_hash.hash_bytes [block_header_metadata]) + Some (Tezos_crypto.Block_metadata_hash.hash_bytes [block_header_metadata]) in let block_header = {Tezos_base.Block_header.shell = header.shell; protocol_data} @@ -615,7 +632,8 @@ let apply ctxt chain_id ~policy ?(operations = empty_operations) pred = let operations_metadata_hashes = Some (List.map - (List.map (fun r -> Operation_metadata_hash.hash_bytes [r])) + (List.map (fun r -> + Tezos_crypto.Operation_metadata_hash.hash_bytes [r])) (WithExceptions.List.init ~loc:__LOC__ 4 (fun _ -> []))) in return @@ -698,7 +716,7 @@ let apply_and_store chain_store ?(synchronous_merge = true) ?policy return b | None -> let h = Tezos_base.Block_header.hash block_header in - Format.eprintf "block %a already stored@." Block_hash.pp h ; + Format.eprintf "block %a already stored@." Tezos_crypto.Block_hash.pp h ; Store.Block.read_block chain_store h let bake chain_store ?synchronous_merge ?policy ?operation ?operations pred = diff --git a/src/lib_store/unix/test/test_block_store.ml b/src/lib_store/unix/test/test_block_store.ml index 6326002094c5..a1d2611a3b19 100644 --- a/src/lib_store/unix/test/test_block_store.ml +++ b/src/lib_store/unix/test/test_block_store.ml @@ -158,11 +158,11 @@ let test_storing_and_access_predecessors block_store = | None -> Alcotest.fail "expected predecessor but none found" | Some h -> Alcotest.check - (module Block_hash) + (module Tezos_crypto.Block_hash) (Format.asprintf "get %d-th predecessor of %a (%ld)" distance - Block_hash.pp + Tezos_crypto.Block_hash.pp hash level) h @@ -201,7 +201,8 @@ let make_n_consecutive_cycles pred ~cycle_length ~nb_cycles = Lwt.return (List.rev acc, head) | n -> let cycle_length = - if Block_hash.equal (fst pred) genesis_hash then cycle_length - 1 + if Tezos_crypto.Block_hash.equal (fst pred) genesis_hash then + cycle_length - 1 else cycle_length in let lafl = max 0l (snd pred) in @@ -661,10 +662,10 @@ let wrap_test ?(keep_dir = false) (name, g) = let genesis_block = Block_repr.create_genesis_block ~genesis:Test_utils.genesis - Context_hash.zero + Tezos_crypto.Context_hash.zero in let store_dir = Naming.store_dir ~dir_path in - let chain_dir = Naming.chain_dir store_dir Chain_id.zero in + let chain_dir = Naming.chain_dir store_dir Tezos_crypto.Chain_id.zero in let*! () = Lwt_utils_unix.create_dir (Naming.dir_path chain_dir) in let*! r = Block_store.create chain_dir ~genesis_block in match r with diff --git a/src/lib_store/unix/test/test_cemented_store.ml b/src/lib_store/unix/test/test_cemented_store.ml index c7b0daf17bc8..b0aaac1b8b60 100644 --- a/src/lib_store/unix/test/test_cemented_store.ml +++ b/src/lib_store/unix/test/test_cemented_store.ml @@ -107,7 +107,9 @@ let wrap_cemented_store_test (name, f) = let*! r = run (fun base_dir -> let store_dir = Naming.store_dir ~dir_path:base_dir in - let chain_dir = Naming.chain_dir store_dir Chain_id.zero in + let chain_dir = + Naming.chain_dir store_dir Tezos_crypto.Chain_id.zero + in let*! () = Lwt_unix.mkdir (Naming.dir_path chain_dir) 0o700 in let* cemented_store = Cemented_block_store.init ~readonly:false chain_dir diff --git a/src/lib_store/unix/test/test_consistency.ml b/src/lib_store/unix/test/test_consistency.ml index 11134830e4de..bab78db4ce6e 100644 --- a/src/lib_store/unix/test/test_consistency.ml +++ b/src/lib_store/unix/test/test_consistency.ml @@ -176,7 +176,7 @@ let test_protocol_level_consistency_drop_one history_mode nth in let*! ctxt = Store.Block.context_exn chain_store b in let*! proto_block = Context_ops.get_protocol ctxt in - assert (Protocol_hash.(proto = proto_block)) ; + assert (Tezos_crypto.Protocol_hash.(proto = proto_block)) ; return_unit) (Int32.to_int savepoint_level -- Int32.to_int (Store.Block.level current_head)) @@ -257,7 +257,7 @@ let test_protocol_level_consistency_remove_file history_mode in let*! ctxt = Store.Block.context_exn chain_store b in let*! proto_block = Context_ops.get_protocol ctxt in - assert (Protocol_hash.(proto = proto_block)) ; + assert (Tezos_crypto.Protocol_hash.(proto = proto_block)) ; return_unit) (Int32.to_int savepoint_level -- Int32.to_int (Store.Block.level current_head)) diff --git a/src/lib_store/unix/test/test_locator.ml b/src/lib_store/unix/test/test_locator.ml index 3ca1629aa95b..ed5ddb181d4f 100644 --- a/src/lib_store/unix/test/test_locator.ml +++ b/src/lib_store/unix/test/test_locator.ml @@ -37,11 +37,11 @@ module Assert = Lib_test.Assert (** Basic blocks *) let genesis_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisGeneskvg68z" let genesis_protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" let proto = @@ -89,7 +89,7 @@ let init_chain ?(history_mode = History_mode.Archive) base_dir = let zero = Bytes.create 0 (* adds n blocks on top of an initialized chain *) -let make_empty_chain chain_store n : Block_hash.t Lwt.t = +let make_empty_chain chain_store n : Tezos_crypto.Block_hash.t Lwt.t = let open Lwt_result_syntax in let*! genesis = Store.Block.read_block_opt chain_store genesis_hash in let genesis = WithExceptions.Option.get ~loc:__LOC__ genesis in @@ -191,7 +191,8 @@ let make_multiple_protocol_chain (chain_store : Store.Chain.t) in let block_metadata = zero in let block_metadata_hash = - Option.some @@ Block_metadata_hash.hash_bytes [block_metadata] + Option.some + @@ Tezos_crypto.Block_metadata_hash.hash_bytes [block_metadata] in (* make some cycles *) let last_allowed_fork_level = @@ -267,8 +268,8 @@ let rec repeat f n = (* ----------------------------------------------------- *) (* returns the predecessor at distance one, reading the header *) -let linear_predecessor chain_store (bh : Block_hash.t) : - Block_hash.t option Lwt.t = +let linear_predecessor chain_store (bh : Tezos_crypto.Block_hash.t) : + Tezos_crypto.Block_hash.t option Lwt.t = let open Lwt_syntax in let* b = Store.Block.read_block_opt chain_store bh in let b = WithExceptions.Option.get ~loc:__LOC__ b in @@ -276,8 +277,8 @@ let linear_predecessor chain_store (bh : Block_hash.t) : match o with None -> None | Some pred -> Some (Store.Block.hash pred) (* returns the predecessors at distance n, traversing all n intermediate blocks *) -let linear_predecessor_n chain_store (bh : Block_hash.t) (distance : int) : - Block_hash.t option Lwt.t = +let linear_predecessor_n chain_store (bh : Tezos_crypto.Block_hash.t) + (distance : int) : Tezos_crypto.Block_hash.t option Lwt.t = let open Lwt_syntax in (* let _ = Printf.printf "LP: %4i " distance; print_block_h chain bh in *) if distance < 1 then invalid_arg "distance<1" @@ -417,7 +418,7 @@ let bench_locator base_dir = @@ List.iter2 ~when_different_lengths:(TzTrace.make @@ Exn (Failure __LOC__)) (fun hn ho -> - if not (Block_hash.equal hn ho) then + if not (Tezos_crypto.Block_hash.equal hn ho) then Assert.fail_msg "Invalid locator %i" max_size) l_exp l_lin @@ -591,13 +592,13 @@ let test_protocol_locator base_dir = in Assert.assert_true "last block in locator is the checkpoint" - (Block_hash.equal last_hash caboose_hash) ; + (Tezos_crypto.Block_hash.equal last_hash caboose_hash) ; let first_hash = (WithExceptions.Option.get ~loc:__LOC__ @@ List.last_opt steps).block in Assert.assert_true "first block in locator is the head" - (Block_hash.equal first_hash head_hash) ; + (Tezos_crypto.Block_hash.equal first_hash head_hash) ; return_unit let wrap n f = diff --git a/src/lib_store/unix/test/test_snapshots.ml b/src/lib_store/unix/test/test_snapshots.ml index 2a8cabe62efd..f689a42df204 100644 --- a/src/lib_store/unix/test/test_snapshots.ml +++ b/src/lib_store/unix/test/test_snapshots.ml @@ -160,7 +160,7 @@ let export_import ~test_descr ~previously_baked_blocks ?exported_block_hash | Some hash -> Assert.equal ~msg:("export with given hash: " ^ test_descr) - ~eq:Block_hash.equal + ~eq:Tezos_crypto.Block_hash.equal (Store.Block.hash head') hash ; Lwt.return head' @@ -168,7 +168,7 @@ let export_import ~test_descr ~previously_baked_blocks ?exported_block_hash let*! checkpoint = Store.Chain.checkpoint chain_store in Assert.equal ~msg:("export checkpoint: " ^ test_descr) - ~eq:Block_hash.equal + ~eq:Tezos_crypto.Block_hash.equal (Store.Block.hash head') (fst checkpoint) ; Lwt.return head' @@ -255,7 +255,7 @@ let check_baking_continuity ~test_descr ~exported_chain_store Assert.equal ~msg:("checkpoint equality: " ^ test_descr) ~pp:(fun ppf (hash, level) -> - Format.fprintf ppf "%a (%ld)" Block_hash.pp hash level) + Format.fprintf ppf "%a (%ld)" Tezos_crypto.Block_hash.pp hash level) checkpoint checkpoint' ; return_unit diff --git a/src/lib_store/unix/test/test_store.ml b/src/lib_store/unix/test/test_store.ml index cacd0db7a28e..e82a43c444f9 100644 --- a/src/lib_store/unix/test/test_store.ml +++ b/src/lib_store/unix/test/test_store.ml @@ -60,7 +60,9 @@ let pp_print_list fmt l = Format.fprintf fmt "@[%a@]" - (Format.pp_print_list ~pp_sep:Format.pp_print_space Block_hash.pp_short) + (Format.pp_print_list + ~pp_sep:Format.pp_print_space + Tezos_crypto.Block_hash.pp_short) (List.map Store.Block.hash l) let test_path chain_store tbl = @@ -107,7 +109,9 @@ let test_ancestor chain_store tbl = | Some a -> if not - (Block_hash.equal (Store.Block.hash a) (Store.Block.hash expected)) + (Tezos_crypto.Block_hash.equal + (Store.Block.hash a) + (Store.Block.hash expected)) then Assert.fail_msg "bad ancestor %s %s" h1 h2 ; Lwt.return_unit in @@ -163,8 +167,12 @@ let test_locator chain_store tbl = (List.length expected) ; iter2_exn (fun h h2 -> - if not (Block_hash.equal h (Store.Block.hash @@ vblock tbl h2)) then - Assert.fail_msg "Invalid locator %s (expected: %s)" h1 h2) + if + not + (Tezos_crypto.Block_hash.equal + h + (Store.Block.hash @@ vblock tbl h2)) + then Assert.fail_msg "Invalid locator %s (expected: %s)" h1 h2) history expected ; Lwt.return_unit @@ -193,8 +201,10 @@ let compare s name heads l = List.iter (fun bname -> let hash = Store.Block.hash (vblock s bname) in - if not (List.exists (fun bh -> Block_hash.equal hash bh) heads) then - Assert.fail_msg "missing block in known_heads (%s: %s)" name bname) + if + not + (List.exists (fun bh -> Tezos_crypto.Block_hash.equal hash bh) heads) + then Assert.fail_msg "missing block in known_heads (%s: %s)" name bname) l let test_known_heads chain_store tbl = @@ -314,7 +324,7 @@ let test_new_blocks chain_store tbl = in if not - (Block_hash.equal + (Tezos_crypto.Block_hash.equal (Store.Block.hash ancestor) (Store.Block.hash @@ vblock tbl expected_ancestor)) then @@ -333,7 +343,7 @@ let test_new_blocks chain_store tbl = (fun h1 h2 -> if not - (Block_hash.equal + (Tezos_crypto.Block_hash.equal (Store.Block.hash h1) (Store.Block.hash @@ vblock tbl h2)) then @@ -383,7 +393,7 @@ let test_basic_checkpoint chain_store table = | None -> return_unit in if - (not (Block_hash.equal c_block (Store.Block.hash block))) + (not (Tezos_crypto.Block_hash.equal c_block (Store.Block.hash block))) && Int32.equal c_level (Store.Block.level block) then Assert.fail_msg "unexpected checkpoint" else return_unit @@ -533,7 +543,7 @@ let test_reach_target chain_store table = then if Int32.equal header.shell.level checkpoint_level - && not (Block_hash.equal checkpoint_hash c_hash) + && not (Tezos_crypto.Block_hash.equal checkpoint_hash c_hash) then Assert.fail_msg "checkpoint error" else let* _ = Store.Chain.set_head chain_store (vblock table "A2") in @@ -594,8 +604,9 @@ let test_not_may_update_target chain_store table = let testable_hash = Alcotest.testable - (fun fmt h -> Format.fprintf fmt "%s" (Block_hash.to_b58check h)) - Block_hash.equal + (fun fmt h -> + Format.fprintf fmt "%s" (Tezos_crypto.Block_hash.to_b58check h)) + Tezos_crypto.Block_hash.equal let init_block_of_identifier_test chain_store table = let open Lwt_result_syntax in @@ -623,7 +634,7 @@ let assert_failing_block_of_identifier ?(init = init_block_of_identifier_test) match r with | Ok b -> Assert.fail_msg - ~given:(Store.Block.hash b |> Block_hash.to_b58check) + ~given:(Store.Block.hash b |> Tezos_crypto.Block_hash.to_b58check) "retrieving the block did not failed as expected" | _ -> return_unit diff --git a/src/lib_store/unix/test/test_testchain.ml b/src/lib_store/unix/test/test_testchain.ml index 68fa63ce809b..bc620ba4b490 100644 --- a/src/lib_store/unix/test/test_testchain.ml +++ b/src/lib_store/unix/test/test_testchain.ml @@ -29,9 +29,10 @@ let fork_testchain chain_store (blocks, forked_block) = let open Lwt_result_syntax in let forked_block_hash = Store.Block.hash forked_block in let genesis_hash = - Block_hash.hash_bytes [Block_hash.to_bytes forked_block_hash] + Tezos_crypto.Block_hash.hash_bytes + [Tezos_crypto.Block_hash.to_bytes forked_block_hash] in - let testchain_id = Chain_id.of_block_hash genesis_hash in + let testchain_id = Tezos_crypto.Chain_id.of_block_hash genesis_hash in let head_header = Store.Block.header forked_block in let test_protocol = Tezos_protocol_alpha.Protocol.hash in let expiration = Time.Protocol.epoch in @@ -145,7 +146,10 @@ let test_shutdown store = | Some testchain'' -> let testchain_store'' = Store.Chain.testchain_store testchain'' in let testchain_id'' = Store.Chain.chain_id testchain_store'' in - Assert.equal ~eq:Chain_id.equal testchain_id testchain_id'' ; + Assert.equal + ~eq:Tezos_crypto.Chain_id.equal + testchain_id + testchain_id'' ; assert_presence_in_store testchain_store'' blocks)) let tests = diff --git a/src/lib_store/unix/test/test_utils.ml b/src/lib_store/unix/test/test_utils.ml index b3b08da6d56a..88ea48e22084 100644 --- a/src/lib_store/unix/test/test_utils.ml +++ b/src/lib_store/unix/test/test_utils.ml @@ -66,7 +66,7 @@ let equal_metadata ?msg m1 m2 = Assert.equal ?msg ~pp ~eq m1 m2 let genesis_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2" let genesis = @@ -166,7 +166,7 @@ let dummy_patch_context ctxt = let*! ctxt = Context_ops.add ctxt ["protocol_parameters"] proto_params in let*! res = Protocol.Main.init - Chain_id.zero + Tezos_crypto.Chain_id.zero ctxt { level = 0l; @@ -174,9 +174,9 @@ let dummy_patch_context ctxt = predecessor = genesis.block; timestamp = genesis.time; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; fitness = []; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } in let*? {context; _} = Environment.wrap_tzresult res in @@ -338,7 +338,8 @@ let wrap_simple_store_init_test ?history_mode ?(speed = `Quick) ?patch_context (wrap_simple_store_init ?history_mode ?patch_context ?keep_dir ?with_gc f) let make_raw_block ?min_lafl ?(max_operations_ttl = default_max_operations_ttl) - ?(constants = default_protocol_constants) ?(context = Context_hash.zero) + ?(constants = default_protocol_constants) + ?(context = Tezos_crypto.Context_hash.zero) (pred_block_hash, pred_block_level) = let level = Int32.succ pred_block_level in let header = @@ -351,7 +352,7 @@ let make_raw_block ?min_lafl ?(max_operations_ttl = default_max_operations_ttl) timestamp = Time.Protocol.(add epoch (Int64.of_int32 level)); validation_passes = List.length Tezos_protocol_alpha.Protocol.Main.validation_passes; - operations_hash = Operation_list_list_hash.zero; + operations_hash = Tezos_crypto.Operation_list_list_hash.zero; fitness = [Bytes.create 8]; context; }; @@ -414,12 +415,13 @@ let make_raw_block ?min_lafl ?(max_operations_ttl = default_max_operations_ttl) header; operations; block_metadata_hash = - (if Random.bool () then Some Block_metadata_hash.zero else None); + (if Random.bool () then Some Tezos_crypto.Block_metadata_hash.zero + else None); operations_metadata_hashes = (if Random.bool () then Some (List.map - (List.map (fun _ -> Operation_metadata_hash.zero)) + (List.map (fun _ -> Tezos_crypto.Operation_metadata_hash.zero)) operations) else None); }; @@ -432,13 +434,13 @@ let prune_block block = block.Block_repr.metadata <- None let pp_block fmt b = let h, lvl = Store.Block.descriptor b in - Format.fprintf fmt "%a (%ld)" Block_hash.pp h lvl + Format.fprintf fmt "%a (%ld)" Tezos_crypto.Block_hash.pp h lvl let raw_descriptor b = (Block_repr.hash b, Block_repr.level b) let pp_raw_block fmt b = let h, lvl = raw_descriptor b in - Format.fprintf fmt "%a (%ld)" Block_hash.pp h lvl + Format.fprintf fmt "%a (%ld)" Tezos_crypto.Block_hash.pp h lvl let store_raw_block chain_store (raw_block : Block_repr.t) = let open Lwt_syntax in @@ -487,7 +489,7 @@ let store_raw_block chain_store (raw_block : Block_repr.t) = | Ok None -> Alcotest.failf "store_raw_block: could not store block %a (%ld)" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_repr.hash raw_block) (Block_repr.level raw_block) | Error _ as err -> Lwt.return err @@ -789,7 +791,8 @@ module Example_tree = struct (fun k b o -> match o with | None -> - if Block_hash.equal block_hash (Store.Block.hash b) then Some k + if Tezos_crypto.Block_hash.equal block_hash (Store.Block.hash b) + then Some k else None | x -> x) tbl -- GitLab From bb13d230db340773b553826c0db0ec885b76d68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:29:58 +0200 Subject: [PATCH 12/30] Shell: unopen Crypto --- src/lib_shell/block_directory.ml | 5 +- src/lib_shell/block_validator.ml | 10 +- src/lib_shell/block_validator.mli | 6 +- src/lib_shell/block_validator_events.ml | 36 ++--- src/lib_shell/block_validator_process.ml | 41 +++--- src/lib_shell/block_validator_process.mli | 11 +- src/lib_shell/bootstrap_pipeline.ml | 17 ++- src/lib_shell/bootstrap_pipeline_event.ml | 20 +-- src/lib_shell/chain_directory.ml | 9 +- src/lib_shell/chain_directory.mli | 8 +- src/lib_shell/chain_validator.ml | 30 +++-- src/lib_shell/chain_validator.mli | 10 +- src/lib_shell/chain_validator_events.ml | 12 +- src/lib_shell/distributed_db.ml | 31 +++-- src/lib_shell/distributed_db.mli | 24 ++-- src/lib_shell/distributed_db_event.ml | 2 +- src/lib_shell/distributed_db_message.ml | 80 ++++++----- src/lib_shell/distributed_db_message.mli | 35 ++--- src/lib_shell/distributed_db_requester.ml | 42 +++--- src/lib_shell/distributed_db_requester.mli | 15 ++- src/lib_shell/injection_directory.ml | 12 +- src/lib_shell/legacy_prevalidation.ml | 16 ++- src/lib_shell/legacy_prevalidation.mli | 15 ++- .../legacy_prevalidator_classification.ml | 80 ++++++----- .../legacy_prevalidator_classification.mli | 53 ++++---- src/lib_shell/legacy_prevalidator_internal.ml | 127 ++++++++++-------- .../legacy_prevalidator_internal.mli | 20 +-- .../legacy_prevalidator_pending_operations.ml | 5 +- ...legacy_prevalidator_pending_operations.mli | 19 +-- src/lib_shell/monitor_directory.ml | 18 ++- src/lib_shell/node.ml | 8 +- src/lib_shell/node.mli | 2 +- src/lib_shell/node_event.ml | 8 +- src/lib_shell/p2p_reader.ml | 39 +++--- src/lib_shell/p2p_reader.mli | 15 ++- src/lib_shell/patch_context.ml | 6 +- src/lib_shell/peer_validator.ml | 24 +++- src/lib_shell/peer_validator.mli | 10 +- src/lib_shell/peer_validator_events.ml | 56 ++++---- src/lib_shell/prevalidation.ml | 16 ++- src/lib_shell/prevalidation.mli | 17 ++- src/lib_shell/prevalidator.ml | 16 +-- src/lib_shell/prevalidator.mld | 2 +- src/lib_shell/prevalidator.mli | 9 +- src/lib_shell/prevalidator_classification.ml | 80 ++++++----- src/lib_shell/prevalidator_classification.mli | 53 ++++---- src/lib_shell/prevalidator_events.ml | 20 +-- src/lib_shell/prevalidator_internal.ml | 127 ++++++++++-------- src/lib_shell/prevalidator_internal.mli | 20 +-- src/lib_shell/prevalidator_internal_common.ml | 13 +- .../prevalidator_internal_common.mli | 3 +- .../prevalidator_pending_operations.ml | 5 +- .../prevalidator_pending_operations.mli | 19 +-- src/lib_shell/protocol_directory.ml | 7 +- src/lib_shell/protocol_validator.ml | 23 ++-- src/lib_shell/protocol_validator.mli | 7 +- src/lib_shell/protocol_validator_event.ml | 6 +- src/lib_shell/shell_metrics.ml | 2 +- src/lib_shell/shell_metrics.mli | 2 +- src/lib_shell/shell_plugin.ml | 47 ++++--- src/lib_shell/shell_plugin.mli | 20 +-- src/lib_shell/test/generators.ml | 52 +++---- src/lib_shell/test/generators_tree.ml | 27 ++-- src/lib_shell/test/legacy_generators.ml | 52 +++---- src/lib_shell/test/legacy_generators_tree.ml | 27 ++-- .../test/legacy_test_prevalidation.ml | 21 +-- .../test/legacy_test_prevalidation_t.ml | 33 +++-- ...legacy_test_prevalidator_classification.ml | 127 +++++++++++------- ..._prevalidator_classification_operations.ml | 98 ++++++++------ ...cy_test_prevalidator_pending_operations.ml | 2 +- src/lib_shell/test/shell_test_helpers.ml | 6 +- .../test/test_consensus_heuristic.ml | 28 ++-- src/lib_shell/test/test_node.ml | 2 +- src/lib_shell/test/test_peer_validator.ml | 6 +- src/lib_shell/test/test_prevalidation.ml | 21 +-- src/lib_shell/test/test_prevalidation_t.ml | 33 +++-- .../test/test_prevalidator_classification.ml | 127 +++++++++++------- ..._prevalidator_classification_operations.ml | 98 ++++++++------ .../test_prevalidator_pending_operations.ml | 2 +- src/lib_shell/test/test_protocol_validator.ml | 12 +- src/lib_shell/validator.ml | 26 ++-- src/lib_shell/validator.mli | 17 ++- src/lib_shell/validator_event.ml | 4 +- src/lib_shell/worker_directory.ml | 12 +- 84 files changed, 1338 insertions(+), 986 deletions(-) diff --git a/src/lib_shell/block_directory.ml b/src/lib_shell/block_directory.ml index 873047a41633..deb14000afe1 100644 --- a/src/lib_shell/block_directory.ml +++ b/src/lib_shell/block_directory.ml @@ -62,7 +62,8 @@ let read_partial_context = let build_raw_header_rpc_directory (module Proto : Block_services.PROTO) = let open Lwt_result_syntax in let dir : - (Store.chain_store * Block_hash.t * Block_header.t) Tezos_rpc.Directory.t + (Store.chain_store * Tezos_crypto.Block_hash.t * Block_header.t) + Tezos_rpc.Directory.t ref = ref Tezos_rpc.Directory.empty in @@ -728,7 +729,7 @@ let build_raw_rpc_directory (module Proto : Block_services.PROTO) return (List.rev acc)) ; register1 S.Helpers.complete (fun (chain_store, block) prefix () () -> let* ctxt = Store.Block.context chain_store block in - let*! l1 = Base58.complete prefix in + let*! l1 = Tezos_crypto.Base58.complete prefix in let*! l2 = Next_proto.complete_b58prefix ctxt prefix in return (l1 @ l2)) ; (* merge protocol rpcs... *) diff --git a/src/lib_shell/block_validator.ml b/src/lib_shell/block_validator.ml index 0da335efa97d..30c17865ea3b 100644 --- a/src/lib_shell/block_validator.ml +++ b/src/lib_shell/block_validator.ml @@ -40,7 +40,7 @@ type validation_result = module Block_hash_ring = (val Ringo.(map_maker ~replacement:FIFO ~overflow:Strong ~accounting:Precise)) - (Block_hash) + (Tezos_crypto.Block_hash) module Name = struct type t = unit @@ -78,7 +78,7 @@ module Request = struct notify_new_block : Store.Block.t -> unit; canceler : Lwt_canceler.t option; peer : P2p_peer.Id.t option; - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.t list list; precheck_and_notify : bool; @@ -476,12 +476,12 @@ let validate w ?canceler ?peer ?(notify_new_block = fun _ -> ()) let open Lwt_result_syntax in let hashes = List.map (List.map Operation.hash) operations in let computed_hash = - Operation_list_list_hash.compute - (List.map Operation_list_hash.compute hashes) + Tezos_crypto.Operation_list_list_hash.compute + (List.map Tezos_crypto.Operation_list_hash.compute hashes) in let* () = fail_when - (Operation_list_list_hash.compare + (Tezos_crypto.Operation_list_list_hash.compare computed_hash header.shell.operations_hash <> 0) diff --git a/src/lib_shell/block_validator.mli b/src/lib_shell/block_validator.mli index ebf631dc08f5..6f308f91e339 100644 --- a/src/lib_shell/block_validator.mli +++ b/src/lib_shell/block_validator.mli @@ -98,7 +98,7 @@ val validate : ?notify_new_block:(Store.Block.t -> unit) -> ?precheck_and_notify:bool -> Distributed_db.chain_db -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t list list -> block_validity Lwt.t @@ -129,7 +129,7 @@ val fetch_and_compile_protocol : t -> ?peer:P2p_peer.Id.t -> ?timeout:Time.System.Span.t -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Registered_protocol.t tzresult Lwt.t (** [context_garbage_collection bv chain_store context_hash] moves the @@ -137,7 +137,7 @@ val fetch_and_compile_protocol : to the lower layer. For full and rolling nodes, this is considered as a garbage collection. *) val context_garbage_collection : - t -> Context_ops.index -> Context_hash.t -> unit tzresult Lwt.t + t -> Context_ops.index -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t val shutdown : t -> unit Lwt.t diff --git a/src/lib_shell/block_validator_events.ml b/src/lib_shell/block_validator_events.ml index 2eec997289a6..d70510e38a96 100644 --- a/src/lib_shell/block_validator_events.ml +++ b/src/lib_shell/block_validator_events.ml @@ -34,9 +34,9 @@ let validation_success = ~name:"validation_success" ~msg:"block {block} validated {worker_status}" ~level:Notice - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:Worker_types.pp_status - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("worker_status", Worker_types.request_status_encoding) let validation_failure = @@ -45,10 +45,10 @@ let validation_failure = ~name:"validation_failed" ~msg:"validation of block {block} failed, {worker_status}: {errors}" ~level:Notice - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:Worker_types.pp_status ~pp3:pp_print_top_error_of_trace - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("worker_status", Worker_types.request_status_encoding) ("errors", Error_monad.trace_encoding) @@ -58,8 +58,8 @@ let previously_validated = ~name:"previously_validated" ~msg:"previously validated block {hash} (after pipe)" ~level:Debug - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) let validating_block = declare_1 @@ -67,8 +67,8 @@ let validating_block = ~name:"validating_block" ~msg:"balidating block {hash}" ~level:Debug - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) let preapplication_success = declare_2 @@ -104,10 +104,10 @@ let validation_failure_after_precheck = ~msg: "validation of block {block} failed but precheck succeeded, \ {worker_status}: {errors}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:Worker_types.pp_status ~pp3:pp_print_top_error_of_trace - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("worker_status", Worker_types.request_status_encoding) ("errors", Tezos_rpc.Error.encoding) @@ -117,10 +117,10 @@ let precheck_failure = ~name:"precheck_failure" ~level:Notice ~msg:"precheck of block {block} failed, {worker_status}: {errors}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:Worker_types.pp_status ~pp3:pp_print_top_error_of_trace - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("worker_status", Worker_types.request_status_encoding) ("errors", Tezos_rpc.Error.encoding) @@ -130,8 +130,8 @@ let prechecked_block = ~name:"prechecked_block" ~level:Notice ~msg:"prechecked block {hash}" - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) let prechecking_block = declare_1 @@ -139,8 +139,8 @@ let prechecking_block = ~name:"prechecking_block" ~level:Debug ~msg:"prechecking block {hash}" - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) let could_not_find_context = declare_1 @@ -148,5 +148,5 @@ let could_not_find_context = ~name:"could_not_find_context" ~level:Debug ~msg:"could not find context for block {hash}" - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) diff --git a/src/lib_shell/block_validator_process.ml b/src/lib_shell/block_validator_process.ml index 130112b79aa7..0a5962ead07c 100644 --- a/src/lib_shell/block_validator_process.ml +++ b/src/lib_shell/block_validator_process.ml @@ -62,16 +62,17 @@ module type S = sig val preapply_block : t -> - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> timestamp:Time.Protocol.t -> protocol_data:bytes -> - live_blocks:Block_hash.Set.t -> - live_operations:Operation_hash.Set.t -> + live_blocks:Tezos_crypto.Block_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> predecessor_shell_header:Block_header.shell_header -> - predecessor_hash:Block_hash.t -> + predecessor_hash:Tezos_crypto.Block_hash.t -> predecessor_max_operations_ttl:int -> - predecessor_block_metadata_hash:Block_metadata_hash.t option -> - predecessor_ops_metadata_hash:Operation_metadata_list_list_hash.t option -> + predecessor_block_metadata_hash:Tezos_crypto.Block_metadata_hash.t option -> + predecessor_ops_metadata_hash: + Tezos_crypto.Operation_metadata_list_list_hash.t option -> Operation.t list list -> (Block_header.shell_header * error Preapply_result.t list) tzresult Lwt.t @@ -80,18 +81,24 @@ module type S = sig Store.chain_store -> predecessor:Store.Block.t -> Block_header.t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Operation.t trace trace -> unit tzresult Lwt.t val context_garbage_collection : - t -> Context_ops.index -> Context_hash.t -> unit tzresult Lwt.t + t -> Context_ops.index -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t - val commit_genesis : t -> chain_id:Chain_id.t -> Context_hash.t tzresult Lwt.t + val commit_genesis : + t -> + chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Context_hash.t tzresult Lwt.t (** [init_test_chain] must only be called on a forking block. *) val init_test_chain : - t -> Chain_id.t -> Store.Block.t -> Block_header.t tzresult Lwt.t + t -> + Tezos_crypto.Chain_id.t -> + Store.Block.t -> + Block_header.t tzresult Lwt.t val reconfigure_event_logging : t -> Internal_event_unix.Configuration.t -> unit tzresult Lwt.t @@ -126,10 +133,10 @@ module Internal_validator_process = struct ~level:Debug ~name:"seq_validation_request" ~msg:"requesting validation of {block} for chain {chain}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) - ~pp2:Chain_id.pp - ("chain", Chain_id.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Chain_id.pp + ("chain", Tezos_crypto.Chain_id.encoding) let validation_success = declare_2 @@ -137,8 +144,8 @@ module Internal_validator_process = struct ~level:Debug ~name:"seq_validation_success" ~msg:"block {block} successfully validated in {timespan}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:Time.System.Span.pp_hum ("timespan", Time.System.Span.encoding) @@ -825,7 +832,7 @@ module External_validator_process = struct let commit_genesis validator ~chain_id = let request = External_validation.Commit_genesis {chain_id} in - send_request validator request Context_hash.encoding + send_request validator request Tezos_crypto.Context_hash.encoding let init_test_chain validator chain_id forking_block = let forked_header = Store.Block.header forking_block in diff --git a/src/lib_shell/block_validator_process.mli b/src/lib_shell/block_validator_process.mli index d2316afe52e2..7cc591d8fe4a 100644 --- a/src/lib_shell/block_validator_process.mli +++ b/src/lib_shell/block_validator_process.mli @@ -102,17 +102,20 @@ val precheck_block : Store.chain_store -> predecessor:Store.Block.t -> Block_header.t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Operation.t trace trace -> unit tzresult Lwt.t (** [context_garbage_collection context_index context_hash] removes contexts that are below [context_hash] in the context tree. *) val context_garbage_collection : - t -> Context_ops.index -> Context_hash.t -> unit tzresult Lwt.t + t -> Context_ops.index -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t -val commit_genesis : t -> chain_id:Chain_id.t -> Context_hash.t tzresult Lwt.t +val commit_genesis : + t -> + chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Context_hash.t tzresult Lwt.t (** [init_test_chain] must only be called on a forking block. *) val init_test_chain : - t -> Chain_id.t -> Store.Block.t -> Block_header.t tzresult Lwt.t + t -> Tezos_crypto.Chain_id.t -> Store.Block.t -> Block_header.t tzresult Lwt.t diff --git a/src/lib_shell/bootstrap_pipeline.ml b/src/lib_shell/bootstrap_pipeline.ml index feee9347ddc2..ca15e74d3be5 100644 --- a/src/lib_shell/bootstrap_pipeline.ml +++ b/src/lib_shell/bootstrap_pipeline.ml @@ -127,9 +127,12 @@ type t = { locator : Block_locator.t; block_validator : Block_validator.t; notify_new_block : Store.Block.t -> unit; - fetched_headers : (Block_hash.t * Block_header.t) list Lwt_pipe.Bounded.t; + fetched_headers : + (Tezos_crypto.Block_hash.t * Block_header.t) list Lwt_pipe.Bounded.t; fetched_blocks : - (Block_hash.t * Block_header.t * Operation.t list list tzresult Lwt.t) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list tzresult Lwt.t) Lwt_pipe.Bounded.t; (* HACK, a worker should be able to return the 'error'. *) @@ -167,7 +170,7 @@ let assert_acceptable_header pipeline hash (header : Block_header.t) = let* () = fail_when (Compare.Int32.(header.shell.level = checkpoint_level) - && not (Block_hash.equal hash checkpoint_hash)) + && not (Tezos_crypto.Block_hash.equal hash checkpoint_hash)) (Checkpoint_error (hash, Some pipeline.peer_id)) in let*! current_head = Store.Chain.current_head chain_store in @@ -218,7 +221,7 @@ let fetch_step pipeline (step : Block_locator.step) = Bootstrap_pipeline_event.(emit step_too_long) pipeline.peer_id in tzfail (Invalid_locator (pipeline.peer_id, pipeline.locator)) - else if Block_hash.equal hash step.predecessor then + else if Tezos_crypto.Block_hash.equal hash step.predecessor then if step.strict_step && cpt <> step.step then let*! () = Bootstrap_pipeline_event.(emit step_too_short) pipeline.peer_id @@ -585,7 +588,7 @@ let create ?(notify_new_block = fun _ -> ()) ~block_header_timeout "bootstrap_pipeline-headers_fetch.%a.%a" P2p_peer.Id.pp_short peer_id - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short locator.Block_locator.head_hash) ~on_event:Internal_event.Lwt_worker_logger.on_event ~run:(fun () -> headers_fetch_worker_loop pipeline) @@ -596,7 +599,7 @@ let create ?(notify_new_block = fun _ -> ()) ~block_header_timeout "bootstrap_pipeline-operations_fetch.%a.%a" P2p_peer.Id.pp_short peer_id - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short locator.head_hash) ~on_event:Internal_event.Lwt_worker_logger.on_event ~run:(fun () -> operations_fetch_worker_loop pipeline) @@ -607,7 +610,7 @@ let create ?(notify_new_block = fun _ -> ()) ~block_header_timeout "bootstrap_pipeline-validation.%a.%a" P2p_peer.Id.pp_short peer_id - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short locator.head_hash) ~on_event:Internal_event.Lwt_worker_logger.on_event ~run:(fun () -> validation_worker_loop pipeline) diff --git a/src/lib_shell/bootstrap_pipeline_event.ml b/src/lib_shell/bootstrap_pipeline_event.ml index d2383901e429..b75565607d60 100644 --- a/src/lib_shell/bootstrap_pipeline_event.ml +++ b/src/lib_shell/bootstrap_pipeline_event.ml @@ -66,8 +66,8 @@ let fetching_step_from_peer = ("step_number", Data_encoding.int31) ("number_of_steps", Data_encoding.int31) ("step_length", Data_encoding.int31) - ("block", Block_hash.encoding) - ("predecessor", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) let fetching_block_header_from_peer = @@ -76,7 +76,7 @@ let fetching_block_header_from_peer = ~name:"fetching_block_header_from_peer" ~msg:"fetched header {block} from {peer_id} {block_fetched}/{step_length}" ~level:Debug - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) ("block_fetched", Data_encoding.int31) ("step_length", Data_encoding.int31) @@ -97,7 +97,7 @@ let fetching_operations = ~name:"fetching_operations" ~msg:"fetching operations of block {block_hash} from peer {peer_id}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) let fetched_operations = @@ -106,7 +106,7 @@ let fetched_operations = ~name:"fetched_operations" ~msg:"fetched operations of block {block_hash} from peer {peer_id}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) let requesting_validation = @@ -115,7 +115,7 @@ let requesting_validation = ~name:"requesting_validation" ~msg:"requesting validation for block {block_hash} from peer {peer_id}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) let validated_block = @@ -124,7 +124,7 @@ let validated_block = ~name:"validated_block" ~msg:"validated block {block_hash} from peer {peer_id}" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) (* warning level events *) @@ -137,7 +137,7 @@ let request_operations_timeout = "request for operations {block_hash}:{operations_index_tag} from peer \ {peer_id} timed out" ~level:Warning - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("operations_index_tag", Data_encoding.int31) ("peer_id", P2p_peer.Id.encoding) @@ -163,7 +163,7 @@ let header_request_timeout = ~name:"header_request_timeout" ~msg:"request for header {block_hash} from peer {peer_id} timed out" ~level:Warning - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) let locator_contains_future_block = @@ -172,7 +172,7 @@ let locator_contains_future_block = ~name:"locator_contains_future_block" ~msg:"block locator {block_hash} from peer {peer_id} contains future blocks" ~level:Warning - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) ("time", Time.System.encoding) ("block_time", Time.Protocol.encoding) diff --git a/src/lib_shell/chain_directory.ml b/src/lib_shell/chain_directory.ml index 318301a839d4..dba4b4c504b5 100644 --- a/src/lib_shell/chain_directory.ml +++ b/src/lib_shell/chain_directory.ml @@ -63,7 +63,8 @@ let predecessors chain_store ignored length head = match o with | None -> return (List.rev acc) | Some pred -> - if Block_hash.Set.mem block ignored then return (List.rev acc) + if Tezos_crypto.Block_hash.Set.mem block ignored then + return (List.rev acc) else loop (pred :: acc) (length - 1) pred in let head_hash = Store.Block.hash head in @@ -111,12 +112,12 @@ let list_blocks chain_store ?(length = 1) ?min_date heads = let* predecessors = predecessors chain_store ignored length block in let ignored = List.fold_left - (fun acc v -> Block_hash.Set.add v acc) + (fun acc v -> Tezos_crypto.Block_hash.Set.add v acc) ignored predecessors in return (ignored, predecessors :: acc)) - (Block_hash.Set.empty, []) + (Tezos_crypto.Block_hash.Set.empty, []) requested_heads in return (List.rev blocks) @@ -190,7 +191,7 @@ let rpc_directory validator = register0 S.Invalid_blocks.list (fun chain_store () () -> let convert (hash, {Store_types.level; errors}) = {hash; level; errors} in let*! invalid_blocks_map = Store.Block.read_invalid_blocks chain_store in - let blocks = Block_hash.Map.bindings invalid_blocks_map in + let blocks = Tezos_crypto.Block_hash.Map.bindings invalid_blocks_map in return (List.map convert blocks)) ; register1 S.Invalid_blocks.get (fun chain_store hash () () -> let*! o = Store.Block.read_invalid_block_opt chain_store hash in diff --git a/src/lib_shell/chain_directory.mli b/src/lib_shell/chain_directory.mli index 4e15fa460529..20b82984748c 100644 --- a/src/lib_shell/chain_directory.mli +++ b/src/lib_shell/chain_directory.mli @@ -24,15 +24,17 @@ (* *) (*****************************************************************************) -val get_chain_id : Store.t -> Chain_services.chain -> Chain_id.t Lwt.t +val get_chain_id : + Store.t -> Chain_services.chain -> Tezos_crypto.Chain_id.t Lwt.t val get_chain_id_opt : - Store.t -> Chain_services.chain -> Chain_id.t option Lwt.t + Store.t -> Chain_services.chain -> Tezos_crypto.Chain_id.t option Lwt.t val get_chain_store_exn : Store.t -> Chain_services.chain -> Store.chain_store Lwt.t -val get_checkpoint : Store.t -> Chain_services.chain -> Block_hash.t Lwt.t +val get_checkpoint : + Store.t -> Chain_services.chain -> Tezos_crypto.Block_hash.t Lwt.t val rpc_directory : Validator.t -> Store.chain_store Tezos_rpc.Directory.t diff --git a/src/lib_shell/chain_validator.ml b/src/lib_shell/chain_validator.ml index c629547d7274..5468186aaf80 100644 --- a/src/lib_shell/chain_validator.ml +++ b/src/lib_shell/chain_validator.ml @@ -27,15 +27,15 @@ open Chain_validator_worker_state module Name = struct - type t = Chain_id.t + type t = Tezos_crypto.Chain_id.t - let encoding = Chain_id.encoding + let encoding = Tezos_crypto.Chain_id.encoding let base = ["validator"; "chain"] - let pp = Chain_id.pp_short + let pp = Tezos_crypto.Chain_id.pp_short - let equal = Chain_id.equal + let equal = Tezos_crypto.Chain_id.equal end module Request = struct @@ -50,7 +50,7 @@ module Request = struct -> (update, error trace) t | Notify_branch : P2p_peer.Id.t * Block_locator.t -> (unit, Empty.t) t | Notify_head : - P2p_peer.Id.t * Block_hash.t * Block_header.t * Mempool.t + P2p_peer.Id.t * Tezos_crypto.Block_hash.t * Block_header.t * Mempool.t -> (unit, Empty.t) t | Disconnection : P2p_peer.Id.t -> (unit, Empty.t) t @@ -71,7 +71,7 @@ module Types = struct block_validator : Block_validator.t; block_validator_process : Block_validator_process.t; global_valid_block_input : Store.Block.t Lwt_watcher.input; - global_chains_input : (Chain_id.t * bool) Lwt_watcher.input; + global_chains_input : (Tezos_crypto.Chain_id.t * bool) Lwt_watcher.input; start_prevalidator : bool; prevalidator_limits : Shell_limits.prevalidator_limits; peer_validator_limits : Shell_limits.peer_validator_limits; @@ -115,7 +115,7 @@ let shutdown_child nv active_chains = (fun ({parameters = {chain_store; global_chains_input; _}; _}, shutdown) -> let test_chain_id = Store.Chain.chain_id chain_store in Lwt_watcher.notify global_chains_input (test_chain_id, false) ; - Chain_id.Table.remove active_chains test_chain_id ; + Tezos_crypto.Chain_id.Table.remove active_chains test_chain_id ; let* r = Store.Chain.shutdown_testchain nv.parameters.chain_store in match r with | Error _err -> @@ -158,7 +158,7 @@ let notify_new_block w peer block = let nv = Worker.state w in Option.iter (fun id -> - List.assoc ~equal:Chain_id.equal id (Worker.list table) + List.assoc ~equal:Tezos_crypto.Chain_id.equal id (Worker.list table) |> Option.iter (fun w -> let nv = Worker.state w in Lwt_watcher.notify nv.valid_block_input block)) @@ -226,7 +226,8 @@ let may_switch_test_chain w active_chains spawn_child block = | Some (child, _) -> let child_chain_store = child.parameters.chain_store in let child_genesis = Store.Chain.genesis child_chain_store in - Lwt.return (Block_hash.equal child_genesis.block genesis_hash) + Lwt.return + (Tezos_crypto.Block_hash.equal child_genesis.block genesis_hash) in let expired = expiration < block_header.shell.timestamp in if expired && activated then @@ -364,7 +365,7 @@ let safe_get_prevalidator_filter hash = (* This should not happen: it should be handled in the validator. *) failwith "chain_validator: missing protocol '%a' for the current block." - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short hash | Some protocol -> let* () = Events.(emit prevalidator_filter_not_found) hash in @@ -482,7 +483,7 @@ let on_validation_request w peer start_testchain active_chains spawn_child block in Lwt_watcher.notify nv.new_head_input block ; let is_head_increment = - Block_hash.equal head_hash block_header.shell.predecessor + Tezos_crypto.Block_hash.equal head_hash block_header.shell.predecessor in let event = if is_head_increment then Head_increment else Branch_switch @@ -861,7 +862,10 @@ let rec create ~start_testchain ~active_chains ?parent ~block_validator_process } in let* w = Worker.launch table chain_id parameters (module Handlers) in - Chain_id.Table.add active_chains (Store.Chain.chain_id chain_store) w ; + Tezos_crypto.Chain_id.Table.add + active_chains + (Store.Chain.chain_id chain_store) + w ; register_garbage_collect_callback w ; Lwt_watcher.notify global_chains_input (Store.Chain.chain_id chain_store, true) ; return w @@ -908,7 +912,7 @@ let child w = (Worker.state w).child (fun ({parameters = {chain_store; _}; _}, _) -> List.assoc - ~equal:Chain_id.equal + ~equal:Tezos_crypto.Chain_id.equal (Store.Chain.chain_id chain_store) (Worker.list table)) diff --git a/src/lib_shell/chain_validator.mli b/src/lib_shell/chain_validator.mli index c01122f1b791..94e05ce5aa7c 100644 --- a/src/lib_shell/chain_validator.mli +++ b/src/lib_shell/chain_validator.mli @@ -29,19 +29,19 @@ type t val create : start_prevalidator:bool -> start_testchain:bool -> - active_chains:t Chain_id.Table.t -> + active_chains:t Tezos_crypto.Chain_id.Table.t -> block_validator_process:Block_validator_process.t -> Shell_limits.peer_validator_limits -> Shell_limits.prevalidator_limits -> Block_validator.t -> Store.Block.t Lwt_watcher.input -> - (Chain_id.t * bool) Lwt_watcher.input -> + (Tezos_crypto.Chain_id.t * bool) Lwt_watcher.input -> Distributed_db.t -> Store.chain_store -> Shell_limits.chain_validator_limits -> t tzresult Lwt.t -val chain_id : t -> Chain_id.t +val chain_id : t -> Tezos_crypto.Chain_id.t val chain_store : t -> Store.chain_store @@ -69,7 +69,7 @@ val reconfigure_event_logging : val validate_block : t -> ?force:bool -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t list list -> unit tzresult Lwt.t @@ -80,7 +80,7 @@ val valid_block_watcher : t -> Store.Block.t Lwt_stream.t * Lwt_watcher.stopper val new_head_watcher : t -> Store.Block.t Lwt_stream.t * Lwt_watcher.stopper -val running_workers : unit -> (Chain_id.t * t) list +val running_workers : unit -> (Tezos_crypto.Chain_id.t * t) list val status : t -> Worker_types.worker_status diff --git a/src/lib_shell/chain_validator_events.ml b/src/lib_shell/chain_validator_events.ml index cb4e08dd1074..20f9c4df2d26 100644 --- a/src/lib_shell/chain_validator_events.ml +++ b/src/lib_shell/chain_validator_events.ml @@ -34,9 +34,9 @@ let updated_to_checkpoint = ~name:"updated_to_checkpoint" ~msg:"updated to checkpoint {block_hash} (running in mode {history_mode})" ~level:Notice - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:History_mode.Legacy.pp - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("history_mode", History_mode.Legacy.encoding) let prevalidator_filter_not_found = @@ -45,8 +45,8 @@ let prevalidator_filter_not_found = ~name:"prevalidator_filter_not_found" ~msg:"no prevalidator filter found for protocol {protocol_hash}" ~level:Warning - ~pp1:Protocol_hash.pp - ("protocol_hash", Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp + ("protocol_hash", Tezos_crypto.Protocol_hash.encoding) let prevalidator_reinstantiation_failure = declare_1 @@ -72,8 +72,8 @@ let loading_protocol = ~name:"loading_protocol" ~level:Notice ~msg:"loading non-embedded protocol {protocol} from disk" - ~pp1:Protocol_hash.pp - ("protocol", Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp + ("protocol", Tezos_crypto.Protocol_hash.encoding) let bootstrapped = declare_0 diff --git a/src/lib_shell/distributed_db.ml b/src/lib_shell/distributed_db.ml index 7fc88a00185f..712204139e69 100644 --- a/src/lib_shell/distributed_db.ml +++ b/src/lib_shell/distributed_db.ml @@ -56,7 +56,7 @@ type db = { p2p : p2p; p2p_readers : P2p_reader.t P2p_peer.Table.t; disk : Store.t; - active_chains : P2p_reader.chain_db Chain_id.Table.t; + active_chains : P2p_reader.chain_db Tezos_crypto.Chain_id.Table.t; protocol_db : Distributed_db_requester.Raw_protocol.t; } @@ -74,7 +74,8 @@ let information {global_db; reader_chain_db} = { Chain_validator_worker_state.Distributed_db_state.p2p_readers_length = P2p_peer.Table.length global_db.p2p_readers; - active_chains_length = Chain_id.Table.length global_db.active_chains; + active_chains_length = + Tezos_crypto.Chain_id.Table.length global_db.active_chains; operation_db = Distributed_db_requester.Raw_operation.state_of_t reader_chain_db.operation_db; @@ -114,7 +115,7 @@ let create disk p2p = let protocol_db = Distributed_db_requester.Raw_protocol.create global_request disk in - let active_chains = Chain_id.Table.create ~random:true 17 in + let active_chains = Tezos_crypto.Chain_id.Table.create ~random:true 17 in let p2p_readers = P2p_peer.Table.create ~random:true 17 in let db = {p2p; p2p_readers; disk; active_chains; protocol_db} in db @@ -132,7 +133,7 @@ let activate P2p.activate p2p ; let chain_id = Store.Chain.chain_id chain_store in let reader_chain_db = - match Chain_id.Table.find active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find active_chains chain_id with | Some local_db -> local_db | None -> let active_peers = ref P2p_peer.Set.empty in @@ -183,7 +184,7 @@ let activate trace) (fun exc -> Format.eprintf "Uncaught exception: %s\n%!" (Printexc.to_string exc)) ; - Chain_id.Table.add active_chains chain_id local_db ; + Tezos_crypto.Chain_id.Table.add active_chains chain_id local_db ; local_db in {global_db; reader_chain_db} @@ -192,7 +193,7 @@ let deactivate chain_db = let open Lwt_syntax in let {active_chains; p2p; _} = chain_db.global_db in let chain_id = Store.Chain.chain_id chain_db.reader_chain_db.chain_store in - Chain_id.Table.remove active_chains chain_id ; + Tezos_crypto.Chain_id.Table.remove active_chains chain_id ; let sends = P2p_peer.Table.iter_ep (fun gid conn -> @@ -218,7 +219,9 @@ let deactivate chain_db = let get_chain global_db chain_id = let open Option_syntax in - let+ reader_chain_db = Chain_id.Table.find global_db.active_chains chain_id in + let+ reader_chain_db = + Tezos_crypto.Chain_id.Table.find global_db.active_chains chain_id + in {global_db; reader_chain_db} let greylist {global_db = {p2p; _}; _} peer_id = @@ -236,7 +239,7 @@ let shutdown {p2p_readers; active_chains; _} = (fun _peer_id reader -> P2p_reader.shutdown reader) p2p_readers in - Chain_id.Table.iter_p + Tezos_crypto.Chain_id.Table.iter_p (fun _ reader_chain_db -> let* () = Distributed_db_requester.Raw_operation.shutdown @@ -257,7 +260,7 @@ let clear_block chain_db hash n = let commit_block chain_db hash block_header operations result = let open Lwt_result_syntax in - assert (Block_hash.equal hash (Block_header.hash block_header)) ; + assert (Tezos_crypto.Block_hash.equal hash (Block_header.hash block_header)) ; assert ( Compare.List_length_with.(operations = block_header.shell.validation_passes)) ; let* res = @@ -272,7 +275,7 @@ let commit_block chain_db hash block_header operations result = let commit_invalid_block chain_db hash header errors = let open Lwt_result_syntax in - assert (Block_hash.equal hash (Block_header.hash header)) ; + assert (Tezos_crypto.Block_hash.equal hash (Block_header.hash header)) ; let* () = Store.Block.mark_invalid chain_db.reader_chain_db.chain_store @@ -284,7 +287,7 @@ let commit_invalid_block chain_db hash header errors = return_unit let inject_operation chain_db h op = - assert (Operation_hash.equal h (Operation.hash op)) ; + assert (Tezos_crypto.Operation_hash.equal h (Operation.hash op)) ; Distributed_db_requester.Raw_operation.inject chain_db.reader_chain_db.operation_db h @@ -352,7 +355,7 @@ module Block_header = struct end) : Requester.REQUESTER with type t := chain_db - and type key := Block_hash.t + and type key := Tezos_crypto.Block_hash.t and type value := Block_header.t and type param := unit) end @@ -379,7 +382,7 @@ module Operation = struct end) : Requester.REQUESTER with type t := chain_db - and type key := Operation_hash.t + and type key := Tezos_crypto.Operation_hash.t and type value := Operation.t and type param := unit) end @@ -397,7 +400,7 @@ module Protocol = struct end) : Requester.REQUESTER with type t := db - and type key := Protocol_hash.t + and type key := Tezos_crypto.Protocol_hash.t and type value := Protocol.t and type param := unit) end diff --git a/src/lib_shell/distributed_db.mli b/src/lib_shell/distributed_db.mli index 203a4a83d8d2..5af50aa35384 100644 --- a/src/lib_shell/distributed_db.mli +++ b/src/lib_shell/distributed_db.mli @@ -88,7 +88,7 @@ type chain_db val activate : t -> Store.Chain.t -> P2p_reader.callback -> chain_db (** Look for the database of an active chain. *) -val get_chain : t -> Chain_id.t -> chain_db option +val get_chain : t -> Tezos_crypto.Chain_id.t -> chain_db option (** [deactivate chain_db] sends a [Deactivate chain_id] message to all active neighbors for this chain. This notifies them that this node isn't interested @@ -166,7 +166,7 @@ module Block_header : sig include Requester.REQUESTER with type t := chain_db - and type key := Block_hash.t + and type key := Tezos_crypto.Block_hash.t and type value := Block_header.t and type param := unit end @@ -181,14 +181,14 @@ end module Operations : Requester.REQUESTER with type t := chain_db - and type key = Block_hash.t * int + and type key = Tezos_crypto.Block_hash.t * int and type value = Operation.t list - and type param := Operation_list_list_hash.t + and type param := Tezos_crypto.Operation_list_list_hash.t (** Store on disk all the data associated to a valid block. *) val commit_block : chain_db -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t list list -> Block_validation.result -> @@ -197,7 +197,7 @@ val commit_block : (** Store on disk all the data associated to an invalid block. *) val commit_invalid_block : chain_db -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Error_monad.error list -> unit tzresult Lwt.t @@ -205,7 +205,8 @@ val commit_invalid_block : (** {2 Operations index} *) (** Inject a new operation in the local index (memory only). *) -val inject_operation : chain_db -> Operation_hash.t -> Operation.t -> bool Lwt.t +val inject_operation : + chain_db -> Tezos_crypto.Operation_hash.t -> Operation.t -> bool Lwt.t (** Inject a prechecked block in the [precheck_blocks] memory table. This is to ensure the data availability of the operations once the @@ -215,7 +216,7 @@ val inject_operation : chain_db -> Operation_hash.t -> Operation.t -> bool Lwt.t memory table. The table is handled as an LRU cache. *) val inject_prechecked_block : chain_db -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t @@ -224,7 +225,7 @@ val inject_prechecked_block : module Operation : Requester.REQUESTER with type t := chain_db - and type key := Operation_hash.t + and type key := Tezos_crypto.Operation_hash.t and type value := Operation.t and type param := unit @@ -237,10 +238,11 @@ module Protocol : sig include Requester.REQUESTER with type t := db - and type key := Protocol_hash.t + and type key := Tezos_crypto.Protocol_hash.t and type value := Protocol.t and type param := unit end (** Store on disk protocol sources. *) -val commit_protocol : db -> Protocol_hash.t -> Protocol.t -> bool tzresult Lwt.t +val commit_protocol : + db -> Tezos_crypto.Protocol_hash.t -> Protocol.t -> bool tzresult Lwt.t diff --git a/src/lib_shell/distributed_db_event.ml b/src/lib_shell/distributed_db_event.ml index 5574d3d6af80..6d6aea5a8739 100644 --- a/src/lib_shell/distributed_db_event.ml +++ b/src/lib_shell/distributed_db_event.ml @@ -56,6 +56,6 @@ module P2p_reader_event = struct ~name:"received_future_block" ~msg:"received future block {block_hash} from peer {peer_id}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("peer_id", P2p_peer.Id.encoding) end diff --git a/src/lib_shell/distributed_db_message.ml b/src/lib_shell/distributed_db_message.ml index 765d7b8740dc..18f29c13b60e 100644 --- a/src/lib_shell/distributed_db_message.ml +++ b/src/lib_shell/distributed_db_message.ml @@ -187,27 +187,31 @@ module Bounded_encoding = struct end type t = - | Get_current_branch of Chain_id.t - | Current_branch of Chain_id.t * Block_locator.t - | Deactivate of Chain_id.t - | Get_current_head of Chain_id.t - | Current_head of Chain_id.t * Block_header.t * Mempool.t - | Get_block_headers of Block_hash.t list + | Get_current_branch of Tezos_crypto.Chain_id.t + | Current_branch of Tezos_crypto.Chain_id.t * Block_locator.t + | Deactivate of Tezos_crypto.Chain_id.t + | Get_current_head of Tezos_crypto.Chain_id.t + | Current_head of Tezos_crypto.Chain_id.t * Block_header.t * Mempool.t + | Get_block_headers of Tezos_crypto.Block_hash.t list | Block_header of Block_header.t - | Get_operations of Operation_hash.t list + | Get_operations of Tezos_crypto.Operation_hash.t list | Operation of Operation.t - | Get_protocols of Protocol_hash.t list + | Get_protocols of Tezos_crypto.Protocol_hash.t list | Protocol of Protocol.t - | Get_operations_for_blocks of (Block_hash.t * int) list + | Get_operations_for_blocks of (Tezos_crypto.Block_hash.t * int) list | Operations_for_block of - Block_hash.t * int * Operation.t list * Operation_list_list_hash.path - | Get_checkpoint of Chain_id.t - | Checkpoint of Chain_id.t * Block_header.t - | Get_protocol_branch of Chain_id.t * int (* proto_level: uint8 *) + Tezos_crypto.Block_hash.t + * int + * Operation.t list + * Tezos_crypto.Operation_list_list_hash.path + | Get_checkpoint of Tezos_crypto.Chain_id.t + | Checkpoint of Tezos_crypto.Chain_id.t * Block_header.t + | Get_protocol_branch of + Tezos_crypto.Chain_id.t * int (* proto_level: uint8 *) | Protocol_branch of - Chain_id.t * int (* proto_level: uint8 *) * Block_locator.t - | Get_predecessor_header of Block_hash.t * int32 - | Predecessor_header of Block_hash.t * int32 * Block_header.t + Tezos_crypto.Chain_id.t * int (* proto_level: uint8 *) * Block_locator.t + | Get_predecessor_header of Tezos_crypto.Block_hash.t * int32 + | Predecessor_header of Tezos_crypto.Block_hash.t * int32 * Block_header.t let encoding = let open Data_encoding in @@ -218,14 +222,14 @@ let encoding = case ~tag:0x10 ~title:"Get_current_branch" - (obj1 (req "get_current_branch" Chain_id.encoding)) + (obj1 (req "get_current_branch" Tezos_crypto.Chain_id.encoding)) (function Get_current_branch chain_id -> Some chain_id | _ -> None) (fun chain_id -> Get_current_branch chain_id); case ~tag:0x11 ~title:"Current_branch" (obj2 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "current_branch" Bounded_encoding.block_locator)) (function | Current_branch (chain_id, locator) -> Some (chain_id, locator) @@ -234,20 +238,20 @@ let encoding = case ~tag:0x12 ~title:"Deactivate" - (obj1 (req "deactivate" Chain_id.encoding)) + (obj1 (req "deactivate" Tezos_crypto.Chain_id.encoding)) (function Deactivate chain_id -> Some chain_id | _ -> None) (fun chain_id -> Deactivate chain_id); case ~tag:0x13 ~title:"Get_current_head" - (obj1 (req "get_current_head" Chain_id.encoding)) + (obj1 (req "get_current_head" Tezos_crypto.Chain_id.encoding)) (function Get_current_head chain_id -> Some chain_id | _ -> None) (fun chain_id -> Get_current_head chain_id); case ~tag:0x14 ~title:"Current_head" (obj3 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "current_block_header" (dynamic_size Bounded_encoding.block_header)) @@ -259,7 +263,10 @@ let encoding = case ~tag:0x20 ~title:"Get_block_headers" - (obj1 (req "get_block_headers" (list ~max_length:10 Block_hash.encoding))) + (obj1 + (req + "get_block_headers" + (list ~max_length:10 Tezos_crypto.Block_hash.encoding))) (function Get_block_headers bhs -> Some bhs | _ -> None) (fun bhs -> Get_block_headers bhs); case @@ -272,7 +279,9 @@ let encoding = ~tag:0x30 ~title:"Get_operations" (obj1 - (req "get_operations" (list ~max_length:10 Operation_hash.encoding))) + (req + "get_operations" + (list ~max_length:10 Tezos_crypto.Operation_hash.encoding))) (function Get_operations bhs -> Some bhs | _ -> None) (fun bhs -> Get_operations bhs); case @@ -284,7 +293,10 @@ let encoding = case ~tag:0x40 ~title:"Get_protocols" - (obj1 (req "get_protocols" (list ~max_length:10 Protocol_hash.encoding))) + (obj1 + (req + "get_protocols" + (list ~max_length:10 Tezos_crypto.Protocol_hash.encoding))) (function Get_protocols protos -> Some protos | _ -> None) (fun protos -> Get_protocols protos); case @@ -302,7 +314,7 @@ let encoding = (list ~max_length:10 (obj2 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "validation_pass" int8))))) (function Get_operations_for_blocks keys -> Some keys | _ -> None) (fun keys -> Get_operations_for_blocks keys); @@ -314,7 +326,7 @@ let encoding = (req "operations_for_block" (obj2 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "validation_pass" int8)))) Bounded_encoding.operation_list) (function @@ -326,7 +338,7 @@ let encoding = case ~tag:0x70 ~title:"Get_checkpoint" - (obj1 (req "get_checkpoint" Chain_id.encoding)) + (obj1 (req "get_checkpoint" Tezos_crypto.Chain_id.encoding)) (function Get_checkpoint chain -> Some chain | _ -> None) (fun chain -> Get_checkpoint chain); case @@ -336,7 +348,7 @@ let encoding = (req "checkpoint" (obj2 - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "header" Bounded_encoding.block_header)))) (function | Checkpoint (chain_id, header) -> Some (chain_id, header) | _ -> None) @@ -347,7 +359,9 @@ let encoding = (obj1 (req "get_protocol_branch" - (obj2 (req "chain" Chain_id.encoding) (req "proto_level" uint8)))) + (obj2 + (req "chain" Tezos_crypto.Chain_id.encoding) + (req "proto_level" uint8)))) (function | Get_protocol_branch (chain, protocol) -> Some (chain, protocol) | _ -> None) @@ -359,7 +373,7 @@ let encoding = (req "protocol_branch" (obj3 - (req "chain" Chain_id.encoding) + (req "chain" Tezos_crypto.Chain_id.encoding) (req "proto_level" uint8) (req "locator" Bounded_encoding.block_locator)))) (function @@ -374,7 +388,9 @@ let encoding = (obj1 (req "get_predecessor_header" - (obj2 (req "block" Block_hash.encoding) (req "offset" int32)))) + (obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (req "offset" int32)))) (function | Get_predecessor_header (block, offset) -> Some (block, offset) | _ -> None) @@ -386,7 +402,7 @@ let encoding = (req "predecessor_header" (obj3 - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (req "offset" int32) (req "header" Bounded_encoding.block_header)))) (function diff --git a/src/lib_shell/distributed_db_message.mli b/src/lib_shell/distributed_db_message.mli index f679bce6ad38..07b4c768075c 100644 --- a/src/lib_shell/distributed_db_message.mli +++ b/src/lib_shell/distributed_db_message.mli @@ -29,26 +29,29 @@ corresponding request. Thus, we are able to discrimate between expected responses from the unexpected ones. *) type t = - | Get_current_branch of Chain_id.t - | Current_branch of Chain_id.t * Block_locator.t - | Deactivate of Chain_id.t - | Get_current_head of Chain_id.t - | Current_head of Chain_id.t * Block_header.t * Mempool.t - | Get_block_headers of Block_hash.t list + | Get_current_branch of Tezos_crypto.Chain_id.t + | Current_branch of Tezos_crypto.Chain_id.t * Block_locator.t + | Deactivate of Tezos_crypto.Chain_id.t + | Get_current_head of Tezos_crypto.Chain_id.t + | Current_head of Tezos_crypto.Chain_id.t * Block_header.t * Mempool.t + | Get_block_headers of Tezos_crypto.Block_hash.t list | Block_header of Block_header.t - | Get_operations of Operation_hash.t list + | Get_operations of Tezos_crypto.Operation_hash.t list | Operation of Operation.t - | Get_protocols of Protocol_hash.t list + | Get_protocols of Tezos_crypto.Protocol_hash.t list | Protocol of Protocol.t - | Get_operations_for_blocks of (Block_hash.t * int) list + | Get_operations_for_blocks of (Tezos_crypto.Block_hash.t * int) list | Operations_for_block of - Block_hash.t * int * Operation.t list * Operation_list_list_hash.path - | Get_checkpoint of Chain_id.t - | Checkpoint of Chain_id.t * Block_header.t - | Get_protocol_branch of Chain_id.t * int - | Protocol_branch of Chain_id.t * int * Block_locator.t - | Get_predecessor_header of Block_hash.t * int32 - | Predecessor_header of Block_hash.t * int32 * Block_header.t + Tezos_crypto.Block_hash.t + * int + * Operation.t list + * Tezos_crypto.Operation_list_list_hash.path + | Get_checkpoint of Tezos_crypto.Chain_id.t + | Checkpoint of Tezos_crypto.Chain_id.t * Block_header.t + | Get_protocol_branch of Tezos_crypto.Chain_id.t * int + | Protocol_branch of Tezos_crypto.Chain_id.t * int * Block_locator.t + | Get_predecessor_header of Tezos_crypto.Block_hash.t * int32 + | Predecessor_header of Tezos_crypto.Block_hash.t * int32 * Block_header.t val encoding : t P2p_params.app_message_encoding list diff --git a/src/lib_shell/distributed_db_requester.ml b/src/lib_shell/distributed_db_requester.ml index 2b683d0f865b..215cd3695353 100644 --- a/src/lib_shell/distributed_db_requester.ml +++ b/src/lib_shell/distributed_db_requester.ml @@ -43,7 +43,7 @@ end module type EXTENDED_REQUESTER_2 = sig include EXTENDED_REQUESTER - val clear_all : t -> Block_hash.t -> int -> unit + val clear_all : t -> Tezos_crypto.Block_hash.t -> int -> unit end module type REQUEST_MESSAGE = sig @@ -174,12 +174,12 @@ end module Raw_operation = Make_raw (struct - include Operation_hash + include Tezos_crypto.Operation_hash let name = "operation" end) (Fake_operation_storage) - (Operation_hash.Table) + (Tezos_crypto.Operation_hash.Table) (struct type param = unit @@ -233,12 +233,12 @@ end module Raw_block_header = Make_raw (struct - include Block_hash + include Tezos_crypto.Block_hash let name = "block_header" end) (Block_header_storage) - (Block_hash.Table) + (Tezos_crypto.Block_hash.Table) (struct type param = unit @@ -257,11 +257,11 @@ module Raw_block_header = end) module Operations_table = Hashtbl.MakeSeeded (struct - type t = Block_hash.t * int + type t = Tezos_crypto.Block_hash.t * int let hash = Hashtbl.seeded_hash - let equal (b1, i1) (b2, i2) = Block_hash.equal b1 b2 && i1 = i2 + let equal (b1, i1) (b2, i2) = Tezos_crypto.Block_hash.equal b1 b2 && i1 = i2 end) module Operations_storage = struct @@ -292,15 +292,18 @@ module Raw_operations = struct include Make_raw (struct - type t = Block_hash.t * int + type t = Tezos_crypto.Block_hash.t * int let name = "operations" - let pp ppf (h, n) = Format.fprintf ppf "%a:%d" Block_hash.pp h n + let pp ppf (h, n) = + Format.fprintf ppf "%a:%d" Tezos_crypto.Block_hash.pp h n let encoding = let open Data_encoding in - obj2 (req "block" Block_hash.encoding) (req "index" uint16) + obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (req "index" uint16) end) (Operations_storage) (Operations_table) @@ -314,19 +317,24 @@ module Raw_operations = struct let forge () keys = Message.Get_operations_for_blocks keys end) (struct - type param = Operation_list_list_hash.t + type param = Tezos_crypto.Operation_list_list_hash.t - type notified_value = Operation.t list * Operation_list_list_hash.path + type notified_value = + Operation.t list * Tezos_crypto.Operation_list_list_hash.path let probe (_block, expected_ofs) expected_hash (ops, path) = let received_hash, received_ofs = - Operation_list_list_hash.check_path + Tezos_crypto.Operation_list_list_hash.check_path path - (Operation_list_hash.compute (List.map Operation.hash ops)) + (Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash ops)) in if received_ofs = expected_ofs - && Operation_list_list_hash.compare expected_hash received_hash = 0 + && Tezos_crypto.Operation_list_list_hash.compare + expected_hash + received_hash + = 0 then Some ops else None end) @@ -353,12 +361,12 @@ end module Raw_protocol = Make_raw (struct - include Protocol_hash + include Tezos_crypto.Protocol_hash let name = "protocol" end) (Protocol_storage) - (Protocol_hash.Table) + (Tezos_crypto.Protocol_hash.Table) (struct type param = unit diff --git a/src/lib_shell/distributed_db_requester.mli b/src/lib_shell/distributed_db_requester.mli index e653561cb67a..15bea043d1e5 100644 --- a/src/lib_shell/distributed_db_requester.mli +++ b/src/lib_shell/distributed_db_requester.mli @@ -49,12 +49,12 @@ end module type EXTENDED_REQUESTER_2 = sig include EXTENDED_REQUESTER - val clear_all : t -> Block_hash.t -> int -> unit + val clear_all : t -> Tezos_crypto.Block_hash.t -> int -> unit end module Raw_protocol : EXTENDED_REQUESTER - with type key = Protocol_hash.t + with type key = Tezos_crypto.Protocol_hash.t and type param = unit and type request_param = unit request_param and type store = Store.t @@ -63,7 +63,7 @@ module Raw_protocol : module Raw_operation : EXTENDED_REQUESTER - with type key = Operation_hash.t + with type key = Tezos_crypto.Operation_hash.t and type param = unit and type request_param = unit request_param and type store = Store.chain_store @@ -72,7 +72,7 @@ module Raw_operation : module Raw_block_header : EXTENDED_REQUESTER - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type param = unit and type request_param = unit request_param and type store = Store.chain_store @@ -81,13 +81,14 @@ module Raw_block_header : module Raw_operations : EXTENDED_REQUESTER_2 - with type key = Block_hash.t * int + with type key = Tezos_crypto.Block_hash.t * int and type request_param = unit request_param (* root of merkle tree for this block, used to check the notified value. *) - and type param = Operation_list_list_hash.t + and type param = Tezos_crypto.Operation_list_list_hash.t and type store = Store.chain_store and type value = Operation.t list (* notified value contain the queried value, plus the merkle tree hashes needed to recompute the merkle tree root. *) - and type notified_value = Operation.t list * Operation_list_list_hash.path + and type notified_value = + Operation.t list * Tezos_crypto.Operation_list_list_hash.path diff --git a/src/lib_shell/injection_directory.ml b/src/lib_shell/injection_directory.ml index ab6192369aaf..4f8e93624777 100644 --- a/src/lib_shell/injection_directory.ml +++ b/src/lib_shell/injection_directory.ml @@ -53,7 +53,7 @@ let inject_operation validator ~force ?chain bytes = | None -> failwith "Can't parse the operation" | Some op -> Validator.inject_operation validator ~force ?chain_id op in - let hash = Operation_hash.hash_bytes [bytes] in + let hash = Tezos_crypto.Operation_hash.hash_bytes [bytes] in Lwt.return (hash, t) let inject_operations validator ~force ?chain bytes_list = @@ -101,18 +101,22 @@ let inject_operations validator ~force ?chain bytes_list = let inject_protocol store proto = let open Lwt_result_syntax in let proto_bytes = Data_encoding.Binary.to_bytes_exn Protocol.encoding proto in - let hash = Protocol_hash.hash_bytes [proto_bytes] in + let hash = Tezos_crypto.Protocol_hash.hash_bytes [proto_bytes] in let validation = let*! b = Updater.compile hash proto in match b with - | false -> failwith "Compilation failed (%a)" Protocol_hash.pp_short hash + | false -> + failwith + "Compilation failed (%a)" + Tezos_crypto.Protocol_hash.pp_short + hash | true -> ( let*! o = Store.Protocol.store store hash proto in match o with | None -> failwith "Previously registered protocol (%a)" - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short hash | Some _ -> return_unit) in diff --git a/src/lib_shell/legacy_prevalidation.ml b/src/lib_shell/legacy_prevalidation.ml index ed2a872ffe9a..e2262a80025a 100644 --- a/src/lib_shell/legacy_prevalidation.ml +++ b/src/lib_shell/legacy_prevalidation.ml @@ -39,7 +39,7 @@ open Validation_errors type 'protocol_operation operation = { - hash : Operation_hash.t; + hash : Tezos_crypto.Operation_hash.t; raw : Operation.t; protocol : 'protocol_operation; count_successful_prechecks : int; @@ -67,7 +67,7 @@ module type CHAIN_STORE = sig Store.Block.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t end module type T = sig @@ -82,7 +82,9 @@ module type T = sig type t val parse : - Operation_hash.t -> Operation.t -> protocol_operation operation tzresult + Tezos_crypto.Operation_hash.t -> + Operation.t -> + protocol_operation operation tzresult val increment_successful_precheck : protocol_operation operation -> protocol_operation operation @@ -90,7 +92,7 @@ module type T = sig val create : chain_store -> predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> t tzresult Lwt.t @@ -144,7 +146,7 @@ module MakeAbstract validation_state : validation_state; application_state : Proto.application_state; applied : (protocol_operation operation * Proto.operation_receipt) list; - live_operations : Operation_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; } type result = @@ -218,7 +220,7 @@ module MakeAbstract let apply_operation pv op = let open Lwt_syntax in - if Operation_hash.Set.mem op.hash pv.live_operations then + if Tezos_crypto.Operation_hash.Set.mem op.hash pv.live_operations then (* As of November 2021, it is dubious that this case can happen. If it can, it is more likely to be because of a consensus operation; hence the returned error. *) @@ -243,7 +245,7 @@ module MakeAbstract application_state; applied = (op, receipt) :: pv.applied; live_operations = - Operation_hash.Set.add op.hash pv.live_operations; + Tezos_crypto.Operation_hash.Set.add op.hash pv.live_operations; } in match diff --git a/src/lib_shell/legacy_prevalidation.mli b/src/lib_shell/legacy_prevalidation.mli index 95dd3dd6d844..4e7758a2b04f 100644 --- a/src/lib_shell/legacy_prevalidation.mli +++ b/src/lib_shell/legacy_prevalidation.mli @@ -41,7 +41,7 @@ prevalidation_state. *) type 'protocol_operation operation = private { - hash : Operation_hash.t; (** Hash of an operation. *) + hash : Tezos_crypto.Operation_hash.t; (** Hash of an operation. *) raw : Operation.t; (** Raw representation of an operation (from the point view of the shell). *) @@ -87,7 +87,9 @@ module type T = sig data within [op] is too large (to protect against DoS attacks), and - {!Validation_errors.Parse_error} if serialized data cannot be parsed. *) val parse : - Operation_hash.t -> Operation.t -> protocol_operation operation tzresult + Tezos_crypto.Operation_hash.t -> + Operation.t -> + protocol_operation operation tzresult (** [increment_successful_precheck op] increments the field [count_successful_prechecks] of the given operation [op]. It is supposed @@ -102,7 +104,7 @@ module type T = sig val create : chain_store -> predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> t tzresult Lwt.t @@ -154,11 +156,12 @@ module Internal_for_tests : sig val to_raw : _ operation -> Operation.t (** The hash of an {!operation} *) - val hash_of : _ operation -> Operation_hash.t + val hash_of : _ operation -> Tezos_crypto.Operation_hash.t (** A constructor for the [operation] datatype. It by-passes the checks done by the [parse] function. *) - val make_operation : Operation.t -> Operation_hash.t -> 'a -> 'a operation + val make_operation : + Operation.t -> Tezos_crypto.Operation_hash.t -> 'a -> 'a operation (** [safe_binary_of_bytes encoding bytes] parses [bytes] using [encoding]. Any error happening during parsing becomes {!Parse_error}. @@ -182,7 +185,7 @@ module Internal_for_tests : sig (** [chain_id store] returns the {!Chain_id.t} to which [store] corresponds *) - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t end (** A variant of [Make] above that is parameterized by {!CHAIN_STORE}, diff --git a/src/lib_shell/legacy_prevalidator_classification.ml b/src/lib_shell/legacy_prevalidator_classification.ml index 73235679b8e6..a250d3393a0f 100644 --- a/src/lib_shell/legacy_prevalidator_classification.ml +++ b/src/lib_shell/legacy_prevalidator_classification.ml @@ -47,7 +47,7 @@ module Event = struct ~name:"predecessor_less_block" ~msg:"Observing that a parent of block {blk_h} has no predecessor" ~level:Warning - ("blk_h", Block_hash.encoding) + ("blk_h", Tezos_crypto.Block_hash.encoding) end type error_classification = @@ -58,7 +58,7 @@ type error_classification = type classification = [`Applied | `Prechecked | error_classification] -module Map = Operation_hash.Map +module Map = Tezos_crypto.Operation_hash.Map module Sized_map = Tezos_base.Sized.MakeSizedMap (Map) (** This type wraps together: @@ -69,7 +69,7 @@ module Sized_map = Tezos_base.Sized.MakeSizedMap (Map) All operations must maintain integrity between the 2! *) type 'protocol_data bounded_map = { - ring : Operation_hash.t Ringo.Ring.t; + ring : Tezos_crypto.Operation_hash.t Ringo.Ring.t; mutable map : ('protocol_data Prevalidation.operation * error list) Map.t; } @@ -85,7 +85,7 @@ let mk_empty_bounded_map ring_size = type parameters = { map_size_limit : int; - on_discarded_operation : Operation_hash.t -> unit; + on_discarded_operation : Tezos_crypto.Operation_hash.t -> unit; } (** Note that [applied] and [in_mempool] are intentionally unbounded. @@ -100,7 +100,7 @@ type 'protocol_data t = { branch_delayed : 'protocol_data bounded_map; mutable applied_rev : 'protocol_data Prevalidation.operation list; mutable prechecked : 'protocol_data Prevalidation.operation Sized_map.t; - mutable unparsable : Operation_hash.Set.t; + mutable unparsable : Tezos_crypto.Operation_hash.Set.t; mutable in_mempool : ('protocol_data Prevalidation.operation * classification) Map.t; } @@ -113,7 +113,7 @@ let create parameters = branch_refused = mk_empty_bounded_map parameters.map_size_limit; branch_delayed = mk_empty_bounded_map parameters.map_size_limit; prechecked = Sized_map.empty; - unparsable = Operation_hash.Set.empty; + unparsable = Tezos_crypto.Operation_hash.Set.empty; in_mempool = Map.empty; applied_rev = []; } @@ -137,13 +137,13 @@ let is_empty [in_mempool] is the union of all other fields (see the MLI for detailed documentation of this invariant) except unparsable operations which are not classified yet. *) - Map.is_empty in_mempool && Operation_hash.Set.is_empty unparsable + Map.is_empty in_mempool && Tezos_crypto.Operation_hash.Set.is_empty unparsable let set_of_bounded_map bounded_map = Map.fold - (fun oph _ acc -> Operation_hash.Set.add oph acc) + (fun oph _ acc -> Tezos_crypto.Operation_hash.Set.add oph acc) bounded_map.map - Operation_hash.Set.empty + Tezos_crypto.Operation_hash.Set.empty let flush (classes : 'protocol_data t) ~handle_branch_refused = let remove_map_from_in_mempool map = @@ -170,13 +170,13 @@ let flush (classes : 'protocol_data t) ~handle_branch_refused = remove_list_from_in_mempool classes.applied_rev ; classes.applied_rev <- [] ; remove_map_from_in_mempool (Sized_map.to_map classes.prechecked) ; - classes.unparsable <- Operation_hash.Set.empty ; + classes.unparsable <- Tezos_crypto.Operation_hash.Set.empty ; classes.prechecked <- Sized_map.empty let is_in_mempool oph classes = Map.find oph classes.in_mempool let is_known_unparsable oph classes = - Operation_hash.Set.mem oph classes.unparsable + Tezos_crypto.Operation_hash.Set.mem oph classes.unparsable (* Removing an operation is currently used for operations which are banned (this can only be achieved by the adminstrator of the @@ -208,7 +208,8 @@ let remove oph classes = | `Applied -> classes.applied_rev <- List.filter - (fun op -> Operation_hash.(op.Prevalidation.hash <> oph)) + (fun op -> + Tezos_crypto.Operation_hash.(op.Prevalidation.hash <> oph)) classes.applied_rev) ; Some (op, classification) @@ -256,7 +257,8 @@ let handle_error oph op classification classes = classes.in_mempool <- Map.add oph (op, classification) classes.in_mempool let add_unparsable oph classes = - classes.unparsable <- Operation_hash.Set.add oph classes.unparsable ; + classes.unparsable <- + Tezos_crypto.Operation_hash.Set.add oph classes.unparsable ; classes.parameters.on_discarded_operation oph let add classification op classes = @@ -300,14 +302,14 @@ let to_map ~applied ~prechecked ~branch_delayed ~branch_refused ~refused +> if outdated then classes.outdated.map else Map.empty type 'block block_tools = { - hash : 'block -> Block_hash.t; + hash : 'block -> Tezos_crypto.Block_hash.t; operations : 'block -> Operation.t list list; - all_operation_hashes : 'block -> Operation_hash.t list list; + all_operation_hashes : 'block -> Tezos_crypto.Operation_hash.t list list; } type 'block chain_tools = { - clear_or_cancel : Operation_hash.t -> unit; - inject_operation : Operation_hash.t -> Operation.t -> unit Lwt.t; + clear_or_cancel : Tezos_crypto.Operation_hash.t -> unit; + inject_operation : Tezos_crypto.Operation_hash.t -> Operation.t -> unit Lwt.t; new_blocks : from_block:'block -> to_block:'block -> ('block * 'block list) Lwt.t; read_predecessor_opt : 'block -> 'block option Lwt.t; @@ -316,15 +318,15 @@ type 'block chain_tools = { (* There's detailed documentation in the mli *) let handle_live_operations ~classes ~(block_store : 'block block_tools) ~(chain : 'block chain_tools) ~(from_branch : 'block) ~(to_branch : 'block) - ~(is_branch_alive : Block_hash.t -> bool) + ~(is_branch_alive : Tezos_crypto.Block_hash.t -> bool) ~(parse : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) old_mempool = let open Lwt_syntax in let rec pop_block ancestor (block : 'block) mempool = let hash = block_store.hash block in - if Block_hash.equal hash ancestor then Lwt.return mempool + if Tezos_crypto.Block_hash.equal hash ancestor then Lwt.return mempool else let operations = block_store.operations block in let* mempool = @@ -353,7 +355,8 @@ let handle_live_operations ~classes ~(block_store : 'block block_tools) unparsable and it is ok. *) add_unparsable oph classes ; mempool - | Some parsed_op -> Operation_hash.Map.add oph parsed_op mempool)) + | Some parsed_op -> + Tezos_crypto.Operation_hash.Map.add oph parsed_op mempool)) mempool operations in @@ -377,7 +380,8 @@ let handle_live_operations ~classes ~(block_store : 'block block_tools) let operations = block_store.all_operation_hashes block in List.iter (List.iter chain.clear_or_cancel) operations ; List.fold_left - (List.fold_left (fun mempool h -> Operation_hash.Map.remove h mempool)) + (List.fold_left (fun mempool h -> + Tezos_crypto.Operation_hash.Map.remove h mempool)) mempool operations in @@ -408,7 +412,8 @@ let recycle_operations ~from_branch ~to_branch ~live_blocks ~classes ~parse ~chain ~from_branch ~to_branch - ~is_branch_alive:(fun branch -> Block_hash.Set.mem branch live_blocks) + ~is_branch_alive:(fun branch -> + Tezos_crypto.Block_hash.Set.mem branch live_blocks) ~parse (Map.union (fun _key v _ -> Some v) @@ -432,7 +437,7 @@ module Internal_for_tests = struct (** [copy_bounded_map bm] returns a deep copy of [bm] *) let copy_bounded_map (bm : 'protocol_data bounded_map) : 'protocol_data bounded_map = - let copy_ring (ring : Operation_hash.t Ringo.Ring.t) = + let copy_ring (ring : Tezos_crypto.Operation_hash.t Ringo.Ring.t) = let result = Ringo.Ring.capacity ring |> Ringo.Ring.create in List.iter (Ringo.Ring.add result) (Ringo.Ring.elements ring) ; result @@ -458,7 +463,10 @@ module Internal_for_tests = struct let[@coverage off] bounded_map_pp ppf bounded_map = bounded_map.map |> Map.bindings |> List.map (fun (key, _value) -> key) - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) let[@coverage off] pp ppf { @@ -475,19 +483,31 @@ module Internal_for_tests = struct let applied_pp ppf applied = applied |> List.map (fun op -> op.Prevalidation.hash) - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let in_mempool_pp ppf in_mempool = in_mempool |> Map.bindings |> List.map fst - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let prechecked_pp ppf prechecked = prechecked |> Sized_map.bindings |> List.map fst - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let unparsable_pp ppf unparsable = - unparsable |> Operation_hash.Set.elements - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + unparsable |> Tezos_crypto.Operation_hash.Set.elements + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in Format.fprintf ppf diff --git a/src/lib_shell/legacy_prevalidator_classification.mli b/src/lib_shell/legacy_prevalidator_classification.mli index de4b005df959..12b3142f74c0 100644 --- a/src/lib_shell/legacy_prevalidator_classification.mli +++ b/src/lib_shell/legacy_prevalidator_classification.mli @@ -51,20 +51,21 @@ type 'protocol_data bounded_map (** [map bounded_map] gets the underling map of the [bounded_map]. *) val map : 'protocol_data bounded_map -> - ('protocol_data Prevalidation.operation * tztrace) Operation_hash.Map.t + ('protocol_data Prevalidation.operation * tztrace) + Tezos_crypto.Operation_hash.Map.t (** [cardinal bounded_map] gets the cardinal of the underling map of the [bounded_map] *) val cardinal : 'protocol_data bounded_map -> int type parameters = { map_size_limit : int; - on_discarded_operation : Operation_hash.t -> unit; + on_discarded_operation : Tezos_crypto.Operation_hash.t -> unit; } module Sized_map : Tezos_base.Sized.SizedMap - with type 'a map := 'a Operation_hash.Map.t - and type key = Operation_hash.t + with type 'a map := 'a Tezos_crypto.Operation_hash.Map.t + and type key = Tezos_crypto.Operation_hash.t (** Invariants ensured by this module, provided that the caller does not {!add} an operation which is already present in [t]: @@ -96,10 +97,10 @@ type 'protocol_data t = private { branch_delayed : 'protocol_data bounded_map; mutable applied_rev : 'protocol_data Prevalidation.operation list; mutable prechecked : 'protocol_data Prevalidation.operation Sized_map.t; - mutable unparsable : Operation_hash.Set.t; + mutable unparsable : Tezos_crypto.Operation_hash.Set.t; mutable in_mempool : ('protocol_data Prevalidation.operation * classification) - Operation_hash.Map.t; + Tezos_crypto.Operation_hash.Map.t; } (** [create parameters] returns an empty {!t} whose bounded maps hold @@ -118,14 +119,15 @@ val is_empty : 'protocol_data t -> bool in field [in_mempool] of [classes]. It returns the corresponding operation and its classification if present, and None otherwise. *) val is_in_mempool : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> ('protocol_data Prevalidation.operation * classification) option (** [is_known_unparsable oph] returns [true] if the [oph] is associated to an operation which is known to be unparsable. [false] otherwise. *) -val is_known_unparsable : Operation_hash.t -> 'protocol_data t -> bool +val is_known_unparsable : + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> bool (** [remove oph classes] removes operation of hash [oph] from all fields of [classes]. If the [oph] was classified as [Applied], the @@ -141,7 +143,7 @@ val is_known_unparsable : Operation_hash.t -> 'protocol_data t -> bool this may invalidate the classification of all the other operations. It is left to the caller to restore a consistent state. *) val remove : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> ('protocol_data Prevalidation.operation * classification) option @@ -180,14 +182,14 @@ val add : operation. [unparsable] operations are removed automatically by the [recycle_operations] function. [on_discard_operation] is also called on those operations. *) -val add_unparsable : Operation_hash.t -> 'protocol_data t -> unit +val add_unparsable : Tezos_crypto.Operation_hash.t -> 'protocol_data t -> unit (** Functions to query data on a polymorphic block-like type ['block]. *) type 'block block_tools = { - hash : 'block -> Block_hash.t; (** The hash of a block *) + hash : 'block -> Tezos_crypto.Block_hash.t; (** The hash of a block *) operations : 'block -> Operation.t list list; (** The list of operations of a block ordered by their validation pass *) - all_operation_hashes : 'block -> Operation_hash.t list list; + all_operation_hashes : 'block -> Tezos_crypto.Operation_hash.t list list; (** The list of hashes of operations of a block ordered by their validation pass. Could be implemented using {!operations} but this lets an alternative implementation @@ -197,9 +199,9 @@ type 'block block_tools = { (** A wrapper over chain-related modules, to make client code easier to emulate, and hence to test *) type 'block chain_tools = { - clear_or_cancel : Operation_hash.t -> unit; + clear_or_cancel : Tezos_crypto.Operation_hash.t -> unit; (** Removes the operation from the distributed database. *) - inject_operation : Operation_hash.t -> Operation.t -> unit Lwt.t; + inject_operation : Tezos_crypto.Operation_hash.t -> Operation.t -> unit Lwt.t; (** Puts the operation in the distributed database. Returns [false] if the [hash] is already in the distributed database *) new_blocks : @@ -236,17 +238,18 @@ type 'block chain_tools = { val recycle_operations : from_branch:'block -> to_branch:'block -> - live_blocks:Block_hash.Set.t -> + live_blocks:Tezos_crypto.Block_hash.Set.t -> classes:'protocol_data t -> parse: - (Operation_hash.t -> + (Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) -> - pending:'protocol_data Prevalidation.operation Operation_hash.Map.t -> + pending: + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t -> block_store:'block block_tools -> chain:'block chain_tools -> handle_branch_refused:bool -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t Lwt.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t Lwt.t (**/**) @@ -260,7 +263,8 @@ module Internal_for_tests : sig val copy : 'protocol_data t -> 'protocol_data t (** [set_of_bounded_map m] returns all the operation hashes in [m]. *) - val set_of_bounded_map : 'protocol_data bounded_map -> Operation_hash.Set.t + val set_of_bounded_map : + 'protocol_data bounded_map -> Tezos_crypto.Operation_hash.Set.t (** [pp_t_sizes t] prints the [map_size_limit] parameter of [t] and the sizes of its fields (number of elements in the map and @@ -279,7 +283,7 @@ module Internal_for_tests : sig refused:bool -> outdated:bool -> 'protocol_data t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t (** [flush classes ~handle_branch_refused] partially resets [classes]: - fields [applied_rev], [branch_delayed] and [unparsable] are emptied; @@ -325,11 +329,12 @@ module Internal_for_tests : sig chain:'block chain_tools -> from_branch:'block -> to_branch:'block -> - is_branch_alive:(Block_hash.t -> bool) -> + is_branch_alive:(Tezos_crypto.Block_hash.t -> bool) -> parse: - (Operation_hash.t -> + (Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t Lwt.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t -> + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t + Lwt.t end diff --git a/src/lib_shell/legacy_prevalidator_internal.ml b/src/lib_shell/legacy_prevalidator_internal.ml index 749ce5ece710..03677c36fb7e 100644 --- a/src/lib_shell/legacy_prevalidator_internal.ml +++ b/src/lib_shell/legacy_prevalidator_internal.ml @@ -78,7 +78,7 @@ module Tools = struct (** Lower-level tools provided by {!Prevalidator_classification} *) create : predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> 'prevalidation_t tzresult Lwt.t; @@ -87,19 +87,20 @@ module Tools = struct fetch : ?peer:P2p_peer.Id.t -> ?timeout:Time.System.Span.t -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t tzresult Lwt.t; (** [fetch ?peer ?timeout oph] returns the value when it is known. It can fail with [Requester.Timeout] if [timeout] is provided and the value isn't known before the timeout expires. It can fail with [Requester.Cancel] if the request is canceled. *) - read_block : Block_hash.t -> Store.Block.t tzresult Lwt.t; + read_block : Tezos_crypto.Block_hash.t -> Store.Block.t tzresult Lwt.t; (** [read_block bh] tries to read the block [bh] from the chain store. *) send_get_current_head : ?peer:P2p_peer_id.t -> unit -> unit; (** [send_get_current_head ?peer ()] sends a [Get_Current_head] to a given peer, or to all known active peers for the chain considered. Expected answer is a [Get_current_head] message *) - set_mempool : head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; + set_mempool : + head:Tezos_crypto.Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; (** [set_mempool ~head mempool] sets the [mempool] of the [chain_store] of the chain considered. Does nothing if [head] differs from current_head which might happen when a new head concurrently arrives just @@ -132,13 +133,13 @@ type ('protocol_data, 'a) types_state_shell = { parameters : 'a parameters; mutable predecessor : Store.Block.t; mutable timestamp : Time.System.t; - mutable live_blocks : Block_hash.Set.t; - mutable live_operations : Operation_hash.Set.t; - mutable fetching : Operation_hash.Set.t; + mutable live_blocks : Tezos_crypto.Block_hash.Set.t; + mutable live_operations : Tezos_crypto.Operation_hash.Set.t; + mutable fetching : Tezos_crypto.Operation_hash.Set.t; mutable pending : 'protocol_data Pending_ops.t; mutable mempool : Mempool.t; mutable advertisement : [`Pending of Mempool.t | `None]; - mutable banned_operations : Operation_hash.Set.t; + mutable banned_operations : Tezos_crypto.Operation_hash.Set.t; worker : Tools.worker_tools; } @@ -216,7 +217,7 @@ module type S = sig val may_fetch_operation : (protocol_operation, prevalidation_t) types_state_shell -> P2p_peer_id.t option -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Lwt.t (** The function called after every call to a function of {!API}. *) @@ -234,18 +235,19 @@ module type S = sig val on_arrived : types_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> (unit, Empty.t) result Lwt.t - val on_ban : types_state -> Operation_hash.t -> unit tzresult Lwt.t + val on_ban : + types_state -> Tezos_crypto.Operation_hash.t -> unit tzresult Lwt.t val on_flush : handle_branch_refused:bool -> types_state -> Store.Block.t -> - Block_hash.Set.t -> - Operation_hash.Set.t -> + Tezos_crypto.Block_hash.Set.t -> + Tezos_crypto.Operation_hash.Set.t -> unit tzresult Lwt.t val on_inject : @@ -300,14 +302,14 @@ module Make_s (* This function is in [Lwt] only for logging. *) let already_handled ~origin shell oph = let open Lwt_syntax in - if Operation_hash.Set.mem oph shell.banned_operations then + if Tezos_crypto.Operation_hash.Set.mem oph shell.banned_operations then let+ () = Events.(emit ban_operation_encountered) (origin, oph) in true else Lwt.return (Pending_ops.mem oph shell.pending - || Operation_hash.Set.mem oph shell.fetching - || Operation_hash.Set.mem oph shell.live_operations + || Tezos_crypto.Operation_hash.Set.mem oph shell.fetching + || Tezos_crypto.Operation_hash.Set.mem oph shell.live_operations || Classification.is_in_mempool oph shell.classification <> None || Classification.is_known_unparsable oph shell.classification) @@ -319,7 +321,8 @@ module Make_s `Pending { known_valid = known_valid @ mempool.Mempool.known_valid; - pending = Operation_hash.Set.union pending mempool.pending; + pending = + Tezos_crypto.Operation_hash.Set.union pending mempool.pending; } | `None -> shell.advertisement <- `Pending mempool ; @@ -706,10 +709,12 @@ module Make_s ignore (Lwt.finalize (fun () -> - shell.fetching <- Operation_hash.Set.add oph shell.fetching ; + shell.fetching <- + Tezos_crypto.Operation_hash.Set.add oph shell.fetching ; fetch_operation shell ?peer oph) (fun () -> - shell.fetching <- Operation_hash.Set.remove oph shell.fetching ; + shell.fetching <- + Tezos_crypto.Operation_hash.Set.remove oph shell.fetching ; Lwt.return_unit)) ; Lwt.return_unit @@ -744,7 +749,7 @@ module Make_s | (`High | `Medium | `Low _) as prio -> if not - (Block_hash.Set.mem + (Tezos_crypto.Block_hash.Set.mem op.Operation.shell.branch pv.shell.live_blocks) then ( @@ -778,7 +783,7 @@ module Make_s | Error err -> failwith "Invalid operation %a: %a." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Error_monad.pp_print_trace err @@ -792,15 +797,15 @@ module Make_s return_unit) else if not - (Block_hash.Set.mem + (Tezos_crypto.Block_hash.Set.mem op.Operation.shell.branch pv.shell.live_blocks) then failwith "Operation %a is branched on a block %a which is too old" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.Operation.shell.branch else let*? validation_state = @@ -831,7 +836,7 @@ module Make_s List.find_opt (function | ({hash; _} : protocol_operation operation), _ -> - Operation_hash.equal hash oph) + Tezos_crypto.Operation_hash.equal hash oph) to_handle in match op_status with @@ -864,7 +869,7 @@ module Make_s Lwt.return @@ error_with "Error while applying operation %a:@ %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph pp_print_trace e @@ -873,7 +878,7 @@ module Make_s failwith "Unexpected error while injecting operation %a. Operation \ not found after classifying it." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) let on_notify (shell : ('operation_data, _) types_state_shell) peer mempool @@ -883,7 +888,7 @@ module Make_s let* () = List.iter_s may_fetch_operation mempool.Mempool.known_valid in Seq.iter_s may_fetch_operation - (Operation_hash.Set.to_seq mempool.Mempool.pending) + (Tezos_crypto.Operation_hash.Set.to_seq mempool.Mempool.pending) let on_flush ~handle_branch_refused pv new_predecessor new_live_blocks new_live_operations = @@ -929,10 +934,10 @@ module Make_s ~chain:pv.shell.parameters.tools.chain_tools ~handle_branch_refused in - (* Could be implemented as Operation_hash.Map.filter_s which + (* Could be implemented as Tezos_crypto.Operation_hash.Map.filter_s which does not exist for the moment. *) let*! new_pending_operations, nb_pending = - Operation_hash.Map.fold_s + Tezos_crypto.Operation_hash.Map.fold_s (fun _oph op (pending, nb_pending) -> let*! v = pre_filter @@ -981,11 +986,12 @@ module Make_s pv.shell.advertisement <- remove_from_advertisement oph pv.shell.advertisement ; pv.shell.banned_operations <- - Operation_hash.Set.add oph pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.add oph pv.shell.banned_operations ; match Classification.remove oph pv.shell.classification with | None -> pv.shell.pending <- Pending_ops.remove oph pv.shell.pending ; - pv.shell.fetching <- Operation_hash.Set.remove oph pv.shell.fetching ; + pv.shell.fetching <- + Tezos_crypto.Operation_hash.Set.remove oph pv.shell.fetching ; return_unit | Some (_op, classification) -> ( match (classification, flush_if_prechecked) with @@ -1016,7 +1022,9 @@ module Make_s let on_ban pv oph_to_ban = pv.shell.banned_operations <- - Operation_hash.Set.add oph_to_ban pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.add + oph_to_ban + pv.shell.banned_operations ; remove ~flush_if_prechecked:true pv oph_to_ban end end @@ -1026,7 +1034,7 @@ module type ARG = sig val chain_db : Distributed_db.chain_db - val chain_id : Chain_id.t + val chain_id : Tezos_crypto.Chain_id.t end module Name = struct @@ -1157,7 +1165,9 @@ module Make (Proto_services.S.Mempool.unban_operation Tezos_rpc.Path.open_root) (fun pv () oph -> pv.shell.banned_operations <- - Operation_hash.Set.remove oph pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.remove + oph + pv.shell.banned_operations ; return_unit) ; (* Unban all operations: clear the set pv.banned_operations. *) dir := @@ -1166,7 +1176,7 @@ module Make (Proto_services.S.Mempool.unban_all_operations Tezos_rpc.Path.open_root) (fun pv () () -> - pv.shell.banned_operations <- Operation_hash.Set.empty ; + pv.shell.banned_operations <- Tezos_crypto.Operation_hash.Set.empty ; return_unit) ; dir := Tezos_rpc.Directory.gen_register @@ -1175,7 +1185,7 @@ module Make (fun pv params () -> let map_op_error oph (op, error) acc = op.Prevalidation.protocol |> fun res -> - Operation_hash.Map.add oph (res, error) acc + Tezos_crypto.Operation_hash.Map.add oph (res, error) acc in let applied = if params#applied then @@ -1185,42 +1195,45 @@ module Make else [] in let filter f map = - Operation_hash.Map.fold f map Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.fold + f + map + Tezos_crypto.Operation_hash.Map.empty in let refused = if params#refused then filter map_op_error (Classification.map pv.shell.classification.refused) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let outdated = if params#outdated then filter map_op_error (Classification.map pv.shell.classification.outdated) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let branch_refused = if params#branch_refused then filter map_op_error (Classification.map pv.shell.classification.branch_refused) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let branch_delayed = if params#branch_delayed then filter map_op_error (Classification.map pv.shell.classification.branch_delayed) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let unprocessed = Pending_ops.fold (fun _prio oph op acc -> - Operation_hash.Map.add oph op.protocol acc) + Tezos_crypto.Operation_hash.Map.add oph op.protocol acc) pv.shell.pending - Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.empty in (* FIXME https://gitlab.com/tezos/tezos/-/issues/2250 @@ -1293,7 +1306,7 @@ module Make in let refused = if params#refused then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.refused) [] @@ -1301,7 +1314,7 @@ module Make in let branch_refused = if params#branch_refused then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.branch_refused) [] @@ -1309,7 +1322,7 @@ module Make in let branch_delayed = if params#branch_delayed then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.branch_delayed) [] @@ -1317,7 +1330,7 @@ module Make in let outdated = if params#outdated then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.outdated) [] @@ -1431,7 +1444,7 @@ module Make let on_close w = let pv = Worker.state w in - Operation_hash.Set.iter + Tezos_crypto.Operation_hash.Set.iter pv.shell.parameters.tools.chain_tools.clear_or_cancel pv.shell.fetching ; Lwt.return_unit @@ -1502,8 +1515,8 @@ module Make in let fetching = List.fold_left - (fun s h -> Operation_hash.Set.add h s) - Operation_hash.Set.empty + (fun s h -> Tezos_crypto.Operation_hash.Set.add h s) + Tezos_crypto.Operation_hash.Set.empty mempool.known_valid in let classification_parameters = @@ -1528,7 +1541,7 @@ module Make fetching; pending = Pending_ops.empty; advertisement = `None; - banned_operations = Operation_hash.Set.empty; + banned_operations = Tezos_crypto.Operation_hash.Set.empty; worker = mk_worker_tools w; } in @@ -1577,7 +1590,7 @@ module Make let*! () = Seq.iter_s (may_fetch_operation pv.shell None) - (Operation_hash.Set.to_seq fetching) + (Tezos_crypto.Operation_hash.Set.to_seq fetching) in return pv @@ -1659,12 +1672,12 @@ module Internal_for_tests = struct {map_size_limit = 32; on_discarded_operation = Fun.const ()} in let advertisement = `None in - let banned_operations = Operation_hash.Set.empty in + let banned_operations = Tezos_crypto.Operation_hash.Set.empty in let classification = Classification.create c_parameters in - let fetching = Operation_hash.Set.empty in + let fetching = Tezos_crypto.Operation_hash.Set.empty in let mempool = Mempool.empty in - let live_blocks = Block_hash.Set.empty in - let live_operations = Operation_hash.Set.empty in + let live_blocks = Tezos_crypto.Block_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let pending = Pending_ops.empty in let timestamp = Tezos_base.Time.System.now () in { diff --git a/src/lib_shell/legacy_prevalidator_internal.mli b/src/lib_shell/legacy_prevalidator_internal.mli index e5cd07ff3a0d..3da7595c1114 100644 --- a/src/lib_shell/legacy_prevalidator_internal.mli +++ b/src/lib_shell/legacy_prevalidator_internal.mli @@ -46,7 +46,7 @@ val make : Shell_limits.prevalidator_limits -> Distributed_db.chain_db -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> (module Shell_plugin.FILTER) -> Prevalidator_internal_common.t @@ -59,18 +59,19 @@ module Internal_for_tests : sig chain_tools : Store.Block.t Legacy_prevalidator_classification.chain_tools; create : predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> 'prevalidation_t tzresult Lwt.t; fetch : ?peer:P2p_peer.Id.t -> ?timeout:Time.System.Span.t -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t tzresult Lwt.t; - read_block : Block_hash.t -> Store.Block.t tzresult Lwt.t; + read_block : Tezos_crypto.Block_hash.t -> Store.Block.t tzresult Lwt.t; send_get_current_head : ?peer:P2p_peer_id.t -> unit -> unit; - set_mempool : head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; + set_mempool : + head:Tezos_crypto.Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; } (** Documented in the ml file, because this is only exported for tests. *) @@ -127,18 +128,19 @@ module Internal_for_tests : sig val on_arrived : types_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> (unit, Empty.t) result Lwt.t - val on_ban : types_state -> Operation_hash.t -> unit tzresult Lwt.t + val on_ban : + types_state -> Tezos_crypto.Operation_hash.t -> unit tzresult Lwt.t val on_flush : handle_branch_refused:bool -> types_state -> Store.Block.t -> - Block_hash.Set.t -> - Operation_hash.Set.t -> + Tezos_crypto.Block_hash.Set.t -> + Tezos_crypto.Operation_hash.Set.t -> unit tzresult Lwt.t val on_inject : diff --git a/src/lib_shell/legacy_prevalidator_pending_operations.ml b/src/lib_shell/legacy_prevalidator_pending_operations.ml index 86939ff274e0..25d72bd1556e 100644 --- a/src/lib_shell/legacy_prevalidator_pending_operations.ml +++ b/src/lib_shell/legacy_prevalidator_pending_operations.ml @@ -62,8 +62,9 @@ module Priority_map : Map.S with type key = priority = Map.Make (struct | `Medium, `Low _ -> -1 end) -module Map = Operation_hash.Map -module Sized_set = Tezos_base.Sized.MakeSizedSet (Operation_hash.Set) +module Map = Tezos_crypto.Operation_hash.Map +module Sized_set = + Tezos_base.Sized.MakeSizedSet (Tezos_crypto.Operation_hash.Set) (* The type below is used for representing pending operations data of the diff --git a/src/lib_shell/legacy_prevalidator_pending_operations.mli b/src/lib_shell/legacy_prevalidator_pending_operations.mli index e1b2504cb2d0..c56838f5718d 100644 --- a/src/lib_shell/legacy_prevalidator_pending_operations.mli +++ b/src/lib_shell/legacy_prevalidator_pending_operations.mli @@ -49,18 +49,18 @@ type priority = [`High | `Medium | `Low of Q.t list] type 'protocol_data t module Sized_set : - Tezos_base.Sized.SizedSet with type set := Operation_hash.Set.t + Tezos_base.Sized.SizedSet with type set := Tezos_crypto.Operation_hash.Set.t (** The empty structure of pending operations. *) val empty : 'protocol_data t (** [hashes p] returns the set of hashes contained in [p] *) -val hashes : 'protocol_data t -> Operation_hash.Set.t +val hashes : 'protocol_data t -> Tezos_crypto.Operation_hash.Set.t (** [operations p] returns the Map of bindings [oph -> op] contained in [p] *) val operations : 'protocol_data t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t (** [is_empty p] returns [true] if [p] has operations, [false] otherwise. *) val is_empty : 'protocol_data t -> bool @@ -70,7 +70,7 @@ val is_empty : 'protocol_data t -> bool Complexity is O(log(n)), where n is the number of operations (hashes) in the structure. *) -val mem : Operation_hash.t -> 'protocol_data t -> bool +val mem : Tezos_crypto.Operation_hash.t -> 'protocol_data t -> bool (** [add oph op p prio] records the operation [op] whose hash is [oph] and whose priority is [prio] in [p]. @@ -93,7 +93,8 @@ val add : Complexity is O(log(n)), where n is the number of operations (hashes) in the structure. *) -val remove : Operation_hash.t -> 'protocol_data t -> 'protocol_data t +val remove : + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> 'protocol_data t (** [cardinal p] returns the number of operations (hashes) in [p]. @@ -108,12 +109,12 @@ val cardinal : 'protocol_data t -> int We iterate on operations with `High priority first, then on those with `Low priority. For operations with the same priority, the iteration order is - defined [Operation_hash.compare] function (operations with small hashes are + defined [Tezos_crypto.Operation_hash.compare] function (operations with small hashes are processed first). *) val fold : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> 'a -> 'a) -> @@ -124,7 +125,7 @@ val fold : (** [iter f p] is similar to [fold] where [acc] is unit *) val iter : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> unit) -> 'protocol_data t -> @@ -135,7 +136,7 @@ val iter : value [Error e] is returned by [f] *) val fold_es : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> 'a -> ('a, 'b) result Lwt.t) -> diff --git a/src/lib_shell/monitor_directory.ml b/src/lib_shell/monitor_directory.ml index 1e410538b420..21d44f8e3dbf 100644 --- a/src/lib_shell/monitor_directory.ml +++ b/src/lib_shell/monitor_directory.ml @@ -75,7 +75,7 @@ let build_rpc_directory validator mainchain_validator = match o with | None -> false | Some this_chain_id -> - Chain_id.equal this_chain_id that_chain_id) + Tezos_crypto.Chain_id.equal this_chain_id that_chain_id) chains in let in_protocols (chain_store, block) = @@ -89,7 +89,9 @@ let build_rpc_directory validator mainchain_validator = let* context = Store.Block.context_exn chain_store pred in let* protocol = Context_ops.get_protocol context in Lwt.return - (List.exists (Protocol_hash.equal protocol) protocols)) + (List.exists + (Tezos_crypto.Protocol_hash.equal protocol) + protocols)) in let in_next_protocols (chain_store, block) = match q#next_protocols with @@ -98,7 +100,9 @@ let build_rpc_directory validator mainchain_validator = let* context = Store.Block.context_exn chain_store block in let* next_protocol = Context_ops.get_protocol context in Lwt.return - (List.exists (Protocol_hash.equal next_protocol) protocols) + (List.exists + (Tezos_crypto.Protocol_hash.equal next_protocol) + protocols) in let stream = Lwt_stream.filter_map_s @@ -134,7 +138,9 @@ let build_rpc_directory validator mainchain_validator = let* context = Store.Block.context_exn chain_store block in let* next_protocol = Context_ops.get_protocol context in Lwt.return - (List.exists (Protocol_hash.equal next_protocol) protocols) + (List.exists + (Tezos_crypto.Protocol_hash.equal next_protocol) + protocols) in let stream = Lwt_stream.filter_map_s @@ -176,7 +182,7 @@ let build_rpc_directory validator mainchain_validator = let convert (chain_id, b) = if not b then Lwt.return (Monitor_services.Stopping chain_id) else if - Chain_id.equal + Tezos_crypto.Chain_id.equal (Store.Chain.chain_id (Store.main_chain_store store)) chain_id then Lwt.return (Monitor_services.Active_main chain_id) @@ -193,7 +199,7 @@ let build_rpc_directory validator mainchain_validator = (Format.asprintf "Monitor.active_chains: no expiration date for the \ chain %a" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id)) (Store.Chain.expiration chain_store) in diff --git a/src/lib_shell/node.ml b/src/lib_shell/node.ml index 41ff1bfdf2da..bbf19b426580 100644 --- a/src/lib_shell/node.ml +++ b/src/lib_shell/node.ml @@ -132,7 +132,7 @@ type config = { Tezos_protocol_environment.Context.t tzresult Lwt.t) option; p2p : (P2p.config * P2p_limits.t) option; - target : (Block_hash.t * int32) option; + target : (Tezos_crypto.Block_hash.t * int32) option; disable_mempool : bool; enable_testchain : bool; } @@ -141,7 +141,7 @@ type config = { do not have their actual hash on purpose. *) let test_protocol_hashes = List.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [ "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK"; "ProtoDemoCounterDemoCounterDemoCounterDemoCou4LSpdT"; @@ -161,10 +161,10 @@ let store_known_protocols store = | None -> Node_event.(emit store_protocol_missing_files) protocol_hash | Some protocol -> ( let hash = Protocol.hash protocol in - if not (Protocol_hash.equal hash protocol_hash) then + if not (Tezos_crypto.Protocol_hash.equal hash protocol_hash) then if List.mem - ~equal:Protocol_hash.equal + ~equal:Tezos_crypto.Protocol_hash.equal protocol_hash test_protocol_hashes then Lwt.return_unit diff --git a/src/lib_shell/node.mli b/src/lib_shell/node.mli index 134128e91f6b..ea3116a862e3 100644 --- a/src/lib_shell/node.mli +++ b/src/lib_shell/node.mli @@ -42,7 +42,7 @@ type config = { Tezos_protocol_environment.Context.t tzresult Lwt.t) option; p2p : (P2p.config * P2p_limits.t) option; - target : (Block_hash.t * int32) option; + target : (Tezos_crypto.Block_hash.t * int32) option; disable_mempool : bool; (** If [true], all non-empty mempools will be ignored. *) enable_testchain : bool; diff --git a/src/lib_shell/node_event.ml b/src/lib_shell/node_event.ml index 74b4f0f0fe8d..a94acccbb972 100644 --- a/src/lib_shell/node_event.ml +++ b/src/lib_shell/node_event.ml @@ -47,7 +47,7 @@ let store_protocol_already_included = ~name:"store_protocol_already_included" ~msg:"protocol {protocol} is already in store: nothing to do" ~level:Debug - ("protocol", Protocol_hash.encoding) + ("protocol", Tezos_crypto.Protocol_hash.encoding) let store_protocol_missing_files = declare_1 @@ -55,7 +55,7 @@ let store_protocol_missing_files = ~name:"store_protocol_missing_files" ~msg:"protocol {protocol} won't be stored: missing source files" ~level:Warning - ("protocol", Protocol_hash.encoding) + ("protocol", Tezos_crypto.Protocol_hash.encoding) let store_protocol_incorrect_hash = declare_1 @@ -63,7 +63,7 @@ let store_protocol_incorrect_hash = ~name:"store_protocol_incorrect_hash" ~msg:"protocol {protocol} won't be stored: wrong hash" ~level:Warning - ("protocol", Protocol_hash.encoding) + ("protocol", Tezos_crypto.Protocol_hash.encoding) let store_protocol_success = declare_1 @@ -71,7 +71,7 @@ let store_protocol_success = ~name:"store_successful_store" ~msg:"protocol {protocol} successfully stored" ~level:Info - ("protocol", Protocol_hash.encoding) + ("protocol", Tezos_crypto.Protocol_hash.encoding) let section = section_root @ ["storage_consistency"] diff --git a/src/lib_shell/p2p_reader.ml b/src/lib_shell/p2p_reader.ml index 198b665ed472..36af6008da02 100644 --- a/src/lib_shell/p2p_reader.ml +++ b/src/lib_shell/p2p_reader.ml @@ -35,13 +35,18 @@ type connection = type callback = { notify_branch : P2p_peer.Id.t -> Block_locator.t -> unit; notify_head : - P2p_peer.Id.t -> Block_hash.t -> Block_header.t -> Mempool.t -> unit; + P2p_peer.Id.t -> + Tezos_crypto.Block_hash.t -> + Block_header.t -> + Mempool.t -> + unit; disconnection : P2p_peer.Id.t -> unit; } -module Block_hash_cache : Ringo.CACHE_MAP with type key = Block_hash.t = +module Block_hash_cache : + Ringo.CACHE_MAP with type key = Tezos_crypto.Block_hash.t = (val Ringo.(map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash) + (Tezos_crypto.Block_hash) type chain_db = { chain_store : Store.Chain.t; @@ -57,12 +62,12 @@ type t = { p2p : p2p; gid : P2p_peer.Id.t; (** remote peer id *) conn : connection; - peer_active_chains : chain_db Chain_id.Table.t; + peer_active_chains : chain_db Tezos_crypto.Chain_id.Table.t; disk : Store.t; canceler : Lwt_canceler.t; mutable worker : unit Lwt.t; protocol_db : Distributed_db_requester.Raw_protocol.t; - active_chains : chain_db Chain_id.Table.t; + active_chains : chain_db Tezos_crypto.Chain_id.Table.t; (** All chains managed by this peer **) unregister : unit -> unit; } @@ -71,7 +76,7 @@ type t = { and [chain_db] is the chain_db corresponding to this chain id, otherwise does nothing (simply update peer metadata). *) let may_handle state chain_id f = - match Chain_id.Table.find state.peer_active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find state.peer_active_chains chain_id with | None -> let meta = P2p.get_peer_metadata state.p2p state.gid in Peer_metadata.incr meta Inactive_chain ; @@ -81,12 +86,12 @@ let may_handle state chain_id f = (* performs [f chain_db] if [chain_id] is active and [chain_db] is the chain_db corresponding to this chain id. *) let may_handle_global state chain_id f = - match Chain_id.Table.find state.active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find state.active_chains chain_id with | None -> Lwt.return_unit | Some chain_db -> f chain_db let find_pending_operations {peer_active_chains; _} h i = - Chain_id.Table.to_seq_values peer_active_chains + Tezos_crypto.Chain_id.Table.to_seq_values peer_active_chains |> Seq.filter (fun chain_db -> Distributed_db_requester.Raw_operations.pending chain_db.operations_db @@ -94,7 +99,7 @@ let find_pending_operations {peer_active_chains; _} h i = |> Seq.first let find_pending_operation {peer_active_chains; _} h = - Chain_id.Table.to_seq_values peer_active_chains + Tezos_crypto.Chain_id.Table.to_seq_values peer_active_chains |> Seq.filter (fun chain_db -> Distributed_db_requester.Raw_operation.pending chain_db.operation_db h) |> Seq.first @@ -103,7 +108,7 @@ let read_operation state h = (* Remember that seqs are lazy. The table is only traversed until a match is found, the rest is not explored. *) let open Lwt_syntax in - Seq_s.of_seq (Chain_id.Table.to_seq state.active_chains) + Seq_s.of_seq (Tezos_crypto.Chain_id.Table.to_seq state.active_chains) |> Seq_s.filter_map_s (fun (chain_id, chain_db) -> let+ v = Distributed_db_requester.Raw_operation.read_opt @@ -149,7 +154,7 @@ let read_predecessor_header {disk; _} h offset = chain_stores) let find_pending_block_header {peer_active_chains; _} h = - Chain_id.Table.to_seq_values peer_active_chains + Tezos_crypto.Chain_id.Table.to_seq_values peer_active_chains |> Seq.filter (fun chain_db -> Distributed_db_requester.Raw_block_header.pending chain_db.block_header_db @@ -163,13 +168,13 @@ let deactivate gid chain_db = (* Active the chain_id for the remote peer. Is a nop if it is already activated. *) let activate state chain_id chain_db = - match Chain_id.Table.find state.peer_active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find state.peer_active_chains chain_id with | Some _ -> () | None -> chain_db.active_peers := P2p_peer.Set.add state.gid !(chain_db.active_peers) ; P2p_peer.Table.add chain_db.active_connections state.gid state.conn ; - Chain_id.Table.add state.peer_active_chains chain_id chain_db + Tezos_crypto.Chain_id.Table.add state.peer_active_chains chain_id chain_db let my_peer_id state = P2p.peer_id state.p2p @@ -223,7 +228,7 @@ let handle_msg state msg = | Deactivate chain_id -> may_handle state chain_id @@ fun chain_db -> deactivate state.gid chain_db ; - Chain_id.Table.remove state.peer_active_chains chain_id ; + Tezos_crypto.Chain_id.Table.remove state.peer_active_chains chain_id ; Lwt.return_unit | Get_current_head chain_id -> may_handle state chain_id @@ fun chain_db -> @@ -464,7 +469,7 @@ let rec worker_loop state = let* () = handle_msg state msg in worker_loop state | Error _ -> - Chain_id.Table.iter + Tezos_crypto.Chain_id.Table.iter (fun _ -> deactivate state.gid) state.peer_active_chains ; state.unregister () ; @@ -481,12 +486,12 @@ let run ~register ~unregister p2p disk protocol_db active_chains gid conn = conn; gid; canceler; - peer_active_chains = Chain_id.Table.create 17; + peer_active_chains = Tezos_crypto.Chain_id.Table.create 17; worker = Lwt.return_unit; unregister; } in - Chain_id.Table.iter + Tezos_crypto.Chain_id.Table.iter (fun chain_id _chain_db -> Error_monad.dont_wait (fun () -> diff --git a/src/lib_shell/p2p_reader.mli b/src/lib_shell/p2p_reader.mli index 8f96d8054c5e..a055cba81278 100644 --- a/src/lib_shell/p2p_reader.mli +++ b/src/lib_shell/p2p_reader.mli @@ -141,7 +141,8 @@ type t module Message = Distributed_db_message -module Block_hash_cache : Ringo.CACHE_MAP with type key = Block_hash.t +module Block_hash_cache : + Ringo.CACHE_MAP with type key = Tezos_crypto.Block_hash.t type p2p = (Message.t, Peer_metadata.t, Connection_metadata.t) P2p.net @@ -152,7 +153,11 @@ type callback = { notify_branch : P2p_peer.Id.t -> Block_locator.t -> unit; (** callback function called on reception of a [Current_branch] message *) notify_head : - P2p_peer.Id.t -> Block_hash.t -> Block_header.t -> Mempool.t -> unit; + P2p_peer.Id.t -> + Tezos_crypto.Block_hash.t -> + Block_header.t -> + Mempool.t -> + unit; (** callback function called on reception of a [Current_head] message *) disconnection : P2p_peer.Id.t -> unit; } @@ -170,7 +175,9 @@ type chain_db = { (** Lookup for block header in any active chains *) val read_block_header : - t -> Block_hash.t -> (Chain_id.t * Block_header.t) option Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + (Tezos_crypto.Chain_id.t * Block_header.t) option Lwt.t (** [run ~register ~unregister p2p state protocol_db active_chains peer_id conn] runs an answering worker on a p2p connection [connection]. [peer_id] is @@ -185,7 +192,7 @@ val run : p2p -> Store.t -> Distributed_db_requester.Raw_protocol.t -> - chain_db Chain_id.Table.t -> + chain_db Tezos_crypto.Chain_id.Table.t -> P2p_peer.Id.t -> connection -> unit diff --git a/src/lib_shell/patch_context.ml b/src/lib_shell/patch_context.ml index 6c788e361f37..0c3ba522117e 100644 --- a/src/lib_shell/patch_context.ml +++ b/src/lib_shell/patch_context.ml @@ -39,7 +39,7 @@ let patch_context (genesis : Genesis.t) key_json ctxt = let module Proto = (val proto) in let* {context; _} = Proto.init - (Chain_id.of_block_hash genesis.block) + (Tezos_crypto.Chain_id.of_block_hash genesis.block) ctxt { level = 0l; @@ -47,9 +47,9 @@ let patch_context (genesis : Genesis.t) key_json ctxt = predecessor = genesis.block; timestamp = genesis.time; validation_passes = 0; - operations_hash = Operation_list_list_hash.empty; + operations_hash = Tezos_crypto.Operation_list_list_hash.empty; fitness = []; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } in return context diff --git a/src/lib_shell/peer_validator.ml b/src/lib_shell/peer_validator.ml index 2cc929cdd1ac..57daf5192e1e 100644 --- a/src/lib_shell/peer_validator.ml +++ b/src/lib_shell/peer_validator.ml @@ -29,23 +29,33 @@ open Peer_validator_worker_state module Name = struct - type t = Chain_id.t * P2p_peer.Id.t + type t = Tezos_crypto.Chain_id.t * P2p_peer.Id.t - let encoding = Data_encoding.tup2 Chain_id.encoding P2p_peer.Id.encoding + let encoding = + Data_encoding.tup2 Tezos_crypto.Chain_id.encoding P2p_peer.Id.encoding let base = ["validator"; "peer"] let pp ppf (chain, peer) = - Format.fprintf ppf "%a:%a" Chain_id.pp_short chain P2p_peer.Id.pp_short peer - - let equal (c1, p1) (c2, p2) = Chain_id.equal c1 c2 && P2p_peer.Id.equal p1 p2 + Format.fprintf + ppf + "%a:%a" + Tezos_crypto.Chain_id.pp_short + chain + P2p_peer.Id.pp_short + peer + + let equal (c1, p1) (c2, p2) = + Tezos_crypto.Chain_id.equal c1 c2 && P2p_peer.Id.equal p1 p2 end module Request = struct include Request type (_, _) t = - | New_head : Block_hash.t * Block_header.t -> (unit, error trace) t + | New_head : + Tezos_crypto.Block_hash.t * Block_header.t + -> (unit, error trace) t | New_branch : Block_locator.t * Block_locator.seed -> (unit, error trace) t let view (type a b) (req : (a, b) t) : view = @@ -396,7 +406,7 @@ let on_error (type a b) w st (request : (a, b) Request.t) (err : b) : ( pv.peer_id, Format.asprintf "missing protocol: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol ) in let* () = Events.(emit request_error) (request_view, st, err) in diff --git a/src/lib_shell/peer_validator.mli b/src/lib_shell/peer_validator.mli index 56b06bab9a12..95e97943d8fb 100644 --- a/src/lib_shell/peer_validator.mli +++ b/src/lib_shell/peer_validator.mli @@ -41,9 +41,10 @@ val shutdown : t -> unit Lwt.t val notify_branch : t -> Block_locator.t -> unit -val notify_head : t -> Block_hash.t -> Block_header.t -> unit +val notify_head : t -> Tezos_crypto.Block_hash.t -> Block_header.t -> unit -val running_workers : unit -> ((Chain_id.t * P2p_peer.Id.t) * t) list +val running_workers : + unit -> ((Tezos_crypto.Chain_id.t * P2p_peer.Id.t) * t) list val status : t -> Worker_types.worker_status @@ -58,5 +59,8 @@ val pipeline_length : t -> Peer_validator_worker_state.pipeline_length module Internal_for_tests : sig val validate_new_head : - t -> Block_hash.t -> Block_header.t -> (unit, error trace) result Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Block_header.t -> + (unit, error trace) result Lwt.t end diff --git a/src/lib_shell/peer_validator_events.ml b/src/lib_shell/peer_validator_events.ml index c117976d37c8..e5200973e7bd 100644 --- a/src/lib_shell/peer_validator_events.ml +++ b/src/lib_shell/peer_validator_events.ml @@ -46,9 +46,9 @@ let new_branch_validated = ~msg:"branch from {peer} validated with head {hash}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetching_operations_for_head = declare_2 @@ -57,9 +57,9 @@ let fetching_operations_for_head = ~msg:"fetching operaitons from {peer} for head {hash}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let requesting_new_head_validation = declare_2 @@ -68,9 +68,9 @@ let requesting_new_head_validation = ~msg:"requesting new head validation from {peer} for head {hash}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let new_head_validation_end = declare_2 @@ -79,9 +79,9 @@ let new_head_validation_end = ~msg:"new head validation from {peer} for head {hash} ended" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_head = declare_2 @@ -90,9 +90,9 @@ let ignoring_head = ~msg:"ignoring head {hash} from peer {peer} with non-increasing fitness" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_previously_validated_block = declare_2 @@ -101,9 +101,9 @@ let ignoring_previously_validated_block = ~msg:"ignoring previously validated head {hash} from {peer}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_invalid_block = declare_2 @@ -112,9 +112,9 @@ let ignoring_invalid_block = ~msg:"ignoring invalid block {hash} from {peer}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_valid_block = declare_2 @@ -123,9 +123,9 @@ let ignoring_valid_block = ~msg:"ignoring prechecked head {hash} from {peer}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_prechecked_invalid_block = declare_2 @@ -134,9 +134,9 @@ let ignoring_prechecked_invalid_block = ~msg:"ignoring invalid block {hash} from {peer}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let missing_new_head_predecessor = declare_2 @@ -145,9 +145,9 @@ let missing_new_head_predecessor = ~msg:"missing new head's predecessor {hash} from {peer}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_branch_with_invalid_locator = declare_2 @@ -156,9 +156,9 @@ let ignoring_branch_with_invalid_locator = ~msg:"ignoring branch with head {hash} from {peer} (invalid locator)" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let ignoring_branch_without_common_ancestor = declare_2 @@ -167,9 +167,9 @@ let ignoring_branch_without_common_ancestor = ~msg:"ignoring branch with head {hash} from {peer} (no common ancestor)" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let no_new_head_from_peer = declare_2 @@ -189,9 +189,9 @@ let processing_new_head = ~msg:"processing new head fron peer {peer}: {hash}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let processing_new_branch = declare_2 @@ -200,9 +200,9 @@ let processing_new_branch = ~msg:"processing new branch fron peer {peer}: {hash}" ~level:Debug ~pp1:P2p_peer.Id.pp - ~pp2:Block_hash.pp + ~pp2:Tezos_crypto.Block_hash.pp ("peer", P2p_peer.Id.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let terminating_worker = declare_2 diff --git a/src/lib_shell/prevalidation.ml b/src/lib_shell/prevalidation.ml index e6ec0a0386d8..aeb1fa3d3ce6 100644 --- a/src/lib_shell/prevalidation.ml +++ b/src/lib_shell/prevalidation.ml @@ -38,7 +38,7 @@ open Validation_errors type 'protocol_operation operation = { - hash : Operation_hash.t; + hash : Tezos_crypto.Operation_hash.t; raw : Operation.t; protocol : 'protocol_operation; count_successful_prechecks : int; @@ -66,7 +66,7 @@ module type CHAIN_STORE = sig Store.Block.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t end module type T = sig @@ -81,7 +81,9 @@ module type T = sig type t val parse : - Operation_hash.t -> Operation.t -> protocol_operation operation tzresult + Tezos_crypto.Operation_hash.t -> + Operation.t -> + protocol_operation operation tzresult val increment_successful_precheck : protocol_operation operation -> protocol_operation operation @@ -89,7 +91,7 @@ module type T = sig val create : chain_store -> predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> t tzresult Lwt.t @@ -143,7 +145,7 @@ module MakeAbstract validation_state : validation_state; application_state : Proto.application_state; applied : (protocol_operation operation * Proto.operation_receipt) list; - live_operations : Operation_hash.Set.t; + live_operations : Tezos_crypto.Operation_hash.Set.t; } type result = @@ -217,7 +219,7 @@ module MakeAbstract let apply_operation pv op = let open Lwt_syntax in - if Operation_hash.Set.mem op.hash pv.live_operations then + if Tezos_crypto.Operation_hash.Set.mem op.hash pv.live_operations then (* As of November 2021, it is dubious that this case can happen. If it can, it is more likely to be because of a consensus operation; hence the returned error. *) @@ -242,7 +244,7 @@ module MakeAbstract application_state; applied = (op, receipt) :: pv.applied; live_operations = - Operation_hash.Set.add op.hash pv.live_operations; + Tezos_crypto.Operation_hash.Set.add op.hash pv.live_operations; } in match diff --git a/src/lib_shell/prevalidation.mli b/src/lib_shell/prevalidation.mli index 9a918ece4b03..2e673b9e5428 100644 --- a/src/lib_shell/prevalidation.mli +++ b/src/lib_shell/prevalidation.mli @@ -40,7 +40,7 @@ prevalidation_state. *) type 'protocol_operation operation = private { - hash : Operation_hash.t; (** Hash of an operation. *) + hash : Tezos_crypto.Operation_hash.t; (** Hash of an operation. *) raw : Operation.t; (** Raw representation of an operation (from the point view of the shell). *) @@ -86,7 +86,9 @@ module type T = sig data within [op] is too large (to protect against DoS attacks), and - {!Validation_errors.Parse_error} if serialized data cannot be parsed. *) val parse : - Operation_hash.t -> Operation.t -> protocol_operation operation tzresult + Tezos_crypto.Operation_hash.t -> + Operation.t -> + protocol_operation operation tzresult (** [increment_successful_precheck op] increments the field [count_successful_prechecks] of the given operation [op]. It is supposed @@ -101,7 +103,7 @@ module type T = sig val create : chain_store -> predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> t tzresult Lwt.t @@ -153,11 +155,12 @@ module Internal_for_tests : sig val to_raw : _ operation -> Operation.t (** The hash of an {!operation} *) - val hash_of : _ operation -> Operation_hash.t + val hash_of : _ operation -> Tezos_crypto.Operation_hash.t (** A constructor for the [operation] datatype. It by-passes the checks done by the [parse] function. *) - val make_operation : Operation.t -> Operation_hash.t -> 'a -> 'a operation + val make_operation : + Operation.t -> Tezos_crypto.Operation_hash.t -> 'a -> 'a operation (** [safe_binary_of_bytes encoding bytes] parses [bytes] using [encoding]. Any error happening during parsing becomes {!Parse_error}. @@ -179,9 +182,9 @@ module Internal_for_tests : sig Store.Block.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t - (** [chain_id store] returns the {!Chain_id.t} to which [store] + (** [chain_id store] returns the {!Tezos_crypto.Chain_id.t} to which [store] corresponds *) - val chain_id : chain_store -> Chain_id.t + val chain_id : chain_store -> Tezos_crypto.Chain_id.t end (** A variant of [Make] above that is parameterized by {!CHAIN_STORE}, diff --git a/src/lib_shell/prevalidator.ml b/src/lib_shell/prevalidator.ml index d2744c930e72..356c0011b23b 100644 --- a/src/lib_shell/prevalidator.ml +++ b/src/lib_shell/prevalidator.ml @@ -28,11 +28,11 @@ include Prevalidator_internal_common open Prevalidator_worker_state module ChainProto_registry = Map.Make (struct - type t = Chain_id.t * Protocol_hash.t + type t = Tezos_crypto.Chain_id.t * Tezos_crypto.Protocol_hash.t let compare (c1, p1) (c2, p2) = - let pc = Protocol_hash.compare p1 p2 in - if pc = 0 then Chain_id.compare c1 c2 else pc + let pc = Tezos_crypto.Protocol_hash.compare p1 p2 in + if pc = 0 then Tezos_crypto.Chain_id.compare c1 c2 else pc end) let chain_proto_registry : t ChainProto_registry.t ref = @@ -150,11 +150,11 @@ let empty_rpc_directory : unit Tezos_rpc.Directory.t = let pending_operations = { Block_services.Empty.Mempool.applied = []; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; - unprocessed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; + unprocessed = Tezos_crypto.Operation_hash.Map.empty; } in Block_services.Empty.Mempool.pending_operations_version_dispatcher diff --git a/src/lib_shell/prevalidator.mld b/src/lib_shell/prevalidator.mld index f12e0ef9fad2..c6003e74a54a 100644 --- a/src/lib_shell/prevalidator.mld +++ b/src/lib_shell/prevalidator.mld @@ -162,7 +162,7 @@ new [live_blocks] and [live_operations], triggering also a {{!Tezos_shell.module-Prevalidator.flush} flush} of the mempool: every operation classified as {{!Tezos_shell.module-Prevalidation.T.result.Applied} Applied} or {{!Tezos_shell.module-Prevalidation.T.result.Branch_delayed} Branch_delayed} -which is anchored (to the {{!Tezos_crypto.module-Block_hash.type-t} block_hash} +which is anchored (to the {{!Tezos_crypto.module-Tezos_crypto.Block_hash.type-t} block_hash} on which the operation is based on when it was created) on a [live block] and which is not in the [live operations] (operations which are included in [live_blocks]) is set diff --git a/src/lib_shell/prevalidator.mli b/src/lib_shell/prevalidator.mli index f1fa50bbc0d0..644163bdf931 100644 --- a/src/lib_shell/prevalidator.mli +++ b/src/lib_shell/prevalidator.mli @@ -76,14 +76,15 @@ val inject_operation : t -> force:bool -> Operation.t -> unit tzresult Lwt.t val flush : t -> Chain_validator_worker_state.update -> - Block_hash.t -> - Block_hash.Set.t -> - Operation_hash.Set.t -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Block_hash.Set.t -> + Tezos_crypto.Operation_hash.Set.t -> unit tzresult Lwt.t (** Returns the list of prevalidation contexts running and their associated chain *) -val running_workers : unit -> (Chain_id.t * Protocol_hash.t * t) list +val running_workers : + unit -> (Tezos_crypto.Chain_id.t * Tezos_crypto.Protocol_hash.t * t) list (** Worker status and events *) diff --git a/src/lib_shell/prevalidator_classification.ml b/src/lib_shell/prevalidator_classification.ml index 727fc912ffee..ecfa3230605a 100644 --- a/src/lib_shell/prevalidator_classification.ml +++ b/src/lib_shell/prevalidator_classification.ml @@ -44,7 +44,7 @@ module Event = struct ~name:"predecessor_less_block" ~msg:"Observing that a parent of block {blk_h} has no predecessor" ~level:Warning - ("blk_h", Block_hash.encoding) + ("blk_h", Tezos_crypto.Block_hash.encoding) end type error_classification = @@ -55,7 +55,7 @@ type error_classification = type classification = [`Applied | `Prechecked | error_classification] -module Map = Operation_hash.Map +module Map = Tezos_crypto.Operation_hash.Map module Sized_map = Tezos_base.Sized.MakeSizedMap (Map) (** This type wraps together: @@ -66,7 +66,7 @@ module Sized_map = Tezos_base.Sized.MakeSizedMap (Map) All operations must maintain integrity between the 2! *) type 'protocol_data bounded_map = { - ring : Operation_hash.t Ringo.Ring.t; + ring : Tezos_crypto.Operation_hash.t Ringo.Ring.t; mutable map : ('protocol_data Prevalidation.operation * error list) Map.t; } @@ -82,7 +82,7 @@ let mk_empty_bounded_map ring_size = type parameters = { map_size_limit : int; - on_discarded_operation : Operation_hash.t -> unit; + on_discarded_operation : Tezos_crypto.Operation_hash.t -> unit; } (** Note that [applied] and [in_mempool] are intentionally unbounded. @@ -97,7 +97,7 @@ type 'protocol_data t = { branch_delayed : 'protocol_data bounded_map; mutable applied_rev : 'protocol_data Prevalidation.operation list; mutable prechecked : 'protocol_data Prevalidation.operation Sized_map.t; - mutable unparsable : Operation_hash.Set.t; + mutable unparsable : Tezos_crypto.Operation_hash.Set.t; mutable in_mempool : ('protocol_data Prevalidation.operation * classification) Map.t; } @@ -110,7 +110,7 @@ let create parameters = branch_refused = mk_empty_bounded_map parameters.map_size_limit; branch_delayed = mk_empty_bounded_map parameters.map_size_limit; prechecked = Sized_map.empty; - unparsable = Operation_hash.Set.empty; + unparsable = Tezos_crypto.Operation_hash.Set.empty; in_mempool = Map.empty; applied_rev = []; } @@ -134,13 +134,13 @@ let is_empty [in_mempool] is the union of all other fields (see the MLI for detailed documentation of this invariant) except unparsable operations which are not classified yet. *) - Map.is_empty in_mempool && Operation_hash.Set.is_empty unparsable + Map.is_empty in_mempool && Tezos_crypto.Operation_hash.Set.is_empty unparsable let set_of_bounded_map bounded_map = Map.fold - (fun oph _ acc -> Operation_hash.Set.add oph acc) + (fun oph _ acc -> Tezos_crypto.Operation_hash.Set.add oph acc) bounded_map.map - Operation_hash.Set.empty + Tezos_crypto.Operation_hash.Set.empty let flush (classes : 'protocol_data t) ~handle_branch_refused = let remove_map_from_in_mempool map = @@ -167,13 +167,13 @@ let flush (classes : 'protocol_data t) ~handle_branch_refused = remove_list_from_in_mempool classes.applied_rev ; classes.applied_rev <- [] ; remove_map_from_in_mempool (Sized_map.to_map classes.prechecked) ; - classes.unparsable <- Operation_hash.Set.empty ; + classes.unparsable <- Tezos_crypto.Operation_hash.Set.empty ; classes.prechecked <- Sized_map.empty let is_in_mempool oph classes = Map.find oph classes.in_mempool let is_known_unparsable oph classes = - Operation_hash.Set.mem oph classes.unparsable + Tezos_crypto.Operation_hash.Set.mem oph classes.unparsable (* Removing an operation is currently used for operations which are banned (this can only be achieved by the adminstrator of the @@ -205,7 +205,8 @@ let remove oph classes = | `Applied -> classes.applied_rev <- List.filter - (fun op -> Operation_hash.(op.Prevalidation.hash <> oph)) + (fun op -> + Tezos_crypto.Operation_hash.(op.Prevalidation.hash <> oph)) classes.applied_rev) ; Some (op, classification) @@ -253,7 +254,8 @@ let handle_error oph op classification classes = classes.in_mempool <- Map.add oph (op, classification) classes.in_mempool let add_unparsable oph classes = - classes.unparsable <- Operation_hash.Set.add oph classes.unparsable ; + classes.unparsable <- + Tezos_crypto.Operation_hash.Set.add oph classes.unparsable ; classes.parameters.on_discarded_operation oph let add classification op classes = @@ -297,14 +299,14 @@ let to_map ~applied ~prechecked ~branch_delayed ~branch_refused ~refused +> if outdated then classes.outdated.map else Map.empty type 'block block_tools = { - hash : 'block -> Block_hash.t; + hash : 'block -> Tezos_crypto.Block_hash.t; operations : 'block -> Operation.t list list; - all_operation_hashes : 'block -> Operation_hash.t list list; + all_operation_hashes : 'block -> Tezos_crypto.Operation_hash.t list list; } type 'block chain_tools = { - clear_or_cancel : Operation_hash.t -> unit; - inject_operation : Operation_hash.t -> Operation.t -> unit Lwt.t; + clear_or_cancel : Tezos_crypto.Operation_hash.t -> unit; + inject_operation : Tezos_crypto.Operation_hash.t -> Operation.t -> unit Lwt.t; new_blocks : from_block:'block -> to_block:'block -> ('block * 'block list) Lwt.t; read_predecessor_opt : 'block -> 'block option Lwt.t; @@ -313,15 +315,15 @@ type 'block chain_tools = { (* There's detailed documentation in the mli *) let handle_live_operations ~classes ~(block_store : 'block block_tools) ~(chain : 'block chain_tools) ~(from_branch : 'block) ~(to_branch : 'block) - ~(is_branch_alive : Block_hash.t -> bool) + ~(is_branch_alive : Tezos_crypto.Block_hash.t -> bool) ~(parse : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) old_mempool = let open Lwt_syntax in let rec pop_block ancestor (block : 'block) mempool = let hash = block_store.hash block in - if Block_hash.equal hash ancestor then Lwt.return mempool + if Tezos_crypto.Block_hash.equal hash ancestor then Lwt.return mempool else let operations = block_store.operations block in let* mempool = @@ -350,7 +352,8 @@ let handle_live_operations ~classes ~(block_store : 'block block_tools) unparsable and it is ok. *) add_unparsable oph classes ; mempool - | Some parsed_op -> Operation_hash.Map.add oph parsed_op mempool)) + | Some parsed_op -> + Tezos_crypto.Operation_hash.Map.add oph parsed_op mempool)) mempool operations in @@ -374,7 +377,8 @@ let handle_live_operations ~classes ~(block_store : 'block block_tools) let operations = block_store.all_operation_hashes block in List.iter (List.iter chain.clear_or_cancel) operations ; List.fold_left - (List.fold_left (fun mempool h -> Operation_hash.Map.remove h mempool)) + (List.fold_left (fun mempool h -> + Tezos_crypto.Operation_hash.Map.remove h mempool)) mempool operations in @@ -405,7 +409,8 @@ let recycle_operations ~from_branch ~to_branch ~live_blocks ~classes ~parse ~chain ~from_branch ~to_branch - ~is_branch_alive:(fun branch -> Block_hash.Set.mem branch live_blocks) + ~is_branch_alive:(fun branch -> + Tezos_crypto.Block_hash.Set.mem branch live_blocks) ~parse (Map.union (fun _key v _ -> Some v) @@ -429,7 +434,7 @@ module Internal_for_tests = struct (** [copy_bounded_map bm] returns a deep copy of [bm] *) let copy_bounded_map (bm : 'protocol_data bounded_map) : 'protocol_data bounded_map = - let copy_ring (ring : Operation_hash.t Ringo.Ring.t) = + let copy_ring (ring : Tezos_crypto.Operation_hash.t Ringo.Ring.t) = let result = Ringo.Ring.capacity ring |> Ringo.Ring.create in List.iter (Ringo.Ring.add result) (Ringo.Ring.elements ring) ; result @@ -455,7 +460,10 @@ module Internal_for_tests = struct let[@coverage off] bounded_map_pp ppf bounded_map = bounded_map.map |> Map.bindings |> List.map (fun (key, _value) -> key) - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) let[@coverage off] pp ppf { @@ -472,19 +480,31 @@ module Internal_for_tests = struct let applied_pp ppf applied = applied |> List.map (fun op -> op.Prevalidation.hash) - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let in_mempool_pp ppf in_mempool = in_mempool |> Map.bindings |> List.map fst - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let prechecked_pp ppf prechecked = prechecked |> Sized_map.bindings |> List.map fst - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in let unparsable_pp ppf unparsable = - unparsable |> Operation_hash.Set.elements - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + unparsable |> Tezos_crypto.Operation_hash.Set.elements + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) in Format.fprintf ppf diff --git a/src/lib_shell/prevalidator_classification.mli b/src/lib_shell/prevalidator_classification.mli index 24c1ad663be7..1176538c8d73 100644 --- a/src/lib_shell/prevalidator_classification.mli +++ b/src/lib_shell/prevalidator_classification.mli @@ -48,20 +48,21 @@ type 'protocol_data bounded_map (** [map bounded_map] gets the underling map of the [bounded_map]. *) val map : 'protocol_data bounded_map -> - ('protocol_data Prevalidation.operation * tztrace) Operation_hash.Map.t + ('protocol_data Prevalidation.operation * tztrace) + Tezos_crypto.Operation_hash.Map.t (** [cardinal bounded_map] gets the cardinal of the underling map of the [bounded_map] *) val cardinal : 'protocol_data bounded_map -> int type parameters = { map_size_limit : int; - on_discarded_operation : Operation_hash.t -> unit; + on_discarded_operation : Tezos_crypto.Operation_hash.t -> unit; } module Sized_map : Tezos_base.Sized.SizedMap - with type 'a map := 'a Operation_hash.Map.t - and type key = Operation_hash.t + with type 'a map := 'a Tezos_crypto.Operation_hash.Map.t + and type key = Tezos_crypto.Operation_hash.t (** Invariants ensured by this module, provided that the caller does not {!add} an operation which is already present in [t]: @@ -93,10 +94,10 @@ type 'protocol_data t = private { branch_delayed : 'protocol_data bounded_map; mutable applied_rev : 'protocol_data Prevalidation.operation list; mutable prechecked : 'protocol_data Prevalidation.operation Sized_map.t; - mutable unparsable : Operation_hash.Set.t; + mutable unparsable : Tezos_crypto.Operation_hash.Set.t; mutable in_mempool : ('protocol_data Prevalidation.operation * classification) - Operation_hash.Map.t; + Tezos_crypto.Operation_hash.Map.t; } (** [create parameters] returns an empty {!t} whose bounded maps hold @@ -115,14 +116,15 @@ val is_empty : 'protocol_data t -> bool in field [in_mempool] of [classes]. It returns the corresponding operation and its classification if present, and None otherwise. *) val is_in_mempool : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> ('protocol_data Prevalidation.operation * classification) option (** [is_known_unparsable oph] returns [true] if the [oph] is associated to an operation which is known to be unparsable. [false] otherwise. *) -val is_known_unparsable : Operation_hash.t -> 'protocol_data t -> bool +val is_known_unparsable : + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> bool (** [remove oph classes] removes operation of hash [oph] from all fields of [classes]. If the [oph] was classified as [Applied], the @@ -138,7 +140,7 @@ val is_known_unparsable : Operation_hash.t -> 'protocol_data t -> bool this may invalidate the classification of all the other operations. It is left to the caller to restore a consistent state. *) val remove : - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> ('protocol_data Prevalidation.operation * classification) option @@ -177,14 +179,14 @@ val add : operation. [unparsable] operations are removed automatically by the [recycle_operations] function. [on_discard_operation] is also called on those operations. *) -val add_unparsable : Operation_hash.t -> 'protocol_data t -> unit +val add_unparsable : Tezos_crypto.Operation_hash.t -> 'protocol_data t -> unit (** Functions to query data on a polymorphic block-like type ['block]. *) type 'block block_tools = { - hash : 'block -> Block_hash.t; (** The hash of a block *) + hash : 'block -> Tezos_crypto.Block_hash.t; (** The hash of a block *) operations : 'block -> Operation.t list list; (** The list of operations of a block ordered by their validation pass *) - all_operation_hashes : 'block -> Operation_hash.t list list; + all_operation_hashes : 'block -> Tezos_crypto.Operation_hash.t list list; (** The list of hashes of operations of a block ordered by their validation pass. Could be implemented using {!operations} but this lets an alternative implementation @@ -194,9 +196,9 @@ type 'block block_tools = { (** A wrapper over chain-related modules, to make client code easier to emulate, and hence to test *) type 'block chain_tools = { - clear_or_cancel : Operation_hash.t -> unit; + clear_or_cancel : Tezos_crypto.Operation_hash.t -> unit; (** Removes the operation from the distributed database. *) - inject_operation : Operation_hash.t -> Operation.t -> unit Lwt.t; + inject_operation : Tezos_crypto.Operation_hash.t -> Operation.t -> unit Lwt.t; (** Puts the operation in the distributed database. Returns [false] if the [hash] is already in the distributed database *) new_blocks : @@ -233,17 +235,18 @@ type 'block chain_tools = { val recycle_operations : from_branch:'block -> to_branch:'block -> - live_blocks:Block_hash.Set.t -> + live_blocks:Tezos_crypto.Block_hash.Set.t -> classes:'protocol_data t -> parse: - (Operation_hash.t -> + (Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) -> - pending:'protocol_data Prevalidation.operation Operation_hash.Map.t -> + pending: + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t -> block_store:'block block_tools -> chain:'block chain_tools -> handle_branch_refused:bool -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t Lwt.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t Lwt.t (**/**) @@ -257,7 +260,8 @@ module Internal_for_tests : sig val copy : 'protocol_data t -> 'protocol_data t (** [set_of_bounded_map m] returns all the operation hashes in [m]. *) - val set_of_bounded_map : 'protocol_data bounded_map -> Operation_hash.Set.t + val set_of_bounded_map : + 'protocol_data bounded_map -> Tezos_crypto.Operation_hash.Set.t (** [pp_t_sizes t] prints the [map_size_limit] parameter of [t] and the sizes of its fields (number of elements in the map and @@ -276,7 +280,7 @@ module Internal_for_tests : sig refused:bool -> outdated:bool -> 'protocol_data t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t (** [flush classes ~handle_branch_refused] partially resets [classes]: - fields [applied_rev], [branch_delayed] and [unparsable] are emptied; @@ -322,11 +326,12 @@ module Internal_for_tests : sig chain:'block chain_tools -> from_branch:'block -> to_branch:'block -> - is_branch_alive:(Block_hash.t -> bool) -> + is_branch_alive:(Tezos_crypto.Block_hash.t -> bool) -> parse: - (Operation_hash.t -> + (Tezos_crypto.Operation_hash.t -> Operation.t -> 'protocol_data Prevalidation.operation option) -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t Lwt.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t -> + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t + Lwt.t end diff --git a/src/lib_shell/prevalidator_events.ml b/src/lib_shell/prevalidator_events.ml index bee712e3e713..949cc252945e 100644 --- a/src/lib_shell/prevalidator_events.ml +++ b/src/lib_shell/prevalidator_events.ml @@ -62,8 +62,8 @@ let unparsable_operation = ~name:"unparsable_operation" ~msg:"unparsable operation {oph}" ~level:Debug - ~pp1:Operation_hash.pp - ("oph", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("oph", Tezos_crypto.Operation_hash.encoding) let processing_operations = declare_0 @@ -79,8 +79,8 @@ let fetching_operation = ~name:"fetching_operation" ~msg:"fetching operation {oph}" ~level:Debug - ~pp1:Operation_hash.pp - ("oph", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("oph", Tezos_crypto.Operation_hash.encoding) let operation_included = declare_1 @@ -88,8 +88,8 @@ let operation_included = ~name:"operation_included" ~msg:"operation {oph} included before being prevalidated" ~level:Debug - ~pp1:Operation_hash.pp - ("oph", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("oph", Tezos_crypto.Operation_hash.encoding) let operations_to_reclassify = declare_1 @@ -175,9 +175,9 @@ let ban_operation_encountered = ~msg:"{origin}: banned {oph} encountered" ~level:Notice ~pp1:pp_origin - ~pp2:Operation_hash.pp + ~pp2:Tezos_crypto.Operation_hash.pp ("origin", origin_encoding) - ("oph", Operation_hash.encoding) + ("oph", Tezos_crypto.Operation_hash.encoding) let operation_not_fetched = declare_1 @@ -185,5 +185,5 @@ let operation_not_fetched = ~name:"operation_not_fetched" ~msg:"Operation {oph} was not fetched" ~level:Debug - ~pp1:Operation_hash.pp - ("oph", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("oph", Tezos_crypto.Operation_hash.encoding) diff --git a/src/lib_shell/prevalidator_internal.ml b/src/lib_shell/prevalidator_internal.ml index a3be06cb0d77..bc166fc9609e 100644 --- a/src/lib_shell/prevalidator_internal.ml +++ b/src/lib_shell/prevalidator_internal.ml @@ -76,7 +76,7 @@ module Tools = struct (** Lower-level tools provided by {!Prevalidator_classification} *) create : predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> 'prevalidation_t tzresult Lwt.t; @@ -85,19 +85,20 @@ module Tools = struct fetch : ?peer:P2p_peer.Id.t -> ?timeout:Time.System.Span.t -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t tzresult Lwt.t; (** [fetch ?peer ?timeout oph] returns the value when it is known. It can fail with [Requester.Timeout] if [timeout] is provided and the value isn't known before the timeout expires. It can fail with [Requester.Cancel] if the request is canceled. *) - read_block : Block_hash.t -> Store.Block.t tzresult Lwt.t; + read_block : Tezos_crypto.Block_hash.t -> Store.Block.t tzresult Lwt.t; (** [read_block bh] tries to read the block [bh] from the chain store. *) send_get_current_head : ?peer:P2p_peer_id.t -> unit -> unit; (** [send_get_current_head ?peer ()] sends a [Get_Current_head] to a given peer, or to all known active peers for the chain considered. Expected answer is a [Get_current_head] message *) - set_mempool : head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; + set_mempool : + head:Tezos_crypto.Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; (** [set_mempool ~head mempool] sets the [mempool] of the [chain_store] of the chain considered. Does nothing if [head] differs from current_head which might happen when a new head concurrently arrives just @@ -130,13 +131,13 @@ type ('protocol_data, 'a) types_state_shell = { parameters : 'a parameters; mutable predecessor : Store.Block.t; mutable timestamp : Time.System.t; - mutable live_blocks : Block_hash.Set.t; - mutable live_operations : Operation_hash.Set.t; - mutable fetching : Operation_hash.Set.t; + mutable live_blocks : Tezos_crypto.Block_hash.Set.t; + mutable live_operations : Tezos_crypto.Operation_hash.Set.t; + mutable fetching : Tezos_crypto.Operation_hash.Set.t; mutable pending : 'protocol_data Pending_ops.t; mutable mempool : Mempool.t; mutable advertisement : [`Pending of Mempool.t | `None]; - mutable banned_operations : Operation_hash.Set.t; + mutable banned_operations : Tezos_crypto.Operation_hash.Set.t; worker : Tools.worker_tools; } @@ -214,7 +215,7 @@ module type S = sig val may_fetch_operation : (protocol_operation, prevalidation_t) types_state_shell -> P2p_peer_id.t option -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Lwt.t (** The function called after every call to a function of {!API}. *) @@ -232,18 +233,19 @@ module type S = sig val on_arrived : types_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> (unit, Empty.t) result Lwt.t - val on_ban : types_state -> Operation_hash.t -> unit tzresult Lwt.t + val on_ban : + types_state -> Tezos_crypto.Operation_hash.t -> unit tzresult Lwt.t val on_flush : handle_branch_refused:bool -> types_state -> Store.Block.t -> - Block_hash.Set.t -> - Operation_hash.Set.t -> + Tezos_crypto.Block_hash.Set.t -> + Tezos_crypto.Operation_hash.Set.t -> unit tzresult Lwt.t val on_inject : @@ -298,14 +300,14 @@ module Make_s (* This function is in [Lwt] only for logging. *) let already_handled ~origin shell oph = let open Lwt_syntax in - if Operation_hash.Set.mem oph shell.banned_operations then + if Tezos_crypto.Operation_hash.Set.mem oph shell.banned_operations then let+ () = Events.(emit ban_operation_encountered) (origin, oph) in true else Lwt.return (Pending_ops.mem oph shell.pending - || Operation_hash.Set.mem oph shell.fetching - || Operation_hash.Set.mem oph shell.live_operations + || Tezos_crypto.Operation_hash.Set.mem oph shell.fetching + || Tezos_crypto.Operation_hash.Set.mem oph shell.live_operations || Classification.is_in_mempool oph shell.classification <> None || Classification.is_known_unparsable oph shell.classification) @@ -317,7 +319,8 @@ module Make_s `Pending { known_valid = known_valid @ mempool.Mempool.known_valid; - pending = Operation_hash.Set.union pending mempool.pending; + pending = + Tezos_crypto.Operation_hash.Set.union pending mempool.pending; } | `None -> shell.advertisement <- `Pending mempool ; @@ -704,10 +707,12 @@ module Make_s ignore (Lwt.finalize (fun () -> - shell.fetching <- Operation_hash.Set.add oph shell.fetching ; + shell.fetching <- + Tezos_crypto.Operation_hash.Set.add oph shell.fetching ; fetch_operation shell ?peer oph) (fun () -> - shell.fetching <- Operation_hash.Set.remove oph shell.fetching ; + shell.fetching <- + Tezos_crypto.Operation_hash.Set.remove oph shell.fetching ; Lwt.return_unit)) ; Lwt.return_unit @@ -744,7 +749,7 @@ module Make_s | (`High | `Medium | `Low _) as prio -> if not - (Block_hash.Set.mem + (Tezos_crypto.Block_hash.Set.mem op.Operation.shell.branch pv.shell.live_blocks) then ( @@ -778,7 +783,7 @@ module Make_s | Error err -> failwith "Invalid operation %a: %a." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Error_monad.pp_print_trace err @@ -792,15 +797,15 @@ module Make_s return_unit) else if not - (Block_hash.Set.mem + (Tezos_crypto.Block_hash.Set.mem op.Operation.shell.branch pv.shell.live_blocks) then failwith "Operation %a is branched on a block %a which is too old" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.Operation.shell.branch else let*? validation_state = @@ -831,7 +836,7 @@ module Make_s List.find_opt (function | ({hash; _} : protocol_operation operation), _ -> - Operation_hash.equal hash oph) + Tezos_crypto.Operation_hash.equal hash oph) to_handle in match op_status with @@ -864,7 +869,7 @@ module Make_s Lwt.return @@ error_with "Error while applying operation %a:@ %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph pp_print_trace e @@ -873,7 +878,7 @@ module Make_s failwith "Unexpected error while injecting operation %a. Operation \ not found after classifying it." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) let on_notify (shell : ('operation_data, _) types_state_shell) peer mempool @@ -883,7 +888,7 @@ module Make_s let* () = List.iter_s may_fetch_operation mempool.Mempool.known_valid in Seq.iter_s may_fetch_operation - (Operation_hash.Set.to_seq mempool.Mempool.pending) + (Tezos_crypto.Operation_hash.Set.to_seq mempool.Mempool.pending) let on_flush ~handle_branch_refused pv new_predecessor new_live_blocks new_live_operations = @@ -929,10 +934,10 @@ module Make_s ~chain:pv.shell.parameters.tools.chain_tools ~handle_branch_refused in - (* Could be implemented as Operation_hash.Map.filter_s which + (* Could be implemented as Tezos_crypto.Operation_hash.Map.filter_s which does not exist for the moment. *) let*! new_pending_operations, nb_pending = - Operation_hash.Map.fold_s + Tezos_crypto.Operation_hash.Map.fold_s (fun _oph op (pending, nb_pending) -> let*! v = pre_filter @@ -981,11 +986,12 @@ module Make_s pv.shell.advertisement <- remove_from_advertisement oph pv.shell.advertisement ; pv.shell.banned_operations <- - Operation_hash.Set.add oph pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.add oph pv.shell.banned_operations ; match Classification.remove oph pv.shell.classification with | None -> pv.shell.pending <- Pending_ops.remove oph pv.shell.pending ; - pv.shell.fetching <- Operation_hash.Set.remove oph pv.shell.fetching ; + pv.shell.fetching <- + Tezos_crypto.Operation_hash.Set.remove oph pv.shell.fetching ; return_unit | Some (_op, classification) -> ( match (classification, flush_if_prechecked) with @@ -1016,7 +1022,9 @@ module Make_s let on_ban pv oph_to_ban = pv.shell.banned_operations <- - Operation_hash.Set.add oph_to_ban pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.add + oph_to_ban + pv.shell.banned_operations ; remove ~flush_if_prechecked:true pv oph_to_ban end end @@ -1026,7 +1034,7 @@ module type ARG = sig val chain_db : Distributed_db.chain_db - val chain_id : Chain_id.t + val chain_id : Tezos_crypto.Chain_id.t end module WorkerGroup = Worker.MakeGroup (Name) (Prevalidator_worker_state.Request) @@ -1151,7 +1159,9 @@ module Make (Proto_services.S.Mempool.unban_operation Tezos_rpc.Path.open_root) (fun pv () oph -> pv.shell.banned_operations <- - Operation_hash.Set.remove oph pv.shell.banned_operations ; + Tezos_crypto.Operation_hash.Set.remove + oph + pv.shell.banned_operations ; return_unit) ; (* Unban all operations: clear the set pv.banned_operations. *) dir := @@ -1160,7 +1170,7 @@ module Make (Proto_services.S.Mempool.unban_all_operations Tezos_rpc.Path.open_root) (fun pv () () -> - pv.shell.banned_operations <- Operation_hash.Set.empty ; + pv.shell.banned_operations <- Tezos_crypto.Operation_hash.Set.empty ; return_unit) ; dir := Tezos_rpc.Directory.gen_register @@ -1169,7 +1179,7 @@ module Make (fun pv params () -> let map_op_error oph (op, error) acc = op.Prevalidation.protocol |> fun res -> - Operation_hash.Map.add oph (res, error) acc + Tezos_crypto.Operation_hash.Map.add oph (res, error) acc in let applied = if params#applied then @@ -1179,42 +1189,45 @@ module Make else [] in let filter f map = - Operation_hash.Map.fold f map Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.fold + f + map + Tezos_crypto.Operation_hash.Map.empty in let refused = if params#refused then filter map_op_error (Classification.map pv.shell.classification.refused) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let outdated = if params#outdated then filter map_op_error (Classification.map pv.shell.classification.outdated) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let branch_refused = if params#branch_refused then filter map_op_error (Classification.map pv.shell.classification.branch_refused) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let branch_delayed = if params#branch_delayed then filter map_op_error (Classification.map pv.shell.classification.branch_delayed) - else Operation_hash.Map.empty + else Tezos_crypto.Operation_hash.Map.empty in let unprocessed = Pending_ops.fold (fun _prio oph op acc -> - Operation_hash.Map.add oph op.protocol acc) + Tezos_crypto.Operation_hash.Map.add oph op.protocol acc) pv.shell.pending - Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.empty in (* FIXME https://gitlab.com/tezos/tezos/-/issues/2250 @@ -1287,7 +1300,7 @@ module Make in let refused = if params#refused then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.refused) [] @@ -1295,7 +1308,7 @@ module Make in let branch_refused = if params#branch_refused then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.branch_refused) [] @@ -1303,7 +1316,7 @@ module Make in let branch_delayed = if params#branch_delayed then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.branch_delayed) [] @@ -1311,7 +1324,7 @@ module Make in let outdated = if params#outdated then - Operation_hash.Map.fold + Tezos_crypto.Operation_hash.Map.fold fold_op (Classification.map pv.shell.classification.outdated) [] @@ -1425,7 +1438,7 @@ module Make let on_close w = let pv = Worker.state w in - Operation_hash.Set.iter + Tezos_crypto.Operation_hash.Set.iter pv.shell.parameters.tools.chain_tools.clear_or_cancel pv.shell.fetching ; Lwt.return_unit @@ -1496,8 +1509,8 @@ module Make in let fetching = List.fold_left - (fun s h -> Operation_hash.Set.add h s) - Operation_hash.Set.empty + (fun s h -> Tezos_crypto.Operation_hash.Set.add h s) + Tezos_crypto.Operation_hash.Set.empty mempool.known_valid in let classification_parameters = @@ -1522,7 +1535,7 @@ module Make fetching; pending = Pending_ops.empty; advertisement = `None; - banned_operations = Operation_hash.Set.empty; + banned_operations = Tezos_crypto.Operation_hash.Set.empty; worker = mk_worker_tools w; } in @@ -1576,7 +1589,7 @@ module Make let*! () = Seq.iter_s (may_fetch_operation pv.shell None) - (Operation_hash.Set.to_seq fetching) + (Tezos_crypto.Operation_hash.Set.to_seq fetching) in return pv @@ -1658,12 +1671,12 @@ module Internal_for_tests = struct {map_size_limit = 32; on_discarded_operation = Fun.const ()} in let advertisement = `None in - let banned_operations = Operation_hash.Set.empty in + let banned_operations = Tezos_crypto.Operation_hash.Set.empty in let classification = Classification.create c_parameters in - let fetching = Operation_hash.Set.empty in + let fetching = Tezos_crypto.Operation_hash.Set.empty in let mempool = Mempool.empty in - let live_blocks = Block_hash.Set.empty in - let live_operations = Operation_hash.Set.empty in + let live_blocks = Tezos_crypto.Block_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let pending = Pending_ops.empty in let timestamp = Tezos_base.Time.System.now () in { diff --git a/src/lib_shell/prevalidator_internal.mli b/src/lib_shell/prevalidator_internal.mli index f9153f237473..8338ec39be4c 100644 --- a/src/lib_shell/prevalidator_internal.mli +++ b/src/lib_shell/prevalidator_internal.mli @@ -45,7 +45,7 @@ val make : Shell_limits.prevalidator_limits -> Distributed_db.chain_db -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> (module Shell_plugin.FILTER) -> Prevalidator_internal_common.t @@ -58,18 +58,19 @@ module Internal_for_tests : sig chain_tools : Store.Block.t Prevalidator_classification.chain_tools; create : predecessor:Store.Block.t -> - live_operations:Operation_hash.Set.t -> + live_operations:Tezos_crypto.Operation_hash.Set.t -> timestamp:Time.Protocol.t -> unit -> 'prevalidation_t tzresult Lwt.t; fetch : ?peer:P2p_peer.Id.t -> ?timeout:Time.System.Span.t -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t tzresult Lwt.t; - read_block : Block_hash.t -> Store.Block.t tzresult Lwt.t; + read_block : Tezos_crypto.Block_hash.t -> Store.Block.t tzresult Lwt.t; send_get_current_head : ?peer:P2p_peer_id.t -> unit -> unit; - set_mempool : head:Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; + set_mempool : + head:Tezos_crypto.Block_hash.t -> Mempool.t -> unit tzresult Lwt.t; } (** Documented in the ml file, because this is only exported for tests. *) @@ -126,18 +127,19 @@ module Internal_for_tests : sig val on_arrived : types_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Operation.t -> (unit, Empty.t) result Lwt.t - val on_ban : types_state -> Operation_hash.t -> unit tzresult Lwt.t + val on_ban : + types_state -> Tezos_crypto.Operation_hash.t -> unit tzresult Lwt.t val on_flush : handle_branch_refused:bool -> types_state -> Store.Block.t -> - Block_hash.Set.t -> - Operation_hash.Set.t -> + Tezos_crypto.Block_hash.Set.t -> + Tezos_crypto.Operation_hash.Set.t -> unit tzresult Lwt.t val on_inject : diff --git a/src/lib_shell/prevalidator_internal_common.ml b/src/lib_shell/prevalidator_internal_common.ml index 5bec2002a65e..44af56d356a9 100644 --- a/src/lib_shell/prevalidator_internal_common.ml +++ b/src/lib_shell/prevalidator_internal_common.ml @@ -27,9 +27,12 @@ let advertisement_delay = 0.1 module Name = struct - type t = Chain_id.t * Protocol_hash.t + type t = Tezos_crypto.Chain_id.t * Tezos_crypto.Protocol_hash.t - let encoding = Data_encoding.tup2 Chain_id.encoding Protocol_hash.encoding + let encoding = + Data_encoding.tup2 + Tezos_crypto.Chain_id.encoding + Tezos_crypto.Protocol_hash.encoding let base = ["prevalidator"] @@ -37,13 +40,13 @@ module Name = struct Format.fprintf fmt "%a:%a" - Chain_id.pp_short + Tezos_crypto.Chain_id.pp_short chain_id - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short proto_hash let equal (c1, p1) (c2, p2) = - Chain_id.equal c1 c2 && Protocol_hash.equal p1 p2 + Tezos_crypto.Chain_id.equal c1 c2 && Tezos_crypto.Protocol_hash.equal p1 p2 end open Prevalidator_worker_state diff --git a/src/lib_shell/prevalidator_internal_common.mli b/src/lib_shell/prevalidator_internal_common.mli index bc893bd04348..e58326b0a475 100644 --- a/src/lib_shell/prevalidator_internal_common.mli +++ b/src/lib_shell/prevalidator_internal_common.mli @@ -34,7 +34,8 @@ val advertisement_delay : float (** Argument that will be provided to {!Worker.MakeGroup} to create the prevalidator worker. *) module Name : - Tezos_base.Worker_intf.NAME with type t = Chain_id.t * Protocol_hash.t + Tezos_base.Worker_intf.NAME + with type t = Tezos_crypto.Chain_id.t * Tezos_crypto.Protocol_hash.t open Prevalidator_worker_state diff --git a/src/lib_shell/prevalidator_pending_operations.ml b/src/lib_shell/prevalidator_pending_operations.ml index 1ef2b9deba69..c47cb1045b3d 100644 --- a/src/lib_shell/prevalidator_pending_operations.ml +++ b/src/lib_shell/prevalidator_pending_operations.ml @@ -59,8 +59,9 @@ module Priority_map : Map.S with type key = priority = Map.Make (struct | `Medium, `Low _ -> -1 end) -module Map = Operation_hash.Map -module Sized_set = Tezos_base.Sized.MakeSizedSet (Operation_hash.Set) +module Map = Tezos_crypto.Operation_hash.Map +module Sized_set = + Tezos_base.Sized.MakeSizedSet (Tezos_crypto.Operation_hash.Set) (* The type below is used for representing pending operations data of the diff --git a/src/lib_shell/prevalidator_pending_operations.mli b/src/lib_shell/prevalidator_pending_operations.mli index a020ed35feb3..cf7ffbd4b5c2 100644 --- a/src/lib_shell/prevalidator_pending_operations.mli +++ b/src/lib_shell/prevalidator_pending_operations.mli @@ -46,18 +46,18 @@ type priority = [`High | `Medium | `Low of Q.t list] type 'protocol_data t module Sized_set : - Tezos_base.Sized.SizedSet with type set := Operation_hash.Set.t + Tezos_base.Sized.SizedSet with type set := Tezos_crypto.Operation_hash.Set.t (** The empty structure of pending operations. *) val empty : 'protocol_data t (** [hashes p] returns the set of hashes contained in [p] *) -val hashes : 'protocol_data t -> Operation_hash.Set.t +val hashes : 'protocol_data t -> Tezos_crypto.Operation_hash.Set.t (** [operations p] returns the Map of bindings [oph -> op] contained in [p] *) val operations : 'protocol_data t -> - 'protocol_data Prevalidation.operation Operation_hash.Map.t + 'protocol_data Prevalidation.operation Tezos_crypto.Operation_hash.Map.t (** [is_empty p] returns [true] if [p] has operations, [false] otherwise. *) val is_empty : 'protocol_data t -> bool @@ -67,7 +67,7 @@ val is_empty : 'protocol_data t -> bool Complexity is O(log(n)), where n is the number of operations (hashes) in the structure. *) -val mem : Operation_hash.t -> 'protocol_data t -> bool +val mem : Tezos_crypto.Operation_hash.t -> 'protocol_data t -> bool (** [add oph op p prio] records the operation [op] whose hash is [oph] and whose priority is [prio] in [p]. @@ -90,7 +90,8 @@ val add : Complexity is O(log(n)), where n is the number of operations (hashes) in the structure. *) -val remove : Operation_hash.t -> 'protocol_data t -> 'protocol_data t +val remove : + Tezos_crypto.Operation_hash.t -> 'protocol_data t -> 'protocol_data t (** [cardinal p] returns the number of operations (hashes) in [p]. @@ -105,12 +106,12 @@ val cardinal : 'protocol_data t -> int We iterate on operations with `High priority first, then on those with `Low priority. For operations with the same priority, the iteration order is - defined [Operation_hash.compare] function (operations with small hashes are + defined [Tezos_crypto.Operation_hash.compare] function (operations with small hashes are processed first). *) val fold : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> 'a -> 'a) -> @@ -121,7 +122,7 @@ val fold : (** [iter f p] is similar to [fold] where [acc] is unit *) val iter : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> unit) -> 'protocol_data t -> @@ -132,7 +133,7 @@ val iter : value [Error e] is returned by [f] *) val fold_es : (priority -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> 'protocol_data Prevalidation.operation -> 'a -> ('a, 'b) result Lwt.t) -> diff --git a/src/lib_shell/protocol_directory.ml b/src/lib_shell/protocol_directory.ml index c9b241850362..d1701b112c75 100644 --- a/src/lib_shell/protocol_directory.ml +++ b/src/lib_shell/protocol_directory.ml @@ -36,9 +36,12 @@ let build_rpc_directory block_validator store = gen_register0 Protocol_services.S.list (fun () () -> let set = Store.Protocol.all store in let protocols = - Protocol_hash.Set.add_seq (Registered_protocol.seq_embedded ()) set + Tezos_crypto.Protocol_hash.Set.add_seq + (Registered_protocol.seq_embedded ()) + set in - Tezos_rpc.Answer.return (Protocol_hash.Set.elements protocols)) ; + Tezos_rpc.Answer.return + (Tezos_crypto.Protocol_hash.Set.elements protocols)) ; register1 Protocol_services.S.contents (fun hash () () -> match Registered_protocol.get_embedded_sources hash with | Some p -> return p diff --git a/src/lib_shell/protocol_validator.ml b/src/lib_shell/protocol_validator.ml index 57114e0dfe04..28974fdfaa57 100644 --- a/src/lib_shell/protocol_validator.ml +++ b/src/lib_shell/protocol_validator.ml @@ -35,7 +35,7 @@ type t = { (Protocol.t * Registered_protocol.t tzresult Lwt.t * Registered_protocol.t tzresult Lwt.u) - Protocol_hash.Map.t; + Tezos_crypto.Protocol_hash.Map.t; canceler : Lwt_canceler.t; } @@ -44,12 +44,12 @@ type t = { let rec worker_loop bv = let open Lwt_result_syntax in let*! r = - match Protocol_hash.Map.choose bv.pending with + match Tezos_crypto.Protocol_hash.Map.choose bv.pending with | None -> let*! v = Lwt_condition.wait bv.request in return v | Some (hash, (protocol, _, wakener)) -> - bv.pending <- Protocol_hash.Map.remove hash bv.pending ; + bv.pending <- Tezos_crypto.Protocol_hash.Map.remove hash bv.pending ; let*! valid = Updater.compile hash protocol in if valid then ( let* _ = Distributed_db.commit_protocol bv.db hash protocol in @@ -80,11 +80,13 @@ let rec worker_loop bv = let create db = let canceler = Lwt_canceler.create () in - let pending = Protocol_hash.Map.empty in + let pending = Tezos_crypto.Protocol_hash.Map.empty in let request = Lwt_condition.create () in let bv = {canceler; pending; request; db; worker = Lwt.return_unit} in Lwt_canceler.on_cancel bv.canceler (fun () -> - Protocol_hash.Map.iter (fun _ (_, r, _) -> Lwt.cancel r) bv.pending ; + Tezos_crypto.Protocol_hash.Map.iter + (fun _ (_, r, _) -> Lwt.cancel r) + bv.pending ; Lwt.return_unit) ; bv.worker <- Lwt_utils.worker @@ -111,12 +113,17 @@ let validate state hash protocol = let* () = Protocol_validator_event.(emit pushing_protocol_validation) hash in - match Protocol_hash.Map.find hash state.pending with + match Tezos_crypto.Protocol_hash.Map.find hash state.pending with | None -> let res, wakener = Lwt.task () in - let broadcast = Protocol_hash.Map.cardinal state.pending = 0 in + let broadcast = + Tezos_crypto.Protocol_hash.Map.cardinal state.pending = 0 + in state.pending <- - Protocol_hash.Map.add hash (protocol, res, wakener) state.pending ; + Tezos_crypto.Protocol_hash.Map.add + hash + (protocol, res, wakener) + state.pending ; if broadcast then Lwt_condition.broadcast state.request () ; res | Some (_, res, _) -> res) diff --git a/src/lib_shell/protocol_validator.mli b/src/lib_shell/protocol_validator.mli index ca1e65baabc6..33281e37d040 100644 --- a/src/lib_shell/protocol_validator.mli +++ b/src/lib_shell/protocol_validator.mli @@ -29,7 +29,10 @@ type t val create : Distributed_db.t -> t val validate : - t -> Protocol_hash.t -> Protocol.t -> Registered_protocol.t tzresult Lwt.t + t -> + Tezos_crypto.Protocol_hash.t -> + Protocol.t -> + Registered_protocol.t tzresult Lwt.t val shutdown : t -> unit Lwt.t @@ -37,7 +40,7 @@ val fetch_and_compile_protocol : t -> ?peer:P2p_peer.Id.t -> ?timeout:Ptime.Span.t -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Registered_protocol.t tzresult Lwt.t val fetch_and_compile_protocols : diff --git a/src/lib_shell/protocol_validator_event.ml b/src/lib_shell/protocol_validator_event.ml index 5858320264a3..e080d62858e8 100644 --- a/src/lib_shell/protocol_validator_event.ml +++ b/src/lib_shell/protocol_validator_event.ml @@ -52,7 +52,7 @@ let previously_validated_protocol = ~name:"previously_validated_protocol" ~msg:"protocol {hash} already validated, ignoring" ~level:Debug - ("hash", Protocol_hash.encoding) + ("hash", Tezos_crypto.Protocol_hash.encoding) let pushing_protocol_validation = declare_1 @@ -60,7 +60,7 @@ let pushing_protocol_validation = ~name:"pushing_protocol_validation" ~msg:"pushing validation request for protocol {hash}" ~level:Debug - ("hash", Protocol_hash.encoding) + ("hash", Tezos_crypto.Protocol_hash.encoding) let fetching_protocol = declare_2 @@ -68,5 +68,5 @@ let fetching_protocol = ~name:"fetching_protocol" ~msg:"fetching protocol {hash}" ~level:Notice - ("hash", Protocol_hash.encoding) + ("hash", Tezos_crypto.Protocol_hash.encoding) ("source", Data_encoding.option P2p_peer.Id.encoding) diff --git a/src/lib_shell/shell_metrics.ml b/src/lib_shell/shell_metrics.ml index 12c97ec0a8dd..31f18168a82c 100644 --- a/src/lib_shell/shell_metrics.ml +++ b/src/lib_shell/shell_metrics.ml @@ -504,7 +504,7 @@ module Chain_validator = struct Worker.declare_counters ~label_names:[label_name] ~namespace ?subsystem () in fun chain_id -> - let label = Chain_id.to_short_b58check chain_id in + let label = Tezos_crypto.Chain_id.to_short_b58check chain_id in { head_level = head_level label; ignored_head_count = ignored_head_count label; diff --git a/src/lib_shell/shell_metrics.mli b/src/lib_shell/shell_metrics.mli index c1766349fefa..4d48caa26fc9 100644 --- a/src/lib_shell/shell_metrics.mli +++ b/src/lib_shell/shell_metrics.mli @@ -103,7 +103,7 @@ module Chain_validator : sig val update_sync_status : metrics:t -> Chain_validator_worker_state.synchronisation_status -> unit - val init : string list -> Chain_id.t -> t + val init : string list -> Tezos_crypto.Chain_id.t -> t val update_proto_metrics_callback : metrics:t -> cycle:float -> consumed_gas:float -> round:float -> unit diff --git a/src/lib_shell/shell_plugin.ml b/src/lib_shell/shell_plugin.ml index f51d378329b6..f0c87be4b192 100644 --- a/src/lib_shell/shell_plugin.ml +++ b/src/lib_shell/shell_plugin.ml @@ -50,13 +50,13 @@ module type FILTER = sig unit -> state tzresult Lwt.t - val remove : filter_state:state -> Operation_hash.t -> state + val remove : filter_state:state -> Tezos_crypto.Operation_hash.t -> state val precheck : config -> filter_state:state -> validation_state:Proto.validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Proto.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of @@ -64,8 +64,8 @@ module type FILTER = sig * Proto.validation_state * [ `No_replace | `Replace of - Operation_hash.t * Prevalidator_classification.error_classification - ] + Tezos_crypto.Operation_hash.t + * Prevalidator_classification.error_classification ] | `Undecided | Prevalidator_classification.error_classification ] Lwt.t @@ -130,7 +130,7 @@ module No_filter (Proto : Registered_protocol.T) = struct end module type METRICS = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t val update_metrics : protocol_metadata:bytes -> @@ -140,7 +140,7 @@ module type METRICS = sig end module Undefined_metrics_plugin (Proto : sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t end) = struct let hash = Proto.hash @@ -148,31 +148,38 @@ struct let update_metrics ~protocol_metadata:_ _ _ = Lwt.return_unit end -let filter_table : (module FILTER) Protocol_hash.Table.t = - Protocol_hash.Table.create 5 +let filter_table : (module FILTER) Tezos_crypto.Protocol_hash.Table.t = + Tezos_crypto.Protocol_hash.Table.create 5 -let rpc_table : (module RPC) Protocol_hash.Table.t = - Protocol_hash.Table.create 5 +let rpc_table : (module RPC) Tezos_crypto.Protocol_hash.Table.t = + Tezos_crypto.Protocol_hash.Table.create 5 -let metrics_table : (module METRICS) Protocol_hash.Table.t = - Protocol_hash.Table.create 5 +let metrics_table : (module METRICS) Tezos_crypto.Protocol_hash.Table.t = + Tezos_crypto.Protocol_hash.Table.create 5 let register_filter (module Filter : FILTER) = - assert (not (Protocol_hash.Table.mem filter_table Filter.Proto.hash)) ; - Protocol_hash.Table.add filter_table Filter.Proto.hash (module Filter) + assert ( + not (Tezos_crypto.Protocol_hash.Table.mem filter_table Filter.Proto.hash)) ; + Tezos_crypto.Protocol_hash.Table.add + filter_table + Filter.Proto.hash + (module Filter) let register_rpc (module Rpc : RPC) = - assert (not (Protocol_hash.Table.mem rpc_table Rpc.Proto.hash)) ; - Protocol_hash.Table.add rpc_table Rpc.Proto.hash (module Rpc) + assert (not (Tezos_crypto.Protocol_hash.Table.mem rpc_table Rpc.Proto.hash)) ; + Tezos_crypto.Protocol_hash.Table.add rpc_table Rpc.Proto.hash (module Rpc) let register_metrics (module Metrics : METRICS) = - Protocol_hash.Table.replace metrics_table Metrics.hash (module Metrics) + Tezos_crypto.Protocol_hash.Table.replace + metrics_table + Metrics.hash + (module Metrics) -let find_filter = Protocol_hash.Table.find filter_table +let find_filter = Tezos_crypto.Protocol_hash.Table.find filter_table -let find_rpc = Protocol_hash.Table.find rpc_table +let find_rpc = Tezos_crypto.Protocol_hash.Table.find rpc_table -let find_metrics = Protocol_hash.Table.find metrics_table +let find_metrics = Tezos_crypto.Protocol_hash.Table.find metrics_table let safe_find_metrics hash = match find_metrics hash with diff --git a/src/lib_shell/shell_plugin.mli b/src/lib_shell/shell_plugin.mli index 3d24e9b37607..1e01d7cedf01 100644 --- a/src/lib_shell/shell_plugin.mli +++ b/src/lib_shell/shell_plugin.mli @@ -59,7 +59,7 @@ module type FILTER = sig (** [remove ~filter_state oph] removes the operation manager linked to [oph] from the state of the filter *) - val remove : filter_state:state -> Operation_hash.t -> state + val remove : filter_state:state -> Tezos_crypto.Operation_hash.t -> state (** [precheck config ~filter_state ~validation_state oph op ~nb_successful_prechecks] @@ -85,7 +85,7 @@ module type FILTER = sig config -> filter_state:state -> validation_state:Proto.validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Proto.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of @@ -93,8 +93,8 @@ module type FILTER = sig * Proto.validation_state * [ `No_replace | `Replace of - Operation_hash.t * Prevalidator_classification.error_classification - ] + Tezos_crypto.Operation_hash.t + * Prevalidator_classification.error_classification ] | `Undecided | Prevalidator_classification.error_classification ] Lwt.t @@ -154,7 +154,7 @@ module No_filter (Proto : Registered_protocol.T) : * allows to decode protocol data payload and provide back basic * types that can be used as metrics. *) module type METRICS = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t val update_metrics : protocol_metadata:bytes -> @@ -165,7 +165,7 @@ end (** Emtpy metrics module. All metrics are -1. *) module Undefined_metrics_plugin (P : sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t end) : METRICS (** Registers a mempool filters plug-in for a specific protocol (according to its [Proto.hash]). *) @@ -178,13 +178,13 @@ val register_rpc : (module RPC) -> unit val register_metrics : (module METRICS) -> unit (** Looks for a mempool filter plug-in for a specific protocol. *) -val find_filter : Protocol_hash.t -> (module FILTER) option +val find_filter : Tezos_crypto.Protocol_hash.t -> (module FILTER) option (** Looks for an rpc plug-in for a specific protocol. *) -val find_rpc : Protocol_hash.t -> (module RPC) option +val find_rpc : Tezos_crypto.Protocol_hash.t -> (module RPC) option (** Looks for a metrics plugin module for a specific protocol *) -val find_metrics : Protocol_hash.t -> (module METRICS) option +val find_metrics : Tezos_crypto.Protocol_hash.t -> (module METRICS) option (** Same as [find_metrics] but returns [Undefined_metrics_plugin] if not found *) -val safe_find_metrics : Protocol_hash.t -> (module METRICS) Lwt.t +val safe_find_metrics : Tezos_crypto.Protocol_hash.t -> (module METRICS) Lwt.t diff --git a/src/lib_shell/test/generators.ml b/src/lib_shell/test/generators.ml index 6548f1dddab8..31204b79b23e 100644 --- a/src/lib_shell/test/generators.ml +++ b/src/lib_shell/test/generators.ml @@ -50,12 +50,12 @@ let operation_mock_proto_gen = let* len_gen = frequencya [|(9, return 0); (1, 0 -- 31)|] in string_size ?gen:None len_gen -let block_hash_gen : Block_hash.t QCheck2.Gen.t = +let block_hash_gen : Tezos_crypto.Block_hash.t QCheck2.Gen.t = let open QCheck2.Gen in let string_gen = QCheck2.Gen.small_string ?gen:None in let+ key = opt (string_size (0 -- 64)) and+ path = list_size (0 -- 10) string_gen in - Block_hash.hash_string ?key path + Tezos_crypto.Block_hash.hash_string ?key path (** A generator of operations. - [proto_gen] is the generator for protocol bytes. By default, it is @@ -78,7 +78,7 @@ let operation_gen ?(proto_gen = operation_proto_gen) ?block_hash_t () : (** Like {!operation_gen} with a hash. *) let raw_operation_with_hash_gen ?proto_gen ?block_hash_t () : - (Operation_hash.t * Operation.t) QCheck2.Gen.t = + (Tezos_crypto.Operation_hash.t * Operation.t) QCheck2.Gen.t = let open QCheck2.Gen in let+ op = operation_gen ?proto_gen ?block_hash_t () in let hash = Operation.hash op in @@ -133,12 +133,12 @@ let operation_with_hash_and_priority_gen ?proto_gen ?block_hash_t () : return (op, priority) let raw_op_map_gen ?proto_gen ?block_hash_t () : - Operation.t Operation_hash.Map.t QCheck2.Gen.t = + Operation.t Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t = let open QCheck2.Gen in let+ ops = small_list (raw_operation_with_hash_gen ?proto_gen ?block_hash_t ()) in - List.to_seq ops |> Operation_hash.Map.of_seq + List.to_seq ops |> Tezos_crypto.Operation_hash.Map.of_seq (** A generator of maps of operations and their hashes. Parameters are: - [?proto_gen] is an optional generator for the protocol bytes. @@ -148,12 +148,13 @@ let raw_op_map_gen ?proto_gen ?block_hash_t () : this generator guarantees that all returned operations are distinct (because their hashes differ). *) let op_map_gen ?proto_gen ?block_hash_t () : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let open QCheck2.Gen in let+ ops = small_list (operation_with_hash_gen ?proto_gen ?block_hash_t ()) in List.to_seq ops |> Seq.map (fun op -> (op.Prevalidation.hash, op)) - |> Operation_hash.Map.of_seq + |> Tezos_crypto.Operation_hash.Map.of_seq (** A generator like {!raw_op_map_gen} but which guarantees the size of the returned maps: they are exactly of size [n]. We need @@ -161,23 +162,23 @@ let op_map_gen ?proto_gen ?block_hash_t () : of fixed lengths) because we *need* to return maps, because we need the properties that all operations hashes are different. *) let raw_op_map_gen_n ?proto_gen ?block_hash_t (n : int) : - Operation.t Operation_hash.Map.t QCheck2.Gen.t = + Operation.t Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t = let open QCheck2.Gen in let map_take_n n m = - Operation_hash.Map.bindings m - |> List.take_n n |> List.to_seq |> Operation_hash.Map.of_seq + Tezos_crypto.Operation_hash.Map.bindings m + |> List.take_n n |> List.to_seq |> Tezos_crypto.Operation_hash.Map.of_seq in let merge _oph old _new = Some old in - let rec go (ops : Operation.t Operation_hash.Map.t) = - if Operation_hash.Map.cardinal ops >= n then + let rec go (ops : Operation.t Tezos_crypto.Operation_hash.Map.t) = + if Tezos_crypto.Operation_hash.Map.cardinal ops >= n then (* Done *) return (map_take_n n ops) else (* Not enough operations yet, generate more *) let* new_ops = raw_op_map_gen ?proto_gen ?block_hash_t () in - go (Operation_hash.Map.union merge ops new_ops) + go (Tezos_crypto.Operation_hash.Map.union merge ops new_ops) in - go Operation_hash.Map.empty + go Tezos_crypto.Operation_hash.Map.empty (** A generator like {!op_map_gen} but which guarantees the size of the returned maps: they are exactly of size [n]. We need @@ -185,23 +186,25 @@ let raw_op_map_gen_n ?proto_gen ?block_hash_t (n : int) : of fixed lengths) because we *need* to return maps, because we need the properties that all operations hashes are different. *) let op_map_gen_n ?proto_gen ?block_hash_t (n : int) : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let open QCheck2.Gen in let map_take_n n m = - Operation_hash.Map.bindings m - |> List.take_n n |> List.to_seq |> Operation_hash.Map.of_seq + Tezos_crypto.Operation_hash.Map.bindings m + |> List.take_n n |> List.to_seq |> Tezos_crypto.Operation_hash.Map.of_seq in let merge _oph old _new = Some old in - let rec go (ops : unit Prevalidation.operation Operation_hash.Map.t) = - if Operation_hash.Map.cardinal ops >= n then + let rec go + (ops : unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t) = + if Tezos_crypto.Operation_hash.Map.cardinal ops >= n then (* Done *) return (map_take_n n ops) else (* Not enough operations yet, generate more *) let* new_ops = op_map_gen ?proto_gen ?block_hash_t () in - go (Operation_hash.Map.union merge ops new_ops) + go (Tezos_crypto.Operation_hash.Map.union merge ops new_ops) in - go Operation_hash.Map.empty + go Tezos_crypto.Operation_hash.Map.empty (** Do we need richer errors? If so, how to generate those? *) let classification_gen : classification QCheck2.Gen.t = @@ -250,10 +253,13 @@ let with_t_operation_gen : unit t -> unit Prevalidation.operation QCheck2.Gen.t let open QCheck2 in fun t -> let to_ops map = - Operation_hash.Map.bindings map |> List.map (fun (_oph, (op, _)) -> op) + Tezos_crypto.Operation_hash.Map.bindings map + |> List.map (fun (_oph, (op, _)) -> op) in (* If map is empty, it cannot be used as a generator *) - let freq_of_map map = if Operation_hash.Map.is_empty map then 0 else 1 in + let freq_of_map map = + if Tezos_crypto.Operation_hash.Map.is_empty map then 0 else 1 + in (* If list is empty, it cannot be used as a generator *) let freq_of_list = function [] -> 0 | _ -> 1 in (* If map is not empty, take one of its elements *) diff --git a/src/lib_shell/test/generators_tree.ml b/src/lib_shell/test/generators_tree.ml index 6476d731bbf9..11a77b1e37ea 100644 --- a/src/lib_shell/test/generators_tree.ml +++ b/src/lib_shell/test/generators_tree.ml @@ -208,7 +208,7 @@ module Block = struct (** The block-like interface that suffices to test [Prevalidator.Internal_for_tests.handle_live_operations] *) type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; operations : unit Prevalidation.operation list list; } @@ -216,9 +216,11 @@ module Block = struct that for any pair of generated blocks [(b1, b2)], [b1.hash <> b2.hash] implies [b1 <> b2] where [<>] is polymorphic inequality. Said differently, hashes should not be faked. *) - let equal : t -> t -> bool = fun t1 t2 -> Block_hash.equal t1.hash t2.hash + let equal : t -> t -> bool = + fun t1 t2 -> Tezos_crypto.Block_hash.equal t1.hash t2.hash - let compare (t1 : t) (t2 : t) = Block_hash.compare t1.hash t2.hash + let compare (t1 : t) (t2 : t) = + Tezos_crypto.Block_hash.compare t1.hash t2.hash (** [hash_of_blocks ops] is used to compute the hash of a block whose [operations] field contains [ops]. @@ -230,15 +232,15 @@ module Block = struct is why we hash the hashes of operations. *) let hash_of_block ops = let hash = - Operation_list_hash.compute + Tezos_crypto.Operation_list_hash.compute (List.map (fun op -> op.Prevalidation.hash) @@ List.concat ops) in (* We forge a fake [block_header] hash by first hashing the operations and change the [b58] signature into a signature that looks like the one of a block header by prefixing it with the letter [B]. *) - let hash_string = Operation_list_hash.to_b58check hash in + let hash_string = Tezos_crypto.Operation_list_hash.to_b58check hash in let suffix = String.sub hash_string 2 31 in - match Block_hash.of_string @@ "B" ^ suffix with + match Tezos_crypto.Block_hash.of_string @@ "B" ^ suffix with | Error err -> Format.printf "Unexpected error: %a" Error_monad.pp_print_trace err ; assert false @@ -261,7 +263,7 @@ module Block = struct String.concat "|" (List.map - Operation_hash.to_short_b58check + Tezos_crypto.Operation_hash.to_short_b58check (List.map (fun op -> op.Prevalidation.hash) ops)) in let ops_string = @@ -270,7 +272,7 @@ module Block = struct "" t.operations in - Format.asprintf "%a:[%s]" Block_hash.pp t.hash ops_string + Format.asprintf "%a:[%s]" Tezos_crypto.Block_hash.pp t.hash ops_string (* [pp_list] is unused but useful when debugging, renaming it to [_pp_list] to keep it around *) @@ -398,7 +400,8 @@ let tree_gen ?blocks () = (** A generator for passing the last argument of [Prevalidator.handle_live_operations] *) let old_mempool_gen (tree : Block.t Tree.tree) : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let blocks = Tree.values tree in let pairs = List.concat_map Block.tools.operations blocks |> List.concat in let elements = @@ -408,14 +411,14 @@ let old_mempool_gen (tree : Block.t Tree.tree) : Prevalidation.Internal_for_tests.make_operation op hash ()) pairs in - if elements = [] then QCheck2.Gen.return Operation_hash.Map.empty + if elements = [] then QCheck2.Gen.return Tezos_crypto.Operation_hash.Map.empty else let list_gen = QCheck2.Gen.(oneofl elements |> list) in QCheck2.Gen.map (fun l -> List.to_seq l |> Seq.map (fun op -> (op.Prevalidation.hash, op)) - |> Operation_hash.Map.of_seq) + |> Tezos_crypto.Operation_hash.Map.of_seq) list_gen (** Function to implement @@ -497,7 +500,7 @@ let classification_chain_tools (tree : Block.t Tree.tree) : let tree_gen ?blocks () : (Block.t Tree.tree * (Block.t * Block.t) option - * unit Prevalidation.operation Operation_hash.Map.t) + * unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t) QCheck2.Gen.t = let open QCheck2.Gen in let* tree = tree_gen ?blocks () in diff --git a/src/lib_shell/test/legacy_generators.ml b/src/lib_shell/test/legacy_generators.ml index c9ef6fe56698..94a6c9728772 100644 --- a/src/lib_shell/test/legacy_generators.ml +++ b/src/lib_shell/test/legacy_generators.ml @@ -53,12 +53,12 @@ let operation_mock_proto_gen = let* len_gen = frequencya [|(9, return 0); (1, 0 -- 31)|] in string_size ?gen:None len_gen -let block_hash_gen : Block_hash.t QCheck2.Gen.t = +let block_hash_gen : Tezos_crypto.Block_hash.t QCheck2.Gen.t = let open QCheck2.Gen in let string_gen = QCheck2.Gen.small_string ?gen:None in let+ key = opt (string_size (0 -- 64)) and+ path = list_size (0 -- 10) string_gen in - Block_hash.hash_string ?key path + Tezos_crypto.Block_hash.hash_string ?key path (** A generator of operations. - [proto_gen] is the generator for protocol bytes. By default, it is @@ -82,7 +82,7 @@ let operation_gen ?(proto_gen = operation_proto_gen) ?block_hash_t () : (** Like {!operation_gen} with a hash. *) let raw_operation_with_hash_gen ?proto_gen ?block_hash_t () : - (Operation_hash.t * Operation.t) QCheck2.Gen.t = + (Tezos_crypto.Operation_hash.t * Operation.t) QCheck2.Gen.t = let open QCheck2.Gen in let+ op = operation_gen ?proto_gen ?block_hash_t () in let hash = Operation.hash op in @@ -136,12 +136,12 @@ let operation_with_hash_and_priority_gen ?proto_gen ?block_hash_t () : return (op, priority) let raw_op_map_gen ?proto_gen ?block_hash_t () : - Operation.t Operation_hash.Map.t QCheck2.Gen.t = + Operation.t Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t = let open QCheck2.Gen in let+ ops = small_list (raw_operation_with_hash_gen ?proto_gen ?block_hash_t ()) in - List.to_seq ops |> Operation_hash.Map.of_seq + List.to_seq ops |> Tezos_crypto.Operation_hash.Map.of_seq (** A generator of maps of operations and their hashes. Parameters are: - [?proto_gen] is an optional generator for the protocol bytes. @@ -151,12 +151,13 @@ let raw_op_map_gen ?proto_gen ?block_hash_t () : this generator guarantees that all returned operations are distinct (because their hashes differ). *) let op_map_gen ?proto_gen ?block_hash_t () : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let open QCheck2.Gen in let+ ops = small_list (operation_with_hash_gen ?proto_gen ?block_hash_t ()) in List.to_seq ops |> Seq.map (fun op -> (op.Prevalidation.hash, op)) - |> Operation_hash.Map.of_seq + |> Tezos_crypto.Operation_hash.Map.of_seq (** A generator like {!raw_op_map_gen} but which guarantees the size of the returned maps: they are exactly of size [n]. We need @@ -164,23 +165,23 @@ let op_map_gen ?proto_gen ?block_hash_t () : of fixed lengths) because we *need* to return maps, because we need the properties that all operations hashes are different. *) let raw_op_map_gen_n ?proto_gen ?block_hash_t (n : int) : - Operation.t Operation_hash.Map.t QCheck2.Gen.t = + Operation.t Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t = let open QCheck2.Gen in let map_take_n n m = - Operation_hash.Map.bindings m - |> List.take_n n |> List.to_seq |> Operation_hash.Map.of_seq + Tezos_crypto.Operation_hash.Map.bindings m + |> List.take_n n |> List.to_seq |> Tezos_crypto.Operation_hash.Map.of_seq in let merge _oph old _new = Some old in - let rec go (ops : Operation.t Operation_hash.Map.t) = - if Operation_hash.Map.cardinal ops >= n then + let rec go (ops : Operation.t Tezos_crypto.Operation_hash.Map.t) = + if Tezos_crypto.Operation_hash.Map.cardinal ops >= n then (* Done *) return (map_take_n n ops) else (* Not enough operations yet, generate more *) let* new_ops = raw_op_map_gen ?proto_gen ?block_hash_t () in - go (Operation_hash.Map.union merge ops new_ops) + go (Tezos_crypto.Operation_hash.Map.union merge ops new_ops) in - go Operation_hash.Map.empty + go Tezos_crypto.Operation_hash.Map.empty (** A generator like {!op_map_gen} but which guarantees the size of the returned maps: they are exactly of size [n]. We need @@ -188,23 +189,25 @@ let raw_op_map_gen_n ?proto_gen ?block_hash_t (n : int) : of fixed lengths) because we *need* to return maps, because we need the properties that all operations hashes are different. *) let op_map_gen_n ?proto_gen ?block_hash_t (n : int) : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let open QCheck2.Gen in let map_take_n n m = - Operation_hash.Map.bindings m - |> List.take_n n |> List.to_seq |> Operation_hash.Map.of_seq + Tezos_crypto.Operation_hash.Map.bindings m + |> List.take_n n |> List.to_seq |> Tezos_crypto.Operation_hash.Map.of_seq in let merge _oph old _new = Some old in - let rec go (ops : unit Prevalidation.operation Operation_hash.Map.t) = - if Operation_hash.Map.cardinal ops >= n then + let rec go + (ops : unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t) = + if Tezos_crypto.Operation_hash.Map.cardinal ops >= n then (* Done *) return (map_take_n n ops) else (* Not enough operations yet, generate more *) let* new_ops = op_map_gen ?proto_gen ?block_hash_t () in - go (Operation_hash.Map.union merge ops new_ops) + go (Tezos_crypto.Operation_hash.Map.union merge ops new_ops) in - go Operation_hash.Map.empty + go Tezos_crypto.Operation_hash.Map.empty (** Do we need richer errors? If so, how to generate those? *) let classification_gen : classification QCheck2.Gen.t = @@ -252,10 +255,13 @@ let with_t_operation_gen : unit t -> unit Prevalidation.operation QCheck2.Gen.t let open QCheck2 in fun t -> let to_ops map = - Operation_hash.Map.bindings map |> List.map (fun (_oph, (op, _)) -> op) + Tezos_crypto.Operation_hash.Map.bindings map + |> List.map (fun (_oph, (op, _)) -> op) in (* If map is empty, it cannot be used as a generator *) - let freq_of_map map = if Operation_hash.Map.is_empty map then 0 else 1 in + let freq_of_map map = + if Tezos_crypto.Operation_hash.Map.is_empty map then 0 else 1 + in (* If list is empty, it cannot be used as a generator *) let freq_of_list = function [] -> 0 | _ -> 1 in (* If map is not empty, take one of its elements *) diff --git a/src/lib_shell/test/legacy_generators_tree.ml b/src/lib_shell/test/legacy_generators_tree.ml index b2e9993d21be..3073ad0abb67 100644 --- a/src/lib_shell/test/legacy_generators_tree.ml +++ b/src/lib_shell/test/legacy_generators_tree.ml @@ -210,7 +210,7 @@ module Block = struct (** The block-like interface that suffices to test [Prevalidator.Internal_for_tests.handle_live_operations] *) type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; operations : unit Prevalidation.operation list list; } @@ -218,9 +218,11 @@ module Block = struct that for any pair of generated blocks [(b1, b2)], [b1.hash <> b2.hash] implies [b1 <> b2] where [<>] is polymorphic inequality. Said differently, hashes should not be faked. *) - let equal : t -> t -> bool = fun t1 t2 -> Block_hash.equal t1.hash t2.hash + let equal : t -> t -> bool = + fun t1 t2 -> Tezos_crypto.Block_hash.equal t1.hash t2.hash - let compare (t1 : t) (t2 : t) = Block_hash.compare t1.hash t2.hash + let compare (t1 : t) (t2 : t) = + Tezos_crypto.Block_hash.compare t1.hash t2.hash (** [hash_of_blocks ops] is used to compute the hash of a block whose [operations] field contains [ops]. @@ -232,15 +234,15 @@ module Block = struct is why we hash the hashes of operations. *) let hash_of_block ops = let hash = - Operation_list_hash.compute + Tezos_crypto.Operation_list_hash.compute (List.map (fun op -> op.Prevalidation.hash) @@ List.concat ops) in (* We forge a fake [block_header] hash by first hashing the operations and change the [b58] signature into a signature that looks like the one of a block header by prefixing it with the letter [B]. *) - let hash_string = Operation_list_hash.to_b58check hash in + let hash_string = Tezos_crypto.Operation_list_hash.to_b58check hash in let suffix = String.sub hash_string 2 31 in - match Block_hash.of_string @@ "B" ^ suffix with + match Tezos_crypto.Block_hash.of_string @@ "B" ^ suffix with | Error err -> Format.printf "Unexpected error: %a" Error_monad.pp_print_trace err ; assert false @@ -263,7 +265,7 @@ module Block = struct String.concat "|" (List.map - Operation_hash.to_short_b58check + Tezos_crypto.Operation_hash.to_short_b58check (List.map (fun op -> op.Prevalidation.hash) ops)) in let ops_string = @@ -272,7 +274,7 @@ module Block = struct "" t.operations in - Format.asprintf "%a:[%s]" Block_hash.pp t.hash ops_string + Format.asprintf "%a:[%s]" Tezos_crypto.Block_hash.pp t.hash ops_string (* [pp_list] is unused but useful when debugging, renaming it to [_pp_list] to keep it around *) @@ -400,7 +402,8 @@ let tree_gen ?blocks () = (** A generator for passing the last argument of [Prevalidator.handle_live_operations] *) let old_mempool_gen (tree : Block.t Tree.tree) : - unit Prevalidation.operation Operation_hash.Map.t QCheck2.Gen.t = + unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t QCheck2.Gen.t + = let blocks = Tree.values tree in let pairs = List.concat_map Block.tools.operations blocks |> List.concat in let elements = @@ -410,14 +413,14 @@ let old_mempool_gen (tree : Block.t Tree.tree) : Prevalidation.Internal_for_tests.make_operation op hash ()) pairs in - if elements = [] then QCheck2.Gen.return Operation_hash.Map.empty + if elements = [] then QCheck2.Gen.return Tezos_crypto.Operation_hash.Map.empty else let list_gen = QCheck2.Gen.(oneofl elements |> list) in QCheck2.Gen.map (fun l -> List.to_seq l |> Seq.map (fun op -> (op.Prevalidation.hash, op)) - |> Operation_hash.Map.of_seq) + |> Tezos_crypto.Operation_hash.Map.of_seq) list_gen (** Function to implement @@ -499,7 +502,7 @@ let classification_chain_tools (tree : Block.t Tree.tree) : let tree_gen ?blocks () : (Block.t Tree.tree * (Block.t * Block.t) option - * unit Prevalidation.operation Operation_hash.Map.t) + * unit Prevalidation.operation Tezos_crypto.Operation_hash.Map.t) QCheck2.Gen.t = let open QCheck2.Gen in let* tree = tree_gen ?blocks () in diff --git a/src/lib_shell/test/legacy_test_prevalidation.ml b/src/lib_shell/test/legacy_test_prevalidation.ml index e21e1315f80e..1b80851d16fc 100644 --- a/src/lib_shell/test/legacy_test_prevalidation.ml +++ b/src/lib_shell/test/legacy_test_prevalidation.ml @@ -68,21 +68,22 @@ module Classification = Legacy_prevalidator_classification module Parameters : Requester_impl.PARAMETERS - with type key = Operation_hash.t + with type key = Tezos_crypto.Operation_hash.t and type value = int = struct - type key = Operation_hash.t + type key = Tezos_crypto.Operation_hash.t type value = int end -module Hash : Requester.HASH with type t = Operation_hash.t = struct +module Hash : Requester.HASH with type t = Tezos_crypto.Operation_hash.t = +struct type t = Parameters.key let name = "test_with_key_Operation_hash_dot_t" - let encoding = Operation_hash.encoding + let encoding = Tezos_crypto.Operation_hash.encoding - let pp = Operation_hash.pp + let pp = Tezos_crypto.Operation_hash.pp end module Test_request = Requester_impl.Simple_request (Parameters) @@ -108,7 +109,7 @@ let mk_operation n : Operation.t = let base_prefix = String.sub base 0 (base_len - n_string_len) in let hash_string = base_prefix ^ n_string in assert (String.length hash_string = base_len) ; - let branch = Block_hash.of_string_exn hash_string in + let branch = Tezos_crypto.Block_hash.of_string_exn hash_string in let proto = Bytes.of_string n_string in {shell = {branch}; proto} @@ -175,7 +176,9 @@ let test_in_mempool_leak f (nb_ops : int) (_ : unit) = f [] op classes in List.iter handle (1 -- nb_ops) ; - let actual_in_mempool_size = Operation_hash.Map.cardinal classes.in_mempool in + let actual_in_mempool_size = + Tezos_crypto.Operation_hash.Map.cardinal classes.in_mempool + in Alcotest.( check bool @@ -206,7 +209,7 @@ let test_db_do_not_clear_right_away f (nb_ops : int) (_ : unit) = let op = mk_operation i in let oph = Operation.hash op in let op = Prevalidation.Internal_for_tests.make_operation op oph () in - Format.printf "Injecting op: %a\n" Operation_hash.pp oph ; + Format.printf "Injecting op: %a\n" Tezos_crypto.Operation_hash.pp oph ; let injected = Lwt_main.run @@ Test_Requester.inject requester oph i in assert injected ; f [] op classes ; @@ -215,7 +218,7 @@ let test_db_do_not_clear_right_away f (nb_ops : int) (_ : unit) = bool (Format.asprintf "requester memory contains most recent classified operation (%a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) (Option.is_some @@ Lwt_main.run @@ Test_Requester.read_opt requester oph) true) diff --git a/src/lib_shell/test/legacy_test_prevalidation_t.ml b/src/lib_shell/test/legacy_test_prevalidation_t.ml index 986dcf9300de..f0e6b16237c3 100644 --- a/src/lib_shell/test/legacy_test_prevalidation_t.ml +++ b/src/lib_shell/test/legacy_test_prevalidation_t.ml @@ -67,10 +67,10 @@ module Internal_for_tests = Prevalidation.Internal_for_tests module Init = struct let genesis_protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" - let chain_id = Chain_id.zero + let chain_id = Tezos_crypto.Chain_id.zero let genesis_time = Time.Protocol.of_seconds 0L @@ -97,8 +97,11 @@ module Init = struct let v = Tezos_shell_context.Shell_context.wrap_disk_context v in f v) - let genesis_block (context_hash : Context_hash.t) : Store.Block.t = - let block_hash : Block_hash.t = Block_hash.hash_string ["genesis"] in + let genesis_block (context_hash : Tezos_crypto.Context_hash.t) : Store.Block.t + = + let block_hash : Tezos_crypto.Block_hash.t = + Tezos_crypto.Block_hash.hash_string ["genesis"] + in let genesis : Genesis.t = {time = genesis_time; block = block_hash; protocol = genesis_protocol} in @@ -139,7 +142,7 @@ let chain_store = () (** Test that [create] returns [Ok] in a pristine context. *) let test_create ctxt = let open Lwt_result_syntax in - let live_operations = Operation_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let timestamp : Time.Protocol.t = now () in let (module Prevalidation) = create_prevalidation (module Mock_protocol) ctxt @@ -171,10 +174,10 @@ let prevalidation_operations_gen (type a) empty string, otherwise the call to [P.parse] will fail with the bytes being too long (hereby looking like an attack). *) let proto_gen : string QCheck2.Gen.t = QCheck2.Gen.return "" in - let+ (ops : Operation.t Operation_hash.Map.t) = + let+ (ops : Operation.t Tezos_crypto.Operation_hash.Map.t) = Generators.raw_op_map_gen_n ~proto_gen ?block_hash_t:None n in - List.map mk_operation (Operation_hash.Map.bindings ops) + List.map mk_operation (Tezos_crypto.Operation_hash.Map.bindings ops) (** The number of operations used by tests that follow *) let nb_ops = 100 @@ -192,7 +195,7 @@ let mk_ops (type a) when the protocol's [apply_operation] crashes. *) let test_apply_operation_crash ctxt = let open Lwt_result_syntax in - let live_operations = Operation_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let timestamp : Time.Protocol.t = now () in let (module P) = create_prevalidation (module Mock_protocol) ctxt in let ops : P.protocol_operation Prevalidation.operation list = @@ -233,11 +236,11 @@ let mk_live_operations (type a) rand (ops : a Prevalidation.operation list) = List.fold_left (fun acc (op : _ Prevalidation.operation) -> if Random.State.bool rand then - Operation_hash.Set.add + Tezos_crypto.Operation_hash.Set.add (Internal_for_tests.to_raw op |> Operation.hash) acc else acc) - Operation_hash.Set.empty + Tezos_crypto.Operation_hash.Set.empty ops (** Test that [Prevalidation.apply_operations] returns [Outdated] @@ -264,13 +267,15 @@ let test_apply_operation_live_operations ctxt = let ops : P.protocol_operation Prevalidation.operation list = mk_ops (module P) in - let live_operations : Operation_hash.Set.t = mk_live_operations rand ops in + let live_operations : Tezos_crypto.Operation_hash.Set.t = + mk_live_operations rand ops + in let predecessor : Store.Block.t = Init.genesis_block @@ Context_ops.hash ~time:timestamp ctxt in let* pv = P.create chain_store ~predecessor ~live_operations ~timestamp () in let op_in_live_operations op = - Operation_hash.Set.mem + Tezos_crypto.Operation_hash.Set.mem (Internal_for_tests.to_raw op |> Operation.hash) live_operations in @@ -313,7 +318,9 @@ let test_apply_operation_applied ctxt = let ops : P.protocol_operation Prevalidation.operation list = mk_ops (module P) in - let live_operations : Operation_hash.Set.t = mk_live_operations rand ops in + let live_operations : Tezos_crypto.Operation_hash.Set.t = + mk_live_operations rand ops + in let predecessor : Store.Block.t = Init.genesis_block @@ Context_ops.hash ~time:timestamp ctxt in diff --git a/src/lib_shell/test/legacy_test_prevalidator_classification.ml b/src/lib_shell/test/legacy_test_prevalidator_classification.ml index 711abb39a530..708c0f58dedd 100644 --- a/src/lib_shell/test/legacy_test_prevalidator_classification.ml +++ b/src/lib_shell/test/legacy_test_prevalidator_classification.ml @@ -57,11 +57,11 @@ module Operation_map = struct Format.fprintf ppf "(%a: (%a, ))" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Operation.pp op.Prevalidation.raw)) - (Operation_hash.Map.bindings map) + (Tezos_crypto.Operation_hash.Map.bindings map) let pp ppf map = Format.fprintf @@ -71,22 +71,23 @@ module Operation_map = struct Format.fprintf ppf "(%a: %a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Operation.pp op.Prevalidation.raw)) - (Operation_hash.Map.bindings map) + (Tezos_crypto.Operation_hash.Map.bindings map) (* Uses polymorphic equality on tztraces! *) let eq = - Operation_hash.Map.equal (fun (o1, t1) (o2, t2) -> - Operation_hash.equal o1.Prevalidation.hash o2.hash && t1 = t2) + Tezos_crypto.Operation_hash.Map.equal (fun (o1, t1) (o2, t2) -> + Tezos_crypto.Operation_hash.equal o1.Prevalidation.hash o2.hash + && t1 = t2) end type classification_event = | Add_if_not_present of Classification.classification * unit Prevalidation.operation - | Remove of Operation_hash.t + | Remove of Tezos_crypto.Operation_hash.t | Flush of bool let drop oph t = @@ -169,7 +170,8 @@ let qcheck_eq_false ~actual = let qcheck_bounded_map_is_empty bounded_map = let actual = - bounded_map |> Classification.map |> Operation_hash.Map.is_empty + bounded_map |> Classification.map + |> Tezos_crypto.Operation_hash.Map.is_empty in qcheck_eq_true ~actual @@ -178,21 +180,21 @@ let qcheck_bounded_map_is_empty bounded_map = that these fields are disjoint. *) let disjoint_union_classified_fields ?fail_msg (t : unit Classification.t) = let ( +> ) acc next_set = - if not (Operation_hash.Set.disjoint acc next_set) then + if not (Tezos_crypto.Operation_hash.Set.disjoint acc next_set) then QCheck2.Test.fail_reportf "Invariant 'The fields: [refused; outdated; branch_refused; \ branch_delayed; applied] are disjoint' broken by t =@.%a@.%s" Classification.Internal_for_tests.pp t (match fail_msg with None -> "" | Some msg -> "\n" ^ msg ^ "@.") ; - Operation_hash.Set.union acc next_set + Tezos_crypto.Operation_hash.Set.union acc next_set in let to_set = Classification.Internal_for_tests.set_of_bounded_map in to_set t.refused +> to_set t.outdated +> to_set t.branch_refused +> to_set t.branch_delayed +> (Classification.Sized_map.to_seq t.prechecked - |> Seq.map fst |> Operation_hash.Set.of_seq) - +> (Operation_hash.Set.of_list + |> Seq.map fst |> Tezos_crypto.Operation_hash.Set.of_seq) + +> (Tezos_crypto.Operation_hash.Set.of_list @@ List.rev_map (fun op -> op.Prevalidation.hash) t.applied_rev) (** Checks both invariants of type [Legacy_prevalidator_classification.t]: @@ -210,17 +212,28 @@ let disjoint_union_classified_fields ?fail_msg (t : unit Classification.t) = of breaking this using [Tezt]. *) let check_invariants ?fail_msg (t : unit Classification.t) = let to_set map = - Operation_hash.Map.to_seq map |> Seq.map fst |> Operation_hash.Set.of_seq + Tezos_crypto.Operation_hash.Map.to_seq map + |> Seq.map fst |> Tezos_crypto.Operation_hash.Set.of_seq in let expected_in_mempool = disjoint_union_classified_fields ?fail_msg t in let mempool_as_set = to_set t.in_mempool in - if not (Operation_hash.Set.equal expected_in_mempool mempool_as_set) then + if + not + (Tezos_crypto.Operation_hash.Set.equal expected_in_mempool mempool_as_set) + then let set_pp ppf set = - set |> Operation_hash.Set.elements - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + set |> Tezos_crypto.Operation_hash.Set.elements + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) + in + let set1 = + Tezos_crypto.Operation_hash.Set.diff expected_in_mempool mempool_as_set + in + let set2 = + Tezos_crypto.Operation_hash.Set.diff mempool_as_set expected_in_mempool in - let set1 = Operation_hash.Set.diff expected_in_mempool mempool_as_set in - let set2 = Operation_hash.Set.diff mempool_as_set expected_in_mempool in let sets_report = Format.asprintf "In individual fields but not in [in_mempool]:\n\ @@ -263,9 +276,10 @@ let event_pp pp = function "Add_if_not_present %a %a" classification_pp classification - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash - | Remove oph -> Format.fprintf pp "Remove %a" Operation_hash.pp oph + | Remove oph -> + Format.fprintf pp "Remove %a" Tezos_crypto.Operation_hash.pp oph | Flush handle_branch_refused -> Format.fprintf pp "Flush ~handle_branch_refused:%b" handle_branch_refused @@ -441,7 +455,7 @@ module Bounded = struct let binding_pp ppf bindings = bindings |> List.map (fun value -> value.Prevalidation.hash) - |> Format.pp_print_list Operation_hash.pp ppf + |> Format.pp_print_list Tezos_crypto.Operation_hash.pp ppf in Format.asprintf "Legacy_prevalidator_classification.t:@.%a@.Classification:@.%s@.First \ @@ -454,7 +468,8 @@ module Bounded = struct binding_pp other_bindings - let custom_gen (discarded_operations_rev : Operation_hash.t list ref) : + let custom_gen + (discarded_operations_rev : Tezos_crypto.Operation_hash.t list ref) : custom QCheck2.Gen.t = let open QCheck2.Gen in let* map_size_limit = 1 -- 20 in @@ -491,10 +506,13 @@ module Bounded = struct not (List.for_all (fun excess_hash -> - List.mem ~equal:Operation_hash.equal excess_hash discarded_hashes) + List.mem + ~equal:Tezos_crypto.Operation_hash.equal + excess_hash + discarded_hashes) excess_hashes) then - let hashes_pp = Format.pp_print_list Operation_hash.pp in + let hashes_pp = Format.pp_print_list Tezos_crypto.Operation_hash.pp in QCheck2.Test.fail_reportf "Expected all excess hashes to have been discarded but it was \ not.@.Excess hashes:@.%a@.Discarded hashes:@.%a" @@ -506,7 +524,8 @@ module Bounded = struct let check_map_is_full ~expected_size ~bounded_map = if Compare.List_length_with.( - Operation_hash.Map.bindings (Classification.map bounded_map) + Tezos_crypto.Operation_hash.Map.bindings + (Classification.map bounded_map) <> expected_size) then QCheck2.Test.fail_reportf @@ -514,7 +533,8 @@ module Bounded = struct %i.@.Bounded_map content:@.%a" expected_size (List.length - (Operation_hash.Map.bindings (Classification.map bounded_map))) + (Tezos_crypto.Operation_hash.Map.bindings + (Classification.map bounded_map))) Classification.Internal_for_tests.bounded_map_pp bounded_map @@ -532,10 +552,10 @@ module Bounded = struct let hashes = first_ops @ other_ops |> List.map (fun op -> op.Prevalidation.hash) in - let unique_hashes = Operation_hash.Set.of_list hashes in + let unique_hashes = Tezos_crypto.Operation_hash.Set.of_list hashes in QCheck2.assume Compare.List_length_with.( - hashes = Operation_hash.Set.cardinal unique_hashes) ; + hashes = Tezos_crypto.Operation_hash.Set.cardinal unique_hashes) ; (* Remove all operations for the tested classification *) let bounded_map = match error_classification with @@ -545,7 +565,7 @@ module Bounded = struct | `Outdated _ -> t.outdated in let () = - Operation_hash.Map.iter + Tezos_crypto.Operation_hash.Map.iter (fun oph _op -> drop oph t) (Classification.map bounded_map) in @@ -568,13 +588,15 @@ end module To_map = struct let map_pp fmt x = let map_to_list m = - Operation_hash.Map.to_seq m |> Seq.map (fun (_, op) -> op) |> List.of_seq + Tezos_crypto.Operation_hash.Map.to_seq m + |> Seq.map (fun (_, op) -> op) + |> List.of_seq in let pp_pair fmt op = Format.fprintf fmt "%a:%a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash Operation.pp op.raw @@ -582,7 +604,7 @@ module To_map = struct Format.fprintf fmt "%a" (Format.pp_print_list pp_pair) (map_to_list x) let map_eq = - Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> Operation.equal op1.Prevalidation.raw op2.raw) (** [remove_all m1 m2] returns the subset of [m1] thas is not within [m2]. @@ -590,11 +612,11 @@ module To_map = struct that are in [m2]. *) let remove_all m1 m2 = let keys2 = - Operation_hash.Map.bindings m2 - |> List.map fst |> Operation_hash.Set.of_list + Tezos_crypto.Operation_hash.Map.bindings m2 + |> List.map fst |> Tezos_crypto.Operation_hash.Set.of_list in - Operation_hash.Map.filter - (fun key _val -> not (Operation_hash.Set.mem key keys2)) + Tezos_crypto.Operation_hash.Map.filter + (fun key _val -> not (Tezos_crypto.Operation_hash.Set.mem key keys2)) m1 (** [eq_mod_binding m1 (k, v_opt) m2] holds iff: @@ -605,13 +627,13 @@ module To_map = struct for some unknown value [v]. *) let eq_mod_op m1 (k, v_opt) m2 = let diff = remove_all m2 m1 in - match (Operation_hash.Map.bindings diff, v_opt) with + match (Tezos_crypto.Operation_hash.Map.bindings diff, v_opt) with | [], _ -> true | [(kdiff, vdiff)], Some v - when Operation_hash.equal kdiff k + when Tezos_crypto.Operation_hash.equal kdiff k && Operation.equal v.Prevalidation.raw vdiff.Prevalidation.raw -> true - | [(kdiff, _)], None when Operation_hash.equal kdiff k -> true + | [(kdiff, _)], None when Tezos_crypto.Operation_hash.equal kdiff k -> true | _ -> false (** [to_map_all] calls [Classification.to_map] with all named @@ -637,7 +659,7 @@ module To_map = struct qcheck_eq' ~pp:map_pp ~eq:map_eq - ~expected:Operation_hash.Map.empty + ~expected:Tezos_crypto.Operation_hash.Map.empty ~actual:(to_map_all t) () @@ -683,7 +705,7 @@ module To_map = struct "Starting with:@. %a@.and operation hash %a@. " Operation_map.pp (to_map_all t) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash let test_map_remove_add = @@ -708,15 +730,17 @@ module To_map = struct let t' = Classification.Internal_for_tests.copy t in drop op.Prevalidation.hash t ; let initial = to_map_all t in - let left = Operation_hash.Map.add op.Prevalidation.hash op initial in + let left = + Tezos_crypto.Operation_hash.Map.add op.Prevalidation.hash op initial + in Classification.add classification op t' ; let right = to_map_all t' in qcheck_eq' ~expected:left ~actual:right ~eq: - (Operation_hash.Map.equal (fun op1 op2 -> - Operation_hash.equal op1.Prevalidation.hash op2.hash)) + (Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.equal op1.Prevalidation.hash op2.hash)) ~pp:map_pp () @@ -742,15 +766,17 @@ module To_map = struct Classification.add classification op t ; let initial = to_map_all t in let oph = op.Prevalidation.hash in - let left = Operation_hash.Map.remove oph initial in + let left = Tezos_crypto.Operation_hash.Map.remove oph initial in drop oph t' ; let right = to_map_all t' in qcheck_eq' ~expected:left ~actual:right ~eq: - (Operation_hash.Map.equal (fun op1 op2 -> - Operation_hash.equal op1.Prevalidation.hash op2.Prevalidation.hash)) + (Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.equal + op1.Prevalidation.hash + op2.Prevalidation.hash)) ~pp:map_pp () @@ -787,11 +813,12 @@ module To_map = struct let oph = op.Prevalidation.hash in let is_in_mempool = is_in_mempool oph t in let map = - to_map_all t |> Operation_hash.Map.filter (fun oph' _ -> oph' = oph) + to_map_all t + |> Tezos_crypto.Operation_hash.Map.filter (fun oph' _ -> oph' = oph) in qcheck_eq' ~expected:is_in_mempool - ~actual:(Operation_hash.Map.cardinal map = 1) + ~actual:(Tezos_crypto.Operation_hash.Map.cardinal map = 1) () (** Tests that [Classification.to_map] returns an empty map if all parameters @@ -805,7 +832,7 @@ module To_map = struct qcheck_eq' ~pp:map_pp ~eq:map_eq - ~expected:Operation_hash.Map.empty + ~expected:Tezos_crypto.Operation_hash.Map.empty ~actual: (Classification.Internal_for_tests.to_map ~applied:false diff --git a/src/lib_shell/test/legacy_test_prevalidator_classification_operations.ml b/src/lib_shell/test/legacy_test_prevalidator_classification_operations.ml index 02f909690eb0..ac2186eb0765 100644 --- a/src/lib_shell/test/legacy_test_prevalidator_classification_operations.ml +++ b/src/lib_shell/test/legacy_test_prevalidator_classification_operations.ml @@ -43,7 +43,7 @@ *) open Lib_test.Qcheck2_helpers -module Op_map = Operation_hash.Map +module Op_map = Tezos_crypto.Operation_hash.Map module Prevalidation = Legacy_prevalidation module Classification = Legacy_prevalidator_classification module Generators = Legacy_generators @@ -65,22 +65,22 @@ let values_from_to ~(equal : 'a -> 'a -> bool) (tree : 'a Tree.tree) |> force_opt ~loc:__LOC__ |> fun preds -> start :: preds -(** Pretty print values of type [Operation_hash.Set.t] *) +(** Pretty print values of type [Tezos_crypto.Operation_hash.Set.t] *) let op_set_pp fmt x = - let set_to_list m = Operation_hash.Set.to_seq m |> List.of_seq in + let set_to_list m = Tezos_crypto.Operation_hash.Set.to_seq m |> List.of_seq in Format.fprintf fmt "%a" - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) (set_to_list x) -(** Pretty print values of type [Operation.t Operation_hash.Map] *) +(** Pretty print values of type [Operation.t Tezos_crypto.Operation_hash.Map] *) let op_map_pp fmt x = let pp_pair fmt (hash, op) = Format.fprintf fmt "%a:%a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp hash Operation.pp op.Prevalidation.raw @@ -89,7 +89,7 @@ let op_map_pp fmt x = fmt "%a" (Format.pp_print_list pp_pair) - (Operation_hash.Map.bindings x) + (Tezos_crypto.Operation_hash.Map.bindings x) let qcheck_cond ?pp ~cond e1 e2 () = if cond e1 e2 then true @@ -111,23 +111,24 @@ let qcheck_cond ?pp ~cond e1 e2 () = pp e2 -let blocks_to_oph_set (blocks : Operation_hash.t list list list) : - Operation_hash.Set.t = - List.concat blocks |> List.concat |> Operation_hash.Set.of_list +let blocks_to_oph_set (blocks : Tezos_crypto.Operation_hash.t list list list) : + Tezos_crypto.Operation_hash.Set.t = + List.concat blocks |> List.concat |> Tezos_crypto.Operation_hash.Set.of_list (** [is_subset m1 m2] returns whether all bindings of [m1] are in [m2]. In other words, it returns whether [m2] is a superset of [m1]. *) let is_subset (m1 : unit Prevalidation.operation Op_map.t) (m2 : unit Prevalidation.operation Op_map.t) = - let rec go (m1_seq : (Operation_hash.t * unit Prevalidation.operation) Seq.t) - = + let rec go + (m1_seq : + (Tezos_crypto.Operation_hash.t * unit Prevalidation.operation) Seq.t) = match m1_seq () with | Seq.Nil -> true | Seq.Cons ((m1_key, m1_value), m1_rest) -> ( match Op_map.find m1_key m2 with | None -> (* A key in [m1] that is not in [m2] *) false | Some m2_value -> - Operation_hash.equal + Tezos_crypto.Operation_hash.equal m1_value.Prevalidation.hash m2_value.Prevalidation.hash && go m1_rest) @@ -160,7 +161,10 @@ module Handle_operations = struct List.map (fun (blk : Block.t) -> blk.hash) live_blocks in return - (tree, pair_blocks_opt, old_mempool, Block_hash.Set.of_list live_blocks) + ( tree, + pair_blocks_opt, + old_mempool, + Tezos_crypto.Block_hash.Set.of_list live_blocks ) in QCheck2.Test.make ~name:"[handle_live_operations] is a subset of alive blocks" @@ -175,7 +179,7 @@ module Handle_operations = struct (* Keep only the ones in live_blocks *) |> List.to_seq |> Seq.filter (fun (blk : Block.t) -> - Block_hash.Set.mem blk.hash live_blocks) + Tezos_crypto.Block_hash.Set.mem blk.hash live_blocks) (* Then extract (oph, op) pairs from them *) |> Seq.flat_map (fun (blk : Block.t) -> List.to_seq blk.operations) |> Seq.flat_map List.to_seq @@ -190,7 +194,7 @@ module Handle_operations = struct ~from_branch ~to_branch ~is_branch_alive:(fun blk_hash -> - Block_hash.Set.mem blk_hash live_blocks) + Tezos_crypto.Block_hash.Set.mem blk_hash live_blocks) ~parse old_mempool |> Lwt_main.run @@ -227,7 +231,9 @@ module Handle_operations = struct (* Expected operations are the ones from [ancestor] to [from_branch], minus the ones from ancestor to [to_branch]. *) let expected = - Operation_hash.Set.diff expected_superset from_ancestor_to_to_branch + Tezos_crypto.Operation_hash.Set.diff + expected_superset + from_ancestor_to_to_branch in let actual = Classification.Internal_for_tests.handle_live_operations @@ -238,11 +244,16 @@ module Handle_operations = struct ~to_branch ~is_branch_alive:(Fun.const true) ~parse - Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.empty |> Lwt_main.run |> Op_map.bindings |> List.map fst - |> Operation_hash.Set.of_list + |> Tezos_crypto.Operation_hash.Set.of_list in - qcheck_eq' ~pp:op_set_pp ~eq:Operation_hash.Set.equal ~expected ~actual () + qcheck_eq' + ~pp:op_set_pp + ~eq:Tezos_crypto.Operation_hash.Set.equal + ~expected + ~actual + () (** Test that operations cleared by [handle_live_operations] are operations on the path from [ancestor] to [to_branch] (when all @@ -255,8 +266,10 @@ module Handle_operations = struct QCheck2.assume @@ Option.is_some pair_blocks_opt ; let from_branch, to_branch = force_opt ~loc:__LOC__ pair_blocks_opt in let chain = Generators_tree.classification_chain_tools tree in - let cleared = ref Operation_hash.Set.empty in - let clearer oph = cleared := Operation_hash.Set.add oph !cleared in + let cleared = ref Tezos_crypto.Operation_hash.Set.empty in + let clearer oph = + cleared := Tezos_crypto.Operation_hash.Set.add oph !cleared + in let chain = {chain with clear_or_cancel = clearer} in let equal = Block.equal in let ancestor : Block.t = @@ -281,7 +294,7 @@ module Handle_operations = struct |> Lwt_main.run |> ignore ; qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset !cleared expected_superset () @@ -296,9 +309,9 @@ module Handle_operations = struct QCheck2.assume @@ Option.is_some pair_blocks_opt ; let from_branch, to_branch = force_opt ~loc:__LOC__ pair_blocks_opt in let chain = Generators_tree.classification_chain_tools tree in - let injected = ref Operation_hash.Set.empty in + let injected = ref Tezos_crypto.Operation_hash.Set.empty in let inject_operation oph _op = - injected := Operation_hash.Set.add oph !injected ; + injected := Tezos_crypto.Operation_hash.Set.add oph !injected ; Lwt.return_unit in let chain = {chain with inject_operation} in @@ -325,7 +338,7 @@ module Handle_operations = struct |> Lwt_main.run |> ignore ; qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset !injected expected_superset () @@ -344,7 +357,7 @@ module Recyle_operations = struct let classification_of_ops_gen (ops : unit Prevalidation.operation Op_map.t) : unit Classification.t QCheck2.Gen.t = let open QCheck2.Gen in - let ops = Operation_hash.Map.bindings ops |> List.map snd in + let ops = Tezos_crypto.Operation_hash.Map.bindings ops |> List.map snd in let length = List.length ops in let* empty_space = 0 -- 100 in (* To avoid throwing part of [ops], we want the capacity of the classification @@ -446,7 +459,7 @@ module Recyle_operations = struct ~chain ~from_branch ~to_branch - ~live_blocks:Block_hash.Set.empty + ~live_blocks:Tezos_crypto.Block_hash.Set.empty ~classes ~pending ~handle_branch_refused @@ -473,19 +486,21 @@ module Recyle_operations = struct Tree.find_ancestor ~equal tree from_branch to_branch |> force_opt ~loc:__LOC__ in - let live_blocks : Block_hash.Set.t = - Tree.values tree |> List.map Block.to_hash |> Block_hash.Set.of_list + let live_blocks : Tezos_crypto.Block_hash.Set.t = + Tree.values tree |> List.map Block.to_hash + |> Tezos_crypto.Block_hash.Set.of_list in (* This is inherited from the behavior of [handle_live_operations] *) - let expected_from_tree : Operation_hash.Set.t = + let expected_from_tree : Tezos_crypto.Operation_hash.Set.t = List.map Block.tools.all_operation_hashes (values_from_to ~equal tree from_branch ancestor) |> blocks_to_oph_set in (* This is coming from [recycle_operations] itself *) - let op_map_to_hash_list (m : 'a Operation_hash.Map.t) = - Op_map.bindings m |> List.map fst |> Operation_hash.Set.of_list + let op_map_to_hash_list (m : 'a Tezos_crypto.Operation_hash.Map.t) = + Op_map.bindings m |> List.map fst + |> Tezos_crypto.Operation_hash.Set.of_list in let expected_from_classification = Classification.Internal_for_tests.to_map @@ -499,9 +514,9 @@ module Recyle_operations = struct |> op_map_to_hash_list in let expected_from_pending = op_map_to_hash_list pending in - let expected_superset : Operation_hash.Set.t = - Operation_hash.Set.union - (Operation_hash.Set.union + let expected_superset : Tezos_crypto.Operation_hash.Set.t = + Tezos_crypto.Operation_hash.Set.union + (Tezos_crypto.Operation_hash.Set.union expected_from_tree expected_from_classification) expected_from_pending @@ -509,7 +524,7 @@ module Recyle_operations = struct let parse raw hash = Some (Prevalidation.Internal_for_tests.make_operation hash raw ()) in - let actual : Operation_hash.Set.t = + let actual : Tezos_crypto.Operation_hash.Set.t = Classification.recycle_operations ~block_store:Block.tools ~chain @@ -521,11 +536,11 @@ module Recyle_operations = struct ~handle_branch_refused ~parse |> Lwt_main.run |> Op_map.bindings |> List.map fst - |> Operation_hash.Set.of_list + |> Tezos_crypto.Operation_hash.Set.of_list in qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset actual expected_superset () @@ -538,8 +553,9 @@ module Recyle_operations = struct QCheck2.Gen.(pair gen bool) @@ fun ((tree, pair_blocks_opt, classes, pending), handle_branch_refused) -> QCheck2.assume @@ Option.is_some pair_blocks_opt ; - let live_blocks : Block_hash.Set.t = - Tree.values tree |> List.map Block.to_hash |> Block_hash.Set.of_list + let live_blocks : Tezos_crypto.Block_hash.Set.t = + Tree.values tree |> List.map Block.to_hash + |> Tezos_crypto.Block_hash.Set.of_list in let expected : unit Prevalidation.operation Op_map.t = Classification.Internal_for_tests.to_map diff --git a/src/lib_shell/test/legacy_test_prevalidator_pending_operations.ml b/src/lib_shell/test/legacy_test_prevalidator_pending_operations.ml index 66642ac83a5c..c57cc5a68fa8 100644 --- a/src/lib_shell/test/legacy_test_prevalidator_pending_operations.ml +++ b/src/lib_shell/test/legacy_test_prevalidator_pending_operations.ml @@ -51,7 +51,7 @@ let pending_of_list = List.fold_left (fun pendings (op, priority) -> if - Operation_hash.Set.mem + Tezos_crypto.Operation_hash.Set.mem (Prevalidation.Internal_for_tests.hash_of op) (Pending_ops.hashes pendings) then (* no duplicate hashes *) diff --git a/src/lib_shell/test/shell_test_helpers.ml b/src/lib_shell/test/shell_test_helpers.ml index 1771f7ef59b1..4a397ac7e9dc 100644 --- a/src/lib_shell/test/shell_test_helpers.ml +++ b/src/lib_shell/test/shell_test_helpers.ml @@ -35,11 +35,11 @@ open Filename.Infix (** Basic blocks *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisGeneskvg68z" let genesis_protocol_hash = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" let genesis_time = Time.Protocol.of_seconds 0L @@ -65,7 +65,7 @@ let genesis : Genesis.t = protocol = genesis_protocol_hash; } -let chain_id = Chain_id.of_block_hash genesis_block_hash +let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis_block_hash let patch_context ctxt = let open Lwt_syntax in diff --git a/src/lib_shell/test/test_consensus_heuristic.ml b/src/lib_shell/test/test_consensus_heuristic.ml index c1c8bf6b1cb4..82aa60084120 100644 --- a/src/lib_shell/test/test_consensus_heuristic.ml +++ b/src/lib_shell/test/test_consensus_heuristic.ml @@ -35,7 +35,8 @@ module Assert = Lib_test.Assert open Consensus_heuristic let pp ppf = function - | Consensus hash -> Format.fprintf ppf "Consensus with %a" Block_hash.pp hash + | Consensus hash -> + Format.fprintf ppf "Consensus with %a" Tezos_crypto.Block_hash.pp hash | No_consensus _ -> Format.fprintf ppf "No consensus" | Need_more_candidates -> Format.fprintf ppf "Synchronised (not stuck)" @@ -44,7 +45,8 @@ let forge_peer_id () = identity.peer_id let forge_hash () = - Block_hash.hash_bytes [Bytes.init 32 (fun _ -> Char.chr (Random.int 256))] + Tezos_crypto.Block_hash.hash_bytes + [Bytes.init 32 (fun _ -> Char.chr (Random.int 256))] let create_state_init_1 () = let h = create ~expected:1 ~threshold:1 () in @@ -65,7 +67,7 @@ let create_state_bad_expected () = let create_consensus () = let h = create ~expected:1 ~threshold:1 () in let peer_id = forge_peer_id () in - let zero = Block_hash.zero in + let zero = Tezos_crypto.Block_hash.zero in update h (peer_id, zero) ; Assert.equal ~pp (get_state h) (Consensus zero) @@ -74,7 +76,7 @@ let create_no_consensus () = let peer_1 = forge_peer_id () in let peer_2 = forge_peer_id () in let peer_3 = forge_peer_id () in - let hash_1 = Block_hash.zero in + let hash_1 = Tezos_crypto.Block_hash.zero in let hash_2 = forge_hash () in update h (peer_1, hash_1) ; update h (peer_2, hash_2) ; @@ -120,10 +122,13 @@ let job_return_hash () = Worker.create ~expire_time:Ptime.Span.zero ~restart_delay:Ptime.Span.zero - ~job:(fun () -> Lwt.return (Consensus Block_hash.zero)) + ~job:(fun () -> Lwt.return (Consensus Tezos_crypto.Block_hash.zero)) in let p = Worker.wait worker in - Assert.equal ~pp (Lwt.state p) (Lwt.state (Lwt.return Block_hash.zero)) + Assert.equal + ~pp + (Lwt.state p) + (Lwt.state (Lwt.return Tezos_crypto.Block_hash.zero)) let job_sleep () = let worker = @@ -148,9 +153,12 @@ let job_protected () = let p = Worker.wait worker in Assert.equal ~pp (Lwt.state p) Lwt.Sleep ; Lwt.cancel p ; - Lwt.wakeup u (Consensus Block_hash.zero) ; + Lwt.wakeup u (Consensus Tezos_crypto.Block_hash.zero) ; let p' = Worker.wait worker in - Assert.equal ~pp (Lwt.state p') (Lwt.state (Lwt.return Block_hash.zero)) + Assert.equal + ~pp + (Lwt.state p') + (Lwt.state (Lwt.return Tezos_crypto.Block_hash.zero)) let worker_canceled () = let t, _ = Lwt.task () in @@ -178,7 +186,7 @@ let tests_worker_raw : (string * (unit -> unit)) list = let job_return_no_consensus () = let open Lwt_syntax in let counter = ref 0 in - let hash_1 = Block_hash.zero in + let hash_1 = Tezos_crypto.Block_hash.zero in let worker = Worker.create ~expire_time:Ptime.Span.zero @@ -198,7 +206,7 @@ let job_return_no_consensus () = let job_return_need_more_candidates () = let open Lwt_syntax in let counter = ref 0 in - let hash_1 = Block_hash.zero in + let hash_1 = Tezos_crypto.Block_hash.zero in let worker = Worker.create ~expire_time:Ptime.Span.zero diff --git a/src/lib_shell/test/test_node.ml b/src/lib_shell/test/test_node.ml index 80eece8e3f46..8e0ab73aba05 100644 --- a/src/lib_shell/test/test_node.ml +++ b/src/lib_shell/test/test_node.ml @@ -73,7 +73,7 @@ let default_p2p : P2p.config = peers_file = ""; private_mode = true; identity = P2p_identity.generate_with_pow_target_0 (); - proof_of_work_target = Crypto_box.default_pow_target; + proof_of_work_target = Tezos_crypto.Crypto_box.default_pow_target; trust_discovered_peers = false; reconnection_config = Point_reconnection_config.default; } diff --git a/src/lib_shell/test/test_peer_validator.ml b/src/lib_shell/test/test_peer_validator.ml index c308bedaa1fd..4a03f0cc6d46 100644 --- a/src/lib_shell/test/test_peer_validator.ml +++ b/src/lib_shell/test/test_peer_validator.ml @@ -91,7 +91,7 @@ let wrap Shell_limits.default_peer_validator_limits block_validator chain_db - Crypto_box.Public_key_hash.zero + Tezos_crypto.Crypto_box.Public_key_hash.zero in f chain_db genesis_header pv) @@ -137,7 +137,7 @@ let test_validate_new_head_on_lower_fitness () = Assert.assert_true (Format.asprintf "The ddb should contain two entries for %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash) (known_0 && known_1) ; @@ -160,7 +160,7 @@ let test_validate_new_head_on_lower_fitness () = Assert.assert_false (Format.asprintf "The ddb should not contain an entry for %a anymore" - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash) (known_0 || known_1) ; return_unit) diff --git a/src/lib_shell/test/test_prevalidation.ml b/src/lib_shell/test/test_prevalidation.ml index 42335c27f07c..2c76a04d72ca 100644 --- a/src/lib_shell/test/test_prevalidation.ml +++ b/src/lib_shell/test/test_prevalidation.ml @@ -65,21 +65,22 @@ module Classification = Prevalidator_classification module Parameters : Requester_impl.PARAMETERS - with type key = Operation_hash.t + with type key = Tezos_crypto.Operation_hash.t and type value = int = struct - type key = Operation_hash.t + type key = Tezos_crypto.Operation_hash.t type value = int end -module Hash : Requester.HASH with type t = Operation_hash.t = struct +module Hash : Requester.HASH with type t = Tezos_crypto.Operation_hash.t = +struct type t = Parameters.key let name = "test_with_key_Operation_hash_dot_t" - let encoding = Operation_hash.encoding + let encoding = Tezos_crypto.Operation_hash.encoding - let pp = Operation_hash.pp + let pp = Tezos_crypto.Operation_hash.pp end module Test_request = Requester_impl.Simple_request (Parameters) @@ -105,7 +106,7 @@ let mk_operation n : Operation.t = let base_prefix = String.sub base 0 (base_len - n_string_len) in let hash_string = base_prefix ^ n_string in assert (String.length hash_string = base_len) ; - let branch = Block_hash.of_string_exn hash_string in + let branch = Tezos_crypto.Block_hash.of_string_exn hash_string in let proto = Bytes.of_string n_string in {shell = {branch}; proto} @@ -172,7 +173,9 @@ let test_in_mempool_leak f (nb_ops : int) (_ : unit) = f [] op classes in List.iter handle (1 -- nb_ops) ; - let actual_in_mempool_size = Operation_hash.Map.cardinal classes.in_mempool in + let actual_in_mempool_size = + Tezos_crypto.Operation_hash.Map.cardinal classes.in_mempool + in Alcotest.( check bool @@ -203,7 +206,7 @@ let test_db_do_not_clear_right_away f (nb_ops : int) (_ : unit) = let op = mk_operation i in let oph = Operation.hash op in let op = Prevalidation.Internal_for_tests.make_operation op oph () in - Format.printf "Injecting op: %a\n" Operation_hash.pp oph ; + Format.printf "Injecting op: %a\n" Tezos_crypto.Operation_hash.pp oph ; let injected = Lwt_main.run @@ Test_Requester.inject requester oph i in assert injected ; f [] op classes ; @@ -212,7 +215,7 @@ let test_db_do_not_clear_right_away f (nb_ops : int) (_ : unit) = bool (Format.asprintf "requester memory contains most recent classified operation (%a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) (Option.is_some @@ Lwt_main.run @@ Test_Requester.read_opt requester oph) true) diff --git a/src/lib_shell/test/test_prevalidation_t.ml b/src/lib_shell/test/test_prevalidation_t.ml index 137d06b8dae9..cd59889aa279 100644 --- a/src/lib_shell/test/test_prevalidation_t.ml +++ b/src/lib_shell/test/test_prevalidation_t.ml @@ -64,10 +64,10 @@ module Internal_for_tests = Prevalidation.Internal_for_tests module Init = struct let genesis_protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoDemoNoopsDemoNoopsDemoNoopsDemoNoopsDemo6XBoYp" - let chain_id = Chain_id.zero + let chain_id = Tezos_crypto.Chain_id.zero let genesis_time = Time.Protocol.of_seconds 0L @@ -94,8 +94,11 @@ module Init = struct let v = Tezos_shell_context.Shell_context.wrap_disk_context v in f v) - let genesis_block (context_hash : Context_hash.t) : Store.Block.t = - let block_hash : Block_hash.t = Block_hash.hash_string ["genesis"] in + let genesis_block (context_hash : Tezos_crypto.Context_hash.t) : Store.Block.t + = + let block_hash : Tezos_crypto.Block_hash.t = + Tezos_crypto.Block_hash.hash_string ["genesis"] + in let genesis : Genesis.t = {time = genesis_time; block = block_hash; protocol = genesis_protocol} in @@ -136,7 +139,7 @@ let chain_store = () (** Test that [create] returns [Ok] in a pristine context. *) let test_create ctxt = let open Lwt_result_syntax in - let live_operations = Operation_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let timestamp : Time.Protocol.t = now () in let (module Prevalidation) = create_prevalidation (module Mock_protocol) ctxt @@ -168,10 +171,10 @@ let prevalidation_operations_gen (type a) empty string, otherwise the call to [P.parse] will fail with the bytes being too long (hereby looking like an attack). *) let proto_gen : string QCheck2.Gen.t = QCheck2.Gen.return "" in - let+ (ops : Operation.t Operation_hash.Map.t) = + let+ (ops : Operation.t Tezos_crypto.Operation_hash.Map.t) = Generators.raw_op_map_gen_n ~proto_gen ?block_hash_t:None n in - List.map mk_operation (Operation_hash.Map.bindings ops) + List.map mk_operation (Tezos_crypto.Operation_hash.Map.bindings ops) (** The number of operations used by tests that follow *) let nb_ops = 100 @@ -189,7 +192,7 @@ let mk_ops (type a) when the protocol's [apply_operation] crashes. *) let test_apply_operation_crash ctxt = let open Lwt_result_syntax in - let live_operations = Operation_hash.Set.empty in + let live_operations = Tezos_crypto.Operation_hash.Set.empty in let timestamp : Time.Protocol.t = now () in let (module P) = create_prevalidation (module Mock_protocol) ctxt in let ops : P.protocol_operation Prevalidation.operation list = @@ -230,11 +233,11 @@ let mk_live_operations (type a) rand (ops : a Prevalidation.operation list) = List.fold_left (fun acc (op : _ Prevalidation.operation) -> if Random.State.bool rand then - Operation_hash.Set.add + Tezos_crypto.Operation_hash.Set.add (Internal_for_tests.to_raw op |> Operation.hash) acc else acc) - Operation_hash.Set.empty + Tezos_crypto.Operation_hash.Set.empty ops (** Test that [Prevalidation.apply_operations] returns [Outdated] @@ -261,13 +264,15 @@ let test_apply_operation_live_operations ctxt = let ops : P.protocol_operation Prevalidation.operation list = mk_ops (module P) in - let live_operations : Operation_hash.Set.t = mk_live_operations rand ops in + let live_operations : Tezos_crypto.Operation_hash.Set.t = + mk_live_operations rand ops + in let predecessor : Store.Block.t = Init.genesis_block @@ Context_ops.hash ~time:timestamp ctxt in let* pv = P.create chain_store ~predecessor ~live_operations ~timestamp () in let op_in_live_operations op = - Operation_hash.Set.mem + Tezos_crypto.Operation_hash.Set.mem (Internal_for_tests.to_raw op |> Operation.hash) live_operations in @@ -310,7 +315,9 @@ let test_apply_operation_applied ctxt = let ops : P.protocol_operation Prevalidation.operation list = mk_ops (module P) in - let live_operations : Operation_hash.Set.t = mk_live_operations rand ops in + let live_operations : Tezos_crypto.Operation_hash.Set.t = + mk_live_operations rand ops + in let predecessor : Store.Block.t = Init.genesis_block @@ Context_ops.hash ~time:timestamp ctxt in diff --git a/src/lib_shell/test/test_prevalidator_classification.ml b/src/lib_shell/test/test_prevalidator_classification.ml index 344c28039b76..ecb79bf1fba6 100644 --- a/src/lib_shell/test/test_prevalidator_classification.ml +++ b/src/lib_shell/test/test_prevalidator_classification.ml @@ -54,11 +54,11 @@ module Operation_map = struct Format.fprintf ppf "(%a: (%a, ))" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Operation.pp op.Prevalidation.raw)) - (Operation_hash.Map.bindings map) + (Tezos_crypto.Operation_hash.Map.bindings map) let pp ppf map = Format.fprintf @@ -68,22 +68,23 @@ module Operation_map = struct Format.fprintf ppf "(%a: %a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Operation.pp op.Prevalidation.raw)) - (Operation_hash.Map.bindings map) + (Tezos_crypto.Operation_hash.Map.bindings map) (* Uses polymorphic equality on tztraces! *) let eq = - Operation_hash.Map.equal (fun (o1, t1) (o2, t2) -> - Operation_hash.equal o1.Prevalidation.hash o2.hash && t1 = t2) + Tezos_crypto.Operation_hash.Map.equal (fun (o1, t1) (o2, t2) -> + Tezos_crypto.Operation_hash.equal o1.Prevalidation.hash o2.hash + && t1 = t2) end type classification_event = | Add_if_not_present of Classification.classification * unit Prevalidation.operation - | Remove of Operation_hash.t + | Remove of Tezos_crypto.Operation_hash.t | Flush of bool let drop oph t = @@ -166,7 +167,8 @@ let qcheck_eq_false ~actual = let qcheck_bounded_map_is_empty bounded_map = let actual = - bounded_map |> Classification.map |> Operation_hash.Map.is_empty + bounded_map |> Classification.map + |> Tezos_crypto.Operation_hash.Map.is_empty in qcheck_eq_true ~actual @@ -175,21 +177,21 @@ let qcheck_bounded_map_is_empty bounded_map = that these fields are disjoint. *) let disjoint_union_classified_fields ?fail_msg (t : unit Classification.t) = let ( +> ) acc next_set = - if not (Operation_hash.Set.disjoint acc next_set) then + if not (Tezos_crypto.Operation_hash.Set.disjoint acc next_set) then QCheck2.Test.fail_reportf "Invariant 'The fields: [refused; outdated; branch_refused; \ branch_delayed; applied] are disjoint' broken by t =@.%a@.%s" Classification.Internal_for_tests.pp t (match fail_msg with None -> "" | Some msg -> "\n" ^ msg ^ "@.") ; - Operation_hash.Set.union acc next_set + Tezos_crypto.Operation_hash.Set.union acc next_set in let to_set = Classification.Internal_for_tests.set_of_bounded_map in to_set t.refused +> to_set t.outdated +> to_set t.branch_refused +> to_set t.branch_delayed +> (Classification.Sized_map.to_seq t.prechecked - |> Seq.map fst |> Operation_hash.Set.of_seq) - +> (Operation_hash.Set.of_list + |> Seq.map fst |> Tezos_crypto.Operation_hash.Set.of_seq) + +> (Tezos_crypto.Operation_hash.Set.of_list @@ List.rev_map (fun op -> op.Prevalidation.hash) t.applied_rev) (** Checks both invariants of type [Prevalidator_classification.t]: @@ -207,17 +209,28 @@ let disjoint_union_classified_fields ?fail_msg (t : unit Classification.t) = of breaking this using [Tezt]. *) let check_invariants ?fail_msg (t : unit Classification.t) = let to_set map = - Operation_hash.Map.to_seq map |> Seq.map fst |> Operation_hash.Set.of_seq + Tezos_crypto.Operation_hash.Map.to_seq map + |> Seq.map fst |> Tezos_crypto.Operation_hash.Set.of_seq in let expected_in_mempool = disjoint_union_classified_fields ?fail_msg t in let mempool_as_set = to_set t.in_mempool in - if not (Operation_hash.Set.equal expected_in_mempool mempool_as_set) then + if + not + (Tezos_crypto.Operation_hash.Set.equal expected_in_mempool mempool_as_set) + then let set_pp ppf set = - set |> Operation_hash.Set.elements - |> Format.fprintf ppf "%a" (Format.pp_print_list Operation_hash.pp) + set |> Tezos_crypto.Operation_hash.Set.elements + |> Format.fprintf + ppf + "%a" + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) + in + let set1 = + Tezos_crypto.Operation_hash.Set.diff expected_in_mempool mempool_as_set + in + let set2 = + Tezos_crypto.Operation_hash.Set.diff mempool_as_set expected_in_mempool in - let set1 = Operation_hash.Set.diff expected_in_mempool mempool_as_set in - let set2 = Operation_hash.Set.diff mempool_as_set expected_in_mempool in let sets_report = Format.asprintf "In individual fields but not in [in_mempool]:\n\ @@ -260,9 +273,10 @@ let event_pp pp = function "Add_if_not_present %a %a" classification_pp classification - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash - | Remove oph -> Format.fprintf pp "Remove %a" Operation_hash.pp oph + | Remove oph -> + Format.fprintf pp "Remove %a" Tezos_crypto.Operation_hash.pp oph | Flush handle_branch_refused -> Format.fprintf pp "Flush ~handle_branch_refused:%b" handle_branch_refused @@ -438,7 +452,7 @@ module Bounded = struct let binding_pp ppf bindings = bindings |> List.map (fun value -> value.Prevalidation.hash) - |> Format.pp_print_list Operation_hash.pp ppf + |> Format.pp_print_list Tezos_crypto.Operation_hash.pp ppf in Format.asprintf "Prevalidator_classification.t:@.%a@.Classification:@.%s@.First \ @@ -451,7 +465,8 @@ module Bounded = struct binding_pp other_bindings - let custom_gen (discarded_operations_rev : Operation_hash.t list ref) : + let custom_gen + (discarded_operations_rev : Tezos_crypto.Operation_hash.t list ref) : custom QCheck2.Gen.t = let open QCheck2.Gen in let* map_size_limit = 1 -- 20 in @@ -488,10 +503,13 @@ module Bounded = struct not (List.for_all (fun excess_hash -> - List.mem ~equal:Operation_hash.equal excess_hash discarded_hashes) + List.mem + ~equal:Tezos_crypto.Operation_hash.equal + excess_hash + discarded_hashes) excess_hashes) then - let hashes_pp = Format.pp_print_list Operation_hash.pp in + let hashes_pp = Format.pp_print_list Tezos_crypto.Operation_hash.pp in QCheck2.Test.fail_reportf "Expected all excess hashes to have been discarded but it was \ not.@.Excess hashes:@.%a@.Discarded hashes:@.%a" @@ -503,7 +521,8 @@ module Bounded = struct let check_map_is_full ~expected_size ~bounded_map = if Compare.List_length_with.( - Operation_hash.Map.bindings (Classification.map bounded_map) + Tezos_crypto.Operation_hash.Map.bindings + (Classification.map bounded_map) <> expected_size) then QCheck2.Test.fail_reportf @@ -511,7 +530,8 @@ module Bounded = struct %i.@.Bounded_map content:@.%a" expected_size (List.length - (Operation_hash.Map.bindings (Classification.map bounded_map))) + (Tezos_crypto.Operation_hash.Map.bindings + (Classification.map bounded_map))) Classification.Internal_for_tests.bounded_map_pp bounded_map @@ -529,10 +549,10 @@ module Bounded = struct let hashes = first_ops @ other_ops |> List.map (fun op -> op.Prevalidation.hash) in - let unique_hashes = Operation_hash.Set.of_list hashes in + let unique_hashes = Tezos_crypto.Operation_hash.Set.of_list hashes in QCheck2.assume Compare.List_length_with.( - hashes = Operation_hash.Set.cardinal unique_hashes) ; + hashes = Tezos_crypto.Operation_hash.Set.cardinal unique_hashes) ; (* Remove all operations for the tested classification *) let bounded_map = match error_classification with @@ -542,7 +562,7 @@ module Bounded = struct | `Outdated _ -> t.outdated in let () = - Operation_hash.Map.iter + Tezos_crypto.Operation_hash.Map.iter (fun oph _op -> drop oph t) (Classification.map bounded_map) in @@ -565,13 +585,15 @@ end module To_map = struct let map_pp fmt x = let map_to_list m = - Operation_hash.Map.to_seq m |> Seq.map (fun (_, op) -> op) |> List.of_seq + Tezos_crypto.Operation_hash.Map.to_seq m + |> Seq.map (fun (_, op) -> op) + |> List.of_seq in let pp_pair fmt op = Format.fprintf fmt "%a:%a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash Operation.pp op.raw @@ -579,7 +601,7 @@ module To_map = struct Format.fprintf fmt "%a" (Format.pp_print_list pp_pair) (map_to_list x) let map_eq = - Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> Operation.equal op1.Prevalidation.raw op2.raw) (** [remove_all m1 m2] returns the subset of [m1] thas is not within [m2]. @@ -587,11 +609,11 @@ module To_map = struct that are in [m2]. *) let remove_all m1 m2 = let keys2 = - Operation_hash.Map.bindings m2 - |> List.map fst |> Operation_hash.Set.of_list + Tezos_crypto.Operation_hash.Map.bindings m2 + |> List.map fst |> Tezos_crypto.Operation_hash.Set.of_list in - Operation_hash.Map.filter - (fun key _val -> not (Operation_hash.Set.mem key keys2)) + Tezos_crypto.Operation_hash.Map.filter + (fun key _val -> not (Tezos_crypto.Operation_hash.Set.mem key keys2)) m1 (** [eq_mod_binding m1 (k, v_opt) m2] holds iff: @@ -602,13 +624,13 @@ module To_map = struct for some unknown value [v]. *) let eq_mod_op m1 (k, v_opt) m2 = let diff = remove_all m2 m1 in - match (Operation_hash.Map.bindings diff, v_opt) with + match (Tezos_crypto.Operation_hash.Map.bindings diff, v_opt) with | [], _ -> true | [(kdiff, vdiff)], Some v - when Operation_hash.equal kdiff k + when Tezos_crypto.Operation_hash.equal kdiff k && Operation.equal v.Prevalidation.raw vdiff.Prevalidation.raw -> true - | [(kdiff, _)], None when Operation_hash.equal kdiff k -> true + | [(kdiff, _)], None when Tezos_crypto.Operation_hash.equal kdiff k -> true | _ -> false (** [to_map_all] calls [Classification.to_map] with all named @@ -634,7 +656,7 @@ module To_map = struct qcheck_eq' ~pp:map_pp ~eq:map_eq - ~expected:Operation_hash.Map.empty + ~expected:Tezos_crypto.Operation_hash.Map.empty ~actual:(to_map_all t) () @@ -680,7 +702,7 @@ module To_map = struct "Starting with:@. %a@.and operation hash %a@. " Operation_map.pp (to_map_all t) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op.Prevalidation.hash let test_map_remove_add = @@ -705,15 +727,17 @@ module To_map = struct let t' = Classification.Internal_for_tests.copy t in drop op.Prevalidation.hash t ; let initial = to_map_all t in - let left = Operation_hash.Map.add op.Prevalidation.hash op initial in + let left = + Tezos_crypto.Operation_hash.Map.add op.Prevalidation.hash op initial + in Classification.add classification op t' ; let right = to_map_all t' in qcheck_eq' ~expected:left ~actual:right ~eq: - (Operation_hash.Map.equal (fun op1 op2 -> - Operation_hash.equal op1.Prevalidation.hash op2.hash)) + (Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.equal op1.Prevalidation.hash op2.hash)) ~pp:map_pp () @@ -739,15 +763,17 @@ module To_map = struct Classification.add classification op t ; let initial = to_map_all t in let oph = op.Prevalidation.hash in - let left = Operation_hash.Map.remove oph initial in + let left = Tezos_crypto.Operation_hash.Map.remove oph initial in drop oph t' ; let right = to_map_all t' in qcheck_eq' ~expected:left ~actual:right ~eq: - (Operation_hash.Map.equal (fun op1 op2 -> - Operation_hash.equal op1.Prevalidation.hash op2.Prevalidation.hash)) + (Tezos_crypto.Operation_hash.Map.equal (fun op1 op2 -> + Tezos_crypto.Operation_hash.equal + op1.Prevalidation.hash + op2.Prevalidation.hash)) ~pp:map_pp () @@ -784,11 +810,12 @@ module To_map = struct let oph = op.Prevalidation.hash in let is_in_mempool = is_in_mempool oph t in let map = - to_map_all t |> Operation_hash.Map.filter (fun oph' _ -> oph' = oph) + to_map_all t + |> Tezos_crypto.Operation_hash.Map.filter (fun oph' _ -> oph' = oph) in qcheck_eq' ~expected:is_in_mempool - ~actual:(Operation_hash.Map.cardinal map = 1) + ~actual:(Tezos_crypto.Operation_hash.Map.cardinal map = 1) () (** Tests that [Classification.to_map] returns an empty map if all parameters @@ -802,7 +829,7 @@ module To_map = struct qcheck_eq' ~pp:map_pp ~eq:map_eq - ~expected:Operation_hash.Map.empty + ~expected:Tezos_crypto.Operation_hash.Map.empty ~actual: (Classification.Internal_for_tests.to_map ~applied:false diff --git a/src/lib_shell/test/test_prevalidator_classification_operations.ml b/src/lib_shell/test/test_prevalidator_classification_operations.ml index b34033d39b0e..46ad3eebee63 100644 --- a/src/lib_shell/test/test_prevalidator_classification_operations.ml +++ b/src/lib_shell/test/test_prevalidator_classification_operations.ml @@ -42,7 +42,7 @@ *) open Lib_test.Qcheck2_helpers -module Op_map = Operation_hash.Map +module Op_map = Tezos_crypto.Operation_hash.Map module Classification = Prevalidator_classification module Tree = Generators_tree.Tree module List_extra = Generators_tree.List_extra @@ -61,22 +61,22 @@ let values_from_to ~(equal : 'a -> 'a -> bool) (tree : 'a Tree.tree) |> force_opt ~loc:__LOC__ |> fun preds -> start :: preds -(** Pretty print values of type [Operation_hash.Set.t] *) +(** Pretty print values of type [Tezos_crypto.Operation_hash.Set.t] *) let op_set_pp fmt x = - let set_to_list m = Operation_hash.Set.to_seq m |> List.of_seq in + let set_to_list m = Tezos_crypto.Operation_hash.Set.to_seq m |> List.of_seq in Format.fprintf fmt "%a" - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) (set_to_list x) -(** Pretty print values of type [Operation.t Operation_hash.Map] *) +(** Pretty print values of type [Operation.t Tezos_crypto.Operation_hash.Map] *) let op_map_pp fmt x = let pp_pair fmt (hash, op) = Format.fprintf fmt "%a:%a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp hash Operation.pp op.Prevalidation.raw @@ -85,7 +85,7 @@ let op_map_pp fmt x = fmt "%a" (Format.pp_print_list pp_pair) - (Operation_hash.Map.bindings x) + (Tezos_crypto.Operation_hash.Map.bindings x) let qcheck_cond ?pp ~cond e1 e2 () = if cond e1 e2 then true @@ -107,23 +107,24 @@ let qcheck_cond ?pp ~cond e1 e2 () = pp e2 -let blocks_to_oph_set (blocks : Operation_hash.t list list list) : - Operation_hash.Set.t = - List.concat blocks |> List.concat |> Operation_hash.Set.of_list +let blocks_to_oph_set (blocks : Tezos_crypto.Operation_hash.t list list list) : + Tezos_crypto.Operation_hash.Set.t = + List.concat blocks |> List.concat |> Tezos_crypto.Operation_hash.Set.of_list (** [is_subset m1 m2] returns whether all bindings of [m1] are in [m2]. In other words, it returns whether [m2] is a superset of [m1]. *) let is_subset (m1 : unit Prevalidation.operation Op_map.t) (m2 : unit Prevalidation.operation Op_map.t) = - let rec go (m1_seq : (Operation_hash.t * unit Prevalidation.operation) Seq.t) - = + let rec go + (m1_seq : + (Tezos_crypto.Operation_hash.t * unit Prevalidation.operation) Seq.t) = match m1_seq () with | Seq.Nil -> true | Seq.Cons ((m1_key, m1_value), m1_rest) -> ( match Op_map.find m1_key m2 with | None -> (* A key in [m1] that is not in [m2] *) false | Some m2_value -> - Operation_hash.equal + Tezos_crypto.Operation_hash.equal m1_value.Prevalidation.hash m2_value.Prevalidation.hash && go m1_rest) @@ -156,7 +157,10 @@ module Handle_operations = struct List.map (fun (blk : Block.t) -> blk.hash) live_blocks in return - (tree, pair_blocks_opt, old_mempool, Block_hash.Set.of_list live_blocks) + ( tree, + pair_blocks_opt, + old_mempool, + Tezos_crypto.Block_hash.Set.of_list live_blocks ) in QCheck2.Test.make ~name:"[handle_live_operations] is a subset of alive blocks" @@ -171,7 +175,7 @@ module Handle_operations = struct (* Keep only the ones in live_blocks *) |> List.to_seq |> Seq.filter (fun (blk : Block.t) -> - Block_hash.Set.mem blk.hash live_blocks) + Tezos_crypto.Block_hash.Set.mem blk.hash live_blocks) (* Then extract (oph, op) pairs from them *) |> Seq.flat_map (fun (blk : Block.t) -> List.to_seq blk.operations) |> Seq.flat_map List.to_seq @@ -186,7 +190,7 @@ module Handle_operations = struct ~from_branch ~to_branch ~is_branch_alive:(fun blk_hash -> - Block_hash.Set.mem blk_hash live_blocks) + Tezos_crypto.Block_hash.Set.mem blk_hash live_blocks) ~parse old_mempool |> Lwt_main.run @@ -223,7 +227,9 @@ module Handle_operations = struct (* Expected operations are the ones from [ancestor] to [from_branch], minus the ones from ancestor to [to_branch]. *) let expected = - Operation_hash.Set.diff expected_superset from_ancestor_to_to_branch + Tezos_crypto.Operation_hash.Set.diff + expected_superset + from_ancestor_to_to_branch in let actual = Classification.Internal_for_tests.handle_live_operations @@ -234,11 +240,16 @@ module Handle_operations = struct ~to_branch ~is_branch_alive:(Fun.const true) ~parse - Operation_hash.Map.empty + Tezos_crypto.Operation_hash.Map.empty |> Lwt_main.run |> Op_map.bindings |> List.map fst - |> Operation_hash.Set.of_list + |> Tezos_crypto.Operation_hash.Set.of_list in - qcheck_eq' ~pp:op_set_pp ~eq:Operation_hash.Set.equal ~expected ~actual () + qcheck_eq' + ~pp:op_set_pp + ~eq:Tezos_crypto.Operation_hash.Set.equal + ~expected + ~actual + () (** Test that operations cleared by [handle_live_operations] are operations on the path from [ancestor] to [to_branch] (when all @@ -251,8 +262,10 @@ module Handle_operations = struct QCheck2.assume @@ Option.is_some pair_blocks_opt ; let from_branch, to_branch = force_opt ~loc:__LOC__ pair_blocks_opt in let chain = Generators_tree.classification_chain_tools tree in - let cleared = ref Operation_hash.Set.empty in - let clearer oph = cleared := Operation_hash.Set.add oph !cleared in + let cleared = ref Tezos_crypto.Operation_hash.Set.empty in + let clearer oph = + cleared := Tezos_crypto.Operation_hash.Set.add oph !cleared + in let chain = {chain with clear_or_cancel = clearer} in let equal = Block.equal in let ancestor : Block.t = @@ -277,7 +290,7 @@ module Handle_operations = struct |> Lwt_main.run |> ignore ; qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset !cleared expected_superset () @@ -292,9 +305,9 @@ module Handle_operations = struct QCheck2.assume @@ Option.is_some pair_blocks_opt ; let from_branch, to_branch = force_opt ~loc:__LOC__ pair_blocks_opt in let chain = Generators_tree.classification_chain_tools tree in - let injected = ref Operation_hash.Set.empty in + let injected = ref Tezos_crypto.Operation_hash.Set.empty in let inject_operation oph _op = - injected := Operation_hash.Set.add oph !injected ; + injected := Tezos_crypto.Operation_hash.Set.add oph !injected ; Lwt.return_unit in let chain = {chain with inject_operation} in @@ -321,7 +334,7 @@ module Handle_operations = struct |> Lwt_main.run |> ignore ; qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset !injected expected_superset () @@ -340,7 +353,7 @@ module Recyle_operations = struct let classification_of_ops_gen (ops : unit Prevalidation.operation Op_map.t) : unit Classification.t QCheck2.Gen.t = let open QCheck2.Gen in - let ops = Operation_hash.Map.bindings ops |> List.map snd in + let ops = Tezos_crypto.Operation_hash.Map.bindings ops |> List.map snd in let length = List.length ops in let* empty_space = 0 -- 100 in (* To avoid throwing part of [ops], we want the capacity of the classification @@ -442,7 +455,7 @@ module Recyle_operations = struct ~chain ~from_branch ~to_branch - ~live_blocks:Block_hash.Set.empty + ~live_blocks:Tezos_crypto.Block_hash.Set.empty ~classes ~pending ~handle_branch_refused @@ -469,19 +482,21 @@ module Recyle_operations = struct Tree.find_ancestor ~equal tree from_branch to_branch |> force_opt ~loc:__LOC__ in - let live_blocks : Block_hash.Set.t = - Tree.values tree |> List.map Block.to_hash |> Block_hash.Set.of_list + let live_blocks : Tezos_crypto.Block_hash.Set.t = + Tree.values tree |> List.map Block.to_hash + |> Tezos_crypto.Block_hash.Set.of_list in (* This is inherited from the behavior of [handle_live_operations] *) - let expected_from_tree : Operation_hash.Set.t = + let expected_from_tree : Tezos_crypto.Operation_hash.Set.t = List.map Block.tools.all_operation_hashes (values_from_to ~equal tree from_branch ancestor) |> blocks_to_oph_set in (* This is coming from [recycle_operations] itself *) - let op_map_to_hash_list (m : 'a Operation_hash.Map.t) = - Op_map.bindings m |> List.map fst |> Operation_hash.Set.of_list + let op_map_to_hash_list (m : 'a Tezos_crypto.Operation_hash.Map.t) = + Op_map.bindings m |> List.map fst + |> Tezos_crypto.Operation_hash.Set.of_list in let expected_from_classification = Classification.Internal_for_tests.to_map @@ -495,9 +510,9 @@ module Recyle_operations = struct |> op_map_to_hash_list in let expected_from_pending = op_map_to_hash_list pending in - let expected_superset : Operation_hash.Set.t = - Operation_hash.Set.union - (Operation_hash.Set.union + let expected_superset : Tezos_crypto.Operation_hash.Set.t = + Tezos_crypto.Operation_hash.Set.union + (Tezos_crypto.Operation_hash.Set.union expected_from_tree expected_from_classification) expected_from_pending @@ -505,7 +520,7 @@ module Recyle_operations = struct let parse raw hash = Some (Prevalidation.Internal_for_tests.make_operation hash raw ()) in - let actual : Operation_hash.Set.t = + let actual : Tezos_crypto.Operation_hash.Set.t = Classification.recycle_operations ~block_store:Block.tools ~chain @@ -517,11 +532,11 @@ module Recyle_operations = struct ~handle_branch_refused ~parse |> Lwt_main.run |> Op_map.bindings |> List.map fst - |> Operation_hash.Set.of_list + |> Tezos_crypto.Operation_hash.Set.of_list in qcheck_cond ~pp:op_set_pp - ~cond:Operation_hash.Set.subset + ~cond:Tezos_crypto.Operation_hash.Set.subset actual expected_superset () @@ -534,8 +549,9 @@ module Recyle_operations = struct QCheck2.Gen.(pair gen bool) @@ fun ((tree, pair_blocks_opt, classes, pending), handle_branch_refused) -> QCheck2.assume @@ Option.is_some pair_blocks_opt ; - let live_blocks : Block_hash.Set.t = - Tree.values tree |> List.map Block.to_hash |> Block_hash.Set.of_list + let live_blocks : Tezos_crypto.Block_hash.Set.t = + Tree.values tree |> List.map Block.to_hash + |> Tezos_crypto.Block_hash.Set.of_list in let expected : unit Prevalidation.operation Op_map.t = Classification.Internal_for_tests.to_map diff --git a/src/lib_shell/test/test_prevalidator_pending_operations.ml b/src/lib_shell/test/test_prevalidator_pending_operations.ml index 43adc3e6be19..511ba194105e 100644 --- a/src/lib_shell/test/test_prevalidator_pending_operations.ml +++ b/src/lib_shell/test/test_prevalidator_pending_operations.ml @@ -48,7 +48,7 @@ let pending_of_list = List.fold_left (fun pendings (op, priority) -> if - Operation_hash.Set.mem + Tezos_crypto.Operation_hash.Set.mem (Prevalidation.Internal_for_tests.hash_of op) (Pending_ops.hashes pendings) then (* no duplicate hashes *) diff --git a/src/lib_shell/test/test_protocol_validator.ml b/src/lib_shell/test/test_protocol_validator.ml index dae28d96044c..0f491e4cacdb 100644 --- a/src/lib_shell/test/test_protocol_validator.ml +++ b/src/lib_shell/test/test_protocol_validator.ml @@ -53,11 +53,11 @@ module Alcotest_protocol_validator = struct let eq (p1 : t) (p2 : t) : bool = let (module P1) = p1 in let (module P2) = p2 in - Tezos_base.TzPervasives.Protocol_hash.equal P1.hash P2.hash + Tezos_crypto.Protocol_hash.equal P1.hash P2.hash in let pp fmt (p : t) = let (module P) = p in - Tezos_base.TzPervasives.Protocol_hash.pp fmt P.hash + Tezos_crypto.Protocol_hash.pp fmt P.hash in Alcotest.testable pp eq end @@ -97,7 +97,9 @@ let test_pushing_validator_protocol vl _switch () = (* Let's validate a phony protocol *) let open Lwt_syntax in let pt = Protocol.{expected_env = V0; components = []} in - let* res = Protocol_validator.validate vl Protocol_hash.zero pt in + let* res = + Protocol_validator.validate vl Tezos_crypto.Protocol_hash.zero pt + in Alcotest.( check (Tztestable.tzresults Alcotest_protocol_validator.registered_protocol)) "Compilation should fail." @@ -105,7 +107,7 @@ let test_pushing_validator_protocol vl _switch () = (Error [ Validation_errors.Invalid_protocol - {hash = Protocol_hash.zero; error = Compilation_failed}; + {hash = Tezos_crypto.Protocol_hash.zero; error = Compilation_failed}; ]) ; Mock_sink.( assert_has_event @@ -154,7 +156,7 @@ let test_fetching_protocol vl _switch () = ~peer:P2p_peer.Id.zero ~timeout:Ptime.Span.zero vl - Protocol_hash.zero + Tezos_crypto.Protocol_hash.zero in Mock_sink.( assert_has_event diff --git a/src/lib_shell/validator.ml b/src/lib_shell/validator.ml index 753558b4333c..2381a3865dc3 100644 --- a/src/lib_shell/validator.ml +++ b/src/lib_shell/validator.ml @@ -34,8 +34,8 @@ type t = { prevalidator_limits : Shell_limits.prevalidator_limits; start_testchain : bool; valid_block_input : Store.Block.t Lwt_watcher.input; - chains_input : (Chain_id.t * bool) Lwt_watcher.input; - active_chains : Chain_validator.t Chain_id.Table.t; + chains_input : (Tezos_crypto.Chain_id.t * bool) Lwt_watcher.input; + active_chains : Chain_validator.t Tezos_crypto.Chain_id.Table.t; } let create state db peer_validator_limits block_validator_limits @@ -63,14 +63,14 @@ let create state db peer_validator_limits block_validator_limits chain_validator_limits; valid_block_input; chains_input; - active_chains = Chain_id.Table.create 7; + active_chains = Tezos_crypto.Chain_id.Table.create 7; } let activate v ~start_prevalidator ~validator_process chain_store = let open Lwt_syntax in let chain_id = Store.Chain.chain_id chain_store in let* () = Validator_event.(emit activate_chain) chain_id in - match Chain_id.Table.find v.active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find v.active_chains chain_id with | Some chain -> return_ok chain | None -> Chain_validator.create @@ -89,12 +89,14 @@ let activate v ~start_prevalidator ~validator_process chain_store = let get {active_chains; _} chain_id = let open Result_syntax in - match Chain_id.Table.find active_chains chain_id with + match Tezos_crypto.Chain_id.Table.find active_chains chain_id with | Some nv -> return nv | None -> tzfail (Validation_errors.Inactive_chain chain_id) let get_active_chains {active_chains; _} = - let l = Chain_id.Table.fold (fun c _ acc -> c :: acc) active_chains [] in + let l = + Tezos_crypto.Chain_id.Table.fold (fun c _ acc -> c :: acc) active_chains [] + in List.rev l let read_block store h = @@ -115,7 +117,7 @@ let read_block_header db h = let validate_block v ?(force = false) ?chain_id bytes operations = let open Lwt_result_syntax in - let hash = Block_hash.hash_bytes [bytes] in + let hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in match Block_header.of_bytes bytes with | None -> failwith "Cannot parse block header." | Some block -> @@ -130,7 +132,7 @@ let validate_block v ?(force = false) ?chain_id bytes operations = | None -> failwith "Unknown predecessor (%a), cannot inject the block." - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block.shell.predecessor | Some (chain_id, _bh) -> Lwt.return (get v chain_id)) | Some chain_id -> ( @@ -147,7 +149,7 @@ let validate_block v ?(force = false) ?chain_id bytes operations = | false -> failwith "Unknown predecessor (%a), cannot inject the block." - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short block.shell.predecessor) in let validation = @@ -163,7 +165,7 @@ let shutdown {active_chains; block_validator; _} = (fun (id, nv) -> let* () = Validator_event.(emit shutdown_chain_validator) id in Chain_validator.shutdown nv) - (Chain_id.Table.to_seq active_chains) + (Tezos_crypto.Chain_id.Table.to_seq active_chains) in (* Shutdown the chain_validator (peer_validators, prevalidator, etc.) before the block_validator *) @@ -191,7 +193,7 @@ let inject_operation v ?chain_id ~force op = match o with | None -> if force then - Chain_id.Table.iter_es + Tezos_crypto.Chain_id.Table.iter_es (fun _chain_id chain -> inject_operation_on chain @@ -200,7 +202,7 @@ let inject_operation v ?chain_id ~force op = else failwith "Unknown branch (%a), cannot inject the operation." - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short op.shell.branch | Some (chain_id, _bh) -> let*? nv = get v chain_id in diff --git a/src/lib_shell/validator.mli b/src/lib_shell/validator.mli index e1a308e0e59a..cbcc8420e8c8 100644 --- a/src/lib_shell/validator.mli +++ b/src/lib_shell/validator.mli @@ -49,23 +49,24 @@ val activate : Store.chain_store -> Chain_validator.t tzresult Lwt.t -val get : t -> Chain_id.t -> Chain_validator.t tzresult +val get : t -> Tezos_crypto.Chain_id.t -> Chain_validator.t tzresult -val get_active_chains : t -> Chain_id.t list +val get_active_chains : t -> Tezos_crypto.Chain_id.t list (** Force the validation of a block. *) val validate_block : t -> ?force:bool -> - ?chain_id:Chain_id.t -> + ?chain_id:Tezos_crypto.Chain_id.t -> Bytes.t -> Operation.t list list -> - (Block_hash.t * unit tzresult Lwt.t) tzresult Lwt.t + (Tezos_crypto.Block_hash.t * unit tzresult Lwt.t) tzresult Lwt.t (** Monitor all the valid block (for all activate chains). *) val watcher : t -> Store.Block.t Lwt_stream.t * Lwt_watcher.stopper -val chains_watcher : t -> (Chain_id.t * bool) Lwt_stream.t * Lwt_watcher.stopper +val chains_watcher : + t -> (Tezos_crypto.Chain_id.t * bool) Lwt_stream.t * Lwt_watcher.stopper (** [inject_operation t ?chain_id ~force op] notifies the prevalidator worker associated with the [chain_id] of a new injected operation. @@ -75,6 +76,10 @@ val chains_watcher : t -> (Chain_id.t * bool) Lwt_stream.t * Lwt_watcher.stopper in the operation data. Fails if no chain_id can be recovered unless [force] is set. If force is set, notify all the known prevalidator workers. *) val inject_operation : - t -> ?chain_id:Chain_id.t -> force:bool -> Operation.t -> unit tzresult Lwt.t + t -> + ?chain_id:Tezos_crypto.Chain_id.t -> + force:bool -> + Operation.t -> + unit tzresult Lwt.t val distributed_db : t -> Distributed_db.t diff --git a/src/lib_shell/validator_event.ml b/src/lib_shell/validator_event.ml index dbf986dc4cee..4da070bea446 100644 --- a/src/lib_shell/validator_event.ml +++ b/src/lib_shell/validator_event.ml @@ -35,7 +35,7 @@ let activate_chain = ~name:"activate_chain" ~msg:"activate chain {chain}" ~level:Notice - ("chain", Chain_id.encoding) + ("chain", Tezos_crypto.Chain_id.encoding) let shutdown_block_validator = declare_0 @@ -51,4 +51,4 @@ let shutdown_chain_validator = ~name:"shutdown_chain_validator" ~msg:"shutting down the chain validator {chain}" ~level:Notice - ("chain", Chain_id.encoding) + ("chain", Tezos_crypto.Chain_id.encoding) diff --git a/src/lib_shell/worker_directory.ml b/src/lib_shell/worker_directory.ml index 6823c7dc3778..da2abfebabcb 100644 --- a/src/lib_shell/worker_directory.ml +++ b/src/lib_shell/worker_directory.ml @@ -58,7 +58,9 @@ let build_rpc_directory state = * register multiple Prevalidator for a single chain (using distinct * protocols). However, this is never done. *) WithExceptions.Option.to_exn ~none:Not_found - @@ List.find (fun (c, _, _) -> Chain_id.equal c chain_id) workers + @@ List.find + (fun (c, _, _) -> Tezos_crypto.Chain_id.equal c chain_id) + workers in let status = Prevalidator.status t in let pending_requests = Prevalidator.pending_requests t in @@ -79,7 +81,7 @@ let build_rpc_directory state = return_ok (List.filter_map (fun ((id, peer_id), w) -> - if Chain_id.equal id chain_id then + if Tezos_crypto.Chain_id.equal id chain_id then Some ( peer_id, Peer_validator.status w, @@ -90,7 +92,7 @@ let build_rpc_directory state = register2 Worker_services.Peer_validators.S.state (fun chain peer_id () () -> let* chain_id = Chain_directory.get_chain_id state chain in let equal (acid, apid) (bcid, bpid) = - Chain_id.equal acid bcid && P2p_peer.Id.equal apid bpid + Tezos_crypto.Chain_id.equal acid bcid && P2p_peer.Id.equal apid bpid in let w = WithExceptions.Option.to_exn ~none:Not_found @@ -120,7 +122,7 @@ let build_rpc_directory state = let w = WithExceptions.Option.to_exn ~none:Not_found @@ List.assoc - ~equal:Chain_id.equal + ~equal:Tezos_crypto.Chain_id.equal chain_id (Chain_validator.running_workers ()) in @@ -136,7 +138,7 @@ let build_rpc_directory state = let w = WithExceptions.Option.to_exn ~none:Not_found @@ List.assoc - ~equal:Chain_id.equal + ~equal:Tezos_crypto.Chain_id.equal chain_id (Chain_validator.running_workers ()) in -- GitLab From dadf0eb03f37906d1703e1e697a7ec7bf32a3df9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:42:08 +0200 Subject: [PATCH 13/30] Mockup: unopen Crypto --- src/lib_mockup/RPC_client.ml | 5 +- src/lib_mockup/local_services.ml | 73 +++++++++++++++---------- src/lib_mockup/migration.mli | 4 +- src/lib_mockup/mockup_args.ml | 2 +- src/lib_mockup/mockup_args.mli | 7 ++- src/lib_mockup/mockup_commands.ml | 4 +- src/lib_mockup/mockup_wallet.ml | 5 +- src/lib_mockup/persistence.ml | 29 +++++----- src/lib_mockup/persistence_intf.ml | 12 ++-- src/lib_mockup/registration_intf.ml | 6 +- src/lib_mockup/test/test_mockup_args.ml | 3 +- src/lib_mockup/test/test_persistence.ml | 34 +++++++----- 12 files changed, 104 insertions(+), 80 deletions(-) diff --git a/src/lib_mockup/RPC_client.ml b/src/lib_mockup/RPC_client.ml index 0cd8f8a81bb6..8c945f8d712d 100644 --- a/src/lib_mockup/RPC_client.ml +++ b/src/lib_mockup/RPC_client.ml @@ -25,8 +25,9 @@ class mockup_ctxt (base_dir : string) (mem_only : bool) (mockup_env : Tezos_mockup_registration.Registration.mockup_environment) - (chain_id : Chain_id.t) (rpc_context : Tezos_protocol_environment.rpc_context) - protocol_data : Tezos_rpc.Context.generic = + (chain_id : Tezos_crypto.Chain_id.t) + (rpc_context : Tezos_protocol_environment.rpc_context) protocol_data : + Tezos_rpc.Context.generic = let local_ctxt = Tezos_mockup_proxy.RPC_client.local_ctxt (Local_services.build_directory diff --git a/src/lib_mockup/local_services.ml b/src/lib_mockup/local_services.ml index cc3db51f6df1..bccc41c9b5d1 100644 --- a/src/lib_mockup/local_services.ml +++ b/src/lib_mockup/local_services.ml @@ -79,7 +79,7 @@ let () = module type MENV = sig include Registration.MOCKUP - val chain_id : Chain_id.t + val chain_id : Tezos_crypto.Chain_id.t val rpc_context : Tezos_protocol_environment.rpc_context @@ -139,7 +139,7 @@ module Make (E : MENV) = struct Directory.register Directory.empty service (fun _prefix () () -> let current_protocol = if Compare.Int32.(E.rpc_context.block_header.level = 0l) then - Protocol_hash.zero + Tezos_crypto.Protocol_hash.zero else protocol_hash in Lwt.return @@ -155,13 +155,13 @@ module Make (E : MENV) = struct Tezos_rpc.Answer.return (block_hash, block_header.timestamp)) let chain_chain_id = function - | `Main -> Chain_id.hash_string ["main"] - | `Test -> Chain_id.hash_string ["test"] + | `Main -> Tezos_crypto.Chain_id.hash_string ["main"] + | `Test -> Tezos_crypto.Chain_id.hash_string ["test"] | `Hash cid -> cid let check_chain ?caller_name (chain : Block_services.chain) = unless - (Chain_id.equal E.chain_id (chain_chain_id chain)) + (Tezos_crypto.Chain_id.equal E.chain_id (chain_chain_id chain)) (fun () -> let msg = let open Format in @@ -175,17 +175,17 @@ module Make (E : MENV) = struct fprintf ppf "main (%a)" - Chain_id.pp - (Chain_id.hash_string ["main"]) + Tezos_crypto.Chain_id.pp + (Tezos_crypto.Chain_id.hash_string ["main"]) | `Test -> fprintf ppf "test (%a)" - Chain_id.pp - (Chain_id.hash_string ["test"]) - | `Hash chain_id -> Chain_id.pp ppf chain_id) + Tezos_crypto.Chain_id.pp + (Tezos_crypto.Chain_id.hash_string ["test"]) + | `Hash chain_id -> Tezos_crypto.Chain_id.pp ppf chain_id) chain - Chain_id.pp + Tezos_crypto.Chain_id.pp E.chain_id in Lwt.fail_with msg) @@ -370,11 +370,11 @@ module Make (E : MENV) = struct let pending_operations = { E.Block_services.Mempool.applied; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; - unprocessed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; + unprocessed = Tezos_crypto.Operation_hash.Map.empty; } in return pending_operations @@ -421,7 +421,9 @@ module Make (E : MENV) = struct E.Block_services.S.live_blocks (fun (((), chain), _block) () () -> with_chain ~caller_name:"live blocks" chain (fun () -> - let set = Block_hash.Set.singleton E.rpc_context.block_hash in + let set = + Tezos_crypto.Block_hash.Set.singleton E.rpc_context.block_hash + in Tezos_rpc.Answer.return set)) let simulate_operation (state, preapply_result) op = @@ -444,7 +446,7 @@ module Make (E : MENV) = struct { preapply_result with refused = - Operation_hash.Map.add + Tezos_crypto.Operation_hash.Map.add hash (op_t, e) preapply_result.refused; @@ -509,10 +511,11 @@ module Make (E : MENV) = struct (* Similar to lib_shell.Prevalidation.preapply *) let operations_hash = let open Preapply_result in - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute @@ List.rev_map (fun x -> - Operation_list_hash.compute @@ List.map fst x.applied) + Tezos_crypto.Operation_list_hash.compute + @@ List.map fst x.applied) preapply_results in let timestamp = @@ -534,7 +537,9 @@ module Make (E : MENV) = struct operations_hash; validation_passes; fitness = validation_result.fitness; - context = Context_hash.zero (* TODO: is that correct ? *); + context = + Tezos_crypto.Context_hash.zero + (* TODO: is that correct ? *); } in return (shell_header, List.rev preapply_results) @@ -602,7 +607,7 @@ module Make (E : MENV) = struct let equal_op (a_shell_header, a_operation_data) (b_shell_header, b_operation_data) = - Block_hash.equal + Tezos_crypto.Block_hash.equal a_shell_header.Operation.branch b_shell_header.Operation.branch && (* FIXME: the protocol should export equality/comparison functions for @@ -625,7 +630,7 @@ module Make (E : MENV) = struct (proto_state, Preapply_result.empty) operations in - if Operation_hash.Map.is_empty preapply_result.refused then + if Tezos_crypto.Operation_hash.Map.is_empty preapply_result.refused then let* _ = finalize_validation_and_application proto_state None in return `Applicable else return `Refused @@ -765,7 +770,7 @@ module Make (E : MENV) = struct (* See injection_directory.ml for vanilla implementation *) (fun () _ (bytes, operations) -> (* assert (Files.Mempool.exists ~dirname:E.base_dir) ; *) - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in match Block_header.of_bytes bytes with | None -> Tezos_rpc.Answer.fail [Cannot_parse_op] | Some block_header -> ( @@ -809,21 +814,28 @@ module Make (E : MENV) = struct let h = Operation.hash {Operation.shell = shell_header; proto} in - return @@ Operation_hash.Map.add h v map) - Operation_hash.Map.empty + return @@ Tezos_crypto.Operation_hash.Map.add h v map) + Tezos_crypto.Operation_hash.Map.empty mempool_operations in let refused_map = List.fold_left (List.fold_left (fun mempool op -> - Operation_hash.Map.remove (Operation.hash op) mempool)) + Tezos_crypto.Operation_hash.Map.remove + (Operation.hash op) + mempool)) mempool_map operations in let* () = - unless (Operation_hash.Map.is_empty refused_map) (fun () -> + unless + (Tezos_crypto.Operation_hash.Map.is_empty refused_map) + (fun () -> let refused_ops = - Operation_hash.Map.fold (fun _k v l -> v :: l) refused_map [] + Tezos_crypto.Operation_hash.Map.fold + (fun _k v l -> v :: l) + refused_map + [] in let*! () = L.(S.emit warn_trashpool_append) refused_ops in Trashpool.append refused_ops) @@ -984,7 +996,8 @@ let build_shell_directory (base_dir : string) [rpc_context] is data used when honoring an RPC. *) let build_directory (base_dir : string) (mem_only : bool) - (mockup_env : Registration.mockup_environment) (chain_id : Chain_id.t) + (mockup_env : Registration.mockup_environment) + (chain_id : Tezos_crypto.Chain_id.t) (rpc_context : Tezos_protocol_environment.rpc_context) protocol_data : unit Tezos_rpc.Directory.t = let write_context rpc_context protocol_data = diff --git a/src/lib_mockup/migration.mli b/src/lib_mockup/migration.mli index 0cd615c1cdb5..0fc4656831af 100644 --- a/src/lib_mockup/migration.mli +++ b/src/lib_mockup/migration.mli @@ -27,6 +27,6 @@ The effect is protocol-dependent. *) val migrate_mockup : cctxt:Tezos_client_base.Client_context.full -> - protocol_hash:Tezos_base.TzPervasives.Protocol_hash.t option -> - next_protocol_hash:Tezos_base.TzPervasives.Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t option -> + next_protocol_hash:Tezos_crypto.Protocol_hash.t -> unit tzresult Lwt.t diff --git a/src/lib_mockup/mockup_args.ml b/src/lib_mockup/mockup_args.ml index 17f2bfefdc09..ecc425edd405 100644 --- a/src/lib_mockup/mockup_args.ml +++ b/src/lib_mockup/mockup_args.ml @@ -24,7 +24,7 @@ (*****************************************************************************) module Chain_id = struct - let of_string s = Chain_id.hash_string ~key:"mockup" [s] + let of_string s = Tezos_crypto.Chain_id.hash_string ~key:"mockup" [s] let dummy = of_string "chain" diff --git a/src/lib_mockup/mockup_args.mli b/src/lib_mockup/mockup_args.mli index 9ef4a1789acd..4c8c25bafbb1 100644 --- a/src/lib_mockup/mockup_args.mli +++ b/src/lib_mockup/mockup_args.mli @@ -29,13 +29,13 @@ module Chain_id : sig ** This function is useful to get valid, but dummy, chain identifiers out of ** command lines in the context of a mockup client. *) - val of_string : string -> Chain_id.t + val of_string : string -> Tezos_crypto.Chain_id.t (** [dummy] is a valid dummy chain identifier. ** ** Do not use it outside of the context of a mockup client. *) - val dummy : Chain_id.t + val dummy : Tezos_crypto.Chain_id.t (** [choose ~from_config_file] ** produces a valid chain id from the optionally given one. @@ -44,5 +44,6 @@ module Chain_id : sig ** one from the config file. ** When both values are [None], it uses the {!dummy}. *) - val choose : from_config_file:Chain_id.t option -> Chain_id.t + val choose : + from_config_file:Tezos_crypto.Chain_id.t option -> Tezos_crypto.Chain_id.t end diff --git a/src/lib_mockup/mockup_commands.ml b/src/lib_mockup/mockup_commands.ml index 7e3ae309494d..1cd06cf40a73 100644 --- a/src/lib_mockup/mockup_commands.ml +++ b/src/lib_mockup/mockup_commands.ml @@ -34,7 +34,7 @@ let list_mockup_command_handler _ _ = List.iter (fun (mockup : (module Registration.MOCKUP)) -> let module Mockup = (val mockup) in - Format.printf "%a@." Protocol_hash.pp Mockup.protocol_hash) + Format.printf "%a@." Tezos_crypto.Protocol_hash.pp Mockup.protocol_hash) available ; Lwt_result_syntax.return_unit @@ -50,7 +50,7 @@ let list_mockup_command : let migrate_mockup_command_handler () next_protococol_hash (cctxt : Tezos_client_base.Client_context.full) = - match Protocol_hash.of_b58check next_protococol_hash with + match Tezos_crypto.Protocol_hash.of_b58check next_protococol_hash with | Error _ as result -> Lwt.return result | Ok next_protocol_hash -> Migration.migrate_mockup ~cctxt ~protocol_hash:None ~next_protocol_hash diff --git a/src/lib_mockup/mockup_wallet.ml b/src/lib_mockup/mockup_wallet.ml index 7e8d1826dc43..1c817d0a267c 100644 --- a/src/lib_mockup/mockup_wallet.ml +++ b/src/lib_mockup/mockup_wallet.ml @@ -68,7 +68,10 @@ let add_bootstrap_secret cctxt {name; sk_uri} = Client_keys.import_secret_key ~io:(cctxt :> Client_context.io_wallet) pk_uri in let*! () = - cctxt#message "Tezos address added: %a" Signature.Public_key_hash.pp pkh + cctxt#message + "Tezos address added: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh in Client_keys.register_key cctxt ~force (pkh, pk_uri, sk_uri) ?public_key name diff --git a/src/lib_mockup/persistence.ml b/src/lib_mockup/persistence.ml index 8d0b7dde126d..83845c1c926a 100644 --- a/src/lib_mockup/persistence.ml +++ b/src/lib_mockup/persistence.ml @@ -46,14 +46,14 @@ module Make (Registration : Registration.S) = struct (fun (block_hash, block_header, context) -> {block_hash; block_header; context}) (obj3 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "shell_header" Block_header.shell_header_encoding) (req "context" Memory_context.encoding)) module Persistent_mockup_environment = struct type t = { - protocol_hash : Protocol_hash.t; - chain_id : Chain_id.t; + protocol_hash : Tezos_crypto.Protocol_hash.t; + chain_id : Tezos_crypto.Chain_id.t; rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : bytes; } @@ -66,8 +66,8 @@ module Make (Registration : Registration.S) = struct (fun (protocol_hash, chain_id, rpc_context, protocol_data) -> {protocol_hash; chain_id; rpc_context; protocol_data}) (obj4 - (req "protocol_hash" Protocol_hash.encoding) - (req "chain_id" Chain_id.encoding) + (req "protocol_hash" Tezos_crypto.Protocol_hash.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (req "context" rpc_context_encoding) (req "protocol_data" Variable.bytes)) @@ -76,7 +76,8 @@ module Make (Registration : Registration.S) = struct let of_json = Data_encoding.Json.destruct encoding end - let get_registered_mockup (protocol_hash_opt : Protocol_hash.t option) + let get_registered_mockup + (protocol_hash_opt : Tezos_crypto.Protocol_hash.t option) (printer : #Tezos_client_base.Client_context.printer) : Registration.mockup_environment tzresult Lwt.t = let open Lwt_result_syntax in @@ -84,11 +85,11 @@ module Make (Registration : Registration.S) = struct let hash_is_of_mockup hash (module Mockup : Registration.MOCKUP) = match hash with | Some protocol_hash -> - Protocol_hash.equal protocol_hash Mockup.protocol_hash + Tezos_crypto.Protocol_hash.equal protocol_hash Mockup.protocol_hash | None -> Re.Str.string_match is_proto_alpha_regexp - (Protocol_hash.to_b58check Mockup.protocol_hash) + (Tezos_crypto.Protocol_hash.to_b58check Mockup.protocol_hash) 0 in let*! () = @@ -107,7 +108,7 @@ module Make (Registration : Registration.S) = struct | Some requested -> Format.asprintf "Requested protocol with hash %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp requested | None -> "Default protocol Alpha (no requested protocol)" in @@ -123,7 +124,7 @@ module Make (Registration : Registration.S) = struct Format.( pp_print_list ~pp_sep:(fun fmt () -> fprintf fmt ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) protocol_hashes let default_mockup_context : @@ -145,7 +146,7 @@ module Make (Registration : Registration.S) = struct let init_mockup_context_by_protocol_hash : cctxt:Tezos_client_base.Client_context.printer -> - protocol_hash:Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> constants_overrides_json:Data_encoding.json option -> bootstrap_accounts_json:Data_encoding.json option -> (Registration.mockup_environment * Registration.mockup_context) tzresult @@ -238,7 +239,7 @@ module Make (Registration : Registration.S) = struct match protocol_hash with | None -> return_unit | Some desired_protocol - when Protocol_hash.equal + when Tezos_crypto.Protocol_hash.equal Mockup_environment.protocol_hash desired_protocol -> return_unit @@ -246,10 +247,10 @@ module Make (Registration : Registration.S) = struct failwith "Protocol %a was requested via --protocol\n\ yet the mockup at %s was initialized with %a" - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short desired_protocol base_dir - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Mockup_environment.protocol_hash in return res diff --git a/src/lib_mockup/persistence_intf.ml b/src/lib_mockup/persistence_intf.ml index f523a7239dc6..c5bbabc97f03 100644 --- a/src/lib_mockup/persistence_intf.ml +++ b/src/lib_mockup/persistence_intf.ml @@ -25,7 +25,7 @@ module type S = sig val get_registered_mockup : - Protocol_hash.t option -> + Tezos_crypto.Protocol_hash.t option -> #Tezos_client_base.Client_context.printer -> Registration.mockup_environment tzresult Lwt.t @@ -39,7 +39,7 @@ module type S = sig (** Returns a mockup environment for the specified protocol hash. *) val init_mockup_context_by_protocol_hash : cctxt:Tezos_client_base.Client_context.printer -> - protocol_hash:Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> constants_overrides_json:Data_encoding.json option -> bootstrap_accounts_json:Data_encoding.json option -> (Registration.mockup_environment * Registration.mockup_context) tzresult @@ -50,7 +50,7 @@ module type S = sig loaded environment agrees with it. *) val get_mockup_context_from_disk : base_dir:string -> - protocol_hash:Protocol_hash.t option -> + protocol_hash:Tezos_crypto.Protocol_hash.t option -> #Tezos_client_base.Client_context.printer -> (Registration.mockup_environment * Registration.mockup_context) tzresult Lwt.t @@ -59,7 +59,7 @@ module type S = sig protocol. *) val create_mockup : cctxt:Tezos_client_base.Client_context.full -> - protocol_hash:Protocol_hash.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> constants_overrides_json:Data_encoding.json option -> bootstrap_accounts_json:Data_encoding.json option -> asynchronous:bool -> @@ -67,8 +67,8 @@ module type S = sig (** Overwrites an on-disk mockup environment. *) val overwrite_mockup : - protocol_hash:Protocol_hash.t -> - chain_id:Chain_id.t -> + protocol_hash:Tezos_crypto.Protocol_hash.t -> + chain_id:Tezos_crypto.Chain_id.t -> rpc_context:Tezos_protocol_environment.rpc_context -> protocol_data:bytes -> base_dir:string -> diff --git a/src/lib_mockup/registration_intf.ml b/src/lib_mockup/registration_intf.ml index 76a693b7a73d..6efe791a34d4 100644 --- a/src/lib_mockup/registration_intf.ml +++ b/src/lib_mockup/registration_intf.ml @@ -25,7 +25,7 @@ (** Type of a mockup environment *) type t = { - chain : Chain_id.t; + chain : Tezos_crypto.Chain_id.t; rpc_context : Tezos_protocol_environment.rpc_context; protocol_data : bytes; } @@ -33,7 +33,7 @@ type t = { type mockup_context = t module type PROTOCOL = sig - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t include Tezos_protocol_environment.PROTOCOL end @@ -60,7 +60,7 @@ module type MOCKUP = sig val default_bootstrap_accounts : Tezos_client_base.Client_context.full -> string tzresult Lwt.t - val protocol_hash : Protocol_hash.t + val protocol_hash : Tezos_crypto.Protocol_hash.t module Protocol : PROTOCOL diff --git a/src/lib_mockup/test/test_mockup_args.ml b/src/lib_mockup/test/test_mockup_args.ml index 4c0dbf5e13ad..55f5a33333a6 100644 --- a/src/lib_mockup/test/test_mockup_args.ml +++ b/src/lib_mockup/test/test_mockup_args.ml @@ -35,7 +35,8 @@ open Tezos_mockup_registration.Mockup_args let testable_chain_id = Alcotest.testable Tezos_crypto.Chain_id.pp Tezos_crypto.Chain_id.( = ) -(** {!val:Chain_id.choose} uses the dummy value if no config file is specified *) +(** {!val:Tezos_crypto.Chain_id.choose} uses the dummy value if no config file + is specified *) let test_no_config_file_dummy () = let expected = Chain_id.dummy in let actual = Chain_id.choose ~from_config_file:None in diff --git a/src/lib_mockup/test/test_persistence.ml b/src/lib_mockup/test/test_persistence.ml index 7b96c9446fe8..54dc35bb87da 100644 --- a/src/lib_mockup/test/test_persistence.ml +++ b/src/lib_mockup/test/test_persistence.ml @@ -91,7 +91,7 @@ module Mock_protocol : Registration.PROTOCOL = struct open Tezos_protocol_environment.Internal_for_tests include Environment_protocol_T_test.Mock_all_unit - let hash = Protocol_hash.hash_string [""] + let hash = Tezos_crypto.Protocol_hash.hash_string [""] end module Mock_mockup : Registration.MOCKUP = struct @@ -124,7 +124,7 @@ module Mock_mockup : Registration.MOCKUP = struct let migrate _ = assert false end -let mock_mockup_module (protocol_hash' : Protocol_hash.t) : +let mock_mockup_module (protocol_hash' : Tezos_crypto.Protocol_hash.t) : (module Registration.MOCKUP) = (module struct include Mock_mockup @@ -179,9 +179,9 @@ let test_get_registered_mockup_not_found = (fun () -> let module Registration = Registration.Internal_for_tests.Make () in let module Persistence = Persistence.Internal_for_tests.Make (Registration) in - let proto_hash_1 = Protocol_hash.hash_string ["mock1"] in - let proto_hash_2 = Protocol_hash.hash_string ["mock2"] in - let proto_hash_3 = Protocol_hash.hash_string ["mock3"] in + let proto_hash_1 = Tezos_crypto.Protocol_hash.hash_string ["mock1"] in + let proto_hash_2 = Tezos_crypto.Protocol_hash.hash_string ["mock2"] in + let proto_hash_3 = Tezos_crypto.Protocol_hash.hash_string ["mock3"] in Registration.register_mockup_environment (mock_mockup_module proto_hash_1) ; Registration.register_mockup_environment (mock_mockup_module proto_hash_2) ; let*! r = @@ -197,11 +197,11 @@ let test_get_registered_mockup_not_found = Format.asprintf "Requested protocol with hash %a not found in available mockup \ environments. Available protocol hashes: [%a, %a]" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto_hash_3 - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto_hash_2 - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto_hash_1 in return @@ -222,19 +222,21 @@ let test_get_registered_mockup_take_alpha = let module Registration = Registration.Internal_for_tests.Make () in let module Persistence = Persistence.Internal_for_tests.Make (Registration) in let printer = mock_printer () in - let proto_hash_1 = Protocol_hash.hash_string ["mock1"] in + let proto_hash_1 = Tezos_crypto.Protocol_hash.hash_string ["mock1"] in let proto_hash_alpha = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK" in - let proto_hash_3 = Protocol_hash.hash_string ["mock3"] in + let proto_hash_3 = Tezos_crypto.Protocol_hash.hash_string ["mock3"] in Registration.register_mockup_environment (mock_mockup_module proto_hash_1) ; Registration.register_mockup_environment (mock_mockup_module proto_hash_alpha) ; Registration.register_mockup_environment (mock_mockup_module proto_hash_3) ; let+ (module Result) = Persistence.get_registered_mockup None printer in Alcotest.check' - (Alcotest.testable Protocol_hash.pp Protocol_hash.equal) + (Alcotest.testable + Tezos_crypto.Protocol_hash.pp + Tezos_crypto.Protocol_hash.equal) ~msg:"The Alpha protocol is returned" ~expected:proto_hash_alpha ~actual:Result.protocol_hash ; @@ -254,15 +256,17 @@ let test_get_registered_mockup_take_requested = (fun () -> let module Registration = Registration.Internal_for_tests.Make () in let module Persistence = Persistence.Internal_for_tests.Make (Registration) in - let proto_hash_1 = Protocol_hash.hash_string ["mock1"] in - let proto_hash_2 = Protocol_hash.hash_string ["mock2"] in + let proto_hash_1 = Tezos_crypto.Protocol_hash.hash_string ["mock1"] in + let proto_hash_2 = Tezos_crypto.Protocol_hash.hash_string ["mock2"] in Registration.register_mockup_environment (mock_mockup_module proto_hash_1) ; Registration.register_mockup_environment (mock_mockup_module proto_hash_2) ; let+ (module Result) = Persistence.get_registered_mockup (Some proto_hash_1) (mock_printer ()) in Alcotest.check' - (Alcotest.testable Protocol_hash.pp Protocol_hash.equal) + (Alcotest.testable + Tezos_crypto.Protocol_hash.pp + Tezos_crypto.Protocol_hash.equal) ~msg:"The requested protocol is returned" ~expected:proto_hash_1 ~actual:Result.protocol_hash) -- GitLab From 4a212873d7e0d3eaef1f88ef5e0d55acfdd67905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 10:02:39 +0200 Subject: [PATCH 14/30] Porxy: unopen Crypto --- src/lib_proxy/light.ml | 2 +- src/lib_proxy/light.mli | 2 +- src/lib_proxy/proxy_commands.ml | 2 +- src/lib_proxy/proxy_getter.ml | 5 +++-- src/lib_proxy/proxy_getter.mli | 4 ++-- src/lib_proxy/proxy_services.ml | 14 ++++++++------ src/lib_proxy/proxy_services.mli | 6 +++--- src/lib_proxy/registration.ml | 19 ++++++++++--------- src/lib_proxy/registration.mli | 6 +++--- src/lib_proxy/rpc/RPC_client.mli | 2 +- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/lib_proxy/light.ml b/src/lib_proxy/light.ml index 1d8f4ad409c0..927b904d7f9c 100644 --- a/src/lib_proxy/light.ml +++ b/src/lib_proxy/light.ml @@ -82,7 +82,7 @@ let sources_config_to_sources rpc_context_builder {min_agreement; uris} = {min_agreement; endpoints} let hash_of_block (block : Tezos_shell_services.Block_services.block) : - Block_hash.t option = + Tezos_crypto.Block_hash.t option = match block with | `Hash (h, 0) -> Some h | `Alias (_, _) | `Genesis | `Head _ | `Level _ | `Hash (_, _) -> None diff --git a/src/lib_proxy/light.mli b/src/lib_proxy/light.mli index e604659cb653..49acf6166caa 100644 --- a/src/lib_proxy/light.mli +++ b/src/lib_proxy/light.mli @@ -72,4 +72,4 @@ val sources_config_to_sources : (** [None] if the given block is symbolic, otherwise its concrete hash. *) val hash_of_block : - Tezos_shell_services.Block_services.block -> Block_hash.t option + Tezos_shell_services.Block_services.block -> Tezos_crypto.Block_hash.t option diff --git a/src/lib_proxy/proxy_commands.ml b/src/lib_proxy/proxy_commands.ml index 00b559612293..94c3ffc9baea 100644 --- a/src/lib_proxy/proxy_commands.ml +++ b/src/lib_proxy/proxy_commands.ml @@ -31,7 +31,7 @@ let group : Tezos_clic.group = let list_proxy_command_handler _ _ = List.iter (fun (module Proxy : Registration.Proxy_sig) -> - Format.printf "%a@." Protocol_hash.pp Proxy.protocol_hash) + Format.printf "%a@." Tezos_crypto.Protocol_hash.pp Proxy.protocol_hash) @@ Registration.get_all_registered () ; Lwt_result_syntax.return_unit diff --git a/src/lib_proxy/proxy_getter.ml b/src/lib_proxy/proxy_getter.ml index e23914b5ce7e..fd784fe2350a 100644 --- a/src/lib_proxy/proxy_getter.ml +++ b/src/lib_proxy/proxy_getter.ml @@ -125,7 +125,7 @@ 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 -> + (Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) type rpc_context_args = { @@ -140,7 +140,8 @@ type rpc_context_args = { module StringMap = String.Map let make_delegate (ctx : rpc_context_args) - (proto_rpc : (module Proxy_proto.PROTO_RPC)) (hash : Context_hash.t) : + (proto_rpc : (module Proxy_proto.PROTO_RPC)) + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t = match ctx.proxy_builder with | Of_rpc f -> diff --git a/src/lib_proxy/proxy_getter.mli b/src/lib_proxy/proxy_getter.mli index dc12bab56cc6..04494cfa7801 100644 --- a/src/lib_proxy/proxy_getter.mli +++ b/src/lib_proxy/proxy_getter.mli @@ -97,7 +97,7 @@ 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 -> + (Tezos_crypto.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. *) @@ -126,7 +126,7 @@ type rpc_context_args = { val make_delegate : rpc_context_args -> (module Proxy_proto.PROTO_RPC) -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t (** Functor to obtain the implementation of [M] for the proxy diff --git a/src/lib_proxy/proxy_services.ml b/src/lib_proxy/proxy_services.ml index 53418c2200ad..c1c15f437a0a 100644 --- a/src/lib_proxy/proxy_services.ml +++ b/src/lib_proxy/proxy_services.ml @@ -59,7 +59,7 @@ type mode = sleep : float -> unit Lwt.t; sym_block_caching_time : Ptime.span option; on_disk_proxy_builder : - (Context_hash.t -> + (Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) option; } @@ -76,17 +76,19 @@ let get_protocols ?expected_protocol rpc_context chain block = match expected_protocol with | None -> return protocols | Some proto_hash -> - if Protocol_hash.equal next_protocol proto_hash then return protocols + if Tezos_crypto.Protocol_hash.equal next_protocol proto_hash then + return protocols else failwith "Protocol passed to the proxy (%a) and protocol of the node (%a) \ differ." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto_hash - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp next_protocol -type env_cache_key = Tezos_shell_services.Chain_services.chain * Block_hash.t +type env_cache_key = + Tezos_shell_services.Chain_services.chain * Tezos_crypto.Block_hash.t module Env_cache_key_hashed_type : Stdlib.Hashtbl.HashedType with type t = env_cache_key = struct @@ -94,7 +96,7 @@ module Env_cache_key_hashed_type : let equal ((lchain, lblock) : t) ((rchain, rblock) : t) = (* Avoid using polymorphic equality *) - lchain = rchain && Block_hash.equal lblock rblock + lchain = rchain && Tezos_crypto.Block_hash.equal lblock rblock let hash = Hashtbl.hash end diff --git a/src/lib_proxy/proxy_services.mli b/src/lib_proxy/proxy_services.mli index 8f5307c1cdc0..149f67a59681 100644 --- a/src/lib_proxy/proxy_services.mli +++ b/src/lib_proxy/proxy_services.mli @@ -42,7 +42,7 @@ type mode = sleep : float -> unit Lwt.t; sym_block_caching_time : Ptime.span option; on_disk_proxy_builder : - (Context_hash.t -> + (Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Proxy_delegate.t tzresult Lwt.t) option; } @@ -50,7 +50,7 @@ type mode = by {!Lwt_unix.sleep}. We don't want to depend on it directly (for compiling to Javascript), hence this field. The [Ptime.span option] field is the value of argument [--sym-block-caching-time]. The - [(Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) option] + [(Tezos_crypto.Context_hash.t -> Proxy_delegate.t tzresult Lwt.t) option] value is constructed from argument [--data-dir]: if the argument is present, this value represents how data is looked up in the data-dir of a running node. *) @@ -68,5 +68,5 @@ val build_directory : Tezos_client_base.Client_context.printer -> Tezos_rpc.Context.generic -> mode -> - Protocol_hash.t option -> + Tezos_crypto.Protocol_hash.t option -> unit Tezos_rpc.Directory.t diff --git a/src/lib_proxy/registration.ml b/src/lib_proxy/registration.ml index aeabe2b0c5cc..a039c8aa6782 100644 --- a/src/lib_proxy/registration.ml +++ b/src/lib_proxy/registration.ml @@ -26,7 +26,7 @@ open Tezos_shell_services module type Proxy_sig = sig - val protocol_hash : Protocol_hash.t + val protocol_hash : Tezos_crypto.Protocol_hash.t (** RPCs provided by the protocol *) val directory : Tezos_protocol_environment.rpc_context Tezos_rpc.Directory.t @@ -34,7 +34,7 @@ module type Proxy_sig = sig (** How to build the context to execute RPCs on *) val initial_context : Proxy_getter.rpc_context_args -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t val time_between_blocks : @@ -55,27 +55,28 @@ let register_proxy_context m = if List.exists (fun (module P : Proxy_sig) -> - Protocol_hash.(P.protocol_hash = INCOMING_P.protocol_hash)) + Tezos_crypto.Protocol_hash.(P.protocol_hash = INCOMING_P.protocol_hash)) !registered then raise @@ Invalid_argument (Format.asprintf "A proxy environment for protocol %a is registered already" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp INCOMING_P.protocol_hash) else registered := m :: !registered let get_all_registered () : proxy_environment list = !registered let get_registered_proxy (printer : Tezos_client_base.Client_context.printer) - (protocol_hash : Protocol_hash.t) : proxy_environment tzresult Lwt.t = + (protocol_hash : Tezos_crypto.Protocol_hash.t) : + proxy_environment tzresult Lwt.t = let open Lwt_result_syntax in let available = !registered in let proxy_opt = List.find_opt (fun (module Proxy : Proxy_sig) -> - Protocol_hash.equal protocol_hash Proxy.protocol_hash) + Tezos_crypto.Protocol_hash.equal protocol_hash Proxy.protocol_hash) available in match proxy_opt with @@ -96,14 +97,14 @@ let get_registered_proxy (printer : Tezos_client_base.Client_context.printer) Proceeding with the first available protocol (%a). This will \ work if the mismatch is harmless, otherwise deserialization is \ the failure most likely to happen." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol_hash (Format.pp_print_list ~pp_sep:Format.pp_print_space - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) ((List.map (fun (module P : Proxy_sig) -> P.protocol_hash)) available) - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp fst_available_proto in return fst_available) diff --git a/src/lib_proxy/registration.mli b/src/lib_proxy/registration.mli index 96493398b918..c6abf652f1b9 100644 --- a/src/lib_proxy/registration.mli +++ b/src/lib_proxy/registration.mli @@ -29,7 +29,7 @@ open Tezos_shell_services prepared protocol-side and registered here to become available to the proxy facility. *) module type Proxy_sig = sig - val protocol_hash : Protocol_hash.t + val protocol_hash : Tezos_crypto.Protocol_hash.t (** RPCs provided by the protocol *) val directory : Tezos_protocol_environment.rpc_context Tezos_rpc.Directory.t @@ -44,7 +44,7 @@ module type Proxy_sig = sig *) val initial_context : Proxy_getter.rpc_context_args -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tezos_protocol_environment.Context.t tzresult Lwt.t (** The [time_between_blocks] constant for the given block, if any. *) @@ -72,5 +72,5 @@ val get_all_registered : unit -> proxy_environment list (** Returns a proxy environment for the given protocol. *) val get_registered_proxy : Tezos_client_base.Client_context.printer -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> proxy_environment tzresult Lwt.t diff --git a/src/lib_proxy/rpc/RPC_client.mli b/src/lib_proxy/rpc/RPC_client.mli index 4e47edf417f8..2c1178c2bb85 100644 --- a/src/lib_proxy/rpc/RPC_client.mli +++ b/src/lib_proxy/rpc/RPC_client.mli @@ -33,5 +33,5 @@ class http_local_ctxt : Tezos_client_base.Client_context.printer -> Tezos_rpc.Context.generic -> Tezos_proxy.Proxy_services.mode - -> Protocol_hash.t option + -> Tezos_crypto.Protocol_hash.t option -> Tezos_rpc.Context.generic -- GitLab From 2ecc009538cacf18861dcf00d1f56a0ea442d72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 10:03:18 +0200 Subject: [PATCH 15/30] Client-libs: unopen Crypto --- src/lib_client_base/bip39.ml | 3 +- src/lib_client_base/client_confirmations.ml | 44 ++++--- src/lib_client_base/client_confirmations.mli | 16 +-- src/lib_client_base/client_keys.ml | 90 ++++++++------ src/lib_client_base/client_keys.mli | 113 +++++++++++------- src/lib_client_base/pbkdf.ml | 6 +- src/lib_client_base/pbkdf.mli | 2 +- src/lib_client_base/test/pbkdf_tests.ml | 9 +- src/lib_client_base_unix/client_config.ml | 18 ++- .../client_context_unix.mli | 4 +- src/lib_client_base_unix/client_main_run.ml | 8 +- .../client_admin_commands.ml | 18 +-- src/lib_client_commands/client_commands.ml | 10 +- src/lib_client_commands/client_commands.mli | 9 +- .../client_keys_commands.ml | 90 ++++++++------ .../client_report_commands.ml | 4 +- 16 files changed, 263 insertions(+), 181 deletions(-) diff --git a/src/lib_client_base/bip39.ml b/src/lib_client_base/bip39.ml index cbcc68940b48..fea5acc58aeb 100644 --- a/src/lib_client_base/bip39.ml +++ b/src/lib_client_base/bip39.ml @@ -4,7 +4,6 @@ ---------------------------------------------------------------------------*) open StdLabels -open Tezos_crypto let acceptable_num_words = [12; 15; 18; 21; 24] @@ -110,7 +109,7 @@ let of_entropy entropy = match entropy_of_bytes entropy with | None -> invalid_arg "Bip39.of_entropy: wrong entropy length" | Some {bytes; digest_length; _} -> - let digest = Bytes.get (Hacl.Hash.SHA256.digest entropy) 0 in + let digest = Bytes.get (Tezos_crypto.Hacl.Hash.SHA256.digest entropy) 0 in let digest = list_sub (bits_of_char digest) digest_length in let entropy = bits_of_bytes bytes @ digest in List.map (pack entropy 11) ~f:int_of_bits diff --git a/src/lib_client_base/client_confirmations.ml b/src/lib_client_base/client_confirmations.ml index 3eecb9fabe73..abca8ba1ed6a 100644 --- a/src/lib_client_base/client_confirmations.ml +++ b/src/lib_client_base/client_confirmations.ml @@ -30,14 +30,15 @@ let in_block operation_hash operations = (fun i ops -> List.iteri (fun j op -> - if Operation_hash.equal operation_hash op then raise (Found (i, j))) + if Tezos_crypto.Operation_hash.equal operation_hash op then + raise (Found (i, j))) ops) operations ; None with Found (i, j) -> Some (i, j) type operation_status = - | Confirmed of (Block_hash.t * int * int) + | Confirmed of (Tezos_crypto.Block_hash.t * int * int) | Pending | Still_not_found @@ -45,20 +46,22 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain ?(predecessors = 10) ?(confirmations = 1) ?branch operation_hash = let open Lwt_result_syntax in let exception WrapError of error list in - let exception Outdated of Operation_hash.t in + let exception Outdated of Tezos_crypto.Operation_hash.t in (* Table of known blocks: - None: if neither the block or its predecessors contains the operation - (Some ((hash, i, j), n)): if the `hash` contains the operation in list `i` at position `j` and if `hash` denotes the `n-th` predecessors of the block. *) - let blocks : ((Block_hash.t * int * int) * int) option Block_hash.Table.t = - Block_hash.Table.create ~random:true confirmations + let blocks : + ((Tezos_crypto.Block_hash.t * int * int) * int) option + Tezos_crypto.Block_hash.Table.t = + Tezos_crypto.Block_hash.Table.create ~random:true confirmations in (* Fetch _all_ the 'unknown' predecessors af a block. *) let fetch_predecessors (hash, header) = let rec loop acc (_hash, header) = let predecessor = header.Block_header.predecessor in - if Block_hash.Table.mem blocks predecessor then return acc + if Tezos_crypto.Block_hash.Table.mem blocks predecessor then return acc else let* shell = Chain_services.Blocks.Header.shell_header @@ -90,7 +93,7 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain let predecessor = header.Tezos_base.Block_header.predecessor in let pred_block = WithExceptions.Option.to_exn ~none:Not_found - @@ Block_hash.Table.find blocks predecessor + @@ Tezos_crypto.Block_hash.Table.find blocks predecessor in match pred_block with | Some (block_with_op, n) -> @@ -98,10 +101,13 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain ctxt#answer "Operation received %d confirmations as of block: %a" (n + 1) - Block_hash.pp + Tezos_crypto.Block_hash.pp hash in - Block_hash.Table.add blocks hash (Some (block_with_op, n + 1)) ; + Tezos_crypto.Block_hash.Table.add + blocks + hash + (Some (block_with_op, n + 1)) ; if n + 1 < confirmations then return Pending else return (Confirmed block_with_op) | None -> ( @@ -114,18 +120,21 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain in match in_block operation_hash operations with | None -> - Block_hash.Table.add blocks hash None ; + Tezos_crypto.Block_hash.Table.add blocks hash None ; return Still_not_found | Some (i, j) -> let*! () = ctxt#answer "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash i j in - Block_hash.Table.add blocks hash (Some ((hash, i, j), 0)) ; + Tezos_crypto.Block_hash.Table.add + blocks + hash + (Some ((hash, i, j), 0)) ; if confirmations <= 0 then return (Confirmed (hash, i, j)) else return Pending) in @@ -138,14 +147,15 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain in match r with | Ok live_blocks -> - if Block_hash.Set.mem branch_hash live_blocks then Lwt.return_unit + if Tezos_crypto.Block_hash.Set.mem branch_hash live_blocks then + Lwt.return_unit else let*! () = ctxt#error "The operation %a is outdated and may never be included in \ the chain.@,\ We recommend to use an external block explorer." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp operation_hash in Lwt.fail (Outdated operation_hash) @@ -198,7 +208,7 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain | None -> failwith "..." | Some (hash, _) -> ( stop () ; - match Block_hash.Table.find blocks hash with + match Tezos_crypto.Block_hash.Table.find blocks hash with | None | Some None -> assert false | Some (Some (hash, _)) -> return hash) in @@ -239,7 +249,7 @@ let wait_for_operation_inclusion (ctxt : #Client_context.full) ~chain ~block:(`Hash (head, block_hook + 1)) () in - Block_hash.Table.add blocks oldest None ; + Tezos_crypto.Block_hash.Table.add blocks oldest None ; loop block_hook let lookup_operation_in_previous_block ctxt chain operation_hash i = @@ -296,7 +306,7 @@ let wait_for_bootstrapped ?(retry = fun f x -> f x) if !display then ctxt#message "Current head: %a (timestamp: %a, validation: %a)" - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short hash Time.System.pp_hum (Time.System.of_protocol_exn time) diff --git a/src/lib_client_base/client_confirmations.mli b/src/lib_client_base/client_confirmations.mli index 725f2288c44a..76f60ebb13c7 100644 --- a/src/lib_client_base/client_confirmations.mli +++ b/src/lib_client_base/client_confirmations.mli @@ -35,9 +35,9 @@ val wait_for_operation_inclusion : chain:Chain_services.chain -> ?predecessors:int -> ?confirmations:int -> - ?branch:Block_hash.t -> - Operation_hash.t -> - (Block_hash.t * int * int) tzresult Lwt.t + ?branch:Tezos_crypto.Block_hash.t -> + Tezos_crypto.Operation_hash.t -> + (Tezos_crypto.Block_hash.t * int * int) tzresult Lwt.t (** lookup an operation in [predecessors] previous blocks, starting from head *) @@ -45,8 +45,8 @@ val lookup_operation_in_previous_blocks : #Client_context.full -> chain:Block_services.chain -> predecessors:int -> - Operation_list_hash.elt -> - (Block_hash.t * int * int) option tzresult Lwt.t + Tezos_crypto.Operation_list_hash.elt -> + (Tezos_crypto.Block_hash.t * int * int) option tzresult Lwt.t (** returns when the node consider itself as bootstrapped. @@ -57,11 +57,13 @@ val lookup_operation_in_previous_blocks : val wait_for_bootstrapped : ?retry: (((#Client_context.full as 'a) -> - ((Block_hash.t * Time.Protocol.t) Lwt_stream.t * Tezos_rpc.Context.stopper) + ((Tezos_crypto.Block_hash.t * Time.Protocol.t) Lwt_stream.t + * Tezos_rpc.Context.stopper) tzresult Lwt.t) -> 'a -> - ((Block_hash.t * Time.Protocol.t) Lwt_stream.t * Tezos_rpc.Context.stopper) + ((Tezos_crypto.Block_hash.t * Time.Protocol.t) Lwt_stream.t + * Tezos_rpc.Context.stopper) tzresult Lwt.t) -> 'a -> diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 698325146930..cdbff93eb2f0 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -67,11 +67,13 @@ let () = module Public_key_hash = struct include Client_aliases.Alias (struct (* includes t, Compare, encoding *) - include Signature.Public_key_hash + include Tezos_crypto.Signature.Public_key_hash - let of_source s = Lwt.return (Signature.Public_key_hash.of_b58check s) + let of_source s = + Lwt.return (Tezos_crypto.Signature.Public_key_hash.of_b58check s) - let to_source p = Lwt.return_ok (Signature.Public_key_hash.to_b58check p) + let to_source p = + Lwt.return_ok (Tezos_crypto.Signature.Public_key_hash.to_b58check p) let name = "public key hash" end) @@ -235,14 +237,14 @@ end) module Public_key = Client_aliases.Alias (struct let name = "public_key" - type t = pk_uri * Signature.Public_key.t option + type t = pk_uri * Tezos_crypto.Signature.Public_key.t option include Compare.Make (struct type nonrec t = t let compare (apk, aso) (bpk, bso) = Compare.or_else (CompareUri.compare apk bpk) (fun () -> - Option.compare Signature.Public_key.compare aso bso) + Option.compare Tezos_crypto.Signature.Public_key.compare aso bso) end) let of_source s = @@ -267,7 +269,7 @@ module Public_key = Client_aliases.Alias (struct ~title:"Locator_and_full_key" (obj2 (req "locator" uri_encoding) - (req "key" Signature.Public_key.encoding)) + (req "key" Tezos_crypto.Signature.Public_key.encoding)) (function uri, Some key -> Some (uri, key) | _, None -> None) (fun (uri, key) -> (uri, Some key)); ] @@ -325,7 +327,7 @@ module Aggregate_alias = struct module Public_key_hash = struct include Client_aliases.Alias (struct (* includes t, Compare, encoding, of/to_b58check *) - include Aggregate_signature.Public_key_hash + include Tezos_crypto.Aggregate_signature.Public_key_hash let of_source s = Lwt.return (of_b58check s) @@ -349,14 +351,17 @@ module Aggregate_alias = struct module Public_key = Client_aliases.Alias (struct let name = "Aggregate_public_key" - type t = pk_uri * Aggregate_signature.Public_key.t option + type t = pk_uri * Tezos_crypto.Aggregate_signature.Public_key.t option include Compare.Make (struct type nonrec t = t let compare (apk, aso) (bpk, bso) = Compare.or_else (CompareUri.compare apk bpk) (fun () -> - Option.compare Aggregate_signature.Public_key.compare aso bso) + Option.compare + Tezos_crypto.Aggregate_signature.Public_key.compare + aso + bso) end) let of_source s = @@ -381,7 +386,7 @@ module Aggregate_alias = struct ~title:"Locator_and_full_key" (obj2 (req "locator" uri_encoding) - (req "key" Aggregate_signature.Public_key.encoding)) + (req "key" Tezos_crypto.Aggregate_signature.Public_key.encoding)) (function uri, Some key -> Some (uri, key) | _, None -> None) (fun (uri, key) -> (uri, Some key)); ] @@ -412,7 +417,7 @@ module Aggregate_alias = struct end module Make_common_type (S : sig - include S.COMMON_SIGNATURE + include Tezos_crypto.S.COMMON_SIGNATURE type pk_uri @@ -431,7 +436,7 @@ struct end module Signature_type = Make_common_type (struct - include Signature + include Tezos_crypto.Signature type nonrec pk_uri = pk_uri @@ -439,7 +444,7 @@ module Signature_type = Make_common_type (struct end) module Aggregate_type = Make_common_type (struct - include Aggregate_signature + include Tezos_crypto.Aggregate_signature type pk_uri = aggregate_pk_uri @@ -479,17 +484,17 @@ end module type SIGNER = sig include COMMON_SIGNER - with type public_key_hash = Signature.Public_key_hash.t - and type public_key = Signature.Public_key.t - and type secret_key = Signature.Secret_key.t + with type public_key_hash = Tezos_crypto.Signature.Public_key_hash.t + and type public_key = Tezos_crypto.Signature.Public_key.t + and type secret_key = Tezos_crypto.Signature.Secret_key.t and type pk_uri = pk_uri and type sk_uri = sk_uri val sign : - ?watermark:Signature.watermark -> + ?watermark:Tezos_crypto.Signature.watermark -> sk_uri -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val deterministic_nonce : sk_uri -> Bytes.t -> Bytes.t tzresult Lwt.t @@ -501,13 +506,17 @@ end module type AGGREGATE_SIGNER = sig include COMMON_SIGNER - with type public_key_hash = Aggregate_signature.Public_key_hash.t - and type public_key = Aggregate_signature.Public_key.t - and type secret_key = Aggregate_signature.Secret_key.t + with type public_key_hash = + Tezos_crypto.Aggregate_signature.Public_key_hash.t + and type public_key = Tezos_crypto.Aggregate_signature.Public_key.t + and type secret_key = Tezos_crypto.Aggregate_signature.Secret_key.t and type pk_uri = aggregate_pk_uri and type sk_uri = aggregate_sk_uri - val sign : aggregate_sk_uri -> Bytes.t -> Aggregate_signature.t tzresult Lwt.t + val sign : + aggregate_sk_uri -> + Bytes.t -> + Tezos_crypto.Aggregate_signature.t tzresult Lwt.t end type signer = @@ -628,7 +637,7 @@ let sign cctxt ?watermark sk_uri buf = in let* () = fail_unless - (Signature.check ?watermark pubkey signature buf) + (Tezos_crypto.Signature.check ?watermark pubkey signature buf) (Signature_mismatch sk_uri) in return signature) @@ -636,12 +645,12 @@ let sign cctxt ?watermark sk_uri buf = let append cctxt ?watermark loc buf = let open Lwt_result_syntax in let+ signature = sign cctxt ?watermark loc buf in - Signature.concat buf signature + Tezos_crypto.Signature.concat buf signature let check ?watermark pk_uri signature buf = let open Lwt_result_syntax in let* pk = public_key pk_uri in - return (Signature.check ?watermark pk signature buf) + return (Tezos_crypto.Signature.check ?watermark pk signature buf) let deterministic_nonce sk_uri data = with_scheme_simple_signer sk_uri (fun (module Signer : SIGNER) -> @@ -705,7 +714,8 @@ let raw_get_key_aux (cctxt : #Client_context.wallet) pkhs pks sks pkh = let rev_find_all list pkh = List.filter_map (fun (name, pkh') -> - if Signature.Public_key_hash.equal pkh pkh' then Some name else None) + if Tezos_crypto.Signature.Public_key_hash.equal pkh pkh' then Some name + else None) list in let*! r = @@ -731,7 +741,7 @@ let raw_get_key_aux (cctxt : #Client_context.wallet) pkhs pks sks pkh = | None -> failwith "no keys for the source contract %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh | Some keys -> return keys in @@ -741,7 +751,7 @@ let raw_get_key_aux (cctxt : #Client_context.wallet) pkhs pks sks pkh = let*! r = let*? signer = find_simple_signer_for_key ~scheme:"remote" in let module Signer = (val signer : SIGNER) in - let path = Signature.Public_key_hash.to_b58check pkh in + let path = Tezos_crypto.Signature.Public_key_hash.to_b58check pkh in let uri = Uri.make ~scheme:Signer.scheme ~path () in let* pk = Signer.public_key uri in return (path, Some pk, Some uri) @@ -764,9 +774,15 @@ let get_key cctxt pkh = match r with | pkh, Some pk, Some sk -> return (pkh, pk, sk) | _pkh, _pk, None -> - failwith "Unknown secret key for %a" Signature.Public_key_hash.pp pkh + failwith + "Unknown secret key for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh | _pkh, None, _sk -> - failwith "Unknown public key for %a" Signature.Public_key_hash.pp pkh + failwith + "Unknown public key for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let get_public_key cctxt pkh = let open Lwt_result_syntax in @@ -774,7 +790,10 @@ let get_public_key cctxt pkh = match r with | pkh, Some pk, _sk -> return (pkh, pk) | _pkh, None, _sk -> - failwith "Unknown public key for %a" Signature.Public_key_hash.pp pkh + failwith + "Unknown public key for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let get_keys (cctxt : #Client_context.wallet) = let open Lwt_result_syntax in @@ -855,7 +874,8 @@ let raw_get_aggregate_key_aux (cctxt : #Client_context.wallet) pkhs pks sks pkh let rev_find_all list pkh = List.filter_map (fun (name, pkh') -> - if Aggregate_signature.Public_key_hash.equal pkh pkh' then Some name + if Tezos_crypto.Aggregate_signature.Public_key_hash.equal pkh pkh' then + Some name else None) list in @@ -883,7 +903,7 @@ let raw_get_aggregate_key_aux (cctxt : #Client_context.wallet) pkhs pks sks pkh | None -> failwith "no keys for the source contract %a" - Aggregate_signature.Public_key_hash.pp + Tezos_crypto.Aggregate_signature.Public_key_hash.pp pkh | Some keys -> return keys @@ -941,13 +961,13 @@ let aggregate_sign cctxt sk_uri buf = in let* () = fail_unless - (Aggregate_signature.check pubkey signature buf) + (Tezos_crypto.Aggregate_signature.check pubkey signature buf) (Signature_mismatch sk_uri) in return signature) module Mnemonic = struct - let new_random = Bip39.of_entropy (Hacl.Rand.gen 32) + let new_random = Bip39.of_entropy (Tezos_crypto.Hacl.Rand.gen 32) let to_32_bytes mnemonic = let seed_64_to_seed_32 (seed_64 : bytes) : bytes = diff --git a/src/lib_client_base/client_keys.mli b/src/lib_client_base/client_keys.mli index 5525c684c319..558ed7684a37 100644 --- a/src/lib_client_base/client_keys.mli +++ b/src/lib_client_base/client_keys.mli @@ -67,10 +67,11 @@ type error += Unregistered_key_scheme of string type error += Invalid_uri of Uri.t module Public_key_hash : - Client_aliases.Alias with type t = Signature.Public_key_hash.t + Client_aliases.Alias with type t = Tezos_crypto.Signature.Public_key_hash.t module Public_key : - Client_aliases.Alias with type t = pk_uri * Signature.Public_key.t option + Client_aliases.Alias + with type t = pk_uri * Tezos_crypto.Signature.Public_key.t option module Secret_key : Client_aliases.Alias with type t = sk_uri @@ -91,16 +92,18 @@ module Sapling_key : Client_aliases.Alias with type t = sapling_key standard signature (i.e. [Public_key], [Public_key_hash], and [Secret_key]). On possible refactor would be to move the alias definition in - [Aggregate_signature] (resp. [Signature]). + [Tezos_crypto.Aggregate_signature] (resp. [Tezos_crypto.Signature]). See [Client_aliases] for more information about Aliases.*) module Aggregate_alias : sig module Public_key_hash : - Client_aliases.Alias with type t = Aggregate_signature.Public_key_hash.t + Client_aliases.Alias + with type t = Tezos_crypto.Aggregate_signature.Public_key_hash.t module Public_key : Client_aliases.Alias - with type t = aggregate_pk_uri * Aggregate_signature.Public_key.t option + with type t = + aggregate_pk_uri * Tezos_crypto.Aggregate_signature.Public_key.t option module Secret_key : Client_aliases.Alias with type t = aggregate_sk_uri end @@ -161,11 +164,11 @@ end (** [Signature_type] is a small module to be included in signer to conform to the module type [SIGNER] instead of rewriting all type. *) module Signature_type : sig - type public_key_hash = Signature.Public_key_hash.t + type public_key_hash = Tezos_crypto.Signature.Public_key_hash.t - type public_key = Signature.Public_key.t + type public_key = Tezos_crypto.Signature.Public_key.t - type secret_key = Signature.Secret_key.t + type secret_key = Tezos_crypto.Signature.Secret_key.t type nonrec pk_uri = pk_uri @@ -173,11 +176,11 @@ module Signature_type : sig end module Aggregate_type : sig - type public_key_hash = Aggregate_signature.Public_key_hash.t + type public_key_hash = Tezos_crypto.Aggregate_signature.Public_key_hash.t - type public_key = Aggregate_signature.Public_key.t + type public_key = Tezos_crypto.Aggregate_signature.Public_key.t - type secret_key = Aggregate_signature.Secret_key.t + type secret_key = Tezos_crypto.Aggregate_signature.Secret_key.t type pk_uri = aggregate_pk_uri @@ -187,19 +190,19 @@ end module type SIGNER = sig include COMMON_SIGNER - with type public_key_hash = Signature.Public_key_hash.t - and type public_key = Signature.Public_key.t - and type secret_key = Signature.Secret_key.t + with type public_key_hash = Tezos_crypto.Signature.Public_key_hash.t + and type public_key = Tezos_crypto.Signature.Public_key.t + and type secret_key = Tezos_crypto.Signature.Secret_key.t and type pk_uri = pk_uri and type sk_uri = sk_uri (** [sign ?watermark sk data] is signature obtained by signing [data] with [sk]. *) val sign : - ?watermark:Signature.watermark -> + ?watermark:Tezos_crypto.Signature.watermark -> sk_uri -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t (** [deterministic_nonce sk data] is a nonce obtained deterministically from [data] and [sk]. *) @@ -217,14 +220,18 @@ end module type AGGREGATE_SIGNER = sig include COMMON_SIGNER - with type public_key_hash = Aggregate_signature.Public_key_hash.t - and type public_key = Aggregate_signature.Public_key.t - and type secret_key = Aggregate_signature.Secret_key.t + with type public_key_hash = + Tezos_crypto.Aggregate_signature.Public_key_hash.t + and type public_key = Tezos_crypto.Aggregate_signature.Public_key.t + and type secret_key = Tezos_crypto.Aggregate_signature.Secret_key.t and type pk_uri = aggregate_pk_uri and type sk_uri = aggregate_sk_uri (** [sign sk data] is signature obtained by signing [data] with [sk]. *) - val sign : aggregate_sk_uri -> Bytes.t -> Aggregate_signature.t tzresult Lwt.t + val sign : + aggregate_sk_uri -> + Bytes.t -> + Tezos_crypto.Aggregate_signature.t tzresult Lwt.t end type signer = @@ -244,34 +251,40 @@ val register_aggregate_signer : (module AGGREGATE_SIGNER) -> unit val import_secret_key : io:Client_context.io_wallet -> pk_uri -> - (Signature.Public_key_hash.t * Signature.Public_key.t option) tzresult Lwt.t + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key.t option) + tzresult + Lwt.t -val public_key : pk_uri -> Signature.Public_key.t tzresult Lwt.t +val public_key : pk_uri -> Tezos_crypto.Signature.Public_key.t tzresult Lwt.t val public_key_hash : pk_uri -> - (Signature.Public_key_hash.t * Signature.Public_key.t option) tzresult Lwt.t + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key.t option) + tzresult + Lwt.t val neuterize : sk_uri -> pk_uri tzresult Lwt.t val sign : #Client_context.wallet -> - ?watermark:Signature.watermark -> + ?watermark:Tezos_crypto.Signature.watermark -> sk_uri -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val append : #Client_context.wallet -> - ?watermark:Signature.watermark -> + ?watermark:Tezos_crypto.Signature.watermark -> sk_uri -> Bytes.t -> Bytes.t tzresult Lwt.t val check : - ?watermark:Signature.watermark -> + ?watermark:Tezos_crypto.Signature.watermark -> pk_uri -> - Signature.t -> + Tezos_crypto.Signature.t -> Bytes.t -> bool tzresult Lwt.t @@ -284,8 +297,8 @@ val supports_deterministic_nonces : sk_uri -> bool tzresult Lwt.t val register_key : #Client_context.wallet -> ?force:bool -> - Signature.Public_key_hash.t * pk_uri * sk_uri -> - ?public_key:Signature.Public_key.t -> + Tezos_crypto.Signature.Public_key_hash.t * pk_uri * sk_uri -> + ?public_key:Tezos_crypto.Signature.Public_key.t -> string -> unit tzresult Lwt.t @@ -294,8 +307,8 @@ val register_key : val register_keys : #Client_context.wallet -> (string - * Signature.Public_key_hash.t - * Signature.public_key + * Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.public_key * pk_uri * sk_uri) list -> @@ -303,7 +316,10 @@ val register_keys : val list_keys : #Client_context.wallet -> - (string * Public_key_hash.t * Signature.public_key option * sk_uri option) + (string + * Public_key_hash.t + * Tezos_crypto.Signature.public_key option + * sk_uri option) list tzresult Lwt.t @@ -311,23 +327,26 @@ val list_keys : val alias_keys : #Client_context.wallet -> string -> - (Public_key_hash.t * Signature.public_key option * sk_uri option) option + (Public_key_hash.t * Tezos_crypto.Signature.public_key option * sk_uri option) + option tzresult Lwt.t val get_key : #Client_context.wallet -> Public_key_hash.t -> - (string * Signature.Public_key.t * sk_uri) tzresult Lwt.t + (string * Tezos_crypto.Signature.Public_key.t * sk_uri) tzresult Lwt.t val get_public_key : #Client_context.wallet -> Public_key_hash.t -> - (string * Signature.Public_key.t) tzresult Lwt.t + (string * Tezos_crypto.Signature.Public_key.t) tzresult Lwt.t val get_keys : #Client_context.wallet -> - (string * Public_key_hash.t * Signature.Public_key.t * sk_uri) list tzresult + (string * Public_key_hash.t * Tezos_crypto.Signature.Public_key.t * sk_uri) + list + tzresult Lwt.t val force_switch : unit -> (bool, 'ctx) Tezos_clic.arg @@ -337,16 +356,18 @@ val aggregate_neuterize : aggregate_sk_uri -> aggregate_pk_uri tzresult Lwt.t val register_aggregate_key : #Client_context.wallet -> ?force:bool -> - Aggregate_signature.Public_key_hash.t * aggregate_pk_uri * aggregate_sk_uri -> - ?public_key:Aggregate_signature.Public_key.t -> + Tezos_crypto.Aggregate_signature.Public_key_hash.t + * aggregate_pk_uri + * aggregate_sk_uri -> + ?public_key:Tezos_crypto.Aggregate_signature.Public_key.t -> string -> unit tzresult Lwt.t val list_aggregate_keys : #Client_context.wallet -> (string - * Aggregate_signature.Public_key_hash.t - * Aggregate_signature.Public_key.t option + * Tezos_crypto.Aggregate_signature.Public_key_hash.t + * Tezos_crypto.Aggregate_signature.Public_key.t option * aggregate_sk_uri option) list tzresult @@ -355,16 +376,16 @@ val list_aggregate_keys : val import_aggregate_secret_key : io:Client_context.io_wallet -> aggregate_pk_uri -> - (Aggregate_signature.Public_key_hash.t - * Aggregate_signature.Public_key.t option) + (Tezos_crypto.Aggregate_signature.Public_key_hash.t + * Tezos_crypto.Aggregate_signature.Public_key.t option) tzresult Lwt.t val alias_aggregate_keys : #Client_context.wallet -> string -> - (Aggregate_signature.Public_key_hash.t - * Aggregate_signature.Public_key.t option + (Tezos_crypto.Aggregate_signature.Public_key_hash.t + * Tezos_crypto.Aggregate_signature.Public_key.t option * aggregate_sk_uri option) option tzresult @@ -374,7 +395,7 @@ val aggregate_sign : #Client_context.wallet -> aggregate_sk_uri -> Bytes.t -> - Aggregate_signature.t tzresult Lwt.t + Tezos_crypto.Aggregate_signature.t tzresult Lwt.t (**/**) diff --git a/src/lib_client_base/pbkdf.ml b/src/lib_client_base/pbkdf.ml index e887a671976f..27ebd11e6170 100644 --- a/src/lib_client_base/pbkdf.ml +++ b/src/lib_client_base/pbkdf.ml @@ -25,7 +25,7 @@ module type S = sig password:Bytes.t -> salt:Bytes.t -> count:int -> dk_len:int32 -> Bytes.t end -module Make (H : Hacl.Hash.S) : S = struct +module Make (H : Tezos_crypto.Hacl.Hash.S) : S = struct let pbkdf2 ~password ~salt ~count ~dk_len = if count <= 0 then invalid_arg "count must be a positive integer" ; if dk_len <= 0l then @@ -52,8 +52,8 @@ module Make (H : Hacl.Hash.S) : S = struct Bytes.concat Bytes.empty (loop [Bytes.sub (block l) 0 r] (l - 1)) end -module SHA256 = Make (Hacl.Hash.SHA256) -module SHA512 = Make (Hacl.Hash.SHA512) +module SHA256 = Make (Tezos_crypto.Hacl.Hash.SHA256) +module SHA512 = Make (Tezos_crypto.Hacl.Hash.SHA512) (* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/src/lib_client_base/pbkdf.mli b/src/lib_client_base/pbkdf.mli index c6e07264be39..f3cca4fab5f3 100644 --- a/src/lib_client_base/pbkdf.mli +++ b/src/lib_client_base/pbkdf.mli @@ -12,7 +12,7 @@ module type S = sig end (** Given a Hash/pseudorandom function, get the PBKDF *) -module Make (H : Hacl.Hash.S) : S +module Make (H : Tezos_crypto.Hacl.Hash.S) : S module SHA256 : S diff --git a/src/lib_client_base/test/pbkdf_tests.ml b/src/lib_client_base/test/pbkdf_tests.ml index 5f43354e4a7f..6e924238d0ac 100644 --- a/src/lib_client_base/test/pbkdf_tests.ml +++ b/src/lib_client_base/test/pbkdf_tests.ml @@ -6,10 +6,9 @@ when using hash functions SHA256 and SHA512. *) -open Tezos_crypto - (* PBKDF2 *) -let test_pbkdf2 (module A : Hacl.Hash.S) ~password ~salt ~count ~dk_len ~dk = +let test_pbkdf2 (module A : Tezos_crypto.Hacl.Hash.S) ~password ~salt ~count + ~dk_len ~dk = let module P = Pbkdf.Make (A) in let salt = Tezos_stdlib.Hex.to_bytes_exn (`Hex salt) in let dk = Tezos_stdlib.Hex.to_bytes_exn (`Hex dk) in @@ -38,7 +37,7 @@ let test_pbkdf2 (module A : Hacl.Hash.S) ~password ~salt ~count ~dk_len ~dk = *) let pbkdf2_test11 = test_pbkdf2 - (module Hacl.Hash.SHA256) + (module Tezos_crypto.Hacl.Hash.SHA256) ~password:"xyz" ~salt:"0001020304050607" ~count:10000 @@ -53,7 +52,7 @@ let pbkdf2_test11 = *) let pbkdf2_test13 = test_pbkdf2 - (module Hacl.Hash.SHA512) + (module Tezos_crypto.Hacl.Hash.SHA512) ~password:"xyz" ~salt:"0001020304050607" ~count:10000 diff --git a/src/lib_client_base_unix/client_config.ml b/src/lib_client_base_unix/client_config.ml index 47774088fdcf..a7a4a6e57745 100644 --- a/src/lib_client_base_unix/client_config.ml +++ b/src/lib_client_base_unix/client_config.ml @@ -32,7 +32,7 @@ type cli_args = { confirmations : int option; sources : Tezos_proxy.Light.sources_config option; password_filename : string option; - protocol : Protocol_hash.t option; + protocol : Tezos_crypto.Protocol_hash.t option; print_timings : bool; log_requests : bool; better_errors : bool; @@ -407,7 +407,9 @@ let protocol_parameter () = match Seq.filter (fun (hash, _commands) -> - String.has_prefix ~prefix:arg (Protocol_hash.to_b58check hash)) + String.has_prefix + ~prefix:arg + (Tezos_crypto.Protocol_hash.to_b58check hash)) (Client_commands.get_versions ()) @@ () with @@ -686,7 +688,8 @@ let config_show_client (cctxt : #Client_context.full) (config_file : string) cfg (* The implementation of ["config"; "show"] when --mode is "mockup" *) let config_show_mockup (cctxt : #Client_context.full) - (protocol_hash_opt : Protocol_hash.t option) (base_dir : string) = + (protocol_hash_opt : Tezos_crypto.Protocol_hash.t option) + (base_dir : string) = let open Lwt_result_syntax in let* () = fail_on_non_mockup_dir cctxt in let* mockup, _ = @@ -778,7 +781,8 @@ let config_init_mockup cctxt protocol_hash_opt bootstrap_accounts_file return_unit let commands config_file cfg (client_mode : client_mode) - (protocol_hash_opt : Protocol_hash.t option) (base_dir : string) = + (protocol_hash_opt : Tezos_crypto.Protocol_hash.t option) + (base_dir : string) = let open Tezos_clic in let group = { @@ -1239,7 +1243,7 @@ type t = * Shell_services.chain * Shell_services.block * int option option - * Protocol_hash.t option option + * Tezos_crypto.Protocol_hash.t option option * bool * bool * string option @@ -1254,7 +1258,9 @@ type t = module type Remote_params = sig val authenticate : - Signature.public_key_hash list -> Bytes.t -> Signature.t tzresult Lwt.t + Tezos_crypto.Signature.public_key_hash list -> + Bytes.t -> + Tezos_crypto.Signature.t tzresult Lwt.t val logger : Tezos_rpc_http_client_unix.RPC_client_unix.logger end diff --git a/src/lib_client_base_unix/client_context_unix.mli b/src/lib_client_base_unix/client_context_unix.mli index 425e10c42189..757c01523709 100644 --- a/src/lib_client_base_unix/client_context_unix.mli +++ b/src/lib_client_base_unix/client_context_unix.mli @@ -50,14 +50,14 @@ class unix_mockup : base_dir:string -> mem_only:bool -> mockup_env:Tezos_mockup_registration.Registration.mockup_environment - -> chain_id:Chain_id.t + -> chain_id:Tezos_crypto.Chain_id.t -> rpc_context:Tezos_protocol_environment.rpc_context -> protocol_data:bytes -> Client_context.full class unix_proxy : base_dir:string - -> ?protocol:Protocol_hash.t + -> ?protocol:Tezos_crypto.Protocol_hash.t -> chain:Shell_services.chain -> block:Shell_services.block -> confirmations:int option diff --git a/src/lib_client_base_unix/client_main_run.ml b/src/lib_client_base_unix/client_main_run.ml index 9f3e9c43511c..86db94288c89 100644 --- a/src/lib_client_base_unix/client_main_run.ml +++ b/src/lib_client_base_unix/client_main_run.ml @@ -39,7 +39,8 @@ let builtin_commands = (fun () (cctxt : #Client_context.full) -> let* () = Seq.iter_s - (fun (ver, _) -> cctxt#message "%a" Protocol_hash.pp_short ver) + (fun (ver, _) -> + cctxt#message "%a" Tezos_crypto.Protocol_hash.pp_short ver) (Client_commands.get_versions ()) in return_ok_unit); @@ -92,7 +93,10 @@ let setup_remote_signer (module C : M) client_config (function | _, known_pkh, _, Some known_sk_uri when List.exists - (fun pkh -> Signature.Public_key_hash.equal pkh known_pkh) + (fun pkh -> + Tezos_crypto.Signature.Public_key_hash.equal + pkh + known_pkh) pkhs -> Some known_sk_uri | _ -> None) diff --git a/src/lib_client_commands/client_admin_commands.ml b/src/lib_client_commands/client_admin_commands.ml index 004f6d9391aa..a93c18501a28 100644 --- a/src/lib_client_commands/client_admin_commands.ml +++ b/src/lib_client_commands/client_admin_commands.ml @@ -28,7 +28,8 @@ let block_param ~name ~desc t = Tezos_clic.param ~name ~desc - (Tezos_clic.parameter (fun _ str -> Lwt.return (Block_hash.of_b58check str))) + (Tezos_clic.parameter (fun _ str -> + Lwt.return (Tezos_crypto.Block_hash.of_b58check str))) t let operation_param ~name ~desc t = @@ -36,7 +37,7 @@ let operation_param ~name ~desc t = ~name ~desc (Tezos_clic.parameter (fun _ str -> - Lwt.return (Operation_hash.of_b58check str))) + Lwt.return (Tezos_crypto.Operation_hash.of_b58check str))) t let commands () = @@ -65,7 +66,7 @@ let commands () = let*! () = cctxt#message "Block %a no longer marked invalid." - Block_hash.pp + Tezos_crypto.Block_hash.pp block in return_unit) @@ -83,7 +84,7 @@ let commands () = let*! () = cctxt#message "Block %a no longer marked invalid." - Block_hash.pp_short + Tezos_crypto.Block_hash.pp_short hash in return_unit) @@ -102,7 +103,7 @@ let commands () = let*! () = cctxt#message "@[Checkpoint: %a@,Checkpoint level: %ld@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp checkpoint_hash checkpoint_level in @@ -124,7 +125,10 @@ let commands () = Shell_services.Mempool.ban_operation cctxt ~chain:cctxt#chain op_hash in let*! () = - cctxt#message "Operation %a is now banned." Operation_hash.pp op_hash + cctxt#message + "Operation %a is now banned." + Tezos_crypto.Operation_hash.pp + op_hash in return ()); command @@ -146,7 +150,7 @@ let commands () = let*! () = cctxt#message "Operation %a is now unbanned." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash in return ()); diff --git a/src/lib_client_commands/client_commands.ml b/src/lib_client_commands/client_commands.ml index c7bc47d017df..18c2d4f29deb 100644 --- a/src/lib_client_commands/client_commands.ml +++ b/src/lib_client_commands/client_commands.ml @@ -31,18 +31,18 @@ type network = [`Mainnet | `Testnet] exception Version_not_found -let versions = Protocol_hash.Table.create 7 +let versions = Tezos_crypto.Protocol_hash.Table.create 7 -let get_versions () = Protocol_hash.Table.to_seq versions +let get_versions () = Tezos_crypto.Protocol_hash.Table.to_seq versions let register name commands = let previous = Option.value ~default:(fun _network_opt -> []) - @@ Protocol_hash.Table.find versions name + @@ Tezos_crypto.Protocol_hash.Table.find versions name in - Protocol_hash.Table.replace versions name (fun network_opt -> + Tezos_crypto.Protocol_hash.Table.replace versions name (fun network_opt -> commands network_opt @ previous network_opt) let commands_for_version version = WithExceptions.Option.to_exn ~none:Version_not_found - @@ Protocol_hash.Table.find versions version + @@ Tezos_crypto.Protocol_hash.Table.find versions version diff --git a/src/lib_client_commands/client_commands.mli b/src/lib_client_commands/client_commands.mli index 650b9ab101b2..4bc970b47c82 100644 --- a/src/lib_client_commands/client_commands.mli +++ b/src/lib_client_commands/client_commands.mli @@ -31,9 +31,12 @@ type network = [`Mainnet | `Testnet] exception Version_not_found -val register : Protocol_hash.t -> (network option -> command list) -> unit +val register : + Tezos_crypto.Protocol_hash.t -> (network option -> command list) -> unit -val commands_for_version : Protocol_hash.t -> network option -> command list +val commands_for_version : + Tezos_crypto.Protocol_hash.t -> network option -> command list val get_versions : - unit -> (Protocol_hash.t * (network option -> command list)) Seq.t + unit -> + (Tezos_crypto.Protocol_hash.t * (network option -> command list)) Seq.t diff --git a/src/lib_client_commands/client_keys_commands.ml b/src/lib_client_commands/client_keys_commands.ml index 473a3cd5d926..9b8c1eb899da 100644 --- a/src/lib_client_commands/client_keys_commands.ml +++ b/src/lib_client_commands/client_keys_commands.ml @@ -37,9 +37,9 @@ let algo_param () = ~autocomplete:(fun _ -> return ["ed25519"; "secp256k1"; "p256"]) (fun _ name -> match name with - | "ed25519" -> return Signature.Ed25519 - | "secp256k1" -> return Signature.Secp256k1 - | "p256" -> return Signature.P256 + | "ed25519" -> return Tezos_crypto.Signature.Ed25519 + | "secp256k1" -> return Tezos_crypto.Signature.Secp256k1 + | "p256" -> return Tezos_crypto.Signature.P256 | name -> failwith "Unknown signature algorithm (%s). Available: 'ed25519', \ @@ -63,9 +63,9 @@ let gen_keys_containing ?(encrypted = false) ?(prefix = false) List.filter (fun s -> not - @@ Base58.Alphabet.all_in_alphabet + @@ Tezos_crypto.Base58.Alphabet.all_in_alphabet ~ignore_case - Base58.Alphabet.bitcoin + Tezos_crypto.Base58.Alphabet.bitcoin s) containing in @@ -87,8 +87,8 @@ let gen_keys_containing ?(encrypted = false) ?(prefix = false) ~pp_sep:(fun ppf () -> Format.fprintf ppf ", ") (fun ppf s -> Format.fprintf ppf "'%s'" s)) unrepresentable - Base58.Alphabet.pp - Base58.Alphabet.bitcoin + Tezos_crypto.Base58.Alphabet.pp + Tezos_crypto.Base58.Alphabet.bitcoin good_initial_char | [] -> ( let unrepresentable = @@ -107,8 +107,8 @@ let gen_keys_containing ?(encrypted = false) ?(prefix = false) ~pp_sep:(fun ppf () -> Format.fprintf ppf ", ") (fun ppf s -> Format.fprintf ppf "'%s'" s)) unrepresentable - Base58.Alphabet.pp - Base58.Alphabet.bitcoin + Tezos_crypto.Base58.Alphabet.pp + Tezos_crypto.Base58.Alphabet.bitcoin good_initial_char | [] -> let* name_exists = Public_key_hash.mem cctxt name in @@ -147,11 +147,11 @@ let gen_keys_containing ?(encrypted = false) ?(prefix = false) in let rec loop attempts = let public_key_hash, public_key, secret_key = - Signature.generate_key () + Tezos_crypto.Signature.generate_key () in let hash = - Signature.Public_key_hash.to_b58check - @@ Signature.Public_key.hash public_key + Tezos_crypto.Signature.Public_key_hash.to_b58check + @@ Tezos_crypto.Signature.Public_key.hash public_key in if matches hash then let*? pk_uri = @@ -224,16 +224,18 @@ let rec input_fundraiser_params (cctxt : #Client_context.io_wallet) = let passphrase = Bytes.(cat (of_string email) password) in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in let msg = Format.asprintf "Your public Tezos address is %a is that correct?" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in let* b = get_boolean_answer cctxt ~msg ~default:true in @@ -267,9 +269,9 @@ let keys_count_param = (** The kind of info that the [generate_test_keys] command outputs. *) type source = { - pkh : Signature.public_key_hash; - pk : Signature.public_key; - sk : Signature.secret_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; + sk : Tezos_crypto.Signature.secret_key; } let source_encoding = @@ -278,9 +280,9 @@ let source_encoding = (fun {pkh; pk; sk} -> (pkh, pk, sk)) (fun (pkh, pk, sk) -> {pkh; pk; sk}) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) let source_list_encoding = Data_encoding.list source_encoding @@ -341,7 +343,9 @@ let generate_test_keys = List.init_es ~when_negative_length:[] n (fun i -> let alias = alias_prefix i in let pkh, pk, sk = - Signature.generate_key ~algo:Signature.Ed25519 () + Tezos_crypto.Signature.generate_key + ~algo:Tezos_crypto.Signature.Ed25519 + () in let*? pk_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let*? sk_uri = Tezos_signer_backends.Unencrypted.make_sk sk in @@ -403,7 +407,7 @@ module Bls_commands = struct (Bip39.to_words mnemonic) in let seed = Mnemonic.to_32_bytes mnemonic in - let pkh, pk, sk = Aggregate_signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Aggregate_signature.generate_key ~seed () in let*? pk_uri = Tezos_signer_backends.Unencrypted.Aggregate.make_pk pk in let* sk_uri = if encrypted then @@ -446,7 +450,10 @@ module Bls_commands = struct return_unit | Some (pkh, pk, skloc) -> ( let*! () = - cctxt#message "Hash: %a" Aggregate_signature.Public_key_hash.pp pkh + cctxt#message + "Hash: %a" + Tezos_crypto.Aggregate_signature.Public_key_hash.pp + pkh in match pk with | None -> return_unit @@ -454,7 +461,7 @@ module Bls_commands = struct let*! () = cctxt#message "Public Key: %a" - Aggregate_signature.Public_key.pp + Tezos_crypto.Aggregate_signature.Public_key.pp pk in if show_private then @@ -476,7 +483,7 @@ module Bls_commands = struct let*! () = cctxt#message "Bls address added: %a" - Aggregate_signature.Public_key_hash.pp + Tezos_crypto.Aggregate_signature.Public_key_hash.pp pkh in register_aggregate_key cctxt (pkh, pk_uri, sk_uri) ?public_key name @@ -547,7 +554,7 @@ let commands network : Client_context.full Tezos_clic.command list = (prefixes ["gen"; "keys"] @@ Secret_key.fresh_alias_param @@ stop) (fun (force, algo) name (cctxt : Client_context.full) -> let* name = Secret_key.of_fresh cctxt force name in - let pkh, pk, sk = Signature.generate_key ~algo () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~algo () in let*? pk_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = Tezos_signer_backends.Encrypted.prompt_twice_and_encrypt cctxt sk @@ -564,7 +571,7 @@ let commands network : Client_context.full Tezos_clic.command list = (prefixes ["gen"; "keys"] @@ Secret_key.fresh_alias_param @@ stop) (fun (force, algo, encrypted) name (cctxt : Client_context.full) -> let* name = Secret_key.of_fresh cctxt force name in - let pkh, pk, sk = Signature.generate_key ~algo () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~algo () in let*? pk_uri = Tezos_signer_backends.Unencrypted.make_pk pk in let* sk_uri = if encrypted then @@ -662,7 +669,8 @@ let commands network : Client_context.full Tezos_clic.command list = "This command can only be used with the \"unencrypted\" scheme" in let* sk = - Lwt.return (Signature.Secret_key.of_b58check (Uri.path sk_uri)) + Lwt.return + (Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path sk_uri)) in let* sk_uri = Tezos_signer_backends.Encrypted.prompt_twice_and_encrypt cctxt sk @@ -690,7 +698,7 @@ let commands network : Client_context.full Tezos_clic.command list = let*! () = cctxt#message "Tezos address added: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in register_key cctxt ~force (pkh, pk_uri, sk_uri) ?public_key name); @@ -731,7 +739,7 @@ let commands network : Client_context.full Tezos_clic.command list = let*! () = cctxt#message "Tezos address added: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in Public_key.add ~force cctxt name (pk_uri, public_key)); @@ -781,13 +789,19 @@ let commands network : Client_context.full Tezos_clic.command list = return_unit | Some (pkh, pk, skloc) -> ( let*! () = - cctxt#message "Hash: %a" Signature.Public_key_hash.pp pkh + cctxt#message + "Hash: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh in match pk with | None -> return_unit | Some pk -> let*! () = - cctxt#message "Public Key: %a" Signature.Public_key.pp pk + cctxt#message + "Public Key: %a" + Tezos_crypto.Signature.Public_key.pp + pk in if show_private then match skloc with @@ -919,10 +933,10 @@ let commands network : Client_context.full Tezos_clic.command list = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 (Data_encoding.Binary.of_bytes_exn - Ed25519.Secret_key.encoding + Tezos_crypto.Ed25519.Secret_key.encoding sk) in let*? unencrypted_sk_uri = @@ -947,7 +961,7 @@ let commands network : Client_context.full Tezos_clic.command list = let*! () = cctxt#message "Tezos address added: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in return_unit); diff --git a/src/lib_client_commands/client_report_commands.ml b/src/lib_client_commands/client_report_commands.ml index b9330a418903..950c30bc1cd4 100644 --- a/src/lib_client_commands/client_report_commands.ml +++ b/src/lib_client_commands/client_report_commands.ml @@ -29,7 +29,7 @@ let print_invalid_blocks ppf (b : Shell_services.Chain.invalid_block) = Format.fprintf ppf "@[Hash: %a@ Level: %ld@ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp b.hash b.level pp_print_trace @@ -66,7 +66,7 @@ let commands () = Format.fprintf ppf "@[%a@]@." - (Format.pp_print_list Block_hash.pp) + (Format.pp_print_list Tezos_crypto.Block_hash.pp) (List.concat heads) ; return_unit); command -- GitLab From b48d5d93b6ead9ec0ff0e43347d0e1f68fbb31be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 10:04:47 +0200 Subject: [PATCH 16/30] DALnode: unopen Crypto --- src/bin_dal_node/configuration.ml | 6 ++++-- src/bin_dal_node/configuration.mli | 2 +- src/bin_dal_node/dac_manager.mli | 4 ++-- src/bin_dal_node/event.ml | 8 ++++---- src/bin_dal_node/main_dal.ml | 8 ++++---- src/bin_dal_node/slot_headers_store.ml | 4 ++-- src/lib_dal_node/dal_plugin.ml | 9 +++++---- src/lib_dal_node/dal_plugin.mli | 2 +- src/lib_dal_node_services/services.ml | 3 ++- 9 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/bin_dal_node/configuration.ml b/src/bin_dal_node/configuration.ml index 547e9d261523..f9a6d171c107 100644 --- a/src/bin_dal_node/configuration.ml +++ b/src/bin_dal_node/configuration.ml @@ -26,7 +26,7 @@ type neighbor = {addr : string; port : int} type dac = { - addresses : Aggregate_signature.public_key_hash list; + addresses : Tezos_crypto.Aggregate_signature.public_key_hash list; threshold : int; reveal_data_dir : string; } @@ -87,7 +87,9 @@ let dac_encoding : dac Data_encoding.t = (fun (addresses, threshold, reveal_data_dir) -> {addresses; threshold; reveal_data_dir}) (obj3 - (req "addresses" (list Aggregate_signature.Public_key_hash.encoding)) + (req + "addresses" + (list Tezos_crypto.Aggregate_signature.Public_key_hash.encoding)) (req "threshold" uint8) (req "reveal-data-dir" string)) diff --git a/src/bin_dal_node/configuration.mli b/src/bin_dal_node/configuration.mli index 3835bff9abc3..ee506311e3fc 100644 --- a/src/bin_dal_node/configuration.mli +++ b/src/bin_dal_node/configuration.mli @@ -26,7 +26,7 @@ type neighbor = {addr : string; port : int} type dac = { - addresses : Aggregate_signature.public_key_hash list; + addresses : Tezos_crypto.Aggregate_signature.public_key_hash list; threshold : int; (** The number of signature needed on root page hashes for the corresponding reveal preimages to be available. *) diff --git a/src/bin_dal_node/dac_manager.mli b/src/bin_dal_node/dac_manager.mli index ca9a2954beeb..03b597650438 100644 --- a/src/bin_dal_node/dac_manager.mli +++ b/src/bin_dal_node/dac_manager.mli @@ -35,8 +35,8 @@ module Keys : sig val get_keys : #Client_context.wallet -> Configuration.t -> - (Aggregate_signature.public_key_hash - * Aggregate_signature.public_key option + (Tezos_crypto.Aggregate_signature.public_key_hash + * Tezos_crypto.Aggregate_signature.public_key option * Client_keys.aggregate_sk_uri) option list diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 8351d9c84cbd..9e147a0531d4 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -110,7 +110,7 @@ let layer1_node_new_head = ~name:"dal_node_layer_1_new_head" ~msg:"Head of layer 1's node updated to {hash} at level {level}" ~level:Notice - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let layer1_node_tracking_started = @@ -157,7 +157,7 @@ let dac_account_not_available = "There is no account with public key {tz4_account} in the Tezos client \ wallet. This account won't be used for signing DAC root hash pages." ~level:Warning - ("tz4_account", Aggregate_signature.Public_key_hash.encoding) + ("tz4_account", Tezos_crypto.Aggregate_signature.Public_key_hash.encoding) let dac_account_cannot_sign = declare_1 @@ -168,10 +168,10 @@ let dac_account_cannot_sign = wallet, but its secret key URI is not available. This account won't be \ used for signing DAC root hash pages." ~level:Warning - ("tz4_account", Aggregate_signature.Public_key_hash.encoding) + ("tz4_account", Tezos_crypto.Aggregate_signature.Public_key_hash.encoding) let proto_short_hash_string hash = - Format.asprintf "%a" Protocol_hash.pp_short hash + Format.asprintf "%a" Tezos_crypto.Protocol_hash.pp_short hash let emit_protocol_plugin_resolved hash = emit protocol_plugin_resolved (proto_short_hash_string hash) diff --git a/src/bin_dal_node/main_dal.ml b/src/bin_dal_node/main_dal.ml index d2b3dcbc9411..243984d32469 100644 --- a/src/bin_dal_node/main_dal.ml +++ b/src/bin_dal_node/main_dal.ml @@ -128,9 +128,9 @@ module Dac_client = struct let tz4_address_parameter () = Tezos_clic.parameter (fun _cctxt s -> let open Lwt_result_syntax in - let*? bls_pkh = Bls.Public_key_hash.of_b58check s in - let pkh : Aggregate_signature.public_key_hash = - Aggregate_signature.Bls12_381 bls_pkh + let*? bls_pkh = Tezos_crypto.Bls.Public_key_hash.of_b58check s in + let pkh : Tezos_crypto.Aggregate_signature.public_key_hash = + Tezos_crypto.Aggregate_signature.Bls12_381 bls_pkh in return pkh) @@ -156,7 +156,7 @@ module Dac_client = struct let old_addresses = config.dac.addresses in if List.mem - ~equal:Aggregate_signature.Public_key_hash.equal + ~equal:Tezos_crypto.Aggregate_signature.Public_key_hash.equal address old_addresses then diff --git a/src/bin_dal_node/slot_headers_store.ml b/src/bin_dal_node/slot_headers_store.ml index 49f216988713..fd80adae6cb8 100644 --- a/src/bin_dal_node/slot_headers_store.ml +++ b/src/bin_dal_node/slot_headers_store.ml @@ -46,9 +46,9 @@ include let path = ["dal"; "slot_headers"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type key = int diff --git a/src/lib_dal_node/dal_plugin.ml b/src/lib_dal_node/dal_plugin.ml index 6c3f2ff2332f..4efd23217224 100644 --- a/src/lib_dal_node/dal_plugin.ml +++ b/src/lib_dal_node/dal_plugin.ml @@ -43,10 +43,11 @@ module type T = sig end end -let table : (module T) Protocol_hash.Table.t = Protocol_hash.Table.create 5 +let table : (module T) Tezos_crypto.Protocol_hash.Table.t = + Tezos_crypto.Protocol_hash.Table.create 5 let register (module Plugin : T) = - assert (not (Protocol_hash.Table.mem table Plugin.Proto.hash)) ; - Protocol_hash.Table.add table Plugin.Proto.hash (module Plugin) + assert (not (Tezos_crypto.Protocol_hash.Table.mem table Plugin.Proto.hash)) ; + Tezos_crypto.Protocol_hash.Table.add table Plugin.Proto.hash (module Plugin) -let get hash = Protocol_hash.Table.find table hash +let get hash = Tezos_crypto.Protocol_hash.Table.find table hash diff --git a/src/lib_dal_node/dal_plugin.mli b/src/lib_dal_node/dal_plugin.mli index d040d930a157..94b985f5269f 100644 --- a/src/lib_dal_node/dal_plugin.mli +++ b/src/lib_dal_node/dal_plugin.mli @@ -45,4 +45,4 @@ end val register : (module T) -> unit -val get : Protocol_hash.Table.key -> (module T) option +val get : Tezos_crypto.Protocol_hash.Table.key -> (module T) option diff --git a/src/lib_dal_node_services/services.ml b/src/lib_dal_node_services/services.ml index 73c8d0b851f8..a912e9ee7175 100644 --- a/src/lib_dal_node_services/services.ml +++ b/src/lib_dal_node_services/services.ml @@ -71,7 +71,8 @@ let stored_slot_headers () = (obj2 (req "index" int31) (req "slot_header" Cryptobox.Commitment.encoding))) - Tezos_rpc.Path.(open_root / "stored_slot_headers" /: Block_hash.rpc_arg) + Tezos_rpc.Path.( + open_root / "stored_slot_headers" /: Tezos_crypto.Block_hash.rpc_arg) let shard () = let shard_arg = Tezos_rpc.Arg.int in -- GitLab From a4e10b58f3d67f0c17d589d38013f9bba5cb2f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 10:11:40 +0200 Subject: [PATCH 17/30] Benchmark: unopen Crypto --- manifest/main.ml | 4 +- opam/tezos-benchmark.opam | 1 + opam/tezos-micheline-rewriting.opam | 1 + src/lib_benchmark/crypto_samplers.ml | 21 +++-- src/lib_benchmark/crypto_samplers.mli | 12 +-- src/lib_benchmark/dune | 1 + .../lib_micheline_rewriting/dune | 1 + .../bloomer_benchmarks.ml | 2 +- src/lib_shell_benchmarks/dune | 3 +- .../encoding_benchmarks.ml | 80 +++++++++---------- src/lib_shell_benchmarks/io_benchmarks.ml | 16 ++-- src/lib_shell_benchmarks/io_helpers.ml | 6 +- 12 files changed, 83 insertions(+), 65 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index d7800d37ac46..6e5912ca47ed 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -2949,6 +2949,7 @@ let octez_benchmark = [ octez_base |> open_ ~m:"TzPervasives"; octez_stdlib_unix |> open_; + octez_crypto; octez_micheline; octez_clic; data_encoding; @@ -3011,6 +3012,7 @@ let octez_micheline_rewriting = zarith; zarith_stubs_js; octez_stdlib |> open_; + octez_crypto; octez_error_monad |> open_; octez_micheline |> open_; ] @@ -3026,7 +3028,7 @@ let octez_shell_benchmarks = octez_base |> open_ |> open_ ~m:"TzPervasives"; octez_error_monad |> open_; octez_benchmark |> open_; - octez_crypto |> open_; + octez_crypto; octez_context; octez_shell_context; octez_micheline; diff --git a/opam/tezos-benchmark.opam b/opam/tezos-benchmark.opam index 74da4cfad3ee..c5c4acb531f2 100644 --- a/opam/tezos-benchmark.opam +++ b/opam/tezos-benchmark.opam @@ -12,6 +12,7 @@ depends: [ "ppx_expect" "tezos-base" "tezos-stdlib-unix" + "tezos-crypto" "tezos-micheline" "tezos-clic" "data-encoding" { >= "0.6" & < "0.7" } diff --git a/opam/tezos-micheline-rewriting.opam b/opam/tezos-micheline-rewriting.opam index a3fb8a40a22f..7b8e9e569f2e 100644 --- a/opam/tezos-micheline-rewriting.opam +++ b/opam/tezos-micheline-rewriting.opam @@ -12,6 +12,7 @@ depends: [ "zarith" { >= "1.12" & < "1.13" } "zarith_stubs_js" "tezos-stdlib" + "tezos-crypto" "tezos-error-monad" "tezos-micheline" "tezos-protocol-alpha" {with-test} diff --git a/src/lib_benchmark/crypto_samplers.ml b/src/lib_benchmark/crypto_samplers.ml index fa4d8fe3590d..13051326c24c 100644 --- a/src/lib_benchmark/crypto_samplers.ml +++ b/src/lib_benchmark/crypto_samplers.ml @@ -28,18 +28,20 @@ module type Param_S = sig val size : int - val algo : [`Algo of Signature.algo | `Default] + val algo : [`Algo of Tezos_crypto.Signature.algo | `Default] end module type Finite_key_pool_S = sig - val pk : Signature.public_key Base_samplers.sampler + val pk : Tezos_crypto.Signature.public_key Base_samplers.sampler - val pkh : Signature.public_key_hash Base_samplers.sampler + val pkh : Tezos_crypto.Signature.public_key_hash Base_samplers.sampler - val sk : Signature.secret_key Base_samplers.sampler + val sk : Tezos_crypto.Signature.secret_key Base_samplers.sampler val all : - (Signature.public_key_hash * Signature.public_key * Signature.secret_key) + (Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tezos_crypto.Signature.secret_key) Base_samplers.sampler end @@ -51,7 +53,12 @@ module Make_finite_key_pool (Arg : Param_S) : Finite_key_pool_S = struct let key_pool = Queue.create () - let all_algos = [|Signature.Ed25519; Signature.Secp256k1; Signature.P256|] + let all_algos = + [| + Tezos_crypto.Signature.Ed25519; + Tezos_crypto.Signature.Secp256k1; + Tezos_crypto.Signature.P256; + |] let uniform_algo state = let i = Random.State.int state (Array.length all_algos) in @@ -67,7 +74,7 @@ module Make_finite_key_pool (Arg : Param_S) : Finite_key_pool_S = struct let seed = Base_samplers.uniform_bytes ~nbytes:minimal_seed_length state in - let triple = Signature.generate_key ~algo ~seed () in + let triple = Tezos_crypto.Signature.generate_key ~algo ~seed () in Queue.add triple key_pool ; triple) else diff --git a/src/lib_benchmark/crypto_samplers.mli b/src/lib_benchmark/crypto_samplers.mli index 2cfdabe9b6e3..6148a0076b89 100644 --- a/src/lib_benchmark/crypto_samplers.mli +++ b/src/lib_benchmark/crypto_samplers.mli @@ -36,22 +36,24 @@ module type Param_S = sig val size : int (** Algorithm to use for triplet generation. *) - val algo : [`Algo of Signature.algo | `Default] + val algo : [`Algo of Tezos_crypto.Signature.algo | `Default] end module type Finite_key_pool_S = sig (** Sample a public key from the pool. *) - val pk : Signature.public_key Base_samplers.sampler + val pk : Tezos_crypto.Signature.public_key Base_samplers.sampler (** Sample a public key hash from the pool. *) - val pkh : Signature.public_key_hash Base_samplers.sampler + val pkh : Tezos_crypto.Signature.public_key_hash Base_samplers.sampler (** Sample a secret key from the pool. *) - val sk : Signature.secret_key Base_samplers.sampler + val sk : Tezos_crypto.Signature.secret_key Base_samplers.sampler (** Sample a (pkh, pk, sk) triplet from the pool. *) val all : - (Signature.public_key_hash * Signature.public_key * Signature.secret_key) + (Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tezos_crypto.Signature.secret_key) Base_samplers.sampler end diff --git a/src/lib_benchmark/dune b/src/lib_benchmark/dune index 5543052844a7..9bfd9c6f26ec 100644 --- a/src/lib_benchmark/dune +++ b/src/lib_benchmark/dune @@ -8,6 +8,7 @@ (libraries tezos-base tezos-stdlib-unix + tezos-crypto tezos-micheline tezos-clic data-encoding diff --git a/src/lib_benchmark/lib_micheline_rewriting/dune b/src/lib_benchmark/lib_micheline_rewriting/dune index 294c1ed00bd6..a5f178aa73bd 100644 --- a/src/lib_benchmark/lib_micheline_rewriting/dune +++ b/src/lib_benchmark/lib_micheline_rewriting/dune @@ -9,6 +9,7 @@ zarith zarith_stubs_js tezos-stdlib + tezos-crypto tezos-error-monad tezos-micheline) (flags diff --git a/src/lib_shell_benchmarks/bloomer_benchmarks.ml b/src/lib_shell_benchmarks/bloomer_benchmarks.ml index a914d9ff9296..eaf92a9098aa 100644 --- a/src/lib_shell_benchmarks/bloomer_benchmarks.ml +++ b/src/lib_shell_benchmarks/bloomer_benchmarks.ml @@ -63,7 +63,7 @@ let make_bench name info model generator make_bench : let make_bloomer () = Bloomer.create - ~hash:(fun x -> Blake2B.(to_bytes (hash_string [x]))) + ~hash:(fun x -> Tezos_crypto.Blake2B.(to_bytes (hash_string [x]))) ~hashes:5 ~countdown_bits:4 ~index_bits:(Bits.numbits (2 * 1024 * 8 * 1024 / 4)) diff --git a/src/lib_shell_benchmarks/dune b/src/lib_shell_benchmarks/dune index b8a351df5a1e..28b9b32120c4 100644 --- a/src/lib_shell_benchmarks/dune +++ b/src/lib_shell_benchmarks/dune @@ -21,5 +21,4 @@ -open Tezos_base -open Tezos_base.TzPervasives -open Tezos_error_monad - -open Tezos_benchmark - -open Tezos_crypto)) + -open Tezos_benchmark)) diff --git a/src/lib_shell_benchmarks/encoding_benchmarks.ml b/src/lib_shell_benchmarks/encoding_benchmarks.ml index c635d873c7bc..5e824f53047b 100644 --- a/src/lib_shell_benchmarks/encoding_benchmarks.ml +++ b/src/lib_shell_benchmarks/encoding_benchmarks.ml @@ -28,14 +28,14 @@ open Encoding_benchmarks_helpers (* ------------------------------------------------------------------------- *) module Make_elliptic_curve_encoding_benchmarks (A : sig - val algo : Signature.algo + val algo : Tezos_crypto.Signature.algo end) = struct let algo_name = match A.algo with - | Signature.Ed25519 -> "ed25519" - | Signature.Secp256k1 -> "secp256k1" - | Signature.P256 -> "p256" + | Tezos_crypto.Signature.Ed25519 -> "ed25519" + | Tezos_crypto.Signature.Secp256k1 -> "secp256k1" + | Tezos_crypto.Signature.P256 -> "p256" module Sampler = Crypto_samplers.Make_finite_key_pool (struct let size = 256 @@ -48,7 +48,7 @@ struct let public_key_encoding = make_encode_fixed_size ~name:("ENCODING_PUBLIC_KEY_" ^ algo_name) - ~encoding:Signature.Public_key.encoding + ~encoding:Tezos_crypto.Signature.Public_key.encoding ~generator:Sampler.pk () @@ -57,7 +57,7 @@ struct let public_key_to_b58check = make_encode_fixed_size_to_string ~name:("B58CHECK_ENCODING_PUBLIC_KEY_" ^ algo_name) - ~to_string:Signature.Public_key.to_b58check + ~to_string:Tezos_crypto.Signature.Public_key.to_b58check ~generator:Sampler.pk () @@ -66,7 +66,7 @@ struct let public_key_hash_encoding = make_encode_fixed_size ~name:("ENCODING_PUBLIC_KEY_HASH_" ^ algo_name) - ~encoding:Signature.Public_key_hash.encoding + ~encoding:Tezos_crypto.Signature.Public_key_hash.encoding ~generator:Sampler.pkh () @@ -75,7 +75,7 @@ struct let public_key_hash_to_b58check = make_encode_fixed_size_to_string ~name:("B58CHECK_ENCODING_PUBLIC_KEY_HASH_" ^ algo_name) - ~to_string:Signature.Public_key_hash.to_b58check + ~to_string:Tezos_crypto.Signature.Public_key_hash.to_b58check ~generator:Sampler.pkh () @@ -84,7 +84,7 @@ struct let secret_key_encoding = make_encode_fixed_size ~name:("ENCODING_SECRET_KEY_" ^ algo_name) - ~encoding:Signature.Public_key_hash.encoding + ~encoding:Tezos_crypto.Signature.Public_key_hash.encoding ~generator:Sampler.pkh () @@ -93,7 +93,7 @@ struct let secret_key_to_b58check = make_encode_fixed_size_to_string ~name:("B58CHECK_ENCODING_SECRET_KEY_" ^ algo_name) - ~to_string:Signature.Secret_key.to_b58check + ~to_string:Tezos_crypto.Signature.Secret_key.to_b58check ~generator:Sampler.sk () @@ -102,8 +102,8 @@ struct let signature_encoding = make_encode_fixed_size ~name:("ENCODING_SIGNATURE_" ^ algo_name) - ~encoding:Signature.encoding - ~generator:(fun _rng_state -> Signature.zero) + ~encoding:Tezos_crypto.Signature.encoding + ~generator:(fun _rng_state -> Tezos_crypto.Signature.zero) () let () = Registration.register signature_encoding @@ -111,8 +111,8 @@ struct let signature_to_b58check = make_encode_fixed_size_to_string ~name:("B58CHECK_ENCODING_SIGNATURE_" ^ algo_name) - ~to_string:Signature.to_b58check - ~generator:(fun _rng_state -> Signature.zero) + ~to_string:Tezos_crypto.Signature.to_b58check + ~generator:(fun _rng_state -> Tezos_crypto.Signature.zero) () let () = Registration.register signature_to_b58check @@ -122,7 +122,7 @@ struct let public_key_decoding = make_decode_fixed_size ~name:("DECODING_PUBLIC_KEY_" ^ algo_name) - ~encoding:Signature.Public_key.encoding + ~encoding:Tezos_crypto.Signature.Public_key.encoding ~generator:Sampler.pk () @@ -131,8 +131,8 @@ struct let public_key_from_b58check = make_decode_fixed_size_from_string ~name:("B58CHECK_DECODING_PUBLIC_KEY_" ^ algo_name) - ~to_string:Signature.Public_key.to_b58check - ~from_string:Signature.Public_key.of_b58check_exn + ~to_string:Tezos_crypto.Signature.Public_key.to_b58check + ~from_string:Tezos_crypto.Signature.Public_key.of_b58check_exn ~generator:Sampler.pk () @@ -141,7 +141,7 @@ struct let public_key_hash_decoding = make_decode_fixed_size ~name:("DECODING_PUBLIC_KEY_HASH_" ^ algo_name) - ~encoding:Signature.Public_key_hash.encoding + ~encoding:Tezos_crypto.Signature.Public_key_hash.encoding ~generator:Sampler.pkh () @@ -150,8 +150,8 @@ struct let public_key_hash_from_b58check = make_decode_fixed_size_from_string ~name:("B58CHECK_DECODING_PUBLIC_KEY_HASH_" ^ algo_name) - ~to_string:Signature.Public_key_hash.to_b58check - ~from_string:Signature.Public_key_hash.of_b58check_exn + ~to_string:Tezos_crypto.Signature.Public_key_hash.to_b58check + ~from_string:Tezos_crypto.Signature.Public_key_hash.of_b58check_exn ~generator:Sampler.pkh () @@ -160,7 +160,7 @@ struct let secret_key_decoding = make_decode_fixed_size ~name:("DECODING_SECRET_KEY_" ^ algo_name) - ~encoding:Signature.Secret_key.encoding + ~encoding:Tezos_crypto.Signature.Secret_key.encoding ~generator:Sampler.sk () @@ -169,8 +169,8 @@ struct let secret_key_from_b58check = make_decode_fixed_size_from_string ~name:("B58CHECK_DECODING_SECRET_KEY_" ^ algo_name) - ~to_string:Signature.Secret_key.to_b58check - ~from_string:Signature.Secret_key.of_b58check_exn + ~to_string:Tezos_crypto.Signature.Secret_key.to_b58check + ~from_string:Tezos_crypto.Signature.Secret_key.of_b58check_exn ~generator:Sampler.sk () @@ -179,8 +179,8 @@ struct let signature_decoding = make_decode_fixed_size ~name:("DECODING_SIGNATURE_" ^ algo_name) - ~encoding:Signature.encoding - ~generator:(fun _rng_state -> Signature.zero) + ~encoding:Tezos_crypto.Signature.encoding + ~generator:(fun _rng_state -> Tezos_crypto.Signature.zero) () let () = Registration.register signature_decoding @@ -188,32 +188,32 @@ struct let signature_from_b58check = make_decode_fixed_size_from_string ~name:("B58CHECK_DECODING_SIGNATURE_" ^ algo_name) - ~to_string:Signature.to_b58check - ~from_string:Signature.of_b58check_exn - ~generator:(fun _rng_state -> Signature.zero) + ~to_string:Tezos_crypto.Signature.to_b58check + ~from_string:Tezos_crypto.Signature.of_b58check_exn + ~generator:(fun _rng_state -> Tezos_crypto.Signature.zero) () let () = Registration.register signature_from_b58check end module Ed25519 = Make_elliptic_curve_encoding_benchmarks (struct - let algo = Signature.Ed25519 + let algo = Tezos_crypto.Signature.Ed25519 end) module Secp256k1 = Make_elliptic_curve_encoding_benchmarks (struct - let algo = Signature.Secp256k1 + let algo = Tezos_crypto.Signature.Secp256k1 end) module P256 = Make_elliptic_curve_encoding_benchmarks (struct - let algo = Signature.P256 + let algo = Tezos_crypto.Signature.P256 end) let chain_id_encoding = make_encode_fixed_size ~name:"ENCODING_CHAIN_ID" - ~encoding:Chain_id.encoding + ~encoding:Tezos_crypto.Chain_id.encoding ~generator:(fun rng_state -> - Chain_id.hash_bytes + Tezos_crypto.Chain_id.hash_bytes [Base_samplers.bytes ~size:{min = 32; max = 32} rng_state]) () @@ -222,9 +222,9 @@ let () = Registration.register chain_id_encoding let chain_id_decoding = make_encode_fixed_size ~name:"DECODING_CHAIN_ID" - ~encoding:Chain_id.encoding + ~encoding:Tezos_crypto.Chain_id.encoding ~generator:(fun rng_state -> - Chain_id.hash_bytes + Tezos_crypto.Chain_id.hash_bytes [Base_samplers.bytes ~size:{min = 32; max = 32} rng_state]) () @@ -233,9 +233,9 @@ let () = Registration.register chain_id_decoding let chain_id_readable_encoding = make_encode_fixed_size_to_string ~name:"B58CHECK_ENCODING_CHAIN_ID" - ~to_string:Chain_id.to_b58check + ~to_string:Tezos_crypto.Chain_id.to_b58check ~generator:(fun rng_state -> - Chain_id.hash_bytes + Tezos_crypto.Chain_id.hash_bytes [Base_samplers.bytes ~size:{min = 32; max = 32} rng_state]) () @@ -244,10 +244,10 @@ let () = Registration.register chain_id_readable_encoding let chain_id_readable_decoding = make_decode_fixed_size_from_string ~name:"B58CHECK_DECODING_CHAIN_ID" - ~to_string:Chain_id.to_b58check - ~from_string:Chain_id.of_b58check_exn + ~to_string:Tezos_crypto.Chain_id.to_b58check + ~from_string:Tezos_crypto.Chain_id.of_b58check_exn ~generator:(fun rng_state -> - Chain_id.hash_bytes + Tezos_crypto.Chain_id.hash_bytes [Base_samplers.bytes ~size:{min = 32; max = 32} rng_state]) () diff --git a/src/lib_shell_benchmarks/io_benchmarks.ml b/src/lib_shell_benchmarks/io_benchmarks.ml index f3c539f03c7a..d3e260d26b66 100644 --- a/src/lib_shell_benchmarks/io_benchmarks.ml +++ b/src/lib_shell_benchmarks/io_benchmarks.ml @@ -866,13 +866,13 @@ let () = Registration.register (module Irmin_pack_write_bench) module Read_random_key_bench : Benchmark.S = struct type config = { - existing_context : string * Context_hash.t; + existing_context : string * Tezos_crypto.Context_hash.t; subdirectory : string list; } let default_config = { - existing_context = ("/no/such/directory", Context_hash.zero); + existing_context = ("/no/such/directory", Tezos_crypto.Context_hash.zero); subdirectory = ["no"; "such"; "key"]; } @@ -882,7 +882,9 @@ module Read_random_key_bench : Benchmark.S = struct (fun {existing_context; subdirectory} -> (existing_context, subdirectory)) (fun (existing_context, subdirectory) -> {existing_context; subdirectory}) (obj2 - (req "existing_context" (tup2 string Context_hash.encoding)) + (req + "existing_context" + (tup2 string Tezos_crypto.Context_hash.encoding)) (req "subdirectory" (list string))) let name = ns "READ_RANDOM_KEY" @@ -974,7 +976,7 @@ module Write_random_keys_bench : Benchmark.S = struct open Base_samplers type config = { - existing_context : string * Context_hash.t; + existing_context : string * Tezos_crypto.Context_hash.t; storage_chunk_bytes : int; storage_chunks : range; max_written_keys : int; @@ -984,7 +986,7 @@ module Write_random_keys_bench : Benchmark.S = struct let default_config = { - existing_context = ("/no/such/directory", Context_hash.zero); + existing_context = ("/no/such/directory", Tezos_crypto.Context_hash.zero); storage_chunk_bytes = 1000; storage_chunks = {min = 1; max = 1000}; max_written_keys = 10_000; @@ -1025,7 +1027,9 @@ module Write_random_keys_bench : Benchmark.S = struct subdirectory; }) (obj6 - (req "existing_context" (tup2 string Context_hash.encoding)) + (req + "existing_context" + (tup2 string Tezos_crypto.Context_hash.encoding)) (req "storage_chunk_bytes" int) (req "storage_chunks" range_encoding) (req "max_written_keys" int) diff --git a/src/lib_shell_benchmarks/io_helpers.ml b/src/lib_shell_benchmarks/io_helpers.ml index eebf86966707..ee13463f7673 100644 --- a/src/lib_shell_benchmarks/io_helpers.ml +++ b/src/lib_shell_benchmarks/io_helpers.ml @@ -37,15 +37,15 @@ let prepare_genesis base_dir = let open Lwt_result_syntax in let*! index = Tezos_context.Context.init ~readonly:false base_dir in let genesis_block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisGeneskvg68z" in let* context_hash = Tezos_context.Context.commit_genesis index - ~chain_id:(Chain_id.of_block_hash genesis_block) + ~chain_id:(Tezos_crypto.Chain_id.of_block_hash genesis_block) ~time:(Time.Protocol.of_seconds 0L) - ~protocol:Protocol_hash.zero + ~protocol:Tezos_crypto.Protocol_hash.zero in let*! o = Tezos_context.Context.checkout index context_hash in match o with -- GitLab From ecffc5e97939e31f9d8e3c3e2b06c6e7c4d8abaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 09:38:09 +0200 Subject: [PATCH 18/30] Signer: unopen Crypto --- manifest/main.ml | 4 +- src/bin_signer/handler.ml | 34 +-- src/bin_signer/handler.mli | 13 +- src/bin_signer/http_daemon.ml | 4 +- src/bin_signer/main_signer.ml | 6 +- src/bin_signer/signer_events.ml | 14 +- src/bin_signer/socket_daemon.ml | 4 +- src/lib_signer_backends/encrypted.ml | 217 +++++++++++------- src/lib_signer_backends/encrypted.mli | 13 +- src/lib_signer_backends/http.mli | 4 +- src/lib_signer_backends/http_gen.ml | 12 +- src/lib_signer_backends/http_gen.mli | 4 +- src/lib_signer_backends/https.mli | 4 +- src/lib_signer_backends/test/dune | 1 - .../test/test_encrypted.ml | 31 ++- src/lib_signer_backends/unencrypted.ml | 20 +- src/lib_signer_backends/unencrypted.mli | 10 +- .../unix/ledger.available.ml | 134 +++++++---- src/lib_signer_backends/unix/ledger_names.ml | 3 +- src/lib_signer_backends/unix/remote.ml | 14 +- src/lib_signer_backends/unix/remote.mli | 8 +- src/lib_signer_backends/unix/socket.ml | 15 +- src/lib_signer_backends/unix/socket.mli | 4 +- src/lib_signer_backends/unix/test/dune | 1 - src/lib_signer_services/signer_messages.ml | 37 +-- src/lib_signer_services/signer_messages.mli | 17 +- src/lib_signer_services/signer_services.ml | 28 ++- src/lib_signer_services/signer_services.mli | 22 +- 28 files changed, 410 insertions(+), 268 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index 6e5912ca47ed..fbba596a6d42 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -2612,7 +2612,7 @@ let _octez_signer_backends_tests = octez_base_unix; octez_stdlib |> open_; octez_error_monad |> open_ |> open_ ~m:"TzLwtreslib"; - octez_crypto |> open_; + octez_crypto; octez_client_base |> open_; octez_signer_backends |> open_; alcotest_lwt; @@ -2656,7 +2656,7 @@ let _octez_signer_backends_unix_tests = [ octez_error_monad |> open_; octez_stdlib |> open_; - octez_crypto |> open_; + octez_crypto; octez_client_base |> open_; octez_signer_backends_unix |> open_; alcotest_lwt; diff --git a/src/bin_signer/handler.ml b/src/bin_signer/handler.ml index 34f769a316fd..4870fc3814b9 100644 --- a/src/bin_signer/handler.ml +++ b/src/bin_signer/handler.ml @@ -27,24 +27,26 @@ module Events = Signer_events.Handler module High_watermark = struct let encoding = let open Data_encoding in - let raw_hash = conv Blake2B.to_bytes Blake2B.of_bytes_exn bytes in + let raw_hash = + conv Tezos_crypto.Blake2B.to_bytes Tezos_crypto.Blake2B.of_bytes_exn bytes + in conv (List.map (fun (chain_id, marks) -> - (Chain_id.to_b58check chain_id, marks))) + (Tezos_crypto.Chain_id.to_b58check chain_id, marks))) (List.map (fun (chain_id, marks) -> - (Chain_id.of_b58check_exn chain_id, marks))) + (Tezos_crypto.Chain_id.of_b58check_exn chain_id, marks))) @@ assoc @@ conv (List.map (fun (pkh, mark) -> - (Signature.Public_key_hash.to_b58check pkh, mark))) + (Tezos_crypto.Signature.Public_key_hash.to_b58check pkh, mark))) (List.map (fun (pkh, mark) -> - (Signature.Public_key_hash.of_b58check_exn pkh, mark))) + (Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh, mark))) @@ assoc @@ obj4 (req "level" int32) (opt "round" int32) (req "hash" raw_hash) - (opt "signature" Signature.encoding) + (opt "signature" Tezos_crypto.Signature.encoding) let get_level_and_round_for_tenderbake_block bytes = (* ... *) @@ -161,14 +163,18 @@ module High_watermark = struct if Bytes.length bytes < 9 then failwith "byte sequence too short to be %s %s" art name else - let hash = Blake2B.hash_bytes [bytes] in - let chain_id = Chain_id.of_bytes_exn (Bytes.sub bytes 1 4) in + let hash = Tezos_crypto.Blake2B.hash_bytes [bytes] in + let chain_id = + Tezos_crypto.Chain_id.of_bytes_exn (Bytes.sub bytes 1 4) + in let* level, round_opt = get_level_and_round () in let* o = match Option.bind - (List.assoc_opt ~equal:Chain_id.equal chain_id all) - (List.assoc_opt ~equal:Signature.Public_key_hash.equal pkh) + (List.assoc_opt ~equal:Tezos_crypto.Chain_id.equal chain_id all) + (List.assoc_opt + ~equal:Tezos_crypto.Signature.Public_key_hash.equal + pkh) with | None -> return_none | Some mark -> check_mark name mark level round_opt hash @@ -220,7 +226,7 @@ module High_watermark = struct end module Authorized_key = Client_aliases.Alias (struct - include Signature.Public_key + include Tezos_crypto.Signature.Public_key let name = "authorized_key" @@ -248,7 +254,9 @@ let check_authorization cctxt pkh data require_auth signature = let to_sign = Signer_messages.Sign.Request.to_sign ~pkh ~data in let* keys = Authorized_key.load cctxt in if - List.exists (fun (_, key) -> Signature.check key signature to_sign) keys + List.exists + (fun (_, key) -> Tezos_crypto.Signature.check key signature to_sign) + keys then return_unit else failwith "invalid authentication signature" @@ -306,7 +314,7 @@ let public_key (cctxt : #Client_context.wallet) pkh = let* all_keys = Client_keys.list_keys cctxt in match List.find_opt - (fun (_, h, _, _) -> Signature.Public_key_hash.equal h pkh) + (fun (_, h, _, _) -> Tezos_crypto.Signature.Public_key_hash.equal h pkh) all_keys with | None | Some (_, _, None, _) -> diff --git a/src/bin_signer/handler.mli b/src/bin_signer/handler.mli index 6e371b2cd483..2ac8232640d5 100644 --- a/src/bin_signer/handler.mli +++ b/src/bin_signer/handler.mli @@ -24,14 +24,15 @@ (*****************************************************************************) (** Storage for keys that have been authorized for baking. *) -module Authorized_key : Client_aliases.Alias with type t := Signature.public_key +module Authorized_key : + Client_aliases.Alias with type t := Tezos_crypto.Signature.public_key (** [public_key cctxt pkh] returns the public key whose hash is [pkh] iff it is present if [cctxt]. *) val public_key : #Client_context.wallet -> - Signature.public_key_hash -> - Signature.public_key tzresult Lwt.t + Tezos_crypto.Signature.public_key_hash -> + Tezos_crypto.Signature.public_key tzresult Lwt.t (** [sign cctxt req ?magic_bytes ~check_high_watermark ~require_auth] signs [req] and returns a signature. *) @@ -41,7 +42,7 @@ val sign : require_auth:bool -> #Client_context.wallet -> Signer_messages.Sign.Request.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t (** [deterministic_nonce cctxt req ~require_auth] generates deterministically a nonce from [req.data]. *) @@ -63,4 +64,6 @@ val deterministic_nonce_hash : (** [supports_deterministic_nonces cctxt pkh] determines whether the signer provides the deterministic nonce functionality. *) val supports_deterministic_nonces : - #Client_context.wallet -> Signature.public_key_hash -> bool tzresult Lwt.t + #Client_context.wallet -> + Tezos_crypto.Signature.public_key_hash -> + bool tzresult Lwt.t diff --git a/src/bin_signer/http_daemon.ml b/src/bin_signer/http_daemon.ml index 4d916f106ef2..beb84db698b5 100644 --- a/src/bin_signer/http_daemon.ml +++ b/src/bin_signer/http_daemon.ml @@ -55,7 +55,9 @@ let run (cctxt : #Client_context.wallet) ~hosts ?magic_bytes if require_auth then let* keys = Handler.Authorized_key.load cctxt in let hashes = - List.map (fun (_, k) -> Signature.Public_key.hash k) keys + List.map + (fun (_, k) -> Tezos_crypto.Signature.Public_key.hash k) + keys in return_some hashes else return_none) diff --git a/src/bin_signer/main_signer.ml b/src/bin_signer/main_signer.ml index d45c8f9027b5..be0d9eb99b15 100644 --- a/src/bin_signer/main_signer.ml +++ b/src/bin_signer/main_signer.ml @@ -293,14 +293,14 @@ let commands base_dir require_auth : Client_context.full Tezos_clic.command list ~name:"pk" ~desc:"full public key (Base58 encoded)" (parameter (fun _ s -> - Lwt.return (Signature.Public_key.of_b58check s))) + Lwt.return (Tezos_crypto.Signature.Public_key.of_b58check s))) @@ stop) (fun name key cctxt -> - let pkh = Signature.Public_key.hash key in + let pkh = Tezos_crypto.Signature.Public_key.hash key in let name = match name with | Some name -> name - | None -> Signature.Public_key_hash.to_b58check pkh + | None -> Tezos_crypto.Signature.Public_key_hash.to_b58check pkh in Handler.Authorized_key.add ~force:false cctxt name key); ] diff --git a/src/bin_signer/signer_events.ml b/src/bin_signer/signer_events.ml index 4e871ab61e36..8b61bc612bfd 100644 --- a/src/bin_signer/signer_events.ml +++ b/src/bin_signer/signer_events.ml @@ -63,7 +63,7 @@ module Handler = struct "request for signing {bytes} bytes of data for key {key}, magic byte = \ {magic}" ("bytes", Data_encoding.int31) - ("key", Signature.Public_key_hash.encoding) + ("key", Tezos_crypto.Signature.Public_key_hash.encoding) ("magic", Data_encoding.uint8) let signing_data = @@ -81,7 +81,7 @@ module Handler = struct ~name:"request_for_deterministic_nonce" ~msg:"request for creating a nonce from {bytes} input bytes for key {key}" ("bytes", Data_encoding.int31) - ("key", Signature.Public_key_hash.encoding) + ("key", Tezos_crypto.Signature.Public_key_hash.encoding) let creating_nonce = declare_1 @@ -100,7 +100,7 @@ module Handler = struct "request for creating a nonce hash from {bytes} input bytes for key \ {key}" ("bytes", Data_encoding.int31) - ("key", Signature.Public_key_hash.encoding) + ("key", Tezos_crypto.Signature.Public_key_hash.encoding) let creating_nonce_hash = declare_1 @@ -118,7 +118,7 @@ module Handler = struct ~msg: "request for checking whether the signer supports deterministic nonces \ for key {key}" - ("key", Signature.Public_key_hash.encoding) + ("key", Tezos_crypto.Signature.Public_key_hash.encoding) let supports_deterministic_nonces = declare_1 @@ -136,7 +136,7 @@ module Handler = struct ~level ~name:"request_for_public_key" ~msg:"request for public key {key}" - ("key", Signature.Public_key_hash.encoding) + ("key", Tezos_crypto.Signature.Public_key_hash.encoding) let not_found_public_key = declare_1 @@ -144,7 +144,7 @@ module Handler = struct ~level ~name:"not_found_public_key" ~msg:"no public key found for hash {hash}" - ("hash", Signature.Public_key_hash.encoding) + ("hash", Tezos_crypto.Signature.Public_key_hash.encoding) let found_public_key = declare_2 @@ -152,7 +152,7 @@ module Handler = struct ~level ~name:"found_public_key" ~msg:"found public key for hash {hash} (name: {name})" - ("hash", Signature.Public_key_hash.encoding) + ("hash", Tezos_crypto.Signature.Public_key_hash.encoding) ("name", Data_encoding.string) end diff --git a/src/bin_signer/socket_daemon.ml b/src/bin_signer/socket_daemon.ml index ac920945e0d4..54bf6817dfd1 100644 --- a/src/bin_signer/socket_daemon.ml +++ b/src/bin_signer/socket_daemon.ml @@ -63,7 +63,9 @@ let handle_client_step ?magic_bytes ?timeout ~check_high_watermark ~require_auth if require_auth then let* keys = Handler.Authorized_key.load cctxt in let hashes = - List.map (fun (_, k) -> Signature.Public_key.hash k) keys + List.map + (fun (_, k) -> Tezos_crypto.Signature.Public_key.hash k) + keys in return (Authorized_keys.Response.Authorized_keys hashes) else return Authorized_keys.Response.No_authentication diff --git a/src/lib_signer_backends/encrypted.ml b/src/lib_signer_backends/encrypted.ml index 9c0184b06e57..700a7b187bc6 100644 --- a/src/lib_signer_backends/encrypted.ml +++ b/src/lib_signer_backends/encrypted.ml @@ -24,21 +24,23 @@ (* *) (*****************************************************************************) -type Base58.data += Encrypted_ed25519 of Bytes.t +type Tezos_crypto.Base58.data += Encrypted_ed25519 of Bytes.t -type Base58.data += Encrypted_secp256k1 of Bytes.t +type Tezos_crypto.Base58.data += Encrypted_secp256k1 of Bytes.t -type Base58.data += Encrypted_p256 of Bytes.t +type Tezos_crypto.Base58.data += Encrypted_p256 of Bytes.t -type Base58.data += Encrypted_secp256k1_element of Bytes.t +type Tezos_crypto.Base58.data += Encrypted_secp256k1_element of Bytes.t -type Base58.data += Encrypted_bls12_381 of Bytes.t +type Tezos_crypto.Base58.data += Encrypted_bls12_381 of Bytes.t -type encrypted_sk = Encrypted_aggregate_sk | Encrypted_sk of Signature.algo +type encrypted_sk = + | Encrypted_aggregate_sk + | Encrypted_sk of Tezos_crypto.Signature.algo type decrypted_sk = - | Decrypted_aggregate_sk of Aggregate_signature.Secret_key.t - | Decrypted_sk of Signature.Secret_key.t + | Decrypted_aggregate_sk of Tezos_crypto.Aggregate_signature.Secret_key.t + | Decrypted_sk of Tezos_crypto.Signature.Secret_key.t open Client_keys @@ -51,76 +53,102 @@ module Raw = struct let salt_len = 8 (* Fixed zero nonce *) - let nonce = Crypto_box.zero_nonce + let nonce = Tezos_crypto.Crypto_box.zero_nonce (* Secret keys for Ed25519, secp256k1, P256 have the same size. *) - let encrypted_size = Crypto_box.tag_length + Hacl.Ed25519.sk_size + let encrypted_size = + Tezos_crypto.Crypto_box.tag_length + Tezos_crypto.Hacl.Ed25519.sk_size let pbkdf ~salt ~password = Pbkdf.SHA512.pbkdf2 ~count:32768 ~dk_len:32l ~salt ~password let encrypt ~password sk = - let salt = Hacl.Rand.gen salt_len in - let key = Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) in + let salt = Tezos_crypto.Hacl.Rand.gen salt_len in + let key = + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) + in let msg = match (sk : decrypted_sk) with | Decrypted_sk (Ed25519 sk) -> - Data_encoding.Binary.to_bytes_exn Ed25519.Secret_key.encoding sk + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk | Decrypted_sk (Secp256k1 sk) -> - Data_encoding.Binary.to_bytes_exn Secp256k1.Secret_key.encoding sk + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Secp256k1.Secret_key.encoding + sk | Decrypted_sk (P256 sk) -> - Data_encoding.Binary.to_bytes_exn P256.Secret_key.encoding sk + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.P256.Secret_key.encoding + sk | Decrypted_aggregate_sk (Bls12_381 sk) -> - Data_encoding.Binary.to_bytes_exn Bls.Secret_key.encoding sk + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Bls.Secret_key.encoding + sk in - Bytes.cat salt (Crypto_box.Secretbox.secretbox key msg nonce) + Bytes.cat salt (Tezos_crypto.Crypto_box.Secretbox.secretbox key msg nonce) let decrypt algo ~password ~encrypted_sk = let open Lwt_result_syntax in let salt = Bytes.sub encrypted_sk 0 salt_len in let encrypted_sk = Bytes.sub encrypted_sk salt_len encrypted_size in - let key = Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) in + let key = + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) + in match - (Crypto_box.Secretbox.secretbox_open key encrypted_sk nonce, algo) + ( Tezos_crypto.Crypto_box.Secretbox.secretbox_open key encrypted_sk nonce, + algo ) with | None, _ -> return_none - | Some bytes, Encrypted_sk Signature.Ed25519 -> ( + | Some bytes, Encrypted_sk Tezos_crypto.Signature.Ed25519 -> ( match - Data_encoding.Binary.of_bytes_opt Ed25519.Secret_key.encoding bytes + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.Ed25519.Secret_key.encoding + bytes with | Some sk -> - return_some (Decrypted_sk (Ed25519 sk : Signature.Secret_key.t)) + return_some + (Decrypted_sk (Ed25519 sk : Tezos_crypto.Signature.Secret_key.t)) | None -> failwith - "Corrupted wallet, deciphered key is not a valid Ed25519 secret \ - key") - | Some bytes, Encrypted_sk Signature.Secp256k1 -> ( + "Corrupted wallet, deciphered key is not a valid \ + Tezos_crypto.Ed25519 secret key") + | Some bytes, Encrypted_sk Tezos_crypto.Signature.Secp256k1 -> ( match - Data_encoding.Binary.of_bytes_opt Secp256k1.Secret_key.encoding bytes + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.Secp256k1.Secret_key.encoding + bytes with | Some sk -> - return_some (Decrypted_sk (Secp256k1 sk : Signature.Secret_key.t)) + return_some + (Decrypted_sk (Secp256k1 sk : Tezos_crypto.Signature.Secret_key.t)) | None -> failwith - "Corrupted wallet, deciphered key is not a valid Secp256k1 \ - secret key") - | Some bytes, Encrypted_sk Signature.P256 -> ( + "Corrupted wallet, deciphered key is not a valid \ + Tezos_crypto.Secp256k1 secret key") + | Some bytes, Encrypted_sk Tezos_crypto.Signature.P256 -> ( match - Data_encoding.Binary.of_bytes_opt P256.Secret_key.encoding bytes + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.P256.Secret_key.encoding + bytes with | Some sk -> - return_some (Decrypted_sk (P256 sk : Signature.Secret_key.t)) + return_some + (Decrypted_sk (P256 sk : Tezos_crypto.Signature.Secret_key.t)) | None -> failwith - "Corrupted wallet, deciphered key is not a valid P256 secret key") + "Corrupted wallet, deciphered key is not a valid \ + Tezos_crypto.P256 secret key") | Some bytes, Encrypted_aggregate_sk -> ( match - Data_encoding.Binary.of_bytes_opt Bls.Secret_key.encoding bytes + Data_encoding.Binary.of_bytes_opt + Tezos_crypto.Bls.Secret_key.encoding + bytes with | Some sk -> return_some (Decrypted_aggregate_sk - (Bls12_381 sk : Aggregate_signature.Secret_key.t)) + (Bls12_381 sk : Tezos_crypto.Aggregate_signature.Secret_key.t)) | None -> failwith "Corrupted wallet, deciphered key is not a valid BLS12_381 \ @@ -129,9 +157,12 @@ end module Encodings = struct let ed25519 = - let length = Hacl.Ed25519.sk_size + Crypto_box.tag_length + Raw.salt_len in - Base58.register_encoding - ~prefix:Base58.Prefix.ed25519_encrypted_seed + let length = + Tezos_crypto.Hacl.Ed25519.sk_size + Tezos_crypto.Crypto_box.tag_length + + Raw.salt_len + in + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.ed25519_encrypted_seed ~length ~to_raw:(fun sk -> Bytes.to_string sk) ~of_raw:(fun buf -> @@ -140,9 +171,11 @@ module Encodings = struct let secp256k1 = let open Libsecp256k1.External in - let length = Key.secret_bytes + Crypto_box.tag_length + Raw.salt_len in - Base58.register_encoding - ~prefix:Base58.Prefix.secp256k1_encrypted_secret_key + let length = + Key.secret_bytes + Tezos_crypto.Crypto_box.tag_length + Raw.salt_len + in + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.secp256k1_encrypted_secret_key ~length ~to_raw:(fun sk -> Bytes.to_string sk) ~of_raw:(fun buf -> @@ -150,9 +183,12 @@ module Encodings = struct ~wrap:(fun sk -> Encrypted_secp256k1 sk) let p256 = - let length = Hacl.P256.sk_size + Crypto_box.tag_length + Raw.salt_len in - Base58.register_encoding - ~prefix:Base58.Prefix.p256_encrypted_secret_key + let length = + Tezos_crypto.Hacl.P256.sk_size + Tezos_crypto.Crypto_box.tag_length + + Raw.salt_len + in + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.p256_encrypted_secret_key ~length ~to_raw:(fun sk -> Bytes.to_string sk) ~of_raw:(fun buf -> @@ -162,11 +198,11 @@ module Encodings = struct let bls12_381 = let length = (* 32 + 16 + 8 = 56 *) - Bls12_381_signature.sk_size_in_bytes + Crypto_box.tag_length + Bls12_381_signature.sk_size_in_bytes + Tezos_crypto.Crypto_box.tag_length + Raw.salt_len in - Base58.register_encoding - ~prefix:Base58.Prefix.bls12_381_encrypted_secret_key + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.bls12_381_encrypted_secret_key ~length ~to_raw:(fun sk -> Bytes.to_string sk) ~of_raw:(fun buf -> @@ -174,9 +210,9 @@ module Encodings = struct ~wrap:(fun sk -> Encrypted_bls12_381 sk) let secp256k1_scalar = - let length = 36 + Crypto_box.tag_length + Raw.salt_len in - Base58.register_encoding - ~prefix:Base58.Prefix.secp256k1_encrypted_scalar + let length = 36 + Tezos_crypto.Crypto_box.tag_length + Raw.salt_len in + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.secp256k1_encrypted_scalar ~length ~to_raw:(fun sk -> Bytes.to_string sk) ~of_raw:(fun buf -> @@ -184,11 +220,11 @@ module Encodings = struct ~wrap:(fun sk -> Encrypted_secp256k1_element sk) let () = - Base58.check_encoded_prefix ed25519 "edesk" 88 ; - Base58.check_encoded_prefix secp256k1 "spesk" 88 ; - Base58.check_encoded_prefix p256 "p2esk" 88 ; - Base58.check_encoded_prefix bls12_381 "BLesk" 88 ; - Base58.check_encoded_prefix secp256k1_scalar "seesk" 93 + Tezos_crypto.Base58.check_encoded_prefix ed25519 "edesk" 88 ; + Tezos_crypto.Base58.check_encoded_prefix secp256k1 "spesk" 88 ; + Tezos_crypto.Base58.check_encoded_prefix p256 "p2esk" 88 ; + Tezos_crypto.Base58.check_encoded_prefix bls12_381 "BLesk" 88 ; + Tezos_crypto.Base58.check_encoded_prefix secp256k1_scalar "seesk" 93 end (* we cache the password in this list to avoid @@ -264,13 +300,13 @@ let rec noninteractive_decrypt_loop algo ~encrypted_sk = let decrypt_payload cctxt ?name encrypted_sk = let open Lwt_result_syntax in let* algo, encrypted_sk = - match Base58.decode encrypted_sk with + match Tezos_crypto.Base58.decode encrypted_sk with | Some (Encrypted_ed25519 encrypted_sk) -> - return (Encrypted_sk Signature.Ed25519, encrypted_sk) + return (Encrypted_sk Tezos_crypto.Signature.Ed25519, encrypted_sk) | Some (Encrypted_secp256k1 encrypted_sk) -> - return (Encrypted_sk Signature.Secp256k1, encrypted_sk) + return (Encrypted_sk Tezos_crypto.Signature.Secp256k1, encrypted_sk) | Some (Encrypted_p256 encrypted_sk) -> - return (Encrypted_sk Signature.P256, encrypted_sk) + return (Encrypted_sk Tezos_crypto.Signature.P256, encrypted_sk) | Some (Encrypted_bls12_381 encrypted_sk) -> return (Encrypted_aggregate_sk, encrypted_sk) | _ -> failwith "Not a Base58Check-encoded encrypted key" @@ -364,7 +400,7 @@ let common_encrypt sk password = | Decrypted_sk (P256 _) -> Encodings.p256 | Decrypted_aggregate_sk (Bls12_381 _) -> Encodings.bls12_381 in - Base58.simple_encode encoding payload + Tezos_crypto.Base58.simple_encode encoding payload let internal_encrypt_simple sk password = let open Lwt_result_syntax in @@ -400,33 +436,40 @@ module Sapling_raw = struct let salt_len = 8 (* 193 *) - let encrypted_size = Crypto_box.tag_length + salt_len + 169 + let encrypted_size = Tezos_crypto.Crypto_box.tag_length + salt_len + 169 - let nonce = Crypto_box.zero_nonce + let nonce = Tezos_crypto.Crypto_box.zero_nonce let pbkdf ~salt ~password = Pbkdf.SHA512.pbkdf2 ~count:32768 ~dk_len:32l ~salt ~password let encrypt ~password msg = let msg = Tezos_sapling.Core.Wallet.Spending_key.to_bytes msg in - let salt = Hacl.Rand.gen salt_len in - let key = Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) in - Bytes.(to_string (cat salt (Crypto_box.Secretbox.secretbox key msg nonce))) + let salt = Tezos_crypto.Hacl.Rand.gen salt_len in + let key = + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) + in + Bytes.( + to_string + (cat salt (Tezos_crypto.Crypto_box.Secretbox.secretbox key msg nonce))) let decrypt ~password payload = let ebytes = Bytes.of_string payload in let salt = Bytes.sub ebytes 0 salt_len in let encrypted_sk = Bytes.sub ebytes salt_len (encrypted_size - salt_len) in - let key = Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) in + let key = + Tezos_crypto.Crypto_box.Secretbox.unsafe_of_bytes (pbkdf ~salt ~password) + in Option.bind - (Crypto_box.Secretbox.secretbox_open key encrypted_sk nonce) + (Tezos_crypto.Crypto_box.Secretbox.secretbox_open key encrypted_sk nonce) Tezos_sapling.Core.Wallet.Spending_key.of_bytes - type Base58.data += Data of Tezos_sapling.Core.Wallet.Spending_key.t + type Tezos_crypto.Base58.data += + | Data of Tezos_sapling.Core.Wallet.Spending_key.t let encrypted_b58_encoding password = - Base58.register_encoding - ~prefix:Base58.Prefix.sapling_spending_key + Tezos_crypto.Base58.register_encoding + ~prefix:Tezos_crypto.Base58.Prefix.sapling_spending_key ~length:encrypted_size ~to_raw:(encrypt ~password) ~of_raw:(decrypt ~password) @@ -437,7 +480,9 @@ let encrypt_sapling_key cctxt sk = let open Lwt_result_syntax in let* password = read_password cctxt in let path = - Base58.simple_encode (Sapling_raw.encrypted_b58_encoding password) sk + Tezos_crypto.Base58.simple_encode + (Sapling_raw.encrypted_b58_encoding password) + sk in let*? v = Client_keys.make_sapling_uri (Uri.make ~scheme ~path ()) in return v @@ -451,7 +496,9 @@ let decrypt_sapling_key (cctxt : #Client_context.io) (sk_uri : sapling_uri) = cctxt#prompt_password "Enter password to decrypt your key: " in match - Base58.simple_decode (Sapling_raw.encrypted_b58_encoding password) payload + Tezos_crypto.Base58.simple_decode + (Sapling_raw.encrypted_b58_encoding password) + payload with | None -> failwith @@ -460,7 +507,7 @@ let decrypt_sapling_key (cctxt : #Client_context.io) (sk_uri : sapling_uri) = | Some sapling_key -> return sapling_key else match - Base58.simple_decode + Tezos_crypto.Base58.simple_decode Tezos_sapling.Core.Wallet.Spending_key.b58check_encoding payload with @@ -481,10 +528,11 @@ struct "Valid secret key URIs are of the form\n\ \ - encrypted:\n\ where is the encrypted (password protected using Nacl's \ - cryptobox and pbkdf) secret key, formatted in unprefixed Base58.\n\ + cryptobox and pbkdf) secret key, formatted in unprefixed \ + Tezos_crypto.Base58.\n\ Valid public key URIs are of the form\n\ \ - encrypted:\n\ - where is the public key in Base58." + where is the public key in Tezos_crypto.Base58." include Client_keys.Signature_type @@ -497,23 +545,25 @@ struct let neuterize sk_uri = let open Lwt_result_syntax in let* sk = decrypt C.cctxt sk_uri in - let*? v = Unencrypted.make_pk (Signature.Secret_key.to_public_key sk) in + let*? v = + Unencrypted.make_pk (Tezos_crypto.Signature.Secret_key.to_public_key sk) + in return v let sign ?watermark sk_uri buf = let open Lwt_result_syntax in let* sk = decrypt C.cctxt sk_uri in - return (Signature.sign ?watermark sk buf) + return (Tezos_crypto.Signature.sign ?watermark sk buf) let deterministic_nonce sk_uri buf = let open Lwt_result_syntax in let* sk = decrypt C.cctxt sk_uri in - return (Signature.deterministic_nonce sk buf) + return (Tezos_crypto.Signature.deterministic_nonce sk buf) let deterministic_nonce_hash sk_uri buf = let open Lwt_result_syntax in let* sk = decrypt C.cctxt sk_uri in - return (Signature.deterministic_nonce_hash sk buf) + return (Tezos_crypto.Signature.deterministic_nonce_hash sk buf) let supports_deterministic_nonces _ = Lwt_result_syntax.return_true end @@ -530,10 +580,11 @@ struct "Valid aggregate secret key URIs are of the form\n\ \ - aggregate_encrypted:\n\ where is the encrypted (password protected using Nacl's \ - cryptobox and pbkdf) secret key, formatted in unprefixed Base58.\n\ + cryptobox and pbkdf) secret key, formatted in unprefixed \ + Tezos_crypto.Base58.\n\ Valid aggregate public key URIs are of the form\n\ \ - aggregate_encrypted:\n\ - where is the public key in Base58." + where is the public key in Tezos_crypto.Base58." include Client_keys.Aggregate_type @@ -548,12 +599,12 @@ struct let* sk = decrypt_aggregate C.cctxt sk_uri in let*? v = Unencrypted.Aggregate.make_pk - (Aggregate_signature.Secret_key.to_public_key sk) + (Tezos_crypto.Aggregate_signature.Secret_key.to_public_key sk) in return v let sign sk_uri buf = let open Lwt_result_syntax in let* sk = decrypt_aggregate C.cctxt sk_uri in - return (Aggregate_signature.sign sk buf) + return (Tezos_crypto.Aggregate_signature.sign sk buf) end diff --git a/src/lib_signer_backends/encrypted.mli b/src/lib_signer_backends/encrypted.mli index b0c37d4266bb..2be1ae1a2943 100644 --- a/src/lib_signer_backends/encrypted.mli +++ b/src/lib_signer_backends/encrypted.mli @@ -35,13 +35,13 @@ val decrypt : #Client_context.io_wallet -> ?name:string -> Client_keys.sk_uri -> - Signature.secret_key tzresult Lwt.t + Tezos_crypto.Signature.secret_key tzresult Lwt.t val decrypt_aggregate : #Client_context.io_wallet -> ?name:string -> Client_keys.aggregate_sk_uri -> - Aggregate_signature.secret_key tzresult Lwt.t + Tezos_crypto.Aggregate_signature.secret_key tzresult Lwt.t val decrypt_all : #Client_context.io_wallet -> unit tzresult Lwt.t @@ -49,13 +49,16 @@ val decrypt_list : #Client_context.io_wallet -> string list -> unit tzresult Lwt.t (** Encrypts a secret key using the given password *) -val encrypt : Signature.secret_key -> bytes -> Client_keys.sk_uri tzresult Lwt.t +val encrypt : + Tezos_crypto.Signature.secret_key -> + bytes -> + Client_keys.sk_uri tzresult Lwt.t (** Prompts password twice to user for confirmation and returns the corresponding encrypted secret key *) val prompt_twice_and_encrypt : #Client_context.io -> - Signature.secret_key -> + Tezos_crypto.Signature.secret_key -> Client_keys.sk_uri tzresult Lwt.t (** [prompt_twice_and_encrypt_aggregate cctxt sk] Prompts password twice to user @@ -63,7 +66,7 @@ val prompt_twice_and_encrypt : key *) val prompt_twice_and_encrypt_aggregate : #Client_context.io -> - Aggregate_signature.secret_key -> + Tezos_crypto.Aggregate_signature.secret_key -> Client_keys.aggregate_sk_uri tzresult Lwt.t val encrypt_sapling_key : diff --git a/src/lib_signer_backends/http.mli b/src/lib_signer_backends/http.mli index 6863d04cab8a..eae9cfa9f0a4 100644 --- a/src/lib_signer_backends/http.mli +++ b/src/lib_signer_backends/http.mli @@ -26,9 +26,9 @@ module Make (RPC_client : RPC_client.S) (P : sig val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) : Client_keys.SIGNER diff --git a/src/lib_signer_backends/http_gen.ml b/src/lib_signer_backends/http_gen.ml index c94563e58baf..d2ef037e4b57 100644 --- a/src/lib_signer_backends/http_gen.ml +++ b/src/lib_signer_backends/http_gen.ml @@ -32,9 +32,9 @@ struct module Make (RPC_client : RPC_client.S) (P : sig val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) = @@ -106,7 +106,9 @@ struct let path = String.sub path 0 i in return (Uri.with_path uri path, pkh) in - let* pkh = Lwt.return (Signature.Public_key_hash.of_b58check pkh) in + let* pkh = + Lwt.return (Tezos_crypto.Signature.Public_key_hash.of_b58check pkh) + in return (base, pkh) let public_key uri = @@ -130,7 +132,7 @@ struct let public_key_hash uri = let open Lwt_result_syntax in let* pk = public_key uri in - return (Signature.Public_key.hash pk, Some pk) + return (Tezos_crypto.Signature.Public_key.hash pk, Some pk) let import_secret_key ~io:_ = public_key_hash @@ -164,7 +166,7 @@ struct match watermark with | None -> msg | Some watermark -> - Bytes.cat (Signature.bytes_of_watermark watermark) msg + Bytes.cat (Tezos_crypto.Signature.bytes_of_watermark watermark) msg in let* signature = get_signature base pkh msg in RPC_client.call_service diff --git a/src/lib_signer_backends/http_gen.mli b/src/lib_signer_backends/http_gen.mli index 5fc06a251768..5f7ec48809a9 100644 --- a/src/lib_signer_backends/http_gen.mli +++ b/src/lib_signer_backends/http_gen.mli @@ -29,9 +29,9 @@ end) : sig module Make (RPC_client : RPC_client.S) (P : sig val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) : Client_keys.SIGNER diff --git a/src/lib_signer_backends/https.mli b/src/lib_signer_backends/https.mli index 6863d04cab8a..eae9cfa9f0a4 100644 --- a/src/lib_signer_backends/https.mli +++ b/src/lib_signer_backends/https.mli @@ -26,9 +26,9 @@ module Make (RPC_client : RPC_client.S) (P : sig val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) : Client_keys.SIGNER diff --git a/src/lib_signer_backends/test/dune b/src/lib_signer_backends/test/dune index 86ae744e2a7e..87c7885348c9 100644 --- a/src/lib_signer_backends/test/dune +++ b/src/lib_signer_backends/test/dune @@ -18,7 +18,6 @@ -open Tezos_stdlib -open Tezos_error_monad -open Tezos_error_monad.TzLwtreslib - -open Tezos_crypto -open Tezos_client_base -open Tezos_signer_backends)) diff --git a/src/lib_signer_backends/test/test_encrypted.ml b/src/lib_signer_backends/test/test_encrypted.ml index 7e1831730a46..9f5509b86fc5 100644 --- a/src/lib_signer_backends/test/test_encrypted.ml +++ b/src/lib_signer_backends/test/test_encrypted.ml @@ -178,12 +178,14 @@ let bls12_381_sks_encrypted = ] let sk_testable = - Alcotest.testable Signature.Secret_key.pp Signature.Secret_key.equal + Alcotest.testable + Tezos_crypto.Signature.Secret_key.pp + Tezos_crypto.Signature.Secret_key.equal let aggregate_sk_testable = Alcotest.testable - Aggregate_signature.Secret_key.pp - Aggregate_signature.Secret_key.equal + Tezos_crypto.Aggregate_signature.Secret_key.pp + Tezos_crypto.Aggregate_signature.Secret_key.equal let test_vectors () = let open Encrypted in @@ -191,7 +193,9 @@ let test_vectors () = (fun (sks, encrypted_sks) -> let open Lwt_result_syntax in let ctx = fake_ctx () in - let sks = List.map Signature.Secret_key.of_b58check_exn sks in + let sks = + List.map Tezos_crypto.Signature.Secret_key.of_b58check_exn sks + in let*? l = encrypted_sks in let* decs = List.map_es (decrypt ctx) l in assert (decs = sks) ; @@ -208,10 +212,13 @@ let test_vectors_aggregate () = (fun (sks, encrypted_sks) -> let open Lwt_result_syntax in let ctx = fake_ctx () in - let sks = List.map Aggregate_signature.Secret_key.of_b58check_exn sks in + let sks = + List.map Tezos_crypto.Aggregate_signature.Secret_key.of_b58check_exn sks + in let*? l = encrypted_sks in let* decs = List.map_es (decrypt_aggregate ctx) l in - assert (List.equal Aggregate_signature.Secret_key.equal decs sks) ; + assert ( + List.equal Tezos_crypto.Aggregate_signature.Secret_key.equal decs sks) ; return_unit) [(bls12_381_sks, bls12_381_sks_encrypted)] @@ -223,7 +230,7 @@ let test_random algo = let open Lwt_result_syntax in if i >= loops then return_unit else - let _, _, sk = Signature.generate_key ~algo () in + let _, _, sk = Tezos_crypto.Signature.generate_key ~algo () in let* sk_uri = Tezos_signer_backends.Encrypted.prompt_twice_and_encrypt ctx sk in @@ -241,7 +248,7 @@ let test_random_aggregate () = let open Lwt_result_syntax in if i >= loops then return_unit else - let _, _, sk = Aggregate_signature.generate_key () in + let _, _, sk = Tezos_crypto.Aggregate_signature.generate_key () in let* sk_uri = Tezos_signer_backends.Encrypted.prompt_twice_and_encrypt_aggregate ctx @@ -257,7 +264,7 @@ let test_random_aggregate () = in inner 0 -(** For each of the algorithms [Ed25519; Secp256k1; P256], creates a +(** For each of the algorithms [[Ed25519; Secp256k1; P256]], creates a dummy context. It randomly generates a Base58-encoded secret key, then encrypts it into a URI and decrypts it. It it asserted that the secret key is preserved after Base58-decoding comparison. This @@ -265,12 +272,14 @@ let test_random_aggregate () = *) let test_random _switch () = let open Lwt_syntax in - let* r = List.iter_es test_random Signature.[Ed25519; Secp256k1; P256] in + let* r = + List.iter_es test_random Tezos_crypto.Signature.[Ed25519; Secp256k1; P256] + in match r with | Ok _ -> Lwt.return_unit | Error _ -> Lwt.fail_with "test_random" -(** For each of the algorithms [Ed25519; Secp256k1; P256], creates a +(** For each of the algorithms [[Ed25519; Secp256k1; P256]], creates a dummy context, uses it to decrypt a list of secret key URIs [...__sks_encrypted]. It is asserted that the decrypted keys shall match the list [..._sks]. diff --git a/src/lib_signer_backends/unencrypted.ml b/src/lib_signer_backends/unencrypted.ml index 612ebf3b39ea..1d84f31e8dc4 100644 --- a/src/lib_signer_backends/unencrypted.ml +++ b/src/lib_signer_backends/unencrypted.ml @@ -31,21 +31,21 @@ let description = "Please DO NOT USE this signer outside of test environments.\n\ Valid secret key URIs are of the form\n\ \ - unencrypted:\n\ - where is the secret key in Base58.\n\ + where is the secret key in Tezos_crypto.Base58.\n\ Valid public key URIs are of the form\n\ \ - unencrypted:\n\ - where is the public key in Base58." + where is the public key in Tezos_crypto.Base58." let make_sapling_key sk = let path = - Base58.simple_encode + Tezos_crypto.Base58.simple_encode Tezos_sapling.Core.Wallet.Spending_key.b58check_encoding sk in Client_keys.make_sapling_uri (Uri.make ~scheme ~path ()) module Make_common (S : sig - include S.COMMON_SIGNATURE + include Tezos_crypto.S.COMMON_SIGNATURE type public_key_hash = Public_key_hash.t @@ -99,7 +99,7 @@ struct end include Make_common (struct - include Signature + include Tezos_crypto.Signature include Client_keys.Signature_type let make_sk_uri = Client_keys.make_sk_uri @@ -112,23 +112,23 @@ end) let sign ?watermark sk_uri buf = let open Lwt_result_syntax in let* sk = secret_key sk_uri in - return (Signature.sign ?watermark sk buf) + return (Tezos_crypto.Signature.sign ?watermark sk buf) let deterministic_nonce sk_uri buf = let open Lwt_result_syntax in let* sk = secret_key sk_uri in - return (Signature.deterministic_nonce sk buf) + return (Tezos_crypto.Signature.deterministic_nonce sk buf) let deterministic_nonce_hash sk_uri buf = let open Lwt_result_syntax in let* sk = secret_key sk_uri in - return (Signature.deterministic_nonce_hash sk buf) + return (Tezos_crypto.Signature.deterministic_nonce_hash sk buf) let supports_deterministic_nonces _ = Lwt_result_syntax.return_true module Aggregate = struct include Make_common (struct - include Aggregate_signature + include Tezos_crypto.Aggregate_signature include Client_keys.Aggregate_type let make_sk_uri = Client_keys.make_aggregate_sk_uri @@ -141,5 +141,5 @@ module Aggregate = struct let sign sk_uri buf = let open Lwt_result_syntax in let+ sk = secret_key sk_uri in - Aggregate_signature.sign sk buf + Tezos_crypto.Aggregate_signature.sign sk buf end diff --git a/src/lib_signer_backends/unencrypted.mli b/src/lib_signer_backends/unencrypted.mli index 1ffdc016f534..56abce218586 100644 --- a/src/lib_signer_backends/unencrypted.mli +++ b/src/lib_signer_backends/unencrypted.mli @@ -25,9 +25,9 @@ include Client_keys.SIGNER -val make_pk : Signature.public_key -> Client_keys.pk_uri tzresult +val make_pk : Tezos_crypto.Signature.public_key -> Client_keys.pk_uri tzresult -val make_sk : Signature.secret_key -> Client_keys.sk_uri tzresult +val make_sk : Tezos_crypto.Signature.secret_key -> Client_keys.sk_uri tzresult val make_sapling_key : Tezos_sapling.Core.Wallet.Spending_key.t -> Client_keys.sapling_uri tzresult @@ -36,8 +36,10 @@ module Aggregate : sig include Client_keys.AGGREGATE_SIGNER val make_sk : - Aggregate_signature.secret_key -> Client_keys.aggregate_sk_uri tzresult + Tezos_crypto.Aggregate_signature.secret_key -> + Client_keys.aggregate_sk_uri tzresult val make_pk : - Aggregate_signature.public_key -> Client_keys.aggregate_pk_uri tzresult + Tezos_crypto.Aggregate_signature.public_key -> + Client_keys.aggregate_pk_uri tzresult end diff --git a/src/lib_signer_backends/unix/ledger.available.ml b/src/lib_signer_backends/unix/ledger.available.ml index 04eb53a2ad9e..3893b930e14c 100644 --- a/src/lib_signer_backends/unix/ledger.available.ml +++ b/src/lib_signer_backends/unix/ledger.available.ml @@ -88,9 +88,10 @@ let () = let () = let description ledger_hash computed_hash = let paren fmt hash_opt = - match Base.Option.bind ~f:Blake2B.of_string_opt hash_opt with + match Base.Option.bind ~f:Tezos_crypto.Blake2B.of_string_opt hash_opt with | None -> () - | Some hash -> Format.fprintf fmt " (%a)" Blake2B.pp_short hash + | Some hash -> + Format.fprintf fmt " (%a)" Tezos_crypto.Blake2B.pp_short hash in Format.asprintf "The ledger returned a hash%a which doesn't match the independently \ @@ -211,7 +212,9 @@ module Ledger_commands = struct let pk = Cstruct.to_bytes pk in TzEndian.set_int8 pk 0 0 ; (* hackish, but works. *) - Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding pk + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + pk | Secp256k1 -> let open Libsecp256k1.External in let buf = Bigstring.create (Key.compressed_pk_bytes + 1) in @@ -219,10 +222,10 @@ module Ledger_commands = struct EndianBigstring.BigEndian.set_int8 buf 0 1 ; let _nb_written = Key.write secp256k1_ctx ~pos:1 buf pk in Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding (Bigstring.to_bytes buf) | Secp256r1 -> ( - let open Hacl.P256 in + let open Tezos_crypto.Hacl.P256 in let buf = Bytes.create (pk_size + 1) in match pk_of_bytes (Cstruct.to_bytes pk) with | None -> @@ -230,11 +233,13 @@ module Ledger_commands = struct | Some pk -> TzEndian.set_int8 buf 0 2 ; blit_to_bytes pk ~pos:1 buf ; - Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding buf) + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + buf) let get_public_key = public_key_returning_instruction `Get_public_key - let pkh_of_pk = Signature.Public_key.hash + let pkh_of_pk = Tezos_crypto.Signature.Public_key.hash let public_key ?(first_import : Client_context.io_wallet option) hid curve path = @@ -247,7 +252,7 @@ module Ledger_commands = struct cctxt#message "Please validate@ (and write down)@ the public key hash@ \ displayed@ on the Ledger,@ it should be equal@ to `%a`:" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in get_public_key ~prompt:true hid curve path @@ -289,7 +294,9 @@ module Ledger_commands = struct let open Lwt_result_syntax in let msg = Option.fold watermark ~none:base_msg ~some:(fun watermark -> - Bytes.cat (Signature.bytes_of_watermark watermark) base_msg) + Bytes.cat + (Tezos_crypto.Signature.bytes_of_watermark watermark) + base_msg) in let path = Bip32_path.tezos_root @ path in let* hash_opt, signature = @@ -316,18 +323,23 @@ module Ledger_commands = struct match hash_opt with | None -> return_unit | Some hsh -> - let hash_msg = Blake2B.hash_bytes [msg] in - let ledger_one = Blake2B.of_bytes_exn (Cstruct.to_bytes hsh) in - if Blake2B.equal hash_msg ledger_one then return_unit + let hash_msg = Tezos_crypto.Blake2B.hash_bytes [msg] in + let ledger_one = + Tezos_crypto.Blake2B.of_bytes_exn (Cstruct.to_bytes hsh) + in + if Tezos_crypto.Blake2B.equal hash_msg ledger_one then return_unit else tzfail (Ledger_signing_hash_mismatch - (Blake2B.to_string ledger_one, Blake2B.to_string hash_msg)) + ( Tezos_crypto.Blake2B.to_string ledger_one, + Tezos_crypto.Blake2B.to_string hash_msg )) in match curve with | Ed25519 | Bip32_ed25519 -> - let signature = Ed25519.of_bytes_exn (Cstruct.to_bytes signature) in - return (Signature.of_ed25519 signature) + let signature = + Tezos_crypto.Ed25519.of_bytes_exn (Cstruct.to_bytes signature) + in + return (Tezos_crypto.Signature.of_ed25519 signature) | Secp256k1 -> (* Remove parity info *) Cstruct.(set_uint8 signature 0 (get_uint8 signature 0 land 0xfe)) ; @@ -335,8 +347,10 @@ module Ledger_commands = struct let open Libsecp256k1.External in let signature = Sign.read_der_exn secp256k1_ctx signature in let bytes = Sign.to_bytes secp256k1_ctx signature in - let signature = Secp256k1.of_bytes_exn (Bigstring.to_bytes bytes) in - return (Signature.of_secp256k1 signature) + let signature = + Tezos_crypto.Secp256k1.of_bytes_exn (Bigstring.to_bytes bytes) + in + return (Tezos_crypto.Signature.of_secp256k1 signature) | Secp256r1 -> (* Remove parity info *) Cstruct.(set_uint8 signature 0 (get_uint8 signature 0 land 0xfe)) ; @@ -345,8 +359,10 @@ module Ledger_commands = struct (* We use secp256r1 library to extract P256 DER signature. *) let signature = Sign.read_der_exn secp256k1_ctx signature in let buf = Sign.to_bytes secp256k1_ctx signature in - let signature = P256.of_bytes_exn (Bigstring.to_bytes buf) in - return (Signature.of_p256 signature) + let signature = + Tezos_crypto.P256.of_bytes_exn (Bigstring.to_bytes buf) + in + return (Tezos_crypto.Signature.of_p256 signature) let get_deterministic_nonce hid curve path msg = let open Lwt_result_syntax in @@ -370,23 +386,26 @@ module Ledger_id = struct The “ID” of the ledger is the animals (or pkh) corresponding to ["/ed25519/"] (first curve, no path). *) - type t = Animals of Ledger_names.t | Pkh of Signature.public_key_hash + type t = + | Animals of Ledger_names.t + | Pkh of Tezos_crypto.Signature.public_key_hash let animals_of_pkh pkh = - pkh |> Signature.Public_key_hash.to_string |> Ledger_names.crouching_tiger + pkh |> Tezos_crypto.Signature.Public_key_hash.to_string + |> Ledger_names.crouching_tiger let curve = Ledgerwallet_tezos.Ed25519 let get hidapi = let open Lwt_result_syntax in let* pk = Ledger_commands.get_public_key hidapi curve [] in - let pkh = Signature.Public_key.hash pk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in let animals = animals_of_pkh pkh in return (Animals animals) let pp ppf = function | Animals a -> Ledger_names.pp ppf a - | Pkh pkh -> Signature.Public_key_hash.pp ppf pkh + | Pkh pkh -> Tezos_crypto.Signature.Public_key_hash.pp ppf pkh let to_animals = function Animals a -> a | Pkh pkh -> animals_of_pkh pkh @@ -445,7 +464,9 @@ module Ledger_uri = struct let open Lwt_result_syntax in let host = Uri.host uri in let* ledger = - match Option.bind host Signature.Public_key_hash.of_b58check_opt with + match + Option.bind host Tezos_crypto.Signature.Public_key_hash.of_b58check_opt + with | Some pkh -> return (Ledger_id.Pkh pkh) | None -> ( match Option.bind host parse_animals with @@ -735,12 +756,19 @@ let use_ledger_or_fail ~ledger_uri ?(filter = `None) ?msg f = {!Signer_implementation.get_public_key} too often. *) module Global_cache : sig val record : - pk_uri -> pk:Signature.public_key -> pkh:Signature.public_key_hash -> unit - - val get : pk_uri -> (Signature.public_key_hash * Signature.public_key) option + pk_uri -> + pk:Tezos_crypto.Signature.public_key -> + pkh:Tezos_crypto.Signature.public_key_hash -> + unit + + val get : + pk_uri -> + (Tezos_crypto.Signature.public_key_hash * Tezos_crypto.Signature.public_key) + option end = struct let cache : - (Signature.Public_key_hash.t * Signature.Public_key.t) + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key.t) Client_keys.Pk_uri_hashtbl.t = Client_keys.Pk_uri_hashtbl.create 13 @@ -777,7 +805,7 @@ module Signer_implementation : Client_keys.SIGNER = struct let*? v = make_pk_uri (sk :> Uri.t) in return v - let pkh_of_pk = Signature.Public_key.hash + let pkh_of_pk = Tezos_crypto.Signature.Public_key.hash let public_key_maybe_prompt ?(first_import : Client_context.io_wallet option) (pk_uri : pk_uri) = @@ -844,7 +872,8 @@ module Signer_implementation : Client_keys.SIGNER = struct let deterministic_nonce_hash (sk : sk_uri) msg = let open Lwt_result_syntax in let* nonce = deterministic_nonce sk msg in - return (Blake2B.to_bytes (Blake2B.hash_bytes [nonce])) + return + (Tezos_crypto.Blake2B.to_bytes (Tezos_crypto.Blake2B.hash_bytes [nonce])) let supports_deterministic_nonces _ = Lwt_result_syntax.return_true end @@ -853,7 +882,12 @@ end let pp_ledger_chain_id fmt s = match s with | "\x00\x00\x00\x00" -> Format.fprintf fmt "'Unspecified'" - | other -> Format.fprintf fmt "%a" Chain_id.pp (Chain_id.of_string_exn other) + | other -> + Format.fprintf + fmt + "%a" + Tezos_crypto.Chain_id.pp + (Tezos_crypto.Chain_id.of_string_exn other) (** Commands for both ledger applications. *) let generic_commands group = @@ -981,19 +1015,19 @@ let generic_commands group = let*! () = cctxt#message "* Public Key: %a" - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp pk in let*! () = cctxt#message "* Public Key Hash: %a@\n" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh in match (test_sign, version.app_class) with | true, Tezos -> ( let pkh_bytes = - Signature.Public_key_hash.to_bytes pkh + Tezos_crypto.Signature.Public_key_hash.to_bytes pkh in (* Signing requires validation on the device. *) let*! () = @@ -1013,7 +1047,7 @@ let generic_commands group = pkh_bytes in match - Signature.check + Tezos_crypto.Signature.check ~watermark:Generic_operation pk signature @@ -1022,13 +1056,13 @@ let generic_commands group = | false -> failwith "Fatal: Ledger cannot sign with %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh | true -> let*! () = cctxt#message "Tezos Wallet successfully signed:@ %a." - Signature.pp + Tezos_crypto.Signature.pp signature in return_unit) @@ -1161,14 +1195,14 @@ let baking_commands group = curve path in - let pkh = Signature.Public_key.hash pk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in let*! () = cctxt#message "@[Authorized baking for address: %a@,\ Corresponding full public key: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp pk in return_some ())); @@ -1206,11 +1240,13 @@ let baking_commands group = | s -> ( try return (`Int32 (Int32.of_string s)) with _ -> ( - try return (`Chain_id (Chain_id.of_b58check_exn s)) + try + return + (`Chain_id (Tezos_crypto.Chain_id.of_b58check_exn s)) with _ -> failwith "Parameter %S should be a 32-bits integer or a \ - Base58 chain-id" + Tezos_crypto.Base58 chain-id" s))))) (hwm_arg "main") (hwm_arg "test")) @@ -1249,7 +1285,7 @@ let baking_commands group = logand 0xFFl (shift_right i32 (n * 8)) |> Int32.to_int |> char_of_int in - Chain_id.of_string_exn + Tezos_crypto.Chain_id.of_string_exn (Stringext.of_array (Array.init 4 (fun i -> byte (3 - i)))) in let* main_chain_id = @@ -1273,7 +1309,7 @@ let baking_commands group = Watermark: %ld%a -> %ld%a" pp_ledger_chain_id current_ci - Chain_id.pp + Tezos_crypto.Chain_id.pp main_chain_id current_mh pp_round_opt @@ -1291,19 +1327,21 @@ let baking_commands group = let* pk = Ledger_commands.public_key_returning_instruction (`Setup - (Chain_id.to_string main_chain_id, main_hwm, test_hwm)) + ( Tezos_crypto.Chain_id.to_string main_chain_id, + main_hwm, + test_hwm )) hidapi curve path in - let pkh = Signature.Public_key.hash pk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in let*! () = cctxt#message "@[Authorized baking for address: %a@,\ Corresponding full public key: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp pk in return_some ())); diff --git a/src/lib_signer_backends/unix/ledger_names.ml b/src/lib_signer_backends/unix/ledger_names.ml index 7ca628ce75be..57f47e3e3390 100644 --- a/src/lib_signer_backends/unix/ledger_names.ml +++ b/src/lib_signer_backends/unix/ledger_names.ml @@ -1624,7 +1624,8 @@ let animals = let pick a z = a.(Z.rem z (Array.length a |> Z.of_int) |> Z.to_int) -let hash a = Blake2B.hash_string [a] |> Blake2B.to_string +let hash a = + Tezos_crypto.Blake2B.hash_string [a] |> Tezos_crypto.Blake2B.to_string type t = {c : string; t : string; h : string; d : string} diff --git a/src/lib_signer_backends/unix/remote.ml b/src/lib_signer_backends/unix/remote.ml index 79d9a4b898c9..8925b17b72dd 100644 --- a/src/lib_signer_backends/unix/remote.ml +++ b/src/lib_signer_backends/unix/remote.ml @@ -32,9 +32,9 @@ module Make val default : Uri.t val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) = @@ -127,11 +127,17 @@ end let make_sk sk = Client_keys.make_sk_uri - (Uri.make ~scheme ~path:(Signature.Secret_key.to_b58check sk) ()) + (Uri.make + ~scheme + ~path:(Tezos_crypto.Signature.Secret_key.to_b58check sk) + ()) let make_pk pk = Client_keys.make_pk_uri - (Uri.make ~scheme ~path:(Signature.Public_key.to_b58check pk) ()) + (Uri.make + ~scheme + ~path:(Tezos_crypto.Signature.Public_key.to_b58check pk) + ()) let read_base_uri_from_env () = let open Lwt_result_syntax in diff --git a/src/lib_signer_backends/unix/remote.mli b/src/lib_signer_backends/unix/remote.mli index 9a7ef35993a4..6956e9cb2193 100644 --- a/src/lib_signer_backends/unix/remote.mli +++ b/src/lib_signer_backends/unix/remote.mli @@ -28,16 +28,16 @@ module Make val default : Uri.t val authenticate : - Signature.Public_key_hash.t list -> + Tezos_crypto.Signature.Public_key_hash.t list -> Bytes.t -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val logger : RPC_client.logger end) : Client_keys.SIGNER -val make_pk : Signature.public_key -> Client_keys.pk_uri tzresult +val make_pk : Tezos_crypto.Signature.public_key -> Client_keys.pk_uri tzresult -val make_sk : Signature.secret_key -> Client_keys.sk_uri tzresult +val make_sk : Tezos_crypto.Signature.secret_key -> Client_keys.sk_uri tzresult val read_base_uri_from_env : unit -> Uri.t option tzresult Lwt.t diff --git a/src/lib_signer_backends/unix/socket.ml b/src/lib_signer_backends/unix/socket.ml index 072d4773e90d..bac66775a689 100644 --- a/src/lib_signer_backends/unix/socket.ml +++ b/src/lib_signer_backends/unix/socket.ml @@ -33,7 +33,9 @@ let unix_scheme = "unix" module Make (P : sig val authenticate : - Signature.Public_key_hash.t list -> Bytes.t -> Signature.t tzresult Lwt.t + Tezos_crypto.Signature.Public_key_hash.t list -> + Bytes.t -> + Tezos_crypto.Signature.t tzresult Lwt.t end) = struct open P @@ -100,7 +102,8 @@ struct let msg = match watermark with | None -> msg - | Some watermark -> Bytes.cat (Signature.bytes_of_watermark watermark) msg + | Some watermark -> + Bytes.cat (Tezos_crypto.Signature.bytes_of_watermark watermark) msg in with_signer_operation path pkh msg Sign_request Sign.Response.encoding @@ -166,7 +169,7 @@ struct match Uri.get_query_param uri "pkh" with | None -> error_with "Missing the query parameter: 'pkh=tz1...'" | Some key -> - let+ key = Signature.Public_key_hash.of_b58check key in + let+ key = Tezos_crypto.Signature.Public_key_hash.of_b58check key in (Tezos_base_unix.Socket.Unix (Uri.path uri), key) let parse uri = parse uri |> record_trace (Invalid_uri uri) |> Lwt.return @@ -184,7 +187,7 @@ struct let public_key_hash uri = let open Lwt_result_syntax in let* pk = public_key uri in - return (Signature.Public_key.hash pk, Some pk) + return (Tezos_crypto.Signature.Public_key.hash pk, Some pk) let import_secret_key ~io:_ = public_key_hash @@ -229,7 +232,7 @@ struct | Some path, Some port -> let pkh = Uri.path uri in let pkh = try String.(sub pkh 1 (length pkh - 1)) with _ -> "" in - let+ pkh = Signature.Public_key_hash.of_b58check pkh in + let+ pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check pkh in let tcp_socket = Tezos_base_unix.Socket.Tcp (path, string_of_int port, [Lwt_unix.AI_SOCKTYPE SOCK_STREAM]) @@ -251,7 +254,7 @@ struct let public_key_hash uri = let open Lwt_result_syntax in let* pk = public_key uri in - return (Signature.Public_key.hash pk, Some pk) + return (Tezos_crypto.Signature.Public_key.hash pk, Some pk) let import_secret_key ~io:_ = public_key_hash diff --git a/src/lib_signer_backends/unix/socket.mli b/src/lib_signer_backends/unix/socket.mli index 18a5f14a873a..7fd08d547f39 100644 --- a/src/lib_signer_backends/unix/socket.mli +++ b/src/lib_signer_backends/unix/socket.mli @@ -25,7 +25,9 @@ module Make (P : sig val authenticate : - Signature.Public_key_hash.t list -> Bytes.t -> Signature.t tzresult Lwt.t + Tezos_crypto.Signature.Public_key_hash.t list -> + Bytes.t -> + Tezos_crypto.Signature.t tzresult Lwt.t end) : sig module Unix : Client_keys.SIGNER diff --git a/src/lib_signer_backends/unix/test/dune b/src/lib_signer_backends/unix/test/dune index d432ec1b1447..57e58af23ed9 100644 --- a/src/lib_signer_backends/unix/test/dune +++ b/src/lib_signer_backends/unix/test/dune @@ -14,7 +14,6 @@ (:standard) -open Tezos_error_monad -open Tezos_stdlib - -open Tezos_crypto -open Tezos_client_base -open Tezos_signer_backends_unix)) diff --git a/src/lib_signer_services/signer_messages.ml b/src/lib_signer_services/signer_messages.ml index 7f07c1ccc2c1..38d0fb282d78 100644 --- a/src/lib_signer_services/signer_messages.ml +++ b/src/lib_signer_services/signer_messages.ml @@ -25,12 +25,13 @@ module type Authenticated_request = sig type t = { - pkh : Signature.Public_key_hash.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; data : Bytes.t; - signature : Signature.t option; + signature : Tezos_crypto.Signature.t option; } - val to_sign : pkh:Signature.Public_key_hash.t -> data:Bytes.t -> Bytes.t + val to_sign : + pkh:Tezos_crypto.Signature.Public_key_hash.t -> data:Bytes.t -> Bytes.t val encoding : t Data_encoding.t end @@ -41,9 +42,9 @@ end module Make_authenticated_request (T : Tag) : Authenticated_request = struct type t = { - pkh : Signature.Public_key_hash.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; data : Bytes.t; - signature : Signature.t option; + signature : Tezos_crypto.Signature.t option; } let x04 = Bytes.of_string "\x04" @@ -53,7 +54,7 @@ module Make_authenticated_request (T : Tag) : Authenticated_request = struct TzEndian.set_int8 tag 0 T.tag ; Bytes.concat Bytes.empty - [x04; tag; Signature.Public_key_hash.to_bytes pkh; data] + [x04; tag; Tezos_crypto.Signature.Public_key_hash.to_bytes pkh; data] let encoding = let open Data_encoding in @@ -61,9 +62,9 @@ module Make_authenticated_request (T : Tag) : Authenticated_request = struct (fun {pkh; data; signature} -> (pkh, data, signature)) (fun (pkh, data, signature) -> {pkh; data; signature}) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) (req "data" bytes) - (opt "signature" Signature.encoding)) + (opt "signature" Tezos_crypto.Signature.encoding)) end module Sign = struct @@ -72,12 +73,12 @@ module Sign = struct end) module Response = struct - type t = Signature.t + type t = Tezos_crypto.Signature.t let encoding = let open Data_encoding in def "signer_messages.sign.response" - @@ obj1 (req "signature" Signature.encoding) + @@ obj1 (req "signature" Tezos_crypto.Signature.encoding) end end @@ -113,12 +114,12 @@ end module Supports_deterministic_nonces = struct module Request = struct - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t let encoding = let open Data_encoding in def "signer_messages.supports_deterministic_nonces.request" - @@ obj1 (req "pkh" Signature.Public_key_hash.encoding) + @@ obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) end module Response = struct @@ -133,21 +134,21 @@ end module Public_key = struct module Request = struct - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t let encoding = let open Data_encoding in def "signer_messages.public_key.request" - @@ obj1 (req "pkh" Signature.Public_key_hash.encoding) + @@ obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) end module Response = struct - type t = Signature.Public_key.t + type t = Tezos_crypto.Signature.Public_key.t let encoding = let open Data_encoding in def "signer_messages.public_key.response" - @@ obj1 (req "pubkey" Signature.Public_key.encoding) + @@ obj1 (req "pubkey" Tezos_crypto.Signature.Public_key.encoding) end end @@ -155,7 +156,7 @@ module Authorized_keys = struct module Response = struct type t = | No_authentication - | Authorized_keys of Signature.Public_key_hash.t list + | Authorized_keys of Tezos_crypto.Signature.Public_key_hash.t list let encoding = let open Data_encoding in @@ -170,7 +171,7 @@ module Authorized_keys = struct case (Tag 1) ~title:"Authorized_keys" - (list Signature.Public_key_hash.encoding) + (list Tezos_crypto.Signature.Public_key_hash.encoding) (function Authorized_keys l -> Some l | _ -> None) (fun l -> Authorized_keys l); ] diff --git a/src/lib_signer_services/signer_messages.mli b/src/lib_signer_services/signer_messages.mli index bc8a1643623d..fa98fde95543 100644 --- a/src/lib_signer_services/signer_messages.mli +++ b/src/lib_signer_services/signer_messages.mli @@ -25,12 +25,13 @@ module type Authenticated_request = sig type t = { - pkh : Signature.Public_key_hash.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; data : Bytes.t; - signature : Signature.t option; + signature : Tezos_crypto.Signature.t option; } - val to_sign : pkh:Signature.Public_key_hash.t -> data:Bytes.t -> Bytes.t + val to_sign : + pkh:Tezos_crypto.Signature.Public_key_hash.t -> data:Bytes.t -> Bytes.t val encoding : t Data_encoding.t end @@ -39,7 +40,7 @@ module Sign : sig module Request : Authenticated_request module Response : sig - type t = Signature.t + type t = Tezos_crypto.Signature.t val encoding : t Data_encoding.t end @@ -67,7 +68,7 @@ end module Supports_deterministic_nonces : sig module Request : sig - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t val encoding : t Data_encoding.t end @@ -81,13 +82,13 @@ end module Public_key : sig module Request : sig - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t val encoding : t Data_encoding.t end module Response : sig - type t = Signature.Public_key.t + type t = Tezos_crypto.Signature.Public_key.t val encoding : t Data_encoding.t end @@ -97,7 +98,7 @@ module Authorized_keys : sig module Response : sig type t = | No_authentication - | Authorized_keys of Signature.Public_key_hash.t list + | Authorized_keys of Tezos_crypto.Signature.Public_key_hash.t list val encoding : t Data_encoding.t end diff --git a/src/lib_signer_services/signer_services.ml b/src/lib_signer_services/signer_services.ml index 4c0b1f22921b..3ab2a4f3ce57 100644 --- a/src/lib_signer_services/signer_services.ml +++ b/src/lib_signer_services/signer_services.ml @@ -32,7 +32,7 @@ let query = case, it must be the signature of the public key hash and message \ concatenated, by one of the keys authorized by the signer." "authentication" - Signature.rpc_arg + Tezos_crypto.Signature.rpc_arg (fun signature -> signature) |> seal @@ -41,8 +41,10 @@ let sign = ~description:"Sign a piece of data with a given remote key" ~query ~input:Data_encoding.bytes - ~output:Data_encoding.(obj1 (req "signature" Signature.encoding)) - Tezos_rpc.Path.(root / "keys" /: Signature.Public_key_hash.rpc_arg) + ~output: + Data_encoding.(obj1 (req "signature" Tezos_crypto.Signature.encoding)) + Tezos_rpc.Path.( + root / "keys" /: Tezos_crypto.Signature.Public_key_hash.rpc_arg) let deterministic_nonce = Tezos_rpc.Service.post_service @@ -52,7 +54,8 @@ let deterministic_nonce = ~query ~input:Data_encoding.bytes ~output:Data_encoding.(obj1 (req "deterministic_nonce" bytes)) - Tezos_rpc.Path.(root / "keys" /: Signature.Public_key_hash.rpc_arg) + Tezos_rpc.Path.( + root / "keys" /: Tezos_crypto.Signature.Public_key_hash.rpc_arg) let deterministic_nonce_hash = Tezos_rpc.Service.post_service @@ -62,7 +65,8 @@ let deterministic_nonce_hash = ~query ~input:Data_encoding.bytes ~output:Data_encoding.(obj1 (req "deterministic_nonce_hash" bytes)) - Tezos_rpc.Path.(root / "keys" /: Signature.Public_key_hash.rpc_arg) + Tezos_rpc.Path.( + root / "keys" /: Tezos_crypto.Signature.Public_key_hash.rpc_arg) let supports_deterministic_nonces = Tezos_rpc.Service.get_service @@ -71,15 +75,18 @@ let supports_deterministic_nonces = functionality" ~query:Tezos_rpc.Query.empty ~output:Data_encoding.(obj1 (req "supports_deterministic_nonces" bool)) - Tezos_rpc.Path.(root / "keys" /: Signature.Public_key_hash.rpc_arg) + Tezos_rpc.Path.( + root / "keys" /: Tezos_crypto.Signature.Public_key_hash.rpc_arg) let public_key = Tezos_rpc.Service.get_service ~description:"Retrieve the public key of a given remote key" ~query:Tezos_rpc.Query.empty ~output: - Data_encoding.(obj1 (req "public_key" Signature.Public_key.encoding)) - Tezos_rpc.Path.(root / "keys" /: Signature.Public_key_hash.rpc_arg) + Data_encoding.( + obj1 (req "public_key" Tezos_crypto.Signature.Public_key.encoding)) + Tezos_rpc.Path.( + root / "keys" /: Tezos_crypto.Signature.Public_key_hash.rpc_arg) let authorized_keys = Tezos_rpc.Service.get_service @@ -91,5 +98,8 @@ let authorized_keys = ~query:Tezos_rpc.Query.empty ~output: Data_encoding.( - obj1 (opt "authorized_keys" (list Signature.Public_key_hash.encoding))) + obj1 + (opt + "authorized_keys" + (list Tezos_crypto.Signature.Public_key_hash.encoding))) Tezos_rpc.Path.(root / "authorized_keys") diff --git a/src/lib_signer_services/signer_services.mli b/src/lib_signer_services/signer_services.mli index 02098ba6d7cf..f4ee202da98b 100644 --- a/src/lib_signer_services/signer_services.mli +++ b/src/lib_signer_services/signer_services.mli @@ -26,17 +26,17 @@ val sign : ( [`POST], unit, - unit * Signature.Public_key_hash.t, - Signature.t option, + unit * Tezos_crypto.Signature.Public_key_hash.t, + Tezos_crypto.Signature.t option, Bytes.t, - Signature.t ) + Tezos_crypto.Signature.t ) Tezos_rpc.Service.t val deterministic_nonce : ( [`POST], unit, - unit * Signature.Public_key_hash.t, - Signature.t option, + unit * Tezos_crypto.Signature.Public_key_hash.t, + Tezos_crypto.Signature.t option, Bytes.t, Bytes.t ) Tezos_rpc.Service.t @@ -44,8 +44,8 @@ val deterministic_nonce : val deterministic_nonce_hash : ( [`POST], unit, - unit * Signature.Public_key_hash.t, - Signature.t option, + unit * Tezos_crypto.Signature.Public_key_hash.t, + Tezos_crypto.Signature.t option, Bytes.t, Bytes.t ) Tezos_rpc.Service.t @@ -53,7 +53,7 @@ val deterministic_nonce_hash : val supports_deterministic_nonces : ( [`GET], unit, - unit * Signature.Public_key_hash.t, + unit * Tezos_crypto.Signature.Public_key_hash.t, unit, unit, bool ) @@ -62,10 +62,10 @@ val supports_deterministic_nonces : val public_key : ( [`GET], unit, - unit * Signature.Public_key_hash.t, + unit * Tezos_crypto.Signature.Public_key_hash.t, unit, unit, - Signature.Public_key.t ) + Tezos_crypto.Signature.Public_key.t ) Tezos_rpc.Service.t val authorized_keys : @@ -74,5 +74,5 @@ val authorized_keys : unit, unit, unit, - Signature.Public_key_hash.t list option ) + Tezos_crypto.Signature.Public_key_hash.t list option ) Tezos_rpc.Service.t -- GitLab From 105750dc645a00660d5823a01faef941a4182188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 10:20:09 +0200 Subject: [PATCH 19/30] Validation: unopen Crypto --- src/bin_validation/validator.ml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/bin_validation/validator.ml b/src/bin_validation/validator.ml index 58907b9a62dd..ef77aff78b1e 100644 --- a/src/bin_validation/validator.ml +++ b/src/bin_validation/validator.ml @@ -51,8 +51,8 @@ module Events = struct ~level:Debug ~name:"dynload_protocol" ~msg:"dynamic loading of protocol {protocol}" - ~pp1:Protocol_hash.pp - ("protocol", Protocol_hash.encoding) + ~pp1:Tezos_crypto.Protocol_hash.pp + ("protocol", Tezos_crypto.Protocol_hash.encoding) let validation_request = declare_1 @@ -60,7 +60,8 @@ module Events = struct ~level:Debug ~name:"validation_request" ~msg:"validating block {block}" - ~pp1:(fun fmt header -> Block_hash.pp fmt (Block_header.hash header)) + ~pp1:(fun fmt header -> + Tezos_crypto.Block_hash.pp fmt (Block_header.hash header)) ("block", Block_header.encoding) let precheck_request = @@ -69,8 +70,8 @@ module Events = struct ~level:Debug ~name:"precheck_request" ~msg:"prechecking block {hash}" - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) let commit_genesis_request = declare_1 @@ -78,8 +79,8 @@ module Events = struct ~level:Debug ~name:"commit_genesis_request" ~msg:"committing genesis block {genesis}" - ~pp1:Block_hash.pp - ("genesis", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("genesis", Tezos_crypto.Block_hash.encoding) let initialization_request = declare_0 @@ -104,8 +105,8 @@ module Events = struct ~level:Debug ~name:"context_gc_request" ~msg:"garbage collecting context below {context_hash}" - ~pp1:Context_hash.pp - ("context_hash", Context_hash.encoding) + ~pp1:Tezos_crypto.Context_hash.pp + ("context_hash", Tezos_crypto.Context_hash.encoding) let termination_request = declare_0 @@ -126,8 +127,8 @@ let load_protocol proto protocol_root = else let cmxs_file = protocol_root - // Protocol_hash.to_short_b58check proto - // Format.asprintf "protocol_%a.cmxs" Protocol_hash.pp proto + // Tezos_crypto.Protocol_hash.to_short_b58check proto + // Format.asprintf "protocol_%a.cmxs" Tezos_crypto.Protocol_hash.pp proto in let*! () = Events.(emit dynload_protocol proto) in match Dynlink.loadfile_private cmxs_file with @@ -246,7 +247,7 @@ let run ~readonly input output = let*! () = External_validation.send output - (Error_monad.result_encoding Context_hash.encoding) + (Error_monad.result_encoding Tezos_crypto.Context_hash.encoding) commit in loop cache None -- GitLab From 8c887f7672367717aa12ec54ff9afea936eb6ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 11:08:29 +0200 Subject: [PATCH 20/30] Proto-alpha: unopen Crypto --- .../bin_sc_rollup_node/RPC_server.ml | 2 +- .../bin_sc_rollup_node/commitment.ml | 2 +- .../bin_sc_rollup_node/commitment_event.ml | 2 +- .../bin_sc_rollup_node/commitment_event.mli | 2 +- .../bin_sc_rollup_node/configuration.ml | 5 +- .../bin_sc_rollup_node/configuration.mli | 2 +- src/proto_alpha/bin_sc_rollup_node/context.ml | 5 +- .../bin_sc_rollup_node/context.mli | 2 +- src/proto_alpha/bin_sc_rollup_node/daemon.ml | 13 +- .../bin_sc_rollup_node/daemon_event.ml | 4 +- .../bin_sc_rollup_node/daemon_event.mli | 5 +- .../bin_sc_rollup_node/dal_slots_tracker.ml | 12 +- .../bin_sc_rollup_node/dal_slots_tracker.mli | 6 +- .../dal_slots_tracker_event.ml | 4 +- .../bin_sc_rollup_node/fueled_pvm.ml | 2 +- src/proto_alpha/bin_sc_rollup_node/inbox.ml | 4 +- src/proto_alpha/bin_sc_rollup_node/inbox.mli | 8 +- .../bin_sc_rollup_node/inbox_event.ml | 2 +- .../bin_sc_rollup_node/inbox_event.mli | 2 +- src/proto_alpha/bin_sc_rollup_node/layer1.ml | 24 ++- src/proto_alpha/bin_sc_rollup_node/layer1.mli | 4 +- .../bin_sc_rollup_node/layer1_event.ml | 2 +- .../bin_sc_rollup_node/layer1_event.mli | 2 +- .../main_sc_rollup_node_alpha.ml | 2 +- .../bin_sc_rollup_node/node_context.ml | 2 +- .../bin_sc_rollup_node/node_context.mli | 7 +- .../bin_sc_rollup_node/refutation_game.ml | 2 +- .../refutation_game_event.ml | 2 +- .../sc_rollup_node_errors.ml | 17 +- src/proto_alpha/bin_sc_rollup_node/state.ml | 15 +- src/proto_alpha/bin_sc_rollup_node/state.mli | 6 +- src/proto_alpha/bin_sc_rollup_node/store.ml | 48 ++--- src/proto_alpha/bin_sc_rollup_node/store.mli | 26 +-- .../bin_tx_rollup_client/commands.ml | 32 +-- src/proto_alpha/bin_wasm_repl/config.ml | 4 +- src/proto_alpha/bin_wasm_repl/messages.ml | 5 +- src/proto_alpha/lib_benchmark/dune | 1 - .../lib_benchmark/execution_context.ml | 6 +- .../lib_benchmark/michelson_samplers.ml | 2 +- .../lib_benchmark/michelson_samplers_base.ml | 14 +- src/proto_alpha/lib_benchmarks_proto/dune | 1 - .../encodings_benchmarks.ml | 27 ++- .../interpreter_benchmarks.ml | 29 +-- .../interpreter_workload.ml | 18 +- .../sc_rollup_benchmarks.ml | 4 +- .../storage_benchmarks.ml | 2 +- .../lib_benchmarks_proto/ticket_benchmarks.ml | 9 +- .../tx_rollup_benchmarks.ml | 2 +- .../lib_client/client_proto_args.ml | 4 +- .../lib_client/client_proto_args.mli | 7 +- .../lib_client/client_proto_context.ml | 32 +-- .../lib_client/client_proto_context.mli | 108 +++++----- .../lib_client/client_proto_fa12.mli | 2 +- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_programs.ml | 2 +- .../lib_client/client_proto_programs.mli | 2 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- src/proto_alpha/lib_client/injection.ml | 55 ++--- src/proto_alpha/lib_client/injection.mli | 15 +- .../lib_client/managed_contract.ml | 18 +- src/proto_alpha/lib_client/mockup.ml | 35 ++-- .../lib_client/operation_result.ml | 63 +++--- src/proto_alpha/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 52 +++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 134 ++++++++----- .../client_proto_utils_commands.ml | 8 +- .../client_sapling_commands.ml | 12 +- src/proto_alpha/lib_client_sapling/context.ml | 2 +- .../lib_delegate/abstract_context_index.ml | 3 +- .../lib_delegate/abstract_context_index.mli | 3 +- src/proto_alpha/lib_delegate/baking_cache.ml | 2 +- .../lib_delegate/baking_commands.ml | 2 +- .../lib_delegate/baking_configuration.ml | 4 +- .../lib_delegate/baking_configuration.mli | 9 +- src/proto_alpha/lib_delegate/baking_events.ml | 104 +++++----- src/proto_alpha/lib_delegate/baking_files.ml | 2 +- src/proto_alpha/lib_delegate/baking_files.mli | 2 +- .../lib_delegate/baking_highwatermarks.ml | 6 +- .../lib_delegate/baking_highwatermarks.mli | 12 +- src/proto_alpha/lib_delegate/baking_lib.ml | 4 +- src/proto_alpha/lib_delegate/baking_nonces.ml | 50 +++-- .../lib_delegate/baking_nonces.mli | 45 +++-- src/proto_alpha/lib_delegate/baking_pow.ml | 2 +- .../lib_delegate/baking_scheduling.ml | 8 +- .../lib_delegate/baking_simulator.ml | 4 +- .../lib_delegate/baking_simulator.mli | 4 +- src/proto_alpha/lib_delegate/baking_state.ml | 69 ++++--- src/proto_alpha/lib_delegate/baking_state.mli | 17 +- src/proto_alpha/lib_delegate/baking_vdf.ml | 4 +- src/proto_alpha/lib_delegate/block_forge.ml | 13 +- src/proto_alpha/lib_delegate/block_forge.mli | 2 +- .../lib_delegate/client_baking_blocks.ml | 28 +-- .../lib_delegate/client_baking_blocks.mli | 20 +- .../client_baking_denunciation.ml | 31 +-- src/proto_alpha/lib_delegate/client_daemon.ml | 6 +- .../lib_delegate/delegate_events.ml | 28 +-- src/proto_alpha/lib_delegate/logging.ml | 8 +- src/proto_alpha/lib_delegate/node_rpc.ml | 8 +- src/proto_alpha/lib_delegate/node_rpc.mli | 6 +- .../lib_delegate/operation_pool.ml | 2 +- .../lib_delegate/operation_selection.ml | 11 +- .../lib_delegate/operation_selection.mli | 2 +- .../lib_delegate/operation_worker.ml | 7 +- .../lib_delegate/operation_worker.mli | 2 +- .../lib_delegate/state_transitions.ml | 22 +- .../mockup_simulator/faked_client_context.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 27 ++- .../test/mockup_simulator/mockup_simulator.ml | 188 +++++++++++------- .../mockup_simulator/mockup_simulator.mli | 56 +++--- .../test/tenderbrute/lib/tenderbrute.ml | 12 +- .../test/tenderbrute/lib/tenderbrute.mli | 4 +- .../test/tenderbrute/tenderbrute_main.ml | 2 +- .../lib_delegate/test/test_scenario.ml | 10 +- .../lib_injector/disk_persistence.ml | 2 +- .../lib_injector/disk_persistence.mli | 2 +- src/proto_alpha/lib_injector/dune | 1 - .../lib_injector/injector_common.ml | 8 +- .../lib_injector/injector_common.mli | 20 +- .../lib_injector/injector_errors.ml | 7 +- .../lib_injector/injector_errors.mli | 2 +- .../lib_injector/injector_events.ml | 18 +- .../lib_injector/injector_functor.ml | 49 +++-- .../lib_injector/injector_worker_types.ml | 8 +- src/proto_alpha/lib_injector/l1_operation.ml | 9 +- src/proto_alpha/lib_injector/l1_operation.mli | 2 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 8 +- src/proto_alpha/lib_plugin/RPC.ml | 76 +++---- src/proto_alpha/lib_plugin/mempool.ml | 75 ++++--- src/proto_alpha/lib_plugin/test/generators.ml | 46 +++-- .../lib_plugin/test/test_filter_state.ml | 29 ++- src/proto_alpha/lib_plugin/test/test_utils.ml | 12 +- .../lib_protocol/test/helpers/account.ml | 38 ++-- .../lib_protocol/test/helpers/account.mli | 22 +- .../lib_protocol/test/helpers/assert.ml | 26 +-- .../lib_protocol/test/helpers/block.ml | 52 +++-- .../lib_protocol/test/helpers/block.mli | 8 +- .../lib_protocol/test/helpers/context.ml | 17 +- .../lib_protocol/test/helpers/context.mli | 28 ++- .../test/helpers/contract_helpers.ml | 4 +- .../test/helpers/dummy_zk_rollup.ml | 6 +- .../lib_protocol/test/helpers/expr_common.ml | 2 +- .../lib_protocol/test/helpers/incremental.ml | 26 ++- .../test/helpers/liquidity_baking_machine.ml | 6 +- .../test/helpers/lqt_fa12_repr.ml | 2 +- .../lib_protocol/test/helpers/nonce.ml | 2 +- .../lib_protocol/test/helpers/op.ml | 30 +-- .../lib_protocol/test/helpers/op.mli | 24 +-- .../test/helpers/operation_generator.ml | 20 +- .../test/helpers/sapling_helpers.ml | 9 +- .../test/helpers/sc_rollup_helpers.ml | 4 +- .../test/helpers/tx_rollup_l2_helpers.ml | 9 +- .../test/integration/consensus/test_baking.ml | 12 +- .../consensus/test_deactivation.ml | 4 +- .../consensus/test_double_baking.ml | 8 +- .../consensus/test_double_endorsement.ml | 21 +- .../consensus/test_double_preendorsement.ml | 7 +- .../consensus/test_participation.ml | 2 +- .../test/integration/gas/test_gas_costs.ml | 2 +- .../test/integration/gas/test_gas_levels.ml | 2 +- .../michelson/test_interpretation.ml | 4 +- .../integration/michelson/test_sapling.ml | 2 +- .../michelson/test_script_typed_ir_size.ml | 6 +- .../michelson/test_ticket_balance.ml | 2 +- .../michelson/test_ticket_manager.ml | 2 +- .../integration/michelson/test_timelock.ml | 83 +++++--- .../integration/operations/test_activation.ml | 16 +- .../integration/operations/test_reveal.ml | 12 +- .../integration/operations/test_sc_rollup.ml | 14 +- .../integration/operations/test_tx_rollup.ml | 32 +-- .../integration/operations/test_voting.ml | 71 ++++--- .../test/integration/test_frozen_bonds.ml | 8 +- .../test/integration/test_sc_rollup_wasm.ml | 2 +- .../test/integration/test_token.ml | 43 ++-- .../validate/generator_descriptors.ml | 40 +++- .../validate/generator_descriptors.mli | 2 +- .../validate/manager_operation_helpers.ml | 6 +- .../test/integration/validate/test_mempool.ml | 24 ++- .../integration/validate/validate_helpers.ml | 18 +- .../test/pbt/test_refutation_game.ml | 7 +- .../test/pbt/test_sc_rollup_encoding.ml | 2 +- .../test/pbt/test_script_comparison.ml | 5 +- .../test/pbt/test_tx_rollup_l2_encoding.ml | 10 +- .../test/pbt/test_zk_rollup_encoding.ml | 2 +- .../test/regression/test_logging.ml | 4 +- .../test/unit/test_consensus_key.ml | 8 +- .../test/unit/test_contract_repr.ml | 7 +- .../test/unit/test_destination_repr.ml | 2 +- .../test/unit/test_local_contexts.ml | 4 +- .../lib_protocol/test/unit/test_receipt.ml | 5 +- .../test/unit/test_sc_rollup_arith.ml | 4 +- .../test/unit/test_sc_rollup_game.ml | 2 +- .../test_sc_rollup_management_protocol.ml | 2 +- .../test/unit/test_sc_rollup_storage.ml | 12 +- .../test/unit/test_sc_rollup_wasm.ml | 2 +- .../test/unit/test_tx_rollup_l2.ml | 2 +- .../test/unit/test_tx_rollup_l2_apply.ml | 10 +- .../test/unit/test_zk_rollup_storage.ml | 14 +- .../lib_sc_rollup/sc_rollup_services.ml | 14 +- src/proto_alpha/lib_tx_rollup/RPC.ml | 23 ++- src/proto_alpha/lib_tx_rollup/RPC.mli | 2 +- src/proto_alpha/lib_tx_rollup/accuser.mli | 2 +- src/proto_alpha/lib_tx_rollup/batcher.ml | 6 +- src/proto_alpha/lib_tx_rollup/batcher.mli | 2 +- src/proto_alpha/lib_tx_rollup/context.ml | 8 +- src/proto_alpha/lib_tx_rollup/context.mli | 4 +- src/proto_alpha/lib_tx_rollup/dispatcher.mli | 2 +- src/proto_alpha/lib_tx_rollup/dune | 1 - src/proto_alpha/lib_tx_rollup/error.ml | 36 ++-- src/proto_alpha/lib_tx_rollup/error.mli | 12 +- src/proto_alpha/lib_tx_rollup/event.ml | 22 +- .../lib_tx_rollup/fancy_l2block.ml | 6 +- src/proto_alpha/lib_tx_rollup/inbox.ml | 4 +- src/proto_alpha/lib_tx_rollup/inbox.mli | 2 +- .../lib_tx_rollup/l2_transaction.ml | 11 +- .../lib_tx_rollup/l2_transaction.mli | 2 +- src/proto_alpha/lib_tx_rollup/l2block.ml | 19 +- src/proto_alpha/lib_tx_rollup/l2block.mli | 8 +- src/proto_alpha/lib_tx_rollup/node_config.ml | 14 +- src/proto_alpha/lib_tx_rollup/node_config.mli | 2 +- src/proto_alpha/lib_tx_rollup/state.ml | 2 +- src/proto_alpha/lib_tx_rollup/state.mli | 28 ++- src/proto_alpha/lib_tx_rollup/stores.ml | 57 ++++-- src/proto_alpha/lib_tx_rollup/stores.mli | 14 +- 229 files changed, 1999 insertions(+), 1470 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml index 59344e407bd5..229669e76b09 100644 --- a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml +++ b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml @@ -164,7 +164,7 @@ end) module Block_directory = Make_directory (struct include Sc_rollup_services.Global.Block - type context = Node_context.t * Block_hash.t + type context = Node_context.t * Tezos_crypto.Block_hash.t let context_of_prefix node_ctxt (((), block) : prefix) = let open Lwt_result_syntax in diff --git a/src/proto_alpha/bin_sc_rollup_node/commitment.ml b/src/proto_alpha/bin_sc_rollup_node/commitment.ml index 7da60513f03b..339c605ab479 100644 --- a/src/proto_alpha/bin_sc_rollup_node/commitment.ml +++ b/src/proto_alpha/bin_sc_rollup_node/commitment.ml @@ -178,7 +178,7 @@ module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct | None -> failwith "PVM state for block hash not available %s" - (Block_hash.to_string block_hash) + (Tezos_crypto.Block_hash.to_string block_hash) in let*! number_of_ticks = Number_of_ticks.get node_ctxt.store inbox_level in let+ number_of_ticks = diff --git a/src/proto_alpha/bin_sc_rollup_node/commitment_event.ml b/src/proto_alpha/bin_sc_rollup_node/commitment_event.ml index cabbeba01348..0b706c624e77 100644 --- a/src/proto_alpha/bin_sc_rollup_node/commitment_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/commitment_event.ml @@ -81,7 +81,7 @@ module Simple = struct ~msg: "Computing and storing new commitment for head {head} at level {level}" ~level:Notice - ("head", Block_hash.encoding) + ("head", Tezos_crypto.Block_hash.encoding) ("level", Raw_level.encoding) let commitment_parent_is_not_lcc = diff --git a/src/proto_alpha/bin_sc_rollup_node/commitment_event.mli b/src/proto_alpha/bin_sc_rollup_node/commitment_event.mli index d818ad4d4931..bdca58229142 100644 --- a/src/proto_alpha/bin_sc_rollup_node/commitment_event.mli +++ b/src/proto_alpha/bin_sc_rollup_node/commitment_event.mli @@ -64,4 +64,4 @@ val commitment_parent_is_not_lcc : (** [compute_commitment hash level] emits the event that a new commitment is being computed and stored for the block of the given [hash] and at the given [level]. *) -val compute_commitment : Block_hash.t -> Raw_level.t -> unit Lwt.t +val compute_commitment : Tezos_crypto.Block_hash.t -> Raw_level.t -> unit Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/configuration.ml b/src/proto_alpha/bin_sc_rollup_node/configuration.ml index c7bd43e4032a..ce88222bce42 100644 --- a/src/proto_alpha/bin_sc_rollup_node/configuration.ml +++ b/src/proto_alpha/bin_sc_rollup_node/configuration.ml @@ -38,7 +38,7 @@ module Operator_purpose_map = Map.Make (struct let compare = Stdlib.compare end) -type operators = Signature.Public_key_hash.t Operator_purpose_map.t +type operators = Tezos_crypto.Signature.Public_key_hash.t Operator_purpose_map.t type fee_parameters = Injection.fee_parameter Operator_purpose_map.t @@ -254,7 +254,8 @@ let operator_purpose_map_encoding encoding = Data_encoding.Json.encoding let operators_encoding = - operator_purpose_map_encoding (fun _ -> Signature.Public_key_hash.encoding) + operator_purpose_map_encoding (fun _ -> + Tezos_crypto.Signature.Public_key_hash.encoding) let fee_parameter_encoding purpose = let open Data_encoding in diff --git a/src/proto_alpha/bin_sc_rollup_node/configuration.mli b/src/proto_alpha/bin_sc_rollup_node/configuration.mli index 8560affc08a2..73eb8d01fb5e 100644 --- a/src/proto_alpha/bin_sc_rollup_node/configuration.mli +++ b/src/proto_alpha/bin_sc_rollup_node/configuration.mli @@ -39,7 +39,7 @@ type purpose = Publish | Add_messages | Cement | Timeout | Refute module Operator_purpose_map : Map.S with type key = purpose -type operators = Signature.Public_key_hash.t Operator_purpose_map.t +type operators = Tezos_crypto.Signature.Public_key_hash.t Operator_purpose_map.t type fee_parameters = Injection.fee_parameter Operator_purpose_map.t diff --git a/src/proto_alpha/bin_sc_rollup_node/context.ml b/src/proto_alpha/bin_sc_rollup_node/context.ml index 7c2beb5f91ee..a3f257ddcc6c 100644 --- a/src/proto_alpha/bin_sc_rollup_node/context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/context.ml @@ -98,7 +98,7 @@ let index context = context.index module Proof (Hash : sig type t - val of_context_hash : Context_hash.t -> t + val of_context_hash : Tezos_crypto.Context_hash.t -> t end) (Proof_encoding : sig val proof_encoding : Environment.Context.Proof.tree Environment.Context.Proof.t Data_encoding.t @@ -202,7 +202,8 @@ module Inbox = struct let from_inbox_hash inbox_hash = let ctxt_hash = Hash.to_context_hash inbox_hash in let store_hash = - IStore.Hash.unsafe_of_raw_string (Context_hash.to_string ctxt_hash) + IStore.Hash.unsafe_of_raw_string + (Tezos_crypto.Context_hash.to_string ctxt_hash) in `Node store_hash diff --git a/src/proto_alpha/bin_sc_rollup_node/context.mli b/src/proto_alpha/bin_sc_rollup_node/context.mli index ec91fb9c5c31..516d3443f532 100644 --- a/src/proto_alpha/bin_sc_rollup_node/context.mli +++ b/src/proto_alpha/bin_sc_rollup_node/context.mli @@ -87,7 +87,7 @@ val is_empty : t -> bool module Proof (Hash : sig type t - val of_context_hash : Context_hash.t -> t + val of_context_hash : Tezos_crypto.Context_hash.t -> t end) (Proof_encoding : sig val proof_encoding : Environment.Context.Proof.tree Environment.Context.Proof.t Data_encoding.t diff --git a/src/proto_alpha/bin_sc_rollup_node/daemon.ml b/src/proto_alpha/bin_sc_rollup_node/daemon.ml index 3f13f787e4ef..595f5a7a7b4a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/daemon.ml +++ b/src/proto_alpha/bin_sc_rollup_node/daemon.ml @@ -370,13 +370,18 @@ module Make (PVM : Pvm.S) = struct |> List.fold_left (fun acc (purpose, operator) -> let purposes = - match Signature.Public_key_hash.Map.find operator acc with + match + Tezos_crypto.Signature.Public_key_hash.Map.find operator acc + with | None -> [purpose] | Some ps -> purpose :: ps in - Signature.Public_key_hash.Map.add operator purposes acc) - Signature.Public_key_hash.Map.empty - |> Signature.Public_key_hash.Map.bindings + Tezos_crypto.Signature.Public_key_hash.Map.add + operator + purposes + acc) + Tezos_crypto.Signature.Public_key_hash.Map.empty + |> Tezos_crypto.Signature.Public_key_hash.Map.bindings |> List.map (fun (operator, purposes) -> (operator, `Each_block, purposes)) in diff --git a/src/proto_alpha/bin_sc_rollup_node/daemon_event.ml b/src/proto_alpha/bin_sc_rollup_node/daemon_event.ml index 61958297e722..8b99312a3dce 100644 --- a/src/proto_alpha/bin_sc_rollup_node/daemon_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/daemon_event.ml @@ -37,7 +37,7 @@ module Simple = struct ~name:"sc_rollup_daemon_process_head" ~msg:"Processing {finalized} head {hash} at level {level}" ~level:Notice - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("finalized", Data_encoding.bool) ~pp3:(fun fmt finalized -> @@ -49,7 +49,7 @@ module Simple = struct ~name:"sc_rollup_node_layer_1_new_head_processed" ~msg:"Finished processing layer 1 head {hash} at level {level}" ~level:Notice - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let processing_heads_iteration = diff --git a/src/proto_alpha/bin_sc_rollup_node/daemon_event.mli b/src/proto_alpha/bin_sc_rollup_node/daemon_event.mli index 0626f37693ff..36407b9ba796 100644 --- a/src/proto_alpha/bin_sc_rollup_node/daemon_event.mli +++ b/src/proto_alpha/bin_sc_rollup_node/daemon_event.mli @@ -32,11 +32,12 @@ open Alpha_context (** [head_processing hash level ~finalized] emits the event that the block of the given [hash] and at the given [level] is being processed, and whether it is [finalized]. *) -val head_processing : Block_hash.t -> int32 -> finalized:bool -> unit Lwt.t +val head_processing : + Tezos_crypto.Block_hash.t -> int32 -> finalized:bool -> unit Lwt.t (** [new_head_processed hash level] emits the event that the daemon has finished processing the head of the given [hash] and at the given [level]. *) -val new_head_processed : Block_hash.t -> int32 -> unit Lwt.t +val new_head_processed : Tezos_crypto.Block_hash.t -> int32 -> unit Lwt.t (** [processing_heads_iteration heads] emits the event that the [heads] are going to be processed. *) diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.ml b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.ml index e1643e82d18f..a0dd9cd5a42e 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.ml +++ b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.ml @@ -27,7 +27,7 @@ open Protocol open Alpha_context module Block_services = Block_services.Make (Protocol) (Protocol) -type error += Cannot_read_block_metadata of Block_hash.t +type error += Cannot_read_block_metadata of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -38,10 +38,10 @@ let () = Format.fprintf ppf "Could not read block receipt for block with hash %a." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash) `Temporary - Data_encoding.(obj1 (req "hash" Block_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Cannot_read_block_metadata hash -> Some hash | _ -> None) (fun hash -> Cannot_read_block_metadata hash) @@ -65,7 +65,7 @@ let ancestor_hash ~number_of_levels {Node_context.genesis_info; l1_ctxt; _} head the slot has been confirmed after the endorsement_lag has passed. *) type confirmations_info = { (* The hash of the block in which the slots have been published. *) - published_block_hash : Block_hash.t; + published_block_hash : Tezos_crypto.Block_hash.t; (* The indexes of slots that have beenp published in block with hash `published_block_hash`, and have later been confirmed. *) confirmed_slots_indexes : Bitset.t; @@ -326,7 +326,7 @@ module Confirmed_slots_history = struct "The confirmed DAL %S for block hash %a (level = %a) is not expected \ to be found in the store, but is exists." entry_kind - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash Raw_level.pp block_level @@ -335,7 +335,7 @@ module Confirmed_slots_history = struct "The confirmed DAL %S for block hash %a (level = %a) is expected to \ be found in the store, but is missing." entry_kind - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash Raw_level.pp block_level diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.mli b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.mli index 4b5bc07d97ec..fd89a0a7d338 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.mli +++ b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker.mli @@ -33,7 +33,7 @@ open Alpha_context The state of slots per block is persistent. *) -type error += Cannot_read_block_metadata of Block_hash.t +type error += Cannot_read_block_metadata of Tezos_crypto.Block_hash.t (** [is_slot_confirmed node_ctxt head slot_index] checks whether the slot with index [slot_index] has been confirmed in [head]. *) @@ -44,14 +44,14 @@ val is_slot_confirmed : that [slot_index] is unconfirmed in the block with hash in [node_ctxt.store]. *) val save_unconfirmed_slot : - Node_context.t -> Block_hash.t -> Dal.Slot_index.t -> unit Lwt.t + Node_context.t -> Tezos_crypto.Block_hash.t -> Dal.Slot_index.t -> unit Lwt.t (** [save_confirmed_slot node_ctxt hash slot_index] saves in [node_ctxt.store] that [slot_index] is confirmed in the block with hashin [node_ctxt.store]. The contents of the slot are set to [pages] in [node_ctxt.store]. *) val save_confirmed_slot : Node_context.t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Dal.Slot_index.t -> Dal.Page.content list -> unit Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker_event.ml b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker_event.ml index 84ed4506c47f..c66573018673 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/dal_slots_tracker_event.ml @@ -41,8 +41,8 @@ module Simple = struct {confirmed_hash}. The slot contents will be downloaded." ~level:Notice ("slot_index", Dal.Slot_index.encoding) - ("published_hash", Block_hash.encoding) - ("confirmed_hash", Block_hash.encoding) + ("published_hash", Tezos_crypto.Block_hash.encoding) + ("confirmed_hash", Tezos_crypto.Block_hash.encoding) end let slot_has_been_confirmed slot published_hash confirmed_hash = diff --git a/src/proto_alpha/bin_sc_rollup_node/fueled_pvm.ml b/src/proto_alpha/bin_sc_rollup_node/fueled_pvm.ml index 566bb4886940..f2f261e05f20 100644 --- a/src/proto_alpha/bin_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_alpha/bin_sc_rollup_node/fueled_pvm.ml @@ -39,7 +39,7 @@ module type S = sig dal_endorsement_lag:int -> fuel:fuel -> Node_context.t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> state -> (state * Z.t * Raw_level.t * fuel, tztrace) result Lwt.t end diff --git a/src/proto_alpha/bin_sc_rollup_node/inbox.ml b/src/proto_alpha/bin_sc_rollup_node/inbox.ml index 8a330ae86123..5459cd00f5e6 100644 --- a/src/proto_alpha/bin_sc_rollup_node/inbox.ml +++ b/src/proto_alpha/bin_sc_rollup_node/inbox.ml @@ -62,7 +62,7 @@ module State = struct (* Invariant broken, the inbox for this level should exist. *) failwith "The inbox for block hash %a (level = %ld) is missing." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash block_level else @@ -92,7 +92,7 @@ module State = struct else failwith "The inbox history for hash %a is missing." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash end diff --git a/src/proto_alpha/bin_sc_rollup_node/inbox.mli b/src/proto_alpha/bin_sc_rollup_node/inbox.mli index b9895ae2bec9..7d93c29ffe10 100644 --- a/src/proto_alpha/bin_sc_rollup_node/inbox.mli +++ b/src/proto_alpha/bin_sc_rollup_node/inbox.mli @@ -43,12 +43,16 @@ val process_head : Node_context.t -> Layer1.head -> Context.t tzresult Lwt.t (** [inbox_of_hash node_ctxt block_hash] returns the rollup inbox at the end of the given validation of [block_hash]. *) val inbox_of_hash : - Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.t tzresult Lwt.t + Node_context.t -> + Tezos_crypto.Block_hash.t -> + Sc_rollup.Inbox.t tzresult Lwt.t (** [history_of_hash node_ctxt block_hash] returns the rollup inbox history at the end of the given validation of [block_hash]. *) val history_of_hash : - Node_context.t -> Block_hash.t -> Sc_rollup.Inbox.History.t tzresult Lwt.t + Node_context.t -> + Tezos_crypto.Block_hash.t -> + Sc_rollup.Inbox.History.t tzresult Lwt.t (** [start ()] initializes the inbox to track the messages being published. *) val start : unit -> unit Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/inbox_event.ml b/src/proto_alpha/bin_sc_rollup_node/inbox_event.ml index 36464fa0453f..96ca1e6a1394 100644 --- a/src/proto_alpha/bin_sc_rollup_node/inbox_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/inbox_event.ml @@ -52,7 +52,7 @@ module Simple = struct "Fetching {number_of_messages} messages from block {hash} at level \ {level}" ~level:Notice - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("number_of_messages", Data_encoding.int32) end diff --git a/src/proto_alpha/bin_sc_rollup_node/inbox_event.mli b/src/proto_alpha/bin_sc_rollup_node/inbox_event.mli index 72a3b8200880..c56ea8ad6ae7 100644 --- a/src/proto_alpha/bin_sc_rollup_node/inbox_event.mli +++ b/src/proto_alpha/bin_sc_rollup_node/inbox_event.mli @@ -32,4 +32,4 @@ val stopping : unit -> unit Lwt.t (** [get_messages hash level n] emits the event that [n] messages are being fetched from the block of the given [hash] at the given [level]. *) -val get_messages : Block_hash.t -> int32 -> int -> unit Lwt.t +val get_messages : Tezos_crypto.Block_hash.t -> int32 -> int -> unit Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/layer1.ml b/src/proto_alpha/bin_sc_rollup_node/layer1.ml index df7cf5213382..9c5fc611c559 100644 --- a/src/proto_alpha/bin_sc_rollup_node/layer1.ml +++ b/src/proto_alpha/bin_sc_rollup_node/layer1.ml @@ -35,7 +35,7 @@ open Injector_common *) -type error += Cannot_find_block of Block_hash.t +type error += Cannot_find_block of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -46,14 +46,14 @@ let () = Format.fprintf ppf "Block with hash %a was not found on the L1 node." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash) `Temporary - Data_encoding.(obj1 (req "hash" Block_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Cannot_find_block hash -> Some hash | _ -> None) (fun hash -> Cannot_find_block hash) -type error += Cannot_find_predecessor of Block_hash.t +type error += Cannot_find_predecessor of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -64,10 +64,10 @@ let () = Format.fprintf ppf "Block with hash %a has no predecessor on the L1 node." - Block_hash.pp + Tezos_crypto.Block_hash.pp hash) `Temporary - Data_encoding.(obj1 (req "hash" Block_hash.encoding)) + Data_encoding.(obj1 (req "hash" Tezos_crypto.Block_hash.encoding)) (function Cannot_find_predecessor hash -> Some hash | _ -> None) (fun hash -> Cannot_find_predecessor hash) @@ -78,20 +78,22 @@ let () = *) -type head = {hash : Block_hash.t; level : int32} +type head = {hash : Tezos_crypto.Block_hash.t; level : int32} let head_encoding = Data_encoding.( conv (fun {hash; level} -> (hash, level)) (fun (hash, level) -> {hash; level}) - (obj2 (req "hash" Block_hash.encoding) (req "level" Data_encoding.int32))) + (obj2 + (req "hash" Tezos_crypto.Block_hash.encoding) + (req "level" Data_encoding.int32))) module Blocks_cache = Ringo_lwt.Functors.Make_opt ((val Ringo.( map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash)) + (Tezos_crypto.Block_hash)) type blocks_cache = Protocol_client_context.Alpha_block_services.block_info Blocks_cache.t @@ -127,7 +129,7 @@ let get_predecessor = let (module HMF : Ringo.MAP_MAKER) = Ringo.(map_maker ~replacement:FIFO ~overflow:Strong ~accounting:Precise) in - let module HM = HMF (Block_hash) in + let module HM = HMF (Tezos_crypto.Block_hash) in let cache = HM.create max_cached in fun cctxt (chain : Tezos_shell_services.Chain_services.chain) ancestor -> let open Lwt_result_syntax in @@ -266,7 +268,7 @@ let get_tezos_reorg_for_new_head l1_state old_head new_head = let open Lwt_result_syntax in (* old_head and new_head must have the same level when calling aux *) let rec aux reorg old_head new_head = - if Block_hash.(old_head.hash = new_head.hash) then return reorg + if Tezos_crypto.Block_hash.(old_head.hash = new_head.hash) then return reorg else let* old_head_pred = get_predecessor l1_state old_head in let* new_head_pred = get_predecessor l1_state new_head in diff --git a/src/proto_alpha/bin_sc_rollup_node/layer1.mli b/src/proto_alpha/bin_sc_rollup_node/layer1.mli index 4e72e5fe8fd9..625050011d2a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/layer1.mli +++ b/src/proto_alpha/bin_sc_rollup_node/layer1.mli @@ -29,7 +29,7 @@ subscribing to the head monitoring RPC offered by the Tezos node. *) -type head = {hash : Block_hash.t; level : int32} +type head = {hash : Tezos_crypto.Block_hash.t; level : int32} val head_encoding : head Data_encoding.t @@ -77,7 +77,7 @@ val shutdown : t -> unit Lwt.t node otherwise. *) val fetch_tezos_block : t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Protocol_client_context.Alpha_block_services.block_info tzresult Lwt.t (** [nth_predecessor l1_ctxt n head] return [block, history] where [block] is diff --git a/src/proto_alpha/bin_sc_rollup_node/layer1_event.ml b/src/proto_alpha/bin_sc_rollup_node/layer1_event.ml index e46a9efca893..f8e2dd1edbb9 100644 --- a/src/proto_alpha/bin_sc_rollup_node/layer1_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/layer1_event.ml @@ -50,7 +50,7 @@ module Simple = struct ~name:"sc_rollup_node_layer_1_new_head" ~msg:"Layer 1 node has switched to head {hash} at level {level}" ~level:Notice - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) end diff --git a/src/proto_alpha/bin_sc_rollup_node/layer1_event.mli b/src/proto_alpha/bin_sc_rollup_node/layer1_event.mli index 5b8ff83a660c..467da2e23f72 100644 --- a/src/proto_alpha/bin_sc_rollup_node/layer1_event.mli +++ b/src/proto_alpha/bin_sc_rollup_node/layer1_event.mli @@ -32,4 +32,4 @@ val stopping : unit -> unit Lwt.t (** [switched_new_head hash level] emits the event that the layer 1 has notified a new head with [hash] at some given [level]. *) -val switched_new_head : Block_hash.t -> int32 -> unit Lwt.t +val switched_new_head : Tezos_crypto.Block_hash.t -> int32 -> unit Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml index 27a3662d85d3..f91d067aff60 100644 --- a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml +++ b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml @@ -50,7 +50,7 @@ let sc_rollup_node_operator_param = let parse_pkh s = let from_alias s = Client_keys.Public_key_hash.find cctxt s in let from_key s = - match Signature.Public_key_hash.of_b58check_opt s with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt s with | None -> failwith "Could not read public key hash for rollup node operator" | Some pkh -> return pkh diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.ml b/src/proto_alpha/bin_sc_rollup_node/node_context.ml index 18c6b8cadf48..38b389105dee 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.ml @@ -48,7 +48,7 @@ let get_operator node_ctxt purpose = let is_operator node_ctxt pkh = Configuration.Operator_purpose_map.exists - (fun _ operator -> Signature.Public_key_hash.(operator = pkh)) + (fun _ operator -> Tezos_crypto.Signature.Public_key_hash.(operator = pkh)) node_ctxt.operators let get_fee_parameter node_ctxt purpose = diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.mli b/src/proto_alpha/bin_sc_rollup_node/node_context.mli index 1402747429c5..5105e52f844d 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.mli +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.mli @@ -60,11 +60,11 @@ type t = { who has purpose [purpose], if any. *) val get_operator : - t -> Configuration.purpose -> Signature.Public_key_hash.t option + t -> Configuration.purpose -> Tezos_crypto.Signature.Public_key_hash.t option (** [is_operator cctxt pkh] returns [true] if the public key hash [pkh] is an operator for the node (for any purpose). *) -val is_operator : t -> Signature.Public_key_hash.t -> bool +val is_operator : t -> Tezos_crypto.Signature.Public_key_hash.t -> bool (** [get_fee_parameter cctxt purpose] returns the fee parameter to inject an operation for a given [purpose]. If no specific fee parameters were @@ -94,4 +94,5 @@ val init : (** [checkout_context node_ctxt block_hash] returns the context at block [block_hash]. *) -val checkout_context : t -> Block_hash.t -> Context.t tzresult Lwt.t +val checkout_context : + t -> Tezos_crypto.Block_hash.t -> Context.t tzresult Lwt.t diff --git a/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml b/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml index dd94b2ab6869..b6d1a0b495ee 100644 --- a/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml +++ b/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml @@ -395,7 +395,7 @@ module Make (Interpreter : Interpreter.S) : let open Sc_rollup.Game in match game_result with | Some (Loser {loser; _}) -> - let is_it_me = Signature.Public_key_hash.(self = loser) in + let is_it_me = Tezos_crypto.Signature.Public_key_hash.(self = loser) in return (not is_it_me) | _ -> return_false diff --git a/src/proto_alpha/bin_sc_rollup_node/refutation_game_event.ml b/src/proto_alpha/bin_sc_rollup_node/refutation_game_event.ml index b7b96030d013..996b63ed080a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/refutation_game_event.ml +++ b/src/proto_alpha/bin_sc_rollup_node/refutation_game_event.ml @@ -41,7 +41,7 @@ module Simple = struct "The rollup node has been slashed because of a timeout issued by \ {address}" ~level:Notice - ("address", Signature.Public_key_hash.encoding) + ("address", Tezos_crypto.Signature.Public_key_hash.encoding) let invalid_move = declare_0 diff --git a/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml index 47b23d17967a..f42609b47575 100644 --- a/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml @@ -38,8 +38,8 @@ type error += layer1_inbox : Sc_rollup.Inbox.t; inbox : Sc_rollup.Inbox.t; } - | Missing_PVM_state of Block_hash.t * Int32.t - | Cannot_checkout_context of Block_hash.t * string option + | Missing_PVM_state of Tezos_crypto.Block_hash.t * Int32.t + | Cannot_checkout_context of Tezos_crypto.Block_hash.t * string option | Cannot_retrieve_reveal of Sc_rollup.Reveal_hash.t type error += @@ -176,10 +176,11 @@ let () = Format.fprintf ppf "Cannot retrieve PVM state for block %a at level %ld" - Block_hash.pp + Tezos_crypto.Block_hash.pp block level) - Data_encoding.(obj2 (req "block" Block_hash.encoding) (req "level" int32)) + Data_encoding.( + obj2 (req "block" Tezos_crypto.Block_hash.encoding) (req "level" int32)) (function | Missing_PVM_state (block, level) -> Some (block, level) | _ -> None) (fun (block, level) -> Missing_PVM_state (block, level)) ; @@ -198,11 +199,11 @@ let () = ~none:"" ~some:(fun c -> Hex.(show (of_string c))) context_hash) - Block_hash.pp + Tezos_crypto.Block_hash.pp block) Data_encoding.( obj2 - (req "block" Block_hash.encoding) + (req "block" Tezos_crypto.Block_hash.encoding) (opt "context" (conv Bytes.of_string Bytes.to_string bytes))) (function | Cannot_checkout_context (block, context) -> Some (block, context) @@ -219,7 +220,7 @@ let () = ppf "The rollup node lost the refutation game for operator %a and was \ slashed %s%a, for reason: %a." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp loser tez_sym Tez.pp @@ -228,7 +229,7 @@ let () = reason) Data_encoding.( obj3 - (req "loser" Signature.Public_key_hash.encoding) + (req "loser" Tezos_crypto.Signature.Public_key_hash.encoding) (req "reason" Protocol.Alpha_context.Sc_rollup.Game.reason_encoding) (req "slashed" Tez.encoding)) (function diff --git a/src/proto_alpha/bin_sc_rollup_node/state.ml b/src/proto_alpha/bin_sc_rollup_node/state.ml index 401b0e713c93..ff76af338d9c 100644 --- a/src/proto_alpha/bin_sc_rollup_node/state.ml +++ b/src/proto_alpha/bin_sc_rollup_node/state.ml @@ -32,9 +32,9 @@ module Store = struct let path = ["tezos"; "processed_blocks"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = unit @@ -82,11 +82,11 @@ module Store = struct let to_path_representation = Int32.to_string end) (struct - type value = Block_hash.t + type value = Tezos_crypto.Block_hash.t let name = "block_hash" - let encoding = Block_hash.encoding + let encoding = Tezos_crypto.Block_hash.encoding end) (** Table from L1 blocks hashes to levels. *) @@ -96,9 +96,9 @@ module Store = struct let path = ["tezos"; "blocks_hashes"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = int32 @@ -115,7 +115,8 @@ let level_of_hash store hash = let open Lwt_result_syntax in let*! level = Store.Hashes_to_levels.find store hash in match level with - | None -> failwith "No level known for block %a" Block_hash.pp hash + | None -> + failwith "No level known for block %a" Tezos_crypto.Block_hash.pp hash | Some l -> return l let mark_processed_head store Layer1.({hash; level = _} as head) = diff --git a/src/proto_alpha/bin_sc_rollup_node/state.mli b/src/proto_alpha/bin_sc_rollup_node/state.mli index ec1c21c84472..0ad8de3582bd 100644 --- a/src/proto_alpha/bin_sc_rollup_node/state.mli +++ b/src/proto_alpha/bin_sc_rollup_node/state.mli @@ -25,7 +25,7 @@ (** [is_processed store hash] returns [true] if the block with [hash] has already been processed by the daemon. *) -val is_processed : Store.t -> Block_hash.t -> bool Lwt.t +val is_processed : Store.t -> Tezos_crypto.Block_hash.t -> bool Lwt.t (** [mark_processed_head store head] remembers that the [head] is processed. The system should not have to come back to it. *) @@ -46,11 +46,11 @@ val get_finalized_head_opt : Store.t -> Layer1.head option Lwt.t (** [hash_of_level store level] returns the current block hash for a given [level]. Raise [Invalid_argument] if [hash] does not belong to [store]. *) -val hash_of_level : Store.t -> int32 -> Block_hash.t Lwt.t +val hash_of_level : Store.t -> int32 -> Tezos_crypto.Block_hash.t Lwt.t (** [level_of_hash store hash] returns the level for Tezos block hash [hash] if it is known by the rollup node. *) -val level_of_hash : Store.t -> Block_hash.t -> int32 tzresult Lwt.t +val level_of_hash : Store.t -> Tezos_crypto.Block_hash.t -> int32 tzresult Lwt.t (** [set_block_level_and_has store head] registers the correspondences [head.level |-> head.hash] and [head.hash |-> head.level] in the store. *) diff --git a/src/proto_alpha/bin_sc_rollup_node/store.ml b/src/proto_alpha/bin_sc_rollup_node/store.ml index e43714d3edac..2acb7d7700dc 100644 --- a/src/proto_alpha/bin_sc_rollup_node/store.ml +++ b/src/proto_alpha/bin_sc_rollup_node/store.ml @@ -53,9 +53,9 @@ module StateInfo = let path = ["state_info"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = state_info @@ -78,8 +78,8 @@ module StateInfo = module StateHistoryRepr = struct type event = { tick : Sc_rollup.Tick.t; - block_hash : Block_hash.t; - predecessor_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; level : Raw_level.t; } @@ -96,8 +96,8 @@ module StateHistoryRepr = struct {tick; block_hash; predecessor_hash; level}) (obj4 (req "tick" Sc_rollup.Tick.encoding) - (req "block_hash" Block_hash.encoding) - (req "predecessor_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) + (req "predecessor_hash" Tezos_crypto.Block_hash.encoding) (req "level" Raw_level.encoding)) let name = "state_history" @@ -150,9 +150,9 @@ module Messages = let path = ["messages"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Sc_rollup.Inbox_message.t list @@ -170,9 +170,9 @@ module Inboxes = let path = ["inboxes"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Sc_rollup.Inbox.t @@ -189,9 +189,9 @@ module Histories = let path = ["histories"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Sc_rollup.Inbox.History.t @@ -299,9 +299,9 @@ module Contexts = let path = ["contexts"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Context.hash @@ -321,9 +321,9 @@ module Dal_slot_pages = let path = ["dal"; "slot_pages"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type key = Dal.Slot_index.t * Dal.Page.Index.t @@ -353,9 +353,9 @@ module Dal_processed_slots = let path = ["dal"; "processed_slots"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type key = Dal.Slot_index.t @@ -395,9 +395,9 @@ module Dal_slots_headers = let path = ["dal"; "slot_headers"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type key = Dal.Slot_index.t @@ -431,9 +431,9 @@ module Dal_confirmed_slots_history = let path = ["dal"; "confirmed_slots_history"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Dal.Slots_history.t @@ -451,9 +451,9 @@ module Dal_confirmed_slots_histories = let path = ["dal"; "confirmed_slots_histories_cache"] end) (struct - type key = Block_hash.t + type key = Tezos_crypto.Block_hash.t - let to_path_representation = Block_hash.to_b58check + let to_path_representation = Tezos_crypto.Block_hash.to_b58check end) (struct type value = Dal.Slots_history.History_cache.t diff --git a/src/proto_alpha/bin_sc_rollup_node/store.mli b/src/proto_alpha/bin_sc_rollup_node/store.mli index 6a12355c1d5e..0b5b7be85603 100644 --- a/src/proto_alpha/bin_sc_rollup_node/store.mli +++ b/src/proto_alpha/bin_sc_rollup_node/store.mli @@ -50,15 +50,15 @@ val load : string -> t Lwt.t (** Extraneous state information for the PVM *) module StateInfo : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = state_info and type store = t module StateHistoryRepr : sig type event = { tick : Sc_rollup.Tick.t; - block_hash : Block_hash.t; - predecessor_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; + predecessor_hash : Tezos_crypto.Block_hash.t; level : Raw_level.t; } @@ -87,24 +87,24 @@ module StateHistory : sig end (** Storage for persisting messages downloaded from the L1 node, indexed by - [Block_hash.t]. *) + [Tezos_crypto.Block_hash.t]. *) module Messages : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Sc_rollup.Inbox_message.t list and type store = t (** Aggregated collection of messages from the L1 inbox *) module Inboxes : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Sc_rollup.Inbox.t and type store = t (** Histories from the rollup node. **) module Histories : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Sc_rollup.Inbox.History.t and type store = t @@ -151,7 +151,7 @@ module Commitments_published_at_level : (** Storage containing the hashes of contexts retrieved from the L1 node. *) module Contexts : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Context.hash and type store = t @@ -161,14 +161,14 @@ module Contexts : list into a [Dal.Slot_index.t]-indexed map. *) module Dal_slots_headers : Store_sigs.Nested_map - with type primary_key = Block_hash.t + with type primary_key = Tezos_crypto.Block_hash.t and type secondary_key = Dal.Slot_index.t and type value = Dal.Slot.Header.t and type store = t module Dal_confirmed_slots_history : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Dal.Slots_history.t and type store = t @@ -176,7 +176,7 @@ module Dal_confirmed_slots_history : {Dal_slot_repr.Slots_history} for more details. *) module Dal_confirmed_slots_histories : Store_sigs.Map - with type key = Block_hash.t + with type key = Tezos_crypto.Block_hash.t and type value = Dal.Slots_history.History_cache.t and type store = t @@ -188,7 +188,7 @@ module Dal_confirmed_slots_histories : *) module Dal_slot_pages : Store_sigs.Nested_map - with type primary_key = Block_hash.t + with type primary_key = Tezos_crypto.Block_hash.t and type secondary_key = Dal.Slot_index.t * Dal.Page.Index.t and type value = Dal.Page.content and type store = t @@ -202,7 +202,7 @@ module Dal_slot_pages : *) module Dal_processed_slots : Store_sigs.Nested_map - with type primary_key = Block_hash.t + with type primary_key = Tezos_crypto.Block_hash.t and type secondary_key = Dal.Slot_index.t and type value = [`Confirmed | `Unconfirmed] and type store = t diff --git a/src/proto_alpha/bin_tx_rollup_client/commands.ml b/src/proto_alpha/bin_tx_rollup_client/commands.ml index 37653e577c1d..ad80ad0d1c83 100644 --- a/src/proto_alpha/bin_tx_rollup_client/commands.ml +++ b/src/proto_alpha/bin_tx_rollup_client/commands.ml @@ -27,7 +27,7 @@ open Tezos_client_base let l1_destination_parameter = Tezos_clic.parameter (fun _ s -> - match Signature.Public_key_hash.of_b58check_opt s with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt s with | Some addr -> return addr | None -> failwith "cannot parse %s to get a valid destination" s) @@ -66,15 +66,15 @@ let alias_or_literal ~from_alias ~from_key = type wallet_entry = { alias : string; - public_key_hash : Bls.Public_key_hash.t; - public_key : Bls.Public_key.t option; + public_key_hash : Tezos_crypto.Bls.Public_key_hash.t; + public_key : Tezos_crypto.Bls.Public_key.t option; secret_key_uri : Client_keys.aggregate_sk_uri option; } let wallet_parameter () = Tezos_clic.parameter (fun cctxt alias -> let open Lwt_result_syntax in - let open Aggregate_signature in + let open Tezos_crypto.Aggregate_signature in let* (Bls12_381 public_key_hash) = Client_keys.Aggregate_alias.Public_key_hash.find cctxt alias in @@ -106,11 +106,14 @@ let bls_pkh_parameter () = in return pkh in - let from_key s = Bls.Public_key_hash.of_b58check s |> Lwt.return in + let from_key s = + Tezos_crypto.Bls.Public_key_hash.of_b58check s |> Lwt.return + in alias_or_literal ~from_alias ~from_key s) let conv_bls_pkh_to_l2_addr pkh = - Bls.Public_key_hash.to_b58check pkh |> Tx_rollup_l2_address.of_b58check_exn + Tezos_crypto.Bls.Public_key_hash.to_b58check pkh + |> Tx_rollup_l2_address.of_b58check_exn let bls_pkh_param ?(name = "public key hash") ?(desc = "bls public key hash to use") = @@ -142,7 +145,8 @@ let bls_sk_uri_param ?(name = "secret key") ?(desc = "Bls secret key to use.") = Tezos_clic.param ~name ~desc (bls_sk_uri_parameter ()) let signature_parameter () = - Tezos_clic.parameter (fun _cctxt s -> Bls.of_b58check s |> Lwt.return) + Tezos_clic.parameter (fun _cctxt s -> + Tezos_crypto.Bls.of_b58check s |> Lwt.return) let signature_arg = Tezos_clic.arg @@ -338,7 +342,7 @@ let craft_withdraw ~counter ~signer ~destination ~ticket_hash ~qty = let aggregate_signature signatures = let open Result_syntax in - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> return res | None -> error_with "aggregate_signature" @@ -365,7 +369,7 @@ let conv_counter = let signer_to_address : Tx_rollup_l2_batch.signer -> Tx_rollup_l2_address.t = function - | Bls_pk pk -> Bls.Public_key.hash pk + | Bls_pk pk -> Tezos_crypto.Bls.Public_key.hash pk | L2_addr addr -> addr let wait_for_synchronized ?(quiet = false) @@ -439,7 +443,7 @@ let signer_parameter = match Tx_rollup_l2_address.of_b58check_opt s with | Some pkh -> return @@ Tx_rollup_l2_batch.L2_addr pkh | None -> ( - match Bls.Public_key.of_b58check_opt s with + match Tezos_crypto.Bls.Public_key.of_b58check_opt s with | Some pk -> return @@ Tx_rollup_l2_batch.Bls_pk pk | None -> failwith "cannot parse %s to get a valid signer" s)) @@ -683,7 +687,7 @@ let prepare_operation_parameters cctxt signer counter = | Some pk -> ok pk | None -> error_with "missing signer public key in the wallet" in - let signer_addr = Bls.Public_key.hash signer_pk in + let signer_addr = Tezos_crypto.Bls.Public_key.hash signer_pk in let* () = wait_for_synchronized cctxt in let* counter = match counter with @@ -820,7 +824,9 @@ let sign_transaction () = in let*? aggregated_signature = aggregate_signature signatures in - let*! () = cctxt#message "@[%a@]" Bls.pp aggregated_signature in + let*! () = + cctxt#message "@[%a@]" Tezos_crypto.Bls.pp aggregated_signature + in return_unit else let*! () = @@ -828,7 +834,7 @@ let sign_transaction () = "@[%a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.pp_print_string ppf ";") - Bls.pp) + Tezos_crypto.Bls.pp) signatures in return_unit) diff --git a/src/proto_alpha/bin_wasm_repl/config.ml b/src/proto_alpha/bin_wasm_repl/config.ml index 9bf9824001bd..88456aeba19c 100644 --- a/src/proto_alpha/bin_wasm_repl/config.ml +++ b/src/proto_alpha/bin_wasm_repl/config.ml @@ -25,13 +25,13 @@ let default_sender = Protocol.Contract_hash.zero -let default_source = Signature.Public_key_hash.zero +let default_source = Tezos_crypto.Signature.Public_key_hash.zero let default_destination = Protocol.Alpha_context.Sc_rollup.Address.zero type config = { sender : Protocol.Contract_hash.t; - source : Signature.public_key_hash; + source : Tezos_crypto.Signature.public_key_hash; destination : Protocol.Alpha_context.Sc_rollup.t; } diff --git a/src/proto_alpha/bin_wasm_repl/messages.ml b/src/proto_alpha/bin_wasm_repl/messages.ml index dcff820e5b36..4818f88c71f4 100644 --- a/src/proto_alpha/bin_wasm_repl/messages.ml +++ b/src/proto_alpha/bin_wasm_repl/messages.ml @@ -51,7 +51,10 @@ let input_encoding default_sender default_source default_destination = (obj4 (req "payload" parsed_string_encoding) (dft "sender" Contract_hash.encoding default_sender) - (dft "source" Signature.Public_key_hash.encoding default_source) + (dft + "source" + Tezos_crypto.Signature.Public_key_hash.encoding + default_source) (dft "destination" Sc_rollup_repr.Address.encoding diff --git a/src/proto_alpha/lib_benchmark/dune b/src/proto_alpha/lib_benchmark/dune index 7866df984092..3a29e3bb29ae 100644 --- a/src/proto_alpha/lib_benchmark/dune +++ b/src/proto_alpha/lib_benchmark/dune @@ -30,6 +30,5 @@ -open Tezos_benchmark -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha - -open Tezos_crypto -open Tezos_alpha_test_helpers) (private_modules kernel rules state_space)) diff --git a/src/proto_alpha/lib_benchmark/execution_context.ml b/src/proto_alpha/lib_benchmark/execution_context.ml index 472bf9fa8737..d4089d8b67d1 100644 --- a/src/proto_alpha/lib_benchmark/execution_context.ml +++ b/src/proto_alpha/lib_benchmark/execution_context.ml @@ -53,7 +53,7 @@ let context_init ~rng_state = context_init_memory ~rng_state let make ~rng_state = context_init_memory ~rng_state >>=? fun context -> let amount = Alpha_context.Tez.one in - let chain_id = Chain_id.zero in + let chain_id = Tezos_crypto.Chain_id.zero in let now = Script_timestamp.of_zint Z.zero in let level = Script_int.zero_n in let open Script_interpreter in @@ -88,6 +88,8 @@ let make ~rng_state = let ctxt = Incremental.alpha_ctxt vs in let ctxt = (* Required for eg Create_contract *) - Protocol.Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Protocol.Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in return (ctxt, step_constants) diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers.ml b/src/proto_alpha/lib_benchmark/michelson_samplers.ml index 672588f78d60..f2c1a9f96a14 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers.ml +++ b/src/proto_alpha/lib_benchmark/michelson_samplers.ml @@ -608,7 +608,7 @@ end) let seed = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255) in - let pkh, _pk, _sk = Bls.generate_key ~seed () in + let pkh, _pk, _sk = Tezos_crypto.Bls.generate_key ~seed () in Tx_rollup_l2_address.Indexable.value pkh let chain_id rng_state = diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml b/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml index 586c2176e626..3f8f301fd1ab 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml +++ b/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml @@ -81,25 +81,25 @@ end) : S = struct let i = Random.State.int rng_state 4 in match i with | 0 -> ( - let open Ed25519 in + let open Tezos_crypto.Ed25519 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_ed25519 s) + | Some s -> Tezos_crypto.Signature.of_ed25519 s) | 1 -> ( - let open Secp256k1 in + let open Tezos_crypto.Secp256k1 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_secp256k1 s) + | Some s -> Tezos_crypto.Signature.of_secp256k1 s) | 2 -> ( - let open P256 in + let open Tezos_crypto.P256 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_p256 s) + | Some s -> Tezos_crypto.Signature.of_p256 s) | _ -> ( - let open Signature in + let open Tezos_crypto.Signature in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with None -> assert false | Some s -> s) diff --git a/src/proto_alpha/lib_benchmarks_proto/dune b/src/proto_alpha/lib_benchmarks_proto/dune index dfd091391e1e..ec271df25f9f 100644 --- a/src/proto_alpha/lib_benchmarks_proto/dune +++ b/src/proto_alpha/lib_benchmarks_proto/dune @@ -37,7 +37,6 @@ -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha -open Tezos_protocol_alpha.Protocol - -open Tezos_crypto -open Tezos_micheline -open Tezos_alpha_test_helpers -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml index 2fe28e0a7306..935d293043d3 100644 --- a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml @@ -421,7 +421,7 @@ module Timelock = struct Base_samplers.sample_in_interval ~range:{min = 1; max = 10000} rng_state in let chest, chest_key = - Timelock.chest_sampler ~plaintext_size ~time ~rng_state + Tezos_crypto.Timelock.chest_sampler ~plaintext_size ~time ~rng_state in ((chest, chest_key), plaintext_size) @@ -429,7 +429,9 @@ module Timelock = struct Registration_helpers.register @@ make_encode_variable_size_to_string ~name:"ENCODING_Chest" - ~to_string:(Data_encoding.Binary.to_string_exn Timelock.chest_encoding) + ~to_string: + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), plaintext_size = generator rng_state in (chest, {bytes = plaintext_size})) @@ -440,7 +442,8 @@ module Timelock = struct @@ make_encode_fixed_size_to_string ~name:"ENCODING_Chest_key" ~to_string: - (Data_encoding.Binary.to_string_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) @@ -450,12 +453,18 @@ module Timelock = struct Registration_helpers.register @@ make_decode_variable_size_from_bytes ~name:"DECODING_Chest" - ~to_bytes:(Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding) - ~from_bytes:(Data_encoding.Binary.of_bytes_exn Timelock.chest_encoding) + ~to_bytes: + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding) + ~from_bytes: + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), _ = generator rng_state in let b = - Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest in (chest, {bytes = Bytes.length b})) () @@ -465,9 +474,11 @@ module Timelock = struct @@ make_decode_fixed_size_from_bytes ~name:"DECODING_Chest_key" ~to_bytes: - (Data_encoding.Binary.to_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~from_bytes: - (Data_encoding.Binary.of_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index 0bda6f14adf9..783b63dcf45f 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -25,7 +25,7 @@ let ns = Namespace.make Registration_helpers.ns "interpreter" -module Timelock_samplers = Timelock +module Timelock_samplers = Tezos_crypto.Timelock open Protocol (* ------------------------------------------------------------------------- *) @@ -2322,13 +2322,15 @@ module Registration_section = struct ~kinstr:(ILevel (dummy_loc, halt)) () - let check_signature (algo : Signature.algo) ~for_intercept = + let check_signature (algo : Tezos_crypto.Signature.algo) ~for_intercept = let name = match algo with - | Signature.Ed25519 -> Interpreter_workload.N_ICheck_signature_ed25519 - | Signature.Secp256k1 -> + | Tezos_crypto.Signature.Ed25519 -> + Interpreter_workload.N_ICheck_signature_ed25519 + | Tezos_crypto.Signature.Secp256k1 -> Interpreter_workload.N_ICheck_signature_secp256k1 - | Signature.P256 -> Interpreter_workload.N_ICheck_signature_p256 + | Tezos_crypto.Signature.P256 -> + Interpreter_workload.N_ICheck_signature_p256 in benchmark_with_stack_sampler ~intercept:for_intercept @@ -2345,7 +2347,9 @@ module Registration_section = struct if for_intercept then Environment.Bytes.empty else Samplers.Random_value.value Script_typed_ir.bytes_t rng_state in - let signed_message = Signature.sign sk unsigned_message in + let signed_message = + Tezos_crypto.Signature.sign sk unsigned_message + in let signed_message = Script_signature.make signed_message in (pk, (signed_message, (unsigned_message, eos)))) () @@ -2354,11 +2358,11 @@ module Registration_section = struct check_signature algo ~for_intercept:true ; check_signature algo ~for_intercept:false - let () = check_signature Signature.Ed25519 + let () = check_signature Tezos_crypto.Signature.Ed25519 - let () = check_signature Signature.Secp256k1 + let () = check_signature Tezos_crypto.Signature.Secp256k1 - let () = check_signature Signature.P256 + let () = check_signature Tezos_crypto.Signature.P256 let () = simple_benchmark @@ -3069,12 +3073,13 @@ module Registration_section = struct let open Alpha_context in let step_constants = { - source = Contract.Implicit Signature.Public_key_hash.zero; - payer = Signature.Public_key_hash.zero; + source = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero; + payer = Tezos_crypto.Signature.Public_key_hash.zero; self = Contract_hash.zero; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml index 462f4b534578..09319a8e8e2d 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml @@ -1341,19 +1341,19 @@ let extract_ir_sized_step : | ILevel (_, _), _ -> Instructions.level | ICheck_signature (_, _), (public_key, (_signature, (message, _))) -> ( match public_key with - | Signature.Ed25519 _pk -> - let pk = Size.of_int Ed25519.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Ed25519 _pk -> + let pk = Size.of_int Tezos_crypto.Ed25519.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_ed25519 pk signature message - | Signature.Secp256k1 _pk -> - let pk = Size.of_int Secp256k1.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Secp256k1 _pk -> + let pk = Size.of_int Tezos_crypto.Secp256k1.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_secp256k1 pk signature message - | Signature.P256 _pk -> - let pk = Size.of_int P256.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.P256 _pk -> + let pk = Size.of_int Tezos_crypto.P256.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_p256 pk signature message) | IHash_key (_, _), _ -> Instructions.hash_key diff --git a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml index 7f79a37c47f5..12d428d901f1 100644 --- a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -211,7 +211,9 @@ module Sc_rollup_add_external_messages_benchmark = struct let ctxt = Incremental.alpha_ctxt b in (* Necessary to originate rollups. *) let ctxt = - Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in Alpha_context.Internal_for_tests.to_raw ctxt in diff --git a/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml index dac9aac901a7..27ced6957081 100644 --- a/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/storage_benchmarks.ml @@ -66,7 +66,7 @@ let default_raw_context () = let typecheck ctxt script_repr = return ((script_repr, None), ctxt) in let*! e = Init_storage.prepare_first_block - Chain_id.zero + Tezos_crypto.Chain_id.zero context ~level:0l ~timestamp:(Time.Protocol.of_seconds 1643125688L) diff --git a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml index 137113ef126c..4456f19bfdf8 100644 --- a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml @@ -152,7 +152,7 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let benchmark rng_state _conf () = let bytes = Base_samplers.bytes rng_state ~size:{min = 32; max = 64} in - let branch = Block_hash.hash_bytes [bytes] in + let branch = Tezos_crypto.Block_hash.hash_bytes [bytes] in let op_hash = Operation.hash_raw {shell = {branch}; proto = bytes} in let nonce = Origination_nonce.Internal_for_tests.initial op_hash in let contract = Contract.Internal_for_tests.originated_contract nonce in @@ -253,7 +253,12 @@ let () = Registration_helpers.register (module Has_tickets_type_benchmark) let ticket_sampler rng_state = let seed = Base_samplers.uniform_bytes ~nbytes:32 rng_state in - let pkh, _, _ = Signature.generate_key ~algo:Signature.Ed25519 ~seed () in + let pkh, _, _ = + Tezos_crypto.Signature.generate_key + ~algo:Tezos_crypto.Signature.Ed25519 + ~seed + () + in let ticketer = Alpha_context.Contract.Implicit pkh in Script_typed_ir. {ticketer; contents = Script_int.zero; amount = Ticket_amount.one} diff --git a/src/proto_alpha/lib_benchmarks_proto/tx_rollup_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/tx_rollup_benchmarks.ml index 0a884f1bf78c..20c409020245 100644 --- a/src/proto_alpha/lib_benchmarks_proto/tx_rollup_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/tx_rollup_benchmarks.ml @@ -252,7 +252,7 @@ let unique_ticket_id = let gen_l2_account rng_state = let seed = Base_samplers.uniform_bytes ~nbytes:32 rng_state in - Bls.generate_key ~seed () + Tezos_crypto.Bls.generate_key ~seed () let hash_key_exn ctxt ~ticketer ~typ ~contents ~owner = let ticketer = Micheline.root @@ Expr.from_string ticketer in diff --git a/src/proto_alpha/lib_client/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml index 068a034119df..a6922ece7968 100644 --- a/src/proto_alpha/lib_client/client_proto_args.ml +++ b/src/proto_alpha/lib_client/client_proto_args.ml @@ -555,7 +555,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") @@ -674,7 +674,7 @@ module Tx_rollup = struct let context_hash_parameter = Tezos_clic.parameter (fun _ s -> - match Context_hash.of_b58check_opt s with + match Tezos_crypto.Context_hash.of_b58check_opt s with | Some hash -> return hash | None -> failwith diff --git a/src/proto_alpha/lib_client/client_proto_args.mli b/src/proto_alpha/lib_client/client_proto_args.mli index 79ffb8507940..b1b510aabe9d 100644 --- a/src/proto_alpha/lib_client/client_proto_args.mli +++ b/src/proto_alpha/lib_client/client_proto_args.mli @@ -60,7 +60,8 @@ val entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg val default_entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -117,7 +118,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg @@ -182,7 +183,7 @@ module Tx_rollup : sig ?name:string -> usage:string -> ('a, full) Tezos_clic.params -> - (Context_hash.t -> 'a, full) Tezos_clic.params + (Tezos_crypto.Context_hash.t -> 'a, full) Tezos_clic.params val message_result_path_param : ?name:string -> diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 4e97c8980e67..477508806df9 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -318,7 +318,7 @@ let build_update_consensus_key ?fee ?gas_limit ?storage_limit consensus_pk = let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter ?consensus_pk src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in let delegate_op = build_delegate_operation ?fee (Some source) in match consensus_pk with | None -> ( @@ -379,7 +379,7 @@ let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run let update_consensus_key cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ~consensus_pk ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in let operation = build_update_consensus_key ?fee consensus_pk in let operation = Annotated_manager_operation.Single_manager operation in Injection.inject_manager_operation @@ -618,7 +618,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -629,7 +629,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -659,7 +659,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -707,12 +707,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -737,7 +739,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Operation_result.tez_sym Tez.pp @@ -752,13 +754,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -798,7 +800,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -906,7 +908,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_alpha/lib_client/client_proto_context.mli b/src/proto_alpha/lib_client/client_proto_context.mli index fd6dcbea39f1..d01859204c99 100644 --- a/src/proto_alpha/lib_client/client_proto_context.mli +++ b/src/proto_alpha/lib_client/client_proto_context.mli @@ -81,8 +81,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -140,7 +140,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t (** Calls {!Injection.prepare_manager_operation} @@ -180,10 +180,10 @@ val update_consensus_key : ?verbose_signing:bool -> ?simulation:bool -> ?fee:Tez.tez -> - consensus_pk:Signature.public_key -> + consensus_pk:Tezos_crypto.Signature.public_key -> manager_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> - Signature.public_key -> + Tezos_crypto.Signature.public_key -> Kind.update_consensus_key Kind.manager Injection.result tzresult Lwt.t val drain_delegate : @@ -195,9 +195,9 @@ val drain_delegate : ?verbose_signing:bool -> ?simulation:bool -> consensus_sk:Client_keys.sk_uri -> - consensus_pkh:Signature.public_key_hash -> - ?destination:Signature.public_key_hash -> - delegate:Signature.public_key_hash -> + consensus_pkh:Tezos_crypto.Signature.public_key_hash -> + ?destination:Tezos_crypto.Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> unit -> Kind.drain_delegate Injection.result tzresult Lwt.t @@ -243,7 +243,7 @@ val increase_paid_storage : Kind.increase_paid_storage Kind.manager Injection.result tzresult Lwt.t (** Same as {!set_delegate} but the [~source] argument of {!Injection.inject_manager_operation} - is {!Signature.Public_key.hash} [src_pk]. *) + is {!Tezos_crypto.Signature.Public_key.hash} [src_pk]. *) val register_as_delegate : #Protocol_client_context.full -> chain:Shell_services.chain -> @@ -407,7 +407,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -444,7 +444,7 @@ val activate_account : (** Activate an existing account, by calling {!Injection.inject_operation} with [activation code]. - It fails if the account is unknown or if the account is not [Ed25519]. *) + It fails if the account is unknown or if the account is not [Tezos_crypto.Ed25519]. *) val activate_existing_account : #Protocol_client_context.full -> chain:Shell_services.chain -> @@ -459,7 +459,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -512,7 +512,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t (** Calls {!Injection.inject_operation} @@ -527,7 +527,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -537,7 +537,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t (** Calls {!Tezos_protocol_alpha.Protocol.Alpha_services.Cache.cached_contracts} *) @@ -581,12 +581,12 @@ val originate_tx_rollup : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_origination Kind.manager contents * Kind.tx_rollup_origination Kind.manager Apply_results.contents_result) tzresult @@ -605,14 +605,14 @@ val submit_tx_rollup_batch : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> content:string -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_submit_batch Kind.manager contents * Kind.tx_rollup_submit_batch Kind.manager Apply_results.contents_result) tzresult @@ -630,8 +630,8 @@ val submit_tx_rollup_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -640,7 +640,7 @@ val submit_tx_rollup_commitment : predecessor:Tx_rollup_commitment_hash.t option -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_commit Kind.manager contents * Kind.tx_rollup_commit Kind.manager Apply_results.contents_result) tzresult @@ -658,13 +658,13 @@ val submit_tx_rollup_finalize_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_finalize_commitment Kind.manager contents * Kind.tx_rollup_finalize_commitment Kind.manager Apply_results.contents_result) @@ -683,13 +683,13 @@ val submit_tx_rollup_remove_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_remove_commitment Kind.manager contents * Kind.tx_rollup_remove_commitment Kind.manager Apply_results.contents_result) tzresult @@ -707,8 +707,8 @@ val submit_tx_rollup_rejection : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -718,12 +718,12 @@ val submit_tx_rollup_rejection : message_path:Tx_rollup_inbox.Merkle.path -> message_result_hash:Tx_rollup_message_result_hash.t -> message_result_path:Tx_rollup_commitment.Merkle.path -> - previous_context_hash:Context_hash.t -> + previous_context_hash:Tezos_crypto.Context_hash.t -> previous_withdraw_list_hash:Tx_rollup_withdraw_list_hash.t -> previous_message_result_path:Tx_rollup_commitment.Merkle.path -> proof:Tx_rollup_l2_proof.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_rejection Kind.manager contents * Kind.tx_rollup_rejection Kind.manager Apply_results.contents_result) tzresult @@ -741,13 +741,13 @@ val submit_tx_rollup_return_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_return_bond Kind.manager contents * Kind.tx_rollup_return_bond Kind.manager Apply_results.contents_result) tzresult @@ -765,18 +765,18 @@ val tx_rollup_dispatch_tickets : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> - context_hash:Context_hash.t -> + context_hash:Tezos_crypto.Context_hash.t -> message_position:int -> message_result_path:Tx_rollup_commitment.Merkle.path -> tickets_info:Tx_rollup_reveal.t list -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_dispatch_tickets Kind.manager contents * Kind.tx_rollup_dispatch_tickets Kind.manager Apply_results.contents_result) tzresult @@ -794,8 +794,8 @@ val transfer_ticket : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> contents:string -> @@ -805,7 +805,7 @@ val transfer_ticket : destination:Contract.t -> entrypoint:Entrypoint.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.transfer_ticket Kind.manager contents * Kind.transfer_ticket Kind.manager Apply_results.contents_result) tzresult @@ -831,7 +831,7 @@ val sc_rollup_originate : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_originate Kind.manager contents * Kind.sc_rollup_originate Kind.manager Apply_results.contents_result, tztrace ) @@ -856,7 +856,7 @@ val sc_rollup_add_messages : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_add_messages Kind.manager contents * Kind.sc_rollup_add_messages Kind.manager Apply_results.contents_result) tzresult @@ -881,7 +881,7 @@ val sc_rollup_cement : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_cement Kind.manager contents * Kind.sc_rollup_cement Kind.manager Apply_results.contents_result) tzresult @@ -906,7 +906,7 @@ val sc_rollup_publish : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_publish Kind.manager contents * Kind.sc_rollup_publish Kind.manager Apply_results.contents_result) tzresult @@ -932,7 +932,7 @@ val sc_rollup_execute_outbox_message : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_execute_outbox_message Kind.manager contents * Kind.sc_rollup_execute_outbox_message Kind.manager Apply_results.contents_result, @@ -952,13 +952,13 @@ val sc_rollup_recover_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Manager_counter.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> sc_rollup:Sc_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_recover_bond Kind.manager contents * Kind.sc_rollup_recover_bond Kind.manager Apply_results.contents_result) tzresult @@ -984,7 +984,7 @@ val sc_rollup_refute : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_refute Kind.manager contents * Kind.sc_rollup_refute Kind.manager Apply_results.contents_result) tzresult @@ -1010,7 +1010,7 @@ val sc_rollup_timeout : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_timeout Kind.manager contents * Kind.sc_rollup_timeout Kind.manager Apply_results.contents_result) tzresult diff --git a/src/proto_alpha/lib_client/client_proto_fa12.mli b/src/proto_alpha/lib_client/client_proto_fa12.mli index cfd100f44a46..8dccc6bbca64 100644 --- a/src/proto_alpha/lib_client/client_proto_fa12.mli +++ b/src/proto_alpha/lib_client/client_proto_fa12.mli @@ -155,7 +155,7 @@ val run_view_action : ?source:Contract.t -> contract:Contract_hash.t -> action:action -> - ?payer:Signature.public_key_hash -> + ?payer:Tezos_crypto.Signature.public_key_hash -> ?gas:Gas.Arith.integral -> unparsing_mode:Script_ir_unparser.unparsing_mode -> unit -> diff --git a/src/proto_alpha/lib_client/client_proto_multisig.ml b/src/proto_alpha/lib_client/client_proto_multisig.ml index 108233e7b2ab..9d8d9e8e7f7e 100644 --- a/src/proto_alpha/lib_client/client_proto_multisig.ml +++ b/src/proto_alpha/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -584,11 +588,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) @@ -599,10 +604,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) Data_encoding.(tup2 Contract.encoding Entrypoint.value_encoding) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -707,7 +714,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -783,7 +790,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -810,7 +817,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -820,7 +827,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -847,7 +854,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -859,7 +867,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -880,7 +888,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -897,7 +908,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1045,7 +1060,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1174,7 +1189,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_alpha/lib_client/client_proto_multisig.mli b/src/proto_alpha/lib_client/client_proto_multisig.mli index 5ebfd1448d0f..cb82be9493a1 100644 --- a/src/proto_alpha/lib_client/client_proto_multisig.mli +++ b/src/proto_alpha/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -139,7 +139,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_alpha/lib_client/client_proto_programs.ml b/src/proto_alpha/lib_client/client_proto_programs.ml index 4412d16c001c..3f944c498f9f 100644 --- a/src/proto_alpha/lib_client/client_proto_programs.ml +++ b/src/proto_alpha/lib_client/client_proto_programs.ml @@ -126,7 +126,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Signature.public_key_hash option; + payer : Tezos_crypto.Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_alpha/lib_client/client_proto_programs.mli b/src/proto_alpha/lib_client/client_proto_programs.mli index 383d2116b10b..8e5c87d2ef5e 100644 --- a/src/proto_alpha/lib_client/client_proto_programs.mli +++ b/src/proto_alpha/lib_client/client_proto_programs.mli @@ -39,7 +39,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Signature.public_key_hash option; + payer : Tezos_crypto.Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_alpha/lib_client/client_proto_utils.ml b/src/proto_alpha/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_alpha/lib_client/client_proto_utils.ml +++ b/src/proto_alpha/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_alpha/lib_client/client_proto_utils.mli b/src/proto_alpha/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_alpha/lib_client/client_proto_utils.mli +++ b/src/proto_alpha/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index b7b8f98fdb92..6c18cf9d9d47 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -57,12 +57,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee (contents : packed_contents_list) = let l = Operation.to_list contents in @@ -176,18 +179,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -210,7 +218,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -236,7 +244,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let watermark = match contents with (* TODO-TB sign endorsement? *) - | _ -> Signature.Generic_operation + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -251,7 +259,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -785,7 +793,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -1048,12 +1056,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -1064,7 +1072,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (* Adjust user-provided confirmations with respect to Alpha protocol finality properties *) tenderbake_adjust_confirmations cctxt confirmations >>= fun confirmations -> (match confirmations with @@ -1076,10 +1085,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -1140,10 +1149,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op, result.contents) @@ -1206,10 +1215,10 @@ let pending_applied_operations_of_source (cctxt : #full) chain src : (fun acc (_oph, {protocol_data = Operation_data {contents; _}; _}) -> match contents with | Single (Manager_operation {source; _} as _op) - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | Cons (Manager_operation {source; _}, _rest) as _op - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | _ -> acc) [] @@ -1332,14 +1341,14 @@ let replace_operation (type kind) (cctxt : #full) chain source cctxt#error "Cannot replace! No applied manager operation found for %a in \ mempool@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source >>= fun () -> exit 1 | _ :: _ :: _ as l -> cctxt#error "More than one applied manager operation found for %a in mempool. \ Found %d operations. Are you sure the node is in precheck mode?@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source (List.length l) >>= fun () -> exit 1 @@ -1364,7 +1373,7 @@ let inject_manager_operation cctxt ~chain ~block ?successor_level ?branch ~src_sk ~fee ~gas_limit ~storage_limit ?counter ?(replace_by_fees = false) ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * kind Kind.manager contents_list * kind Kind.manager contents_result_list) diff --git a/src/proto_alpha/lib_client/injection.mli b/src/proto_alpha/lib_client/injection.mli index d66775157c80..c9d649eeb41b 100644 --- a/src/proto_alpha/lib_client/injection.mli +++ b/src/proto_alpha/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -63,7 +63,9 @@ val simulate : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -83,7 +85,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -103,8 +106,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> @@ -113,7 +116,7 @@ val inject_manager_operation : ?replace_by_fees:bool -> fee_parameter:fee_parameter -> 'kind Annotated_manager_operation.annotated_list -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * 'kind Kind.manager contents_list * 'kind Kind.manager contents_result_list) diff --git a/src/proto_alpha/lib_client/managed_contract.ml b/src/proto_alpha/lib_client/managed_contract.ml index 5d406c127648..3edbaae33415 100644 --- a/src/proto_alpha/lib_client/managed_contract.ml +++ b/src/proto_alpha/lib_client/managed_contract.ml @@ -51,7 +51,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -62,7 +62,7 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported for \ \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value with | Some k -> return k | None -> cctxt#error @@ -89,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -104,7 +106,7 @@ let entrypoint_remove_delegate = Entrypoint.remove_delegate let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = entrypoint_do in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -139,7 +141,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -160,7 +162,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -190,7 +192,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 62ed51f59076..ad1b10ea3158 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -35,7 +35,7 @@ module Protocol_constants_overrides = struct (** Equivalent of [Constants.parametric] with additionally [chain_id] and [timestamp]. *) type t = { parametric : Constants.Parametric.t; - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; } @@ -49,7 +49,7 @@ module Protocol_constants_overrides = struct (merge_objs Constants.Parametric.encoding (obj2 - (opt "chain_id" Chain_id.encoding) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding))) let default_value (cctxt : Tezos_client_base.Client_context.full) : @@ -99,7 +99,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. { @@ -165,11 +165,11 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount, delegate_to, consensus_key) -> {public_key_hash; public_key; amount; delegate_to; consensus_key}) (obj5 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding) - (opt "delegate_to" Signature.Public_key_hash.encoding) - (opt "consensus_key" Signature.Public_key.encoding)) + (opt "delegate_to" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "consensus_key" Tezos_crypto.Signature.Public_key.encoding)) end module Bootstrap_contract = struct @@ -180,7 +180,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -239,7 +239,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -259,14 +259,14 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end (* ------------------------------------------------------------------------- *) (* RPC context *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" let endorsement_branch_data_encoding = @@ -275,7 +275,7 @@ let endorsement_branch_data_encoding = (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (obj2 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "block_payload_hash" Protocol.Block_payload_hash.encoding)) let initial_context chain_id (header : Block_header.shell_header) @@ -451,7 +451,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in (match bootstrap_accounts_json with | None -> return None @@ -495,10 +495,13 @@ let mem_init : let protocol_data = let payload_hash = Protocol.Block_payload_hash.hash_bytes - [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] + [ + Tezos_crypto.Block_hash.to_bytes hash; + Tezos_crypto.Operation_list_hash.(to_bytes @@ compute []); + ] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Signature.generate_key () in + let _, _, sk = Tezos_crypto.Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -518,7 +521,7 @@ let mem_init : (shell_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 72ca9b9a44f9..fc9e131388b6 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -96,13 +96,13 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Event {ty; tag; payload} -> Format.fprintf ppf @@ -169,7 +169,7 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Reveal key -> Format.fprintf @@ -177,13 +177,13 @@ let pp_manager_operation_content (type kind) source ppf "Revelation of manager public key:@,Contract: %a@,Key: %a" Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Register_global_constant {value} -> Format.fprintf ppf @@ -213,8 +213,8 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "Update_consensus_key:@,Public key hash: %a" - Signature.Public_key_hash.pp - (Signature.Public_key.hash pk) + Tezos_crypto.Signature.Public_key_hash.pp + (Tezos_crypto.Signature.Public_key.hash pk) | Tx_rollup_origination -> Format.fprintf ppf @@ -326,8 +326,8 @@ let pp_manager_operation_content (type kind) source ppf R.name pp_micheline_from_lazy_expr parameters_ty - Blake2B.pp - (Blake2B.hash_string [boot_sector]) + Tezos_crypto.Blake2B.pp + (Tezos_crypto.Blake2B.hash_string [boot_sector]) | Sc_rollup_add_messages {messages = _} -> Format.pp_print_string ppf "Smart contract rollup messages submission" | Sc_rollup_cement {rollup; commitment} -> @@ -417,9 +417,12 @@ let pp_balance_updates ppf balance_updates = (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero then - Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero + then Format.fprintf ppf "the baker who will include this operation" + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -980,7 +983,11 @@ let pp_manager_operation_result ppf Manager_operation_result {balance_updates; operation_result; internal_operation_results} ) = Format.fprintf ppf "@[Manager signed operations:" ; - Format.fprintf ppf "@,From: %a" Signature.Public_key_hash.pp source ; + Format.fprintf + ppf + "@,From: %a" + Tezos_crypto.Signature.Public_key_hash.pp + source ; Format.fprintf ppf "@,Fee to the baker: %s%a" tez_sym Tez.pp fee ; Format.fprintf ppf "@,Expected counter: %a" Manager_counter.pp counter ; Format.fprintf ppf "@,Gas limit: %a" Gas.Arith.pp_integral gas_limit ; @@ -1031,9 +1038,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -1075,7 +1082,7 @@ let pp_contents_and_result : Format.fprintf ppf "@[Slot availability:@,Delegate: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate | ( Double_endorsement_evidence {op1; op2}, Double_endorsement_evidence_result bus ) -> @@ -1086,9 +1093,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1101,9 +1108,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1114,7 +1121,7 @@ let pp_contents_and_result : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -1122,19 +1129,19 @@ let pp_contents_and_result : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Ballot {source; period; proposal; ballot}, Ballot_result -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) @@ -1147,11 +1154,11 @@ let pp_contents_and_result : Consensus key hash: %a@,\ Delegate: %a@,\ Destination: %a%s%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp consensus_key - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp destination (if allocated_destination_contract then " (allocated)" else "") pp_balance_updates diff --git a/src/proto_alpha/lib_client/proxy.ml b/src/proto_alpha/lib_client/proxy.ml index ba6d01b6a7c5..26a2ebb2204d 100644 --- a/src/proto_alpha/lib_client/proxy.ml +++ b/src/proto_alpha/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index bdd2a6921126..92b6c3c1cafd 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -81,7 +81,7 @@ let report_michelson_errors ?(no_print_source = false) ~msg let block_hash_param = Tezos_clic.parameter (fun _ s -> - try Lwt_result_syntax.return (Block_hash.of_b58check_exn s) + try Lwt_result_syntax.return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -569,7 +569,7 @@ let commands_ro () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ stop) @@ -613,7 +613,10 @@ let commands_ro () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -632,13 +635,16 @@ let commands_ro () = fprintf ppf "* %a %a %s (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p Tez.pp (Tez.of_mutez_exn w) Operation_result.tez_sym (if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; @@ -1084,7 +1090,7 @@ let commands_rw () = (Some delegate) in let*! (_ : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * _ contents * _ Apply_results.contents_result) option) = @@ -1379,7 +1385,7 @@ let commands_rw () = contents in let*! (_ : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * _ contents_list * _ Apply_results.contents_result_list) @@ -1844,7 +1850,7 @@ let commands_rw () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ prefixes ["to"; "be"; "included"] @@ -1853,7 +1859,7 @@ let commands_rw () = operation_hash (ctxt : Protocol_client_context.full) -> let open Lwt_result_syntax in - let* (_ : Block_hash.t * int * int) = + let* (_ : Tezos_crypto.Block_hash.t * int * int) = Client_confirmations.wait_for_operation_inclusion ctxt ~chain:ctxt#chain @@ -1884,7 +1890,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)))) @@ -1948,7 +1954,9 @@ let commands_rw () = (List.length proposals) Constants.max_proposals_per_delegate ; (match - Base.List.find_all_dups ~compare:Protocol_hash.compare proposals + Base.List.find_all_dups + ~compare:Tezos_crypto.Protocol_hash.compare + proposals with | [] -> () | dups -> @@ -1960,22 +1968,25 @@ let commands_rw () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem ~equal:Tezos_crypto.Protocol_hash.equal p known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else - error "Protocol %a is not a known proposal." Protocol_hash.pp p) + error + "Protocol %a is not a known proposal." + Tezos_crypto.Protocol_hash.pp + p) proposals ; if not has_voting_power then error "Public-key-hash `%a` from account `%s` does not appear to have \ voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -2059,7 +2070,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ param @@ -2099,12 +2110,13 @@ let commands_rw () = let* () = match (info.current_period_kind, current_proposal) with | (Exploration | Promotion), Some current_proposal -> - if Protocol_hash.equal proposal current_proposal then return_unit + if Tezos_crypto.Protocol_hash.equal proposal current_proposal then + return_unit else let*! () = (if force then cctxt#warning else cctxt#error) "Unexpected proposal, expected: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp current_proposal in return_unit @@ -2136,7 +2148,7 @@ let commands_rw () = (if force then cctxt#warning else cctxt#error) "Public-key-hash `%a` from account `%s` does not appear to have \ voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name in diff --git a/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml index ac592f0ac2a5..bac3b401d30d 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_fa12_commands.ml @@ -109,7 +109,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.Implicit Signature.Public_key_hash.zero +let dummy_callback = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt (caller : Contract.t) = let open Lwt_result_syntax in diff --git a/src/proto_alpha/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_multisig_commands.ml index fd209a22ce8e..05f08ce7f464 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_multisig_commands.ml @@ -113,7 +113,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -127,7 +128,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) @@ -335,7 +336,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -369,7 +370,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -401,7 +402,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -426,7 +427,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -466,7 +467,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group diff --git a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml index 301fb07c2f2a..df0b2eec95f3 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml @@ -136,7 +136,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> Lwt_result_syntax.return s | None -> failwith "Not given a valid signature") in @@ -483,8 +483,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -735,7 +735,9 @@ let commands () = (fun () bytes sk cctxt -> let open Lwt_result_syntax in let* signature = Client_keys.sign cctxt sk bytes in - let*! () = cctxt#message "Signature: %a" Signature.pp signature in + let*! () = + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + in return_unit); command ~group diff --git a/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml index 1ad8c9b82c93..9b69f2704882 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_stresstest_commands.ml @@ -64,14 +64,14 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type source_with_uri = { pkh : public_key_hash; pk : public_key; pk_uri : Client_keys.pk_uri; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; sk_uri : Client_keys.sk_uri; } @@ -85,7 +85,7 @@ type source_origin = {source : source; origin : origin} (** Destination of a call: either an implicit contract or an originated one with all the necessary data (entrypoint and the argument). *) type destination = - | Implicit of Signature.Public_key_hash.t + | Implicit of Tezos_crypto.Signature.Public_key_hash.t | Originated of Smart_contracts.invocation_parameters type transfer = { @@ -100,17 +100,18 @@ type transfer = { type state = { rng_state : Random.State.t; - current_head_on_start : Block_hash.t; + current_head_on_start : Tezos_crypto.Block_hash.t; mutable pool : source_origin list; mutable pool_size : int; mutable shuffled_pool : source list; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; - mutable target_block : Block_hash.t; + mutable target_block : Tezos_crypto.Block_hash.t; (** The block on top of which we are injecting transactions (HEAD~2). *) new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } (** Cost estimations for every kind of transaction used in the stress test. @@ -161,9 +162,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -175,7 +176,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -186,8 +187,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let transaction_costs_encoding = let open Data_encoding in @@ -241,7 +242,7 @@ let normalize_source cctxt = let open Lwt_syntax in let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -282,7 +283,9 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - let* () = cctxt#warning msg Signature.Public_key_hash.pp pkh in + let* () = + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + in return_none in let* key = @@ -297,7 +300,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias in @@ -343,7 +346,7 @@ let rec get_source_from_shuffled_pool state cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) in Lwt.return source @@ -351,7 +354,7 @@ let rec get_source_from_shuffled_pool state let* () = cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block in let* () = Lwt_condition.wait state.new_block_condition in @@ -362,7 +365,7 @@ let random_seed rng = let generate_fresh_source state = let seed = random_seed state.rng_state in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in state.pool <- fresh :: state.pool ; state.pool_size <- state.pool_size + 1 ; @@ -373,7 +376,9 @@ let generate_fresh_source state = [promise] resolved when the stream is closed. [stopper ()] closes the stream. *) let heads_iter (cctxt : Protocol_client_context.full) - (f : Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t) : + (f : + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t) : (unit tzresult Lwt.t * Tezos_rpc.Context.stopper) tzresult Lwt.t = let open Lwt_result_syntax in let* heads_stream, stopper = Shell_services.Monitor.heads cctxt `Main in @@ -388,7 +393,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "heads_iter: new block received %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp new_block_hash) in let* protocols = @@ -397,7 +402,10 @@ let heads_iter (cctxt : Protocol_client_context.full) ~block:(`Hash (new_block_hash, 0)) () in - if Protocol_hash.(protocols.current_protocol = Protocol.hash) then + if + Tezos_crypto.Protocol_hash.( + protocols.current_protocol = Protocol.hash) + then let* () = f block_hash_and_header in loop () else @@ -406,7 +414,7 @@ let heads_iter (cctxt : Protocol_client_context.full) cctxt#message "heads_iter: new block on protocol %a. Stopping \ iteration.@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocols.current_protocol) in return_unit) @@ -420,7 +428,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "head iteration for proto %a stopped@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash) in return (promise, stopper) @@ -453,7 +461,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block log Debug (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) in (* Sampled source has zero balance: the transfer that created that @@ -499,7 +507,11 @@ let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -552,14 +564,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state Alpha_services.Contract.counter cctxt (`Main, `Head 0) transfer.src.pkh in let* already_revealed = - if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; let* pk_opt = Alpha_services.Contract.manager_key cctxt @@ -593,7 +610,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Manager_counter.pp reveal_counter @@ -619,7 +636,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Manager_counter.pp transf_counter @@ -635,15 +652,18 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Debug (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) in let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find state.injected_operations branch) in - Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; + Tezos_crypto.Block_hash.Table.replace + state.injected_operations + branch + (op_hash :: ops) ; return_unit | Error e -> let*! () = @@ -660,7 +680,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -683,10 +703,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = let* current_head_on_exit = Shell_services.Blocks.hash cctxt () in let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -718,7 +738,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -732,9 +752,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = log Debug (fun () -> cctxt#message "injected : [%a]@.included: [%a]" - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) included_ops) in let injected_ops_count = List.length injected_ops in @@ -828,7 +848,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) loop () in let on_new_head : - Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t = + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t = (* Because of how Tenderbake works the target block should stay 2 blocks in the past because this guarantees that we are targeting a block that is decided. *) @@ -842,7 +863,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) in fun (new_block_hash, new_block_header) -> let* () = update_target_block () in - if not (Block_hash.equal new_block_hash state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal new_block_hash state.last_block) + then ( state.last_block <- new_block_hash ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1178,7 +1200,9 @@ let generate_random_transactions = let sources = List.sort_uniq (fun src1 src2 -> - Signature.Secret_key.compare src1.source.sk src2.source.sk) + Tezos_crypto.Signature.Secret_key.compare + src1.source.sk + src2.source.sk) sources in let rng_state = Random.State.make [|parameters.seed|] in @@ -1191,7 +1215,7 @@ let generate_random_transactions = cctxt#error "The level of the head (%a) needs to be greater than 2 and is \ actually %ld." - Block_hash.pp + Tezos_crypto.Block_hash.pp current_head_on_start header_on_start.level else return_unit @@ -1209,12 +1233,12 @@ let generate_random_transactions = List.shuffle ~rng:rng_state (List.map (fun src_org -> src_org.source) sources); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.level; target_block = current_target_block; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = @@ -1494,14 +1518,14 @@ let load_wallet cctxt ~source_pkh = | [] -> return acc | (alias, pkh, _, _) :: tl when List.exists (String.equal alias) to_ban - || Signature.Public_key_hash.equal pkh source_pkh -> + || Tezos_crypto.Signature.Public_key_hash.equal pkh source_pkh -> aux acc tl | (_, pkh, pk, sk_uri) :: tl -> let* pk_uri = Client_keys.neuterize sk_uri in let payload = Uri.path (sk_uri : Tezos_signer_backends.Unencrypted.sk_uri :> Uri.t) in - let sk = Signature.Secret_key.of_b58check_exn payload in + let sk = Tezos_crypto.Signature.Secret_key.of_b58check_exn payload in aux ({pkh; pk; pk_uri; sk; sk_uri} :: acc) tl in aux [] keys @@ -1514,7 +1538,7 @@ let source_key_arg = "Source key public key hash from which the tokens will be transferred to \ start the funding." (parameter (fun _ s -> - let r = Signature.Public_key_hash.of_b58check s in + let r = Tezos_crypto.Signature.Public_key_hash.of_b58check s in match r with | Ok pkh -> Lwt_result_syntax.return pkh | Error e -> @@ -1799,7 +1823,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command cctxt#message "Starting funding from %a with parameters:@.- batch_size %d@.- \ batches_per_block %d@.- initial_amount %a@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh batch_size batches_per_block @@ -1866,7 +1890,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command source_balance Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh else let*! () = @@ -1875,7 +1899,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command "Transfering %a tz from %a (out of %a)@." Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh Tez.pp source_balance) diff --git a/src/proto_alpha/lib_client_commands/client_proto_utils_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_utils_commands.ml index 0c210d59cfb6..837defaed600 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_utils_commands.ml @@ -95,7 +95,9 @@ let commands () = () in let* signature = sign_message cctxt ~src_sk ~block ~message in - let*! () = cctxt#message "Signature: %a" Signature.pp signature in + let*! () = + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + in return_unit); command ~group @@ -175,6 +177,8 @@ let commands () = sk unsigned_header in - let*! () = cctxt#message "%a" Hex.pp (Signature.to_hex s) in + let*! () = + cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) + in return_unit); ] diff --git a/src/proto_alpha/lib_client_sapling/client_sapling_commands.ml b/src/proto_alpha/lib_client_sapling/client_sapling_commands.ml index 862335b18cb6..4c8cbdab0c9f 100644 --- a/src/proto_alpha/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_alpha/lib_client_sapling/client_sapling_commands.ml @@ -53,7 +53,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -61,7 +61,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Contract_hash.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) (** The shielded tez contract expects the recipient pkh encoded in Micheline @@ -70,7 +70,9 @@ let bound_data_of_public_key_hash cctxt dst = let open Tezos_micheline in let open Protocol.Michelson_v1_primitives in let pkh_bytes = - Data_encoding.Binary.to_bytes_exn Signature.Public_key_hash.encoding dst + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key_hash.encoding + dst in let micheline_bytes = Micheline.(Bytes (0, pkh_bytes) |> strip_locations) in let micheline_pkh_type = @@ -664,7 +666,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_alpha/lib_client_sapling/context.ml b/src/proto_alpha/lib_client_sapling/context.ml index 9412ecb6f6e0..1122de030c3a 100644 --- a/src/proto_alpha/lib_client_sapling/context.ml +++ b/src/proto_alpha/lib_client_sapling/context.ml @@ -140,7 +140,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_alpha/lib_delegate/abstract_context_index.ml b/src/proto_alpha/lib_delegate/abstract_context_index.ml index da5a0d216721..50954c9da376 100644 --- a/src/proto_alpha/lib_delegate/abstract_context_index.ml +++ b/src/proto_alpha/lib_delegate/abstract_context_index.ml @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.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 e6d262a8ad03..2d0533b7067b 100644 --- a/src/proto_alpha/lib_delegate/abstract_context_index.mli +++ b/src/proto_alpha/lib_delegate/abstract_context_index.mli @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.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/baking_cache.ml b/src/proto_alpha/lib_delegate/baking_cache.ml index af2ac36dc1fc..67fdb2d6a581 100644 --- a/src/proto_alpha/lib_delegate/baking_cache.ml +++ b/src/proto_alpha/lib_delegate/baking_cache.ml @@ -31,7 +31,7 @@ type round = Round.t module Block_cache = (val Ringo.(map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash) + (Tezos_crypto.Block_hash) (** The [Timestamp_of_round_tbl] module allows to create memoization tables to store function calls of [Round.timestamp_of_round]. *) diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index b827d5b7cadd..9d76b8745fff 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -166,7 +166,7 @@ let liquidity_baking_toggle_vote_arg = liquidity_baking_toggle_vote_parameter let get_delegates (cctxt : Protocol_client_context.full) - (pkhs : Signature.public_key_hash list) = + (pkhs : Tezos_crypto.Signature.public_key_hash list) = let proj_delegate (alias, public_key_hash, public_key, secret_key_uri) = { Baking_state.alias = Some alias; diff --git a/src/proto_alpha/lib_delegate/baking_configuration.ml b/src/proto_alpha/lib_delegate/baking_configuration.ml index 2b8dca57b0f6..db13c684bf3c 100644 --- a/src/proto_alpha/lib_delegate/baking_configuration.ml +++ b/src/proto_alpha/lib_delegate/baking_configuration.ml @@ -81,7 +81,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -221,7 +221,7 @@ let retries_on_failure_config_encoding = Data_encoding.int31 let user_activate_upgrades_config_encoding = let open Data_encoding in - list (tup2 int32 Protocol_hash.encoding) + list (tup2 int32 Tezos_crypto.Protocol_hash.encoding) let liquidity_baking_toggle_vote_config_encoding = Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote_encoding diff --git a/src/proto_alpha/lib_delegate/baking_configuration.mli b/src/proto_alpha/lib_delegate/baking_configuration.mli index a1908d29dd22..cd5b5a445f41 100644 --- a/src/proto_alpha/lib_delegate/baking_configuration.mli +++ b/src/proto_alpha/lib_delegate/baking_configuration.mli @@ -56,7 +56,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -73,7 +73,8 @@ val default_nonce_config : nonce_config val default_retries_on_failure_config : int -val default_user_activated_upgrades : (int32 * Protocol_hash.t) list +val default_user_activated_upgrades : + (int32 * Tezos_crypto.Protocol_hash.t) list val default_liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote @@ -95,7 +96,7 @@ val make : ?nonce:nonce_config -> ?context_path:string -> ?retries_on_failure:int -> - ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> + ?user_activated_upgrades:(int32 * Tezos_crypto.Protocol_hash.t) list -> ?liquidity_baking_toggle_vote: Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote -> ?per_block_vote_file:string -> @@ -114,7 +115,7 @@ val nonce_config_encoding : nonce_config Data_encoding.t val retries_on_failure_config_encoding : int Data_encoding.t val user_activate_upgrades_config_encoding : - (int32 * Protocol_hash.t) list Data_encoding.t + (int32 * Tezos_crypto.Protocol_hash.t) list Data_encoding.t val liquidity_baking_toggle_vote_config_encoding : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote diff --git a/src/proto_alpha/lib_delegate/baking_events.ml b/src/proto_alpha/lib_delegate/baking_events.ml index 0dd45ce85c65..2f1383b08951 100644 --- a/src/proto_alpha/lib_delegate/baking_events.ml +++ b/src/proto_alpha/lib_delegate/baking_events.ml @@ -43,8 +43,8 @@ module State_transitions = struct ~name:"new_head" ~level:Notice ~msg:"received new head {block} at level {level}, round {round}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) ~pp3:Round.pp @@ -119,12 +119,12 @@ module State_transitions = struct ~msg: "proposal {new_proposal} for current round ({current_round}) has \ already been seen {previous_proposal}" - ~pp1:Block_hash.pp - ("new_proposal", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("new_proposal", Tezos_crypto.Block_hash.encoding) ~pp2:Round.pp ("current_round", Round.encoding) - ~pp3:Block_hash.pp - ("previous_proposal", Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("previous_proposal", Tezos_crypto.Block_hash.encoding) let updating_latest_proposal = declare_1 @@ -132,8 +132,8 @@ module State_transitions = struct ~name:"updating_latest_proposal" ~msg:"updating latest proposal to {block_hash}" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let baker_is_ahead_of_node = declare_2 @@ -156,10 +156,10 @@ module State_transitions = struct ~msg: "received a proposal on another branch - current: current \ pred{current_branch}, new pred {new_branch}" - ~pp1:Block_hash.pp - ("current_branch", Block_hash.encoding) - ~pp2:Block_hash.pp - ("new_branch", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("current_branch", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("new_branch", Tezos_crypto.Block_hash.encoding) let switching_branch = declare_0 @@ -215,8 +215,8 @@ module State_transitions = struct ~name:"attempting_preendorsing_proposal" ~level:Info ~msg:"attempting to preendorse proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let skipping_invalid_proposal = declare_0 @@ -232,8 +232,8 @@ module State_transitions = struct ~name:"outdated_proposal" ~level:Debug ~msg:"outdated proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let proposing_fresh_block = declare_2 @@ -271,10 +271,10 @@ module State_transitions = struct ~msg: "unexpected prequorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let unexpected_quorum_received = declare_2 @@ -284,10 +284,10 @@ module State_transitions = struct ~msg: "unexpected quorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let step_current_phase = declare_2 @@ -321,8 +321,8 @@ module Node_rpc = struct ~name:"raw_info" ~level:Debug ~msg:"raw info for {block_hash} at level {level}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) end @@ -451,8 +451,8 @@ module Scheduling = struct ~name:"proposal_in_the_future" ~level:Debug ~msg:"received proposal in the future {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let process_proposal_in_the_future = declare_1 @@ -460,8 +460,8 @@ module Scheduling = struct ~name:"process_proposal_in_the_future" ~level:Debug ~msg:"process proposal received in the future with hash {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) end module Lib = struct @@ -543,8 +543,8 @@ module Actions = struct ~name:"preendorsement_injected" ~level:Notice ~msg:"injected preendorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_consensus_key_and_delegate ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -554,8 +554,8 @@ module Actions = struct ~name:"endorsement_injected" ~level:Notice ~msg:"injected endorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_consensus_key_and_delegate ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -565,8 +565,8 @@ module Actions = struct ~name:"synchronizing_round" ~level:Info ~msg:"synchronizing round after block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let forging_block = declare_3 @@ -601,11 +601,11 @@ module Actions = struct ~level:Notice ~msg: "block {block} at level {level}, round {round} injected for {delegate}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:pp_int32 ~pp3:Round.pp ~pp4:Baking_state.pp_consensus_key_and_delegate - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("round", Round.encoding) ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -680,8 +680,8 @@ module VDF = struct ("cycle", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let vdf_daemon_start = declare_1 @@ -729,8 +729,8 @@ module Nonces = struct ~name:"found_nonce_to_reveal" ~level:Notice ~msg:"found nonce to reveal for block {block}, level {level}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) @@ -746,8 +746,8 @@ module Nonces = struct ("level", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let cannot_fetch_chain_head_level = declare_0 @@ -821,8 +821,8 @@ module Nonces = struct ~name:"registering_nonce" ~level:Info ~msg:"registering nonce for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let nothing_to_reveal = declare_1 @@ -830,8 +830,8 @@ module Nonces = struct ~name:"nothing_to_reveal" ~level:Info ~msg:"nothing to reveal for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let revelation_worker_started = declare_0 @@ -916,8 +916,8 @@ module Selection = struct ~name:"invalid_operation_filtered" ~level:Warning ~msg:"filtered invalid operation {op}: {errors}" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) @@ -927,6 +927,6 @@ module Selection = struct ~name:"cannot_serialize_operation_metadata" ~level:Warning ~msg:"cannot serialize operation {op} metadata" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) end diff --git a/src/proto_alpha/lib_delegate/baking_files.ml b/src/proto_alpha/lib_delegate/baking_files.ml index 38339e2fe555..67ef0c7ea0d4 100644 --- a/src/proto_alpha/lib_delegate/baking_files.ml +++ b/src/proto_alpha/lib_delegate/baking_files.ml @@ -32,6 +32,6 @@ let resolve_location ~chain_id (kind : 'a) : 'a location = | `State -> "baker_state" | `Nonce -> "nonce" in - Format.asprintf "%a_%s" Chain_id.pp_short chain_id basename + Format.asprintf "%a_%s" Tezos_crypto.Chain_id.pp_short chain_id basename let filename x = x diff --git a/src/proto_alpha/lib_delegate/baking_files.mli b/src/proto_alpha/lib_delegate/baking_files.mli index 01146f7d0744..82940952da05 100644 --- a/src/proto_alpha/lib_delegate/baking_files.mli +++ b/src/proto_alpha/lib_delegate/baking_files.mli @@ -26,7 +26,7 @@ type _ location val resolve_location : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ([< `Highwatermarks | `Nonce | `State] as 'kind) -> 'kind location diff --git a/src/proto_alpha/lib_delegate/baking_highwatermarks.ml b/src/proto_alpha/lib_delegate/baking_highwatermarks.ml index 91b56b3e50b1..4af172f183fe 100644 --- a/src/proto_alpha/lib_delegate/baking_highwatermarks.ml +++ b/src/proto_alpha/lib_delegate/baking_highwatermarks.ml @@ -100,9 +100,9 @@ let () = (fun highwatermark -> Block_previously_endorsed highwatermark) module DelegateMap = Map.Make (struct - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t - let compare = Signature.Public_key_hash.compare + let compare = Tezos_crypto.Signature.Public_key_hash.compare end) let highwatermark_delegate_map_encoding = @@ -113,7 +113,7 @@ let highwatermark_delegate_map_encoding = fun l -> List.fold_left (fun map (k, v) -> add k v map) empty l) (list (obj2 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "highwatermark" highwatermark_encoding))) type highwatermarks = { diff --git a/src/proto_alpha/lib_delegate/baking_highwatermarks.mli b/src/proto_alpha/lib_delegate/baking_highwatermarks.mli index 757b667c58bb..30d4d6f4ea3e 100644 --- a/src/proto_alpha/lib_delegate/baking_highwatermarks.mli +++ b/src/proto_alpha/lib_delegate/baking_highwatermarks.mli @@ -45,7 +45,7 @@ val load : val may_sign_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -53,7 +53,7 @@ val may_sign_block : val may_sign_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -61,7 +61,7 @@ val may_sign_preendorsement : val may_sign_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -69,7 +69,7 @@ val may_sign_endorsement : val record_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -77,7 +77,7 @@ val record_block : val record_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -85,7 +85,7 @@ val record_preendorsement : val record_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/baking_lib.ml b/src/proto_alpha/lib_delegate/baking_lib.ml index 7ec3ae000cd5..f1b23c4582c1 100644 --- a/src/proto_alpha/lib_delegate/baking_lib.ml +++ b/src/proto_alpha/lib_delegate/baking_lib.ml @@ -268,7 +268,7 @@ let propose_at_next_level ~minimal_timestamp state = "Proposed block at round %a on top of %a " Round.pp block_to_bake.round - Block_hash.pp + Tezos_crypto.Block_hash.pp block_to_bake.predecessor.hash in return state @@ -411,7 +411,7 @@ let bake_using_automaton config state block_stream = let*! () = cctxt#message "Block %a (%ld) injected" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash proposal.block.shell.level in diff --git a/src/proto_alpha/lib_delegate/baking_nonces.ml b/src/proto_alpha/lib_delegate/baking_nonces.ml index e8db5ef6965f..3acc87f16377 100644 --- a/src/proto_alpha/lib_delegate/baking_nonces.ml +++ b/src/proto_alpha/lib_delegate/baking_nonces.ml @@ -33,27 +33,34 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -let empty = Block_hash.Map.empty +let empty = Tezos_crypto.Block_hash.Map.empty let encoding = let open Data_encoding in def "seed_nonce" @@ conv (fun m -> - Block_hash.Map.fold (fun hash nonce acc -> (hash, nonce) :: acc) m []) + Tezos_crypto.Block_hash.Map.fold + (fun hash nonce acc -> (hash, nonce) :: acc) + m + []) (fun l -> List.fold_left - (fun map (hash, nonce) -> Block_hash.Map.add hash nonce map) - Block_hash.Map.empty + (fun map (hash, nonce) -> + Tezos_crypto.Block_hash.Map.add hash nonce map) + Tezos_crypto.Block_hash.Map.empty l) - @@ list (obj2 (req "block" Block_hash.encoding) (req "nonce" Nonce.encoding)) + @@ list + (obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (req "nonce" Nonce.encoding)) let may_migrate (wallet : Protocol_client_context.full) location = let base_dir = wallet#get_base_dir in @@ -78,16 +85,16 @@ let load (wallet : #Client_context.wallet) location = let save (wallet : #Client_context.wallet) location nonces = wallet#write (Baking_files.filename location) nonces encoding -let mem nonces hash = Block_hash.Map.mem hash nonces +let mem nonces hash = Tezos_crypto.Block_hash.Map.mem hash nonces -let find_opt nonces hash = Block_hash.Map.find hash nonces +let find_opt nonces hash = Tezos_crypto.Block_hash.Map.find hash nonces -let add nonces hash nonce = Block_hash.Map.add hash nonce nonces +let add nonces hash nonce = Tezos_crypto.Block_hash.Map.add hash nonce nonces -let remove nonces hash = Block_hash.Map.remove hash nonces +let remove nonces hash = Tezos_crypto.Block_hash.Map.remove hash nonces let remove_all nonces nonces_to_remove = - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash _ acc -> remove acc hash) nonces_to_remove nonces @@ -116,7 +123,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let block_cycle = Int32.(div block_level blocks_per_cycle) in Int32.sub current_cycle block_cycle > Int32.of_int preserved_cycles in - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash nonce acc -> acc >>=? fun (orphans, outdated) -> get_block_level_opt cctxt ~chain ~block:(`Hash (hash, 0)) >>= function @@ -131,7 +138,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let filter_outdated_nonces state nonces = get_outdated_nonces state nonces >>=? fun (orphans, outdated_nonces) -> when_ - (Block_hash.Map.cardinal orphans >= 50) + (Tezos_crypto.Block_hash.Map.cardinal orphans >= 50) (fun () -> Events.( emit too_many_nonces (Baking_files.filename state.nonces_location ^ "s")) @@ -207,7 +214,9 @@ let generate_seed_nonce (nonce_config : Baking_configuration.nonce_config) >>=? fun nonce -> return (Data_encoding.Binary.of_bytes_exn Nonce.encoding nonce) | Random -> ( - match Nonce.of_bytes (Rand.generate Constants.nonce_length) with + match + Nonce.of_bytes (Tezos_crypto.Rand.generate Constants.nonce_length) + with | Error _errs -> assert false | Ok nonce -> return nonce)) >>=? fun nonce -> return (Nonce.hash nonce, nonce) @@ -237,7 +246,9 @@ let inject_seed_nonce_revelation (cctxt : #Protocol_client_context.full) ~chain ~nonce () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Shell_services.Injection.operation ~async:true cctxt ~chain bytes >>=? fun oph -> Events.( @@ -252,8 +263,9 @@ let reveal_potential_nonces state new_proposal = let {cctxt; chain; nonces_location; last_predecessor; _} = state in let new_predecessor_hash = new_proposal.Baking_state.predecessor.hash in if - Block_hash.(last_predecessor <> new_predecessor_hash) - && Protocol_hash.(new_proposal.predecessor.protocol = Protocol.hash) + Tezos_crypto.Block_hash.(last_predecessor <> new_predecessor_hash) + && Tezos_crypto.Protocol_hash.( + new_proposal.predecessor.protocol = Protocol.hash) then ( (* only try revealing nonces when the proposal's predecessor is a new one *) state.last_predecessor <- new_predecessor_hash ; @@ -304,7 +316,7 @@ let start_revelation_worker cctxt config chain_id constants block_stream = constants; config; nonces_location; - last_predecessor = Block_hash.zero; + last_predecessor = Tezos_crypto.Block_hash.zero; } in let rec worker_loop () = diff --git a/src/proto_alpha/lib_delegate/baking_nonces.mli b/src/proto_alpha/lib_delegate/baking_nonces.mli index 6e69b009180d..df34657eb901 100644 --- a/src/proto_alpha/lib_delegate/baking_nonces.mli +++ b/src/proto_alpha/lib_delegate/baking_nonces.mli @@ -32,31 +32,35 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -val empty : Nonce.t Block_hash.Map.t +val empty : Nonce.t Tezos_crypto.Block_hash.Map.t -val encoding : Nonce.t Block_hash.Map.t Data_encoding.t +val encoding : Nonce.t Tezos_crypto.Block_hash.Map.t Data_encoding.t val load : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val save : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> unit tzresult Lwt.t -val mem : Nonce.t Block_hash.Map.t -> Block_hash.t -> bool +val mem : + Nonce.t Tezos_crypto.Block_hash.Map.t -> Tezos_crypto.Block_hash.t -> bool -val find_opt : Nonce.t Block_hash.Map.t -> Block_hash.t -> Nonce.t option +val find_opt : + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Tezos_crypto.Block_hash.t -> + Nonce.t option val get_block_level_opt : #Tezos_rpc.Context.simple -> @@ -66,21 +70,28 @@ val get_block_level_opt : val get_outdated_nonces : t -> - Nonce.t Block_hash.Map.t -> - (Nonce.t Block_hash.Map.t * Nonce.t Block_hash.Map.t) tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Nonce.t Tezos_crypto.Block_hash.Map.t + * Nonce.t Tezos_crypto.Block_hash.Map.t) + tzresult + Lwt.t val filter_outdated_nonces : - t -> Nonce.t Block_hash.Map.t -> Nonce.t Block_hash.Map.t tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val blocks_from_current_cycle : t -> Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t val get_unrevealed_nonces : - t -> Nonce.t Block_hash.Map.t -> (Raw_level.t * Nonce.t) list tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Raw_level.t * Nonce.t) list tzresult Lwt.t val generate_seed_nonce : Baking_configuration.nonce_config -> @@ -90,8 +101,8 @@ val generate_seed_nonce : val register_nonce : #Protocol_client_context.full -> - chain_id:Chain_id.t -> - Block_hash.t -> + chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Block_hash.t -> Nonce.t -> unit tzresult Lwt.t @@ -99,7 +110,7 @@ val inject_seed_nonce_revelation : #Protocol_client_context.full -> chain:Chain_services.chain -> block:Block_services.block -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> (Raw_level.t * Nonce.t) list -> unit tzresult Lwt.t @@ -108,7 +119,7 @@ val reveal_potential_nonces : t -> Baking_state.proposal -> unit tzresult Lwt.t val start_revelation_worker : Protocol_client_context.full -> Baking_configuration.nonce_config -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> Constants.t -> Baking_state.proposal Lwt_stream.t -> Lwt_canceler.t Lwt.t diff --git a/src/proto_alpha/lib_delegate/baking_pow.ml b/src/proto_alpha/lib_delegate/baking_pow.ml index 5637988fb52b..d5d4d4be293b 100644 --- a/src/proto_alpha/lib_delegate/baking_pow.ml +++ b/src/proto_alpha/lib_delegate/baking_pow.ml @@ -59,7 +59,7 @@ let init_proof_of_work_nonce () = (* This was used before November 2018 *) (* (\* Random proof of work *\) * let generate_proof_of_work_nonce () = - * Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) + * Tezos_crypto.Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) let empty_proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '\000' diff --git a/src/proto_alpha/lib_delegate/baking_scheduling.ml b/src/proto_alpha/lib_delegate/baking_scheduling.ml index 38d42a06cc3d..bca851f697d8 100644 --- a/src/proto_alpha/lib_delegate/baking_scheduling.ml +++ b/src/proto_alpha/lib_delegate/baking_scheduling.ml @@ -211,8 +211,10 @@ let compute_next_round_time state = | None -> state.level_state.latest_proposal | Some {proposal; _} -> proposal in - if Protocol_hash.(proposal.predecessor.next_protocol <> Protocol.hash) then - None + if + Tezos_crypto.Protocol_hash.( + proposal.predecessor.next_protocol <> Protocol.hash) + then None else match state.level_state.next_level_proposed_round with | Some _proposed_round -> @@ -630,7 +632,7 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config >>=? fun next_level_delegate_slots -> let elected_block = if - Protocol_hash.( + Tezos_crypto.Protocol_hash.( current_proposal.block.protocol <> Protocol.hash && current_proposal.block.next_protocol = Protocol.hash) then diff --git a/src/proto_alpha/lib_delegate/baking_simulator.ml b/src/proto_alpha/lib_delegate/baking_simulator.ml index 957768d1b412..39b641175d45 100644 --- a/src/proto_alpha/lib_delegate/baking_simulator.ml +++ b/src/proto_alpha/lib_delegate/baking_simulator.ml @@ -94,9 +94,9 @@ let begin_construction ~timestamp ~protocol_data fitness = pred_shell.fitness; timestamp; level = pred_shell.level; - context = Context_hash.zero (* fake context hash *); + context = Tezos_crypto.Context_hash.zero (* fake context hash *); operations_hash = - Operation_list_list_hash.zero (* fake op hash *); + Tezos_crypto.Operation_list_list_hash.zero (* fake op hash *); } in let mode = diff --git a/src/proto_alpha/lib_delegate/baking_simulator.mli b/src/proto_alpha/lib_delegate/baking_simulator.mli index 0d0c7ac9f4d2..d6d45255028e 100644 --- a/src/proto_alpha/lib_delegate/baking_simulator.mli +++ b/src/proto_alpha/lib_delegate/baking_simulator.mli @@ -39,14 +39,14 @@ val load_context : (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : - Abstract_context_index.t -> Context_hash.t -> unit tzresult Lwt.t + Abstract_context_index.t -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t val begin_construction : timestamp:Time.Protocol.t -> protocol_data:block_header_data -> Abstract_context_index.t -> Baking_state.block_info -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> incremental tzresult Lwt.t val add_operation : diff --git a/src/proto_alpha/lib_delegate/baking_state.ml b/src/proto_alpha/lib_delegate/baking_state.ml index 5e87c78b4efd..2902469662c7 100644 --- a/src/proto_alpha/lib_delegate/baking_state.ml +++ b/src/proto_alpha/lib_delegate/baking_state.ml @@ -31,8 +31,8 @@ open Protocol_client_context public key, its public key hash, and its secret key. *) type consensus_key = { alias : string option; - public_key : Signature.Public_key.t; - public_key_hash : Signature.Public_key_hash.t; + public_key : Tezos_crypto.Signature.Public_key.t; + public_key_hash : Tezos_crypto.Signature.Public_key_hash.t; secret_key_uri : Client_keys.sk_uri; } @@ -56,39 +56,48 @@ let consensus_key_encoding = }) (obj4 (req "alias" (option string)) - (req "public_key" Signature.Public_key.encoding) - (req "public_key_hash" Signature.Public_key_hash.encoding) + (req "public_key" Tezos_crypto.Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) let pp_consensus_key fmt {alias; public_key_hash; _} = match alias with - | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp public_key_hash + | None -> + Format.fprintf + fmt + "%a" + Tezos_crypto.Signature.Public_key_hash.pp + public_key_hash | Some alias -> Format.fprintf fmt "%s (%a)" alias - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp public_key_hash -type consensus_key_and_delegate = consensus_key * Signature.Public_key_hash.t +type consensus_key_and_delegate = + consensus_key * Tezos_crypto.Signature.Public_key_hash.t let consensus_key_and_delegate_encoding = let open Data_encoding in merge_objs consensus_key_encoding - (obj1 (req "delegate" Signature.Public_key_hash.encoding)) + (obj1 (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding)) let pp_consensus_key_and_delegate fmt (consensus_key, delegate) = - if Signature.Public_key_hash.equal consensus_key.public_key_hash delegate then - pp_consensus_key fmt consensus_key + if + Tezos_crypto.Signature.Public_key_hash.equal + consensus_key.public_key_hash + delegate + then pp_consensus_key fmt consensus_key else Format.fprintf fmt "%a@,on behalf of %a" pp_consensus_key consensus_key - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate type validation_mode = Node | Local of Abstract_context_index.t @@ -101,17 +110,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; } type cache = { @@ -125,7 +134,7 @@ type global_state = { (* client context *) cctxt : Protocol_client_context.full; (* chain id *) - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; (* baker configuration *) config : Baking_configuration.t; (* protocol constants *) @@ -213,17 +222,17 @@ let block_info_encoding = }) (merge_objs (obj10 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "shell" Block_header.shell_header_encoding) (req "payload_hash" Block_payload_hash.encoding) (req "payload_round" Round.encoding) (req "round" Round.encoding) - (req "protocol" Protocol_hash.encoding) - (req "next_protocol" Protocol_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) + (req "next_protocol" Tezos_crypto.Protocol_hash.encoding) (req "prequorum" (option prequorum_encoding)) (req "quorum" (list (dynamic_size Operation.encoding))) (req "payload" Operation_pool.payload_encoding)) - (obj1 (req "live_blocks" Block_hash.Set.encoding))) + (obj1 (req "live_blocks" Tezos_crypto.Block_hash.Set.encoding))) let round_of_shell_header shell_header = Environment.wrap_tzresult @@ -595,7 +604,7 @@ module DelegateSet = struct type t = consensus_key let compare {public_key_hash = pkh; _} {public_key_hash = pkh'; _} = - Signature.Public_key_hash.compare pkh pkh' + Tezos_crypto.Signature.Public_key_hash.compare pkh pkh' end) let find_pkh pkh s = @@ -603,8 +612,8 @@ module DelegateSet = struct try iter (fun ({public_key_hash; _} as delegate) -> - if Signature.Public_key_hash.equal pkh public_key_hash then - raise (Found delegate) + if Tezos_crypto.Signature.Public_key_hash.equal pkh public_key_hash + then raise (Found delegate) else ()) s ; None @@ -670,7 +679,7 @@ let pp_global_state fmt {chain_id; config; validation_mode; delegates; _} = fmt "@[Global state:@ chain_id: %a@ @[config:@ %a@]@ \ validation_mode: %a@ @[delegates:@ %a@]@]" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id Baking_configuration.pp config @@ -712,16 +721,16 @@ let pp_block_info fmt "@[Block:@ hash: %a@ payload_hash: %a@ level: %ld@ round: %a@ \ protocol: %a@ next protocol: %a@ prequorum: %a@ quorum: %d endorsements@ \ payload: %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash Block_payload_hash.pp_short payload_hash shell.level Round.pp round - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short next_protocol (pp_option pp_prequorum) prequorum @@ -744,7 +753,7 @@ let pp_endorsable_payload fmt {proposal; prequorum} = Format.fprintf fmt "proposal: %a, prequorum: %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash pp_prequorum prequorum @@ -861,7 +870,7 @@ let pp_event fmt = function round %a" (List.length preendos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched @@ -871,7 +880,7 @@ let pp_event fmt = function "quorum reached with %d endorsements (power: %d) for %a at round %a" (List.length endos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched diff --git a/src/proto_alpha/lib_delegate/baking_state.mli b/src/proto_alpha/lib_delegate/baking_state.mli index 3650fc322708..3936193bb346 100644 --- a/src/proto_alpha/lib_delegate/baking_state.mli +++ b/src/proto_alpha/lib_delegate/baking_state.mli @@ -28,8 +28,8 @@ open Alpha_context type consensus_key = { alias : string option; - public_key : Signature.public_key; - public_key_hash : Signature.public_key_hash; + public_key : Tezos_crypto.Signature.public_key; + public_key_hash : Tezos_crypto.Signature.public_key_hash; secret_key_uri : Client_keys.sk_uri; } @@ -37,7 +37,8 @@ val consensus_key_encoding : consensus_key Data_encoding.t val pp_consensus_key : Format.formatter -> consensus_key -> unit -type consensus_key_and_delegate = consensus_key * Signature.Public_key_hash.t +type consensus_key_and_delegate = + consensus_key * Tezos_crypto.Signature.Public_key_hash.t val consensus_key_and_delegate_encoding : consensus_key_and_delegate Data_encoding.t @@ -55,17 +56,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; (** Set of live blocks for this block that is used to filter old or too recent operations. *) } @@ -79,7 +80,7 @@ type cache = { type global_state = { cctxt : Protocol_client_context.full; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; config : Baking_configuration.t; constants : Constants.t; round_durations : Round.round_durations; diff --git a/src/proto_alpha/lib_delegate/baking_vdf.ml b/src/proto_alpha/lib_delegate/baking_vdf.ml index b08fd5ebea7b..6dc6d5e9abb1 100644 --- a/src/proto_alpha/lib_delegate/baking_vdf.ml +++ b/src/proto_alpha/lib_delegate/baking_vdf.ml @@ -156,7 +156,7 @@ let inject_vdf_revelation cctxt hash chain_id solution = ~solution () in - let bytes = Signature.concat bytes Signature.zero in + let bytes = Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero in Shell_services.Injection.operation cctxt ~chain bytes (* Checks if the VDF setup saved in the state is equal to the one computed @@ -182,7 +182,7 @@ let process_new_block (cctxt : #Protocol_client_context.full) state let* level_info = get_level_info cctxt level in let level_str = Int32.to_string (Raw_level.to_int32 level) in let* () = check_new_cycle state level_info in - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then let*! () = D_Events.(emit protocol_change_detected) () in return_unit else diff --git a/src/proto_alpha/lib_delegate/block_forge.ml b/src/proto_alpha/lib_delegate/block_forge.ml index 82ca809b9136..73fc1bcfa3e3 100644 --- a/src/proto_alpha/lib_delegate/block_forge.ml +++ b/src/proto_alpha/lib_delegate/block_forge.ml @@ -52,7 +52,7 @@ let forge_faked_protocol_data ?(payload_hash = Block_payload_hash.zero) proof_of_work_nonce = Baking_pow.empty_proof_of_work_nonce; liquidity_baking_toggle_vote; }; - signature = Signature.zero; + signature = Tezos_crypto.Signature.zero; } let convert_operation (op : packed_operation) : Tezos_base.Operation.t = @@ -112,7 +112,7 @@ let finalize_block_header shell_header timestamp validation_result let retain_live_operations_only ~live_blocks operation_pool = Operation_pool.Prioritized.filter (fun ({shell; _} : packed_operation) -> - Block_hash.Set.mem shell.branch live_blocks) + Tezos_crypto.Block_hash.Set.mem shell.branch live_blocks) operation_pool let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info @@ -136,7 +136,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info | None -> next_protocol | Some hash -> hash in - return Protocol_hash.(Protocol.hash <> next_protocol) + return Tezos_crypto.Protocol_hash.(Protocol.hash <> next_protocol) in let filter_via_node ~operation_pool = let filtered_operations = @@ -295,10 +295,11 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info >>=? fun (incremental, ordered_pool) -> let operations = Operation_pool.ordered_to_list_list ordered_pool in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in (* We need to compute the final [operations_hash] before @@ -382,7 +383,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let unsigned_block_header = { Block_header.shell = shell_header; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in return {unsigned_block_header; operations} diff --git a/src/proto_alpha/lib_delegate/block_forge.mli b/src/proto_alpha/lib_delegate/block_forge.mli index b111e27b417c..abf60c86d8f4 100644 --- a/src/proto_alpha/lib_delegate/block_forge.mli +++ b/src/proto_alpha/lib_delegate/block_forge.mli @@ -50,7 +50,7 @@ val forge_faked_protocol_data : val forge : #Protocol_client_context.full -> - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> pred_info:Baking_state.block_info -> timestamp:Time.Protocol.t -> liquidity_baking_toggle_vote:Liquidity_baking.liquidity_baking_toggle_vote -> diff --git a/src/proto_alpha/lib_delegate/client_baking_blocks.ml b/src/proto_alpha/lib_delegate/client_baking_blocks.ml index d7064545b7bd..e192aa649a72 100644 --- a/src/proto_alpha/lib_delegate/client_baking_blocks.ml +++ b/src/proto_alpha/lib_delegate/client_baking_blocks.ml @@ -28,16 +28,16 @@ open Alpha_context open Protocol_client_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } let raw_info cctxt ?(chain = `Main) hash shell_header = @@ -80,9 +80,9 @@ let info cctxt ?(chain = `Main) block = module Block_seen_event = struct type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Tezos_base.Block_header.t; - occurrence : [`Valid_blocks of Chain_id.t | `Heads]; + occurrence : [`Valid_blocks of Tezos_crypto.Chain_id.t | `Heads]; } let make hash header occurrence = {hash; header; occurrence} @@ -101,7 +101,7 @@ module Block_seen_event = struct (function {hash; header; occurrence} -> (hash, occurrence, header)) (fun (hash, occurrence, header) -> make hash header occurrence) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (* Occurrence has to come before header, because: (Invalid_argument "Cannot merge two objects when the left element is of @@ -123,7 +123,7 @@ module Block_seen_event = struct (Tag 1) (obj2 (req "occurrence-kind" (constant "valid-blocks")) - (req "chain-id" Chain_id.encoding)) + (req "chain-id" Tezos_crypto.Chain_id.encoding)) (function | `Valid_blocks ch -> Some ((), ch) | _ -> None) (fun ((), ch) -> `Valid_blocks ch); @@ -133,7 +133,7 @@ module Block_seen_event = struct With_version.(encoding ~name (first_version v0_encoding)) let pp ~short:_ ppf {hash; _} = - Format.fprintf ppf "Saw block %a" Block_hash.pp_short hash + Format.fprintf ppf "Saw block %a" Tezos_crypto.Block_hash.pp_short hash let doc = "Block observed while monitoring a blockchain." @@ -173,7 +173,7 @@ let monitor_heads cctxt ~next_protocols chain = type error += | Unexpected_empty_block_list of { chain : string; - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; length : int; } @@ -190,13 +190,13 @@ let () = "Unexpected empty block list retrieved from chain %s at block %a, \ length %d" chain - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash length) Data_encoding.( obj3 (req "chain" string) - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "length" int31)) (function | Unexpected_empty_block_list {chain; block_hash; length} -> diff --git a/src/proto_alpha/lib_delegate/client_baking_blocks.mli b/src/proto_alpha/lib_delegate/client_baking_blocks.mli index c3358f61f82f..07d582b6ed9b 100644 --- a/src/proto_alpha/lib_delegate/client_baking_blocks.mli +++ b/src/proto_alpha/lib_delegate/client_baking_blocks.mli @@ -27,16 +27,16 @@ open Protocol open Alpha_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } val info : @@ -48,14 +48,14 @@ val info : val monitor_valid_blocks : #Protocol_client_context.rpc_context -> ?chains:Chain_services.chain list -> - ?protocols:Protocol_hash.t list -> - next_protocols:Protocol_hash.t list option -> + ?protocols:Tezos_crypto.Protocol_hash.t list -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> unit -> (block_info tzresult Lwt_stream.t * Tezos_rpc.Context.stopper) tzresult Lwt.t val monitor_heads : #Protocol_client_context.rpc_context -> - next_protocols:Protocol_hash.t list option -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> Chain_services.chain -> block_info tzresult Lwt_stream.t tzresult Lwt.t @@ -65,4 +65,4 @@ val blocks_from_current_cycle : Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t diff --git a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml index 2ebc4af5961e..21b58428d339 100644 --- a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml @@ -31,16 +31,16 @@ module Events = Delegate_events.Denunciator module B_Events = Delegate_events.Baking_scheduling module HLevel = Hashtbl.Make (struct - type t = Chain_id.t * Raw_level.t * Round.t + type t = Tezos_crypto.Chain_id.t * Raw_level.t * Round.t let equal (c, l, r) (c', l', r') = - Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' + Tezos_crypto.Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' let hash (c, lvl, r) = Hashtbl.hash (c, lvl, r) end) (* Blocks are associated to the delegates who baked them *) -module Delegate_Map = Map.Make (Signature.Public_key_hash) +module Delegate_Map = Map.Make (Tezos_crypto.Signature.Public_key_hash) (* (pre)endorsements are associated to the slot they are injected with; we rely on the fact that there is a unique canonical slot @@ -49,7 +49,8 @@ module Slot_Map = Slot.Map (* type of operations stream, as returned by monitor_operations RPC *) type ops_stream = - ((Operation_hash.t * packed_operation) * error trace option) list Lwt_stream.t + ((Tezos_crypto.Operation_hash.t * packed_operation) * error trace option) list + Lwt_stream.t type 'a state = { (* Endorsements seen so far *) @@ -57,7 +58,7 @@ type 'a state = { (* Preendorsements seen so far *) preendorsements_table : Kind.preendorsement operation Slot_Map.t HLevel.t; (* Blocks received so far *) - blocks_table : Block_hash.t Delegate_Map.t HLevel.t; + blocks_table : Tezos_crypto.Block_hash.t Delegate_Map.t HLevel.t; (* Maximum delta of level to register *) preserved_levels : int; (* Highest level seen in a block *) @@ -126,7 +127,7 @@ let double_consensus_op_evidence (type kind) : kind consensus_operation_type -> #Protocol_client_context.full -> 'a -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> op1:kind Alpha_context.operation -> op2:kind Alpha_context.operation -> unit -> @@ -159,7 +160,7 @@ let process_consensus_op (type kind) cctxt (Operation.hash new_op, Operation.hash existing_op) in let op1, op2 = - if Operation_hash.(new_op_hash < existing_op_hash) then + if Tezos_crypto.Operation_hash.(new_op_hash < existing_op_hash) then (new_op, existing_op) else (existing_op, new_op) in @@ -175,7 +176,9 @@ let process_consensus_op (type kind) cctxt ~op2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in let double_op_detected, double_op_denounced = Events.( match op_kind with @@ -271,7 +274,8 @@ let process_block (cctxt : #Protocol_client_context.full) state state.blocks_table (chain_id, level, round) (Delegate_Map.add baker.delegate new_hash map) - | Some existing_hash when Block_hash.(existing_hash = new_hash) -> + | Some existing_hash + when Tezos_crypto.Block_hash.(existing_hash = new_hash) -> (* This case should never happen *) Events.(emit double_baking_but_not) () >>= fun () -> return @@ -287,7 +291,8 @@ let process_block (cctxt : #Protocol_client_context.full) state let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in let bh1, bh2 = - if Block_hash.(hash1 < hash2) then (bh1, bh2) else (bh2, bh1) + if Tezos_crypto.Block_hash.(hash1 < hash2) then (bh1, bh2) + else (bh2, bh1) in (* If the blocks are on different chains then skip it *) get_block_offset level >>= fun block -> @@ -301,7 +306,9 @@ let process_block (cctxt : #Protocol_client_context.full) state ~bh2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Events.(emit double_baking_detected) () >>= fun () -> Shell_services.Injection.operation cctxt ~chain bytes >>=? fun op_hash -> @@ -346,7 +353,7 @@ let cleanup_old_operations state = *) let process_new_block (cctxt : #Protocol_client_context.full) state {hash; chain_id; level; protocol; next_protocol; _} = - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then Events.(emit protocol_change_detected) () >>= fun () -> return_unit else Events.(emit accuser_saw_block) (level, hash) >>= fun () -> diff --git a/src/proto_alpha/lib_delegate/client_daemon.ml b/src/proto_alpha/lib_delegate/client_daemon.ml index ba2cfdac03b3..836c95f1ad9a 100644 --- a/src/proto_alpha/lib_delegate/client_daemon.ml +++ b/src/proto_alpha/lib_delegate/client_daemon.ml @@ -91,7 +91,7 @@ module Baker = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> let canceler = Lwt_canceler.create () in @@ -121,7 +121,7 @@ module Accuser = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> Client_baking_blocks.monitor_valid_blocks @@ -159,7 +159,7 @@ module VDF = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash in let* chain_id = Shell_services.Chain.chain_id cctxt ~chain () in diff --git a/src/proto_alpha/lib_delegate/delegate_events.ml b/src/proto_alpha/lib_delegate/delegate_events.ml index 20f5d091dd9c..ca4361b2dc96 100644 --- a/src/proto_alpha/lib_delegate/delegate_events.ml +++ b/src/proto_alpha/lib_delegate/delegate_events.ml @@ -50,8 +50,8 @@ module Denunciator = struct ~level ~name:"double_endorsement_detected" ~msg:"double endorsement detected" - ("existing_endorsement", Operation_hash.encoding) - ("new_endorsement", Operation_hash.encoding) + ("existing_endorsement", Tezos_crypto.Operation_hash.encoding) + ("new_endorsement", Tezos_crypto.Operation_hash.encoding) let double_endorsement_denounced = declare_2 @@ -59,7 +59,7 @@ module Denunciator = struct ~level ~name:"double_endorsement_denounced" ~msg:"double endorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -69,8 +69,8 @@ module Denunciator = struct ~level ~name:"double_preendorsement_detected" ~msg:"double preendorsement detected" - ("existing_preendorsement", Operation_hash.encoding) - ("new_preendorsement", Operation_hash.encoding) + ("existing_preendorsement", Tezos_crypto.Operation_hash.encoding) + ("new_preendorsement", Tezos_crypto.Operation_hash.encoding) let double_preendorsement_denounced = declare_2 @@ -78,7 +78,7 @@ module Denunciator = struct ~level ~name:"double_preendorsement_denounced" ~msg:"double preendorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -88,7 +88,7 @@ module Denunciator = struct ~level:Error ~name:"inconsistent_endorsement" ~msg:"inconsistent endorsement found {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) let unexpected_pruned_block = declare_1 @@ -96,7 +96,7 @@ module Denunciator = struct ~level:Error ~name:"unexpected_pruned_block" ~msg:"unexpected pruned block: {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let double_baking_but_not = declare_0 @@ -120,7 +120,7 @@ module Denunciator = struct ~level ~name:"double_baking_denounced" ~msg:"double baking evidence injected {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -139,7 +139,7 @@ module Denunciator = struct ~name:"accuser_saw_block" ~msg:"block level: {level}" ("level", Alpha_context.Raw_level.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetch_operations_error = declare_1 @@ -147,8 +147,8 @@ module Denunciator = struct ~level:Error ~name:"fetch_operations_error" ~msg:"error while fetching operations of block {hash}" - ("hash", Block_hash.encoding) - ~pp1:Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp let accuser_processed_block = declare_1 @@ -156,7 +156,7 @@ module Denunciator = struct ~level ~name:"accuser_processed_block" ~msg:"block {hash} registered" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let accuser_block_error = declare_2 @@ -165,7 +165,7 @@ module Denunciator = struct ~name:"accuser_block_error" ~msg:"error while processing block {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) end diff --git a/src/proto_alpha/lib_delegate/logging.ml b/src/proto_alpha/lib_delegate/logging.ml index ed9cb18c9db3..6756e73e07e6 100644 --- a/src/proto_alpha/lib_delegate/logging.ml +++ b/src/proto_alpha/lib_delegate/logging.ml @@ -147,9 +147,9 @@ let conflicting_endorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) let conflicting_preendorsements_tag = @@ -161,7 +161,7 @@ let conflicting_preendorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) diff --git a/src/proto_alpha/lib_delegate/node_rpc.ml b/src/proto_alpha/lib_delegate/node_rpc.ml index badb4fc204d4..96749ae7c4de 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.ml +++ b/src/proto_alpha/lib_delegate/node_rpc.ml @@ -70,7 +70,9 @@ let raw_info cctxt ~chain ~block_hash shell payload_hash payload_round >>= fun () -> let open Protocol_client_context in let block = `Hash (block_hash, 0) in - let is_in_protocol = Protocol_hash.(current_protocol = Protocol.hash) in + let is_in_protocol = + Tezos_crypto.Protocol_hash.(current_protocol = Protocol.hash) + in (if is_in_protocol then Alpha_block_services.Operations.operations cctxt ~chain ~block () >>=? fun operations -> @@ -121,7 +123,7 @@ let info cctxt ~chain ~block () = (* Fails if the block's protocol is not the current one *) Shell_services.Blocks.protocols cctxt ~chain ~block () >>=? fun {current_protocol; next_protocol} -> - (if Protocol_hash.(current_protocol <> Protocol.hash) then + (if Tezos_crypto.Protocol_hash.(current_protocol <> Protocol.hash) then Block_services.Header.shell_header cctxt ~chain ~block () >>=? fun shell -> Chain_services.Blocks.Header.raw_protocol_data cctxt ~chain ~block () >>=? fun protocol_data -> @@ -155,7 +157,7 @@ let info cctxt ~chain ~block () = (Chain_services.Blocks.live_blocks cctxt ~chain ~block () >>= function | Error _ -> (* The RPC might fail when a block's metadata is not available *) - Lwt.return Block_hash.Set.empty + Lwt.return Tezos_crypto.Block_hash.Set.empty | Ok live_blocks -> Lwt.return live_blocks) >>= fun live_blocks -> raw_info diff --git a/src/proto_alpha/lib_delegate/node_rpc.mli b/src/proto_alpha/lib_delegate/node_rpc.mli index 2dd0468ef6f1..55694e129b55 100644 --- a/src/proto_alpha/lib_delegate/node_rpc.mli +++ b/src/proto_alpha/lib_delegate/node_rpc.mli @@ -37,13 +37,13 @@ val inject_block : chain:Shell_services.chain -> Block_header.t -> Tezos_base.Operation.t list list -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t (** Preapply a block using the node validation mechanism.*) val preapply_block : #Protocol_client_context.full -> chain:Shell_services.chain -> - head:Block_hash.t -> + head:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> protocol_data:Protocol.block_header_data -> packed_operation list list -> @@ -58,7 +58,7 @@ val proposal : #Tezos_rpc.Context.simple -> ?cache:Baking_state.block_info Baking_cache.Block_cache.t -> chain:Shell_services.chain -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Baking_state.proposal tzresult Lwt.t (** Monitor proposals from the node.*) diff --git a/src/proto_alpha/lib_delegate/operation_pool.ml b/src/proto_alpha/lib_delegate/operation_pool.ml index 7e0a7612054e..16ec9eda7cdb 100644 --- a/src/proto_alpha/lib_delegate/operation_pool.ml +++ b/src/proto_alpha/lib_delegate/operation_pool.ml @@ -41,7 +41,7 @@ let compare_op op1 op2 = (* FIXME some operations (e.g. tx_rollup_rejection) pack functional values which could raise an exception. In this specific case, we default to comparing their hashes. *) - Operation_hash.compare + Tezos_crypto.Operation_hash.compare (Alpha_context.Operation.hash_packed op1) (Alpha_context.Operation.hash_packed op2) diff --git a/src/proto_alpha/lib_delegate/operation_selection.ml b/src/proto_alpha/lib_delegate/operation_selection.ml index 9a4fbf4d0b92..83543149b056 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.ml +++ b/src/proto_alpha/lib_delegate/operation_selection.ml @@ -57,7 +57,9 @@ module PrioritizedManagerSet = Set.Make (struct let compare {source; counter; weight; op; _} {source = source'; counter = counter'; weight = weight'; op = op'; _} = (* Be careful with the [compare] *) - let cmp_src = Signature.Public_key_hash.compare source source' in + let cmp_src = + Tezos_crypto.Signature.Public_key_hash.compare source source' + in if cmp_src = 0 then (* we want the smallest counter first *) let c = Manager_counter.compare counter counter' in @@ -163,7 +165,7 @@ type simulation_result = { validation_result : Tezos_protocol_environment.validation_result; block_header_metadata : block_header_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } let validate_operation inc op = @@ -248,10 +250,11 @@ let filter_operations_with_simulation initial_inc fees_config >>= fun (inc, managers) -> let operations = [consensus; votes; anonymous; managers] in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in let inc = {inc with header = {inc.header with operations_hash}} in diff --git a/src/proto_alpha/lib_delegate/operation_selection.mli b/src/proto_alpha/lib_delegate/operation_selection.mli index 78caab5c158c..3ab72a91347c 100644 --- a/src/proto_alpha/lib_delegate/operation_selection.mli +++ b/src/proto_alpha/lib_delegate/operation_selection.mli @@ -31,7 +31,7 @@ type simulation_result = { validation_result : validation_result; block_header_metadata : Apply_results.block_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } val filter_operations_with_simulation : diff --git a/src/proto_alpha/lib_delegate/operation_worker.ml b/src/proto_alpha/lib_delegate/operation_worker.ml index 66cec5723476..5589f585649f 100644 --- a/src/proto_alpha/lib_delegate/operation_worker.ml +++ b/src/proto_alpha/lib_delegate/operation_worker.ml @@ -145,7 +145,7 @@ module Events = struct end type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } @@ -158,7 +158,7 @@ let candidate_encoding = (fun (hash, round_watched, payload_hash_watched) -> {hash; round_watched; payload_hash_watched}) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "round_watched" Round.encoding) (req "payload_hash_watched" Block_payload_hash.encoding)) @@ -539,7 +539,8 @@ let retrieve_pending_operations cctxt state = state.operation_pool (List.rev_map (fun (_, (op, _)) -> op) - (Operation_hash.Map.bindings pending_mempool.branch_delayed)) ; + (Tezos_crypto.Operation_hash.Map.bindings + pending_mempool.branch_delayed)) ; return_unit let get_current_operations state = state.operation_pool diff --git a/src/proto_alpha/lib_delegate/operation_worker.mli b/src/proto_alpha/lib_delegate/operation_worker.mli index eecbc990f2d1..ab66270bfd91 100644 --- a/src/proto_alpha/lib_delegate/operation_worker.mli +++ b/src/proto_alpha/lib_delegate/operation_worker.mli @@ -34,7 +34,7 @@ open Alpha_context type t type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } diff --git a/src/proto_alpha/lib_delegate/state_transitions.ml b/src/proto_alpha/lib_delegate/state_transitions.ml index 6e8dd27e6284..71c79251fe67 100644 --- a/src/proto_alpha/lib_delegate/state_transitions.ml +++ b/src/proto_alpha/lib_delegate/state_transitions.ml @@ -47,8 +47,9 @@ let is_acceptable_proposal_for_current_level state let previous_proposal = state.level_state.latest_proposal in if Round.(proposal.block.round = previous_proposal.block.round) - && Block_hash.(proposal.block.hash <> previous_proposal.block.hash) - && Block_hash.( + && Tezos_crypto.Block_hash.( + proposal.block.hash <> previous_proposal.block.hash) + && Tezos_crypto.Block_hash.( proposal.predecessor.hash = previous_proposal.predecessor.hash) then (* An existing proposal was found at the same round: the @@ -117,7 +118,9 @@ let may_update_proposal state (proposal : proposal) = else Lwt.return state let preendorse state proposal = - if Protocol_hash.(proposal.block.protocol <> proposal.block.next_protocol) + if + Tezos_crypto.Protocol_hash.( + proposal.block.protocol <> proposal.block.next_protocol) then (* We do not preendorse the first transition block *) let new_round_state = {state.round_state with current_phase = Idle} in @@ -200,7 +203,7 @@ let rec handle_new_proposal state (new_proposal : proposal) = let's check if it's a valid one for us. *) let current_proposal = state.level_state.latest_proposal in if - Block_hash.( + Tezos_crypto.Block_hash.( current_proposal.predecessor.hash <> new_proposal.predecessor.hash) then Events.( @@ -534,7 +537,8 @@ let end_of_round state current_round = do_nothing new_state | Some (delegate, _) -> let last_proposal = state.level_state.latest_proposal.block in - if Protocol_hash.(last_proposal.protocol <> Protocol.hash) then + if Tezos_crypto.Protocol_hash.(last_proposal.protocol <> Protocol.hash) + then (* Do not inject a block for the previous protocol! (Let the baker of the previous protocol do it.) *) do_nothing new_state @@ -606,7 +610,9 @@ let make_endorse_action state proposal = let prequorum_reached_when_awaiting_preendorsements state candidate preendorsements = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit @@ -646,7 +652,9 @@ let prequorum_reached_when_awaiting_preendorsements state candidate let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_client_context.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_client_context.ml index ededa688a755..cc090580cdb0 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_client_context.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/faked_client_context.ml @@ -46,8 +46,8 @@ let log _channel msg = print_endline msg ; Lwt.return_unit -class faked_ctxt (hooks : Faked_services.hooks) (chain_id : Chain_id.t) : - Tezos_rpc.Context.generic = +class faked_ctxt (hooks : Faked_services.hooks) + (chain_id : Tezos_crypto.Chain_id.t) : Tezos_rpc.Context.generic = let local_ctxt = let module Services = Faked_services.Make ((val hooks)) in Tezos_mockup_proxy.RPC_client.local_ctxt (Services.directory chain_id) 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 907d280256fc..ee21b96b07c2 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 @@ -10,7 +10,7 @@ module type Mocked_services_hooks = sig (** The baker and endorser rely on this stream to be notified of new blocks. *) val monitor_heads : - unit -> (Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream + unit -> (Tezos_crypto.Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream (** Returns current and next protocol for a block. *) val protocols : @@ -30,14 +30,15 @@ module type Mocked_services_hooks = sig [Tezos_shell_services.Injection_services.S.block], after checking that the block header can be deserialized. *) val inject_block : - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t (** [inject_operation] is used by the endorser (or the client) to inject operations, including endorsements. *) - val inject_operation : Operation.t -> Operation_hash.t tzresult Lwt.t + val inject_operation : + Operation.t -> Tezos_crypto.Operation_hash.t tzresult Lwt.t (** [pending_operations] returns the current contents of the mempool. It is used by the baker to fetch operations to potentially include in the @@ -54,7 +55,9 @@ module type Mocked_services_hooks = sig branch_delayed:bool -> branch_refused:bool -> refused:bool -> - ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list + ((Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) + * error trace option) + list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -62,15 +65,16 @@ module type Mocked_services_hooks = sig chain. Optional arguments allow to return the list of predecessors of a given block or of a set of blocks. *) val list_blocks : - heads:Block_hash.t list -> + heads:Tezos_crypto.Block_hash.t list -> length:int option -> min_date:Time.Protocol.t option -> - Block_hash.t list list tzresult Lwt.t + Tezos_crypto.Block_hash.t list list tzresult Lwt.t (** List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block. *) - val live_blocks : Block_services.block -> Block_hash.Set.t tzresult Lwt.t + val live_blocks : + Block_services.block -> Tezos_crypto.Block_hash.Set.t tzresult Lwt.t (** [rpc_context_callback] is used in the implementations of several RPCs (see local_services.ml). It should correspond to the @@ -87,7 +91,7 @@ module type Mocked_services_hooks = sig to all nodes. *) val broadcast_block : ?dests:int list -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t @@ -102,7 +106,8 @@ module type Mocked_services_hooks = sig simulated node is already bootstrapped, returns the current head immediately. *) val monitor_bootstrapped : - unit -> (Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream + unit -> + (Tezos_crypto.Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream end type hooks = (module Mocked_services_hooks) @@ -183,7 +188,7 @@ module Make (Hooks : Mocked_services_hooks) = struct match Block_header.of_bytes bytes with | None -> failwith "faked_services.inject_block: can't deserialize" | Some block_header -> - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in Hooks.inject_block block_hash block_header operations >>=? fun () -> return block_hash) @@ -202,7 +207,7 @@ module Make (Hooks : Mocked_services_hooks) = struct Broadcast_services.S.block (fun () dests (block_header, operations) -> let bytes = Block_header.to_bytes block_header in - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in let dests = match dests#dests with [] -> None | dests -> Some dests in Hooks.broadcast_block ?dests block_hash block_header operations) 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 95efc1b159d5..65c8ad1d7c6c 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 @@ -35,8 +35,10 @@ type chain = block list (** As new blocks and operations are received they are pushed to an Lwt_pipe wrapped into this type. *) type broadcast = - | Broadcast_block of Block_hash.t * Block_header.t * Operation.t list list - | Broadcast_op of Operation_hash.t * Alpha_context.packed_operation + | Broadcast_block of + Tezos_crypto.Block_hash.t * Block_header.t * Operation.t list list + | Broadcast_op of + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation (** The state of a mockup node. *) type state = { @@ -46,29 +48,33 @@ type state = { live_depth : int; (** How many blocks (counting from the head into the past) are considered live? *) mutable chain : chain; (** The chain as seen by this fake "node". *) - mutable mempool : (Operation_hash.t * Mockup.M.Protocol.operation) list; + mutable mempool : + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list; (** Mempool of this fake "node". *) - chain_table : chain Block_hash.Table.t; + chain_table : chain Tezos_crypto.Block_hash.Table.t; (** The chain table of this fake "node". It maps from block hashes to blocks. *) - global_chain_table : block Block_hash.Table.t; + global_chain_table : block Tezos_crypto.Block_hash.Table.t; (** The global chain table that allows us to look up blocks that may be missing in [chain_table], i.e. not known to this particular node. This 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 : Tezos_protocol_environment.rpc_context Context_hash.Table.t; + ctxt_table : + Tezos_protocol_environment.rpc_context Tezos_crypto.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 : + (Tezos_crypto.Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) operations_pipe : - (Operation_hash.t * Mockup.M.Protocol.operation) option Lwt_pipe.Unbounded.t; + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) option + Lwt_pipe.Unbounded.t; (** [operations_pipe] is used to implement the [operations_pipe] RPC. *) mutable streaming_operations : bool; (** A helper flag used to implement the monitor operations RPC. *) broadcast_pipes : broadcast Lwt_pipe.Unbounded.t list; (** Broadcast pipes per node. *) - genesis_block_true_hash : Block_hash.t; + genesis_block_true_hash : Tezos_crypto.Block_hash.t; (** True hash of the genesis block as calculated by the [Block_header.hash] function. *) @@ -76,13 +82,13 @@ type state = { let accounts = Mockup.Protocol_parameters.default_value.bootstrap_accounts -let chain_id = Chain_id.of_string_exn "main" +let chain_id = Tezos_crypto.Chain_id.of_string_exn "main" let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" -let genesis_predecessor_block_hash = Block_hash.zero +let genesis_predecessor_block_hash = Tezos_crypto.Block_hash.zero type propagation = Block | Pass | Delay of float @@ -92,34 +98,40 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -128,7 +140,7 @@ module type Hooks = sig level:int32 -> round:int32 -> chain:chain -> unit tzresult Lwt.t val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t val stop_on_event : Baking_state.event -> bool @@ -149,9 +161,12 @@ let locate_blocks (state : state) block list tzresult Lwt.t = match block with | `Hash (hash, rel) -> ( - match Block_hash.Table.find state.chain_table hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table hash with | None -> - failwith "locate_blocks: can't find the block %a" Block_hash.pp hash + failwith + "locate_blocks: can't find the block %a" + Tezos_crypto.Block_hash.pp + hash | Some chain0 -> let _, chain = List.split_n rel chain0 in return chain) @@ -177,8 +192,8 @@ let live_blocks (state : state) block = (List.fold_left (fun set ({rpc_context; _} : block) -> 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) + Tezos_crypto.Block_hash.Set.add hash set) + (Tezos_crypto.Block_hash.Set.singleton state.genesis_block_true_hash) segment) (** Extract the round number from raw fitness. *) @@ -272,25 +287,27 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : match block with | `Hash (requested_hash, rel) -> Int.equal rel 0 - && Block_hash.equal requested_hash genesis_predecessor_block_hash + && Tezos_crypto.Block_hash.equal + requested_hash + genesis_predecessor_block_hash | _ -> false in (* It is important to tell the baker that the genesis block is not in - the alpha protocol (we use Protocol_hash.zero). This will make the + the alpha protocol (we use Tezos_crypto.Protocol_hash.zero). This will make the baker not try to propose alternatives to that block and just accept - it as final in that Protocol_hash.zero protocol. The same for - predecessor of genesis, it should be in Protocol_hash.zero. *) + it as final in that Tezos_crypto.Protocol_hash.zero protocol. The same for + predecessor of genesis, it should be in Tezos_crypto.Protocol_hash.zero. *) return Tezos_shell_services.Block_services. { current_protocol = (if - Block_hash.equal hash genesis_block_hash + Tezos_crypto.Block_hash.equal hash genesis_block_hash || is_predecessor_of_genesis - then Protocol_hash.zero + then Tezos_crypto.Protocol_hash.zero else Protocol.hash); next_protocol = - (if is_predecessor_of_genesis then Protocol_hash.zero + (if is_predecessor_of_genesis then Tezos_crypto.Protocol_hash.zero else Protocol.hash); } @@ -387,11 +404,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : Mockup.M.Block_services.Mempool. { applied = ops; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; - unprocessed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; + unprocessed = Tezos_crypto.Operation_hash.Map.empty; } let monitor_operations ~applied ~branch_delayed ~branch_refused ~refused = @@ -471,11 +488,12 @@ let clear_mempool state = (fun (_oph, (op : Mockup.M.Protocol.operation)) -> let included_in_head = List.mem - ~equal:Operation_hash.equal + ~equal:Tezos_crypto.Operation_hash.equal (Alpha_context.Operation.hash_packed op) included_ops_hashes in - Block_hash.Set.mem op.shell.branch live_set && not included_in_head) + Tezos_crypto.Block_hash.Set.mem op.shell.branch live_set + && not included_in_head) state.mempool in state.mempool <- mempool ; @@ -549,13 +567,17 @@ let rec process_block state block_hash (block_header : Block_header.t) let get_predecessor () = let predecessor_hash = block_header.Block_header.shell.predecessor in head state >>=? fun head -> - match Block_hash.Table.find state.chain_table predecessor_hash with + match + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash + with | None | Some [] -> ( (* Even if the predecessor is not known locally, it might be known by some node in the network. The code below "requests" information about the block by its hash. *) match - Block_hash.Table.find state.global_chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find + state.global_chain_table + predecessor_hash with | None -> failwith "get_predecessor: unknown predecessor block" | Some predecessor -> @@ -598,7 +620,7 @@ let rec process_block state block_hash (block_header : Block_header.t) then return predecessor else failwith "get_predecessor: the predecessor block is too old" in - match Block_hash.Table.find state.chain_table block_hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table block_hash with | Some _ -> (* The block is already known. *) return_unit @@ -616,7 +638,7 @@ let rec process_block state block_hash (block_header : Block_header.t) (fun pass -> List.map (fun (Operation.{shell; proto} as op) -> - let hash : Operation_hash.t = Operation.hash op in + let hash : Tezos_crypto.Operation_hash.t = Operation.hash op in let protocol_data : Alpha_context.packed_protocol_data = Data_encoding.Binary.of_bytes_exn Protocol.operation_data_encoding @@ -643,13 +665,19 @@ let rec process_block state block_hash (block_header : Block_header.t) in let predecessor_hash = block_header.Block_header.shell.predecessor in let tail = - Block_hash.Table.find state.chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash |> WithExceptions.Option.get ~loc:__LOC__ in let new_chain = new_block :: tail in - Block_hash.Table.replace state.chain_table block_hash new_chain ; - Block_hash.Table.replace state.global_chain_table block_hash new_block ; - Context_hash.Table.replace + Tezos_crypto.Block_hash.Table.replace + state.chain_table + block_hash + new_chain ; + Tezos_crypto.Block_hash.Table.replace + state.global_chain_table + block_hash + new_block ; + Tezos_crypto.Context_hash.Table.replace state.ctxt_table rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; @@ -738,7 +766,7 @@ let create_fake_node_state ~i ~live_depth mempool = []; chain = chain0; chain_table = - Block_hash.Table.of_seq + Tezos_crypto.Block_hash.Table.of_seq (List.to_seq [ (rpc_context0.block_hash, chain0); @@ -747,7 +775,7 @@ let create_fake_node_state ~i ~live_depth ]); global_chain_table; ctxt_table = - Context_hash.Table.of_seq + Tezos_crypto.Context_hash.Table.of_seq (List.to_seq [ ( rpc_context0.Tezos_protocol_environment.block_header @@ -807,7 +835,7 @@ let baker_process ~(delegates : Baking_state.consensus_key list) ~base_dir { checkout_fun = (fun hash -> - Context_hash.Table.find state.ctxt_table hash + Tezos_crypto.Context_hash.Table.find state.ctxt_table hash |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; @@ -827,9 +855,9 @@ let baker_process ~(delegates : Baking_state.consensus_key list) ~base_dir Lwt.pick [listener_process (); baker_process ()] >>=? fun () -> User_hooks.check_chain_on_success ~chain:state.chain -let genesis_protocol_data (baker_sk : Signature.secret_key) - (predecessor_hash : Block_hash.t) (block_header : Block_header.shell_header) - : Bytes.t = +let genesis_protocol_data (baker_sk : Tezos_crypto.Signature.secret_key) + (predecessor_hash : Tezos_crypto.Block_hash.t) + (block_header : Block_header.shell_header) : Bytes.t = let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -856,7 +884,7 @@ let genesis_protocol_data (baker_sk : Signature.secret_key) (block_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) baker_sk @@ -872,7 +900,7 @@ let deduce_baker_sk (Protocol.Alpha_context.Parameters.bootstrap_account * Tezos_mockup_commands.Mockup_wallet.bootstrap_secret) list) (total_accounts : int) (level : int) : - Signature.secret_key tzresult Lwt.t = + Tezos_crypto.Signature.secret_key tzresult Lwt.t = (match (total_accounts, level) with | _, 0 -> return 0 (* apparently this doesn't really matter *) | _ -> @@ -887,7 +915,8 @@ let deduce_baker_sk |> WithExceptions.Option.get ~loc:__LOC__ in let secret_key = - Signature.Secret_key.of_b58check_exn (Uri.path (secret.sk_uri :> Uri.t)) + Tezos_crypto.Signature.Secret_key.of_b58check_exn + (Uri.path (secret.sk_uri :> Uri.t)) in return secret_key @@ -1062,7 +1091,8 @@ type config = { round0 : int64; round1 : int64; timeout : int; - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; initial_seed : State_hash.t option; consensus_committee_size : int; consensus_threshold : int; @@ -1123,7 +1153,7 @@ let run ?(config = default_config) bakers_spec = | Error () -> failwith "impossible: negative length of the baker spec" | Ok xs -> return xs) >>=? fun broadcast_pipes -> - let global_chain_table = Block_hash.Table.create 10 in + let global_chain_table = Tezos_crypto.Block_hash.Table.create 10 in Tezos_mockup_commands.Mockup_wallet.default_bootstrap_accounts >>=? fun bootstrap_secrets -> let accounts_with_secrets = @@ -1198,7 +1228,7 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) (block_header.shell, protocol_data.contents) in if - Signature.check + Tezos_crypto.Signature.check ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) public_key @@ -1208,13 +1238,15 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) else failwith "unexpected signature for %a; tried with %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp public_key type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t let mempool_count_ops ~mempool ~predicate = List.map_es (fun (op_hash, op) -> predicate op_hash op) mempool @@ -1233,7 +1265,7 @@ let mempool_has_op_ref ~mempool ~predicate ~var = if result then var := true ; return_unit -let op_is_signed_by ~public_key (op_hash : Operation_hash.t) +let op_is_signed_by ~public_key (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1245,14 +1277,18 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) Alpha_context.Operation.to_watermark (Endorsement chain_id) | Preendorsement _ -> Alpha_context.Operation.to_watermark (Preendorsement chain_id) - | _ -> Signature.Generic_operation) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> Tezos_crypto.Signature.Generic_operation) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) >>=? fun watermark -> match d.signature with | None -> failwith "did not find a signature for op %a@." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash | Some signature -> let unsigned_operation_bytes = @@ -1261,13 +1297,13 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) (op.shell, Contents_list d.contents) in return - (Signature.check + (Tezos_crypto.Signature.check ~watermark public_key signature unsigned_operation_bytes)) -let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_preendorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1293,9 +1329,13 @@ let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) -let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_endorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1321,7 +1361,11 @@ let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) let op_is_both f g op_hash op = f op_hash op >>=? fun f_result -> 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 57d24764bc7c..42a13cae3af4 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 @@ -56,20 +56,25 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t (** This function is called on injection of an operation. It is similar to [on_inject_block], which see. *) val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t @@ -77,22 +82,23 @@ module type Hooks = sig a "monitor heads" RPC call. Returning [None] here terminates the process for the baker. *) val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t (** This is called when a new operation is going to be sent as the response to a "monitor operations" RPC call. Returning [None] here indicates that the node has advanced to the next level. *) val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t (** Check a block before processing it in the mockup. *) val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -103,7 +109,7 @@ module type Hooks = sig (** Check operations in the mempool after injecting an operation. *) val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t (** This hook is used to decide when the baker is supposed to shut down. @@ -138,7 +144,8 @@ type config = { (** Maximal duration of the test. If the test takes longer to terminate it'll be aborted with an error. *) - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; (** Desired selection of delegates per level/round *) initial_seed : State_hash.t option; (** Optional initial seed for protocol (used to control delegate selection) *) @@ -170,51 +177,54 @@ val default_config : config to the final result. *) val run : ?config:config -> (int * (module Hooks)) list -> unit tzresult Lwt.t -val bootstrap1 : Signature.public_key +val bootstrap1 : Tezos_crypto.Signature.public_key -val bootstrap2 : Signature.public_key +val bootstrap2 : Tezos_crypto.Signature.public_key -val bootstrap3 : Signature.public_key +val bootstrap3 : Tezos_crypto.Signature.public_key -val bootstrap4 : Signature.public_key +val bootstrap4 : Tezos_crypto.Signature.public_key -val bootstrap5 : Signature.public_key +val bootstrap5 : Tezos_crypto.Signature.public_key (** Check if a block header is signed by a given delegate. *) val check_block_signature : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - public_key:Signature.public_key -> + public_key:Tezos_crypto.Signature.public_key -> unit tzresult Lwt.t (** A shortcut type for predicates on operations. *) type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t (** Count the number of operations in the mempool that satisfy the given predicate. *) val mempool_count_ops : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> int tzresult Lwt.t (** Check if the mempool has at least one operation that satisfies the given predicate. *) val mempool_has_op : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> bool tzresult Lwt.t (** Similar to [mempool_has_op] but instead of returning a [bool] it sets the given [bool ref]. *) val mempool_has_op_ref : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> var:bool ref -> unit tzresult Lwt.t (** Check if an operation is signed by the given delegate. *) -val op_is_signed_by : public_key:Signature.public_key -> op_predicate +val op_is_signed_by : + public_key:Tezos_crypto.Signature.public_key -> op_predicate (** Check that an operation is a preendorsement. *) val op_is_preendorsement : ?level:int32 -> ?round:int32 -> op_predicate diff --git a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.ml b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.ml index ce3f8bba6380..fdc0a6dc5abb 100644 --- a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.ml +++ b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.ml @@ -26,7 +26,9 @@ open Protocol type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list module LevelRoundMap = Map.Make (struct type t = Level_repr.t * Round_repr.t @@ -103,8 +105,12 @@ let check ctxt ~selection = Delegate_sampler.baking_rights_owner ctxt level ~round >|= Environment.wrap_tzresult >>=? fun (ctxt, _, pk) -> - if not (Signature.Public_key_hash.equal delegate pk.delegate) then - raise Exit + if + not + (Tezos_crypto.Signature.Public_key_hash.equal + delegate + pk.delegate) + then raise Exit else return ctxt) selection ctxt diff --git a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.mli b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.mli index 7b6915d2cfd2..c13cc23edb60 100644 --- a/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.mli +++ b/src/proto_alpha/lib_delegate/test/tenderbrute/lib/tenderbrute.mli @@ -29,7 +29,9 @@ open Protocol one can provide a public key hash that would be the proposer. All non- specified level and rounds are not constrained. *) type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list (** Brute-force an initial seed nonce for the desired delegate selection. When found, the seed nonce is returned as a byte sequence of size 32. If diff --git a/src/proto_alpha/lib_delegate/test/tenderbrute/tenderbrute_main.ml b/src/proto_alpha/lib_delegate/test/tenderbrute/tenderbrute_main.ml index f3558b1a1985..123db4e59248 100644 --- a/src/proto_alpha/lib_delegate/test/tenderbrute/tenderbrute_main.ml +++ b/src/proto_alpha/lib_delegate/test/tenderbrute/tenderbrute_main.ml @@ -49,7 +49,7 @@ let delegate_encoding = case ~title:"Public key hash" (Tag 0) - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding (function `Pkh p -> Some p | _ -> None) (fun p -> `Pkh p); case diff --git a/src/proto_alpha/lib_delegate/test/test_scenario.ml b/src/proto_alpha/lib_delegate/test/test_scenario.ml index 7543a2b1ab28..f10b60904c24 100644 --- a/src/proto_alpha/lib_delegate/test/test_scenario.ml +++ b/src/proto_alpha/lib_delegate/test/test_scenario.ml @@ -1,14 +1,14 @@ open Mockup_simulator -let bootstrap1 = Signature.Public_key.hash bootstrap1 +let bootstrap1 = Tezos_crypto.Signature.Public_key.hash bootstrap1 -let bootstrap2 = Signature.Public_key.hash bootstrap2 +let bootstrap2 = Tezos_crypto.Signature.Public_key.hash bootstrap2 -let bootstrap3 = Signature.Public_key.hash bootstrap3 +let bootstrap3 = Tezos_crypto.Signature.Public_key.hash bootstrap3 -let bootstrap4 = Signature.Public_key.hash bootstrap4 +let bootstrap4 = Tezos_crypto.Signature.Public_key.hash bootstrap4 -let bootstrap5 = Signature.Public_key.hash bootstrap5 +let bootstrap5 = Tezos_crypto.Signature.Public_key.hash bootstrap5 let some_seed s = Some (Protocol.State_hash.of_b58check_exn s) diff --git a/src/proto_alpha/lib_injector/disk_persistence.ml b/src/proto_alpha/lib_injector/disk_persistence.ml index 20565456cb64..f82914fa5d9d 100644 --- a/src/proto_alpha/lib_injector/disk_persistence.ml +++ b/src/proto_alpha/lib_injector/disk_persistence.ml @@ -276,7 +276,7 @@ end module Make_queue (N : sig val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_alpha/lib_injector/disk_persistence.mli b/src/proto_alpha/lib_injector/disk_persistence.mli index 7412450d251c..6e37f06fe507 100644 --- a/src/proto_alpha/lib_injector/disk_persistence.mli +++ b/src/proto_alpha/lib_injector/disk_persistence.mli @@ -106,7 +106,7 @@ module Make_queue (N : sig to store the persistent information for this queue. *) val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index e3f58247522d..8fe34ddecfc3 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/proto_alpha/lib_injector/dune @@ -26,7 +26,6 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_micheline -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_injector/injector_common.ml b/src/proto_alpha/lib_injector/injector_common.ml index 924c679032c9..b6177f871e7a 100644 --- a/src/proto_alpha/lib_injector/injector_common.ml +++ b/src/proto_alpha/lib_injector/injector_common.ml @@ -27,8 +27,8 @@ open Protocol_client_context type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -76,7 +76,7 @@ let fetch_tezos_block ~find_in_cache (cctxt : #full) hash : i.e. calls {!fetch} for cache misses. *) error_with "Fetching Tezos block %a failed unexpectedly" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash | None, Some errs -> Error errs | Some block, _ -> Ok block @@ -87,7 +87,7 @@ let tezos_reorg fetch_tezos_block ~old_head_hash ~new_head_hash = let open Alpha_block_services in let open Lwt_result_syntax in let rec loop old_chain new_chain old_head_hash new_head_hash = - if Block_hash.(old_head_hash = new_head_hash) then + if Tezos_crypto.Block_hash.(old_head_hash = new_head_hash) then return {old_chain = List.rev old_chain; new_chain = List.rev new_chain} else let* new_head = fetch_tezos_block new_head_hash in diff --git a/src/proto_alpha/lib_injector/injector_common.mli b/src/proto_alpha/lib_injector/injector_common.mli index 4a1651ede2f7..6519834b301f 100644 --- a/src/proto_alpha/lib_injector/injector_common.mli +++ b/src/proto_alpha/lib_injector/injector_common.mli @@ -28,8 +28,8 @@ open Protocol_client_context (** The type of signers for operations injected by the injector *) type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -44,7 +44,9 @@ type 'block reorg = { (** Retrieve a signer from the client wallet. *) val get_signer : - #Client_context.wallet -> Signature.public_key_hash -> signer tzresult Lwt.t + #Client_context.wallet -> + Tezos_crypto.Signature.public_key_hash -> + signer tzresult Lwt.t val no_reorg : 'a reorg @@ -59,18 +61,18 @@ type block_info := Alpha_block_services.block_info {!Ringo_lwt.Sigs.CACHE_MAP_RESULT}. *) val fetch_tezos_block : find_in_cache: - (Block_hash.t -> - (Block_hash.t -> block_info option Lwt.t) -> + (Tezos_crypto.Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info option Lwt.t) -> block_info option Lwt.t) -> #full -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t (** [tezos_reorg fetch ~old_head_hash ~new_head_hash] computes the reorganization of L1 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) val tezos_reorg : - (Block_hash.t -> block_info tzresult Lwt.t) -> - old_head_hash:Block_hash.t -> - new_head_hash:Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> + old_head_hash:Tezos_crypto.Block_hash.t -> + new_head_hash:Tezos_crypto.Block_hash.t -> block_info reorg tzresult Lwt.t diff --git a/src/proto_alpha/lib_injector/injector_errors.ml b/src/proto_alpha/lib_injector/injector_errors.ml index c6c9f590ef93..b2e5b98bebc3 100644 --- a/src/proto_alpha/lib_injector/injector_errors.ml +++ b/src/proto_alpha/lib_injector/injector_errors.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t let () = register_error_kind @@ -35,10 +35,11 @@ let () = Format.fprintf ppf "No worker for source %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp s) `Permanent - Data_encoding.(obj1 (req "source" Signature.Public_key_hash.encoding)) + Data_encoding.( + obj1 (req "source" Tezos_crypto.Signature.Public_key_hash.encoding)) (function No_worker_for_source s -> Some s | _ -> None) (fun s -> No_worker_for_source s) diff --git a/src/proto_alpha/lib_injector/injector_errors.mli b/src/proto_alpha/lib_injector/injector_errors.mli index e3e0f56666c9..1c39b4ffc53a 100644 --- a/src/proto_alpha/lib_injector/injector_errors.mli +++ b/src/proto_alpha/lib_injector/injector_errors.mli @@ -25,7 +25,7 @@ (** Error when the injector has no worker for the source which must inject an operation. *) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t (** Error when the injector has no worker for the tag of the operation to be injected. *) diff --git a/src/proto_alpha/lib_injector/injector_events.ml b/src/proto_alpha/lib_injector/injector_events.ml index 5cf2d04d3a62..c34f719447c8 100644 --- a/src/proto_alpha/lib_injector/injector_events.ml +++ b/src/proto_alpha/lib_injector/injector_events.ml @@ -37,10 +37,10 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 @@ -50,11 +50,11 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -65,12 +65,12 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 enc3 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -113,7 +113,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"new_tezos_head" ~msg:"processing new Tezos head {head}" ~level:Debug - ("head", Block_hash.encoding) + ("head", Tezos_crypto.Block_hash.encoding) let injecting_pending = declare_1 @@ -169,7 +169,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~msg:"Injected {nb} operations in {oph}" ~level:Notice ("nb", Data_encoding.int31) - ("oph", Operation_hash.encoding) + ("oph", Tezos_crypto.Operation_hash.encoding) let add_pending = declare_1 @@ -192,7 +192,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"included" ~msg:"Included operations of {block} at level {level}: {operations}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("operations", Data_encoding.list L1_operation.Hash.encoding) ~pp3:pp_operations_hash_list diff --git a/src/proto_alpha/lib_injector/injector_functor.ml b/src/proto_alpha/lib_injector/injector_functor.ml index 412237ea65d7..0f43feb6eb7d 100644 --- a/src/proto_alpha/lib_injector/injector_functor.ml +++ b/src/proto_alpha/lib_injector/injector_functor.ml @@ -73,7 +73,7 @@ module Make (Rollup : PARAMETERS) = struct node. *) type injected_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) } @@ -93,20 +93,20 @@ module Make (Rollup : PARAMETERS) = struct let open Data_encoding in conv (fun {op; oph} -> (oph, op)) (fun (oph, op) -> {op; oph}) @@ merge_objs - (obj1 (req "oph" Operation_hash.encoding)) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) L1_operation.encoding end) module Injected_ophs = Disk_persistence.Make_table (struct - include Operation_hash.Table + include Tezos_crypto.Operation_hash.Table type value = L1_operation.Hash.t list let name = "injected_ophs" - let string_of_key = Operation_hash.to_b58check + let string_of_key = Tezos_crypto.Operation_hash.to_b58check - let key_of_string = Operation_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Operation_hash.of_b58check_opt let value_encoding = Data_encoding.list L1_operation.Hash.encoding end) @@ -126,10 +126,10 @@ module Make (Rollup : PARAMETERS) = struct block. *) type included_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) - l1_block : Block_hash.t; + l1_block : Tezos_crypto.Block_hash.t; (** The hash of the L1 block in which the operation was included. *) l1_level : int32; (** The level of [l1_block]. *) } @@ -153,21 +153,21 @@ module Make (Rollup : PARAMETERS) = struct @@ merge_objs L1_operation.encoding (obj3 - (req "oph" Operation_hash.encoding) - (req "l1_block" Block_hash.encoding) + (req "oph" Tezos_crypto.Operation_hash.encoding) + (req "l1_block" Tezos_crypto.Block_hash.encoding) (req "l1_level" int32)) end) module Included_in_blocks = Disk_persistence.Make_table (struct - include Block_hash.Table + include Tezos_crypto.Block_hash.Table type value = int32 * L1_operation.Hash.t list let name = "included_in_blocks" - let string_of_key = Block_hash.to_b58check + let string_of_key = Tezos_crypto.Block_hash.to_b58check - let key_of_string = Block_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Block_hash.of_b58check_opt let value_encoding = let open Data_encoding in @@ -548,7 +548,7 @@ module Make (Rollup : PARAMETERS) = struct let* signature = Client_keys.sign state.cctxt - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation state.signer.sk unsigned_op_bytes in @@ -664,11 +664,13 @@ module Make (Rollup : PARAMETERS) = struct in let signature = match state.signer.pkh with - | Signature.Ed25519 _ -> Signature.of_ed25519 Ed25519.zero - | Secp256k1 _ -> Signature.of_secp256k1 Secp256k1.zero - | P256 _ -> Signature.of_p256 P256.zero + | Tezos_crypto.Signature.Ed25519 _ -> + Tezos_crypto.Signature.of_ed25519 Tezos_crypto.Ed25519.zero + | Secp256k1 _ -> + Tezos_crypto.Signature.of_secp256k1 Tezos_crypto.Secp256k1.zero + | P256 _ -> Tezos_crypto.Signature.of_p256 Tezos_crypto.P256.zero in - let branch = Block_hash.zero in + let branch = Tezos_crypto.Block_hash.zero in let operation = { shell = {branch}; @@ -1030,7 +1032,9 @@ module Make (Rollup : PARAMETERS) = struct (fun acc (signer, strategy, tags) -> let tags = Tags.of_list tags in let strategy, tags = - match Signature.Public_key_hash.Map.find_opt signer acc with + match + Tezos_crypto.Signature.Public_key_hash.Map.find_opt signer acc + with | None -> (strategy, tags) | Some (other_strategy, other_tags) -> let strategy = @@ -1044,11 +1048,14 @@ module Make (Rollup : PARAMETERS) = struct in (strategy, Tags.union other_tags tags) in - Signature.Public_key_hash.Map.add signer (strategy, tags) acc) - Signature.Public_key_hash.Map.empty + Tezos_crypto.Signature.Public_key_hash.Map.add + signer + (strategy, tags) + acc) + Tezos_crypto.Signature.Public_key_hash.Map.empty signers in - Signature.Public_key_hash.Map.iter_es + Tezos_crypto.Signature.Public_key_hash.Map.iter_es (fun signer (strategy, tags) -> let+ worker = Worker.launch diff --git a/src/proto_alpha/lib_injector/injector_worker_types.ml b/src/proto_alpha/lib_injector/injector_worker_types.ml index fca7eed3f8ff..7f86e158a775 100644 --- a/src/proto_alpha/lib_injector/injector_worker_types.ml +++ b/src/proto_alpha/lib_injector/injector_worker_types.ml @@ -84,7 +84,7 @@ module Request = struct Format.fprintf ppf "switching to new Tezos head %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp b.Alpha_block_services.hash ; if r.old_chain <> [] || r.new_chain <> [] then Format.fprintf @@ -98,11 +98,11 @@ end module Name = struct type t = public_key_hash - let encoding = Signature.Public_key_hash.encoding + let encoding = Tezos_crypto.Signature.Public_key_hash.encoding let base = ["tx_rollup_injector"] - let pp = Signature.Public_key_hash.pp_short + let pp = Tezos_crypto.Signature.Public_key_hash.pp_short - let equal = Signature.Public_key_hash.equal + let equal = Tezos_crypto.Signature.Public_key_hash.equal end diff --git a/src/proto_alpha/lib_injector/l1_operation.ml b/src/proto_alpha/lib_injector/l1_operation.ml index bc10f74dc96d..c140f9901087 100644 --- a/src/proto_alpha/lib_injector/l1_operation.ml +++ b/src/proto_alpha/lib_injector/l1_operation.ml @@ -149,7 +149,7 @@ module Manager_operation = struct ty pp_lazy_expr contents - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer in Format.fprintf @@ -185,8 +185,8 @@ module Manager_operation = struct end module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "manager_operation_hash" @@ -197,7 +197,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 type hash = Hash.t diff --git a/src/proto_alpha/lib_injector/l1_operation.mli b/src/proto_alpha/lib_injector/l1_operation.mli index 73f1886ed737..21b13fbf32ff 100644 --- a/src/proto_alpha/lib_injector/l1_operation.mli +++ b/src/proto_alpha/lib_injector/l1_operation.mli @@ -26,7 +26,7 @@ open Protocol.Alpha_context (** Hash with b58check encoding mop(53), for hashes of L1 manager operations *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for L1 operations hashes *) type hash = Hash.t diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 91041cab3b54..066824e5c7a8 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -412,8 +412,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index eff7da674972..f930bc38fd87 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -35,11 +35,11 @@ val constants_test : Constants.Parametric.t val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Signature.public_key_hash - * Signature.public_key + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key * Tez.t - * Signature.public_key_hash option - * Signature.public_key option -> + * Tezos_crypto.Signature.public_key_hash option + * Tezos_crypto.Signature.public_key option -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 7ff7da7b1463..0c5436e925d8 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -166,7 +166,7 @@ module Scripts = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (opt "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "self" Contract.originated_encoding) @@ -219,7 +219,7 @@ module Scripts = struct (req "contract" Contract.originated_encoding) (req "entrypoint" Entrypoint.simple_encoding) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -235,7 +235,7 @@ module Scripts = struct (req "view" string) (req "input" Script.expr_encoding) (dft "unlimited_gas" bool false) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.implicit_encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -384,7 +384,7 @@ module Scripts = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") @@ -417,7 +417,7 @@ module Scripts = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_operation") @@ -430,7 +430,7 @@ module Scripts = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_tx_rollup_operation") @@ -916,7 +916,7 @@ module Scripts = struct type run_code_config = { balance : Tez.t; self : Contract_hash.t; - payer : Signature.public_key_hash; + payer : Tezos_crypto.Signature.public_key_hash; source : Contract.t; } @@ -925,7 +925,7 @@ module Scripts = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero in Contract.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, dummy_contract_hash) -> let dummy_contract = Contract.Originated dummy_contract_hash in @@ -946,8 +946,9 @@ module Scripts = struct let source_and_payer ~src_opt ~pay_opt ~default_src = match (src_opt, pay_opt) with | None, None -> - (Contract.Originated default_src, Signature.Public_key_hash.zero) - | Some c, None -> (c, Signature.Public_key_hash.zero) + ( Contract.Originated default_src, + Tezos_crypto.Signature.Public_key_hash.zero ) + | Some c, None -> (c, Tezos_crypto.Signature.Public_key_hash.zero) | None, Some c -> (Contract.Implicit c, c) | Some src, Some pay -> (src, pay) in @@ -2903,10 +2904,10 @@ module Baking_rights = struct {level; delegate; consensus_key; round; timestamp}) (obj5 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "round" Round.encoding) (opt "estimated_time" Timestamp.encoding) - (req "consensus_key" Signature.Public_key_hash.encoding)) + (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) let default_max_round = 64 @@ -2918,8 +2919,8 @@ module Baking_rights = struct type baking_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; - consensus_keys : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; + consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; max_round : int option; all : bool; } @@ -3009,12 +3010,16 @@ module Baking_rights = struct @@ List.fold_left (fun (acc, previous) r -> if - Signature.Public_key_hash.Set.exists - (Signature.Public_key_hash.equal r.delegate) + Tezos_crypto.Signature.Public_key_hash.Set.exists + (Tezos_crypto.Signature.Public_key_hash.equal r.delegate) previous then (acc, previous) - else (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) - ([], Signature.Public_key_hash.Set.empty) + else + ( r :: acc, + Tezos_crypto.Signature.Public_key_hash.Set.add + r.delegate + previous )) + ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) rights let register () = @@ -3050,7 +3055,7 @@ module Baking_rights = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights @@ -3061,7 +3066,7 @@ module Baking_rights = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.consensus_key) + (Tezos_crypto.Signature.Public_key_hash.equal p.consensus_key) delegates in List.filter is_requested rights @@ -3080,8 +3085,8 @@ end module Endorsing_rights = struct type delegate_rights = { - delegate : Signature.Public_key_hash.t; - consensus_key : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; + consensus_key : Tezos_crypto.Signature.Public_key_hash.t; first_slot : Slot.t; endorsing_power : int; } @@ -3100,10 +3105,10 @@ module Endorsing_rights = struct (fun (delegate, first_slot, endorsing_power, consensus_key) -> {delegate; first_slot; endorsing_power; consensus_key}) (obj4 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "first_slot" Slot.encoding) (req "endorsing_power" uint16) - (req "consensus_key" Signature.Public_key_hash.encoding)) + (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) let encoding = let open Data_encoding in @@ -3125,8 +3130,8 @@ module Endorsing_rights = struct type endorsing_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; - consensus_keys : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; + consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -3216,7 +3221,8 @@ module Endorsing_rights = struct (fun rights_at_level -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.consensus_key) + (Tezos_crypto.Signature.Public_key_hash.equal + p.consensus_key) consensus_keys in match @@ -3242,8 +3248,8 @@ end module Validators = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; - consensus_key : Signature.public_key_hash; + delegate : Tezos_crypto.Signature.Public_key_hash.t; + consensus_key : Tezos_crypto.Signature.public_key_hash; slots : Slot.t list; } @@ -3256,9 +3262,9 @@ module Validators = struct {level; delegate; consensus_key; slots}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "slots" (list Slot.encoding)) - (req "consensus_key" Signature.Public_key_hash.encoding)) + (req "consensus_key" Tezos_crypto.Signature.Public_key_hash.encoding)) module S = struct open Data_encoding @@ -3267,8 +3273,8 @@ module Validators = struct type validators_query = { levels : Raw_level.t list; - delegates : Signature.Public_key_hash.t list; - consensus_keys : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; + consensus_keys : Tezos_crypto.Signature.Public_key_hash.t list; } let validators_query = @@ -3323,7 +3329,7 @@ module Validators = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights @@ -3334,7 +3340,7 @@ module Validators = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.consensus_key) + (Tezos_crypto.Signature.Public_key_hash.equal p.consensus_key) delegates in List.filter is_requested rights diff --git a/src/proto_alpha/lib_plugin/mempool.ml b/src/proto_alpha/lib_plugin/mempool.ml index 369082de7e34..066dbc16f8fa 100644 --- a/src/proto_alpha/lib_plugin/mempool.ml +++ b/src/proto_alpha/lib_plugin/mempool.ml @@ -190,7 +190,10 @@ type manager_op_info = { in [state] when appropriate. *) } -type manager_op_weight = {operation_hash : Operation_hash.t; weight : Q.t} +type manager_op_weight = { + operation_hash : Tezos_crypto.Operation_hash.t; + weight : Q.t; +} (** Build a {!manager_op_weight} from operation hash and {!manager_op_info}. *) let mk_op_weight oph (info : manager_op_info) = @@ -199,7 +202,7 @@ let mk_op_weight oph (info : manager_op_info) = let compare_manager_op_weight op1 op2 = let c = Q.compare op1.weight op2.weight in if c <> 0 then c - else Operation_hash.compare op1.operation_hash op2.operation_hash + else Tezos_crypto.Operation_hash.compare op1.operation_hash op2.operation_hash module ManagerOpWeightSet = Set.Make (struct type t = manager_op_weight @@ -224,10 +227,10 @@ type state = { (** Number of prechecked manager operations. Invariants: - [prechecked_manager_op_count - = Operation_hash.Map.cardinal prechecked_manager_ops + = Tezos_crypto.Operation_hash.Map.cardinal prechecked_manager_ops = ManagerOpWeightSet.cardinal prechecked_op_weights] - [prechecked_manager_op_count <= max_prechecked_manager_operations] *) - prechecked_manager_ops : manager_op_info Operation_hash.Map.t; + prechecked_manager_ops : manager_op_info Tezos_crypto.Operation_hash.Map.t; (** All prechecked manager operations. See {!manager_op_info}. *) prechecked_op_weights : ManagerOpWeightSet.t; (** The {!manager_op_weight} of all prechecked manager operations. *) @@ -242,7 +245,7 @@ let empty : state = { state_info = None; prechecked_manager_op_count = 0; - prechecked_manager_ops = Operation_hash.Map.empty; + prechecked_manager_ops = Tezos_crypto.Operation_hash.Map.empty; prechecked_op_weights = ManagerOpWeightSet.empty; min_prechecked_op_weight = None; } @@ -329,7 +332,7 @@ let () = (fun () -> Fees_too_low) type Environment.Error_monad.error += - | Manager_restriction of {oph : Operation_hash.t; fee : Tez.t} + | Manager_restriction of {oph : Tezos_crypto.Operation_hash.t; fee : Tez.t} let () = Environment.Error_monad.register_error_kind @@ -343,21 +346,21 @@ let () = "Only one manager operation per manager per block allowed (found %a \ with %atez fee. You may want to use --replace to provide adequate fee \ and replace it)." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Tez.pp fee) Data_encoding.( obj2 - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation_fee" Tez.encoding)) (function Manager_restriction {oph; fee} -> Some (oph, fee) | _ -> None) (fun (oph, fee) -> Manager_restriction {oph; fee}) type Environment.Error_monad.error += | Manager_operation_replaced of { - old_hash : Operation_hash.t; - new_hash : Operation_hash.t; + old_hash : Tezos_crypto.Operation_hash.t; + new_hash : Tezos_crypto.Operation_hash.t; } let () = @@ -370,13 +373,13 @@ let () = Format.fprintf ppf "The manager operation %a has been replaced with %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_hash - Operation_hash.pp + Tezos_crypto.Operation_hash.pp new_hash) (Data_encoding.obj2 - (Data_encoding.req "old_hash" Operation_hash.encoding) - (Data_encoding.req "new_hash" Operation_hash.encoding)) + (Data_encoding.req "old_hash" Tezos_crypto.Operation_hash.encoding) + (Data_encoding.req "new_hash" Tezos_crypto.Operation_hash.encoding)) (function | Manager_operation_replaced {old_hash; new_hash} -> Some (old_hash, new_hash) @@ -911,7 +914,7 @@ let proto_validate_manager_operation validation_state oph ~nb_successful_prechecks (operation : 'a Kind.manager Alpha_context.operation) : ( [> `Success of validation_state - | `Conflict of Operation_hash.t * error_classification ], + | `Conflict of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -961,7 +964,8 @@ let validate_manager_operation_and_handle_conflicts config filter_state validation_state oph ~nb_successful_prechecks fee gas_limit (operation : 'manager_kind Kind.manager operation) : ( validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification], + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -998,7 +1002,7 @@ let validate_manager_operation_and_handle_conflicts config filter_state branch_delayed ring is bounded to 1000, so we may loose operations. We can probably do better. *) match - Operation_hash.Map.find + Tezos_crypto.Operation_hash.Map.find min_weight_oph filter_state.prechecked_manager_ops with @@ -1027,7 +1031,9 @@ let validate_manager_operation_and_handle_conflicts config filter_state from the same manager. We look at the fees and gas limits of both operations to decide whether to replace the old one. *) match - Operation_hash.Map.find old_oph filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.find + old_oph + filter_state.prechecked_manager_ops with | None -> (* This only occurs for a [Drain_delegate] operation: it has @@ -1079,13 +1085,17 @@ let validate_manager_operation_and_handle_conflicts config filter_state (** Remove a manager operation hash from the filter state. Do nothing if the operation was not in the state. *) let remove ~filter_state oph = - match Operation_hash.Map.find oph filter_state.prechecked_manager_ops with + match + Tezos_crypto.Operation_hash.Map.find oph filter_state.prechecked_manager_ops + with | None -> (* Not present in the filter_state: nothing to do. *) filter_state | Some info -> let prechecked_manager_ops = - Operation_hash.Map.remove oph filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.remove + oph + filter_state.prechecked_manager_ops in let prechecked_manager_op_count = filter_state.prechecked_manager_op_count - 1 @@ -1099,8 +1109,9 @@ let remove ~filter_state oph = match filter_state.min_prechecked_op_weight with | None -> None | Some min_op_weight -> - if Operation_hash.equal min_op_weight.operation_hash oph then - ManagerOpWeightSet.min_elt prechecked_op_weights + if + Tezos_crypto.Operation_hash.equal min_op_weight.operation_hash oph + then ManagerOpWeightSet.min_elt prechecked_op_weights else Some min_op_weight in { @@ -1119,15 +1130,18 @@ let add_manager_op filter_state oph info replacement = | `No_replace -> filter_state | `Replace (oph, _classification) -> remove ~filter_state oph in - if Operation_hash.Map.mem oph filter_state.prechecked_manager_ops then - (* Already present in the filter_state: nothing to do. *) + if Tezos_crypto.Operation_hash.Map.mem oph filter_state.prechecked_manager_ops + then (* Already present in the filter_state: nothing to do. *) filter_state else let prechecked_manager_op_count = filter_state.prechecked_manager_op_count + 1 in let prechecked_manager_ops = - Operation_hash.Map.add oph info filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.add + oph + info + filter_state.prechecked_manager_ops in let op_weight = mk_op_weight oph info in let prechecked_op_weights = @@ -1159,7 +1173,8 @@ let precheck_manager_result config filter_state validation_state oph : ( state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification], + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -1198,7 +1213,8 @@ let precheck_manager config filter_state validation_state oph [> `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification ] Lwt.t = precheck_manager_result @@ -1253,13 +1269,14 @@ let precheck : config -> filter_state:state -> validation_state:validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Main.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | `Undecided | error_classification ] Lwt.t = diff --git a/src/proto_alpha/lib_plugin/test/generators.ml b/src/proto_alpha/lib_plugin/test/generators.ml index afe935242a1b..7cf916779239 100644 --- a/src/proto_alpha/lib_plugin/test/generators.ml +++ b/src/proto_alpha/lib_plugin/test/generators.ml @@ -28,26 +28,28 @@ module Mempool = Plugin.Mempool let string_gen = QCheck2.Gen.small_string ?gen:None let public_key_hash_gen : - (Signature.public_key_hash * Signature.public_key * Signature.secret_key) + (Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tezos_crypto.Signature.secret_key) QCheck2.Gen.t = let open QCheck2.Gen in let+ seed = string_size (32 -- 64) in let seed = Bytes.of_string seed in - Signature.generate_key ~seed () + Tezos_crypto.Signature.generate_key ~seed () (* TODO: https://gitlab.com/tezos/tezos/-/issues/2407 move this function to an helper file? *) -let operation_hash_gen : Operation_hash.t QCheck2.Gen.t = +let operation_hash_gen : Tezos_crypto.Operation_hash.t QCheck2.Gen.t = let open QCheck2.Gen in let+ s = QCheck2.Gen.string_size (return 32) in - Operation_hash.of_string_exn s + Tezos_crypto.Operation_hash.of_string_exn s let dummy_manager_op_info = let fee = Alpha_context.Tez.zero in let gas_limit = Alpha_context.Gas.Arith.zero in let manager_op = let open Alpha_context in - let source = Signature.Public_key_hash.zero in + let source = Tezos_crypto.Signature.Public_key_hash.zero in let counter = Manager_counter.Internal_for_tests.of_int 0 in let storage_limit = Z.zero in let operation = Set_deposits_limit None in @@ -56,8 +58,10 @@ let dummy_manager_op_info = {source; fee; counter; operation; gas_limit; storage_limit} in let contents = Single contents in - let protocol_data = {contents; signature = Some Signature.zero} in - let branch = Block_hash.zero in + let protocol_data = + {contents; signature = Some Tezos_crypto.Signature.zero} + in + let branch = Tezos_crypto.Block_hash.zero in Mempool.Manager_op {shell = {branch}; protocol_data} in Mempool.{manager_op; fee; gas_limit; weight = Q.zero} @@ -73,7 +77,8 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = let+ ops = small_list oph_and_info_gen in List.fold_left (fun state (oph, info) -> - if Operation_hash.Map.mem oph state.prechecked_manager_ops then state + if Tezos_crypto.Operation_hash.Map.mem oph state.prechecked_manager_ops + then state else let prechecked_manager_op_count = state.prechecked_manager_op_count + 1 @@ -90,7 +95,10 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = state with prechecked_manager_op_count; prechecked_manager_ops = - Operation_hash.Map.add oph info state.prechecked_manager_ops; + Tezos_crypto.Operation_hash.Map.add + oph + info + state.prechecked_manager_ops; prechecked_op_weights = ManagerOpWeightSet.add op_weight state.prechecked_op_weights; min_prechecked_op_weight; @@ -102,19 +110,25 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = even odds of belonging to the given filter_state or being fresh. *) let with_filter_state_operation_gen : Plugin.Mempool.state -> - (Operation_hash.t * Plugin.Mempool.manager_op_info) QCheck2.Gen.t = + (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info) + QCheck2.Gen.t = fun state -> let open QCheck2.Gen in let* use_fresh = bool in - if use_fresh || Operation_hash.Map.is_empty state.prechecked_manager_ops then - oph_and_info_gen - else oneofl (Operation_hash.Map.bindings state.prechecked_manager_ops) + if + use_fresh + || Tezos_crypto.Operation_hash.Map.is_empty state.prechecked_manager_ops + then oph_and_info_gen + else + oneofl + (Tezos_crypto.Operation_hash.Map.bindings state.prechecked_manager_ops) (** Generate both a filter_state, and a pair of operation hash and manager_op_info. The pair has even odds of belonging to the filter_state or being fresh. *) let filter_state_with_operation_gen : - (Plugin.Mempool.state * (Operation_hash.t * Plugin.Mempool.manager_op_info)) + (Plugin.Mempool.state + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info)) QCheck2.Gen.t = let open QCheck2.Gen in filter_state_gen >>= fun state -> @@ -125,8 +139,8 @@ let filter_state_with_operation_gen : to the filter_state or being fresh. *) let filter_state_with_two_operations_gen : (Plugin.Mempool.state - * (Operation_hash.t * Plugin.Mempool.manager_op_info) - * (Operation_hash.t * Plugin.Mempool.manager_op_info)) + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info) + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info)) QCheck2.Gen.t = let open QCheck2.Gen in let* filter_state = filter_state_gen in diff --git a/src/proto_alpha/lib_plugin/test/test_filter_state.ml b/src/proto_alpha/lib_plugin/test/test_filter_state.ml index 032e46ae902f..7f112195af83 100644 --- a/src/proto_alpha/lib_plugin/test/test_filter_state.ml +++ b/src/proto_alpha/lib_plugin/test/test_filter_state.ml @@ -46,13 +46,14 @@ let check_filter_state_invariants filter_state = filter_state) ~cond:(fun filter_state -> filter_state.prechecked_manager_op_count - = Operation_hash.Map.cardinal filter_state.prechecked_manager_ops + = Tezos_crypto.Operation_hash.Map.cardinal + filter_state.prechecked_manager_ops && filter_state.prechecked_manager_op_count = ManagerOpWeightSet.cardinal filter_state.prechecked_op_weights && ManagerOpWeightSet.for_all (fun {operation_hash; weight} -> match - Operation_hash.Map.find + Tezos_crypto.Operation_hash.Map.find operation_hash filter_state.prechecked_manager_ops with @@ -79,7 +80,7 @@ let test_add_manager_op = already present in [filter_state] or fresh. *) let replacement = if should_replace then ( - assume (not (Operation_hash.equal oph_to_replace oph)) ; + assume (not (Tezos_crypto.Operation_hash.equal oph_to_replace oph)) ; `Replace (oph_to_replace, ())) else `No_replace in @@ -90,11 +91,11 @@ let test_add_manager_op = Format.fprintf fmt "%a was not found in prechecked_manager_ops: %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph pp_prechecked_manager_ops set) - ~cond:(Operation_hash.Map.mem oph) + ~cond:(Tezos_crypto.Operation_hash.Map.mem oph) filter_state.prechecked_manager_ops () && @@ -104,11 +105,11 @@ let test_add_manager_op = Format.fprintf fmt "%a should have been removed from prechecked_manager_ops." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph_to_replace) ~cond:(fun () -> not - (Operation_hash.Map.mem + (Tezos_crypto.Operation_hash.Map.mem oph_to_replace filter_state.prechecked_manager_ops)) () @@ -131,7 +132,10 @@ let test_remove_present = -> (* Add a fresh operation [oph] to the state. *) assume - (not (Operation_hash.Map.mem oph initial_state.prechecked_manager_ops)) ; + (not + (Tezos_crypto.Operation_hash.Map.mem + oph + initial_state.prechecked_manager_ops)) ; let replacement = if should_replace then `Replace (oph_to_replace, ()) else `No_replace in @@ -147,11 +151,11 @@ let test_remove_present = Format.fprintf fmt "%a should have been removed from prechecked_manager_ops." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) ~cond:(fun () -> not - (Operation_hash.Map.mem + (Tezos_crypto.Operation_hash.Map.mem oph filter_state.prechecked_manager_ops)) () @@ -179,7 +183,10 @@ let test_remove_unknown = (Gen.pair Generators.filter_state_gen Generators.operation_hash_gen) (fun (initial_state, oph) -> assume - (not (Operation_hash.Map.mem oph initial_state.prechecked_manager_ops)) ; + (not + (Tezos_crypto.Operation_hash.Map.mem + oph + initial_state.prechecked_manager_ops)) ; let filter_state = remove ~filter_state:initial_state oph in qcheck_eq ~pp:pp_state ~eq:eq_state initial_state filter_state) diff --git a/src/proto_alpha/lib_plugin/test/test_utils.ml b/src/proto_alpha/lib_plugin/test/test_utils.ml index 57402233a49e..0b92f1f4ca4c 100644 --- a/src/proto_alpha/lib_plugin/test/test_utils.ml +++ b/src/proto_alpha/lib_plugin/test/test_utils.ml @@ -44,7 +44,7 @@ let pp_prechecked_manager_ops fmt set = Format.fprintf ppf "(%a -> {fee: %a; gas: %a; weight: %a})" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Alpha_context.Tez.pp op_info.fee @@ -52,13 +52,13 @@ let pp_prechecked_manager_ops fmt set = op_info.gas_limit Q.pp_print op_info.weight)) - (Operation_hash.Map.bindings set) + (Tezos_crypto.Operation_hash.Map.bindings set) let pp_manager_op_weight fmt weight = Format.fprintf fmt "{oph: %a; weight: %a}" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp weight.operation_hash Q.pp_print weight.weight @@ -95,7 +95,7 @@ let pp_state fmt state = state.min_prechecked_op_weight let eq_prechecked_manager_ops = - Operation_hash.Map.equal + Tezos_crypto.Operation_hash.Map.equal (fun {manager_op = _; fee = fee1; gas_limit = gas1; weight = w1} {manager_op = _; fee = fee2; gas_limit = gas2; weight = w2} @@ -103,7 +103,9 @@ let eq_prechecked_manager_ops = let eq_op_weight_opt = Option.equal (fun op_weight1 op_weight2 -> - Operation_hash.equal op_weight1.operation_hash op_weight2.operation_hash + Tezos_crypto.Operation_hash.equal + op_weight1.operation_hash + op_weight2.operation_hash && Q.equal op_weight1.weight op_weight2.weight) (* This function needs to be updated if the filter state is extended *) diff --git a/src/proto_alpha/lib_protocol/test/helpers/account.ml b/src/proto_alpha/lib_protocol/test/helpers/account.ml index 7706c0050b54..ee34e31ae9b6 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/account.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/account.ml @@ -27,44 +27,52 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -let known_accounts = Signature.Public_key_hash.Table.create 17 +let known_accounts = Tezos_crypto.Signature.Public_key_hash.Table.create 17 let random_seed ~rng_state = - Bytes.init Hacl.Ed25519.sk_size (fun _i -> + Bytes.init Tezos_crypto.Hacl.Ed25519.sk_size (fun _i -> Char.chr (Random.State.int rng_state 256)) let new_account ?(rng_state = Random.State.make_self_init ()) ?(seed = random_seed ~rng_state) () = - let pkh, pk, sk = Signature.generate_key ~algo:Ed25519 ~seed () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ~seed () + in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account ; account let add_account ({pkh; _} as account) = - Signature.Public_key_hash.Table.add known_accounts pkh account + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account let activator_account = let seed = random_seed ~rng_state:(Random.State.make [|0x1337533D|]) in new_account ~seed () let find pkh = - match Signature.Public_key_hash.Table.find known_accounts pkh with + match + Tezos_crypto.Signature.Public_key_hash.Table.find known_accounts pkh + with | Some k -> return k - | None -> failwith "Missing account: %a" Signature.Public_key_hash.pp pkh + | None -> + failwith + "Missing account: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let find_alternate pkh = let exception Found of t in try - Signature.Public_key_hash.Table.iter + Tezos_crypto.Signature.Public_key_hash.Table.iter (fun pkh' account -> - if not (Signature.Public_key_hash.equal pkh pkh') then + if not (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') then raise (Found account)) known_accounts ; raise Not_found @@ -79,7 +87,7 @@ let dummy_account = let default_initial_balance = Tez.of_mutez_exn 4_000_000_000_000L let generate_accounts ?rng_state n : t list tzresult = - Signature.Public_key_hash.Table.clear known_accounts ; + Tezos_crypto.Signature.Public_key_hash.Table.clear known_accounts ; List.init ~when_negative_length:[] n (fun _i -> new_account ?rng_state ()) let commitment_secret = @@ -88,7 +96,9 @@ let commitment_secret = |> WithExceptions.Option.get ~loc:__LOC__ let new_commitment ?seed () = - let pkh, pk, sk = Signature.generate_key ?seed ~algo:Ed25519 () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ?seed ~algo:Ed25519 () + in let unactivated_account = {pkh; pk; sk} in let open Commitment in let pkh = match pkh with Ed25519 pkh -> pkh | _ -> assert false in diff --git a/src/proto_alpha/lib_protocol/test/helpers/account.mli b/src/proto_alpha/lib_protocol/test/helpers/account.mli index 03f9c997c4b3..d0781041c075 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/account.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/account.mli @@ -27,14 +27,14 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -val known_accounts : t Signature.Public_key_hash.Table.t +val known_accounts : t Tezos_crypto.Signature.Public_key_hash.Table.t val activator_account : account @@ -47,9 +47,9 @@ val new_account : ?rng_state:Random.State.t -> ?seed:Bytes.t -> unit -> account val add_account : t -> unit -val find : Signature.Public_key_hash.t -> t tzresult Lwt.t +val find : Tezos_crypto.Signature.Public_key_hash.t -> t tzresult Lwt.t -val find_alternate : Signature.Public_key_hash.t -> t +val find_alternate : Tezos_crypto.Signature.Public_key_hash.t -> t (** 4.000.000.000 tez *) val default_initial_balance : Tez.t @@ -66,7 +66,7 @@ val new_commitment : ?seed:Bytes.t -> unit -> (account * Commitment.t) tzresult Lwt.t (** Fails if the contract is not an implicit one *) -val pkh_of_contract_exn : Contract.t -> Signature.Public_key_hash.t +val pkh_of_contract_exn : Contract.t -> Tezos_crypto.Signature.Public_key_hash.t (** [make_bootstrap_account ~initial_balance ~delegate_to account] creates a {!Parameters.bootstrap_account} from an account with the default or set @@ -75,8 +75,8 @@ val pkh_of_contract_exn : Contract.t -> Signature.Public_key_hash.t *) val make_bootstrap_account : ?balance:Tez.t -> - ?delegate_to:Signature.public_key_hash option -> - ?consensus_key:Signature.public_key option -> + ?delegate_to:Tezos_crypto.Signature.public_key_hash option -> + ?consensus_key:Tezos_crypto.Signature.public_key option -> t -> Parameters.bootstrap_account @@ -88,7 +88,7 @@ val make_bootstrap_account : *) val make_bootstrap_accounts : ?bootstrap_balances:int64 list -> - ?bootstrap_delegations:Signature.public_key_hash option list -> - ?bootstrap_consensus_keys:Signature.public_key option list -> + ?bootstrap_delegations:Tezos_crypto.Signature.public_key_hash option list -> + ?bootstrap_consensus_keys:Tezos_crypto.Signature.public_key option list -> t list -> Parameters.bootstrap_account list diff --git a/src/proto_alpha/lib_protocol/test/helpers/assert.ml b/src/proto_alpha/lib_protocol/test/helpers/assert.ml index 9350839c633a..31db55d5c35d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/assert.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/assert.ml @@ -160,32 +160,34 @@ let not_equal_tez ~loc (a : Alpha_context.Tez.t) (b : Alpha_context.Tez.t) = not_equal ~loc Tez.( = ) "Tez are equal" Tez.pp a b (* pkh *) -let equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in equal ~loc PKH.equal "Public key hashes aren't equal" PKH.pp a b -let not_equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let not_equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in not_equal ~loc PKH.equal "Public key hashes are equal" PKH.pp a b (* protocol hash *) -let equal_protocol_hash ~loc (a : Protocol_hash.t) (b : Protocol_hash.t) = +let equal_protocol_hash ~loc (a : Tezos_crypto.Protocol_hash.t) + (b : Tezos_crypto.Protocol_hash.t) = equal ~loc - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Protocol hashes aren't equal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp a b -let not_equal_protocol_hash ~loc (a : Protocol_hash.t) (b : Protocol_hash.t) = +let not_equal_protocol_hash ~loc (a : Tezos_crypto.Protocol_hash.t) + (b : Tezos_crypto.Protocol_hash.t) = not_equal ~loc - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Protocol hashes are equal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp a b diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index d5df501c2a0f..9db235adbebc 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -31,7 +31,7 @@ open Alpha_context (* This type collects a block and the context that results from its application *) type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; @@ -93,7 +93,11 @@ let get_next_baker_by_account pkh block = >>=? fun bakers -> (match List.hd bakers with | Some b -> return b - | None -> failwith "No slots found for %a" Signature.Public_key_hash.pp pkh) + | None -> + failwith + "No slots found for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh) >>=? fun { Plugin.RPC.Baking_rights.delegate = pkh; consensus_key; @@ -122,7 +126,7 @@ let get_next_baker_excluding excludes block = (fun {Plugin.RPC.Baking_rights.consensus_key; _} -> not (List.mem - ~equal:Signature.Public_key_hash.equal + ~equal:Tezos_crypto.Signature.Public_key_hash.equal consensus_key excludes)) bakers @@ -181,7 +185,7 @@ module Forge = struct (* We don't care of the following values, only the shell validates them. *) proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } let set_seed_nonce_hash seed_nonce_hash @@ -199,8 +203,9 @@ module Forge = struct (shell, contents) in let signature = - Signature.sign - ~watermark:Block_header.(to_watermark (Block_header Chain_id.zero)) + Tezos_crypto.Signature.sign + ~watermark: + Block_header.(to_watermark (Block_header Tezos_crypto.Chain_id.zero)) signer_account.sk unsigned_bytes in @@ -242,7 +247,8 @@ module Forge = struct >|=? fun seed_nonce_hash -> let hashes = List.map Operation.hash_packed operations in let operations_hash = - Operation_list_list_hash.compute [Operation_list_hash.compute hashes] + Tezos_crypto.Operation_list_list_hash.compute + [Tezos_crypto.Operation_list_hash.compute hashes] in let shell = make_shell @@ -391,13 +397,13 @@ let initial_alpha_context ?(commitments = []) constants ~typecheck ~level ~timestamp - Chain_id.zero + Tezos_crypto.Chain_id.zero ctxt >|= Environment.wrap_tzresult let genesis_with_parameters parameters = let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let fitness = @@ -413,7 +419,7 @@ let genesis_with_parameters parameters = ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in let contents = Forge.make_contents @@ -432,12 +438,16 @@ let genesis_with_parameters parameters = add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> - let chain_id = Chain_id.of_block_hash hash in + let chain_id = Tezos_crypto.Chain_id.of_block_hash hash in Main.init chain_id ctxt shell >|= Environment.wrap_tzresult >|=? fun {context; _} -> { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } @@ -582,7 +592,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum in check_constants_consistency constants >>=? fun () -> let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let level = Option.value ~default:0l level in @@ -599,7 +609,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in return (constants, shell, hash) @@ -642,7 +652,7 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum initial_context ?commitments ?bootstrap_contracts - (Chain_id.of_block_hash hash) + (Tezos_crypto.Chain_id.of_block_hash hash) constants shell bootstrap_accounts @@ -656,7 +666,11 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum in { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } @@ -683,7 +697,7 @@ let get_application_vstate (pred : t) (operations : Protocol.operation trace) = let open Environment.Error_monad in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >|= Environment.wrap_tzresult @@ -705,7 +719,7 @@ let get_construction_vstate ?(policy = By_round 0) ?timestamp in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero mode ~predecessor:pred.header.shell >|= Environment.wrap_tzresult @@ -767,7 +781,7 @@ let apply_with_metadata ?(policy = By_round 0) ?(check_size = true) ~baking_mode | Application -> begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >|= Environment.wrap_tzresult diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 3305024728ee..110b9588ff95 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -29,7 +29,7 @@ open Protocol open Alpha_context type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; (** Resulting context *) @@ -103,7 +103,7 @@ module Forge : sig (** Sets the baker that will sign the header to an arbitrary pkh *) val set_baker : public_key_hash -> - ?consensus_key:Signature.public_key_hash -> + ?consensus_key:Tezos_crypto.Signature.public_key_hash -> header -> header @@ -295,7 +295,9 @@ val prepare_initial_context_params : ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> unit -> - ( Constants.Parametric.t * Block_header.shell_header * Block_hash.t, + ( Constants.Parametric.t + * Block_header.shell_header + * Tezos_crypto.Block_hash.t, tztrace ) result Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index ff375c4acd01..c15c0b74ee2c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -136,7 +136,8 @@ let get_endorser_slot ctxt pkh = List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.(delegate = pkh) then Some slots + if Tezos_crypto.Signature.Public_key_hash.(delegate = pkh) then + Some slots else None) endorsers @@ -152,7 +153,7 @@ let get_endorsing_power_for_delegate ctxt ?levels pkh = let rec find_slots_for_delegate = function | [] -> return 0 | {Plugin.RPC.Validators.delegate; slots; _} :: t -> - if Signature.Public_key_hash.equal delegate pkh then + if Tezos_crypto.Signature.Public_key_hash.equal delegate pkh then return (List.length slots) else find_slots_for_delegate t in @@ -175,7 +176,8 @@ let get_baker ctxt ~round = let get_first_different_baker baker bakers = WithExceptions.Option.get ~loc:__LOC__ @@ List.find - (fun baker' -> Signature.Public_key_hash.( <> ) baker baker') + (fun baker' -> + Tezos_crypto.Signature.Public_key_hash.( <> ) baker baker') bakers let get_first_different_bakers ctxt = @@ -270,7 +272,7 @@ module Vote = struct type delegate_info = Alpha_context.Vote.delegate_info = { voting_power : Int64.t option; current_ballot : Alpha_context.Vote.ballot option; - current_proposals : Protocol_hash.t list; + current_proposals : Tezos_crypto.Protocol_hash.t list; remaining_proposals : int; } @@ -349,8 +351,9 @@ module Delegate = struct deactivated : bool; grace_period : Cycle.t; voting_info : Alpha_context.Vote.delegate_info; - active_consensus_key : Signature.Public_key_hash.t; - pending_consensus_keys : (Cycle.t * Signature.Public_key_hash.t) list; + active_consensus_key : Tezos_crypto.Signature.Public_key_hash.t; + pending_consensus_keys : + (Cycle.t * Tezos_crypto.Signature.Public_key_hash.t) list; } let info ctxt pkh = Delegate_services.info rpc_ctxt ctxt pkh @@ -588,7 +591,7 @@ let default_raw_context () = >>= fun context -> let typecheck ctxt script_repr = return ((script_repr, None), ctxt) in Init_storage.prepare_first_block - Chain_id.zero + Tezos_crypto.Chain_id.zero context ~level:0l ~timestamp:(Time.Protocol.of_seconds 1643125688L) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 22366748fc54..34ac44f4391d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -30,7 +30,7 @@ open Environment type t = B of Block.t | I of Incremental.t -val branch : t -> Block_hash.t +val branch : t -> Tezos_crypto.Block_hash.t val get_level : t -> Raw_level.t tzresult @@ -112,7 +112,8 @@ module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t val get_ballot_list : - t -> (Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t + t -> + (Tezos_crypto.Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t val get_current_period : t -> Voting_period.info tzresult Lwt.t @@ -121,20 +122,21 @@ module Vote : sig val get_participation_ema : Block.t -> int32 tzresult Lwt.t val get_listings : - t -> (Signature.Public_key_hash.t * int64) list tzresult Lwt.t + t -> (Tezos_crypto.Signature.Public_key_hash.t * int64) list tzresult Lwt.t val get_proposals : t -> int64 Protocol_hash.Map.t tzresult Lwt.t - val get_current_proposal : t -> Protocol_hash.t option tzresult Lwt.t + val get_current_proposal : + t -> Tezos_crypto.Protocol_hash.t option tzresult Lwt.t - val get_protocol : Block.t -> Protocol_hash.t Lwt.t + val get_protocol : Block.t -> Tezos_crypto.Protocol_hash.t Lwt.t val set_participation_ema : Block.t -> int32 -> Block.t Lwt.t type delegate_info = Alpha_context.Vote.delegate_info = { voting_power : Int64.t option; current_ballot : Alpha_context.Vote.ballot option; - current_proposals : Protocol_hash.t list; + current_proposals : Tezos_crypto.Protocol_hash.t list; remaining_proposals : int; } @@ -190,8 +192,9 @@ module Delegate : sig deactivated : bool; grace_period : Cycle.t; voting_info : Vote.delegate_info; - active_consensus_key : Signature.Public_key_hash.t; - pending_consensus_keys : (Cycle.t * Signature.Public_key_hash.t) list; + active_consensus_key : Tezos_crypto.Signature.Public_key_hash.t; + pending_consensus_keys : + (Cycle.t * Tezos_crypto.Signature.Public_key_hash.t) list; } val info : t -> public_key_hash -> Delegate_services.info tzresult Lwt.t @@ -259,14 +262,17 @@ module Sc_rollup : sig val timeout : t -> Sc_rollup.t -> - Signature.Public_key_hash.t * Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key_hash.t -> Sc_rollup.Game.timeout option tzresult Lwt.t val ongoing_game_for_staker : t -> Sc_rollup.t -> - Signature.public_key_hash -> - (Sc_rollup.Game.t * Signature.public_key_hash * Signature.public_key_hash) + Tezos_crypto.Signature.public_key_hash -> + (Sc_rollup.Game.t + * Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key_hash) option tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml index f7d8dd45bc64..f7d6c63dab2a 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/contract_helpers.ml @@ -67,7 +67,7 @@ let fake_KT1 = let default_self = fake_KT1 -let default_payer = Signature.Public_key_hash.zero +let default_payer = Tezos_crypto.Signature.Public_key_hash.zero let default_source = Contract.Implicit default_payer @@ -79,7 +79,7 @@ let default_step_constants = self = default_self; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_alpha/lib_protocol/test/helpers/dummy_zk_rollup.ml b/src/proto_alpha/lib_protocol/test/helpers/dummy_zk_rollup.ml index 3cfbe83f84f9..70410cca39ce 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dummy_zk_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/dummy_zk_rollup.ml @@ -201,8 +201,8 @@ module Types = struct conv (fun pkhu -> pkhu) (fun w -> w) - (encoding_to_scalar Signature.Public_key_hash.encoding) - (encoding_of_scalar Signature.Public_key_hash.encoding) + (encoding_to_scalar Tezos_crypto.Signature.Public_key_hash.encoding) + (encoding_of_scalar Tezos_crypto.Signature.Public_key_hash.encoding) scalar_encoding let amount_encoding ~safety = Bounded_e.encoding ~safety Bound.bound_amount @@ -596,7 +596,7 @@ end = struct {id; amount = Z.zero}); l1_dst = Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding dummy_l1_dst; rollup_id = Data_encoding.Binary.of_bytes_exn diff --git a/src/proto_alpha/lib_protocol/test/helpers/expr_common.ml b/src/proto_alpha/lib_protocol/test/helpers/expr_common.ml index 554bba47ce07..e6444892c600 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/expr_common.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/expr_common.ml @@ -78,7 +78,7 @@ let big_map_id ?(loc = 0) id = int ~loc @@ Big_map.Id.unparse_to_z id let timestamp_of_zint zint = Script_timestamp.of_zint zint let public_key_of_bytes_exn b = - Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding b + Data_encoding.Binary.of_bytes_exn Tezos_crypto.Signature.Public_key.encoding b let address_of_bytes_exn b = Data_encoding.Binary.of_bytes_exn Contract.encoding b diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml index 506b8e617094..3baf20c3a523 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -54,7 +54,7 @@ let rpc_context st = let fitness = (header st).shell.fitness in let result = Alpha_context.finalize (alpha_ctxt st) fitness in { - Environment.Updater.block_hash = Block_hash.zero; + Environment.Updater.block_hash = Tezos_crypto.Block_hash.zero; block_header = {st.header.shell with fitness = result.fitness}; context = result.context; } @@ -100,7 +100,7 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) Partial_construction {predecessor_hash = predecessor.hash; timestamp} else let block_header_data = - {Block_header.contents; signature = Signature.zero} + {Block_header.contents; signature = Tezos_crypto.Signature.zero} in Construction {predecessor_hash = predecessor.hash; timestamp; block_header_data} @@ -115,15 +115,15 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) fitness = predecessor.header.shell.fitness; timestamp; level = predecessor.header.shell.level; - context = Context_hash.zero; - operations_hash = Operation_list_list_hash.zero; + context = Tezos_crypto.Context_hash.zero; + operations_hash = Tezos_crypto.Operation_list_list_hash.zero; }; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in begin_validation_and_application predecessor.context - Chain_id.zero + Tezos_crypto.Chain_id.zero mode ~predecessor:predecessor.header.shell >|= fun state -> @@ -240,8 +240,11 @@ let finalize_block st = let open Lwt_result_syntax in let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let shell_header = { @@ -256,8 +259,11 @@ let finalize_block st = let*? validation_result, _ = Environment.wrap_tzresult res in let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let header = { diff --git a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml index c0feb9d7e5ab..5ee590fa6812 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml @@ -390,13 +390,13 @@ let total_xtz = 32_000_000_000_000L let tzbtc_admin_account : Account.t = { pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; sk = - Signature.Secret_key.of_b58check_exn + Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"; } diff --git a/src/proto_alpha/lib_protocol/test/helpers/lqt_fa12_repr.ml b/src/proto_alpha/lib_protocol/test/helpers/lqt_fa12_repr.ml index af27ec2e2e93..168bbb43dac6 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/lqt_fa12_repr.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/lqt_fa12_repr.ml @@ -135,7 +135,7 @@ module Storage = struct { tokens = Big_map.Id.parse_z Z.zero; allowances = Big_map.Id.parse_z Z.one; - admin = Contract.Implicit Signature.Public_key_hash.zero; + admin = Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero; totalSupply = Z.zero; } diff --git a/src/proto_alpha/lib_protocol/test/helpers/nonce.ml b/src/proto_alpha/lib_protocol/test/helpers/nonce.ml index 695cdcdbbec9..23edb62e017f 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/nonce.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/nonce.ml @@ -22,7 +22,7 @@ let known_nonces = Table.create 17 let generate () = match Alpha_context.Nonce.of_bytes - @@ Rand.generate Alpha_context.Constants.nonce_length + @@ Tezos_crypto.Rand.generate Alpha_context.Constants.nonce_length with | Ok nonce -> let hash = Alpha_context.Nonce.hash nonce in diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 474269a4058e..e9dc7de381d9 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -31,14 +31,15 @@ let pack_operation ctxt signature contents = Operation.pack ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) -let sign ?(watermark = Signature.Generic_operation) sk ctxt contents = +let sign ?(watermark = Tezos_crypto.Signature.Generic_operation) sk ctxt + contents = let branch = Context.branch ctxt in let unsigned = Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding ({branch}, Contents_list contents) in - let signature = Some (Signature.sign ~watermark sk unsigned) in + let signature = Some (Tezos_crypto.Signature.sign ~watermark sk unsigned) in ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) (** Generates the block payload hash based on the hash [pred_hash] of @@ -81,7 +82,8 @@ let endorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Endorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Endorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -114,7 +116,8 @@ let preendorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Preendorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Preendorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -190,7 +193,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt assert ( List.for_all (fun {shell = {Tezos_base.Operation.branch = b; _}; _} -> - Block_hash.(branch = b)) + Tezos_crypto.Block_hash.(branch = b)) packed_operations) ; (* TODO? : check signatures consistency *) let unpacked_operations = @@ -219,7 +222,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt let reveal_op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -288,7 +291,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter; operation; @@ -304,7 +307,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op_reveal = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -315,7 +318,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter = Manager_counter.succ counter; operation; @@ -334,7 +337,7 @@ let revelation ?(fee = Tez.zero) ?(gas_limit = High) ?(storage_limit = Z.zero) let pkh = match forge_pkh with | Some pkh -> pkh - | None -> Signature.Public_key.hash public_key + | None -> Tezos_crypto.Signature.Public_key.hash public_key in resolve_gas_limit ctxt gas_limit >>=? fun gas_limit -> let source = Contract.Implicit pkh in @@ -501,14 +504,15 @@ let increase_paid_storage ?force_reveal ?counter ?fee ?gas_limit ?storage_limit Context.Contract.manager ctxt source >|=? fun account -> sign account.sk ctxt sop -let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code = +let activation ctxt (pkh : Tezos_crypto.Signature.Public_key_hash.t) + activation_code = (match pkh with | Ed25519 edpkh -> return edpkh | _ -> failwith "Wrong public key hash : %a - Commitments must be activated with an \ - Ed25519 encrypted public key hash" - Signature.Public_key_hash.pp + Tezos_crypto.Ed25519 encrypted public key hash" + Tezos_crypto.Signature.Public_key_hash.pp pkh) >|=? fun id -> let contents = Single (Activate_account {id; activation_code}) in diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index 58806cb4fe9a..13760980995c 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -45,8 +45,8 @@ val pack_operation : Context.t -> signature option -> 'a contents_list -> packed_operation val sign : - ?watermark:Signature.watermark -> - Signature.secret_key -> + ?watermark:Tezos_crypto.Signature.watermark -> + Tezos_crypto.Signature.secret_key -> Context.t -> packed_contents_list -> packed_operation @@ -245,7 +245,7 @@ val originated_contract : Operation.packed -> Contract.t val register_global_constant : ?force_reveal:bool -> ?counter:Manager_counter.t -> - ?public_key:Signature.public_key -> + ?public_key:Tezos_crypto.Signature.public_key -> ?fee:Tez.tez -> ?gas_limit:gas_limit -> ?storage_limit:Z.t -> @@ -276,7 +276,7 @@ val double_baking : val activation : Context.t -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Blinded_public_key_hash.activation_code -> Operation.packed tzresult Lwt.t @@ -316,7 +316,7 @@ val proposals_contents : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals contents_list tzresult Lwt.t (** Craft a Proposals operation. @@ -329,7 +329,7 @@ val proposals : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Operation.packed tzresult Lwt.t (** Craft the [contents_list] for a Ballot operation. @@ -342,7 +342,7 @@ val ballot_contents : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot contents_list tzresult Lwt.t @@ -356,7 +356,7 @@ val ballot : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Operation.packed tzresult Lwt.t @@ -496,7 +496,7 @@ val tx_rollup_dispatch_tickets : message_result_path:Tx_rollup_commitment.Merkle.path -> Tx_rollup.t -> Tx_rollup_level.t -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tx_rollup_reveal.t list -> (packed_operation, tztrace) result Lwt.t @@ -761,9 +761,9 @@ val update_consensus_key : val drain_delegate : Context.t -> - consensus_key:Signature.Public_key_hash.t -> - delegate:Signature.Public_key_hash.t -> - destination:Signature.Public_key_hash.t -> + consensus_key:Tezos_crypto.Signature.Public_key_hash.t -> + delegate:Tezos_crypto.Signature.Public_key_hash.t -> + destination:Tezos_crypto.Signature.Public_key_hash.t -> packed_operation tzresult Lwt.t (** [zk_rollup_publish ctxt source ~zk_rollup ~op] tries to add an operation diff --git a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml index 1a954c098f95..9861e63e77ec 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/operation_generator.ml @@ -121,7 +121,7 @@ let pp_kind fmt k = let block_hashes = List.map - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn [ "BLbcVY1kYiKQy2MJJfoHJMN2xRk5QPG1PEKWMDSyW2JMxBsMmiL"; "BLFhLKqQQn32Cc9QXqtEqysYqWNCowNKaypVHP5zEyZcywbXcHo"; @@ -141,7 +141,7 @@ let random_payload_hash = QCheck2.Gen.oneofl payload_hashes let signatures = List.map - Signature.of_b58check_exn + Tezos_crypto.Signature.of_b58check_exn [ "sigaNsiye7D8dJHKSQZBwDbS2aQNXipDP7bw8uQnMgnaXi5pcnoPZRKXrDeFRx4FjWJD2xfyUA9CuBXhwPHhVs7LxkL4vT32"; "sigvtPBMQvk2DgNtu3AKFU1ZRsagGxsoiZVQyQhJNEojReBY2vE5sDwt3H7Mh8RMe27QHBjemxqhMVVszZqpNsdDux6KAELX"; @@ -152,7 +152,7 @@ let random_signature = QCheck2.Gen.oneofl signatures let pkhs = List.map - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn [ "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; "tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv"; @@ -163,7 +163,7 @@ let random_pkh = QCheck2.Gen.oneofl pkhs let pks = List.map - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn [ "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"; "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"; @@ -227,7 +227,7 @@ let random_sc_rollup = QCheck2.Gen.oneofl sc_rollups let protos = List.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [ "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -442,7 +442,11 @@ let generate_activate_account = let open QCheck2.Gen in let* activation_code = random_code in let+ id = random_pkh in - let id = match id with Signature.Ed25519 pkh -> pkh | _ -> assert false in + let id = + match id with + | Tezos_crypto.Signature.Ed25519 pkh -> pkh + | _ -> assert false + in Activate_account {id; activation_code} let random_period = @@ -576,7 +580,7 @@ let generate_tx_rollup_rejection = { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } in @@ -614,7 +618,7 @@ let generate_tx_dispatch_tickets = let level = Tx_rollup_level.root in let message_index = 0 in let message_result_path = Tx_rollup_commitment.Merkle.dummy_path in - let context_hash = Context_hash.zero in + let context_hash = Tezos_crypto.Context_hash.zero in let reveal = Tx_rollup_reveal. { diff --git a/src/proto_alpha/lib_protocol/test/helpers/sapling_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/sapling_helpers.ml index 4d07ce051426..0f256cd31ce0 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/sapling_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/sapling_helpers.ml @@ -117,7 +117,7 @@ module Common = struct let payload_enc = Data_encoding.Binary.to_bytes_exn Data_encoding.bytes - (Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) + (Tezos_crypto.Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) in Data_encoding.Binary.of_bytes_exn Ciphertext.encoding @@ -353,7 +353,12 @@ module Interpreter_helpers = struct let originate_contract_hash file storage src b baker = originate_contract_hash file storage src b baker >|=? fun (dst, b) -> let anti_replay = - Format.asprintf "%a%a" Contract_hash.pp dst Chain_id.pp Chain_id.zero + Format.asprintf + "%a%a" + Contract_hash.pp + dst + Tezos_crypto.Chain_id.pp + Tezos_crypto.Chain_id.zero in (dst, b, anti_replay) diff --git a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml index d588feb4155a..3b3dbdedb577 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml @@ -447,7 +447,9 @@ module Tree_inbox = struct let commit_tree store key tree = let open Lwt_syntax in let* store = Store.add_tree store key tree in - let* (_ : Context_hash.t) = Store.commit ~time:Time.Protocol.epoch store in + let* (_ : Tezos_crypto.Context_hash.t) = + Store.commit ~time:Time.Protocol.epoch store + in return () let lookup_tree store hash = diff --git a/src/proto_alpha/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml index af75636ef346..22acc5dfcb67 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml @@ -96,10 +96,11 @@ let empty_context : Context_l2.t = empty_storage let rng_state = Random.State.make_self_init () -let gen_l1_address ?seed () = Signature.generate_key ~algo:Ed25519 ?seed () +let gen_l1_address ?seed () = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ?seed () let gen_l2_address () = - let pkh, public_key, secret_key = Bls.generate_key () in + let pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key () in (secret_key, public_key, pkh) (** [make_unit_ticket_key ctxt ticketer l2_address] computes the key hash of @@ -153,7 +154,7 @@ let gen_n_ticket_hash n = | Error _ -> raise (Invalid_argument "Failed to forge tickets") let sign_transaction : - Bls.Secret_key.t list -> + Tezos_crypto.Bls.Secret_key.t list -> ('signer, 'content) Tx_rollup_l2_batch.V1.transaction -> Tx_rollup_l2_batch.V1.signature list = fun sks transaction -> @@ -165,7 +166,7 @@ let sign_transaction : Tx_rollup_l2_batch.V1.transaction_encoding transaction in - List.map (fun sk -> Bls.sign sk buf) sks + List.map (fun sk -> Tezos_crypto.Bls.sign sk buf) sks type Environment.Error_monad.error += Test_error of string diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml index b8f234ad0641..9b994f926adf 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_baking.ml @@ -172,7 +172,7 @@ let get_contract_for_pkh contracts pkh = | [] -> assert false | c :: t -> let c_pkh = Context.Contract.pkh c in - if Signature.Public_key_hash.equal c_pkh pkh then return c + if Tezos_crypto.Signature.Public_key_hash.equal c_pkh pkh then return c else find_contract t in find_contract contracts @@ -227,7 +227,7 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposit -> Context.get_baking_reward_fixed_portion (B b2) >>=? fun baking_reward -> Context.get_bonus_reward (B b2) ~endorsing_power >>=? fun bonus_reward -> - (if Signature.Public_key_hash.equal baker_b2 baker_b1 then + (if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then Context.get_baking_reward_fixed_portion (B b1) else return Tez.zero) >>=? fun reward_for_b1 -> @@ -271,7 +271,8 @@ let test_rewards_block_and_payload_producer () = Context.Delegate.current_frozen_deposits (B b2') baker_b2 >>=? fun frozen_deposit -> let reward_for_b1 = - if Signature.Public_key_hash.equal baker_b2 baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then + baking_reward else Tez.zero in let expected_balance = @@ -288,7 +289,8 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposits' -> Context.get_baker (B genesis) ~round:Round.zero >>=? fun baker_b1 -> let reward_for_b1' = - if Signature.Public_key_hash.equal baker_b2' baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2' baker_b1 then + baking_reward else Tez.zero in let expected_balance' = @@ -394,7 +396,7 @@ let test_committee_sampling () = Format.fprintf ppf "@[- %a %d%a@]@," - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh n (fun ppf failed -> diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml index 393330708fea..a8fa7b8e547b 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_deactivation.ml @@ -311,7 +311,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a1 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m1.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m1.pkh)) ; let constants = Default_parameters.constants_test in let minimal_stake = constants.minimal_stake in Op.transaction ~force_reveal:true (B b) a1 a3 minimal_stake @@ -325,7 +325,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a3 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m3.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m3.pkh)) ; check_active_staking_balance ~loc:__LOC__ ~deactivated:false b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m1 diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml index c2524e1284f6..ec65b7f90731 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -52,7 +52,7 @@ let block_fork ?policy (contract_a, contract_b) b = let order_block_hashes ~correct_order bh1 bh2 = let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in - let c = Block_hash.compare hash1 hash2 in + let c = Tezos_crypto.Block_hash.compare hash1 hash2 in if correct_order then if c < 0 then (bh1, bh2) else (bh2, bh1) else if c < 0 then (bh2, bh1) else (bh1, bh2) @@ -95,7 +95,7 @@ let test_valid_double_baking_evidence () = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -119,7 +119,7 @@ let test_valid_double_baking_followed_by_double_endorsing () = >>=? fun blk_with_db_evidence -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in @@ -168,7 +168,7 @@ let test_valid_double_endorsing_followed_by_double_baking () = Block.bake blk_2 >>=? fun blk_b -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml index 73a28b74b618..2cf9adeb10e0 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -52,7 +52,7 @@ let block_fork b = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -254,8 +254,11 @@ let test_different_delegates () = Context.get_first_different_endorsers (B blk_b) >>=? fun (endorser_b1c, endorser_b2c) -> let endorser_b, b_slots = - if Signature.Public_key_hash.( = ) endorser_a endorser_b1c.delegate then - (endorser_b2c.delegate, endorser_b2c.slots) + if + Tezos_crypto.Signature.Public_key_hash.( = ) + endorser_a + endorser_b1c.delegate + then (endorser_b2c.delegate, endorser_b2c.slots) else (endorser_b1c.delegate, endorser_b1c.slots) in Op.endorsement @@ -296,7 +299,7 @@ let test_wrong_delegate () = Context.get_endorser_n (B blk_b) 0 >>=? fun (endorser0, slots0) -> Context.get_endorser_n (B blk_b) 1 >>=? fun (endorser1, slots1) -> let endorser_b, b_slots = - if Signature.Public_key_hash.equal endorser_a endorser0 then + if Tezos_crypto.Signature.Public_key_hash.equal endorser_a endorser0 then (endorser1, slots1) else (endorser0, slots0) in @@ -320,8 +323,11 @@ let test_freeze_more_with_low_balance = Context.get_endorsers ctxt >>=? function | [d1; d2] -> return - (if Signature.Public_key_hash.equal account d1.delegate then d1 - else if Signature.Public_key_hash.equal account d2.delegate then d2 + (if Tezos_crypto.Signature.Public_key_hash.equal account d1.delegate + then d1 + else if + Tezos_crypto.Signature.Public_key_hash.equal account d2.delegate + then d2 else assert false) .slots | _ -> assert false @@ -352,7 +358,8 @@ let test_freeze_more_with_low_balance = in let check_unique_endorser b account2 = Context.get_endorsers (B b) >>=? function - | [{delegate; _}] when Signature.Public_key_hash.equal account2 delegate -> + | [{delegate; _}] + when Tezos_crypto.Signature.Public_key_hash.equal account2 delegate -> return_unit | _ -> failwith "We are supposed to only have account2 as endorser." in diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml index 07bee3fa71cb..bf01ef688b7b 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_double_preendorsement.ml @@ -150,7 +150,7 @@ end = struct let denun_reward = Test_tez.(lost_deposit /! 2L) in (* if the baker is the endorser, he'll only loose half of the deposits *) let expected_endo_loss = - if Signature.Public_key_hash.equal baker d1 then + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then Test_tez.(lost_deposit -! denun_reward) else lost_deposit in @@ -164,7 +164,8 @@ end = struct burnt deposit of d1, so it's higher *) let high, low = - if Signature.Public_key_hash.equal baker d1 then (bal_good, bal_bad) + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then + (bal_good, bal_bad) else (bal_bad, bal_good) in let diff_baker = Test_tez.(high -! low) in @@ -176,7 +177,7 @@ end = struct let order_preendorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml index 7b39c2bfed10..93c4b456c302 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_participation.ml @@ -42,7 +42,7 @@ let bake_and_endorse_once (b_pred, b_cur) baker endorser = List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.equal delegate endorser then + if Tezos_crypto.Signature.Public_key_hash.equal delegate endorser then Some (delegate, slots) else None) endorsers_list diff --git a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml index c7c7f2ed7729..9fe85ead49c5 100644 --- a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml +++ b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml @@ -54,7 +54,7 @@ let dummy_map = let dummy_timestamp = Script_timestamp.of_zint (Z.of_int 42) let dummy_pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" let dummy_bytes = Bytes.of_string "dummy" 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 03ecdb5c72d2..78100c3c5f81 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 @@ -218,7 +218,7 @@ let apply_with_gas header ?(operations = []) (pred : Block.t) = (let open Environment.Error_monad in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >>=? fun vstate -> diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_interpretation.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_interpretation.ml index 302eb4dcac7b..ebb8358c3f49 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_interpretation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_interpretation.ml @@ -204,7 +204,9 @@ let test_json_roundtrip_err name e () = e let error_encoding_tests = - let contract_zero = Contract.Implicit Signature.Public_key_hash.zero in + let contract_zero = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero + in let script_expr_int = Micheline.strip_locations (Micheline.Int (0, Z.zero)) in List.map (fun (name, e) -> diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml index 9db7896a733e..a07a2e425536 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_sapling.ml @@ -279,7 +279,7 @@ module Raw_context_tests = struct let gen_root () = Data_encoding.Binary.of_bytes_exn Validator.Hash.encoding - (Hacl.Rand.gen 32) + (Tezos_crypto.Hacl.Rand.gen 32) in let roots_ctx = WithExceptions.List.init diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index 4f455ac1b9f2..909af1a1e6bd 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -234,7 +234,7 @@ let check_value_size () = =========== *) @ (let show fmt (Script_typed_ir.Script_signature.Signature_tag s) = - Signature.pp fmt s + Tezos_crypto.Signature.pp fmt s in exs ~error:8 nsample show Signature_t ": signature") (* @@ -259,13 +259,13 @@ let check_value_size () = Key_hash_t ========== *) - @ (let show = Signature.Public_key_hash.pp in + @ (let show = Tezos_crypto.Signature.Public_key_hash.pp in exs nsample show Key_hash_t ": key_hash") (* Key_t ===== *) - @ (let show = Signature.Public_key.pp in + @ (let show = Tezos_crypto.Signature.Public_key.pp in exs nsample show Key_t ": key_t") (* Timestamp_t diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml index b8ae0972f0ef..aedf33233b86 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml @@ -40,7 +40,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_manager.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_manager.ml index 37103dd9ebcd..eca8fee374a4 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_manager.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_manager.ml @@ -46,7 +46,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_timelock.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_timelock.ml index bfb059e6f9b4..f72e3983caef 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_timelock.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_timelock.ml @@ -25,7 +25,7 @@ (** Testing ------- - Component: Protocol (Timelock) + Component: Protocol (Tezos_crypto.Timelock) Invocation: cd src/proto_alpha/lib_protocol/test/integration/michelson && \ dune exec ./main.exe -- test "^timelock$" Subject: On timelock @@ -37,20 +37,29 @@ open Lwt_result_syntax let wrap e = Lwt.return (Environment.wrap_tzresult e) let simple_test () = - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value in assert (unlocked_value = same_unlocked) ; - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value + in let message = Bytes.create 12 in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let expected_result = Environment.Timelock.Correct message in - let chest_key = Timelock.{unlocked_value; proof} in - let chest = Timelock.{locked_value; rsa_public = public; ciphertext = c} in + let chest_key = Tezos_crypto.Timelock.{unlocked_value; proof} in + let chest = + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} + in let result = Environment.Timelock.open_chest chest chest_key ~time in assert (result = expected_result) ; return_unit @@ -93,30 +102,39 @@ let contract_test () = ~baker block in - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let _same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value + in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value in - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in let message = Bytes.of_string "this is my message" in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let check_storage chest chest_key expected_storage_hexa = let chest_key_bytes = "0x" ^ Hex.show (Hex.of_bytes (Data_encoding.Binary.to_bytes_exn - Timelock.chest_key_encoding + Tezos_crypto.Timelock.chest_key_encoding chest_key)) in let chest_bytes = "0x" ^ Hex.show (Hex.of_bytes - (Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest)) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest)) in let michelson_string = Format.sprintf "(Pair %s %s )" chest_key_bytes chest_bytes @@ -150,9 +168,9 @@ let contract_test () = assert (to_check = expected_storage_hexa) ; return_unit in - let chest_key_correct = Timelock.{unlocked_value; proof} in + let chest_key_correct = Tezos_crypto.Timelock.{unlocked_value; proof} in let chest_correct = - Timelock.{locked_value; rsa_public = public; ciphertext = c} + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} in check_storage chest_correct @@ -160,25 +178,36 @@ let contract_test () = (Hex.show (Hex.of_bytes message)) >>=? fun () -> (* We redo an RSA parameters generation to create incorrect cipher and proof *) - let public_bogus, secret_bogus = Timelock.gen_rsa_keys () in - let locked_value_bogus = Timelock.gen_locked_value public_bogus in + let public_bogus, secret_bogus = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value_bogus = + Tezos_crypto.Timelock.gen_locked_value public_bogus + in let time = 1000 in let unlocked_value_bogus = - Timelock.unlock_with_secret secret_bogus ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_with_secret + secret_bogus + ~time + locked_value_bogus in let _same_unlocked, proof_bogus = - Timelock.unlock_and_prove_without_secret public ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value_bogus in let sym_key_bogus = - Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus in - let c_bogus = Timelock.encrypt sym_key_bogus message in + let c_bogus = Tezos_crypto.Timelock.encrypt sym_key_bogus message in let chest_incorrect = - Timelock.{locked_value; rsa_public = public; ciphertext = c_bogus} + Tezos_crypto.Timelock. + {locked_value; rsa_public = public; ciphertext = c_bogus} in check_storage chest_incorrect chest_key_correct "00" >>=? fun () -> - let chest_key_incorrect = Timelock.{unlocked_value; proof = proof_bogus} in + let chest_key_incorrect = + Tezos_crypto.Timelock.{unlocked_value; proof = proof_bogus} + in check_storage chest_correct chest_key_incorrect "01" >>=? fun () -> return_unit diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_activation.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_activation.ml index aa5c46cf4056..778544462e33 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_activation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_activation.ml @@ -85,19 +85,21 @@ let secrets () = let passphrase = Bytes.(cat (of_string email) (of_string password)) in let sk = Tezos_client_base.Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in (pkh, pk, sk) in List.map (fun (mnemonic, secret, amount, pkh, password, email) -> let pkh', pk, sk = read_key mnemonic email password in - let pkh = Signature.Public_key_hash.of_b58check_exn pkh in - assert (Signature.Public_key_hash.equal pkh pkh') ; + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh in + assert (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') ; let account = Account.{pkh; pk; sk} in Account.add_account account ; { @@ -491,7 +493,7 @@ let test_invalid_activation_inexistent_pkh () = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd secrets in let inexistent_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1PeQHGKPWSpNoozvxgqLN9TFsj6rDqNV3o" in Op.activation (B blk) inexistent_pkh activation_code >>=? fun operation -> diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_reveal.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_reveal.ml index c4179f275bda..d8f5ef94b4aa 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_reveal.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_reveal.ml @@ -146,12 +146,12 @@ let test_reveal_with_fake_account () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> @@ -228,12 +228,12 @@ let test_reveal_with_fake_account_already_revealed () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index fefcf221c311..c221cc126bbb 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -1578,7 +1578,7 @@ let test_timeout () = number_of_ticks = number_of_ticks_exn 4L; compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["first"]); + (Tezos_crypto.Context_hash.hash_string ["first"]); } in let commitment2 = @@ -1587,7 +1587,7 @@ let test_timeout () = number_of_ticks = number_of_ticks_exn 4L; compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["second"]); + (Tezos_crypto.Context_hash.hash_string ["second"]); } in @@ -1616,17 +1616,17 @@ let test_timeout () = (%ld, %a)] but got [Sc_rollup_timeout_level_not_reached (%ld, \ %a)]" expected_block_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh1 blocks_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp staker | _ -> failwith "It should have failed with [Sc_rollup_timeout_level_not_reached \ (%ld, %a)]" expected_block_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh1 in let* timeout = Op.sc_rollup_timeout (B block) account3 rollup game_index in @@ -1685,14 +1685,14 @@ let init_with_conflict () = let* block, rollup = sc_originate block account1 "unit" in let compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["first"]) + (Tezos_crypto.Context_hash.hash_string ["first"]) in let* commitment1 = dummy_commitment ~compressed_state ~number_of_ticks:1L (B block) rollup in let compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["second"]) + (Tezos_crypto.Context_hash.hash_string ["second"]) in let* commitment2 = dummy_commitment ~compressed_state ~number_of_ticks:1L (B block) rollup diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml index 4fc80a70e392..26e78f570d3b 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_tx_rollup.ml @@ -310,7 +310,9 @@ let commitment_hash_testable = Alcotest.testable Tx_rollup_commitment_hash.pp Tx_rollup_commitment_hash.( = ) let public_key_hash_testable = - Alcotest.testable Signature.Public_key_hash.pp Signature.Public_key_hash.( = ) + Alcotest.testable + Tezos_crypto.Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.( = ) let raw_level_testable = Alcotest.testable Raw_level.pp Raw_level.( = ) @@ -325,7 +327,7 @@ let gen_l2_account ?rng_state () = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255)) rng_state in - let pkh, public_key, secret_key = Bls.generate_key ?seed () in + let pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key ?seed () in (secret_key, public_key, pkh) (** [make_ticket_key ty contents ticketer tx_rollup] computes the ticket hash @@ -409,7 +411,7 @@ let make_deposit b tx_rollup l1_src addr = (** Create an incomplete (but valid) commitment for a given level. It is incomplete in the sense that the Merkle roots for each message are generated - with [Context_hash.hash_string message_index]. In the meantime provides the + with [Tezos_crypto.Context_hash.hash_string message_index]. In the meantime provides the list of withdraw in a association list of [batch_index -> withdraw_list]. Be careful not to provide a too-big withdraw_list as the construction is expensive *) @@ -420,7 +422,8 @@ let make_incomplete_commitment_for_batch context level tx_rollup withdraw_list = Data_encoding.Binary.to_string_exn Tx_rollup_inbox.encoding metadata in List.init ~when_negative_length:[] metadata.inbox_length (fun i -> - Context_hash.hash_string [str_for_context_hash ^ string_of_int i]) + Tezos_crypto.Context_hash.hash_string + [str_for_context_hash ^ string_of_int i]) >>?= fun batches_result -> let messages = List.mapi @@ -1601,7 +1604,7 @@ let test_commitment_duplication () = let batches2 : Tx_rollup_message_result_hash.t list = [Bytes.make 20 '1'; Bytes.make 20 '2'] |> List.map (fun hash -> - let context_hash = Context_hash.hash_bytes [hash] in + let context_hash = Tezos_crypto.Context_hash.hash_bytes [hash] in Tx_rollup_message_result_hash.hash_uncarbonated { context_hash; @@ -2268,7 +2271,7 @@ module Rejection = struct Tx_rollup_message_result_hash.hash_uncarbonated { context_hash = - Context_hash.of_b58check_exn + Tezos_crypto.Context_hash.of_b58check_exn "CoUiEnajKeukmYFUgWTJF2z3v24MycpTaomF8a9hRzVy7as9hvgy"; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; }; @@ -2338,7 +2341,8 @@ module Rejection = struct let* store = init_l2_store () in let* hash_tree = hash_tree_from_store store in assert ( - Context_hash.(hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; + Tezos_crypto.Context_hash.( + hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; return_unit (** [make_proof store msg] applies [msg] on [store] and returns the @@ -2366,7 +2370,7 @@ module Rejection = struct { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } @@ -2500,7 +2504,9 @@ module Rejection = struct let signatures = Tx_rollup_l2_helpers.sign_transaction signers transaction in - let signature = assert_some @@ Bls.aggregate_signature_opt signatures in + let signature = + assert_some @@ Tezos_crypto.Bls.aggregate_signature_opt signatures + in let batch = Tx_rollup_l2_batch.V1. {contents = [transaction]; aggregated_signature = signature} @@ -2742,7 +2748,7 @@ module Rejection = struct let level1 = tx_level 1l in make_invalid_commitment b level0 l2_context_hash >>=? fun (b, commitment0) -> - make_invalid_commitment b level1 Context_hash.zero + make_invalid_commitment b level1 Tezos_crypto.Context_hash.zero >>=? fun (b, commitment1) -> Context.get_constants (B b) >>=? fun constants -> let bond_cost = constants.parametric.tx_rollup.commitment_bond in @@ -2978,7 +2984,7 @@ module Rejection = struct let previous_message_result : Tx_rollup_message_result.t = { (* Expected is Tx_rollup_commitment.empty_l2_context_hash *) - context_hash = Context_hash.zero; + context_hash = Tezos_crypto.Context_hash.zero; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; } in @@ -3523,7 +3529,7 @@ module Rejection = struct l2_accounts in let time = time () in - let* (_ : Context_hash.t) = C.commit ~time store in + let* (_ : Tezos_crypto.Context_hash.t) = C.commit ~time store in return store (** Regression test to ensure that we can reject a commitment where the @@ -4558,7 +4564,7 @@ module Withdraw = struct ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - (Context_hash.hash_bytes [Bytes.make 20 'c']) + (Tezos_crypto.Context_hash.hash_bytes [Bytes.make 20 'c']) (* any context hash will fail *) [ticket_info] (* any non-empty list will fail *) diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml index 46f377155405..951fa00e12d7 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_voting.ml @@ -74,10 +74,10 @@ let expected_qr_num participation_ema = *. (of_int qr_max_num -. of_int qr_min_num) /. of_int den) -(* Protocol_hash.zero is "PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i" *) +(* Tezos_crypto.Protocol_hash.zero is "PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i" *) let protos = Array.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [| "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -230,9 +230,9 @@ let equal_delegate_info a b = Option.equal Int64.equal a.Vote.voting_power b.Vote.voting_power && Option.equal Vote.equal_ballot a.current_ballot b.current_ballot && List.equal - Protocol_hash.equal - (List.sort Protocol_hash.compare a.current_proposals) - (List.sort Protocol_hash.compare b.current_proposals) + Tezos_crypto.Protocol_hash.equal + (List.sort Tezos_crypto.Protocol_hash.compare a.current_proposals) + (List.sort Tezos_crypto.Protocol_hash.compare b.current_proposals) && Int.equal a.remaining_proposals b.remaining_proposals let assert_equal_info ~loc a b = @@ -470,8 +470,9 @@ let test_successful_vote num_delegates () = let props = List.map (fun i -> protos.(i)) (2 -- Constants.max_proposals_per_delegate) in - Op.proposals (B b) del1 (Protocol_hash.zero :: props) >>=? fun ops1 -> - Op.proposals (B b) del2 [Protocol_hash.zero] >>=? fun ops2 -> + Op.proposals (B b) del1 (Tezos_crypto.Protocol_hash.zero :: props) + >>=? fun ops1 -> + Op.proposals (B b) del2 [Tezos_crypto.Protocol_hash.zero] >>=? fun ops2 -> Block.bake ~operations:[ops1; ops2] b >>=? fun b -> Context.Delegate.voting_info (B b) pkh1 >>=? fun info1 -> Context.Delegate.voting_info (B b) pkh2 >>=? fun info2 -> @@ -481,7 +482,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow1; current_ballot = None; - current_proposals = Protocol_hash.zero :: props; + current_proposals = Tezos_crypto.Protocol_hash.zero :: props; remaining_proposals = 0; } >>=? fun () -> @@ -491,7 +492,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow2; current_ballot = None; - current_proposals = [Protocol_hash.zero]; + current_proposals = [Tezos_crypto.Protocol_hash.zero]; remaining_proposals = Constants.max_proposals_per_delegate - 1; } >>=? fun () -> @@ -513,7 +514,7 @@ let test_successful_vote num_delegates () = assert_validate_proposals_fails ~expected_error:too_many_proposals ~proposer:del1 - ~proposals:(Protocol_hash.zero :: props) + ~proposals:(Tezos_crypto.Protocol_hash.zero :: props) b __LOC__ >>=? fun () -> @@ -544,13 +545,13 @@ let test_successful_vote num_delegates () = (* current proposal must be set during exploration period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p2 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p2 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -571,7 +572,7 @@ let test_successful_vote num_delegates () = assert_validate_ballot_fails ~expected_error:already_submitted_a_ballot ~voter:del1 - ~proposal:Protocol_hash.zero + ~proposal:Tezos_crypto.Protocol_hash.zero ~ballot:Vote.Nay b __LOC__ @@ -622,13 +623,13 @@ let test_successful_vote num_delegates () = (* current proposal must be set during promotion period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p4 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p4 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -663,11 +664,11 @@ let test_successful_vote num_delegates () = Context.Vote.get_protocol b >>= fun p -> Assert.equal ~loc:__LOC__ - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Unexpected proposal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p - Protocol_hash.zero + Tezos_crypto.Protocol_hash.zero >>=? fun () -> return_unit (* given a list of active delegates, @@ -719,7 +720,8 @@ let test_not_enough_quorum_in_exploration num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun operation -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] + >>=? fun operation -> Block.bake ~operation b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -741,7 +743,7 @@ let test_not_enough_quorum_in_exploration num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -773,7 +775,8 @@ let test_not_enough_quorum_in_promotion num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun operation -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] + >>=? fun operation -> Block.bake ~operation b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -789,7 +792,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -820,7 +823,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -944,7 +947,7 @@ let test_supermajority_in_exploration supermajority () = (* assert our proposal won *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal proposal v) then return_unit + if Tezos_crypto.Protocol_hash.(equal proposal v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> @@ -1007,7 +1010,7 @@ let test_quorum_capped_maximum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in @@ -1047,7 +1050,7 @@ let test_quorum_capped_minimum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in @@ -1259,7 +1262,9 @@ let test_proposals_invalid_signature () = let open Lwt_result_syntax in let* block, proposer = context_init1 () in let* contents = Op.proposals_contents (B block) proposer [protos.(0)] in - let op = Op.pack_operation (B block) (Some Signature.zero) contents in + let op = + Op.pack_operation (B block) (Some Tezos_crypto.Signature.zero) contents + in Incremental.assert_validate_operation_fails (invalid_signature __LOC__) op @@ -1276,7 +1281,7 @@ let test_proposals_wrong_voting_period_index () = assert_validate_proposals_fails ~expected_error:(wrong_voting_period_index ~current_index ~op_index) ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] ~period:op_index block __LOC__ @@ -1336,14 +1341,14 @@ let test_proposals_source_not_in_vote_listings () = assert_validate_proposals_fails ~expected_error:proposals_from_unregistered_delegate ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] block in let assert_fails_with_source_not_in_vote_listings block = assert_validate_proposals_fails ~expected_error:source_not_in_vote_listings ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] block in (* Fail when the source has no contract in the storage. *) @@ -1690,7 +1695,9 @@ let test_ballot_invalid_signature () = let open Lwt_result_syntax in let* block, voter, proposal = context_init_exploration () in let* contents = Op.ballot_contents (B block) voter proposal Vote.Yay in - let op = Op.pack_operation (B block) (Some Signature.zero) contents in + let op = + Op.pack_operation (B block) (Some Tezos_crypto.Signature.zero) contents + in Incremental.assert_validate_operation_fails (invalid_signature __LOC__) op @@ -1912,7 +1919,7 @@ let observe_ballot pre_state post_state op caller_loc = let* current_proposal = Assert.get_some ~loc:(make_loc __LOC__) current_proposal in - assert (Protocol_hash.equal proposal current_proposal) ; + assert (Tezos_crypto.Protocol_hash.equal proposal current_proposal) ; (* Observations *) let* post_voting_infos = Context.Delegate.voting_info (B post_state) source in let* recorded_ballot = diff --git a/src/proto_alpha/lib_protocol/test/integration/test_frozen_bonds.ml b/src/proto_alpha/lib_protocol/test/integration/test_frozen_bonds.ml index a851e13cf3e2..789422bbbfa1 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_frozen_bonds.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_frozen_bonds.ml @@ -54,7 +54,7 @@ let very_small_random_amount () = | Some x -> x let nonce_zero = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_tx_rollup ?(nonce = nonce_zero) () = ( Tx_rollup.Internal_for_tests.originated_tx_rollup nonce, @@ -74,13 +74,13 @@ let create_context () = delegate's pkh. *) let init_test ~user_is_delegate = create_context () >>=? fun (ctxt, _) -> - let delegate, delegate_pk, _ = Signature.generate_key () in + let delegate, delegate_pk, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract = Contract.Implicit delegate in let delegate_account = `Contract (Contract.Implicit delegate) in let user_contract = if user_is_delegate then delegate_contract else - let user, _, _ = Signature.generate_key () in + let user, _, _ = Tezos_crypto.Signature.generate_key () in Contract.Implicit user in let user_account = `Contract user_contract in @@ -398,7 +398,7 @@ let test_rpcs () = let test_scenario scenario = init_test ~user_is_delegate:false >>=? fun (ctxt, user_contract, user_account, delegate1) -> - let delegate2, delegate_pk2, _ = Signature.generate_key () in + let delegate2, delegate_pk2, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract2 = Contract.Implicit delegate2 in let delegate_account2 = `Contract delegate_contract2 in let delegate_balance2 = big_random_amount () in diff --git a/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml index 7c39adddd6a6..a56dca847803 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml @@ -85,7 +85,7 @@ module WASM_P : let produce_proof context tree step = let open Lwt_syntax in let* context = Context_binary.add_tree context [] tree in - let* (_hash : Context_hash.t) = + let* (_hash : Tezos_crypto.Context_hash.t) = Context_binary.commit ~time:Time.Protocol.epoch context in let index = Context_binary.index context in diff --git a/src/proto_alpha/lib_protocol/test/integration/test_token.ml b/src/proto_alpha/lib_protocol/test/integration/test_token.ml index 5f8215536b9c..7b5a33155ed2 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_token.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_token.ml @@ -50,7 +50,8 @@ let random_amount () = | None -> assert false | Some x -> x -let nonce = Origination_nonce.Internal_for_tests.initial Operation_hash.zero +let nonce = + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_rollup () = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce @@ -59,7 +60,7 @@ let test_simple_balances () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = `Contract (Contract.Implicit pkh) in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in let amount = Tez.one in wrap (Token.transfer ctxt src dest amount) >>=? fun (ctxt', _) -> @@ -78,7 +79,7 @@ let test_simple_balance_updates () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = Contract.Implicit pkh in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = Tez.one in wrap (Token.transfer ctxt (`Contract src) (`Contract dest) amount) @@ -127,7 +128,7 @@ let test_allocated () = create_context () >>=? fun (ctxt, pkh) -> let dest = `Delegate_balance pkh in test_allocated_and_still_allocated_when_empty ctxt dest true >>=? fun () -> - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in test_allocated_and_deallocated_when_empty ctxt dest >>=? fun () -> let dest = `Collected_commitments Blinded_public_key_hash.zero in @@ -180,7 +181,7 @@ let test_transferring_to_sink ctxt sink amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res "Overflowing tez addition" let test_transferring_to_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -199,7 +200,7 @@ let test_transferring_to_collected_commitments ctxt = [(Commitments bpkh, Credited amount, Block_application)] let test_transferring_to_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -209,7 +210,7 @@ let test_transferring_to_delegate_balance ctxt = [(Contract dest, Credited amount, Block_application)] let test_transferring_to_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_to_sink ctxt @@ -251,7 +252,7 @@ let test_transferring_to_burned ctxt = ]) true >>=? fun () -> - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in let p, r = (Random.bool (), Random.bool ()) in wrap (Token.transfer ctxt `Minted (`Lost_endorsing_rewards (pkh, p, r)) amount) @@ -277,7 +278,7 @@ let test_transferring_to_burned ctxt = true let test_transferring_to_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -377,7 +378,7 @@ let test_transferring_from_bounded_source ctxt src amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res error_title let test_transferring_from_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let src = Contract.Implicit pkh in let amount = random_amount () in test_transferring_from_bounded_source @@ -396,7 +397,7 @@ let test_transferring_from_collected_commitments ctxt = [(Commitments bpkh, Debited amount, Block_application)] let test_transferring_from_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in let src = Contract.Implicit pkh in test_transferring_from_bounded_source @@ -406,7 +407,7 @@ let test_transferring_from_delegate_balance ctxt = [(Contract src, Debited amount, Block_application)] let test_transferring_from_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_from_bounded_source ctxt @@ -423,7 +424,7 @@ let test_transferring_from_collected_fees ctxt = [(Block_fees, Debited amount, Block_application)] let test_transferring_from_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -494,13 +495,13 @@ let cast_to_container_type x = let build_test_cases () = create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let baker1, baker1_pk, _ = Signature.generate_key () in + let baker1, baker1_pk, _ = Tezos_crypto.Signature.generate_key () in let baker1c = `Contract (Contract.Implicit baker1) in - let baker2, baker2_pk, _ = Signature.generate_key () in + let baker2, baker2_pk, _ = Tezos_crypto.Signature.generate_key () in let baker2c = `Contract (Contract.Implicit baker2) in (* Allocate contracts for user1, user2, baker1, and baker2. *) wrap (Token.transfer ctxt origin user1c (random_amount ())) @@ -703,13 +704,13 @@ let test_transfer_n_with_non_empty_source () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let user3, _, _ = Signature.generate_key () in + let user3, _, _ = Tezos_crypto.Signature.generate_key () in let user3c = `Contract (Contract.Implicit user3) in - let user4, _, _ = Signature.generate_key () in + let user4, _, _ = Tezos_crypto.Signature.generate_key () in let user4c = `Contract (Contract.Implicit user4) in (* Allocate contracts for user1, user2, user3, and user4. *) let amount = diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml index 8e38b709b86c..28a5266a11ae 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -42,7 +42,7 @@ type state = { voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; - protocol_hashes : Protocol_hash.t list; + protocol_hashes : Tezos_crypto.Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; dbl_endorsement : dbl_endorsement_state; @@ -129,7 +129,10 @@ let ballot_exploration_prelude state = let* props = List.map_es (fun voter -> - Op.proposals (B state.block) voter [Protocol_hash.zero]) + Op.proposals + (B state.block) + voter + [Tezos_crypto.Protocol_hash.zero]) voters in return (prop :: props, state) @@ -180,7 +183,11 @@ let ballot_exploration_descriptor = in assert (voting_period_info.voting_period.kind = Exploration) ; let ballot = pick_one ballots in - Op.ballot (B state.block) contract Protocol_hash.zero ballot + Op.ballot + (B state.block) + contract + Tezos_crypto.Protocol_hash.zero + ballot in List.map_es gen state.voters); } @@ -201,7 +208,10 @@ let proposal_descriptor = Context.Vote.get_current_period (B state.block) in assert (voting_period_info.voting_period.kind = Proposal) ; - Op.proposals (B state.block) contract [Protocol_hash.zero] + Op.proposals + (B state.block) + contract + [Tezos_crypto.Protocol_hash.zero] in List.map_es gen state.voters); } @@ -246,7 +256,11 @@ let ballot_promotion_descriptor = let* ops = List.map_es (fun voter -> - Op.ballot (B state.block) voter Protocol_hash.zero Vote.Yay) + Op.ballot + (B state.block) + voter + Tezos_crypto.Protocol_hash.zero + Vote.Yay) state.voters in return (ops, state) @@ -260,7 +274,11 @@ let ballot_promotion_descriptor = in assert (voting_period_info.voting_period.kind = Promotion) ; let ballot = Stdlib.List.hd ballots in - Op.ballot (B state.block) contract Protocol_hash.zero ballot + Op.ballot + (B state.block) + contract + Tezos_crypto.Protocol_hash.zero + ballot in List.map_es gen state.voters); } @@ -360,7 +378,9 @@ let dbl_endorsement_prelude state = in let op1, op2 = let comp = - Operation_hash.compare (Operation.hash op1) (Operation.hash op2) + Tezos_crypto.Operation_hash.compare + (Operation.hash op1) + (Operation.hash op2) in assert (comp <> 0) ; if comp < 0 then (op1, op2) else (op2, op1) @@ -376,7 +396,9 @@ let dbl_endorsement_prelude state = in let op3, op4 = let comp = - Operation_hash.compare (Operation.hash op3) (Operation.hash op4) + Tezos_crypto.Operation_hash.compare + (Operation.hash op3) + (Operation.hash op4) in assert (comp <> 0) ; if comp < 0 then (op3, op4) else (op4, op3) @@ -424,7 +446,7 @@ let double_baking_descriptor = let order_block_header bh1 bh2 = let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in - let c = Block_hash.compare hash1 hash2 in + let c = Tezos_crypto.Block_hash.compare hash1 hash2 in if c < 0 then (bh1, bh2) else (bh2, bh1) in let* ctxt = Context.to_alpha_ctxt (B state.block) in diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli index df118ca15c6f..1b9add80bfa6 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli @@ -57,7 +57,7 @@ type state = { voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; - protocol_hashes : Protocol_hash.t list; + protocol_hashes : Tezos_crypto.Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; dbl_endorsement : dbl_endorsement_state; diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml index 9a57b3e7676d..724aefb6c960 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -897,7 +897,7 @@ let mk_tx_rollup_reject (oinfos : operation_req) (infos : infos) = { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } in @@ -982,7 +982,7 @@ let mk_tx_rollup_dispacth_ticket (oinfos : operation_req) (infos : infos) = ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - Context_hash.zero + Tezos_crypto.Context_hash.zero [reveal] let mk_sc_rollup_origination (oinfos : operation_req) (infos : infos) = @@ -1282,7 +1282,7 @@ let make_tztest_batched ?(fmt = Format.std_formatter) name test subjects increment of the counters aka 1 for a single operation, n for a batch of n manager operations. *) type probes = { - source : Signature.Public_key_hash.t; + source : Tezos_crypto.Signature.Public_key_hash.t; fee : Tez.tez; gas_limit : Gas.Arith.integral; nb_counter : int; diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/test_mempool.ml b/src/proto_alpha/lib_protocol/test/integration/validate/test_mempool.ml index a6ab57cc546e..93b6f2aed1ed 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/test_mempool.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/test_mempool.ml @@ -84,14 +84,16 @@ let assert_operation_present_in_mempool ~__LOC__ mempool ophl = let resulting_mempool_operations = Environment.Operation_hash.Map.bindings operations |> List.map fst - |> List.sort Operation_hash.compare + |> List.sort Tezos_crypto.Operation_hash.compare + in + let expected_operations = + List.sort Tezos_crypto.Operation_hash.compare ophl in - let expected_operations = List.sort Operation_hash.compare ophl in Assert.assert_equal_list ~loc:__LOC__ - Operation_hash.equal + Tezos_crypto.Operation_hash.equal "operations present in mempool" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp resulting_mempool_operations expected_operations @@ -106,7 +108,7 @@ let test_simple () = let vs, mempool = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -138,7 +140,7 @@ let test_imcompatible_mempool () = let _vs, mempool1 = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -154,7 +156,7 @@ let test_imcompatible_mempool () = let _vs, mempool2 = Mempool.init ctxt2 - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash:predecessor_hash2 @@ -183,7 +185,7 @@ let test_merge () = let vs, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -275,7 +277,7 @@ let test_add_invalid_operation () = let vs, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -300,7 +302,7 @@ let test_add_and_replace () = let info, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -352,7 +354,7 @@ let test_remove_operation () = let info, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml index 9515b72cfa09..48931342d2b9 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/validate_helpers.ml @@ -61,7 +61,7 @@ let ballots = Vote.[Yay; Nay; Pass] let protos = List.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [ "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -88,7 +88,7 @@ let protos = type secret_account = { blinded_public_key_hash : Blinded_public_key_hash.t; - account : Ed25519.Public_key_hash.t; + account : Tezos_crypto.Ed25519.Public_key_hash.t; activation_code : Blinded_public_key_hash.activation_code; amount : Tez.t; } @@ -103,19 +103,21 @@ let secrets = let passphrase = Bytes.(cat (of_string email) (of_string password)) in let sk = Tezos_client_base.Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in (pkh, pk, sk) in List.map (fun (mnemonic, secret, amount, pkh, password, email) -> let pkh', pk, sk = read_key mnemonic email password in - let pkh = Ed25519.Public_key_hash.of_b58check_exn pkh in - assert (Signature.Public_key_hash.equal (Ed25519 pkh) pkh') ; + let pkh = Tezos_crypto.Ed25519.Public_key_hash.of_b58check_exn pkh in + assert (Tezos_crypto.Signature.Public_key_hash.equal (Ed25519 pkh) pkh') ; let activation_code = Stdlib.Option.get (Blinded_public_key_hash.activation_code_of_hex secret) diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml b/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml index aa62f034622e..5935ad1e771f 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml @@ -957,7 +957,7 @@ let pp_strategy fmt = function | EOL_hater -> Format.pp_print_string fmt "EOL hater" type player = { - pkh : Signature.Public_key_hash.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; contract : Contract.t; strategy : strategy; game_player : Game.player; @@ -967,7 +967,7 @@ let pp_player ppf {pkh; contract = _; strategy; game_player} = Format.fprintf ppf "pkh: %a@,strategy: %a@,game_player: %s" - Signature.Public_key_hash.pp_short + Tezos_crypto.Signature.Public_key_hash.pp_short pkh pp_strategy strategy @@ -1369,7 +1369,8 @@ let make_players ~p1_strategy ~contract1 ~p2_strategy ~contract2 = let pkh2 = Account.pkh_of_contract_exn contract2 in let ({alice; bob = _} : Game.Index.t) = Game.Index.make pkh1 pkh2 in let player1, player2 = - if Signature.Public_key_hash.equal alice pkh1 then Game.(Alice, Bob) + if Tezos_crypto.Signature.Public_key_hash.equal alice pkh1 then + Game.(Alice, Bob) else Game.(Bob, Alice) in ( { diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml index 87da1c9dc820..c0d3ad9ded5b 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml @@ -237,7 +237,7 @@ let gen_inbox_message = (* We won't test the encoding of these values. It's out of scope. *) let payload = Script_repr.unit in let sender = Contract_hash.zero in - let source = Signature.Public_key_hash.zero in + let source = Tezos_crypto.Signature.Public_key_hash.zero in (* But the encoding of the rollup's address is our problem. *) let+ destination = gen_rollup in Internal (Transfer {payload; sender; source; destination}) diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml index 62cd2fd7db55..ecacbec36a17 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_script_comparison.ml @@ -57,8 +57,9 @@ let rec reference_compare_comparable : type a. a comparable_ty -> a -> a -> int | Bool_t, x, y -> normalize_compare @@ Compare.Bool.compare x y | Mutez_t, x, y -> normalize_compare @@ Tez.compare x y | Key_hash_t, x, y -> - normalize_compare @@ Signature.Public_key_hash.compare x y - | Key_t, x, y -> normalize_compare @@ Signature.Public_key.compare x y + normalize_compare @@ Tezos_crypto.Signature.Public_key_hash.compare x y + | Key_t, x, y -> + normalize_compare @@ Tezos_crypto.Signature.Public_key.compare x y | Int_t, x, y -> normalize_compare @@ Script_int.compare x y | Nat_t, x, y -> normalize_compare @@ Script_int.compare x y | Timestamp_t, x, y -> normalize_compare @@ Script_timestamp.compare x y diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml index fcf89c89ec43..440ffd952908 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml @@ -47,7 +47,9 @@ let l2_address, bls_pk = `Hex "8fee216367c463821f82c942a1cee3a01469b1da782736ca269a2accea6e0cc4" |> Hex.to_bytes_exn in - let pkh, public_key, _secret_key = Bls.generate_key ~seed:ikm () in + let pkh, public_key, _secret_key = + Tezos_crypto.Bls.generate_key ~seed:ikm () + in (pkh, public_key) let signer_gen : Signer_indexable.either QCheck2.Gen.t = @@ -74,7 +76,7 @@ let idx_l2_address_gen = oneof [idx_l2_address_idx_gen; return idx_l2_address_value] let public_key_hash = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" let public_key_hash_gen = @@ -87,7 +89,9 @@ let ticket_hash : Protocol.Alpha_context.Ticket_hash.t = (* TODO: https://gitlab.com/tezos/tezos/-/issues/2592 we could introduce a bit more randomness here *) let ticketer_b58 = "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" in - let ticketer_pkh = Signature.Public_key_hash.of_b58check_exn ticketer_b58 in + let ticketer_pkh = + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn ticketer_b58 + in let ticketer = Protocol.Alpha_context.Contract.Implicit ticketer_pkh in Tx_rollup_l2_helpers.make_unit_ticket_key ticketer l2_address diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_zk_rollup_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_zk_rollup_encoding.ml index 042fe450eb13..9d55fd7125bb 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_zk_rollup_encoding.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_zk_rollup_encoding.ml @@ -98,7 +98,7 @@ let gen_ticket_hash = Ticket_hash_repr.of_bytes_exn bytes let gen_pkh = - let pkh, _, _ = Signature.generate_key ~algo:Ed25519 () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key ~algo:Ed25519 () in Gen.return pkh let gen_z = diff --git a/src/proto_alpha/lib_protocol/test/regression/test_logging.ml b/src/proto_alpha/lib_protocol/test/regression/test_logging.ml index a123f6d311ba..5fb8465c249c 100644 --- a/src/proto_alpha/lib_protocol/test/regression/test_logging.ml +++ b/src/proto_alpha/lib_protocol/test/regression/test_logging.ml @@ -225,7 +225,9 @@ let run_script transaction () = let* inc = Incremental.begin_construction b in let ctxt = Incremental.alpha_ctxt inc in let ctxt = - Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in return (parameter, ctxt) in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_consensus_key.ml b/src/proto_alpha/lib_protocol/test/unit/test_consensus_key.ml index 1b3c2b7cdbbc..f985e4cea1e1 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_consensus_key.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_consensus_key.ml @@ -73,18 +73,18 @@ module Assert = struct let equal_pkh ~__LOC__ a b = Assert.equal ~loc:__LOC__ - Signature.Public_key_hash.equal + Tezos_crypto.Signature.Public_key_hash.equal "pkh" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a b let equal_pk ~__LOC__ a b = Assert.equal ~loc:__LOC__ - Signature.Public_key.equal + Tezos_crypto.Signature.Public_key.equal "pk" - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp a b diff --git a/src/proto_alpha/lib_protocol/test/unit/test_contract_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_contract_repr.ml index 1f7f33a7cfa6..9a758c030b67 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_contract_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_contract_repr.ml @@ -47,7 +47,7 @@ module Test_contract_repr = struct open Contract_repr let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash @@ -61,7 +61,8 @@ module Test_contract_repr = struct in Contract_hash.hash_bytes [data] - let dummy_implicit_contract = Implicit Signature.Public_key_hash.zero + let dummy_implicit_contract = + Implicit Tezos_crypto.Signature.Public_key_hash.zero let dummy_originated_contract = originated_contract @@ dummy_origination_nonce @@ -72,7 +73,7 @@ module Test_contract_repr = struct "%s should have been equal to %" Format.pp_print_string (to_b58check dummy_implicit_contract) - Signature.Public_key_hash.(to_b58check zero) + Tezos_crypto.Signature.Public_key_hash.(to_b58check zero) let test_to_b58check_originated () = Assert.equal diff --git a/src/proto_alpha/lib_protocol/test/unit/test_destination_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_destination_repr.ml index b340aa92ee9f..07cf5adbc3df 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_destination_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_destination_repr.ml @@ -36,7 +36,7 @@ open Protocol open Tztest let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash diff --git a/src/proto_alpha/lib_protocol/test/unit/test_local_contexts.ml b/src/proto_alpha/lib_protocol/test/unit/test_local_contexts.ml index d620a1618398..40eabf7d344b 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_local_contexts.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_local_contexts.ml @@ -96,9 +96,9 @@ let eq_context ctxt1 ctxt2 = hash ctxt2 >>=? fun y -> Assert.equal ~loc:__LOC__ - Context_hash.equal + Tezos_crypto.Context_hash.equal "check context" - Context_hash.pp + Tezos_crypto.Context_hash.pp x y diff --git a/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml b/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml index 1aa4c7bce8f3..245ae17b0a54 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_receipt.ml @@ -68,7 +68,7 @@ let test_encodings balance = let test_encodings () = let open Receipt in - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in test_encodings (Contract (Contract.Implicit pkh)) >>=? fun () -> test_encodings Block_fees >>=? fun () -> test_encodings (Deposits pkh) >>=? fun () -> @@ -89,7 +89,8 @@ let test_encodings () = test_encodings Initial_commitments >>=? fun () -> test_encodings Minted >>=? fun () -> let nonce = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial + Tezos_crypto.Operation_hash.zero in let tx_rollup = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml index d2d7192fd8e3..3afd1c0af6b0 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -81,7 +81,7 @@ module Arith_Context = struct (* FIXME: With on-disk context, we cannot commit the empty context. Is it also true in our case? *) let* context = Context_binary.add_tree context [] tree in - let* (_hash : Context_hash.t) = + let* (_hash : Tezos_crypto.Context_hash.t) = Context_binary.commit ~time:Time.Protocol.epoch context in let index = Context_binary.index context in @@ -451,7 +451,7 @@ let dummy_internal_transfer address = let source = WithExceptions.Result.get_ok ~loc:__LOC__ - (Signature.Public_key_hash.of_b58check + (Tezos_crypto.Signature.Public_key_hash.of_b58check "tz1RjtZUVeLhADFHDL8UwDZA6vjWWhojpu5w") in let*? payload = Environment.wrap_tzresult (Script_string.of_string "foo") in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml index 055bfdc68d50..9a0624a8a767 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml @@ -48,7 +48,7 @@ let assert_fails_with ~__LOC__ k expected_err = let tick_of_int_exn n = match Tick.of_int n with None -> assert false | Some t -> t -let context_hash_of_string s = Context_hash.hash_string [s] +let context_hash_of_string s = Tezos_crypto.Context_hash.hash_string [s] let hash_string s = Sc_rollup_repr.State_hash.context_hash_to_state_hash diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml index 2cc1a0fec3a7..328a02e79b1a 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml @@ -111,7 +111,7 @@ let test_encode_decode_internal_inbox_message_transfer () = let source = Result.get_ok ~loc:__LOC__ - (Signature.Public_key_hash.of_b58check + (Tezos_crypto.Signature.Public_key_hash.of_b58check "tz1RjtZUVeLhADFHDL8UwDZA6vjWWhojpu5w") in let*? (Script_typed_ir.Ty_ex_c pair_nat_ticket_string_ty) = diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml index d9145581820d..c92ee7e68e7f 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -60,7 +60,9 @@ let new_context_with_stakers nb_stakers = let+ inc = Incremental.begin_construction b in let ctxt = Incremental.alpha_ctxt inc in (* Necessary to originate rollups. *) - let ctxt = Alpha_context.Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = + Alpha_context.Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero + in let ctxt = Alpha_context.Internal_for_tests.to_raw ctxt in let stakers = List.map @@ -76,7 +78,7 @@ let new_context () = let* ctxt, _stakers = new_context_with_stakers 1 in (* Mint some tez for staker accounts. *) let mint_tez_for ctxt pkh_str = - let pkh = Signature.Public_key_hash.of_b58check_exn pkh_str in + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh_str in let contract = Contract_repr.Implicit pkh in let+ ctxt, _ = lift @@ -427,7 +429,7 @@ let test_deposit_then_withdraw () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in @@ -445,7 +447,7 @@ let test_withdraw_when_not_staked () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in assert_fails_with @@ -457,7 +459,7 @@ let test_withdrawing_twice () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml index 026fad42b561..9f17b6c05f68 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml @@ -66,7 +66,7 @@ module Wasm_context = struct let produce_proof context tree step = let open Lwt_syntax in let* context = Context.add_tree context [] tree in - let* (_hash : Context_hash.t) = + let* (_hash : Tezos_crypto.Context_hash.t) = Context.commit ~time:Time.Protocol.epoch context in let index = Context.index context in diff --git a/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2.ml b/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2.ml index f0fd2133a596..a9ac5e8e606e 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2.ml @@ -516,7 +516,7 @@ module Test_batch_encodings = struct Format.fprintf fmt "@[Withdraw:@ destination=%a,@ ticket_hash=%a,@ qty:%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp destination Alpha_context.Ticket_hash.pp ticket_hash diff --git a/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml b/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml index ab4b08d5ac9b..767190f5ba0e 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml @@ -48,7 +48,7 @@ open Indexable (** {3. Various helpers to facilitate the tests. } *) -let pkh = Signature.Public_key_hash.zero +let pkh = Tezos_crypto.Signature.Public_key_hash.zero let ((_, pk1, addr1) as l2_addr1) = gen_l2_address () @@ -84,7 +84,7 @@ let expect_error_status ~msg error status cont = let aggregate_signature_exn : signature list -> signature = fun signatures -> - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> res | None -> raise (Invalid_argument "aggregate_signature_exn") @@ -127,7 +127,7 @@ let pp_metadata fmt Tx_rollup_l2_context_sig.{counter; public_key} = fmt "{counter=%d; public_key=%a}" counter - Bls.Public_key.pp + Tezos_crypto.Bls.Public_key.pp public_key let eq_metadata = Alcotest.of_pp pp_metadata @@ -154,7 +154,7 @@ let pp_withdrawal fmt = function Format.fprintf fmt "{claimer=%a; ticket_hash=%a; amount=%a}" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer Ticket_hash.pp ticket_hash @@ -280,7 +280,7 @@ let batch_from_transfers inputs = (fun all_sks input -> List.fold_left (fun acc (sk, _, _, _, _, _) -> - if List.mem ~equal:Bls.Secret_key.equal sk acc then acc + if List.mem ~equal:Tezos_crypto.Bls.Secret_key.equal sk acc then acc else sk :: acc) [] input diff --git a/src/proto_alpha/lib_protocol/test/unit/test_zk_rollup_storage.ml b/src/proto_alpha/lib_protocol/test/unit/test_zk_rollup_storage.ml index a6288a63f16f..d4dff0280b8f 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_zk_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_zk_rollup_storage.ml @@ -45,9 +45,9 @@ let batch_size = 10 module ZKRU = struct include Alpha_context.Zk_rollup - type pkh = Signature.Public_key_hash.t + type pkh = Tezos_crypto.Signature.Public_key_hash.t - let pkh_encoding = Signature.Public_key_hash.encoding + let pkh_encoding = Tezos_crypto.Signature.Public_key_hash.encoding type ticket_hash = Alpha_context.Ticket_hash.t @@ -103,7 +103,7 @@ module Raw_context_tests = struct ~predecessor_timestamp:b.header.shell.timestamp ~timestamp:b.header.shell.timestamp in - let nonce = Operation_hash.hash_string ["nonce_hash"] in + let nonce = Tezos_crypto.Operation_hash.hash_string ["nonce_hash"] in return (Raw_context.init_origination_nonce ctx nonce, contract) (* Context with an originated ZKRU *) @@ -141,7 +141,7 @@ module Raw_context_tests = struct let pending_list_append () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _, _ = Signature.generate_key () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. @@ -170,7 +170,7 @@ module Raw_context_tests = struct let pending_list_append_errors () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _, _ = Signature.generate_key () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. @@ -218,7 +218,7 @@ module Raw_context_tests = struct let pending_list_get () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. @@ -239,7 +239,7 @@ module Raw_context_tests = struct let pending_list_errors () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index ab22535a0e0f..b8dbd535a02b 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -62,11 +62,15 @@ end module Arg = struct type block_id = - [`Head | `Hash of Block_hash.t | `Level of Int32.t | `Finalized | `Cemented] + [ `Head + | `Hash of Tezos_crypto.Block_hash.t + | `Level of Int32.t + | `Finalized + | `Cemented ] let construct_block_id = function | `Head -> "head" - | `Hash h -> Block_hash.to_b58check h + | `Hash h -> Tezos_crypto.Block_hash.to_b58check h | `Level l -> Int32.to_string l | `Finalized -> "finalized" | `Cemented -> "cemented" @@ -80,7 +84,7 @@ module Arg = struct match Int32.of_string_opt h with | Some l -> Ok (`Level l) | None -> ( - match Block_hash.of_b58check_opt h with + match Tezos_crypto.Block_hash.of_b58check_opt h with | Some b -> Ok (`Hash b) | None -> Error "Cannot parse block id")) @@ -134,7 +138,7 @@ module Global = struct Tezos_rpc.Service.get_service ~description:"Tezos head known to the smart-contract rollup node" ~query:Tezos_rpc.Query.empty - ~output:(Data_encoding.option Block_hash.encoding) + ~output:(Data_encoding.option Tezos_crypto.Block_hash.encoding) (path / "tezos_head") let current_tezos_level = @@ -215,7 +219,7 @@ module Global = struct ~description: "Tezos block hash of block known to the smart-contract rollup node" ~query:Tezos_rpc.Query.empty - ~output:Block_hash.encoding + ~output:Tezos_crypto.Block_hash.encoding (path / "hash") let level = diff --git a/src/proto_alpha/lib_tx_rollup/RPC.ml b/src/proto_alpha/lib_tx_rollup/RPC.ml index 9c36bf00f67a..7b683e61678b 100644 --- a/src/proto_alpha/lib_tx_rollup/RPC.ml +++ b/src/proto_alpha/lib_tx_rollup/RPC.ml @@ -31,7 +31,7 @@ open Alpha_context type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] type context_id = [block_id | `Context of Tx_rollup_l2_context_hash.t] @@ -62,7 +62,7 @@ let context_of_id state context_id = let construct_block_id = function | `Head -> "head" | `L2_block h -> L2block.Hash.to_b58check h - | `Tezos_block h -> Block_hash.to_b58check h + | `Tezos_block h -> Tezos_crypto.Block_hash.to_b58check h | `Level l -> L2block.level_to_string l let destruct_block_id h = @@ -76,7 +76,7 @@ let destruct_block_id h = | Error _ -> Error "Invalid rollup level" | Ok l -> Ok (`Level l)) | None -> ( - match Block_hash.of_b58check_opt h with + match Tezos_crypto.Block_hash.of_b58check_opt h with | Some b -> Ok (`Tezos_block b) | None -> ( match L2block.Hash.of_b58check_opt h with @@ -344,7 +344,8 @@ module Block = struct | None -> return_none | Some block -> ( match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) return_none | _ -> return_some block.inbox) @@ -357,9 +358,13 @@ module Block = struct | Some block -> let*? () = match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) - error_with "The tezos block (%a) has not L2 inbox" Block_hash.pp b + error_with + "The tezos block (%a) has not L2 inbox" + Tezos_crypto.Block_hash.pp + b | _ -> ok () in let*? () = @@ -413,7 +418,7 @@ module Context_RPC = struct type address_metadata = { index : Tx_rollup_l2_context_sig.address_index; counter : int64; - public_key : Bls.Public_key.t; + public_key : Tezos_crypto.Bls.Public_key.t; } let address_metadata_encoding = @@ -424,7 +429,7 @@ module Context_RPC = struct @@ obj3 (req "index" Tx_rollup_l2_address.Indexable.index_encoding) (req "counter" int64) - (req "public_key" Bls.Public_key.encoding)) + (req "public_key" Tezos_crypto.Bls.Public_key.encoding)) let balance = Tezos_rpc.Service.get_service @@ -496,7 +501,7 @@ module Context_RPC = struct "Get the BLS public key associated to the given address, or null if \ the address has not performed any transfer or withdraw on the rollup." ~query:Tezos_rpc.Query.empty - ~output:(Data_encoding.option Bls.Public_key.encoding) + ~output:(Data_encoding.option Tezos_crypto.Bls.Public_key.encoding) Tezos_rpc.Path.( path / "addresses" /: Arg.address_indexable / "public_key") diff --git a/src/proto_alpha/lib_tx_rollup/RPC.mli b/src/proto_alpha/lib_tx_rollup/RPC.mli index f15657a1fca1..e3062f64be6b 100644 --- a/src/proto_alpha/lib_tx_rollup/RPC.mli +++ b/src/proto_alpha/lib_tx_rollup/RPC.mli @@ -30,7 +30,7 @@ open Protocol type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] val destruct_block_id : string -> (block_id, string) result diff --git a/src/proto_alpha/lib_tx_rollup/accuser.mli b/src/proto_alpha/lib_tx_rollup/accuser.mli index 3183dc73ad38..23e56026d7d4 100644 --- a/src/proto_alpha/lib_tx_rollup/accuser.mli +++ b/src/proto_alpha/lib_tx_rollup/accuser.mli @@ -40,7 +40,7 @@ val build_rejection : (** [reject_bad_commitment ~source state commitment] injects a rejection operation with [source] if the [commitment] is rejectable. *) val reject_bad_commitment : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> Tx_rollup_commitment.Full.t -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_tx_rollup/batcher.ml b/src/proto_alpha/lib_tx_rollup/batcher.ml index b0dce397ccf0..e3e6d0786461 100644 --- a/src/proto_alpha/lib_tx_rollup/batcher.ml +++ b/src/proto_alpha/lib_tx_rollup/batcher.ml @@ -33,7 +33,7 @@ type state = { constants : Constants.t; batch_burn_limit : Tez.t option; index : Context.index; - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; transactions : Tx_queue.t; mutable incr_context : Context.t; lock : Lwt_mutex.t; @@ -158,7 +158,7 @@ let on_register state ~apply (tr : L2_transaction.t) = let open Lwt_result_syntax in Lwt_mutex.with_lock state.lock @@ fun () -> let*? aggregated_signature = - match Bls.aggregate_signature_opt tr.signatures with + match Tezos_crypto.Bls.aggregate_signature_opt tr.signatures with | Some s -> ok s | None -> error_with "could not aggregate signatures of transaction" in @@ -241,7 +241,7 @@ module Types = struct type nonrec state = state type parameters = { - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; index : Context.index; constants : Constants.t; batch_burn_limit : Tez.t option; diff --git a/src/proto_alpha/lib_tx_rollup/batcher.mli b/src/proto_alpha/lib_tx_rollup/batcher.mli index a421b1abce55..6a287c15683f 100644 --- a/src/proto_alpha/lib_tx_rollup/batcher.mli +++ b/src/proto_alpha/lib_tx_rollup/batcher.mli @@ -28,7 +28,7 @@ open Alpha_context (** Initialize the internal state of the batcher. *) val init : rollup:Tx_rollup.t -> - signer:Signature.public_key_hash -> + signer:Tezos_crypto.Signature.public_key_hash -> batch_burn_limit:Tez.t option -> Context.index -> Constants.t -> diff --git a/src/proto_alpha/lib_tx_rollup/context.ml b/src/proto_alpha/lib_tx_rollup/context.ml index d34031bfb9ac..bf3f172fc419 100644 --- a/src/proto_alpha/lib_tx_rollup/context.ml +++ b/src/proto_alpha/lib_tx_rollup/context.ml @@ -88,10 +88,12 @@ end include Protocol.Tx_rollup_l2_context.Make (Irmin_storage) let context_hash_to_l2 hash = - Context_hash.to_bytes hash |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn + Tezos_crypto.Context_hash.to_bytes hash + |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn let l2_to_context_hash hash = - Protocol.Tx_rollup_l2_context_hash.to_bytes hash |> Context_hash.of_bytes_exn + Protocol.Tx_rollup_l2_context_hash.to_bytes hash + |> Tezos_crypto.Context_hash.of_bytes_exn let exists index hash = Raw.exists index (l2_to_context_hash hash) @@ -223,7 +225,7 @@ let init_context index = let* tree = Prover_context.Ticket_index.init_counter tree in let tree_hash = hash_tree tree in assert ( - Context_hash.( + Tezos_crypto.Context_hash.( tree_hash = Protocol.Tx_rollup_message_result_repr.empty_l2_context_hash)) ; let* ctxt, _ = add_tree ctxt tree in return ctxt diff --git a/src/proto_alpha/lib_tx_rollup/context.mli b/src/proto_alpha/lib_tx_rollup/context.mli index 5c781082268d..154f5818a386 100644 --- a/src/proto_alpha/lib_tx_rollup/context.mli +++ b/src/proto_alpha/lib_tx_rollup/context.mli @@ -119,7 +119,7 @@ val produce_proof : (tree -> 'a produce_proof_result Lwt.t) -> (Protocol.Tx_rollup_l2_proof.t * 'a produce_proof_result) tzresult Lwt.t -val hash_tree : tree -> Context_hash.t +val hash_tree : tree -> Tezos_crypto.Context_hash.t (** [add_tree ctxt tree] adds [tree] in the [ctxt]. In order to perform actions on the tree (e.g. proof production), it needs to be persistent. Thus, @@ -133,7 +133,7 @@ val hash_tree : tree -> Context_hash.t val add_tree : context -> tree -> (context * Protocol.Tx_rollup_l2_context_hash.t) Lwt.t -val tree_hash_of_context : context -> Context_hash.t tzresult Lwt.t +val tree_hash_of_context : context -> Tezos_crypto.Context_hash.t tzresult Lwt.t (** {2 Sub-context for tickets } *) diff --git a/src/proto_alpha/lib_tx_rollup/dispatcher.mli b/src/proto_alpha/lib_tx_rollup/dispatcher.mli index 7b23a612ab55..e143b73b8ceb 100644 --- a/src/proto_alpha/lib_tx_rollup/dispatcher.mli +++ b/src/proto_alpha/lib_tx_rollup/dispatcher.mli @@ -26,7 +26,7 @@ (** Produce dispatch of withdrawals operations and sends them to the injector. *) val dispatch_withdrawals : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> L2block.t -> unit tzresult Lwt.t diff --git a/src/proto_alpha/lib_tx_rollup/dune b/src/proto_alpha/lib_tx_rollup/dune index 00d94f969ec0..a922e7feda9e 100644 --- a/src/proto_alpha/lib_tx_rollup/dune +++ b/src/proto_alpha/lib_tx_rollup/dune @@ -35,7 +35,6 @@ -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base - -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_client_alpha -open Tezos_client_commands diff --git a/src/proto_alpha/lib_tx_rollup/error.ml b/src/proto_alpha/lib_tx_rollup/error.ml index 13277743addf..5e95ec3c32f2 100644 --- a/src/proto_alpha/lib_tx_rollup/error.ml +++ b/src/proto_alpha/lib_tx_rollup/error.ml @@ -217,8 +217,8 @@ let () = type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } let () = @@ -233,15 +233,15 @@ let () = ppf "Rollup origination on disk (%a) is different from the provided rollup \ genesis (%a)" - Block_hash.pp + Tezos_crypto.Block_hash.pp disk_rollup - Block_hash.pp + Tezos_crypto.Block_hash.pp given_rollup) `Permanent Data_encoding.( obj2 - (req "disk_rollup" Block_hash.encoding) - (req "given_rollup" Block_hash.encoding)) + (req "disk_rollup" Tezos_crypto.Block_hash.encoding) + (req "given_rollup" Tezos_crypto.Block_hash.encoding)) (function | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis} -> @@ -251,7 +251,7 @@ let () = Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis}) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -264,10 +264,10 @@ let () = "The operation receipt of %a is unavailable. Please make sure that the \ history mode of the Tezos node you are connecting to matches the \ requirements." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "context" Operation_hash.encoding)) + Data_encoding.(obj1 (req "context" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_no_operation_metadata o -> Some o | _ -> None) (fun o -> Tx_rollup_no_operation_metadata o) @@ -287,7 +287,7 @@ let () = (function Tx_rollup_mismatch -> Some () | _ -> None) (fun () -> Tx_rollup_mismatch) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -298,10 +298,10 @@ let () = Format.fprintf ppf "The Tezos block %a cannot be fetched from the node." - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_cannot_fetch_tezos_block b -> Some b | _ -> None) (fun b -> Tx_rollup_cannot_fetch_tezos_block b) @@ -396,7 +396,7 @@ let () = type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t let () = register_error_kind @@ -409,13 +409,13 @@ let () = "No inbox on L1 for rollup level %a at block %a" Protocol.Alpha_context.Tx_rollup_level.pp l - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent Data_encoding.( obj2 (req "level" Protocol.Alpha_context.Tx_rollup_level.encoding) - (req "block" Block_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_no_proto_inbox (l, b) -> Some (l, b) | _ -> None) (fun (l, b) -> Tx_rollup_no_proto_inbox (l, b)) @@ -543,7 +543,7 @@ let () = (function Tx_rollup_deposit_not_allowed -> Some () | _ -> None) (fun () -> Tx_rollup_deposit_not_allowed) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -555,10 +555,10 @@ let () = ppf "The deposit for our operator was slashed in operation %a. Aborting to \ investigate." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "operation" Operation_hash.encoding)) + Data_encoding.(obj1 (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_deposit_slashed o -> Some o | _ -> None) (fun o -> Tx_rollup_deposit_slashed o) diff --git a/src/proto_alpha/lib_tx_rollup/error.mli b/src/proto_alpha/lib_tx_rollup/error.mli index 5c396b5a3671..2d2f7286b60f 100644 --- a/src/proto_alpha/lib_tx_rollup/error.mli +++ b/src/proto_alpha/lib_tx_rollup/error.mli @@ -69,18 +69,18 @@ type error += Tx_rollup_no_rollup_info_on_disk_and_no_rollup_genesis_given different from the given rollup genesis. *) type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } (** Error when operation metadata is not available. *) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t (** Error when rollup stored on disk is different from the expected one. *) type error += Tx_rollup_mismatch (** Error when Tezos block cannot be fetched. *) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t (** Error when the tree is not found in the context. *) type error += Tx_rollup_tree_not_found @@ -102,7 +102,7 @@ type error += (** Error when the tezos node does not know the inbox *) type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t (** Error when the node reconstructed a different inbox than the one stored on L1 *) type error += @@ -131,6 +131,6 @@ type error += type error += Tx_rollup_deposit_not_allowed (** Error (fatal) when we are slashed *) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t type error += Wrong_deposit_parameters diff --git a/src/proto_alpha/lib_tx_rollup/event.ml b/src/proto_alpha/lib_tx_rollup/event.ml index e97224f42dfc..9a64f9f15734 100644 --- a/src/proto_alpha/lib_tx_rollup/event.ml +++ b/src/proto_alpha/lib_tx_rollup/event.ml @@ -101,7 +101,7 @@ let new_block = ~name:"tx_rollup_node_new_block" ~msg:"new block with hash: {block_hash}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block = declare_2 @@ -109,8 +109,8 @@ let processing_block = ~name:"tx_rollup_node_processing_block" ~msg:"processing block: {block_hash} (pred: {predecessor_hash})" ~level:Debug - ("block_hash", Block_hash.encoding) - ("predecessor_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) let missing_blocks = declare_1 @@ -126,7 +126,7 @@ let look_for_origination = ~name:"tx_rollup_node_look_for_origination" ~msg:"Looking for rollup origination in block {block} level {level}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let detected_origination = @@ -136,7 +136,7 @@ let detected_origination = ~msg:"Detected rollup {rollup} origination in {block}" ~level:Notice ("rollup", Protocol.Alpha_context.Tx_rollup.encoding) - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let tezos_block_processed = declare_2 @@ -144,7 +144,7 @@ let tezos_block_processed = ~name:"tx_rollup_node_tezos_block_processed" ~msg:"tezos block {block_hash} at level {level} was sucessfully processed" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let block_already_processed = @@ -155,7 +155,7 @@ let block_already_processed = "the block {block_hash} has already been processed, nothing more to be \ done" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block_predecessor = declare_2 @@ -165,7 +165,7 @@ let processing_block_predecessor = "processing block predecessor {predecessor_hash} at level \ {predecessor_level}" ~level:Debug - ("predecessor_hash", Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) ("predecessor_level", Data_encoding.int32) let messages_application = @@ -184,7 +184,7 @@ let rollup_block = ~level:Notice ("level", L2block.level_encoding) ("hash", L2block.Hash.encoding) - ("tezos_hash", Block_hash.encoding) + ("tezos_hash", Tezos_crypto.Block_hash.encoding) let inbox_stored = declare_4 @@ -194,7 +194,7 @@ let inbox_stored = "an inbox with size {cumulated_size} and resulting context hash \ {context_hash} has been stored for {block_hash}: {messages}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("messages", Data_encoding.list Inbox.message_encoding) ("cumulated_size", Data_encoding.int31) ("context_hash", Protocol.Tx_rollup_l2_context_hash.encoding) @@ -213,7 +213,7 @@ let new_tezos_head = ~name:"tx_rollup_node_new_tezos_head" ~msg:"a new tezos head ({tezos_head}) is stored" ~level:Notice - ("tezos_head", Block_hash.encoding) + ("tezos_head", Tezos_crypto.Block_hash.encoding) let inject_wait = declare_1 diff --git a/src/proto_alpha/lib_tx_rollup/fancy_l2block.ml b/src/proto_alpha/lib_tx_rollup/fancy_l2block.ml index caf3d41391aa..196a618b57d6 100644 --- a/src/proto_alpha/lib_tx_rollup/fancy_l2block.ml +++ b/src/proto_alpha/lib_tx_rollup/fancy_l2block.ml @@ -102,7 +102,7 @@ let signer_value ctxt signer = | Left _ -> assert false) | Right Tx_rollup_l2_batch.(L2_addr _) -> return signer | Right Tx_rollup_l2_batch.(Bls_pk pk) -> - let addr = Bls.Public_key.hash pk in + let addr = Tezos_crypto.Bls.Public_key.hash pk in return (value (Tx_rollup_l2_batch.L2_addr addr) |> forget) let transaction_replace_indexes ctxt transaction = @@ -280,7 +280,7 @@ let l2_message_encoding = (req "result" transaction_result_encoding)))) (req "withdrawals" (list Tx_rollup_withdraw.encoding)) (req "indexes" indexes_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Ok_batch { @@ -314,7 +314,7 @@ let l2_message_encoding = "transactions" (list Tx_rollup_l2_batch.V1.transaction_encoding)) (req "errors" Error_monad.trace_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Failing_batch {transactions; reasons; aggregated_signature} -> Some (transactions, reasons, aggregated_signature) diff --git a/src/proto_alpha/lib_tx_rollup/inbox.ml b/src/proto_alpha/lib_tx_rollup/inbox.ml index 0129b636d665..40bdec5a250a 100644 --- a/src/proto_alpha/lib_tx_rollup/inbox.ml +++ b/src/proto_alpha/lib_tx_rollup/inbox.ml @@ -34,7 +34,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; } type message = { @@ -71,7 +71,7 @@ let l2_context_hash_encoding = (fun (irmin_hash, tree_hash) -> {irmin_hash; tree_hash}) (obj2 (req "irmin_hash" Tx_rollup_l2_context_hash.encoding) - (req "tree_hash" Context_hash.encoding)) + (req "tree_hash" Tezos_crypto.Context_hash.encoding)) let message_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_tx_rollup/inbox.mli b/src/proto_alpha/lib_tx_rollup/inbox.mli index 58798b6a839f..9b874b09d866 100644 --- a/src/proto_alpha/lib_tx_rollup/inbox.mli +++ b/src/proto_alpha/lib_tx_rollup/inbox.mli @@ -41,7 +41,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; (** The context hash of the commited context, used for checkout *) - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; (** The tree hash is the hash of the underlying tree in the {!Context}, used to produce proofs *) } diff --git a/src/proto_alpha/lib_tx_rollup/l2_transaction.ml b/src/proto_alpha/lib_tx_rollup/l2_transaction.ml index e772948c9265..15aa8a7e9041 100644 --- a/src/proto_alpha/lib_tx_rollup/l2_transaction.ml +++ b/src/proto_alpha/lib_tx_rollup/l2_transaction.ml @@ -38,13 +38,13 @@ let encoding = (fun (transaction, signatures) -> {transaction; signatures}) @@ obj2 (req "transaction" Tx_rollup_l2_batch.V1.transaction_encoding) - (req "signatures" (list Bls.encoding)) + (req "signatures" (list Tezos_crypto.Bls.encoding)) let batch l = let contents = List.map (fun {transaction; _} -> transaction) l in let aggregated_signature = List.concat_map (fun {signatures; _} -> signatures) l - |> Bls.aggregate_signature_opt + |> Tezos_crypto.Bls.aggregate_signature_opt in match aggregated_signature with | None -> error_with "Cannot aggregate signatures" @@ -52,8 +52,8 @@ let batch l = ok Tx_rollup_l2_batch.(V1 V1.{contents; aggregated_signature}) module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_transaction_hash" @@ -64,7 +64,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 type hash = Hash.t diff --git a/src/proto_alpha/lib_tx_rollup/l2_transaction.mli b/src/proto_alpha/lib_tx_rollup/l2_transaction.mli index ac8ffa3bdfd9..d431b65218d6 100644 --- a/src/proto_alpha/lib_tx_rollup/l2_transaction.mli +++ b/src/proto_alpha/lib_tx_rollup/l2_transaction.mli @@ -34,7 +34,7 @@ type t = { } (** Hash with b58check encoding txL2(54), for hashes of L2 transactions *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for transaction hash *) type hash = Hash.t diff --git a/src/proto_alpha/lib_tx_rollup/l2block.ml b/src/proto_alpha/lib_tx_rollup/l2block.ml index f3a7cce3aa7d..aa1f6ff01081 100644 --- a/src/proto_alpha/lib_tx_rollup/l2block.ml +++ b/src/proto_alpha/lib_tx_rollup/l2block.ml @@ -27,8 +27,8 @@ open Protocol open Alpha_context module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_block_hash" @@ -39,7 +39,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 type hash = Hash.t @@ -47,7 +48,7 @@ type level = Tx_rollup_level.t type header = { level : level; - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; predecessor : hash option; context : Tx_rollup_l2_context_hash.t; commitment : Tx_rollup_commitment_hash.t; @@ -63,8 +64,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } type metadata = { @@ -85,7 +86,7 @@ let header_encoding = {level; tezos_block; predecessor; context; commitment}) (obj5 (req "level" Tx_rollup_level.encoding) - (req "tezos_block" Block_hash.encoding) + (req "tezos_block" Tezos_crypto.Block_hash.encoding) (opt "predecessor" Hash.encoding) (req "context" Tx_rollup_l2_context_hash.encoding) (req "commitment" Tx_rollup_commitment_hash.encoding)) @@ -109,8 +110,8 @@ let commitment_included_info_encoding = (fun {block; operation} -> (block, operation)) (fun (block, operation) -> {block; operation}) (obj2 - (req "block" Block_hash.encoding) - (req "operation" Operation_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding)) let metadata_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_tx_rollup/l2block.mli b/src/proto_alpha/lib_tx_rollup/l2block.mli index f7ee52d66544..a5176b6a5db6 100644 --- a/src/proto_alpha/lib_tx_rollup/l2block.mli +++ b/src/proto_alpha/lib_tx_rollup/l2block.mli @@ -29,7 +29,7 @@ open Alpha_context (** {2 Types for L2 block and header} *) (** Hash with b58check encoding BTx(53), for hashes of L2 block headers *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for block (header) hashes *) type hash = Hash.t @@ -40,7 +40,7 @@ type level = Tx_rollup_level.t (** Type of L2 block headers *) type header = { level : level; (** The level of the L2 block *) - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; (** The Tezos block on which this L2 block in anchored, i.e. the Tezos block in which the inbox was sent *) predecessor : hash option; (** The hash predecessor L2 block *) @@ -63,8 +63,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } (** Metadata for the block *) diff --git a/src/proto_alpha/lib_tx_rollup/node_config.ml b/src/proto_alpha/lib_tx_rollup/node_config.ml index c8f905f9ad8f..80c54b6d5647 100644 --- a/src/proto_alpha/lib_tx_rollup/node_config.ml +++ b/src/proto_alpha/lib_tx_rollup/node_config.ml @@ -38,7 +38,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; @@ -171,28 +171,28 @@ let signers_encoding = (opt ~description:"The operator of the rollup (public key hash) if any" "operator" - Signature.Public_key_hash.encoding) + Tezos_crypto.Signature.Public_key_hash.encoding) (opt "submit_batch" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for batch submission") (opt "finalize_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for finalization of commitments") (opt "remove_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for removals of commitments") (opt "rejection" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for rejections") (opt "dispatch_withdrawals" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for the dispatch of withdrawals") diff --git a/src/proto_alpha/lib_tx_rollup/node_config.mli b/src/proto_alpha/lib_tx_rollup/node_config.mli index ae293e66e136..31a006cc418c 100644 --- a/src/proto_alpha/lib_tx_rollup/node_config.mli +++ b/src/proto_alpha/lib_tx_rollup/node_config.mli @@ -50,7 +50,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; diff --git a/src/proto_alpha/lib_tx_rollup/state.ml b/src/proto_alpha/lib_tx_rollup/state.ml index c1a0193678eb..4f36987d28e2 100644 --- a/src/proto_alpha/lib_tx_rollup/state.ml +++ b/src/proto_alpha/lib_tx_rollup/state.ml @@ -33,7 +33,7 @@ module Tezos_blocks_cache = Ringo_lwt.Functors.Make_opt ((val Ringo.( map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash)) + (Tezos_crypto.Block_hash)) type rollup_info = Stores.rollup_info = { rollup_id : Tx_rollup.t; diff --git a/src/proto_alpha/lib_tx_rollup/state.mli b/src/proto_alpha/lib_tx_rollup/state.mli index 38850fdfb931..31f435535905 100644 --- a/src/proto_alpha/lib_tx_rollup/state.mli +++ b/src/proto_alpha/lib_tx_rollup/state.mli @@ -33,7 +33,7 @@ open Injector_common data. *) module Tezos_blocks_cache : - Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Block_hash.t + Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Tezos_crypto.Block_hash.t (** Information about the rollup that is kept in the state. *) type rollup_info = Stores.rollup_info = { @@ -102,10 +102,12 @@ val get_header : t -> L2block.hash -> L2block.header option Lwt.t there is no inbox for an L1 block, we associate to it the L2 block of its predecessor. So [get_tezos_l2_block_hash state h] returns L2 block hash at which the rollup was when the Tezos node was at block [h]. *) -val get_tezos_l2_block_hash : t -> Block_hash.t -> L2block.hash option Lwt.t +val get_tezos_l2_block_hash : + t -> Tezos_crypto.Block_hash.t -> L2block.hash option Lwt.t (** Same as {!get_tezos_block} but retrieves the associated L2 block at the same time. *) -val get_tezos_l2_block : t -> Block_hash.t -> L2block.t option Lwt.t +val get_tezos_l2_block : + t -> Tezos_crypto.Block_hash.t -> L2block.t option Lwt.t (** Same as {!get_level} but retrieves the associated header at the same time. *) val get_level_l2_block_header : @@ -119,7 +121,9 @@ val get_level_l2_block : t -> L2block.level -> L2block.t option Lwt.t block for the Tezos block, or [None] otherwise. It returns [`Unknown] when the Tezos block has never been processed. *) val tezos_block_already_processed : - t -> Block_hash.t -> [> `Known of L2block.t option | `Unknown] Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + [> `Known of L2block.t option | `Unknown] Lwt.t (** Returns the inclusion info for a commitment. *) val get_included_commitment : @@ -145,7 +149,9 @@ val set_head : t -> L2block.t -> L2block.t reorg tzresult Lwt.t (** Set the Tezos head and returns the reorganization of L1 blocks. *) val set_tezos_head : - t -> Block_hash.t -> Alpha_block_services.block_info reorg tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info reorg tzresult Lwt.t (** Save an L2 block to disk: - Save both the header and the inbox @@ -161,18 +167,18 @@ val save_level : t -> L2block.level -> L2block.hash -> unit Lwt.t predecessor as well. *) val save_tezos_block_info : t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> L2block.hash option -> level:int32 -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> unit Lwt.t (** Register a commitment as included on L1. *) val set_commitment_included : t -> Tx_rollup_commitment_hash.t -> - Block_hash.t -> - Operation_hash.t -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Lwt.t (** Register a commitment as not included on L1. *) @@ -197,7 +203,9 @@ val rollup_operation_index : int (** Fetch a Tezos block from the cache or the node *) val fetch_tezos_block : - t -> Block_hash.t -> Alpha_block_services.block_info tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info tzresult Lwt.t (** Compute the reorganization of L2 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) diff --git a/src/proto_alpha/lib_tx_rollup/stores.ml b/src/proto_alpha/lib_tx_rollup/stores.ml index 8b79f9b66190..2a010ab01c51 100644 --- a/src/proto_alpha/lib_tx_rollup/stores.ml +++ b/src/proto_alpha/lib_tx_rollup/stores.ml @@ -308,7 +308,7 @@ end module L2_block_key = struct include L2block.Hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -358,9 +358,9 @@ module L2_level_key = struct end module Operation_key = struct - include Operation_hash + include Tezos_crypto.Operation_hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -461,7 +461,7 @@ module Tezos_block_info = struct type t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } let t = @@ -471,7 +471,8 @@ module Tezos_block_info = struct (fun (l2_block, level, predecessor) -> {l2_block; level; predecessor}) (fun {l2_block; level; predecessor} -> (l2_block, level, predecessor)) - let encoded_size = L2block.Hash.size + 4 (* level *) + Block_hash.size + let encoded_size = + L2block.Hash.size + 4 (* level *) + Tezos_crypto.Block_hash.size let encode v = let dst = Bytes.create encoded_size in @@ -482,7 +483,9 @@ module Tezos_block_info = struct in let offset = blit ~src:l2_block_bytes ~dst 0 in let offset = bytes_set_int32 ~dst ~src:v.level offset in - let _ = blit ~src:(Block_hash.to_bytes v.predecessor) ~dst offset in + let _ = + blit ~src:(Tezos_crypto.Block_hash.to_bytes v.predecessor) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = @@ -493,13 +496,20 @@ module Tezos_block_info = struct in let level, offset = read_int32 str offset in let predecessor, _ = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in {l2_block; level; predecessor} end module Commitment_info = struct - type t = {block : Block_hash.t; operation : Operation_hash.t} + type t = { + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; + } let t = let open Repr in @@ -508,20 +518,31 @@ module Commitment_info = struct (fun (block, operation) -> {block; operation}) (fun {block; operation} -> (block, operation)) - let encoded_size = Block_hash.size + Operation_hash.size + let encoded_size = + Tezos_crypto.Block_hash.size + Tezos_crypto.Operation_hash.size let encode v = let dst = Bytes.create encoded_size in - let offset = blit ~src:(Block_hash.to_bytes v.block) ~dst 0 in - let _ = blit ~src:(Operation_hash.to_bytes v.operation) ~dst offset in + let offset = blit ~src:(Tezos_crypto.Block_hash.to_bytes v.block) ~dst 0 in + let _ = + blit ~src:(Tezos_crypto.Operation_hash.to_bytes v.operation) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = let block, offset = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in let operation, _ = - read_str str ~offset ~len:Operation_hash.size Operation_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Operation_hash.size + Tezos_crypto.Operation_hash.of_string_exn in {block; operation} end @@ -530,7 +551,7 @@ module Tezos_block_store = struct type value = Tezos_block_info.t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } include @@ -548,8 +569,8 @@ module Level_store = module Commitment_store = struct type value = Commitment_info.t = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } include @@ -713,11 +734,11 @@ module Head_store = Make_singleton (struct end) module Tezos_head_store = Make_singleton (struct - type t = Block_hash.t + type t = Tezos_crypto.Block_hash.t let name = "tezos_head" - let encoding = Block_hash.encoding + let encoding = Tezos_crypto.Block_hash.encoding end) type rollup_info = { diff --git a/src/proto_alpha/lib_tx_rollup/stores.mli b/src/proto_alpha/lib_tx_rollup/stores.mli index 287ab3861d7c..cae8329b0109 100644 --- a/src/proto_alpha/lib_tx_rollup/stores.mli +++ b/src/proto_alpha/lib_tx_rollup/stores.mli @@ -124,10 +124,13 @@ module Tezos_block_store : sig type value = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } - include INDEXABLE_STORE with type key := Block_hash.t and type value := value + include + INDEXABLE_STORE + with type key := Tezos_crypto.Block_hash.t + and type value := value end (** An index store to map L2 block level to L2 block hashes. It is composed @@ -140,9 +143,9 @@ module Level_store : (** An index store to map commitment hashes to their inclusion information. *) module Commitment_store : sig type value = { - block : Block_hash.t; + block : Tezos_crypto.Block_hash.t; (** Tezos block in which the commitment is included. *) - operation : Operation_hash.t; + operation : Tezos_crypto.Operation_hash.t; (** Operation of the block in which the commitment is included. *) } @@ -158,7 +161,8 @@ end module Head_store : SINGLETON_STORE with type value := L2block.hash (** A store composed of a single file on disk to store the current Tezos head *) -module Tezos_head_store : SINGLETON_STORE with type value := Block_hash.t +module Tezos_head_store : + SINGLETON_STORE with type value := Tezos_crypto.Block_hash.t (** Type for on disk information about a rollup *) type rollup_info = { -- GitLab From 827fd19c9b715e53979940cb744fef82f6c3d6dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 11:08:47 +0200 Subject: [PATCH 21/30] Protos: unopen Crypto --- .../lib_client/client_proto_main.ml | 14 +- .../lib_client/client_proto_main.mli | 2 +- .../lib_client/operation_result.ml | 34 ++-- .../client_proto_programs_commands.ml | 6 +- .../lib_client/client_proto_context.ml | 2 +- .../lib_client/client_proto_context.mli | 2 +- .../lib_client/operation_result.ml | 34 ++-- .../client_proto_context_commands.ml | 2 +- .../client_proto_programs_commands.ml | 6 +- .../lib_client/client_proto_context.ml | 4 +- .../lib_client/client_proto_context.mli | 4 +- .../lib_client/operation_result.ml | 34 ++-- .../client_proto_context_commands.ml | 15 +- .../client_proto_programs_commands.ml | 6 +- .../lib_client/client_proto_context.ml | 4 +- .../lib_client/client_proto_context.mli | 4 +- .../lib_client/operation_result.ml | 34 ++-- .../client_proto_context_commands.ml | 15 +- .../client_proto_programs_commands.ml | 9 +- .../lib_client/client_proto_context.ml | 4 +- .../lib_client/client_proto_context.mli | 4 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 14 +- .../lib_client/operation_result.ml | 34 ++-- .../client_proto_context_commands.ml | 15 +- .../client_proto_programs_commands.ml | 9 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 10 +- .../lib_client/client_proto_multisig.ml | 40 ++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 18 +- .../lib_client/operation_result.ml | 35 ++-- .../client_proto_context_commands.ml | 42 ++-- .../client_proto_multisig_commands.ml | 13 +- .../client_proto_programs_commands.ml | 9 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 4 +- .../lib_client/client_proto_context.mli | 4 +- .../lib_client/managed_contract.ml | 6 +- .../lib_client/operation_result.ml | 35 ++-- .../client_proto_context_commands.ml | 15 +- .../client_proto_programs_commands.ml | 2 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 10 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 20 +- .../lib_client/operation_result.ml | 35 ++-- .../client_proto_context_commands.ml | 42 ++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_programs_commands.ml | 9 +- src/proto_008_PtEdo2Zk/lib_plugin/plugin.ml | 8 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 10 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 20 +- .../lib_client/operation_result.ml | 35 ++-- .../client_proto_context_commands.ml | 41 ++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_utils_commands.ml | 4 +- src/proto_009_PsFLoren/lib_plugin/plugin.ml | 8 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 10 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 20 +- .../lib_client/operation_result.ml | 35 ++-- .../client_proto_context_commands.ml | 41 ++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_utils_commands.ml | 4 +- src/proto_010_PtGRANAD/lib_plugin/plugin.ml | 12 +- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 14 +- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 50 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 20 +- src/proto_011_PtHangz2/lib_client/mockup.ml | 31 +-- .../lib_client/operation_result.ml | 35 ++-- src/proto_011_PtHangz2/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 41 ++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 141 +++++++------ .../client_proto_utils_commands.ml | 4 +- .../client_sapling_commands.ml | 8 +- .../lib_client_sapling/context.ml | 8 +- .../lib_client_sapling/context.mli | 5 +- .../lib_client_sapling/wallet.ml | 2 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 4 +- src/proto_011_PtHangz2/lib_plugin/plugin.ml | 47 +++-- .../lib_client/client_proto_args.ml | 2 +- .../lib_client/client_proto_args.mli | 5 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 16 +- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 47 +++-- .../lib_client/injection.mli | 13 +- .../lib_client/managed_contract.ml | 20 +- src/proto_012_Psithaca/lib_client/mockup.ml | 42 ++-- .../lib_client/operation_result.ml | 41 ++-- src/proto_012_Psithaca/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 46 +++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 141 +++++++------ .../client_proto_utils_commands.ml | 7 +- .../client_sapling_commands.ml | 8 +- .../lib_client_sapling/context.ml | 8 +- .../lib_client_sapling/context.mli | 5 +- .../lib_client_sapling/wallet.ml | 2 +- .../lib_delegate/baking_events.ml | 100 ++++----- .../lib_delegate/delegate_events.ml | 68 +++---- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 4 +- src/proto_012_Psithaca/lib_plugin/plugin.ml | 127 +++++++----- .../lib_client/client_proto_args.ml | 4 +- .../lib_client/client_proto_args.mli | 7 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 82 ++++---- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 55 ++--- .../lib_client/injection.mli | 15 +- .../lib_client/managed_contract.ml | 20 +- src/proto_013_PtJakart/lib_client/mockup.ml | 42 ++-- .../lib_client/operation_result.ml | 41 ++-- src/proto_013_PtJakart/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 46 +++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 128 +++++++----- .../client_proto_utils_commands.ml | 7 +- .../client_sapling_commands.ml | 12 +- .../lib_client_sapling/context.ml | 2 +- .../lib_client_sapling/wallet.ml | 2 +- .../lib_delegate/baking_events.ml | 100 ++++----- .../lib_delegate/delegate_events.ml | 68 +++---- src/proto_013_PtJakart/lib_injector/common.ml | 6 +- .../lib_injector/common.mli | 20 +- .../lib_injector/disk_persistence.ml | 2 +- .../lib_injector/disk_persistence.mli | 2 +- src/proto_013_PtJakart/lib_injector/dune | 1 - .../lib_injector/injector_errors.ml | 7 +- .../lib_injector/injector_errors.mli | 2 +- .../lib_injector/injector_events.ml | 18 +- .../lib_injector/injector_functor.ml | 49 +++-- .../lib_injector/injector_worker_types.ml | 8 +- .../lib_injector/l1_operation.ml | 9 +- .../lib_injector/l1_operation.mli | 2 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 4 +- src/proto_013_PtJakart/lib_plugin/plugin.ml | 128 +++++++----- .../bin_tx_rollup_client/commands.ml | 28 ++- src/proto_014_PtKathma/lib_benchmark/dune | 1 - .../lib_benchmark/execution_context.ml | 6 +- .../lib_benchmark/michelson_samplers.ml | 4 +- .../lib_benchmark/michelson_samplers_base.ml | 16 +- .../lib_benchmark/michelson_samplers_base.mli | 2 +- .../lib_benchmarks_proto/dune | 1 - .../encodings_benchmarks.ml | 27 ++- .../interpreter_benchmarks.ml | 28 ++- .../interpreter_workload.ml | 18 +- .../sc_rollup_benchmarks.ml | 4 +- .../lib_benchmarks_proto/ticket_benchmarks.ml | 9 +- .../lib_client/client_proto_args.ml | 4 +- .../lib_client/client_proto_args.mli | 7 +- .../lib_client/client_proto_context.ml | 30 +-- .../lib_client/client_proto_context.mli | 92 ++++----- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 55 ++--- .../lib_client/injection.mli | 15 +- .../lib_client/managed_contract.ml | 20 +- src/proto_014_PtKathma/lib_client/mockup.ml | 56 ++++-- .../lib_client/operation_result.ml | 53 ++--- src/proto_014_PtKathma/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 46 +++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 134 ++++++------ .../client_proto_utils_commands.ml | 7 +- .../client_sapling_commands.ml | 12 +- .../lib_client_sapling/context.ml | 2 +- .../lib_delegate/abstract_context_index.ml | 3 +- .../lib_delegate/abstract_context_index.mli | 3 +- .../lib_delegate/baking_cache.ml | 2 +- .../lib_delegate/baking_commands.ml | 2 +- .../lib_delegate/baking_configuration.ml | 4 +- .../lib_delegate/baking_configuration.mli | 9 +- .../lib_delegate/baking_events.ml | 104 +++++----- .../lib_delegate/baking_files.ml | 2 +- .../lib_delegate/baking_files.mli | 2 +- .../lib_delegate/baking_highwatermarks.ml | 6 +- .../lib_delegate/baking_highwatermarks.mli | 12 +- .../lib_delegate/baking_lib.ml | 4 +- .../lib_delegate/baking_nonces.ml | 50 +++-- .../lib_delegate/baking_nonces.mli | 45 +++-- .../lib_delegate/baking_pow.ml | 2 +- .../lib_delegate/baking_scheduling.ml | 8 +- .../lib_delegate/baking_simulator.ml | 4 +- .../lib_delegate/baking_simulator.mli | 4 +- .../lib_delegate/baking_state.ml | 57 +++--- .../lib_delegate/baking_state.mli | 16 +- .../lib_delegate/baking_vdf.ml | 4 +- .../lib_delegate/block_forge.ml | 17 +- .../lib_delegate/block_forge.mli | 2 +- .../lib_delegate/client_baking_blocks.ml | 28 +-- .../lib_delegate/client_baking_blocks.mli | 20 +- .../client_baking_denunciation.ml | 31 +-- .../lib_delegate/client_daemon.ml | 6 +- .../lib_delegate/delegate_events.ml | 28 +-- .../lib_delegate/logging.ml | 8 +- .../lib_delegate/node_rpc.ml | 8 +- .../lib_delegate/node_rpc.mli | 6 +- .../lib_delegate/operation_pool.ml | 2 +- .../lib_delegate/operation_selection.ml | 11 +- .../lib_delegate/operation_selection.mli | 2 +- .../lib_delegate/operation_worker.ml | 7 +- .../lib_delegate/operation_worker.mli | 2 +- .../lib_delegate/state_transitions.ml | 22 +- .../mockup_simulator/faked_client_context.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 27 ++- .../test/mockup_simulator/mockup_simulator.ml | 190 +++++++++++------- .../mockup_simulator/mockup_simulator.mli | 56 +++--- .../test/tenderbrute/lib/tenderbrute.ml | 7 +- .../test/tenderbrute/lib/tenderbrute.mli | 4 +- .../test/tenderbrute/tenderbrute_main.ml | 2 +- .../lib_delegate/test/test_scenario.ml | 10 +- src/proto_014_PtKathma/lib_injector/common.ml | 6 +- .../lib_injector/common.mli | 20 +- .../lib_injector/disk_persistence.ml | 2 +- .../lib_injector/disk_persistence.mli | 2 +- src/proto_014_PtKathma/lib_injector/dune | 1 - .../lib_injector/injector_errors.ml | 7 +- .../lib_injector/injector_errors.mli | 2 +- .../lib_injector/injector_events.ml | 18 +- .../lib_injector/injector_functor.ml | 49 +++-- .../lib_injector/injector_worker_types.ml | 8 +- .../lib_injector/l1_operation.ml | 9 +- .../lib_injector/l1_operation.mli | 2 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 6 +- src/proto_014_PtKathma/lib_plugin/RPC.ml | 56 +++--- src/proto_014_PtKathma/lib_plugin/mempool.ml | 72 ++++--- .../lib_plugin/test/generators.ml | 42 ++-- .../lib_plugin/test/test_filter_state.ml | 39 ++-- .../lib_plugin/test/test_utils.ml | 24 +-- .../lib_protocol/test/helpers/account.ml | 50 +++-- .../lib_protocol/test/helpers/account.mli | 18 +- .../lib_protocol/test/helpers/assert.ml | 12 +- .../lib_protocol/test/helpers/block.ml | 67 +++--- .../lib_protocol/test/helpers/block.mli | 12 +- .../lib_protocol/test/helpers/context.ml | 9 +- .../lib_protocol/test/helpers/context.mli | 18 +- .../test/helpers/contract_helpers.ml | 5 +- .../lib_protocol/test/helpers/expr_common.ml | 2 +- .../lib_protocol/test/helpers/incremental.ml | 26 ++- .../test/helpers/liquidity_baking_machine.ml | 6 +- .../test/helpers/lqt_fa12_repr.ml | 2 +- .../lib_protocol/test/helpers/nonce.ml | 2 +- .../lib_protocol/test/helpers/op.ml | 34 ++-- .../lib_protocol/test/helpers/op.mli | 14 +- .../test/helpers/sapling_helpers.ml | 9 +- .../test/helpers/tx_rollup_l2_helpers.ml | 9 +- .../test/integration/consensus/test_baking.ml | 12 +- .../consensus/test_deactivation.ml | 4 +- .../integration/consensus/test_delegation.ml | 4 +- .../consensus/test_double_baking.ml | 8 +- .../consensus/test_double_endorsement.ml | 21 +- .../consensus/test_double_preendorsement.ml | 7 +- .../consensus/test_participation.ml | 2 +- .../test/integration/gas/test_gas_costs.ml | 2 +- .../test/integration/gas/test_gas_levels.ml | 2 +- .../michelson/test_interpretation.ml | 4 +- .../integration/michelson/test_sapling.ml | 2 +- .../michelson/test_script_typed_ir_size.ml | 6 +- .../michelson/test_ticket_balance.ml | 2 +- .../michelson/test_ticket_manager.ml | 2 +- .../integration/michelson/test_timelock.ml | 83 +++++--- .../integration/operations/test_activation.ml | 16 +- .../integration/operations/test_reveal.ml | 12 +- .../integration/operations/test_tx_rollup.ml | 26 ++- .../integration/operations/test_voting.ml | 59 +++--- .../test/integration/test_frozen_bonds.ml | 8 +- .../test/integration/test_token.ml | 43 ++-- .../validate/manager_operation_helpers.ml | 6 +- .../test/pbt/test_script_comparison.ml | 5 +- .../test/pbt/test_tx_rollup_l2_encoding.ml | 10 +- .../test/regression/test_logging.ml | 3 +- .../test/unit/test_contract_repr.ml | 7 +- .../test/unit/test_destination_repr.ml | 2 +- .../lib_protocol/test/unit/test_receipt.ml | 5 +- .../test/unit/test_sc_rollup_arith.ml | 3 +- .../test_sc_rollup_management_protocol.ml | 2 +- .../test/unit/test_sc_rollup_storage.ml | 12 +- .../test/unit/test_tx_rollup_l2.ml | 2 +- .../test/unit/test_tx_rollup_l2_apply.ml | 10 +- src/proto_014_PtKathma/lib_tx_rollup/RPC.ml | 17 +- src/proto_014_PtKathma/lib_tx_rollup/RPC.mli | 2 +- .../lib_tx_rollup/accuser.mli | 2 +- .../lib_tx_rollup/batcher.ml | 6 +- .../lib_tx_rollup/batcher.mli | 2 +- .../lib_tx_rollup/context.ml | 8 +- .../lib_tx_rollup/context.mli | 4 +- .../lib_tx_rollup/dispatcher.mli | 2 +- src/proto_014_PtKathma/lib_tx_rollup/dune | 1 - src/proto_014_PtKathma/lib_tx_rollup/error.ml | 36 ++-- .../lib_tx_rollup/error.mli | 12 +- src/proto_014_PtKathma/lib_tx_rollup/event.ml | 22 +- .../lib_tx_rollup/fancy_l2block.ml | 4 +- src/proto_014_PtKathma/lib_tx_rollup/inbox.ml | 4 +- .../lib_tx_rollup/inbox.mli | 2 +- .../lib_tx_rollup/l2_transaction.ml | 9 +- .../lib_tx_rollup/l2_transaction.mli | 2 +- .../lib_tx_rollup/l2block.ml | 19 +- .../lib_tx_rollup/l2block.mli | 8 +- .../lib_tx_rollup/node_config.ml | 14 +- .../lib_tx_rollup/node_config.mli | 2 +- src/proto_014_PtKathma/lib_tx_rollup/state.ml | 2 +- .../lib_tx_rollup/state.mli | 28 ++- .../lib_tx_rollup/stores.ml | 57 ++++-- .../lib_tx_rollup/stores.mli | 14 +- .../bin_tx_rollup_client/commands.ml | 32 +-- src/proto_015_PtLimaPt/lib_benchmark/dune | 1 - .../lib_benchmark/execution_context.ml | 6 +- .../lib_benchmark/michelson_samplers.ml | 2 +- .../lib_benchmark/michelson_samplers_base.ml | 14 +- .../lib_benchmarks_proto/dune | 1 - .../encodings_benchmarks.ml | 27 ++- .../interpreter_benchmarks.ml | 29 +-- .../interpreter_workload.ml | 18 +- .../sc_rollup_benchmarks.ml | 4 +- .../storage_benchmarks.ml | 2 +- .../lib_benchmarks_proto/ticket_benchmarks.ml | 9 +- .../tx_rollup_benchmarks.ml | 2 +- .../lib_client/client_proto_args.ml | 4 +- .../lib_client/client_proto_args.mli | 7 +- .../lib_client/client_proto_context.ml | 32 +-- .../lib_client/client_proto_context.mli | 108 +++++----- .../lib_client/client_proto_fa12.mli | 2 +- .../lib_client/client_proto_multisig.ml | 49 +++-- .../lib_client/client_proto_multisig.mli | 4 +- .../lib_client/client_proto_programs.ml | 2 +- .../lib_client/client_proto_programs.mli | 2 +- .../lib_client/client_proto_utils.ml | 8 +- .../lib_client/client_proto_utils.mli | 8 +- .../lib_client/injection.ml | 55 ++--- .../lib_client/injection.mli | 15 +- .../lib_client/managed_contract.ml | 18 +- src/proto_015_PtLimaPt/lib_client/mockup.ml | 35 ++-- .../lib_client/operation_result.ml | 63 +++--- src/proto_015_PtLimaPt/lib_client/proxy.ml | 2 +- .../client_proto_context_commands.ml | 52 +++-- .../client_proto_fa12_commands.ml | 3 +- .../client_proto_multisig_commands.ml | 15 +- .../client_proto_programs_commands.ml | 10 +- .../client_proto_stresstest_commands.ml | 134 +++++++----- .../client_proto_utils_commands.ml | 8 +- .../client_sapling_commands.ml | 12 +- .../lib_client_sapling/context.ml | 2 +- .../lib_delegate/abstract_context_index.ml | 3 +- .../lib_delegate/abstract_context_index.mli | 3 +- .../lib_delegate/baking_cache.ml | 2 +- .../lib_delegate/baking_commands.ml | 2 +- .../lib_delegate/baking_configuration.ml | 4 +- .../lib_delegate/baking_configuration.mli | 9 +- .../lib_delegate/baking_events.ml | 104 +++++----- .../lib_delegate/baking_files.ml | 2 +- .../lib_delegate/baking_files.mli | 2 +- .../lib_delegate/baking_highwatermarks.ml | 6 +- .../lib_delegate/baking_highwatermarks.mli | 12 +- .../lib_delegate/baking_lib.ml | 4 +- .../lib_delegate/baking_nonces.ml | 50 +++-- .../lib_delegate/baking_nonces.mli | 45 +++-- .../lib_delegate/baking_pow.ml | 2 +- .../lib_delegate/baking_scheduling.ml | 8 +- .../lib_delegate/baking_simulator.ml | 4 +- .../lib_delegate/baking_simulator.mli | 4 +- .../lib_delegate/baking_state.ml | 69 ++++--- .../lib_delegate/baking_state.mli | 17 +- .../lib_delegate/baking_vdf.ml | 4 +- .../lib_delegate/block_forge.ml | 17 +- .../lib_delegate/block_forge.mli | 2 +- .../lib_delegate/client_baking_blocks.ml | 28 +-- .../lib_delegate/client_baking_blocks.mli | 20 +- .../client_baking_denunciation.ml | 31 +-- .../lib_delegate/client_daemon.ml | 6 +- .../lib_delegate/delegate_events.ml | 28 +-- .../lib_delegate/logging.ml | 8 +- .../lib_delegate/node_rpc.ml | 8 +- .../lib_delegate/node_rpc.mli | 6 +- .../lib_delegate/operation_pool.ml | 2 +- .../lib_delegate/operation_selection.ml | 11 +- .../lib_delegate/operation_selection.mli | 2 +- .../lib_delegate/operation_worker.ml | 7 +- .../lib_delegate/operation_worker.mli | 2 +- .../lib_delegate/state_transitions.ml | 22 +- .../mockup_simulator/faked_client_context.ml | 4 +- .../test/mockup_simulator/faked_services.ml | 27 ++- .../test/mockup_simulator/mockup_simulator.ml | 188 ++++++++++------- .../mockup_simulator/mockup_simulator.mli | 56 +++--- .../test/tenderbrute/lib/tenderbrute.ml | 12 +- .../test/tenderbrute/lib/tenderbrute.mli | 4 +- .../test/tenderbrute/tenderbrute_main.ml | 2 +- .../lib_delegate/test/test_scenario.ml | 10 +- .../lib_injector/disk_persistence.ml | 2 +- .../lib_injector/disk_persistence.mli | 2 +- src/proto_015_PtLimaPt/lib_injector/dune | 1 - .../lib_injector/injector_common.ml | 8 +- .../lib_injector/injector_common.mli | 20 +- .../lib_injector/injector_errors.ml | 7 +- .../lib_injector/injector_errors.mli | 2 +- .../lib_injector/injector_events.ml | 18 +- .../lib_injector/injector_functor.ml | 49 +++-- .../lib_injector/injector_worker_types.ml | 8 +- .../lib_injector/l1_operation.ml | 9 +- .../lib_injector/l1_operation.mli | 2 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_parameters/default_parameters.mli | 8 +- src/proto_015_PtLimaPt/lib_plugin/mempool.ml | 75 ++++--- .../lib_plugin/test/generators.ml | 46 +++-- .../lib_plugin/test/test_filter_state.ml | 29 ++- .../lib_plugin/test/test_utils.ml | 12 +- .../lib_protocol/test/helpers/account.ml | 50 +++-- .../lib_protocol/test/helpers/account.mli | 20 +- .../lib_protocol/test/helpers/assert.ml | 26 +-- .../lib_protocol/test/helpers/block.ml | 64 +++--- .../lib_protocol/test/helpers/block.mli | 14 +- .../lib_protocol/test/helpers/context.ml | 17 +- .../lib_protocol/test/helpers/context.mli | 12 +- .../test/helpers/contract_helpers.ml | 4 +- .../test/helpers/dummy_zk_rollup.ml | 6 +- .../lib_protocol/test/helpers/expr_common.ml | 2 +- .../lib_protocol/test/helpers/incremental.ml | 26 ++- .../test/helpers/liquidity_baking_machine.ml | 6 +- .../test/helpers/lqt_fa12_repr.ml | 2 +- .../lib_protocol/test/helpers/nonce.ml | 2 +- .../lib_protocol/test/helpers/op.ml | 34 ++-- .../lib_protocol/test/helpers/op.mli | 24 +-- .../test/helpers/operation_generator.ml | 20 +- .../test/helpers/sapling_helpers.ml | 9 +- .../test/helpers/tx_rollup_l2_helpers.ml | 9 +- .../test/integration/consensus/test_baking.ml | 12 +- .../consensus/test_deactivation.ml | 4 +- .../integration/consensus/test_delegation.ml | 4 +- .../consensus/test_double_baking.ml | 8 +- .../consensus/test_double_endorsement.ml | 21 +- .../consensus/test_double_preendorsement.ml | 7 +- .../consensus/test_participation.ml | 2 +- .../test/integration/gas/test_gas_costs.ml | 2 +- .../test/integration/gas/test_gas_levels.ml | 2 +- .../michelson/test_interpretation.ml | 4 +- .../integration/michelson/test_sapling.ml | 2 +- .../michelson/test_script_typed_ir_size.ml | 6 +- .../michelson/test_ticket_balance.ml | 2 +- .../michelson/test_ticket_manager.ml | 2 +- .../integration/michelson/test_timelock.ml | 83 +++++--- .../integration/operations/test_activation.ml | 16 +- .../integration/operations/test_reveal.ml | 12 +- .../integration/operations/test_sc_rollup.ml | 14 +- .../integration/operations/test_tx_rollup.ml | 30 +-- .../integration/operations/test_voting.ml | 69 ++++--- .../test/integration/test_frozen_bonds.ml | 8 +- .../test/integration/test_token.ml | 43 ++-- .../validate/generator_descriptors.ml | 40 +++- .../validate/generator_descriptors.mli | 2 +- .../validate/manager_operation_helpers.ml | 6 +- .../test/integration/validate/test_mempool.ml | 24 ++- .../integration/validate/validate_helpers.ml | 18 +- .../test/pbt/test_script_comparison.ml | 5 +- .../test/pbt/test_tx_rollup_l2_encoding.ml | 10 +- .../test/pbt/test_zk_rollup_encoding.ml | 2 +- .../test/regression/test_logging.ml | 4 +- .../test/unit/test_consensus_key.ml | 8 +- .../test/unit/test_contract_repr.ml | 7 +- .../test/unit/test_destination_repr.ml | 2 +- .../lib_protocol/test/unit/test_receipt.ml | 5 +- .../test/unit/test_sc_rollup_game.ml | 2 +- .../test_sc_rollup_management_protocol.ml | 2 +- .../test/unit/test_sc_rollup_storage.ml | 14 +- .../test/unit/test_tx_rollup_l2.ml | 2 +- .../test/unit/test_tx_rollup_l2_apply.ml | 10 +- .../test/unit/test_zk_rollup_storage.ml | 10 +- src/proto_015_PtLimaPt/lib_tx_rollup/RPC.ml | 23 ++- src/proto_015_PtLimaPt/lib_tx_rollup/RPC.mli | 2 +- .../lib_tx_rollup/accuser.mli | 2 +- .../lib_tx_rollup/batcher.ml | 6 +- .../lib_tx_rollup/batcher.mli | 2 +- .../lib_tx_rollup/context.ml | 8 +- .../lib_tx_rollup/context.mli | 4 +- .../lib_tx_rollup/dispatcher.mli | 2 +- src/proto_015_PtLimaPt/lib_tx_rollup/dune | 1 - src/proto_015_PtLimaPt/lib_tx_rollup/error.ml | 36 ++-- .../lib_tx_rollup/error.mli | 12 +- src/proto_015_PtLimaPt/lib_tx_rollup/event.ml | 22 +- .../lib_tx_rollup/fancy_l2block.ml | 6 +- src/proto_015_PtLimaPt/lib_tx_rollup/inbox.ml | 4 +- .../lib_tx_rollup/inbox.mli | 2 +- .../lib_tx_rollup/l2_transaction.ml | 11 +- .../lib_tx_rollup/l2_transaction.mli | 2 +- .../lib_tx_rollup/l2block.ml | 19 +- .../lib_tx_rollup/l2block.mli | 8 +- .../lib_tx_rollup/node_config.ml | 14 +- .../lib_tx_rollup/node_config.mli | 2 +- src/proto_015_PtLimaPt/lib_tx_rollup/state.ml | 2 +- .../lib_tx_rollup/state.mli | 28 ++- .../lib_tx_rollup/stores.ml | 57 ++++-- .../lib_tx_rollup/stores.mli | 14 +- src/proto_alpha/lib_benchmark/dune | 1 + src/proto_alpha/lib_benchmarks_proto/dune | 1 + src/proto_alpha/lib_injector/dune | 1 + src/proto_alpha/lib_tx_rollup/dune | 1 + .../lib_client/client_proto_commands.ml | 9 +- .../lib_client/client_proto_main.ml | 12 +- .../lib_client/client_proto_main.mli | 2 +- src/proto_genesis/lib_client/proxy.ml | 2 +- 553 files changed, 5764 insertions(+), 4202 deletions(-) diff --git a/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.ml b/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.ml index 826b02e794d9..f79e82fafe07 100644 --- a/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.ml +++ b/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.ml @@ -27,7 +27,7 @@ open Protocol open Protocol_client_context let protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P" let bake cctxt ?timestamp block command sk = @@ -36,7 +36,7 @@ let bake cctxt ?timestamp block command sk = | Some t -> t | None -> Time.System.(to_protocol (Tezos_base.Time.System.now ())) in - let protocol_data = {command; signature = Signature.zero} in + let protocol_data = {command; signature = Tezos_crypto.Signature.zero} in Genesis_block_services.Helpers.Preapply.block cctxt ~block @@ -96,7 +96,7 @@ let proto_param ~name ~desc t = ~name ~desc (Tezos_clic.parameter (fun _ str -> - Lwt.return (Protocol_hash.of_b58check str))) + Lwt.return (Tezos_crypto.Protocol_hash.of_b58check str))) t let commands () = @@ -142,8 +142,8 @@ let commands () = (Activate {protocol = hash; fitness; protocol_parameters}) sk >>=? fun hash -> - cctxt#answer "Injected %a" Block_hash.pp_short hash >>= fun () -> - return_unit); + cctxt#answer "Injected %a" Tezos_crypto.Block_hash.pp_short hash + >>= fun () -> return_unit); command ~desc:"Fork a test protocol" (args2 timestamp_arg test_delay_arg) @@ -162,8 +162,8 @@ let commands () = (Activate_testchain {protocol = hash; delay}) sk >>=? fun hash -> - cctxt#answer "Injected %a" Block_hash.pp_short hash >>= fun () -> - return_unit); + cctxt#answer "Injected %a" Tezos_crypto.Block_hash.pp_short hash + >>= fun () -> return_unit); ] let () = Client_commands.register protocol @@ fun _network -> commands () diff --git a/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.mli b/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.mli index d6df9e2403a3..902704cb1064 100644 --- a/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.mli +++ b/src/proto_000_Ps9mPmXa/lib_client/client_proto_main.mli @@ -31,4 +31,4 @@ val bake : Shell_services.block -> Data.Command.t -> Client_keys.sk_uri -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t diff --git a/src/proto_001_PtCJ7pwo/lib_client/operation_result.ml b/src/proto_001_PtCJ7pwo/lib_client/operation_result.ml index c11f45dbc798..09cb02c3d4ef 100644 --- a/src/proto_001_PtCJ7pwo/lib_client/operation_result.ml +++ b/src/proto_001_PtCJ7pwo/lib_client/operation_result.ml @@ -66,7 +66,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal origination" else "Origination") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp manager Client_proto_args.tez_sym Tez.pp @@ -96,7 +96,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; if spendable then Format.fprintf ppf "@,Spendable by the manager" ; if delegatable then @@ -110,7 +110,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -130,7 +130,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -149,21 +149,21 @@ let pp_balance_updates ppf = function | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l @@ -387,9 +387,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -403,9 +403,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -416,7 +416,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -434,7 +434,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -443,22 +443,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %s@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal (match ballot with Yay -> "YAY" | Pass -> "PASS" | Nay -> "NAY") | Single_and_result diff --git a/src/proto_001_PtCJ7pwo/lib_client_commands/client_proto_programs_commands.ml b/src/proto_001_PtCJ7pwo/lib_client_commands/client_proto_programs_commands.ml index 34df3ecad0fd..542fe771f711 100644 --- a/src/proto_001_PtCJ7pwo/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_001_PtCJ7pwo/lib_client_commands/client_proto_programs_commands.ml @@ -103,7 +103,7 @@ let commands () = in let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -306,8 +306,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_002_PsYLVpVv/lib_client/client_proto_context.ml b/src/proto_002_PsYLVpVv/lib_client/client_proto_context.ml index e462089310cd..bd01313f5598 100644 --- a/src/proto_002_PsYLVpVv/lib_client/client_proto_context.ml +++ b/src/proto_002_PsYLVpVv/lib_client/client_proto_context.ml @@ -103,7 +103,7 @@ let get_operation_from_block (cctxt : #Client_context.full) ~chain predecessors | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_002_PsYLVpVv/lib_client/client_proto_context.mli b/src/proto_002_PsYLVpVv/lib_client/client_proto_context.mli index 55f2d8717085..910080f48297 100644 --- a/src/proto_002_PsYLVpVv/lib_client/client_proto_context.mli +++ b/src/proto_002_PsYLVpVv/lib_client/client_proto_context.mli @@ -74,5 +74,5 @@ val display_receipt_for_operation : #Alpha_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_002_PsYLVpVv/lib_client/operation_result.ml b/src/proto_002_PsYLVpVv/lib_client/operation_result.ml index 5fa1a6258f14..74667c650b16 100644 --- a/src/proto_002_PsYLVpVv/lib_client/operation_result.ml +++ b/src/proto_002_PsYLVpVv/lib_client/operation_result.ml @@ -66,7 +66,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal origination" else "Origination") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp manager Client_proto_args.tez_sym Tez.pp @@ -99,7 +99,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; if spendable then Format.fprintf ppf "@,Spendable by the manager" ; if delegatable then @@ -113,7 +113,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -133,7 +133,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -152,21 +152,21 @@ let pp_balance_updates ppf = function | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l @@ -391,9 +391,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -407,9 +407,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -420,7 +420,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -438,7 +438,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -447,22 +447,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %s@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal (match ballot with Yay -> "YAY" | Pass -> "PASS" | Nay -> "NAY") | Single_and_result diff --git a/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_context_commands.ml b/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_context_commands.ml index 16e8f9af5d71..8072548a515f 100644 --- a/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_context_commands.ml @@ -224,7 +224,7 @@ let commands () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) diff --git a/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_programs_commands.ml b/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_programs_commands.ml index 7955869f63e3..47a7ff377bca 100644 --- a/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_002_PsYLVpVv/lib_client_commands/client_proto_programs_commands.ml @@ -103,7 +103,7 @@ let commands () = in let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -354,8 +354,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_003_PsddFKi3/lib_client/client_proto_context.ml b/src/proto_003_PsddFKi3/lib_client/client_proto_context.ml index c6d4bb7c9087..3708813784a1 100644 --- a/src/proto_003_PsddFKi3/lib_client/client_proto_context.ml +++ b/src/proto_003_PsddFKi3/lib_client/client_proto_context.ml @@ -79,7 +79,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -149,7 +149,7 @@ let get_operation_from_block (cctxt : #Client_context.full) ~chain predecessors | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_003_PsddFKi3/lib_client/client_proto_context.mli b/src/proto_003_PsddFKi3/lib_client/client_proto_context.mli index 34d0028a4442..dbdb8260bd18 100644 --- a/src/proto_003_PsddFKi3/lib_client/client_proto_context.mli +++ b/src/proto_003_PsddFKi3/lib_client/client_proto_context.mli @@ -72,7 +72,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -104,5 +104,5 @@ val display_receipt_for_operation : #Alpha_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_003_PsddFKi3/lib_client/operation_result.ml b/src/proto_003_PsddFKi3/lib_client/operation_result.ml index 678fb986075a..a85ac41a7533 100644 --- a/src/proto_003_PsddFKi3/lib_client/operation_result.ml +++ b/src/proto_003_PsddFKi3/lib_client/operation_result.ml @@ -74,7 +74,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal origination" else "Origination") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp manager Client_proto_args.tez_sym Tez.pp @@ -107,7 +107,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; if spendable then Format.fprintf ppf "@,Spendable by the manager" ; if delegatable then @@ -121,7 +121,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -141,7 +141,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -160,21 +160,21 @@ let pp_balance_updates ppf = function | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l @@ -402,9 +402,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -418,9 +418,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -431,7 +431,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -449,7 +449,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -458,22 +458,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_003_PsddFKi3/lib_client_commands/client_proto_context_commands.ml b/src/proto_003_PsddFKi3/lib_client_commands/client_proto_context_commands.ml index 6735e252782d..29d12e45609c 100644 --- a/src/proto_003_PsddFKi3/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_003_PsddFKi3/lib_client_commands/client_proto_context_commands.ml @@ -230,7 +230,7 @@ let commands () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -291,7 +291,10 @@ let commands () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -306,10 +309,14 @@ let commands () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_003_PsddFKi3/lib_client_commands/client_proto_programs_commands.ml b/src/proto_003_PsddFKi3/lib_client_commands/client_proto_programs_commands.ml index 5092837490cc..bc5068d7be21 100644 --- a/src/proto_003_PsddFKi3/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_003_PsddFKi3/lib_client_commands/client_proto_programs_commands.ml @@ -92,7 +92,7 @@ let commands () = in let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -343,8 +343,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_004_Pt24m4xi/lib_client/client_proto_context.ml b/src/proto_004_Pt24m4xi/lib_client/client_proto_context.ml index 004daaa7bfc9..a22995c83333 100644 --- a/src/proto_004_Pt24m4xi/lib_client/client_proto_context.ml +++ b/src/proto_004_Pt24m4xi/lib_client/client_proto_context.ml @@ -80,7 +80,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -150,7 +150,7 @@ let get_operation_from_block (cctxt : #Client_context.full) ~chain predecessors | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_004_Pt24m4xi/lib_client/client_proto_context.mli b/src/proto_004_Pt24m4xi/lib_client/client_proto_context.mli index 4aee9e11a740..85d929df8040 100644 --- a/src/proto_004_Pt24m4xi/lib_client/client_proto_context.mli +++ b/src/proto_004_Pt24m4xi/lib_client/client_proto_context.mli @@ -72,7 +72,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -106,5 +106,5 @@ val display_receipt_for_operation : #Alpha_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_004_Pt24m4xi/lib_client/operation_result.ml b/src/proto_004_Pt24m4xi/lib_client/operation_result.ml index 678fb986075a..a85ac41a7533 100644 --- a/src/proto_004_Pt24m4xi/lib_client/operation_result.ml +++ b/src/proto_004_Pt24m4xi/lib_client/operation_result.ml @@ -74,7 +74,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal origination" else "Origination") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp manager Client_proto_args.tez_sym Tez.pp @@ -107,7 +107,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; if spendable then Format.fprintf ppf "@,Spendable by the manager" ; if delegatable then @@ -121,7 +121,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -141,7 +141,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -160,21 +160,21 @@ let pp_balance_updates ppf = function | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l @@ -402,9 +402,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -418,9 +418,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -431,7 +431,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -449,7 +449,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -458,22 +458,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_context_commands.ml b/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_context_commands.ml index 6735e252782d..29d12e45609c 100644 --- a/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_context_commands.ml @@ -230,7 +230,7 @@ let commands () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -291,7 +291,10 @@ let commands () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -306,10 +309,14 @@ let commands () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_programs_commands.ml b/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_programs_commands.ml index 10035131d3f5..52ad7b6e8738 100644 --- a/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_004_Pt24m4xi/lib_client_commands/client_proto_programs_commands.ml @@ -105,7 +105,7 @@ let commands () = in let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -322,7 +322,8 @@ let commands () = hash Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) - (Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string)) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string)) Hex.pp (Hex.of_bytes (Environment.Raw_hashes.sha256 bytes)) Hex.pp @@ -376,8 +377,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_005_PsBabyM1/lib_client/client_proto_context.ml b/src/proto_005_PsBabyM1/lib_client/client_proto_context.ml index 9342a578698c..1811f0814377 100644 --- a/src/proto_005_PsBabyM1/lib_client/client_proto_context.ml +++ b/src/proto_005_PsBabyM1/lib_client/client_proto_context.ml @@ -77,7 +77,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -147,7 +147,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_005_PsBabyM1/lib_client/client_proto_context.mli b/src/proto_005_PsBabyM1/lib_client/client_proto_context.mli index 0fa6d4b862bb..17878cb4e928 100644 --- a/src/proto_005_PsBabyM1/lib_client/client_proto_context.mli +++ b/src/proto_005_PsBabyM1/lib_client/client_proto_context.mli @@ -73,7 +73,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -107,5 +107,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_005_PsBabyM1/lib_client/injection.ml b/src/proto_005_PsBabyM1/lib_client/injection.ml index 6e933e99874e..53820125e3e3 100644 --- a/src/proto_005_PsBabyM1/lib_client/injection.ml +++ b/src/proto_005_PsBabyM1/lib_client/injection.ml @@ -45,12 +45,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -172,18 +175,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -206,7 +214,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -231,8 +239,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -247,7 +256,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -487,7 +496,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -648,12 +657,12 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -664,7 +673,8 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -674,9 +684,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -733,9 +743,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -743,7 +753,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ~source ~src_pk ~src_sk ?fee ?(gas_limit = Z.minus_one) ?(storage_limit = Z.of_int (-1)) ?counter ~fee_parameter (type kind) (operation : kind manager_operation) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents * kind Kind.manager contents_result) tzresult diff --git a/src/proto_005_PsBabyM1/lib_client/injection.mli b/src/proto_005_PsBabyM1/lib_client/injection.mli index 150d0c91df5b..743274890217 100644 --- a/src/proto_005_PsBabyM1/lib_client/injection.mli +++ b/src/proto_005_PsBabyM1/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list val inject_operation : #Protocol_client_context.full -> @@ -69,7 +71,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val inject_manager_operation : #Protocol_client_context.full -> @@ -79,8 +82,8 @@ val inject_manager_operation : ?confirmations:int -> ?dry_run:bool -> ?verbose_signing:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> ?fee:Tez.t -> ?gas_limit:Z.t -> diff --git a/src/proto_005_PsBabyM1/lib_client/managed_contract.ml b/src/proto_005_PsBabyM1/lib_client/managed_contract.ml index 84a5e4208667..d13d47d2fb98 100644 --- a/src/proto_005_PsBabyM1/lib_client/managed_contract.ml +++ b/src/proto_005_PsBabyM1/lib_client/managed_contract.ml @@ -38,7 +38,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, [Bytes (_, bytes); _], _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -49,7 +49,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, [String (_, value); _], _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -76,7 +78,7 @@ let parse code = let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -90,7 +92,9 @@ let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run let lambda = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; \ SET_DELEGATE ; CONS }" @@ -115,7 +119,7 @@ let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" diff --git a/src/proto_005_PsBabyM1/lib_client/operation_result.ml b/src/proto_005_PsBabyM1/lib_client/operation_result.ml index 1c6c93cfb1ad..85811df298d5 100644 --- a/src/proto_005_PsBabyM1/lib_client/operation_result.ml +++ b/src/proto_005_PsBabyM1/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -145,21 +145,21 @@ let pp_balance_updates ppf = function | Rewards (pkh, l) -> Format.asprintf "rewards(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Fees (pkh, l) -> Format.asprintf "fees(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l | Deposits (pkh, l) -> Format.asprintf "deposits(%a,%a)" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh Cycle.pp l @@ -339,7 +339,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %s@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -407,9 +407,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -423,9 +423,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -436,7 +436,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -454,7 +454,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -463,22 +463,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_005_PsBabyM1/lib_client_commands/client_proto_context_commands.ml b/src/proto_005_PsBabyM1/lib_client_commands/client_proto_context_commands.ml index d9ccc5ff1a06..023df86945cc 100644 --- a/src/proto_005_PsBabyM1/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_005_PsBabyM1/lib_client_commands/client_proto_context_commands.ml @@ -294,7 +294,7 @@ let commands () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -355,7 +355,10 @@ let commands () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -370,10 +373,14 @@ let commands () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_005_PsBabyM1/lib_client_commands/client_proto_programs_commands.ml b/src/proto_005_PsBabyM1/lib_client_commands/client_proto_programs_commands.ml index bb6121c01e1a..775aca692233 100644 --- a/src/proto_005_PsBabyM1/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_005_PsBabyM1/lib_client_commands/client_proto_programs_commands.ml @@ -128,7 +128,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -385,7 +385,8 @@ let commands () = hash Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) - (Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string)) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string)) Hex.pp (Hex.of_bytes (Environment.Raw_hashes.sha256 bytes)) Hex.pp @@ -439,8 +440,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_args.ml b/src/proto_006_PsCARTHA/lib_client/client_proto_args.ml index ece79d8ea9dd..fc492598ad75 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_args.ml +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_args.ml @@ -408,7 +408,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_args.mli b/src/proto_006_PsCARTHA/lib_client/client_proto_args.mli index 6f1173e90061..eb2dce1cd4c3 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_args.mli +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_args.mli @@ -46,7 +46,8 @@ val source_arg : (string option, full) Tezos_clic.arg val entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -90,7 +91,7 @@ val tez_param : ('a, full) Tezos_clic.params -> (Tez.t -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_context.ml b/src/proto_006_PsCARTHA/lib_client/client_proto_context.ml index e06654fca6df..fb3555dee8ba 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_context.ml +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_context.ml @@ -196,7 +196,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -260,7 +260,7 @@ let originate_contract (cctxt : #full) ~chain ~block ?confirmations ?dry_run (List.length contracts) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -271,7 +271,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -301,7 +301,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -323,12 +323,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -354,7 +356,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -369,13 +371,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -415,7 +417,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -522,7 +524,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_context.mli b/src/proto_006_PsCARTHA/lib_client/client_proto_context.mli index 22fa21272ca9..32ce52d9c698 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_context.mli +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_context.mli @@ -167,7 +167,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -203,7 +203,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -240,7 +240,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -252,7 +252,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -262,5 +262,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.ml b/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.ml index 8db84c61233d..20e130fa5779 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.ml +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.ml @@ -131,8 +131,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -469,7 +473,7 @@ let action_to_expr ~loc = function (bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding delegate)))) | Change_keys (threshold, keys) -> right @@ -486,7 +490,7 @@ let action_to_expr ~loc = function bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding k)) keys)))) @@ -550,7 +554,7 @@ let action_of_expr e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -577,14 +581,14 @@ let action_of_expr e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes >>=? fun keys -> return @@ Change_keys (threshold, keys) | _ -> fail () -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -613,7 +617,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -625,7 +630,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -646,7 +651,10 @@ let multisig_create_param ~counter ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> return @@ strip_locations @@ -666,7 +674,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -750,7 +762,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -858,7 +870,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = Data_encoding.Binary.of_bytes_exn Contract.encoding contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.mli b/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.mli index ff1ce62a7efa..ff80be2dcc7b 100644 --- a/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.mli +++ b/src/proto_006_PsCARTHA/lib_client/client_proto_multisig.mli @@ -85,7 +85,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Z.t -> @@ -109,7 +109,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Z.t -> diff --git a/src/proto_006_PsCARTHA/lib_client/injection.ml b/src/proto_006_PsCARTHA/lib_client/injection.ml index 6e933e99874e..53820125e3e3 100644 --- a/src/proto_006_PsCARTHA/lib_client/injection.ml +++ b/src/proto_006_PsCARTHA/lib_client/injection.ml @@ -45,12 +45,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -172,18 +175,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -206,7 +214,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -231,8 +239,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -247,7 +256,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -487,7 +496,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -648,12 +657,12 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -664,7 +673,8 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -674,9 +684,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -733,9 +743,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -743,7 +753,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ~source ~src_pk ~src_sk ?fee ?(gas_limit = Z.minus_one) ?(storage_limit = Z.of_int (-1)) ?counter ~fee_parameter (type kind) (operation : kind manager_operation) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents * kind Kind.manager contents_result) tzresult diff --git a/src/proto_006_PsCARTHA/lib_client/injection.mli b/src/proto_006_PsCARTHA/lib_client/injection.mli index 150d0c91df5b..743274890217 100644 --- a/src/proto_006_PsCARTHA/lib_client/injection.mli +++ b/src/proto_006_PsCARTHA/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list val inject_operation : #Protocol_client_context.full -> @@ -69,7 +71,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val inject_manager_operation : #Protocol_client_context.full -> @@ -79,8 +82,8 @@ val inject_manager_operation : ?confirmations:int -> ?dry_run:bool -> ?verbose_signing:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> ?fee:Tez.t -> ?gas_limit:Z.t -> diff --git a/src/proto_006_PsCARTHA/lib_client/managed_contract.ml b/src/proto_006_PsCARTHA/lib_client/managed_contract.ml index 73cceaf22533..98e198c78648 100644 --- a/src/proto_006_PsCARTHA/lib_client/managed_contract.ml +++ b/src/proto_006_PsCARTHA/lib_client/managed_contract.ml @@ -38,7 +38,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, [Bytes (_, bytes); _], _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -49,7 +49,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, [String (_, value); _], _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -76,7 +78,7 @@ let parse code = let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -90,7 +92,9 @@ let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run let lambda = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; \ SET_DELEGATE ; CONS }" @@ -119,7 +123,7 @@ let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -157,7 +161,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_implicit ~delegate ~amount = - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_006_PsCARTHA/lib_client/operation_result.ml b/src/proto_006_PsCARTHA/lib_client/operation_result.ml index 98f636fa9e73..ba40e717f8ce 100644 --- a/src/proto_006_PsCARTHA/lib_client/operation_result.ml +++ b/src/proto_006_PsCARTHA/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -140,9 +140,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -332,7 +335,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %s@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -400,9 +403,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -416,9 +419,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -429,7 +432,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -447,7 +450,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -456,22 +459,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_context_commands.ml b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_context_commands.ml index 484b68d28dbc..ae33de83a659 100644 --- a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_context_commands.ml @@ -89,7 +89,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -1020,7 +1020,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1051,7 +1051,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1108,7 +1108,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1150,7 +1150,7 @@ let commands network () = Constants.fixed.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1163,31 +1163,36 @@ let commands network () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal + pkh + src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1259,7 +1264,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1329,7 +1334,10 @@ let commands network () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -1344,10 +1352,14 @@ let commands network () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_multisig_commands.ml index 7f82066ba25b..b4bf5a4503d7 100644 --- a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_multisig_commands.ml @@ -97,7 +97,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -111,7 +112,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let commands () : #Protocol_client_context.full Tezos_clic.command list = @@ -383,7 +384,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate change for a multisig contract." @@ -412,7 +413,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate withdraw for a multisig contract." @@ -437,7 +438,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc: @@ -473,7 +474,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Transfer tokens using a multisig contract." diff --git a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_programs_commands.ml b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_programs_commands.ml index bb6121c01e1a..775aca692233 100644 --- a/src/proto_006_PsCARTHA/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_006_PsCARTHA/lib_client_commands/client_proto_programs_commands.ml @@ -128,7 +128,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -385,7 +385,8 @@ let commands () = hash Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) - (Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string)) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string)) Hex.pp (Hex.of_bytes (Environment.Raw_hashes.sha256 bytes)) Hex.pp @@ -439,8 +440,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_007_PsDELPH1/lib_client/client_proto_args.ml b/src/proto_007_PsDELPH1/lib_client/client_proto_args.ml index 66cf83b470fd..a2c681933d6e 100644 --- a/src/proto_007_PsDELPH1/lib_client/client_proto_args.ml +++ b/src/proto_007_PsDELPH1/lib_client/client_proto_args.ml @@ -455,7 +455,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_007_PsDELPH1/lib_client/client_proto_args.mli b/src/proto_007_PsDELPH1/lib_client/client_proto_args.mli index 59fad463c2b5..4a6b0ac4e824 100644 --- a/src/proto_007_PsDELPH1/lib_client/client_proto_args.mli +++ b/src/proto_007_PsDELPH1/lib_client/client_proto_args.mli @@ -56,7 +56,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -100,7 +101,7 @@ val tez_param : ('a, full) Tezos_clic.params -> (Tez.t -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_007_PsDELPH1/lib_client/client_proto_context.ml b/src/proto_007_PsDELPH1/lib_client/client_proto_context.ml index 20a302ed42ed..2122688a9a87 100644 --- a/src/proto_007_PsDELPH1/lib_client/client_proto_context.ml +++ b/src/proto_007_PsDELPH1/lib_client/client_proto_context.ml @@ -92,7 +92,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -162,7 +162,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_007_PsDELPH1/lib_client/client_proto_context.mli b/src/proto_007_PsDELPH1/lib_client/client_proto_context.mli index ade19b02248a..b4fb066bb904 100644 --- a/src/proto_007_PsDELPH1/lib_client/client_proto_context.mli +++ b/src/proto_007_PsDELPH1/lib_client/client_proto_context.mli @@ -75,7 +75,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -109,5 +109,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_007_PsDELPH1/lib_client/managed_contract.ml b/src/proto_007_PsDELPH1/lib_client/managed_contract.ml index 7ea042fcecdc..dcabb8ecffa7 100644 --- a/src/proto_007_PsDELPH1/lib_client/managed_contract.ml +++ b/src/proto_007_PsDELPH1/lib_client/managed_contract.ml @@ -41,7 +41,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, [Bytes (_, bytes); _], _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -52,7 +52,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, [String (_, value); _], _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error diff --git a/src/proto_007_PsDELPH1/lib_client/operation_result.ml b/src/proto_007_PsDELPH1/lib_client/operation_result.ml index c380e4968c39..38f3973b8f4c 100644 --- a/src/proto_007_PsDELPH1/lib_client/operation_result.ml +++ b/src/proto_007_PsDELPH1/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -140,9 +140,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -327,7 +330,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -396,9 +399,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -412,9 +415,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -425,7 +428,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -443,7 +446,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -452,22 +455,22 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %a@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %a@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Voting_period.pp period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_007_PsDELPH1/lib_client_commands/client_proto_context_commands.ml b/src/proto_007_PsDELPH1/lib_client_commands/client_proto_context_commands.ml index d0fe933ebe05..abe19f89fd3b 100644 --- a/src/proto_007_PsDELPH1/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_007_PsDELPH1/lib_client_commands/client_proto_context_commands.ml @@ -278,7 +278,7 @@ let commands () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -339,7 +339,10 @@ let commands () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -354,10 +357,14 @@ let commands () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_007_PsDELPH1/lib_client_commands/client_proto_programs_commands.ml b/src/proto_007_PsDELPH1/lib_client_commands/client_proto_programs_commands.ml index fc0453060e83..3cfbb87ccaaf 100644 --- a/src/proto_007_PsDELPH1/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_007_PsDELPH1/lib_client_commands/client_proto_programs_commands.ml @@ -79,7 +79,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in diff --git a/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.ml b/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.ml index 599e767f060e..b5c0b6b81850 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.ml +++ b/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.ml @@ -455,7 +455,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.mli b/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.mli index 451d3ad1e199..0710270a2851 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.mli +++ b/src/proto_008_PtEdo2Zk/lib_client/client_proto_args.mli @@ -56,7 +56,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -100,7 +101,7 @@ val tez_param : ('a, full) Tezos_clic.params -> (Tez.t -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.ml b/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.ml index dc05d83397b2..1a9f8531274b 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.ml +++ b/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.ml @@ -222,7 +222,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -309,7 +309,7 @@ let originate_contract (cctxt : #full) ~chain ~block ?confirmations ?dry_run (List.length contracts) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -320,7 +320,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -350,7 +350,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -398,12 +398,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -429,7 +431,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -444,13 +446,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -490,7 +492,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -596,7 +598,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.mli b/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.mli index 520721f2e883..ceaa531aa598 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.mli +++ b/src/proto_008_PtEdo2Zk/lib_client/client_proto_context.mli @@ -196,7 +196,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -244,7 +244,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -282,7 +282,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -294,7 +294,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -304,5 +304,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_008_PtEdo2Zk/lib_client/injection.ml b/src/proto_008_PtEdo2Zk/lib_client/injection.ml index 8e63c3396d1b..eabb0c8c9b98 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/injection.ml +++ b/src/proto_008_PtEdo2Zk/lib_client/injection.ml @@ -45,12 +45,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result type _ annotated_manager_operation = | Manager_info : { @@ -214,18 +217,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -248,7 +256,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -273,8 +281,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -289,7 +298,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -537,7 +546,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -709,12 +718,12 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -725,7 +734,8 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -735,9 +745,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -794,9 +804,9 @@ let inject_operation (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -808,7 +818,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?(gas_limit = Gas.Arith.integral Z.minus_one) ?(storage_limit = Z.of_int (-1)) ?counter ~fee_parameter (type kind) (operations : kind annotated_manager_operation_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents_list * kind Kind.manager contents_result_list) tzresult diff --git a/src/proto_008_PtEdo2Zk/lib_client/injection.mli b/src/proto_008_PtEdo2Zk/lib_client/injection.mli index accf1e89d383..a90879d8db87 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/injection.mli +++ b/src/proto_008_PtEdo2Zk/lib_client/injection.mli @@ -68,7 +68,7 @@ val manager_to_list : packed_annotated_manager_operation list type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -93,7 +93,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list val inject_operation : #Protocol_client_context.full -> @@ -110,7 +112,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : ?fee:Tez.t -> @@ -128,8 +131,8 @@ val inject_manager_operation : ?dry_run:bool -> ?verbose_signing:bool -> ?simulation:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_008_PtEdo2Zk/lib_client/managed_contract.ml b/src/proto_008_PtEdo2Zk/lib_client/managed_contract.ml index 8dc8f7f8d499..8d43b2e20867 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/managed_contract.ml +++ b/src/proto_008_PtEdo2Zk/lib_client/managed_contract.ml @@ -48,7 +48,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -59,7 +59,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -86,7 +88,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -95,7 +99,7 @@ let build_lambda_for_set_delegate ~delegate = let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -128,7 +132,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -149,7 +153,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Injection.Single_manager operation in @@ -178,7 +182,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_008_PtEdo2Zk/lib_client/operation_result.ml b/src/proto_008_PtEdo2Zk/lib_client/operation_result.ml index 501b0314df09..8c68db9d29a0 100644 --- a/src/proto_008_PtEdo2Zk/lib_client/operation_result.ml +++ b/src/proto_008_PtEdo2Zk/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -140,9 +140,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -334,7 +337,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -403,9 +406,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -419,9 +422,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -432,7 +435,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -450,7 +453,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -459,20 +462,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_context_commands.ml b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_context_commands.ml index 06aba0740fa1..88a88173999b 100644 --- a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_context_commands.ml @@ -96,7 +96,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -1275,7 +1275,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1306,7 +1306,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1363,7 +1363,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1411,7 +1411,7 @@ let commands network () = Constants.fixed.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1424,31 +1424,36 @@ let commands network () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal + pkh + src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1520,7 +1525,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1596,7 +1601,10 @@ let commands network () = let print_proposal = function | None -> assert false (* not called during proposal phase *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -1611,10 +1619,14 @@ let commands network () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_fa12_commands.ml index b79bd307e178..f0aff0b960dc 100644 --- a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_fa12_commands.ml @@ -151,7 +151,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_programs_commands.ml b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_programs_commands.ml index 7bddcd32dcb1..60fa9c450033 100644 --- a/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_008_PtEdo2Zk/lib_client_commands/client_proto_programs_commands.ml @@ -140,7 +140,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -418,7 +418,8 @@ let commands () = hash Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) - (Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string)) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string)) Hex.pp (Hex.of_bytes (Environment.Raw_hashes.sha256 bytes)) Hex.pp @@ -615,8 +616,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_008_PtEdo2Zk/lib_plugin/plugin.ml b/src/proto_008_PtEdo2Zk/lib_plugin/plugin.ml index f60ae99f51f4..0336400af17d 100644 --- a/src/proto_008_PtEdo2Zk/lib_plugin/plugin.ml +++ b/src/proto_008_PtEdo2Zk/lib_plugin/plugin.ml @@ -391,7 +391,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -404,7 +404,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" string) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -611,7 +611,9 @@ module RPC = struct f ctxt a1 >|=? function None -> raise Not_found | Some v -> v) in let originate_dummy_contract ctxt script balance = - let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in + let ctxt = + Contract.init_origination_nonce ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.originate diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_args.ml b/src/proto_009_PsFLoren/lib_client/client_proto_args.ml index 67ee4de95185..9ea0c27b9240 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_args.ml +++ b/src/proto_009_PsFLoren/lib_client/client_proto_args.ml @@ -454,7 +454,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_args.mli b/src/proto_009_PsFLoren/lib_client/client_proto_args.mli index 451d3ad1e199..0710270a2851 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_args.mli +++ b/src/proto_009_PsFLoren/lib_client/client_proto_args.mli @@ -56,7 +56,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -100,7 +101,7 @@ val tez_param : ('a, full) Tezos_clic.params -> (Tez.t -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_context.ml b/src/proto_009_PsFLoren/lib_client/client_proto_context.ml index 7a36aa64560c..d54ed0f295b8 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_context.ml +++ b/src/proto_009_PsFLoren/lib_client/client_proto_context.ml @@ -232,7 +232,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -319,7 +319,7 @@ let originate_contract (cctxt : #full) ~chain ~block ?confirmations ?dry_run (List.length contracts) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -330,7 +330,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -360,7 +360,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -408,12 +408,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -439,7 +441,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -454,13 +456,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -500,7 +502,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -606,7 +608,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_context.mli b/src/proto_009_PsFLoren/lib_client/client_proto_context.mli index e072380533e1..e9f5701d078a 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_context.mli +++ b/src/proto_009_PsFLoren/lib_client/client_proto_context.mli @@ -196,7 +196,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -244,7 +244,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -282,7 +282,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -294,7 +294,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -304,5 +304,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_utils.ml b/src/proto_009_PsFLoren/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_utils.ml +++ b/src/proto_009_PsFLoren/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_009_PsFLoren/lib_client/client_proto_utils.mli b/src/proto_009_PsFLoren/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_009_PsFLoren/lib_client/client_proto_utils.mli +++ b/src/proto_009_PsFLoren/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_009_PsFLoren/lib_client/injection.ml b/src/proto_009_PsFLoren/lib_client/injection.ml index 1888b99591f6..fef6f26ad2df 100644 --- a/src/proto_009_PsFLoren/lib_client/injection.ml +++ b/src/proto_009_PsFLoren/lib_client/injection.ml @@ -45,12 +45,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -175,18 +178,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -209,7 +217,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -234,8 +242,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -250,7 +259,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -524,7 +533,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -711,12 +720,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -727,7 +736,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -737,9 +747,9 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -796,9 +806,9 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -843,7 +853,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ?simulation ~source ~src_pk ~src_sk ~fee ~gas_limit ~storage_limit ?counter ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents_list * kind Kind.manager contents_result_list) tzresult diff --git a/src/proto_009_PsFLoren/lib_client/injection.mli b/src/proto_009_PsFLoren/lib_client/injection.mli index d8f99d620510..8ced153432db 100644 --- a/src/proto_009_PsFLoren/lib_client/injection.mli +++ b/src/proto_009_PsFLoren/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -72,7 +74,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -90,8 +93,8 @@ val inject_manager_operation : ?dry_run:bool -> ?verbose_signing:bool -> ?simulation:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> diff --git a/src/proto_009_PsFLoren/lib_client/managed_contract.ml b/src/proto_009_PsFLoren/lib_client/managed_contract.ml index ac99cad8a926..67057a96c7df 100644 --- a/src/proto_009_PsFLoren/lib_client/managed_contract.ml +++ b/src/proto_009_PsFLoren/lib_client/managed_contract.ml @@ -48,7 +48,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -59,7 +59,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -86,7 +88,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -95,7 +99,7 @@ let build_lambda_for_set_delegate ~delegate = let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -128,7 +132,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -149,7 +153,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -179,7 +183,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_009_PsFLoren/lib_client/operation_result.ml b/src/proto_009_PsFLoren/lib_client/operation_result.ml index 792bd92d5f58..44adaa93f969 100644 --- a/src/proto_009_PsFLoren/lib_client/operation_result.ml +++ b/src/proto_009_PsFLoren/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -140,9 +140,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -339,7 +342,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -408,9 +411,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -424,9 +427,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -437,7 +440,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -464,7 +467,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -473,20 +476,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_009_PsFLoren/lib_client_commands/client_proto_context_commands.ml b/src/proto_009_PsFLoren/lib_client_commands/client_proto_context_commands.ml index 92706ba3b9e2..7ce830c60224 100644 --- a/src/proto_009_PsFLoren/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_009_PsFLoren/lib_client_commands/client_proto_context_commands.ml @@ -96,7 +96,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -1268,7 +1268,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1299,7 +1299,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1356,7 +1356,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1404,7 +1404,7 @@ let commands network () = Constants.fixed.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1417,31 +1417,36 @@ let commands network () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal + pkh + src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1513,7 +1518,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1592,7 +1597,10 @@ let commands network () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -1610,11 +1618,14 @@ let commands network () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w (if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_009_PsFLoren/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_009_PsFLoren/lib_client_commands/client_proto_fa12_commands.ml index fb18d6ac8b1f..9f6f65741853 100644 --- a/src/proto_009_PsFLoren/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_009_PsFLoren/lib_client_commands/client_proto_fa12_commands.ml @@ -151,7 +151,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_009_PsFLoren/lib_client_commands/client_proto_programs_commands.ml b/src/proto_009_PsFLoren/lib_client_commands/client_proto_programs_commands.ml index 5dd31b160c7d..4d302ba4f83d 100644 --- a/src/proto_009_PsFLoren/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_009_PsFLoren/lib_client_commands/client_proto_programs_commands.ml @@ -140,7 +140,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -417,8 +417,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -633,8 +633,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_009_PsFLoren/lib_client_commands/client_proto_utils_commands.ml b/src/proto_009_PsFLoren/lib_client_commands/client_proto_utils_commands.ml index c4e936e0cd51..9cb7b75ca765 100644 --- a/src/proto_009_PsFLoren/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_009_PsFLoren/lib_client_commands/client_proto_utils_commands.ml @@ -64,8 +64,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_009_PsFLoren/lib_plugin/plugin.ml b/src/proto_009_PsFLoren/lib_plugin/plugin.ml index d90e50d5cb84..dcccb7d3022b 100644 --- a/src/proto_009_PsFLoren/lib_plugin/plugin.ml +++ b/src/proto_009_PsFLoren/lib_plugin/plugin.ml @@ -391,7 +391,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -555,7 +555,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" string) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -618,7 +618,9 @@ module RPC = struct f ctxt a1 >|=? function None -> raise Not_found | Some v -> v) in let originate_dummy_contract ctxt script balance = - let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in + let ctxt = + Contract.init_origination_nonce ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.originate diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_args.ml b/src/proto_010_PtGRANAD/lib_client/client_proto_args.ml index 2474970e4083..3f4b1b84576d 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_args.ml +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_args.ml @@ -454,7 +454,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_args.mli b/src/proto_010_PtGRANAD/lib_client/client_proto_args.mli index 451d3ad1e199..0710270a2851 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_args.mli +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_args.mli @@ -56,7 +56,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -100,7 +101,7 @@ val tez_param : ('a, full) Tezos_clic.params -> (Tez.t -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_context.ml b/src/proto_010_PtGRANAD/lib_client/client_proto_context.ml index 43ff1adacff5..b785f0923f45 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_context.ml +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_context.ml @@ -259,7 +259,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -346,7 +346,7 @@ let originate_contract (cctxt : #full) ~chain ~block ?confirmations ?dry_run (List.length contracts) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -357,7 +357,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -387,7 +387,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -435,12 +435,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -466,7 +468,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -481,13 +483,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -527,7 +529,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -633,7 +635,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_context.mli b/src/proto_010_PtGRANAD/lib_client/client_proto_context.mli index 819ffbf2b05b..86cddd6cab2c 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_context.mli +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_context.mli @@ -205,7 +205,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -253,7 +253,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -291,7 +291,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -303,7 +303,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -313,5 +313,5 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_utils.ml b/src/proto_010_PtGRANAD/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_utils.ml +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_010_PtGRANAD/lib_client/client_proto_utils.mli b/src/proto_010_PtGRANAD/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_010_PtGRANAD/lib_client/client_proto_utils.mli +++ b/src/proto_010_PtGRANAD/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_010_PtGRANAD/lib_client/injection.ml b/src/proto_010_PtGRANAD/lib_client/injection.ml index 624303e83466..40a7e67137da 100644 --- a/src/proto_010_PtGRANAD/lib_client/injection.ml +++ b/src/proto_010_PtGRANAD/lib_client/injection.ml @@ -51,12 +51,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -181,18 +184,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -215,7 +223,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -240,8 +248,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -256,7 +265,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -598,7 +607,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -800,12 +809,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -816,7 +825,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -826,10 +836,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph num_confirmation_blocks - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -886,10 +896,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph num_confirmation_blocks - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -934,7 +944,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ?simulation ~source ~src_pk ~src_sk ~fee ~gas_limit ~storage_limit ?counter ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents_list * kind Kind.manager contents_result_list) tzresult diff --git a/src/proto_010_PtGRANAD/lib_client/injection.mli b/src/proto_010_PtGRANAD/lib_client/injection.mli index d8f99d620510..8ced153432db 100644 --- a/src/proto_010_PtGRANAD/lib_client/injection.mli +++ b/src/proto_010_PtGRANAD/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -72,7 +74,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -90,8 +93,8 @@ val inject_manager_operation : ?dry_run:bool -> ?verbose_signing:bool -> ?simulation:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> diff --git a/src/proto_010_PtGRANAD/lib_client/managed_contract.ml b/src/proto_010_PtGRANAD/lib_client/managed_contract.ml index 910f27a6d9b3..ebd1099a4197 100644 --- a/src/proto_010_PtGRANAD/lib_client/managed_contract.ml +++ b/src/proto_010_PtGRANAD/lib_client/managed_contract.ml @@ -49,7 +49,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -60,7 +60,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -87,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -96,7 +100,7 @@ let build_lambda_for_set_delegate ~delegate = let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -129,7 +133,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -150,7 +154,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -180,7 +184,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_010_PtGRANAD/lib_client/operation_result.ml b/src/proto_010_PtGRANAD/lib_client/operation_result.ml index 5f8d35d8facf..0c3d78bd22f9 100644 --- a/src/proto_010_PtGRANAD/lib_client/operation_result.ml +++ b/src/proto_010_PtGRANAD/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result) ; @@ -140,9 +140,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -340,7 +343,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -409,9 +412,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -425,9 +428,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -438,7 +441,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -465,7 +468,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -474,20 +477,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_context_commands.ml b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_context_commands.ml index 8b9a105f9796..33a19d20aba4 100644 --- a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_context_commands.ml @@ -96,7 +96,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -1262,7 +1262,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1293,7 +1293,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1350,7 +1350,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1398,7 +1398,7 @@ let commands network () = Constants.fixed.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1411,31 +1411,36 @@ let commands network () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal + pkh + src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1507,7 +1512,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1586,7 +1591,10 @@ let commands network () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -1604,11 +1612,14 @@ let commands network () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w (if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_fa12_commands.ml index 5b0a22b9895c..83ba1bd3e607 100644 --- a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_fa12_commands.ml @@ -145,7 +145,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_programs_commands.ml b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_programs_commands.ml index 05303007525d..387618cbb9fa 100644 --- a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_programs_commands.ml @@ -140,7 +140,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -417,8 +417,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -633,8 +633,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_utils_commands.ml b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_utils_commands.ml index c4e936e0cd51..9cb7b75ca765 100644 --- a/src/proto_010_PtGRANAD/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_010_PtGRANAD/lib_client_commands/client_proto_utils_commands.ml @@ -64,8 +64,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_010_PtGRANAD/lib_plugin/plugin.ml b/src/proto_010_PtGRANAD/lib_plugin/plugin.ml index 832ec9154934..66e18b5dfa8e 100644 --- a/src/proto_010_PtGRANAD/lib_plugin/plugin.ml +++ b/src/proto_010_PtGRANAD/lib_plugin/plugin.ml @@ -321,7 +321,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -382,7 +382,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" string) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -520,7 +520,7 @@ module RPC = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") @@ -791,7 +791,9 @@ module RPC = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in + let ctxt = + Contract.init_origination_nonce ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.originate @@ -1149,7 +1151,7 @@ module RPC = struct let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Contract.init_origination_nonce ctxt hash in - let baker = Signature.Public_key_hash.zero in + let baker = Tezos_crypto.Signature.Public_key_hash.zero in match protocol_data.contents with | Single (Manager_operation _) as op -> partial_precheck_manager_contents_list ctxt op >>=? fun ctxt -> diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_args.ml b/src/proto_011_PtHangz2/lib_client/client_proto_args.ml index f78b813ba57f..9fac18b4bdd3 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_args.ml +++ b/src/proto_011_PtHangz2/lib_client/client_proto_args.ml @@ -484,7 +484,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_args.mli b/src/proto_011_PtHangz2/lib_client/client_proto_args.mli index f713b55045e3..a50d6d7664e7 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_args.mli +++ b/src/proto_011_PtHangz2/lib_client/client_proto_args.mli @@ -58,7 +58,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -108,7 +109,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_context.ml b/src/proto_011_PtHangz2/lib_client/client_proto_context.ml index d4bf28f70b4c..83488d49040b 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_context.ml +++ b/src/proto_011_PtHangz2/lib_client/client_proto_context.ml @@ -261,7 +261,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -390,7 +390,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -401,7 +401,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -431,7 +431,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -479,12 +479,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -510,7 +512,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -525,13 +527,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -571,7 +573,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -677,7 +679,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_context.mli b/src/proto_011_PtHangz2/lib_client/client_proto_context.mli index ba5306132ed8..1a25d50c68f1 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_context.mli +++ b/src/proto_011_PtHangz2/lib_client/client_proto_context.mli @@ -60,8 +60,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -227,7 +227,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -275,7 +275,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -313,7 +313,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -325,7 +325,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -335,7 +335,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t val cached_contracts : diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_multisig.ml b/src/proto_011_PtHangz2/lib_client/client_proto_multisig.ml index 616cc64d4d94..0c667664248a 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_multisig.ml +++ b/src/proto_011_PtHangz2/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -575,11 +579,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : string) = @@ -590,10 +595,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : string) = Data_encoding.(tup2 Contract.encoding Variable.string) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -698,7 +705,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -774,7 +781,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -801,7 +808,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -811,7 +818,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -838,7 +845,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -850,7 +858,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -871,7 +879,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc:0 ~generic action >>=? fun expr -> @@ -889,7 +900,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1036,7 +1051,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1158,7 +1173,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = Data_encoding.Binary.of_bytes_exn Contract.encoding contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_multisig.mli b/src/proto_011_PtHangz2/lib_client/client_proto_multisig.mli index ad4a6306d60c..5a9d0ca664ff 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_multisig.mli +++ b/src/proto_011_PtHangz2/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -138,7 +138,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_utils.ml b/src/proto_011_PtHangz2/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_utils.ml +++ b/src/proto_011_PtHangz2/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_011_PtHangz2/lib_client/client_proto_utils.mli b/src/proto_011_PtHangz2/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_011_PtHangz2/lib_client/client_proto_utils.mli +++ b/src/proto_011_PtHangz2/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_011_PtHangz2/lib_client/injection.ml b/src/proto_011_PtHangz2/lib_client/injection.ml index cf6875da6c07..c88ead280643 100644 --- a/src/proto_011_PtHangz2/lib_client/injection.ml +++ b/src/proto_011_PtHangz2/lib_client/injection.ml @@ -51,12 +51,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -181,18 +184,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -215,7 +223,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -240,8 +248,9 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block | Some src_sk -> let watermark = match contents with - | Single (Endorsement _) -> Signature.(Endorsement chain_id) - | _ -> Signature.Generic_operation + | Single (Endorsement _) -> + Tezos_crypto.Signature.(Endorsement chain_id) + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -256,7 +265,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -610,7 +619,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -812,12 +821,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -828,7 +837,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (match confirmations with | None -> cctxt#message @@ -838,10 +848,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph num_confirmation_blocks - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -899,10 +909,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph num_confirmation_blocks - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -947,7 +957,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ?simulation ?force ~source ~src_pk ~src_sk ~fee ~gas_limit ~storage_limit ?counter ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents_list * kind Kind.manager contents_result_list) tzresult diff --git a/src/proto_011_PtHangz2/lib_client/injection.mli b/src/proto_011_PtHangz2/lib_client/injection.mli index 50da92f06c55..9c93d9f174fa 100644 --- a/src/proto_011_PtHangz2/lib_client/injection.mli +++ b/src/proto_011_PtHangz2/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -72,7 +74,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -91,8 +94,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> diff --git a/src/proto_011_PtHangz2/lib_client/managed_contract.ml b/src/proto_011_PtHangz2/lib_client/managed_contract.ml index 7e15c7482cc6..99809742245f 100644 --- a/src/proto_011_PtHangz2/lib_client/managed_contract.ml +++ b/src/proto_011_PtHangz2/lib_client/managed_contract.ml @@ -49,7 +49,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -60,7 +60,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -87,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -96,7 +100,7 @@ let build_lambda_for_set_delegate ~delegate = let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -129,7 +133,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -150,7 +154,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -180,7 +184,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_011_PtHangz2/lib_client/mockup.ml b/src/proto_011_PtHangz2/lib_client/mockup.ml index 675651e960da..44df8927b420 100644 --- a/src/proto_011_PtHangz2/lib_client/mockup.ml +++ b/src/proto_011_PtHangz2/lib_client/mockup.ml @@ -63,7 +63,7 @@ module Protocol_constants_overrides = struct liquidity_baking_sunset_level : int32 option; liquidity_baking_escape_ema_threshold : int32 option; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; } @@ -197,7 +197,7 @@ module Protocol_constants_overrides = struct (opt "liquidity_baking_sunset_level" int32) (opt "liquidity_baking_escape_ema_threshold" int32)) (obj2 - (opt "chain_id" Chain_id.encoding) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding))))) let default_value (cctxt : Tezos_client_base.Client_context.full) : @@ -477,7 +477,12 @@ module Protocol_constants_overrides = struct override_value = o.liquidity_baking_escape_ema_threshold; pp = pp_print_int32; }; - O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; + O + { + name = "chain_id"; + override_value = o.chain_id; + pp = Tezos_crypto.Chain_id.pp; + }; O { name = "timestamp"; @@ -613,7 +618,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. {public_key_hash; public_key = Some public_key; amount = repr.amount} @@ -673,8 +678,8 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount) -> {public_key_hash; public_key; amount}) (obj3 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding)) end @@ -686,7 +691,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -747,10 +752,10 @@ let lib_parameters_json_encoding = (fun (pk, amount) -> { Parameters.public_key = Some pk; - public_key_hash = Signature.Public_key.hash pk; + public_key_hash = Tezos_crypto.Signature.Public_key.hash pk; amount; }) - (tup2 Signature.Public_key.encoding Tez.encoding) + (tup2 Tezos_crypto.Signature.Public_key.encoding Tez.encoding) in Data_encoding.( merge_objs @@ -763,7 +768,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -783,7 +788,7 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end @@ -862,7 +867,7 @@ let mem_init : Tezos_mockup_registration.Registration.mockup_context tzresult Lwt.t = fun ~cctxt ~parameters ~constants_overrides_json ~bootstrap_accounts_json -> let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in (* Need to read this Json file before since timestamp modification may be in @@ -890,7 +895,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness:(Fitness.from_int64 0L) - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in Protocol_constants_overrides.apply_overrides cctxt diff --git a/src/proto_011_PtHangz2/lib_client/operation_result.ml b/src/proto_011_PtHangz2/lib_client/operation_result.ml index a2e72c4a8de5..c741e72d07e5 100644 --- a/src/proto_011_PtHangz2/lib_client/operation_result.ml +++ b/src/proto_011_PtHangz2/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result @@ -153,9 +153,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -382,7 +385,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -451,9 +454,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -467,9 +470,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -480,7 +483,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -507,7 +510,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate (Format.pp_print_list ~pp_sep:Format.pp_print_space Format.pp_print_int) slots @@ -516,20 +519,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_011_PtHangz2/lib_client/proxy.ml b/src/proto_011_PtHangz2/lib_client/proxy.ml index 3e1068d9ae59..abd459fa2f3b 100644 --- a/src/proto_011_PtHangz2/lib_client/proxy.ml +++ b/src/proto_011_PtHangz2/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_context_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_context_commands.ml index efd6c230840d..3d54d6e767d2 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_context_commands.ml @@ -98,7 +98,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -1419,7 +1419,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1450,7 +1450,7 @@ let commands network () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ -1507,7 +1507,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1555,7 +1555,7 @@ let commands network () = Constants.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1568,31 +1568,36 @@ let commands network () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal + pkh + src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1664,7 +1669,7 @@ let commands network () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1743,7 +1748,10 @@ let commands network () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -1761,11 +1769,14 @@ let commands network () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w (if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_fa12_commands.ml index 62f5df292952..cd19030b504c 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_fa12_commands.ml @@ -119,7 +119,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_multisig_commands.ml index 36e7503de6e5..c8ac0b0e4f59 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_multisig_commands.ml @@ -123,7 +123,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -137,7 +138,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) ~destination @@ -477,7 +478,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a lambda for a generic multisig contract." @@ -507,7 +508,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate change for a multisig contract." @@ -536,7 +537,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate withdraw for a multisig contract." @@ -561,7 +562,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc: @@ -597,7 +598,7 @@ let commands () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Transfer tokens using a multisig contract." diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_programs_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_programs_commands.ml index 43b4d1b1c884..fb0ee4a5ce17 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_programs_commands.ml @@ -126,7 +126,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -439,8 +439,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -655,8 +655,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_stresstest_commands.ml index a9f97e00f7ba..b9f68a8ebc7f 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_stresstest_commands.ml @@ -63,7 +63,7 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type input_source = @@ -83,17 +83,20 @@ type transfer = { } type state = { - current_head_on_start : Block_hash.t; - counters : (Block_hash.t * Z.t) Signature.Public_key_hash.Table.t; + current_head_on_start : Tezos_crypto.Block_hash.t; + counters : + (Tezos_crypto.Block_hash.t * Z.t) + Tezos_crypto.Signature.Public_key_hash.Table.t; mutable pool : source_origin list; mutable pool_size : int; (** [Some l] if [single_op_per_pkh_per_block] is true *) mutable shuffled_pool : source list option; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } let verbose = ref false @@ -131,9 +134,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -145,7 +148,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -156,8 +159,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let parse_strategy s = match String.split ~limit:1 ':' s with @@ -196,7 +199,7 @@ let parse_strategy s = let normalize_source cctxt = let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -232,8 +235,8 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - cctxt#warning msg Signature.Public_key_hash.pp pkh >>= fun () -> - Lwt.return_none + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + >>= fun () -> Lwt.return_none in (Client_keys.get_key cctxt pkh >>= function | Error _ -> warning "Pkh \"%a\" not found in the wallet" pkh @@ -243,7 +246,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias >>= fun () -> Lwt.return_none @@ -288,13 +291,13 @@ let rec sample_source_from_pool state rng (cctxt : Protocol_client_context.full) cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) >>= fun () -> Lwt.return source | Some [] -> cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block >>= fun () -> Lwt_condition.wait state.new_block_condition >>= fun () -> @@ -305,7 +308,7 @@ let random_seed rng = let generate_fresh_source pool rng = let seed = random_seed rng in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in pool.pool <- fresh :: pool.pool ; pool.pool_size <- pool.pool_size + 1 ; @@ -314,7 +317,7 @@ let generate_fresh_source pool rng = (* [heads_iter cctxt f] calls [f head] each time there is a new head received by the streamed RPC /monitor/heads/main *) let heads_iter (cctxt : Protocol_client_context.full) - (f : Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t) : + (f : Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t) : unit tzresult Lwt.t = let open Lwt_result_syntax in Error_monad.protect @@ -331,7 +334,7 @@ let heads_iter (cctxt : Protocol_client_context.full) debug_msg (fun () -> cctxt#message "heads_iter: new block received %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp new_block_hash) in let* protocols = @@ -340,7 +343,9 @@ let heads_iter (cctxt : Protocol_client_context.full) ~block:(`Hash (new_block_hash, 0)) () in - if Protocol_hash.(protocols.current_protocol = Protocol.hash) + if + Tezos_crypto.Protocol_hash.( + protocols.current_protocol = Protocol.hash) then let*! () = f block_hash_and_header in loop () @@ -350,7 +355,7 @@ let heads_iter (cctxt : Protocol_client_context.full) cctxt#message "heads_iter: new block on protocol %a. Stopping \ iteration.@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocols.current_protocol) in return_unit) @@ -365,14 +370,14 @@ let heads_iter (cctxt : Protocol_client_context.full) debug_msg (fun () -> cctxt#message "head iteration for proto %a stopped@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash) in return_unit) ~on_error:(fun trace -> cctxt#error "An error while monitoring the new heads for proto %a occured: %a@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash Error_monad.pp_print_trace trace) @@ -391,7 +396,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block debug_msg (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) >>= fun () -> (* Sampled source has zero balance: the transfer that created that @@ -425,7 +430,11 @@ let inject_contents (cctxt : Protocol_client_context.full) chain branch sk ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -470,7 +479,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng >>=? fun pcounter -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun branch -> (* If there is a new block refresh the fresh_pool *) - if not (Block_hash.equal branch state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal branch state.last_block) then ( state.last_block <- branch ; if Option.is_some state.shuffled_pool then state.shuffled_pool <- @@ -480,14 +489,16 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng (List.map (fun src_org -> src_org.source) state.pool))) ; let freshest_counter = match - Signature.Public_key_hash.Table.find state.counters transfer.src.pkh + Tezos_crypto.Signature.Public_key_hash.Table.find + state.counters + transfer.src.pkh with | None -> (* This is the first operation we inject for this pkh: the counter given by the RPC _must_ be the freshest one. *) pcounter | Some (previous_branch, previous_counter) -> - if Block_hash.equal branch previous_branch then + if Tezos_crypto.Block_hash.equal branch previous_branch then (* We already injected an operation on top of this block: the one stored locally is the freshest one. *) previous_counter @@ -497,14 +508,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng given by the RPC. *) pcounter in - (if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + (if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; Alpha_services.Contract.manager_key cctxt (chain, block) transfer.src.pkh >>=? fun pk_opt -> return (Option.is_some pk_opt))) >>=? fun already_revealed -> @@ -528,21 +544,23 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Cons (reveal, Single manager_op) in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print reveal_counter Z.pp_print transf_counter - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.dst else Lwt.return_unit) >>= fun () -> @@ -559,19 +577,21 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Single manager_op in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print transf_counter - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.dst else Lwt.return_unit) >>= fun () -> @@ -582,15 +602,18 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng debug_msg (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) >>= fun () -> let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find state.injected_operations branch) in - Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; + Tezos_crypto.Block_hash.Table.replace + state.injected_operations + branch + (op_hash :: ops) ; return_unit | Error e -> debug_msg (fun () -> @@ -604,7 +627,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -625,10 +648,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = Shell_services.Blocks.hash cctxt () >>=? fun current_head_on_exit -> let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -656,7 +679,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -669,9 +692,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = debug_msg (fun () -> cctxt#message "injected : %a\nincluded: %a" - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) included_ops) >>= fun () -> let injected_ops_count = List.length injected_ops in @@ -756,12 +779,14 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) else Lwt_unix.sleep remaining) >>= loop in - let on_new_head : Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t = + let on_new_head : + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t = match state.shuffled_pool with (* Some _ if and only if [single_op_per_pkh_per_block] is true. *) | Some _ -> fun (new_block_hash, new_block_header) -> - if not (Block_hash.equal new_block_hash state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal new_block_hash state.last_block) + then ( state.last_block <- new_block_hash ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1066,7 +1091,9 @@ let generate_random_transactions = (if !verbose then cctxt#message "all sources have been normalized" else Lwt.return_unit) >>= fun () -> - let counters = Signature.Public_key_hash.Table.create 1023 in + let counters = + Tezos_crypto.Signature.Public_key_hash.Table.create 1023 + in let rng = Random.State.make [|parameters.seed|] in Protocol_client_context.Alpha_block_services.header cctxt () >>=? fun header_on_start -> @@ -1084,11 +1111,11 @@ let generate_random_transactions = ~rng (List.map (fun src_org -> src_org.source) sources)) else None); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.shell.level; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = diff --git a/src/proto_011_PtHangz2/lib_client_commands/client_proto_utils_commands.ml b/src/proto_011_PtHangz2/lib_client_commands/client_proto_utils_commands.ml index c4e936e0cd51..9cb7b75ca765 100644 --- a/src/proto_011_PtHangz2/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_commands/client_proto_utils_commands.ml @@ -64,8 +64,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_011_PtHangz2/lib_client_sapling/client_sapling_commands.ml b/src/proto_011_PtHangz2/lib_client_sapling/client_sapling_commands.ml index 45941a1f9bfe..176cea283c2d 100644 --- a/src/proto_011_PtHangz2/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_011_PtHangz2/lib_client_sapling/client_sapling_commands.ml @@ -52,7 +52,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -60,7 +60,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Alpha_context.Contract.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) let do_unshield cctxt contract src_name stez dst = @@ -714,7 +714,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_011_PtHangz2/lib_client_sapling/context.ml b/src/proto_011_PtHangz2/lib_client_sapling/context.ml index 07ac678504ef..56d4f76d4921 100644 --- a/src/proto_011_PtHangz2/lib_client_sapling/context.ml +++ b/src/proto_011_PtHangz2/lib_client_sapling/context.ml @@ -62,7 +62,7 @@ end = struct end module Shielded_tez_contract_input = struct - type t = UTXO.transaction * Signature.public_key_hash option + type t = UTXO.transaction * Tezos_crypto.Signature.public_key_hash option let create ?pkh tr = (tr, pkh) @@ -70,7 +70,7 @@ module Shielded_tez_contract_input = struct let open Data_encoding in obj2 (req "transaction" UTXO.transaction_encoding) - (opt "pkh" Signature.Public_key_hash.encoding) + (opt "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) let pp ppf t = let open Data_encoding in @@ -92,7 +92,7 @@ module Shielded_tez_contract_input = struct Micheline.Bytes ( 0, Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding v ) in Micheline.Prim (0, Script.D_Some, [value], []) @@ -173,7 +173,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_011_PtHangz2/lib_client_sapling/context.mli b/src/proto_011_PtHangz2/lib_client_sapling/context.mli index e9908bd0e120..1b3fd9c3e0f1 100644 --- a/src/proto_011_PtHangz2/lib_client_sapling/context.mli +++ b/src/proto_011_PtHangz2/lib_client_sapling/context.mli @@ -59,7 +59,8 @@ end module Shielded_tez_contract_input : sig type t - val create : ?pkh:Signature.Public_key_hash.t -> UTXO.transaction -> t + val create : + ?pkh:Tezos_crypto.Signature.Public_key_hash.t -> UTXO.transaction -> t val encoding : t Data_encoding.t @@ -134,7 +135,7 @@ val shield : *) val unshield : src:Spending_key.t -> - dst:Signature.public_key_hash -> + dst:Tezos_crypto.Signature.public_key_hash -> backdst:Viewing_key.address -> Shielded_tez.t -> Contract_state.t -> diff --git a/src/proto_011_PtHangz2/lib_client_sapling/wallet.ml b/src/proto_011_PtHangz2/lib_client_sapling/wallet.ml index 7e180e7679b7..00eb130e8704 100644 --- a/src/proto_011_PtHangz2/lib_client_sapling/wallet.ml +++ b/src/proto_011_PtHangz2/lib_client_sapling/wallet.ml @@ -27,7 +27,7 @@ open Client_keys open Tezos_sapling.Core.Client module Mnemonic = struct - let new_random = Bip39.of_entropy (Hacl.Rand.gen 32) + let new_random = Bip39.of_entropy (Tezos_crypto.Hacl.Rand.gen 32) let to_sapling_key mnemonic = (* Z-cash needs 32 bytes and BIP-39 gives 64 bytes of entropy. diff --git a/src/proto_011_PtHangz2/lib_parameters/default_parameters.ml b/src/proto_011_PtHangz2/lib_parameters/default_parameters.ml index cc9bc015e8da..39666be7fbeb 100644 --- a/src/proto_011_PtHangz2/lib_parameters/default_parameters.ml +++ b/src/proto_011_PtHangz2/lib_parameters/default_parameters.ml @@ -112,8 +112,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let bootstrap_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_011_PtHangz2/lib_parameters/default_parameters.mli b/src/proto_011_PtHangz2/lib_parameters/default_parameters.mli index 0a99181fe345..b4b31838cdc2 100644 --- a/src/proto_011_PtHangz2/lib_parameters/default_parameters.mli +++ b/src/proto_011_PtHangz2/lib_parameters/default_parameters.mli @@ -32,7 +32,9 @@ val constants_sandbox : Constants.parametric val constants_test : Constants.parametric val make_bootstrap_account : - Signature.public_key_hash * Signature.public_key * Tez.t -> + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tez.t -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_011_PtHangz2/lib_plugin/plugin.ml b/src/proto_011_PtHangz2/lib_plugin/plugin.ml index 2492de436fd2..62761d238360 100644 --- a/src/proto_011_PtHangz2/lib_plugin/plugin.ml +++ b/src/proto_011_PtHangz2/lib_plugin/plugin.ml @@ -335,7 +335,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -396,7 +396,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" string) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -529,7 +529,7 @@ module RPC = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") @@ -540,7 +540,7 @@ module RPC = struct ~input: (obj3 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_operation") @@ -908,7 +908,7 @@ module RPC = struct let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Contract.init_origination_nonce ctxt hash in - let baker = Signature.Public_key_hash.zero in + let baker = Tezos_crypto.Signature.Public_key_hash.zero in match protocol_data.contents with | Single (Manager_operation _) as op -> partial_precheck_manager_contents_list ctxt op >>=? fun ctxt -> @@ -950,7 +950,9 @@ module RPC = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in + let ctxt = + Contract.init_origination_nonce ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.originate @@ -1897,7 +1899,7 @@ module RPC = struct module Baking_rights = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; priority : int; timestamp : Timestamp.t option; } @@ -1911,7 +1913,7 @@ module RPC = struct {level; delegate; priority; timestamp}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "priority" uint16) (opt "estimated_time" Timestamp.encoding)) @@ -1923,7 +1925,7 @@ module RPC = struct type baking_rights_query = { levels : Raw_level.t list; cycles : Cycle.t list; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; max_priority : int option; all : bool; } @@ -1971,7 +1973,7 @@ module RPC = struct if Compare.Int.(priority > max_prio) then return (List.rev acc) else let (Misc.LCons (pk, next)) = l in - let delegate = Signature.Public_key.hash pk in + let delegate = Tezos_crypto.Signature.Public_key.hash pk in (match pred_timestamp with | None -> ok_none | Some pred_timestamp -> @@ -2001,7 +2003,8 @@ module RPC = struct next () >>=? fun l -> match List.partition - (fun (pk', _) -> Signature.Public_key.equal pk pk') + (fun (pk', _) -> + Tezos_crypto.Signature.Public_key.equal pk pk') delegates with | [], _ -> loop l acc (priority + 1) delegates @@ -2027,11 +2030,17 @@ module RPC = struct List.rev @@ fst @@ List.fold_left (fun (acc, previous) r -> - if Signature.Public_key_hash.Set.mem r.delegate previous then - (acc, previous) + if + Tezos_crypto.Signature.Public_key_hash.Set.mem + r.delegate + previous + then (acc, previous) else - (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) - ([], Signature.Public_key_hash.Set.empty) + ( r :: acc, + Tezos_crypto.Signature.Public_key_hash.Set.add + r.delegate + previous )) + ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) rights let register () = @@ -2088,7 +2097,7 @@ module RPC = struct module Endorsing_rights = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; slots : int list; estimated_time : Time.t option; } @@ -2102,7 +2111,7 @@ module RPC = struct {level; delegate; slots; estimated_time}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "slots" (list uint16)) (opt "estimated_time" Timestamp.encoding)) @@ -2114,7 +2123,7 @@ module RPC = struct type endorsing_rights_query = { levels : Raw_level.t list; cycles : Cycle.t list; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -2169,7 +2178,7 @@ module RPC = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights) diff --git a/src/proto_012_Psithaca/lib_client/client_proto_args.ml b/src/proto_012_Psithaca/lib_client/client_proto_args.ml index 8bf98a817e81..869ea564290b 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_args.ml +++ b/src/proto_012_Psithaca/lib_client/client_proto_args.ml @@ -492,7 +492,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") diff --git a/src/proto_012_Psithaca/lib_client/client_proto_args.mli b/src/proto_012_Psithaca/lib_client/client_proto_args.mli index 447c5394d716..92467e9a060f 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_args.mli +++ b/src/proto_012_Psithaca/lib_client/client_proto_args.mli @@ -58,7 +58,8 @@ val entrypoint_arg : (string option, full) Tezos_clic.arg val default_entrypoint_arg : (string option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -104,7 +105,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg diff --git a/src/proto_012_Psithaca/lib_client/client_proto_context.ml b/src/proto_012_Psithaca/lib_client/client_proto_context.ml index dad71a964233..cc1f45d72205 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_context.ml +++ b/src/proto_012_Psithaca/lib_client/client_proto_context.ml @@ -264,7 +264,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -426,7 +426,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -437,7 +437,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -467,7 +467,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -515,12 +515,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -546,7 +548,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -561,13 +563,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -607,7 +609,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -713,7 +715,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_012_Psithaca/lib_client/client_proto_context.mli b/src/proto_012_Psithaca/lib_client/client_proto_context.mli index 5cf83c93f133..74a28b56f5e5 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_context.mli +++ b/src/proto_012_Psithaca/lib_client/client_proto_context.mli @@ -60,8 +60,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -104,7 +104,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t val build_delegate_operation : @@ -250,7 +250,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -298,7 +298,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -336,7 +336,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -348,7 +348,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -358,7 +358,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t val cached_contracts : diff --git a/src/proto_012_Psithaca/lib_client/client_proto_multisig.ml b/src/proto_012_Psithaca/lib_client/client_proto_multisig.ml index 09f1bbb5a15f..b5ffcea2b111 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_multisig.ml +++ b/src/proto_012_Psithaca/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -575,11 +579,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : string) = @@ -590,10 +595,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : string) = Data_encoding.(tup2 Contract.encoding Variable.string) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -698,7 +705,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -774,7 +781,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -801,7 +808,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -811,7 +818,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -838,7 +845,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -850,7 +858,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -871,7 +879,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -889,7 +900,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1036,7 +1051,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1158,7 +1173,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = Data_encoding.Binary.of_bytes_exn Contract.encoding contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_012_Psithaca/lib_client/client_proto_multisig.mli b/src/proto_012_Psithaca/lib_client/client_proto_multisig.mli index ad4a6306d60c..5a9d0ca664ff 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_multisig.mli +++ b/src/proto_012_Psithaca/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -138,7 +138,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_012_Psithaca/lib_client/client_proto_utils.ml b/src/proto_012_Psithaca/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_utils.ml +++ b/src/proto_012_Psithaca/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_012_Psithaca/lib_client/client_proto_utils.mli b/src/proto_012_Psithaca/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_012_Psithaca/lib_client/client_proto_utils.mli +++ b/src/proto_012_Psithaca/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_012_Psithaca/lib_client/injection.ml b/src/proto_012_Psithaca/lib_client/injection.ml index cb918fe1112c..6dd4ac16ee21 100644 --- a/src/proto_012_Psithaca/lib_client/injection.ml +++ b/src/proto_012_Psithaca/lib_client/injection.ml @@ -55,12 +55,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee contents = let open Operation in @@ -185,18 +188,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -219,7 +227,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -245,7 +253,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let watermark = match contents with (* TODO-TB sign endosrement? *) - | _ -> Signature.Generic_operation + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -260,7 +268,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -617,7 +625,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -850,12 +858,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -866,7 +874,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (* Adjust user-provided confirmations with respect to Alpha protocol finality properties *) tenderbake_adjust_confirmations cctxt confirmations >>= fun confirmations -> (match confirmations with @@ -878,10 +887,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -939,10 +948,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op.protocol_data.contents, result.contents) @@ -987,7 +996,7 @@ let inject_manager_operation cctxt ~chain ~block ?branch ?confirmations ?dry_run ?verbose_signing ?simulation ?force ~source ~src_pk ~src_sk ~fee ~gas_limit ~storage_limit ?counter ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * kind Kind.manager contents_list * kind Kind.manager contents_result_list) tzresult diff --git a/src/proto_012_Psithaca/lib_client/injection.mli b/src/proto_012_Psithaca/lib_client/injection.mli index 50da92f06c55..9c93d9f174fa 100644 --- a/src/proto_012_Psithaca/lib_client/injection.mli +++ b/src/proto_012_Psithaca/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -53,7 +53,9 @@ val preapply : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -72,7 +74,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -91,8 +94,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> diff --git a/src/proto_012_Psithaca/lib_client/managed_contract.ml b/src/proto_012_Psithaca/lib_client/managed_contract.ml index 7e15c7482cc6..99809742245f 100644 --- a/src/proto_012_Psithaca/lib_client/managed_contract.ml +++ b/src/proto_012_Psithaca/lib_client/managed_contract.ml @@ -49,7 +49,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -60,7 +60,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -87,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -96,7 +100,7 @@ let build_lambda_for_set_delegate ~delegate = let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = "do" in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -129,7 +133,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -150,7 +154,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -180,7 +184,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_012_Psithaca/lib_client/mockup.ml b/src/proto_012_Psithaca/lib_client/mockup.ml index 9355426d3cee..b47dd3ded317 100644 --- a/src/proto_012_Psithaca/lib_client/mockup.ml +++ b/src/proto_012_Psithaca/lib_client/mockup.ml @@ -69,7 +69,7 @@ module Protocol_constants_overrides = struct ratio_of_frozen_deposits_slashed_per_double_endorsement : Constants.ratio option; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; } @@ -229,7 +229,7 @@ module Protocol_constants_overrides = struct (opt "ratio_of_frozen_deposits_slashed_per_double_endorsement" Constants.ratio_encoding) - (opt "chain_id" Chain_id.encoding) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding))))) let default_value (cctxt : Tezos_client_base.Client_context.full) : @@ -544,7 +544,12 @@ module Protocol_constants_overrides = struct o.ratio_of_frozen_deposits_slashed_per_double_endorsement; pp = Constants.pp_ratio; }; - O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; + O + { + name = "chain_id"; + override_value = o.chain_id; + pp = Tezos_crypto.Chain_id.pp; + }; O { name = "timestamp"; @@ -703,7 +708,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. {public_key_hash; public_key = Some public_key; amount = repr.amount} @@ -763,8 +768,8 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount) -> {public_key_hash; public_key; amount}) (obj3 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding)) end @@ -776,7 +781,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -837,10 +842,10 @@ let lib_parameters_json_encoding = (fun (pk, amount) -> { Parameters.public_key = Some pk; - public_key_hash = Signature.Public_key.hash pk; + public_key_hash = Tezos_crypto.Signature.Public_key.hash pk; amount; }) - (tup2 Signature.Public_key.encoding Tez.encoding) + (tup2 Tezos_crypto.Signature.Public_key.encoding Tez.encoding) in Data_encoding.( merge_objs @@ -853,7 +858,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -873,14 +878,14 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end (* ------------------------------------------------------------------------- *) (* RPC context *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" let endorsement_branch_data_encoding = @@ -889,7 +894,7 @@ let endorsement_branch_data_encoding = (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (obj2 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "block_payload_hash" Protocol.Block_payload_hash.encoding)) let initial_context chain_id (header : Block_header.shell_header) @@ -998,7 +1003,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in Protocol_constants_overrides.apply_overrides (cctxt :> Tezos_client_base.Client_context.printer) @@ -1055,10 +1060,13 @@ let mem_init : let protocol_data = let payload_hash = Protocol.Block_payload_hash.hash_bytes - [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] + [ + Tezos_crypto.Block_hash.to_bytes hash; + Tezos_crypto.Operation_list_hash.(to_bytes @@ compute []); + ] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Signature.generate_key () in + let _, _, sk = Tezos_crypto.Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -1078,7 +1086,7 @@ let mem_init : (shell_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_012_Psithaca/lib_client/operation_result.ml b/src/proto_012_Psithaca/lib_client/operation_result.ml index bce11c8a78b3..ce6a9664edba 100644 --- a/src/proto_012_Psithaca/lib_client/operation_result.ml +++ b/src/proto_012_Psithaca/lib_client/operation_result.ml @@ -95,7 +95,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -106,7 +106,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -126,7 +126,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result @@ -175,9 +175,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -457,7 +460,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -526,9 +529,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -547,7 +550,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate preendorsement_power | Single_and_result @@ -564,7 +567,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate endorsement_power | Single_and_result @@ -577,9 +580,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -593,9 +596,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -606,7 +609,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -615,20 +618,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_012_Psithaca/lib_client/proxy.ml b/src/proto_012_Psithaca/lib_client/proxy.ml index db20cd916ebf..18efe19fa6bf 100644 --- a/src/proto_012_Psithaca/lib_client/proxy.ml +++ b/src/proto_012_Psithaca/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_context_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_context_commands.ml index 2b4c6bbdf86b..055f9ec80035 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_context_commands.ml @@ -75,7 +75,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -397,7 +397,7 @@ let commands_ro () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -438,7 +438,10 @@ let commands_ro () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -456,10 +459,14 @@ let commands_ro () = fprintf ppf "* %a %ld (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p w - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; @@ -1615,7 +1622,7 @@ let commands_rw () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ prefixes ["to"; "be"; "included"] @@ -1652,7 +1659,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1704,7 +1711,7 @@ let commands_rw () = Constants.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1717,31 +1724,34 @@ let commands_rw () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal pkh src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1818,7 +1828,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1858,12 +1868,12 @@ let commands_rw () = >>=? fun current_proposal -> (match (info.current_period_kind, current_proposal) with | (Exploration | Promotion), Some current_proposal -> - if Protocol_hash.equal proposal current_proposal then - return_unit + if Tezos_crypto.Protocol_hash.equal proposal current_proposal + then return_unit else (if force then cctxt#warning else cctxt#error) "Unexpected proposal, expected: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp current_proposal >>= fun () -> return_unit | _ -> diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_fa12_commands.ml index 439d0c2a06e4..b49050a23b18 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_fa12_commands.ml @@ -119,7 +119,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_multisig_commands.ml index f5d079a40836..a607ab4401bd 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_multisig_commands.ml @@ -123,7 +123,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -137,7 +138,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) ~destination @@ -350,7 +351,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a lambda for a generic multisig contract." @@ -380,7 +381,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate change for a multisig contract." @@ -409,7 +410,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate withdraw for a multisig contract." @@ -434,7 +435,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc: @@ -470,7 +471,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Transfer tokens using a multisig contract." diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_programs_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_programs_commands.ml index dff3d61022ae..320a467c8bfc 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_programs_commands.ml @@ -128,7 +128,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -442,8 +442,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -658,8 +658,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_stresstest_commands.ml index 1d6b82118980..0594d75d0e4b 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_stresstest_commands.ml @@ -63,7 +63,7 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type input_source = @@ -83,17 +83,20 @@ type transfer = { } type state = { - current_head_on_start : Block_hash.t; - counters : (Block_hash.t * Z.t) Signature.Public_key_hash.Table.t; + current_head_on_start : Tezos_crypto.Block_hash.t; + counters : + (Tezos_crypto.Block_hash.t * Z.t) + Tezos_crypto.Signature.Public_key_hash.Table.t; mutable pool : source_origin list; mutable pool_size : int; (** [Some l] if [single_op_per_pkh_per_block] is true *) mutable shuffled_pool : source list option; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } let verbose = ref false @@ -131,9 +134,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -145,7 +148,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -156,8 +159,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let parse_strategy s = match String.split ~limit:1 ':' s with @@ -196,7 +199,7 @@ let parse_strategy s = let normalize_source cctxt = let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -232,8 +235,8 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - cctxt#warning msg Signature.Public_key_hash.pp pkh >>= fun () -> - Lwt.return_none + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + >>= fun () -> Lwt.return_none in (Client_keys.get_key cctxt pkh >>= function | Error _ -> warning "Pkh \"%a\" not found in the wallet" pkh @@ -243,7 +246,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias >>= fun () -> Lwt.return_none @@ -288,13 +291,13 @@ let rec sample_source_from_pool state rng (cctxt : Protocol_client_context.full) cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) >>= fun () -> Lwt.return source | Some [] -> cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block >>= fun () -> Lwt_condition.wait state.new_block_condition >>= fun () -> @@ -305,7 +308,7 @@ let random_seed rng = let generate_fresh_source pool rng = let seed = random_seed rng in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in pool.pool <- fresh :: pool.pool ; pool.pool_size <- pool.pool_size + 1 ; @@ -314,7 +317,7 @@ let generate_fresh_source pool rng = (* [heads_iter cctxt f] calls [f head] each time there is a new head received by the streamed RPC /monitor/heads/main *) let heads_iter (cctxt : Protocol_client_context.full) - (f : Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t) : + (f : Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t) : unit tzresult Lwt.t = let open Lwt_result_syntax in Error_monad.protect @@ -331,7 +334,7 @@ let heads_iter (cctxt : Protocol_client_context.full) debug_msg (fun () -> cctxt#message "heads_iter: new block received %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp new_block_hash) in let* protocols = @@ -340,7 +343,9 @@ let heads_iter (cctxt : Protocol_client_context.full) ~block:(`Hash (new_block_hash, 0)) () in - if Protocol_hash.(protocols.current_protocol = Protocol.hash) + if + Tezos_crypto.Protocol_hash.( + protocols.current_protocol = Protocol.hash) then let*! () = f block_hash_and_header in loop () @@ -350,7 +355,7 @@ let heads_iter (cctxt : Protocol_client_context.full) cctxt#message "heads_iter: new block on protocol %a. Stopping \ iteration.@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocols.current_protocol) in return_unit) @@ -365,14 +370,14 @@ let heads_iter (cctxt : Protocol_client_context.full) debug_msg (fun () -> cctxt#message "head iteration for proto %a stopped@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash) in return_unit) ~on_error:(fun trace -> cctxt#error "An error while monitoring the new heads for proto %a occured: %a@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash Error_monad.pp_print_trace trace) @@ -391,7 +396,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block debug_msg (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) >>= fun () -> (* Sampled source has zero balance: the transfer that created that @@ -425,7 +430,11 @@ let inject_contents (cctxt : Protocol_client_context.full) chain branch sk ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -470,7 +479,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng >>=? fun pcounter -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun branch -> (* If there is a new block refresh the fresh_pool *) - if not (Block_hash.equal branch state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal branch state.last_block) then ( state.last_block <- branch ; if Option.is_some state.shuffled_pool then state.shuffled_pool <- @@ -480,14 +489,16 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng (List.map (fun src_org -> src_org.source) state.pool))) ; let freshest_counter = match - Signature.Public_key_hash.Table.find state.counters transfer.src.pkh + Tezos_crypto.Signature.Public_key_hash.Table.find + state.counters + transfer.src.pkh with | None -> (* This is the first operation we inject for this pkh: the counter given by the RPC _must_ be the freshest one. *) pcounter | Some (previous_branch, previous_counter) -> - if Block_hash.equal branch previous_branch then + if Tezos_crypto.Block_hash.equal branch previous_branch then (* We already injected an operation on top of this block: the one stored locally is the freshest one. *) previous_counter @@ -497,14 +508,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng given by the RPC. *) pcounter in - (if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + (if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; Alpha_services.Contract.manager_key cctxt (chain, block) transfer.src.pkh >>=? fun pk_opt -> return (Option.is_some pk_opt))) >>=? fun already_revealed -> @@ -528,21 +544,23 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Cons (reveal, Single manager_op) in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print reveal_counter Z.pp_print transf_counter - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.dst else Lwt.return_unit) >>= fun () -> @@ -559,19 +577,21 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Single manager_op in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print transf_counter - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.dst else Lwt.return_unit) >>= fun () -> @@ -582,15 +602,18 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng debug_msg (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) >>= fun () -> let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find state.injected_operations branch) in - Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; + Tezos_crypto.Block_hash.Table.replace + state.injected_operations + branch + (op_hash :: ops) ; return_unit | Error e -> debug_msg (fun () -> @@ -604,7 +627,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -625,10 +648,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = Shell_services.Blocks.hash cctxt () >>=? fun current_head_on_exit -> let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -656,7 +679,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -669,9 +692,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = debug_msg (fun () -> cctxt#message "injected : %a\nincluded: %a" - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) included_ops) >>= fun () -> let injected_ops_count = List.length injected_ops in @@ -756,12 +779,14 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) else Lwt_unix.sleep remaining) >>= loop in - let on_new_head : Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t = + let on_new_head : + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> unit Lwt.t = match state.shuffled_pool with (* Some _ if and only if [single_op_per_pkh_per_block] is true. *) | Some _ -> fun (new_block_hash, new_block_header) -> - if not (Block_hash.equal new_block_hash state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal new_block_hash state.last_block) + then ( state.last_block <- new_block_hash ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1060,7 +1085,9 @@ let generate_random_transactions = | [] -> cctxt#error "It is required to provide sources" | sources -> List.filter_map_p (normalize_source cctxt) sources >>= fun sources -> - let counters = Signature.Public_key_hash.Table.create 1023 in + let counters = + Tezos_crypto.Signature.Public_key_hash.Table.create 1023 + in let rng = Random.State.make [|parameters.seed|] in Protocol_client_context.Alpha_block_services.header cctxt () >>=? fun header_on_start -> @@ -1078,11 +1105,11 @@ let generate_random_transactions = ~rng (List.map (fun src_org -> src_org.source) sources)) else None); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.shell.level; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = diff --git a/src/proto_012_Psithaca/lib_client_commands/client_proto_utils_commands.ml b/src/proto_012_Psithaca/lib_client_commands/client_proto_utils_commands.ml index 9ff9765920ad..cd8c924cfff6 100644 --- a/src/proto_012_Psithaca/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_012_Psithaca/lib_client_commands/client_proto_utils_commands.ml @@ -88,8 +88,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: @@ -157,5 +157,6 @@ let commands () = (Block_header chain_id)) sk unsigned_header - >>=? fun s -> cctxt#message "%a" Hex.pp (Signature.to_hex s) >>= return); + >>=? fun s -> + cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) >>= return); ] diff --git a/src/proto_012_Psithaca/lib_client_sapling/client_sapling_commands.ml b/src/proto_012_Psithaca/lib_client_sapling/client_sapling_commands.ml index 45941a1f9bfe..176cea283c2d 100644 --- a/src/proto_012_Psithaca/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_012_Psithaca/lib_client_sapling/client_sapling_commands.ml @@ -52,7 +52,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -60,7 +60,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Alpha_context.Contract.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) let do_unshield cctxt contract src_name stez dst = @@ -714,7 +714,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_012_Psithaca/lib_client_sapling/context.ml b/src/proto_012_Psithaca/lib_client_sapling/context.ml index 07ac678504ef..56d4f76d4921 100644 --- a/src/proto_012_Psithaca/lib_client_sapling/context.ml +++ b/src/proto_012_Psithaca/lib_client_sapling/context.ml @@ -62,7 +62,7 @@ end = struct end module Shielded_tez_contract_input = struct - type t = UTXO.transaction * Signature.public_key_hash option + type t = UTXO.transaction * Tezos_crypto.Signature.public_key_hash option let create ?pkh tr = (tr, pkh) @@ -70,7 +70,7 @@ module Shielded_tez_contract_input = struct let open Data_encoding in obj2 (req "transaction" UTXO.transaction_encoding) - (opt "pkh" Signature.Public_key_hash.encoding) + (opt "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) let pp ppf t = let open Data_encoding in @@ -92,7 +92,7 @@ module Shielded_tez_contract_input = struct Micheline.Bytes ( 0, Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding v ) in Micheline.Prim (0, Script.D_Some, [value], []) @@ -173,7 +173,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_012_Psithaca/lib_client_sapling/context.mli b/src/proto_012_Psithaca/lib_client_sapling/context.mli index e9908bd0e120..1b3fd9c3e0f1 100644 --- a/src/proto_012_Psithaca/lib_client_sapling/context.mli +++ b/src/proto_012_Psithaca/lib_client_sapling/context.mli @@ -59,7 +59,8 @@ end module Shielded_tez_contract_input : sig type t - val create : ?pkh:Signature.Public_key_hash.t -> UTXO.transaction -> t + val create : + ?pkh:Tezos_crypto.Signature.Public_key_hash.t -> UTXO.transaction -> t val encoding : t Data_encoding.t @@ -134,7 +135,7 @@ val shield : *) val unshield : src:Spending_key.t -> - dst:Signature.public_key_hash -> + dst:Tezos_crypto.Signature.public_key_hash -> backdst:Viewing_key.address -> Shielded_tez.t -> Contract_state.t -> diff --git a/src/proto_012_Psithaca/lib_client_sapling/wallet.ml b/src/proto_012_Psithaca/lib_client_sapling/wallet.ml index c5df62f580c8..412619eec4b8 100644 --- a/src/proto_012_Psithaca/lib_client_sapling/wallet.ml +++ b/src/proto_012_Psithaca/lib_client_sapling/wallet.ml @@ -27,7 +27,7 @@ open Client_keys open Tezos_sapling.Core.Client module Mnemonic = struct - let new_random = Bip39.of_entropy (Hacl.Rand.gen 32) + let new_random = Bip39.of_entropy (Tezos_crypto.Hacl.Rand.gen 32) let to_sapling_key mnemonic = (* Z-cash needs 32 bytes and BIP-39 gives 64 bytes of entropy. diff --git a/src/proto_012_Psithaca/lib_delegate/baking_events.ml b/src/proto_012_Psithaca/lib_delegate/baking_events.ml index 8ed73cd0eb3b..bba61a50f803 100644 --- a/src/proto_012_Psithaca/lib_delegate/baking_events.ml +++ b/src/proto_012_Psithaca/lib_delegate/baking_events.ml @@ -43,8 +43,8 @@ module State_transitions = struct ~name:"new_head" ~level:Notice ~msg:"received new head {block} at level {level}, round {round}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) ~pp3:Round.pp @@ -119,12 +119,12 @@ module State_transitions = struct ~msg: "proposal {new_proposal} for current round ({current_round}) has \ already been seen {previous_proposal}" - ~pp1:Block_hash.pp - ("new_proposal", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("new_proposal", Tezos_crypto.Block_hash.encoding) ~pp2:Round.pp ("current_round", Round.encoding) - ~pp3:Block_hash.pp - ("previous_proposal", Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("previous_proposal", Tezos_crypto.Block_hash.encoding) let updating_latest_proposal = declare_1 @@ -132,8 +132,8 @@ module State_transitions = struct ~name:"updating_latest_proposal" ~msg:"updating latest proposal to {block_hash}" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let baker_is_ahead_of_node = declare_2 @@ -156,10 +156,10 @@ module State_transitions = struct ~msg: "received a proposal on another branch - current: current \ pred{current_branch}, new pred {new_branch}" - ~pp1:Block_hash.pp - ("current_branch", Block_hash.encoding) - ~pp2:Block_hash.pp - ("new_branch", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("current_branch", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("new_branch", Tezos_crypto.Block_hash.encoding) let switching_branch = declare_0 @@ -215,8 +215,8 @@ module State_transitions = struct ~name:"preendorsing_proposal" ~level:Info ~msg:"preendorsing proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let skipping_invalid_proposal = declare_0 @@ -232,8 +232,8 @@ module State_transitions = struct ~name:"outdated_proposal" ~level:Debug ~msg:"outdated proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let proposing_fresh_block = declare_2 @@ -271,10 +271,10 @@ module State_transitions = struct ~msg: "unexpected prequorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let unexpected_quorum_received = declare_2 @@ -284,10 +284,10 @@ module State_transitions = struct ~msg: "unexpected quorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let step_current_phase = declare_2 @@ -321,8 +321,8 @@ module Node_rpc = struct ~name:"raw_info" ~level:Debug ~msg:"raw info for {block_hash} at level {level}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) end @@ -451,8 +451,8 @@ module Scheduling = struct ~name:"proposal_in_the_future" ~level:Debug ~msg:"received proposal in the future {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let process_proposal_in_the_future = declare_1 @@ -460,8 +460,8 @@ module Scheduling = struct ~name:"process_proposal_in_the_future" ~level:Debug ~msg:"process proposal received in the future with hash {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) end module Lib = struct @@ -543,8 +543,8 @@ module Actions = struct ~name:"preendorsement_injected" ~level:Notice ~msg:"injected preendorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -554,8 +554,8 @@ module Actions = struct ~name:"endorsement_injected" ~level:Notice ~msg:"injected endorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -565,8 +565,8 @@ module Actions = struct ~name:"synchronizing_round" ~level:Info ~msg:"synchronizing round after block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let forging_block = declare_3 @@ -605,11 +605,11 @@ module Actions = struct ~msg: "block {block} at level {level}, round {round} injected for delegate \ {delegate}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:pp_int32 ~pp3:Round.pp ~pp4:Baking_state.pp_delegate - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("round", Round.encoding) ("delegate", Baking_state.delegate_encoding) @@ -668,8 +668,8 @@ module Nonces = struct ~name:"found_nonce_to_reveal" ~level:Notice ~msg:"found nonce to reveal for block {block}, level {level}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) @@ -685,8 +685,8 @@ module Nonces = struct ("level", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let cannot_fetch_chain_head_level = declare_0 @@ -761,8 +761,8 @@ module Nonces = struct ~name:"registering_nonce" ~level:Info ~msg:"registering nonce for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let nothing_to_reveal = declare_1 @@ -770,8 +770,8 @@ module Nonces = struct ~name:"nothing_to_reveal" ~level:Info ~msg:"nothing to reveal for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let revelation_worker_started = declare_0 @@ -852,8 +852,8 @@ module Selection = struct ~name:"invalid_operation_filtered" ~level:Warning ~msg:"filtered invalid operation {op}: {errors}" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) @@ -863,6 +863,6 @@ module Selection = struct ~name:"cannot_serialize_operation_metadata" ~level:Warning ~msg:"cannot serialize operation {op} metadata" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) end diff --git a/src/proto_012_Psithaca/lib_delegate/delegate_events.ml b/src/proto_012_Psithaca/lib_delegate/delegate_events.ml index 022682623325..80aaebac4174 100644 --- a/src/proto_012_Psithaca/lib_delegate/delegate_events.ml +++ b/src/proto_012_Psithaca/lib_delegate/delegate_events.ml @@ -41,7 +41,7 @@ module Revelation = struct ~level ~name:"no_nonce_reveal" ~msg:"nothing to reveal for block {block}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let reveal_nonce = declare_5 @@ -55,7 +55,7 @@ module Revelation = struct ("level", Alpha_context.Raw_level.encoding) ("chain", Data_encoding.string) ("block", Data_encoding.string) - ("operation", Operation_hash.encoding) + ("operation", Tezos_crypto.Operation_hash.encoding) end module Nonces = struct @@ -99,7 +99,7 @@ module Nonces = struct ~level ~name:"found_nonce" ~msg:"found nonce to reveal for {hash} (level: {level})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) let bad_nonce = @@ -131,8 +131,8 @@ module Denunciator = struct ~level ~name:"double_endorsement_detected" ~msg:"double endorsement detected" - ("existing_endorsement", Operation_hash.encoding) - ("new_endorsement", Operation_hash.encoding) + ("existing_endorsement", Tezos_crypto.Operation_hash.encoding) + ("new_endorsement", Tezos_crypto.Operation_hash.encoding) let double_endorsement_denounced = declare_2 @@ -140,7 +140,7 @@ module Denunciator = struct ~level ~name:"double_endorsement_denounced" ~msg:"double endorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -150,8 +150,8 @@ module Denunciator = struct ~level ~name:"double_preendorsement_detected" ~msg:"double preendorsement detected" - ("existing_preendorsement", Operation_hash.encoding) - ("new_preendorsement", Operation_hash.encoding) + ("existing_preendorsement", Tezos_crypto.Operation_hash.encoding) + ("new_preendorsement", Tezos_crypto.Operation_hash.encoding) let double_preendorsement_denounced = declare_2 @@ -159,7 +159,7 @@ module Denunciator = struct ~level ~name:"double_preendorsement_denounced" ~msg:"double preendorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -169,7 +169,7 @@ module Denunciator = struct ~level:Error ~name:"inconsistent_endorsement" ~msg:"inconsistent endorsement found {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) let unexpected_pruned_block = declare_1 @@ -177,7 +177,7 @@ module Denunciator = struct ~level:Error ~name:"unexpected_pruned_block" ~msg:"unexpected pruned block: {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let double_baking_but_not = declare_0 @@ -201,7 +201,7 @@ module Denunciator = struct ~level ~name:"double_baking_denounced" ~msg:"double baking evidence injected {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -220,7 +220,7 @@ module Denunciator = struct ~name:"accuser_saw_block" ~msg:"block level: {level}" ("level", Alpha_context.Raw_level.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetch_operations_error = declare_1 @@ -228,8 +228,8 @@ module Denunciator = struct ~level:Error ~name:"fetch_operations_error" ~msg:"error while fetching operations of block {hash}" - ("hash", Block_hash.encoding) - ~pp1:Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp let accuser_processed_block = declare_1 @@ -237,7 +237,7 @@ module Denunciator = struct ~level ~name:"accuser_processed_block" ~msg:"block {hash} registered" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let accuser_block_error = declare_2 @@ -246,7 +246,7 @@ module Denunciator = struct ~name:"accuser_block_error" ~msg:"error while processing block {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) end @@ -325,7 +325,7 @@ module Baking_forge = struct ~level:Info ~name:"inject_baked_block" ~msg:"Client_baking_forge.inject_block: inject {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_ignore ("header", Data_encoding.bytes) ~pp3:Format.(pp_print_list @@ pp_print_list @@ Operation.pp) @@ -338,7 +338,7 @@ module Baking_forge = struct ~level:Debug ~name:"baking_local_validation_start" ~msg:"starting client-side validation after {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let context_fetch_error = declare_1 @@ -364,7 +364,7 @@ module Baking_forge = struct ~name:"baking_rejected_invalid_operation" ~msg:"client-side validation: filtered invalid operation {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) let shell_prevalidation_notice = @@ -436,7 +436,7 @@ module Baking_forge = struct ~name:"try_baking" ~msg: "try baking after {hash} (slot {priority}) for {client} ({timestamp})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("priority", Data_encoding.int31) ("client", Data_encoding.string) ("timestamp", Time.System.encoding) @@ -480,7 +480,7 @@ module Baking_forge = struct ~msg: "try forging locally the block header for {hash} (slot {priority}) for \ {client} ({timestamp})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("priority", Data_encoding.int31) ("client", Data_encoding.string) ("timestamp", Time.System.encoding) @@ -497,7 +497,7 @@ module Baking_forge = struct ("priority", Data_encoding.int31) ("fitness", Fitness.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let injected_block = @@ -511,9 +511,9 @@ module Baking_forge = struct {operations})" ~pp6:Fitness.pp ~pp7:Format.(pp_print_list Operation.pp) - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) ("priority", Data_encoding.int31) ("fitness", Fitness.encoding) @@ -549,7 +549,7 @@ module Baking_forge = struct ("priority", Data_encoding.int31) ("timestamp", Time.System.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let read_nonce_fail = @@ -689,10 +689,10 @@ module Endorsement = struct ~msg: "injected endorsement for block '{block_hash}' (level {level}, \ contract {client}) '{op_hash}'" - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) ("client", Data_encoding.string) - ("op_hash", Operation_hash.encoding) + ("op_hash", Tezos_crypto.Operation_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let endorsing = @@ -701,7 +701,7 @@ module Endorsement = struct ~level:Debug ~name:"endorsing" ~msg:"endorsing {block} for {client} (level {level})!" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) ("level", Alpha_context.Raw_level.encoding) @@ -711,7 +711,7 @@ module Endorsement = struct ~level:Debug ~name:"check_endorsement_ok" ~msg:"checking if allowed to endorse block {block} for {client}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) let endorsement_no_slots_found = @@ -720,7 +720,7 @@ module Endorsement = struct ~level:Debug ~name:"endorsement_no_slots_found" ~msg:"no slot found for {block}/{client}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) let endorsement_slots_found = @@ -738,7 +738,7 @@ module Endorsement = struct (pp_print_list ~pp_sep:(fun f () -> pp_print_string f "; ") Format.pp_print_int)) - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) ("slots", Data_encoding.list Data_encoding.int31) @@ -756,7 +756,7 @@ module Endorsement = struct ~level:Info ~name:"endorsement_stale_block" ~msg:"ignore block {block}: forged too far the past" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let endorsement_got_block = declare_1 @@ -764,7 +764,7 @@ module Endorsement = struct ~level:Info ~name:"endorsement_got_block" ~msg:"received new block {block}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let wait_before_injecting = declare_2 diff --git a/src/proto_012_Psithaca/lib_parameters/default_parameters.ml b/src/proto_012_Psithaca/lib_parameters/default_parameters.ml index c2f8a1c05d00..4b3e6185bf50 100644 --- a/src/proto_012_Psithaca/lib_parameters/default_parameters.ml +++ b/src/proto_012_Psithaca/lib_parameters/default_parameters.ml @@ -194,8 +194,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_012_Psithaca/lib_parameters/default_parameters.mli b/src/proto_012_Psithaca/lib_parameters/default_parameters.mli index 3551ac5d3117..3bc1b8edff70 100644 --- a/src/proto_012_Psithaca/lib_parameters/default_parameters.mli +++ b/src/proto_012_Psithaca/lib_parameters/default_parameters.mli @@ -35,7 +35,9 @@ val constants_test : Constants.parametric val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Signature.public_key_hash * Signature.public_key * Tez.t -> + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tez.t -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_012_Psithaca/lib_plugin/plugin.ml b/src/proto_012_Psithaca/lib_plugin/plugin.ml index e201c42e2a9c..ee6833a317da 100644 --- a/src/proto_012_Psithaca/lib_plugin/plugin.ml +++ b/src/proto_012_Psithaca/lib_plugin/plugin.ml @@ -76,7 +76,8 @@ let () = ~description: "If the balance is empty after precheck, the operation is invalid." Data_encoding.( - obj1 (req "public_key_hash" Signature.Public_key_hash.encoding)) + obj1 + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Balance_is_empty {source} -> Some source | _ -> None) (fun source -> Balance_is_empty {source}) @@ -233,13 +234,16 @@ module Mempool = struct (modulo replace_by_fee_factor) *) type manager_op_info = { - operation_hash : Operation_hash.t; + operation_hash : Tezos_crypto.Operation_hash.t; gas_limit : manager_gas_witness Gas.Arith.t; fee : Tez.t; weight : Q.t; } - type manager_op_weight = {operation_hash : Operation_hash.t; weight : Q.t} + type manager_op_weight = { + operation_hash : Tezos_crypto.Operation_hash.t; + weight : Q.t; + } let op_weight_of_info (info : manager_op_info) : manager_op_weight = {operation_hash = info.operation_hash; weight = info.weight} @@ -251,27 +255,31 @@ module Mempool = struct let compare op1 op2 = let c = Q.compare op1.weight op2.weight in if c <> 0 then c - else Operation_hash.compare op1.operation_hash op2.operation_hash + else + Tezos_crypto.Operation_hash.compare + op1.operation_hash + op2.operation_hash end) type state = { grandparent_level_start : Alpha_context.Timestamp.t option; round_zero_duration : Period.t option; - op_prechecked_managers : manager_op_info Signature.Public_key_hash.Map.t; + op_prechecked_managers : + manager_op_info Tezos_crypto.Signature.Public_key_hash.Map.t; (** All managers that are the source of manager operations prechecked in the mempool. Each manager in the map is associated to a record of type [manager_op_info] (See for record details above). Each manager in the map should be accessible with an operation hash in [operation_hash_to_manager]. *) operation_hash_to_manager : - Signature.Public_key_hash.t Operation_hash.Map.t; + Tezos_crypto.Signature.Public_key_hash.t Tezos_crypto.Operation_hash.Map.t; (** Map of operation hash to manager used to remove a manager from [op_prechecked_managers] with an operation hash. Each manager in the map should also be in [op_prechecked_managers]. *) prechecked_operations_count : int; (** Number of prechecked manager operations. Invariants: - - [Operation_hash.Map.cardinal operation_hash_to_manager = + - [Tezos_crypto.Operation_hash.Map.cardinal operation_hash_to_manager = prechecked_operations_count] - [prechecked_operations_count <= max_prechecked_manager_operations] *) ops_prechecked : ManagerOpWeightSet.t; @@ -286,8 +294,8 @@ module Mempool = struct { grandparent_level_start = None; round_zero_duration = None; - op_prechecked_managers = Signature.Public_key_hash.Map.empty; - operation_hash_to_manager = Operation_hash.Map.empty; + op_prechecked_managers = Tezos_crypto.Signature.Public_key_hash.Map.empty; + operation_hash_to_manager = Tezos_crypto.Operation_hash.Map.empty; prechecked_operations_count = 0; ops_prechecked = ManagerOpWeightSet.empty; min_prechecked_op_weight = None; @@ -346,7 +354,7 @@ module Mempool = struct let remove ~(filter_state : state) oph = let removed_oph_source = ref None in let operation_hash_to_manager = - Operation_hash.Map.update + Tezos_crypto.Operation_hash.Map.update oph (function | None -> None @@ -366,7 +374,7 @@ module Mempool = struct in let removed_op = ref None in let op_prechecked_managers = - Signature.Public_key_hash.Map.update + Tezos_crypto.Signature.Public_key_hash.Map.update source (function | None -> None @@ -387,7 +395,7 @@ module Mempool = struct match filter_state.min_prechecked_op_weight with | None -> None | Some op -> - if Operation_hash.equal op.operation_hash oph then + if Tezos_crypto.Operation_hash.equal op.operation_hash oph then ManagerOpWeightSet.min_elt ops_prechecked else Some op in @@ -431,7 +439,7 @@ module Mempool = struct (fun () -> Fees_too_low) type Environment.Error_monad.error += - | Manager_restriction of {oph : Operation_hash.t; fee : Tez.t} + | Manager_restriction of {oph : Tezos_crypto.Operation_hash.t; fee : Tez.t} let () = Environment.Error_monad.register_error_kind @@ -445,21 +453,21 @@ module Mempool = struct "Only one manager operation per manager per block allowed (found %a \ with %atez fee. You may want to use --replace to provide adequate \ fee and replace it)." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Tez.pp fee) Data_encoding.( obj2 - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation_fee" Tez.encoding)) (function Manager_restriction {oph; fee} -> Some (oph, fee) | _ -> None) (fun (oph, fee) -> Manager_restriction {oph; fee}) type Environment.Error_monad.error += | Manager_operation_replaced of { - old_hash : Operation_hash.t; - new_hash : Operation_hash.t; + old_hash : Tezos_crypto.Operation_hash.t; + new_hash : Tezos_crypto.Operation_hash.t; } let () = @@ -472,13 +480,13 @@ module Mempool = struct Format.fprintf ppf "The manager operation %a has been replaced with %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_hash - Operation_hash.pp + Tezos_crypto.Operation_hash.pp new_hash) (Data_encoding.obj2 - (Data_encoding.req "old_hash" Operation_hash.encoding) - (Data_encoding.req "new_hash" Operation_hash.encoding)) + (Data_encoding.req "old_hash" Tezos_crypto.Operation_hash.encoding) + (Data_encoding.req "new_hash" Tezos_crypto.Operation_hash.encoding)) (function | Manager_operation_replaced {old_hash; new_hash} -> Some (old_hash, new_hash) @@ -553,7 +561,7 @@ module Mempool = struct let check_manager_restriction config filter_state source ~fee ~gas_limit = match - Signature.Public_key_hash.Map.find + Tezos_crypto.Signature.Public_key_hash.Map.find source filter_state.op_prechecked_managers with @@ -1030,7 +1038,7 @@ module Mempool = struct config -> state -> validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Tezos_base.Operation.shell_header -> t Kind.manager protocol_data -> nb_successful_prechecks:int -> @@ -1038,7 +1046,8 @@ module Mempool = struct gas_limit:manager_gas_witness Gas.Arith.t -> public_key_hash -> [> `Prechecked_manager of - [`No_replace | `Replace of Operation_hash.t * error_classification] + [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification ] Lwt.t = fun config @@ -1135,8 +1144,11 @@ module Mempool = struct | `Replace (oph, _class) -> remove ~filter_state oph in let prechecked_operations_count = - if Operation_hash.Map.mem oph filter_state.operation_hash_to_manager then - filter_state.prechecked_operations_count + if + Tezos_crypto.Operation_hash.Map.mem + oph + filter_state.operation_hash_to_manager + then filter_state.prechecked_operations_count else filter_state.prechecked_operations_count + 1 in let op_weight = op_weight_of_info info in @@ -1149,12 +1161,15 @@ module Mempool = struct filter_state with op_prechecked_managers = (* Manager not seen yet, record it for next ops *) - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add source info filter_state.op_prechecked_managers; operation_hash_to_manager = - Operation_hash.Map.add oph source filter_state.operation_hash_to_manager + Tezos_crypto.Operation_hash.Map.add + oph + source + filter_state.operation_hash_to_manager (* Record which manager is used for the operation hash. *); ops_prechecked = ManagerOpWeightSet.add op_weight filter_state.ops_prechecked; @@ -1166,13 +1181,14 @@ module Mempool = struct config -> filter_state:state -> validation_state:validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Main.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification | `Undecided ] Lwt.t = @@ -1594,7 +1610,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (req "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -1658,7 +1674,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" string) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -1797,7 +1813,7 @@ module RPC = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") @@ -1816,7 +1832,7 @@ module RPC = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_operation") @@ -2114,7 +2130,7 @@ module RPC = struct let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Contract.init_origination_nonce ctxt hash in - let payload_producer = Signature.Public_key_hash.zero in + let payload_producer = Tezos_crypto.Signature.Public_key_hash.zero in match protocol_data.contents with | Single (Manager_operation _) as op -> Apply.precheck_manager_contents_list ctxt op ~mempool_mode:true @@ -2244,7 +2260,9 @@ module RPC = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Contract.init_origination_nonce ctxt Operation_hash.zero in + let ctxt = + Contract.init_origination_nonce ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.raw_originate @@ -3269,7 +3287,7 @@ module RPC = struct module Baking_rights = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; round : int; timestamp : Timestamp.t option; } @@ -3283,7 +3301,7 @@ module RPC = struct {level; delegate; round; timestamp}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "round" uint16) (opt "estimated_time" Timestamp.encoding)) @@ -3297,7 +3315,7 @@ module RPC = struct type baking_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; max_round : int option; all : bool; } @@ -3352,7 +3370,7 @@ module RPC = struct if Compare.Int.(round > max_round) then return (List.rev acc) else let (Misc.LCons (pk, next)) = l in - let delegate = Signature.Public_key.hash pk in + let delegate = Tezos_crypto.Signature.Public_key.hash pk in estimated_time round_durations ~current_level @@ -3371,13 +3389,16 @@ module RPC = struct @@ List.fold_left (fun (acc, previous) r -> if - Signature.Public_key_hash.Set.exists - (Signature.Public_key_hash.equal r.delegate) + Tezos_crypto.Signature.Public_key_hash.Set.exists + (Tezos_crypto.Signature.Public_key_hash.equal r.delegate) previous then (acc, previous) else - (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) - ([], Signature.Public_key_hash.Set.empty) + ( r :: acc, + Tezos_crypto.Signature.Public_key_hash.Set.add + r.delegate + previous )) + ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) rights let register () = @@ -3411,7 +3432,7 @@ module RPC = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights) @@ -3428,7 +3449,7 @@ module RPC = struct module Endorsing_rights = struct type delegate_rights = { - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; first_slot : Slot.t; endorsing_power : int; } @@ -3447,7 +3468,7 @@ module RPC = struct (fun (delegate, first_slot, endorsing_power) -> {delegate; first_slot; endorsing_power}) (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "first_slot" Slot.encoding) (req "endorsing_power" uint16)) @@ -3471,7 +3492,7 @@ module RPC = struct type endorsing_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -3549,7 +3570,7 @@ module RPC = struct (fun rights_at_level -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in match @@ -3572,7 +3593,7 @@ module RPC = struct module Validators = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; slots : Slot.t list; } @@ -3583,7 +3604,7 @@ module RPC = struct (fun (level, delegate, slots) -> {level; delegate; slots}) (obj3 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "slots" (list Slot.encoding))) module S = struct @@ -3593,7 +3614,7 @@ module RPC = struct type validators_query = { levels : Raw_level.t list; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let validators_query = @@ -3643,7 +3664,7 @@ module RPC = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights) diff --git a/src/proto_013_PtJakart/lib_client/client_proto_args.ml b/src/proto_013_PtJakart/lib_client/client_proto_args.ml index 15d64b27d583..eeb6e2cc739e 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_args.ml +++ b/src/proto_013_PtJakart/lib_client/client_proto_args.ml @@ -548,7 +548,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") @@ -673,7 +673,7 @@ module Tx_rollup = struct let context_hash_parameter = Tezos_clic.parameter (fun _ s -> - match Context_hash.of_b58check_opt s with + match Tezos_crypto.Context_hash.of_b58check_opt s with | Some hash -> return hash | None -> failwith diff --git a/src/proto_013_PtJakart/lib_client/client_proto_args.mli b/src/proto_013_PtJakart/lib_client/client_proto_args.mli index 20d804afd746..463d9f2a4f41 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_args.mli +++ b/src/proto_013_PtJakart/lib_client/client_proto_args.mli @@ -62,7 +62,8 @@ val entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg val default_entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -123,7 +124,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg @@ -173,7 +174,7 @@ module Tx_rollup : sig ?name:string -> usage:string -> ('a, full) Tezos_clic.params -> - (Context_hash.t -> 'a, full) Tezos_clic.params + (Tezos_crypto.Context_hash.t -> 'a, full) Tezos_clic.params val message_result_path_param : ?name:string -> diff --git a/src/proto_013_PtJakart/lib_client/client_proto_context.ml b/src/proto_013_PtJakart/lib_client/client_proto_context.ml index c070dfe1c739..8efd4e7e46bf 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_context.ml +++ b/src/proto_013_PtJakart/lib_client/client_proto_context.ml @@ -300,7 +300,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -473,7 +473,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -484,7 +484,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -514,7 +514,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -562,12 +562,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -593,7 +595,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Client_proto_args.tez_sym Tez.pp @@ -608,13 +610,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -654,7 +656,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -764,7 +766,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_013_PtJakart/lib_client/client_proto_context.mli b/src/proto_013_PtJakart/lib_client/client_proto_context.mli index 6ad41787284f..fe22473d14d1 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_context.mli +++ b/src/proto_013_PtJakart/lib_client/client_proto_context.mli @@ -60,8 +60,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -105,7 +105,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t val build_delegate_operation : @@ -284,7 +284,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -332,7 +332,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -370,7 +370,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -382,7 +382,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -392,7 +392,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t val cached_contracts : @@ -432,12 +432,12 @@ val originate_tx_rollup : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_origination Kind.manager contents * Kind.tx_rollup_origination Kind.manager Apply_results.contents_result) tzresult @@ -456,14 +456,14 @@ val submit_tx_rollup_batch : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> content:string -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_submit_batch Kind.manager contents * Kind.tx_rollup_submit_batch Kind.manager Apply_results.contents_result) tzresult @@ -481,8 +481,8 @@ val submit_tx_rollup_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -491,7 +491,7 @@ val submit_tx_rollup_commitment : predecessor:Tx_rollup_commitment_hash.t option -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_commit Kind.manager contents * Kind.tx_rollup_commit Kind.manager Apply_results.contents_result) tzresult @@ -509,13 +509,13 @@ val submit_tx_rollup_finalize_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_finalize_commitment Kind.manager contents * Kind.tx_rollup_finalize_commitment Kind.manager Apply_results.contents_result) @@ -534,13 +534,13 @@ val submit_tx_rollup_remove_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_remove_commitment Kind.manager contents * Kind.tx_rollup_remove_commitment Kind.manager Apply_results.contents_result) tzresult @@ -558,8 +558,8 @@ val submit_tx_rollup_rejection : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -569,12 +569,12 @@ val submit_tx_rollup_rejection : message_path:Tx_rollup_inbox.Merkle.path -> message_result_hash:Tx_rollup_message_result_hash.t -> message_result_path:Tx_rollup_commitment.Merkle.path -> - previous_context_hash:Context_hash.t -> + previous_context_hash:Tezos_crypto.Context_hash.t -> previous_withdraw_list_hash:Tx_rollup_withdraw_list_hash.t -> previous_message_result_path:Tx_rollup_commitment.Merkle.path -> proof:Tx_rollup_l2_proof.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_rejection Kind.manager contents * Kind.tx_rollup_rejection Kind.manager Apply_results.contents_result) tzresult @@ -592,13 +592,13 @@ val submit_tx_rollup_return_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_return_bond Kind.manager contents * Kind.tx_rollup_return_bond Kind.manager Apply_results.contents_result) tzresult @@ -616,18 +616,18 @@ val tx_rollup_dispatch_tickets : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> - context_hash:Context_hash.t -> + context_hash:Tezos_crypto.Context_hash.t -> message_position:int -> message_result_path:Tx_rollup_commitment.Merkle.path -> tickets_info:Tx_rollup_reveal.t list -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_dispatch_tickets Kind.manager contents * Kind.tx_rollup_dispatch_tickets Kind.manager Apply_results.contents_result) tzresult @@ -645,8 +645,8 @@ val transfer_ticket : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> contents:string -> @@ -656,7 +656,7 @@ val transfer_ticket : destination:Contract.t -> entrypoint:Entrypoint.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.transfer_ticket Kind.manager contents * Kind.transfer_ticket Kind.manager Apply_results.contents_result) tzresult @@ -681,7 +681,7 @@ val sc_rollup_originate : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_originate Kind.manager contents * Kind.sc_rollup_originate Kind.manager Apply_results.contents_result, tztrace ) @@ -707,7 +707,7 @@ val sc_rollup_add_messages : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_add_messages Kind.manager contents * Kind.sc_rollup_add_messages Kind.manager Apply_results.contents_result) tzresult @@ -732,7 +732,7 @@ val sc_rollup_cement : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_cement Kind.manager contents * Kind.sc_rollup_cement Kind.manager Apply_results.contents_result) tzresult @@ -757,7 +757,7 @@ val sc_rollup_publish : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_publish Kind.manager contents * Kind.sc_rollup_publish Kind.manager Apply_results.contents_result) tzresult diff --git a/src/proto_013_PtJakart/lib_client/client_proto_multisig.ml b/src/proto_013_PtJakart/lib_client/client_proto_multisig.ml index 41a267cb4e5a..f6db6b82d6dc 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_multisig.ml +++ b/src/proto_013_PtJakart/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -578,11 +582,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) @@ -593,10 +598,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) Data_encoding.(tup2 Contract.encoding Entrypoint.value_encoding) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -701,7 +708,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -777,7 +784,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -804,7 +811,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -814,7 +821,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -841,7 +848,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -853,7 +861,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -874,7 +882,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -891,7 +902,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1038,7 +1053,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1160,7 +1175,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = Data_encoding.Binary.of_bytes_exn Contract.encoding contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_013_PtJakart/lib_client/client_proto_multisig.mli b/src/proto_013_PtJakart/lib_client/client_proto_multisig.mli index 909cc0b550cd..609d0c37e66f 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_multisig.mli +++ b/src/proto_013_PtJakart/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -138,7 +138,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_013_PtJakart/lib_client/client_proto_utils.ml b/src/proto_013_PtJakart/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_utils.ml +++ b/src/proto_013_PtJakart/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_013_PtJakart/lib_client/client_proto_utils.mli b/src/proto_013_PtJakart/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_013_PtJakart/lib_client/client_proto_utils.mli +++ b/src/proto_013_PtJakart/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_013_PtJakart/lib_client/injection.ml b/src/proto_013_PtJakart/lib_client/injection.ml index ceb9b29ff246..42f0090655d7 100644 --- a/src/proto_013_PtJakart/lib_client/injection.ml +++ b/src/proto_013_PtJakart/lib_client/injection.ml @@ -55,12 +55,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee (contents : packed_contents_list) = let l = Operation.to_list contents in @@ -184,18 +187,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -218,7 +226,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -244,7 +252,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let watermark = match contents with (* TODO-TB sign endosrement? *) - | _ -> Signature.Generic_operation + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -259,7 +267,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -698,7 +706,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -962,12 +970,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -978,7 +986,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (* Adjust user-provided confirmations with respect to Alpha protocol finality properties *) tenderbake_adjust_confirmations cctxt confirmations >>= fun confirmations -> (match confirmations with @@ -990,10 +999,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -1054,10 +1063,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op, result.contents) @@ -1120,10 +1129,10 @@ let pending_applied_operations_of_source (cctxt : #full) chain src : (fun acc (_oph, {protocol_data = Operation_data {contents; _}; _}) -> match contents with | Single (Manager_operation {source; _} as _op) - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | Cons (Manager_operation {source; _}, _rest) as _op - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | _ -> acc) [] @@ -1246,14 +1255,14 @@ let replace_operation (type kind) (cctxt : #full) chain source cctxt#error "Cannot replace! No applied manager operation found for %a in \ mempool@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source >>= fun () -> exit 1 | _ :: _ :: _ as l -> cctxt#error "More than one applied manager operation found for %a in mempool. \ Found %d operations. Are you sure the node is in precheck mode?@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source (List.length l) >>= fun () -> exit 1 @@ -1278,7 +1287,7 @@ let inject_manager_operation cctxt ~chain ~block ?successor_level ?branch ~src_sk ~fee ~gas_limit ~storage_limit ?counter ?(replace_by_fees = false) ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * kind Kind.manager contents_list * kind Kind.manager contents_result_list) diff --git a/src/proto_013_PtJakart/lib_client/injection.mli b/src/proto_013_PtJakart/lib_client/injection.mli index 79059c0bbade..15ce22884d6d 100644 --- a/src/proto_013_PtJakart/lib_client/injection.mli +++ b/src/proto_013_PtJakart/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -65,7 +65,9 @@ val simulate : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -85,7 +87,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -105,8 +108,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> @@ -115,7 +118,7 @@ val inject_manager_operation : ?replace_by_fees:bool -> fee_parameter:fee_parameter -> 'kind Annotated_manager_operation.annotated_list -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * 'kind Kind.manager contents_list * 'kind Kind.manager contents_result_list) diff --git a/src/proto_013_PtJakart/lib_client/managed_contract.ml b/src/proto_013_PtJakart/lib_client/managed_contract.ml index d05ea75823cc..22a347315236 100644 --- a/src/proto_013_PtJakart/lib_client/managed_contract.ml +++ b/src/proto_013_PtJakart/lib_client/managed_contract.ml @@ -49,7 +49,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -60,7 +60,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -87,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -102,7 +106,7 @@ let entrypoint_remove_delegate = Entrypoint.remove_delegate let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = entrypoint_do in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -137,7 +141,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -158,7 +162,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -188,7 +192,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_013_PtJakart/lib_client/mockup.ml b/src/proto_013_PtJakart/lib_client/mockup.ml index b4849201b12c..ead4324731dd 100644 --- a/src/proto_013_PtJakart/lib_client/mockup.ml +++ b/src/proto_013_PtJakart/lib_client/mockup.ml @@ -92,7 +92,7 @@ module Protocol_constants_overrides = struct sc_rollup_challenge_window_in_blocks : int option; sc_rollup_max_available_messages : int option; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; initial_seed : State_hash.t option option; } @@ -319,7 +319,7 @@ module Protocol_constants_overrides = struct (opt "ratio_of_frozen_deposits_slashed_per_double_endorsement" Constants.ratio_encoding) - (opt "chain_id" Chain_id.encoding) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding) (opt "initial_seed" (option State_hash.encoding))) (merge_objs @@ -740,7 +740,12 @@ module Protocol_constants_overrides = struct override_value = o.sc_rollup_challenge_window_in_blocks; pp = pp_print_int; }; - O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; + O + { + name = "chain_id"; + override_value = o.chain_id; + pp = Tezos_crypto.Chain_id.pp; + }; O { name = "timestamp"; @@ -1028,7 +1033,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. {public_key_hash; public_key = Some public_key; amount = repr.amount} @@ -1088,8 +1093,8 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount) -> {public_key_hash; public_key; amount}) (obj3 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding)) end @@ -1101,7 +1106,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -1162,10 +1167,10 @@ let lib_parameters_json_encoding = (fun (pk, amount) -> { Parameters.public_key = Some pk; - public_key_hash = Signature.Public_key.hash pk; + public_key_hash = Tezos_crypto.Signature.Public_key.hash pk; amount; }) - (tup2 Signature.Public_key.encoding Tez.encoding) + (tup2 Tezos_crypto.Signature.Public_key.encoding Tez.encoding) in Data_encoding.( merge_objs @@ -1178,7 +1183,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -1198,14 +1203,14 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end (* ------------------------------------------------------------------------- *) (* RPC context *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" let endorsement_branch_data_encoding = @@ -1214,7 +1219,7 @@ let endorsement_branch_data_encoding = (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (obj2 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "block_payload_hash" Protocol.Block_payload_hash.encoding)) let initial_context chain_id (header : Block_header.shell_header) @@ -1323,7 +1328,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in Protocol_constants_overrides.apply_overrides (cctxt :> Tezos_client_base.Client_context.printer) @@ -1380,10 +1385,13 @@ let mem_init : let protocol_data = let payload_hash = Protocol.Block_payload_hash.hash_bytes - [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] + [ + Tezos_crypto.Block_hash.to_bytes hash; + Tezos_crypto.Operation_list_hash.(to_bytes @@ compute []); + ] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Signature.generate_key () in + let _, _, sk = Tezos_crypto.Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -1403,7 +1411,7 @@ let mem_init : (shell_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_013_PtJakart/lib_client/operation_result.ml b/src/proto_013_PtJakart/lib_client/operation_result.ml index 952e4a10c09a..79c3e8ddd4e6 100644 --- a/src/proto_013_PtJakart/lib_client/operation_result.ml +++ b/src/proto_013_PtJakart/lib_client/operation_result.ml @@ -93,7 +93,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) ; pp_result ppf result ; Format.fprintf ppf "@]" @@ -104,7 +104,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal revelation" else "Revelation") Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key pp_result result @@ -124,7 +124,7 @@ let pp_manager_operation_content (type kind) source internal pp_result ppf (if internal then "Internal Delegation" else "Delegation") Contract.pp source - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate pp_result result @@ -323,9 +323,12 @@ let pp_balance_updates ppf = function (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero then Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -886,7 +889,7 @@ let pp_manager_operation_contents_and_result ppf Expected counter: %s@,\ Gas limit: %a@,\ Storage limit: %s bytes" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source Client_proto_args.tez_sym Tez.pp @@ -952,9 +955,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -973,7 +976,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate preendorsement_power | Single_and_result @@ -990,7 +993,7 @@ let rec pp_contents_and_result_list : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate endorsement_power | Single_and_result @@ -1003,9 +1006,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1019,9 +1022,9 @@ let rec pp_contents_and_result_list : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1032,7 +1035,7 @@ let rec pp_contents_and_result_list : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -1041,20 +1044,20 @@ let rec pp_contents_and_result_list : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Single_and_result (Ballot {source; period; proposal; ballot}, Ballot_result) -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_013_PtJakart/lib_client/proxy.ml b/src/proto_013_PtJakart/lib_client/proxy.ml index 1bc8a5bb8f40..4fcf55f89628 100644 --- a/src/proto_013_PtJakart/lib_client/proxy.ml +++ b/src/proto_013_PtJakart/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_context_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_context_commands.ml index 4177b81b5fb5..eb61382be7ac 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_context_commands.ml @@ -100,7 +100,7 @@ let non_negative_param = let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let rollup_kind_param = @@ -478,7 +478,7 @@ let commands_ro () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -519,7 +519,10 @@ let commands_ro () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -537,12 +540,16 @@ let commands_ro () = fprintf ppf "* %a %a %s (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p Tez.pp (Tez.of_mutez_exn w) Client_proto_args.tez_sym - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; @@ -1749,7 +1756,7 @@ let commands_rw () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ prefixes ["to"; "be"; "included"] @@ -1786,7 +1793,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1838,7 +1845,7 @@ let commands_rw () = Constants.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1851,31 +1858,34 @@ let commands_rw () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not (List.exists (fun (pkh, _) -> - Signature.Public_key_hash.equal pkh src_pkh) + Tezos_crypto.Signature.Public_key_hash.equal pkh src_pkh) listings) then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1952,7 +1962,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1992,12 +2002,12 @@ let commands_rw () = >>=? fun current_proposal -> (match (info.current_period_kind, current_proposal) with | (Exploration | Promotion), Some current_proposal -> - if Protocol_hash.equal proposal current_proposal then - return_unit + if Tezos_crypto.Protocol_hash.equal proposal current_proposal + then return_unit else (if force then cctxt#warning else cctxt#error) "Unexpected proposal, expected: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp current_proposal >>= fun () -> return_unit | _ -> diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_fa12_commands.ml index 439d0c2a06e4..b49050a23b18 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_fa12_commands.ml @@ -119,7 +119,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.implicit_contract Signature.Public_key_hash.zero +let dummy_callback = + Contract.implicit_contract Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt caller = match Contract.is_implicit caller with diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_multisig_commands.ml index 4bb53f7e754c..ac73d803e088 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_multisig_commands.ml @@ -123,7 +123,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -137,7 +138,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) ~destination @@ -354,7 +355,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a lambda for a generic multisig contract." @@ -384,7 +385,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate change for a multisig contract." @@ -413,7 +414,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate withdraw for a multisig contract." @@ -438,7 +439,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc: @@ -474,7 +475,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Transfer tokens using a multisig contract." diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_programs_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_programs_commands.ml index cd1d98c995cc..bec4370d9ac3 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_programs_commands.ml @@ -133,7 +133,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -452,8 +452,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -668,8 +668,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_stresstest_commands.ml index 35785c81f5a5..c1f043bf15fc 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_stresstest_commands.ml @@ -68,7 +68,7 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type input_source = @@ -81,7 +81,7 @@ type source_origin = {source : source; origin : origin} (** Destination of a call: either an implicit contract or an originated one with all the necessary data (entrypoint and the argument). *) type destination = - | Implicit of Signature.Public_key_hash.t + | Implicit of Tezos_crypto.Signature.Public_key_hash.t | Originated of Smart_contracts.invocation_parameters type transfer = { @@ -95,19 +95,22 @@ type transfer = { } type state = { - current_head_on_start : Block_hash.t; - counters : (Block_hash.t * Z.t) Signature.Public_key_hash.Table.t; + current_head_on_start : Tezos_crypto.Block_hash.t; + counters : + (Tezos_crypto.Block_hash.t * Z.t) + Tezos_crypto.Signature.Public_key_hash.Table.t; mutable pool : source_origin list; mutable pool_size : int; (** [Some l] if [single_op_per_pkh_per_block] is true *) mutable shuffled_pool : source list option; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; - mutable target_block : Block_hash.t; + mutable target_block : Tezos_crypto.Block_hash.t; (** The block on top of which we are injecting transactions (HEAD~2). *) new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } (** Cost estimations for every kind of transaction used in the stress test. @@ -154,9 +157,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -168,7 +171,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -179,8 +182,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let transaction_costs_encoding = let open Data_encoding in @@ -233,7 +236,7 @@ let parse_strategy s = let normalize_source cctxt = let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -269,8 +272,8 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - cctxt#warning msg Signature.Public_key_hash.pp pkh >>= fun () -> - Lwt.return_none + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + >>= fun () -> Lwt.return_none in (Client_keys.get_key cctxt pkh >>= function | Error _ -> warning "Pkh \"%a\" not found in the wallet" pkh @@ -280,7 +283,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias >>= fun () -> Lwt.return_none @@ -325,13 +328,13 @@ let rec sample_source_from_pool state rng (cctxt : Protocol_client_context.full) cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) >>= fun () -> Lwt.return source | Some [] -> cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block >>= fun () -> Lwt_condition.wait state.new_block_condition >>= fun () -> @@ -342,7 +345,7 @@ let random_seed rng = let generate_fresh_source pool rng = let seed = random_seed rng in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in pool.pool <- fresh :: pool.pool ; pool.pool_size <- pool.pool_size + 1 ; @@ -370,7 +373,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block debug_msg (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) >>= fun () -> (* Sampled source has zero balance: the transfer that created that @@ -419,7 +422,11 @@ let inject_contents (cctxt : Protocol_client_context.full) chain branch sk ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -470,7 +477,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng >>=? fun pcounter -> Shell_services.Blocks.hash cctxt ~chain ~block () >>=? fun branch -> (* If there is a new block refresh the fresh_pool *) - if not (Block_hash.equal branch state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal branch state.last_block) then ( state.last_block <- branch ; (* Because of how Tenderbake works the target block should stay 2 blocks in the past because this guarantees that we are targeting a @@ -489,14 +496,16 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng return () >>=? fun () -> let freshest_counter = match - Signature.Public_key_hash.Table.find state.counters transfer.src.pkh + Tezos_crypto.Signature.Public_key_hash.Table.find + state.counters + transfer.src.pkh with | None -> (* This is the first operation we inject for this pkh: the counter given by the RPC _must_ be the freshest one. *) pcounter | Some (previous_branch, previous_counter) -> - if Block_hash.equal branch previous_branch then + if Tezos_crypto.Block_hash.equal branch previous_branch then (* We already injected an operation on top of this block: the one stored locally is the freshest one. *) previous_counter @@ -506,14 +515,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng given by the RPC. *) pcounter in - (if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + (if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; Alpha_services.Contract.manager_key cctxt (chain, block) transfer.src.pkh >>=? fun pk_opt -> return (Option.is_some pk_opt))) >>=? fun already_revealed -> @@ -537,15 +551,17 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Cons (reveal, Single manager_op) in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print reveal_counter @@ -568,15 +584,17 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng {transfer with counter = Some transf_counter} in let list = Single manager_op in - Signature.Public_key_hash.Table.remove state.counters transfer.src.pkh ; - Signature.Public_key_hash.Table.add + Tezos_crypto.Signature.Public_key_hash.Table.remove + state.counters + transfer.src.pkh ; + Tezos_crypto.Signature.Public_key_hash.Table.add state.counters transfer.src.pkh (branch, transf_counter) ; (if !verbose then cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print transf_counter @@ -591,15 +609,17 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state rng debug_msg (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) >>= fun () -> let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find + state.injected_operations + branch) in - Block_hash.Table.replace + Tezos_crypto.Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; @@ -616,7 +636,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -637,10 +657,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = Shell_services.Blocks.hash cctxt () >>=? fun current_head_on_exit -> let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -668,7 +688,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -681,9 +701,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = debug_msg (fun () -> cctxt#message "injected : %a\nincluded: %a" - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list Operation_hash.pp) + (Format.pp_print_list Tezos_crypto.Operation_hash.pp) included_ops) >>= fun () -> let injected_ops_count = List.length injected_ops in @@ -773,7 +793,7 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) dont_wait (fun () -> on_new_head cctxt (fun (block, new_block_header) -> - if not (Block_hash.equal block state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal block state.last_block) then ( state.last_block <- block ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1111,7 +1131,9 @@ let generate_random_transactions = (if !verbose then cctxt#message "all sources have been normalized" else Lwt.return_unit) >>= fun () -> - let counters = Signature.Public_key_hash.Table.create 1023 in + let counters = + Tezos_crypto.Signature.Public_key_hash.Table.create 1023 + in let rng = Random.State.make [|parameters.seed|] in Shell_services.Blocks.hash cctxt () >>=? fun current_head_on_start -> Shell_services.Blocks.hash cctxt ~block:(`Head 2) () @@ -1131,12 +1153,12 @@ let generate_random_transactions = ~rng (List.map (fun src_org -> src_org.source) sources)) else None); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.level; target_block = current_target_block; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = @@ -1190,7 +1212,7 @@ let estimate_transaction_cost parameters (cctxt : Protocol_client_context.full) Protocol_client_context.Alpha_block_services.header cctxt () >>=? fun header_on_start -> let current_head_on_start = header_on_start.hash in - let counters = Signature.Public_key_hash.Table.create 1023 in + let counters = Tezos_crypto.Signature.Public_key_hash.Table.create 1023 in Shell_services.Blocks.hash cctxt ~block:(`Head 2) () >>=? fun current_target_block -> let state = @@ -1200,12 +1222,12 @@ let estimate_transaction_cost parameters (cctxt : Protocol_client_context.full) pool = sources; pool_size = List.length sources; shuffled_pool = None; - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.shell.level; target_block = current_target_block; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let rng = Random.State.make [|parameters.seed|] in diff --git a/src/proto_013_PtJakart/lib_client_commands/client_proto_utils_commands.ml b/src/proto_013_PtJakart/lib_client_commands/client_proto_utils_commands.ml index 9ff9765920ad..cd8c924cfff6 100644 --- a/src/proto_013_PtJakart/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_013_PtJakart/lib_client_commands/client_proto_utils_commands.ml @@ -88,8 +88,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: @@ -157,5 +157,6 @@ let commands () = (Block_header chain_id)) sk unsigned_header - >>=? fun s -> cctxt#message "%a" Hex.pp (Signature.to_hex s) >>= return); + >>=? fun s -> + cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) >>= return); ] diff --git a/src/proto_013_PtJakart/lib_client_sapling/client_sapling_commands.ml b/src/proto_013_PtJakart/lib_client_sapling/client_sapling_commands.ml index b6dbecdb9a7a..761cb6cb4f1b 100644 --- a/src/proto_013_PtJakart/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_013_PtJakart/lib_client_sapling/client_sapling_commands.ml @@ -52,7 +52,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -60,7 +60,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Alpha_context.Contract.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) (** The shielded tez contract expects the recipient pkh encoded in Micheline @@ -69,7 +69,9 @@ let bound_data_of_public_key_hash cctxt dst = let open Tezos_micheline in let open Protocol.Michelson_v1_primitives in let pkh_bytes = - Data_encoding.Binary.to_bytes_exn Signature.Public_key_hash.encoding dst + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key_hash.encoding + dst in let micheline_bytes = Micheline.(Bytes (0, pkh_bytes) |> strip_locations) in let micheline_pkh_type = @@ -733,7 +735,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_013_PtJakart/lib_client_sapling/context.ml b/src/proto_013_PtJakart/lib_client_sapling/context.ml index 0ce463e82e4e..ad91544b0d80 100644 --- a/src/proto_013_PtJakart/lib_client_sapling/context.ml +++ b/src/proto_013_PtJakart/lib_client_sapling/context.ml @@ -140,7 +140,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_013_PtJakart/lib_client_sapling/wallet.ml b/src/proto_013_PtJakart/lib_client_sapling/wallet.ml index c5df62f580c8..412619eec4b8 100644 --- a/src/proto_013_PtJakart/lib_client_sapling/wallet.ml +++ b/src/proto_013_PtJakart/lib_client_sapling/wallet.ml @@ -27,7 +27,7 @@ open Client_keys open Tezos_sapling.Core.Client module Mnemonic = struct - let new_random = Bip39.of_entropy (Hacl.Rand.gen 32) + let new_random = Bip39.of_entropy (Tezos_crypto.Hacl.Rand.gen 32) let to_sapling_key mnemonic = (* Z-cash needs 32 bytes and BIP-39 gives 64 bytes of entropy. diff --git a/src/proto_013_PtJakart/lib_delegate/baking_events.ml b/src/proto_013_PtJakart/lib_delegate/baking_events.ml index 8a148aefb8e7..ee28698ff809 100644 --- a/src/proto_013_PtJakart/lib_delegate/baking_events.ml +++ b/src/proto_013_PtJakart/lib_delegate/baking_events.ml @@ -43,8 +43,8 @@ module State_transitions = struct ~name:"new_head" ~level:Notice ~msg:"received new head {block} at level {level}, round {round}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) ~pp3:Round.pp @@ -119,12 +119,12 @@ module State_transitions = struct ~msg: "proposal {new_proposal} for current round ({current_round}) has \ already been seen {previous_proposal}" - ~pp1:Block_hash.pp - ("new_proposal", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("new_proposal", Tezos_crypto.Block_hash.encoding) ~pp2:Round.pp ("current_round", Round.encoding) - ~pp3:Block_hash.pp - ("previous_proposal", Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("previous_proposal", Tezos_crypto.Block_hash.encoding) let updating_latest_proposal = declare_1 @@ -132,8 +132,8 @@ module State_transitions = struct ~name:"updating_latest_proposal" ~msg:"updating latest proposal to {block_hash}" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let baker_is_ahead_of_node = declare_2 @@ -156,10 +156,10 @@ module State_transitions = struct ~msg: "received a proposal on another branch - current: current \ pred{current_branch}, new pred {new_branch}" - ~pp1:Block_hash.pp - ("current_branch", Block_hash.encoding) - ~pp2:Block_hash.pp - ("new_branch", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("current_branch", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("new_branch", Tezos_crypto.Block_hash.encoding) let switching_branch = declare_0 @@ -215,8 +215,8 @@ module State_transitions = struct ~name:"preendorsing_proposal" ~level:Info ~msg:"preendorsing proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let skipping_invalid_proposal = declare_0 @@ -232,8 +232,8 @@ module State_transitions = struct ~name:"outdated_proposal" ~level:Debug ~msg:"outdated proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let proposing_fresh_block = declare_2 @@ -271,10 +271,10 @@ module State_transitions = struct ~msg: "unexpected prequorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let unexpected_quorum_received = declare_2 @@ -284,10 +284,10 @@ module State_transitions = struct ~msg: "unexpected quorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let step_current_phase = declare_2 @@ -321,8 +321,8 @@ module Node_rpc = struct ~name:"raw_info" ~level:Debug ~msg:"raw info for {block_hash} at level {level}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) end @@ -451,8 +451,8 @@ module Scheduling = struct ~name:"proposal_in_the_future" ~level:Debug ~msg:"received proposal in the future {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let process_proposal_in_the_future = declare_1 @@ -460,8 +460,8 @@ module Scheduling = struct ~name:"process_proposal_in_the_future" ~level:Debug ~msg:"process proposal received in the future with hash {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) end module Lib = struct @@ -543,8 +543,8 @@ module Actions = struct ~name:"preendorsement_injected" ~level:Notice ~msg:"injected preendorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -554,8 +554,8 @@ module Actions = struct ~name:"endorsement_injected" ~level:Notice ~msg:"injected endorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -565,8 +565,8 @@ module Actions = struct ~name:"synchronizing_round" ~level:Info ~msg:"synchronizing round after block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let forging_block = declare_3 @@ -605,11 +605,11 @@ module Actions = struct ~msg: "block {block} at level {level}, round {round} injected for delegate \ {delegate}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:pp_int32 ~pp3:Round.pp ~pp4:Baking_state.pp_delegate - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("round", Round.encoding) ("delegate", Baking_state.delegate_encoding) @@ -678,8 +678,8 @@ module Nonces = struct ~name:"found_nonce_to_reveal" ~level:Notice ~msg:"found nonce to reveal for block {block}, level {level}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) @@ -695,8 +695,8 @@ module Nonces = struct ("level", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let cannot_fetch_chain_head_level = declare_0 @@ -771,8 +771,8 @@ module Nonces = struct ~name:"registering_nonce" ~level:Info ~msg:"registering nonce for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let nothing_to_reveal = declare_1 @@ -780,8 +780,8 @@ module Nonces = struct ~name:"nothing_to_reveal" ~level:Info ~msg:"nothing to reveal for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let revelation_worker_started = declare_0 @@ -864,8 +864,8 @@ module Selection = struct ~name:"invalid_operation_filtered" ~level:Warning ~msg:"filtered invalid operation {op}: {errors}" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) @@ -875,6 +875,6 @@ module Selection = struct ~name:"cannot_serialize_operation_metadata" ~level:Warning ~msg:"cannot serialize operation {op} metadata" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) end diff --git a/src/proto_013_PtJakart/lib_delegate/delegate_events.ml b/src/proto_013_PtJakart/lib_delegate/delegate_events.ml index 7e8988d6e3c2..912bad034cf0 100644 --- a/src/proto_013_PtJakart/lib_delegate/delegate_events.ml +++ b/src/proto_013_PtJakart/lib_delegate/delegate_events.ml @@ -41,7 +41,7 @@ module Revelation = struct ~level ~name:"no_nonce_reveal" ~msg:"nothing to reveal for block {block}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let reveal_nonce = declare_5 @@ -55,7 +55,7 @@ module Revelation = struct ("level", Alpha_context.Raw_level.encoding) ("chain", Data_encoding.string) ("block", Data_encoding.string) - ("operation", Operation_hash.encoding) + ("operation", Tezos_crypto.Operation_hash.encoding) end module Nonces = struct @@ -99,7 +99,7 @@ module Nonces = struct ~level ~name:"found_nonce" ~msg:"found nonce to reveal for {hash} (level: {level})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) let bad_nonce = @@ -131,8 +131,8 @@ module Denunciator = struct ~level ~name:"double_endorsement_detected" ~msg:"double endorsement detected" - ("existing_endorsement", Operation_hash.encoding) - ("new_endorsement", Operation_hash.encoding) + ("existing_endorsement", Tezos_crypto.Operation_hash.encoding) + ("new_endorsement", Tezos_crypto.Operation_hash.encoding) let double_endorsement_denounced = declare_2 @@ -140,7 +140,7 @@ module Denunciator = struct ~level ~name:"double_endorsement_denounced" ~msg:"double endorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -150,8 +150,8 @@ module Denunciator = struct ~level ~name:"double_preendorsement_detected" ~msg:"double preendorsement detected" - ("existing_preendorsement", Operation_hash.encoding) - ("new_preendorsement", Operation_hash.encoding) + ("existing_preendorsement", Tezos_crypto.Operation_hash.encoding) + ("new_preendorsement", Tezos_crypto.Operation_hash.encoding) let double_preendorsement_denounced = declare_2 @@ -159,7 +159,7 @@ module Denunciator = struct ~level ~name:"double_preendorsement_denounced" ~msg:"double preendorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -169,7 +169,7 @@ module Denunciator = struct ~level:Error ~name:"inconsistent_endorsement" ~msg:"inconsistent endorsement found {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) let unexpected_pruned_block = declare_1 @@ -177,7 +177,7 @@ module Denunciator = struct ~level:Error ~name:"unexpected_pruned_block" ~msg:"unexpected pruned block: {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let double_baking_but_not = declare_0 @@ -201,7 +201,7 @@ module Denunciator = struct ~level ~name:"double_baking_denounced" ~msg:"double baking evidence injected {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -220,7 +220,7 @@ module Denunciator = struct ~name:"accuser_saw_block" ~msg:"block level: {level}" ("level", Alpha_context.Raw_level.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetch_operations_error = declare_1 @@ -228,8 +228,8 @@ module Denunciator = struct ~level:Error ~name:"fetch_operations_error" ~msg:"error while fetching operations of block {hash}" - ("hash", Block_hash.encoding) - ~pp1:Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp let accuser_processed_block = declare_1 @@ -237,7 +237,7 @@ module Denunciator = struct ~level ~name:"accuser_processed_block" ~msg:"block {hash} registered" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let accuser_block_error = declare_2 @@ -246,7 +246,7 @@ module Denunciator = struct ~name:"accuser_block_error" ~msg:"error while processing block {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) end @@ -325,7 +325,7 @@ module Baking_forge = struct ~level:Info ~name:"inject_baked_block" ~msg:"Client_baking_forge.inject_block: inject {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_ignore ("header", Data_encoding.bytes) ~pp3:Format.(pp_print_list @@ pp_print_list @@ Operation.pp) @@ -338,7 +338,7 @@ module Baking_forge = struct ~level:Debug ~name:"baking_local_validation_start" ~msg:"starting client-side validation after {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let context_fetch_error = declare_1 @@ -364,7 +364,7 @@ module Baking_forge = struct ~name:"baking_rejected_invalid_operation" ~msg:"client-side validation: filtered invalid operation {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) let shell_prevalidation_notice = @@ -436,7 +436,7 @@ module Baking_forge = struct ~name:"try_baking" ~msg: "try baking after {hash} (slot {priority}) for {client} ({timestamp})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("priority", Data_encoding.int31) ("client", Data_encoding.string) ("timestamp", Time.System.encoding) @@ -480,7 +480,7 @@ module Baking_forge = struct ~msg: "try forging locally the block header for {hash} (slot {priority}) for \ {client} ({timestamp})" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("priority", Data_encoding.int31) ("client", Data_encoding.string) ("timestamp", Time.System.encoding) @@ -497,7 +497,7 @@ module Baking_forge = struct ("priority", Data_encoding.int31) ("fitness", Fitness.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let injected_block = @@ -511,9 +511,9 @@ module Baking_forge = struct {operations})" ~pp6:Fitness.pp ~pp7:Format.(pp_print_list Operation.pp) - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) ("priority", Data_encoding.int31) ("fitness", Fitness.encoding) @@ -549,7 +549,7 @@ module Baking_forge = struct ("priority", Data_encoding.int31) ("timestamp", Time.System.encoding) ("client", Data_encoding.string) - ("predecessor", Block_hash.encoding) + ("predecessor", Tezos_crypto.Block_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let read_nonce_fail = @@ -689,10 +689,10 @@ module Endorsement = struct ~msg: "injected endorsement for block '{block_hash}' (level {level}, \ contract {client}) '{op_hash}'" - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("level", Alpha_context.Raw_level.encoding) ("client", Data_encoding.string) - ("op_hash", Operation_hash.encoding) + ("op_hash", Tezos_crypto.Operation_hash.encoding) ("baker", Client_keys.Public_key_hash.encoding) let endorsing = @@ -701,7 +701,7 @@ module Endorsement = struct ~level:Debug ~name:"endorsing" ~msg:"endorsing {block} for {client} (level {level})!" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) ("level", Alpha_context.Raw_level.encoding) @@ -711,7 +711,7 @@ module Endorsement = struct ~level:Debug ~name:"check_endorsement_ok" ~msg:"checking if allowed to endorse block {block} for {client}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) let endorsement_no_slots_found = @@ -720,7 +720,7 @@ module Endorsement = struct ~level:Debug ~name:"endorsement_no_slots_found" ~msg:"no slot found for {block}/{client}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) let endorsement_slots_found = @@ -738,7 +738,7 @@ module Endorsement = struct (pp_print_list ~pp_sep:(fun f () -> pp_print_string f "; ") Format.pp_print_int)) - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("client", Data_encoding.string) ("slots", Data_encoding.list Data_encoding.int31) @@ -756,7 +756,7 @@ module Endorsement = struct ~level:Info ~name:"endorsement_stale_block" ~msg:"ignore block {block}: forged too far the past" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let endorsement_got_block = declare_1 @@ -764,7 +764,7 @@ module Endorsement = struct ~level:Info ~name:"endorsement_got_block" ~msg:"received new block {block}" - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let wait_before_injecting = declare_2 diff --git a/src/proto_013_PtJakart/lib_injector/common.ml b/src/proto_013_PtJakart/lib_injector/common.ml index 1fd54ccb49e3..3612ecfafb28 100644 --- a/src/proto_013_PtJakart/lib_injector/common.ml +++ b/src/proto_013_PtJakart/lib_injector/common.ml @@ -27,8 +27,8 @@ open Protocol_client_context type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -68,7 +68,7 @@ let tezos_reorg fetch_tezos_block ~old_head_hash ~new_head_hash = let open Alpha_block_services in let open Lwt_result_syntax in let rec loop old_chain new_chain old_head_hash new_head_hash = - if Block_hash.(old_head_hash = new_head_hash) then + if Tezos_crypto.Block_hash.(old_head_hash = new_head_hash) then return {old_chain = List.rev old_chain; new_chain = List.rev new_chain} else let* new_head = fetch_tezos_block new_head_hash in diff --git a/src/proto_013_PtJakart/lib_injector/common.mli b/src/proto_013_PtJakart/lib_injector/common.mli index a1f4a55e2c7d..bff16a3f72e1 100644 --- a/src/proto_013_PtJakart/lib_injector/common.mli +++ b/src/proto_013_PtJakart/lib_injector/common.mli @@ -28,8 +28,8 @@ open Protocol_client_context (** The type of signers for operations injected by the injector *) type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -44,7 +44,9 @@ type 'block reorg = { (** Retrieve a signer from the client wallet. *) val get_signer : - #Client_context.wallet -> Signature.public_key_hash -> signer tzresult Lwt.t + #Client_context.wallet -> + Tezos_crypto.Signature.public_key_hash -> + signer tzresult Lwt.t val no_reorg : 'a reorg @@ -57,18 +59,18 @@ type block_info := Alpha_block_services.block_info it from the L1 node otherwise. *) val fetch_tezos_block : find_in_cache: - (Block_hash.t -> - (Block_hash.t -> block_info tzresult Lwt.t) -> + (Tezos_crypto.Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> block_info tzresult Lwt.t) -> #full -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t (** [tezos_reorg fetch ~old_head_hash ~new_head_hash] computes the reorganization of L1 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) val tezos_reorg : - (Block_hash.t -> block_info tzresult Lwt.t) -> - old_head_hash:Block_hash.t -> - new_head_hash:Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> + old_head_hash:Tezos_crypto.Block_hash.t -> + new_head_hash:Tezos_crypto.Block_hash.t -> block_info reorg tzresult Lwt.t diff --git a/src/proto_013_PtJakart/lib_injector/disk_persistence.ml b/src/proto_013_PtJakart/lib_injector/disk_persistence.ml index 20565456cb64..f82914fa5d9d 100644 --- a/src/proto_013_PtJakart/lib_injector/disk_persistence.ml +++ b/src/proto_013_PtJakart/lib_injector/disk_persistence.ml @@ -276,7 +276,7 @@ end module Make_queue (N : sig val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_013_PtJakart/lib_injector/disk_persistence.mli b/src/proto_013_PtJakart/lib_injector/disk_persistence.mli index 7412450d251c..6e37f06fe507 100644 --- a/src/proto_013_PtJakart/lib_injector/disk_persistence.mli +++ b/src/proto_013_PtJakart/lib_injector/disk_persistence.mli @@ -106,7 +106,7 @@ module Make_queue (N : sig to store the persistent information for this queue. *) val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_013_PtJakart/lib_injector/dune b/src/proto_013_PtJakart/lib_injector/dune index 1cd0774f9678..c8b4ce5d483a 100644 --- a/src/proto_013_PtJakart/lib_injector/dune +++ b/src/proto_013_PtJakart/lib_injector/dune @@ -25,7 +25,6 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_crypto -open Tezos_protocol_013_PtJakart -open Tezos_micheline -open Tezos_client_013_PtJakart diff --git a/src/proto_013_PtJakart/lib_injector/injector_errors.ml b/src/proto_013_PtJakart/lib_injector/injector_errors.ml index f263920da56a..e638807b5154 100644 --- a/src/proto_013_PtJakart/lib_injector/injector_errors.ml +++ b/src/proto_013_PtJakart/lib_injector/injector_errors.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t let () = register_error_kind @@ -35,10 +35,11 @@ let () = Format.fprintf ppf "No worker for source %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp s) `Permanent - Data_encoding.(obj1 (req "source" Signature.Public_key_hash.encoding)) + Data_encoding.( + obj1 (req "source" Tezos_crypto.Signature.Public_key_hash.encoding)) (function No_worker_for_source s -> Some s | _ -> None) (fun s -> No_worker_for_source s) diff --git a/src/proto_013_PtJakart/lib_injector/injector_errors.mli b/src/proto_013_PtJakart/lib_injector/injector_errors.mli index 4745709f70d0..ac6a07279657 100644 --- a/src/proto_013_PtJakart/lib_injector/injector_errors.mli +++ b/src/proto_013_PtJakart/lib_injector/injector_errors.mli @@ -25,7 +25,7 @@ (** Error when the injector has no worker for the source which must inject an operation. *) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t (** Error when the injector has no worker for the tag of the operation to be injected. *) diff --git a/src/proto_013_PtJakart/lib_injector/injector_events.ml b/src/proto_013_PtJakart/lib_injector/injector_events.ml index 71c8c70cada1..7fbfdd1fd99b 100644 --- a/src/proto_013_PtJakart/lib_injector/injector_events.ml +++ b/src/proto_013_PtJakart/lib_injector/injector_events.ml @@ -37,10 +37,10 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 @@ -50,11 +50,11 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -65,12 +65,12 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 enc3 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -113,7 +113,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"new_tezos_head" ~msg:"processing new Tezos head {head}" ~level:Debug - ("head", Block_hash.encoding) + ("head", Tezos_crypto.Block_hash.encoding) let injecting_pending = declare_1 @@ -168,7 +168,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"injected" ~msg:"Injected in {oph}" ~level:Notice - ("oph", Operation_hash.encoding) + ("oph", Tezos_crypto.Operation_hash.encoding) let add_pending = declare_1 @@ -183,7 +183,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"included" ~msg:"Included operations of {block} at level {level}: {operations}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("operations", Data_encoding.list L1_operation.Hash.encoding) ~pp3:pp_operations_hash_list diff --git a/src/proto_013_PtJakart/lib_injector/injector_functor.ml b/src/proto_013_PtJakart/lib_injector/injector_functor.ml index a05ba45c26aa..e5244531d41c 100644 --- a/src/proto_013_PtJakart/lib_injector/injector_functor.ml +++ b/src/proto_013_PtJakart/lib_injector/injector_functor.ml @@ -73,7 +73,7 @@ module Make (Rollup : PARAMETERS) = struct node. *) type injected_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) } @@ -93,20 +93,20 @@ module Make (Rollup : PARAMETERS) = struct let open Data_encoding in conv (fun {op; oph} -> (oph, op)) (fun (oph, op) -> {op; oph}) @@ merge_objs - (obj1 (req "oph" Operation_hash.encoding)) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) L1_operation.encoding end) module Injected_ophs = Disk_persistence.Make_table (struct - include Operation_hash.Table + include Tezos_crypto.Operation_hash.Table type value = L1_operation.Hash.t list let name = "injected_ophs" - let string_of_key = Operation_hash.to_b58check + let string_of_key = Tezos_crypto.Operation_hash.to_b58check - let key_of_string = Operation_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Operation_hash.of_b58check_opt let value_encoding = Data_encoding.list L1_operation.Hash.encoding end) @@ -126,10 +126,10 @@ module Make (Rollup : PARAMETERS) = struct block. *) type included_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) - l1_block : Block_hash.t; + l1_block : Tezos_crypto.Block_hash.t; (** The hash of the L1 block in which the operation was included. *) l1_level : int32; (** The level of [l1_block]. *) } @@ -153,21 +153,21 @@ module Make (Rollup : PARAMETERS) = struct @@ merge_objs L1_operation.encoding (obj3 - (req "oph" Operation_hash.encoding) - (req "l1_block" Block_hash.encoding) + (req "oph" Tezos_crypto.Operation_hash.encoding) + (req "l1_block" Tezos_crypto.Block_hash.encoding) (req "l1_level" int32)) end) module Included_in_blocks = Disk_persistence.Make_table (struct - include Block_hash.Table + include Tezos_crypto.Block_hash.Table type value = int32 * L1_operation.Hash.t list let name = "included_in_blocks" - let string_of_key = Block_hash.to_b58check + let string_of_key = Tezos_crypto.Block_hash.to_b58check - let key_of_string = Block_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Block_hash.of_b58check_opt let value_encoding = let open Data_encoding in @@ -509,7 +509,7 @@ module Make (Rollup : PARAMETERS) = struct let* signature = Client_keys.sign state.cctxt - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation state.signer.sk unsigned_op_bytes in @@ -621,11 +621,13 @@ module Make (Rollup : PARAMETERS) = struct in let signature = match state.signer.pkh with - | Signature.Ed25519 _ -> Signature.of_ed25519 Ed25519.zero - | Secp256k1 _ -> Signature.of_secp256k1 Secp256k1.zero - | P256 _ -> Signature.of_p256 P256.zero + | Tezos_crypto.Signature.Ed25519 _ -> + Tezos_crypto.Signature.of_ed25519 Tezos_crypto.Ed25519.zero + | Secp256k1 _ -> + Tezos_crypto.Signature.of_secp256k1 Tezos_crypto.Secp256k1.zero + | P256 _ -> Tezos_crypto.Signature.of_p256 Tezos_crypto.P256.zero in - let branch = Block_hash.zero in + let branch = Tezos_crypto.Block_hash.zero in let operation = { shell = {branch}; @@ -921,7 +923,9 @@ module Make (Rollup : PARAMETERS) = struct (fun acc (signer, strategy, tags) -> let tags = Tags.of_list tags in let strategy, tags = - match Signature.Public_key_hash.Map.find_opt signer acc with + match + Tezos_crypto.Signature.Public_key_hash.Map.find_opt signer acc + with | None -> (strategy, tags) | Some (other_strategy, other_tags) -> let strategy = @@ -935,11 +939,14 @@ module Make (Rollup : PARAMETERS) = struct in (strategy, Tags.union other_tags tags) in - Signature.Public_key_hash.Map.add signer (strategy, tags) acc) - Signature.Public_key_hash.Map.empty + Tezos_crypto.Signature.Public_key_hash.Map.add + signer + (strategy, tags) + acc) + Tezos_crypto.Signature.Public_key_hash.Map.empty signers in - Signature.Public_key_hash.Map.iter_es + Tezos_crypto.Signature.Public_key_hash.Map.iter_es (fun signer (strategy, tags) -> let+ worker = Worker.launch diff --git a/src/proto_013_PtJakart/lib_injector/injector_worker_types.ml b/src/proto_013_PtJakart/lib_injector/injector_worker_types.ml index 7c6acb7480ca..2f0afaeb7f17 100644 --- a/src/proto_013_PtJakart/lib_injector/injector_worker_types.ml +++ b/src/proto_013_PtJakart/lib_injector/injector_worker_types.ml @@ -84,7 +84,7 @@ module Request = struct Format.fprintf ppf "switching to new Tezos head %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp b.Alpha_block_services.hash ; if r.old_chain <> [] || r.new_chain <> [] then Format.fprintf @@ -98,11 +98,11 @@ end module Name = struct type t = public_key_hash - let encoding = Signature.Public_key_hash.encoding + let encoding = Tezos_crypto.Signature.Public_key_hash.encoding let base = ["tx_rollup_injector"] - let pp = Signature.Public_key_hash.pp_short + let pp = Tezos_crypto.Signature.Public_key_hash.pp_short - let equal = Signature.Public_key_hash.equal + let equal = Tezos_crypto.Signature.Public_key_hash.equal end diff --git a/src/proto_013_PtJakart/lib_injector/l1_operation.ml b/src/proto_013_PtJakart/lib_injector/l1_operation.ml index 1b765034554b..d3de083f1525 100644 --- a/src/proto_013_PtJakart/lib_injector/l1_operation.ml +++ b/src/proto_013_PtJakart/lib_injector/l1_operation.ml @@ -132,7 +132,7 @@ module Manager_operation = struct ty pp_lazy_expr contents - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer in Format.fprintf @@ -146,8 +146,8 @@ module Manager_operation = struct end module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "manager_operation_hash" @@ -158,7 +158,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 type hash = Hash.t diff --git a/src/proto_013_PtJakart/lib_injector/l1_operation.mli b/src/proto_013_PtJakart/lib_injector/l1_operation.mli index 73f1886ed737..21b13fbf32ff 100644 --- a/src/proto_013_PtJakart/lib_injector/l1_operation.mli +++ b/src/proto_013_PtJakart/lib_injector/l1_operation.mli @@ -26,7 +26,7 @@ open Protocol.Alpha_context (** Hash with b58check encoding mop(53), for hashes of L1 manager operations *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for L1 operations hashes *) type hash = Hash.t diff --git a/src/proto_013_PtJakart/lib_parameters/default_parameters.ml b/src/proto_013_PtJakart/lib_parameters/default_parameters.ml index 715a10d04904..8698a322b85a 100644 --- a/src/proto_013_PtJakart/lib_parameters/default_parameters.ml +++ b/src/proto_013_PtJakart/lib_parameters/default_parameters.ml @@ -262,8 +262,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_013_PtJakart/lib_parameters/default_parameters.mli b/src/proto_013_PtJakart/lib_parameters/default_parameters.mli index 3551ac5d3117..3bc1b8edff70 100644 --- a/src/proto_013_PtJakart/lib_parameters/default_parameters.mli +++ b/src/proto_013_PtJakart/lib_parameters/default_parameters.mli @@ -35,7 +35,9 @@ val constants_test : Constants.parametric val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Signature.public_key_hash * Signature.public_key * Tez.t -> + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tez.t -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_013_PtJakart/lib_plugin/plugin.ml b/src/proto_013_PtJakart/lib_plugin/plugin.ml index 9ab6e3b81a38..3cc674bbcd37 100644 --- a/src/proto_013_PtJakart/lib_plugin/plugin.ml +++ b/src/proto_013_PtJakart/lib_plugin/plugin.ml @@ -219,13 +219,16 @@ module Mempool = struct (modulo replace_by_fee_factor) *) type manager_op_info = { - operation_hash : Operation_hash.t; + operation_hash : Tezos_crypto.Operation_hash.t; gas_limit : Gas.Arith.fp; fee : Tez.t; weight : Q.t; } - type manager_op_weight = {operation_hash : Operation_hash.t; weight : Q.t} + type manager_op_weight = { + operation_hash : Tezos_crypto.Operation_hash.t; + weight : Q.t; + } let op_weight_of_info (info : manager_op_info) : manager_op_weight = {operation_hash = info.operation_hash; weight = info.weight} @@ -237,27 +240,31 @@ module Mempool = struct let compare op1 op2 = let c = Q.compare op1.weight op2.weight in if c <> 0 then c - else Operation_hash.compare op1.operation_hash op2.operation_hash + else + Tezos_crypto.Operation_hash.compare + op1.operation_hash + op2.operation_hash end) type state = { grandparent_level_start : Alpha_context.Timestamp.t option; round_zero_duration : Period.t option; - op_prechecked_managers : manager_op_info Signature.Public_key_hash.Map.t; + op_prechecked_managers : + manager_op_info Tezos_crypto.Signature.Public_key_hash.Map.t; (** All managers that are the source of manager operations prechecked in the mempool. Each manager in the map is associated to a record of type [manager_op_info] (See for record details above). Each manager in the map should be accessible with an operation hash in [operation_hash_to_manager]. *) operation_hash_to_manager : - Signature.Public_key_hash.t Operation_hash.Map.t; + Tezos_crypto.Signature.Public_key_hash.t Tezos_crypto.Operation_hash.Map.t; (** Map of operation hash to manager used to remove a manager from [op_prechecked_managers] with an operation hash. Each manager in the map should also be in [op_prechecked_managers]. *) prechecked_operations_count : int; (** Number of prechecked manager operations. Invariants: - - [Operation_hash.Map.cardinal operation_hash_to_manager = + - [Tezos_crypto.Operation_hash.Map.cardinal operation_hash_to_manager = prechecked_operations_count] - [prechecked_operations_count <= max_prechecked_manager_operations] *) ops_prechecked : ManagerOpWeightSet.t; @@ -272,8 +279,8 @@ module Mempool = struct { grandparent_level_start = None; round_zero_duration = None; - op_prechecked_managers = Signature.Public_key_hash.Map.empty; - operation_hash_to_manager = Operation_hash.Map.empty; + op_prechecked_managers = Tezos_crypto.Signature.Public_key_hash.Map.empty; + operation_hash_to_manager = Tezos_crypto.Operation_hash.Map.empty; prechecked_operations_count = 0; ops_prechecked = ManagerOpWeightSet.empty; min_prechecked_op_weight = None; @@ -332,7 +339,7 @@ module Mempool = struct let remove ~(filter_state : state) oph = let removed_oph_source = ref None in let operation_hash_to_manager = - Operation_hash.Map.update + Tezos_crypto.Operation_hash.Map.update oph (function | None -> None @@ -352,7 +359,7 @@ module Mempool = struct in let removed_op = ref None in let op_prechecked_managers = - Signature.Public_key_hash.Map.update + Tezos_crypto.Signature.Public_key_hash.Map.update source (function | None -> None @@ -373,7 +380,7 @@ module Mempool = struct match filter_state.min_prechecked_op_weight with | None -> None | Some op -> - if Operation_hash.equal op.operation_hash oph then + if Tezos_crypto.Operation_hash.equal op.operation_hash oph then ManagerOpWeightSet.min_elt ops_prechecked else Some op in @@ -417,7 +424,7 @@ module Mempool = struct (fun () -> Fees_too_low) type Environment.Error_monad.error += - | Manager_restriction of {oph : Operation_hash.t; fee : Tez.t} + | Manager_restriction of {oph : Tezos_crypto.Operation_hash.t; fee : Tez.t} let () = Environment.Error_monad.register_error_kind @@ -431,21 +438,21 @@ module Mempool = struct "Only one manager operation per manager per block allowed (found %a \ with %atez fee. You may want to use --replace to provide adequate \ fee and replace it)." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Tez.pp fee) Data_encoding.( obj2 - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation_fee" Tez.encoding)) (function Manager_restriction {oph; fee} -> Some (oph, fee) | _ -> None) (fun (oph, fee) -> Manager_restriction {oph; fee}) type Environment.Error_monad.error += | Manager_operation_replaced of { - old_hash : Operation_hash.t; - new_hash : Operation_hash.t; + old_hash : Tezos_crypto.Operation_hash.t; + new_hash : Tezos_crypto.Operation_hash.t; } let () = @@ -458,13 +465,13 @@ module Mempool = struct Format.fprintf ppf "The manager operation %a has been replaced with %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_hash - Operation_hash.pp + Tezos_crypto.Operation_hash.pp new_hash) (Data_encoding.obj2 - (Data_encoding.req "old_hash" Operation_hash.encoding) - (Data_encoding.req "new_hash" Operation_hash.encoding)) + (Data_encoding.req "old_hash" Tezos_crypto.Operation_hash.encoding) + (Data_encoding.req "new_hash" Tezos_crypto.Operation_hash.encoding)) (function | Manager_operation_replaced {old_hash; new_hash} -> Some (old_hash, new_hash) @@ -539,7 +546,7 @@ module Mempool = struct let check_manager_restriction config filter_state source ~fee ~gas_limit = match - Signature.Public_key_hash.Map.find + Tezos_crypto.Signature.Public_key_hash.Map.find source filter_state.op_prechecked_managers with @@ -1022,7 +1029,7 @@ module Mempool = struct config -> state -> validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Tezos_base.Operation.shell_header -> t Kind.manager protocol_data -> nb_successful_prechecks:int -> @@ -1030,7 +1037,8 @@ module Mempool = struct gas_limit:Gas.Arith.fp -> public_key_hash -> [> `Prechecked_manager of - [`No_replace | `Replace of Operation_hash.t * error_classification] + [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification ] Lwt.t = fun config @@ -1117,8 +1125,11 @@ module Mempool = struct | `Replace (oph, _class) -> remove ~filter_state oph in let prechecked_operations_count = - if Operation_hash.Map.mem oph filter_state.operation_hash_to_manager then - filter_state.prechecked_operations_count + if + Tezos_crypto.Operation_hash.Map.mem + oph + filter_state.operation_hash_to_manager + then filter_state.prechecked_operations_count else filter_state.prechecked_operations_count + 1 in let op_weight = op_weight_of_info info in @@ -1131,12 +1142,15 @@ module Mempool = struct filter_state with op_prechecked_managers = (* Manager not seen yet, record it for next ops *) - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add source info filter_state.op_prechecked_managers; operation_hash_to_manager = - Operation_hash.Map.add oph source filter_state.operation_hash_to_manager + Tezos_crypto.Operation_hash.Map.add + oph + source + filter_state.operation_hash_to_manager (* Record which manager is used for the operation hash. *); ops_prechecked = ManagerOpWeightSet.add op_weight filter_state.ops_prechecked; @@ -1148,13 +1162,14 @@ module Mempool = struct config -> filter_state:state -> validation_state:validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Main.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification | `Undecided ] Lwt.t = @@ -1695,7 +1710,7 @@ module RPC = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (opt "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "self" Contract.encoding) @@ -1744,7 +1759,7 @@ module RPC = struct (req "contract" Contract.encoding) (req "entrypoint" Entrypoint.simple_encoding) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -1760,7 +1775,7 @@ module RPC = struct (req "view" string) (req "input" Script.expr_encoding) (dft "unlimited_gas" bool false) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -1908,7 +1923,7 @@ module RPC = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding Tezos_rpc.Path.(path / "run_operation") @@ -1941,7 +1956,7 @@ module RPC = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding Tezos_rpc.Path.(path / "simulate_operation") @@ -1954,7 +1969,7 @@ module RPC = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding Tezos_rpc.Path.(path / "simulate_tx_rollup_operation") @@ -2221,7 +2236,7 @@ module RPC = struct let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Origination_nonce.init ctxt hash in - let payload_producer = Signature.Public_key_hash.zero in + let payload_producer = Tezos_crypto.Signature.Public_key_hash.zero in match protocol_data.contents with | Single (Manager_operation _) as op -> Apply.precheck_manager_contents_list ctxt op ~mempool_mode:true @@ -2310,7 +2325,9 @@ module RPC = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = + Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero + in Lwt.return (Contract.fresh_contract_from_current_nonce ctxt) >>=? fun (ctxt, dummy_contract) -> Contract.raw_originate @@ -3761,7 +3778,7 @@ module RPC = struct module Baking_rights = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; round : int; timestamp : Timestamp.t option; } @@ -3775,7 +3792,7 @@ module RPC = struct {level; delegate; round; timestamp}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "round" uint16) (opt "estimated_time" Timestamp.encoding)) @@ -3789,7 +3806,7 @@ module RPC = struct type baking_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; max_round : int option; all : bool; } @@ -3844,7 +3861,7 @@ module RPC = struct if Compare.Int.(round > max_round) then return (List.rev acc) else let (Misc.LCons (pk, next)) = l in - let delegate = Signature.Public_key.hash pk in + let delegate = Tezos_crypto.Signature.Public_key.hash pk in estimated_time round_durations ~current_level @@ -3863,13 +3880,16 @@ module RPC = struct @@ List.fold_left (fun (acc, previous) r -> if - Signature.Public_key_hash.Set.exists - (Signature.Public_key_hash.equal r.delegate) + Tezos_crypto.Signature.Public_key_hash.Set.exists + (Tezos_crypto.Signature.Public_key_hash.equal r.delegate) previous then (acc, previous) else - (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) - ([], Signature.Public_key_hash.Set.empty) + ( r :: acc, + Tezos_crypto.Signature.Public_key_hash.Set.add + r.delegate + previous )) + ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) rights let register () = @@ -3903,7 +3923,7 @@ module RPC = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights) @@ -3920,7 +3940,7 @@ module RPC = struct module Endorsing_rights = struct type delegate_rights = { - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; first_slot : Slot.t; endorsing_power : int; } @@ -3939,7 +3959,7 @@ module RPC = struct (fun (delegate, first_slot, endorsing_power) -> {delegate; first_slot; endorsing_power}) (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "first_slot" Slot.encoding) (req "endorsing_power" uint16)) @@ -3963,7 +3983,7 @@ module RPC = struct type endorsing_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -4041,7 +4061,7 @@ module RPC = struct (fun rights_at_level -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in match @@ -4064,7 +4084,7 @@ module RPC = struct module Validators = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; slots : Slot.t list; } @@ -4075,7 +4095,7 @@ module RPC = struct (fun (level, delegate, slots) -> {level; delegate; slots}) (obj3 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "slots" (list Slot.encoding))) module S = struct @@ -4085,7 +4105,7 @@ module RPC = struct type validators_query = { levels : Raw_level.t list; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let validators_query = @@ -4135,7 +4155,7 @@ module RPC = struct | _ :: _ as delegates -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in List.filter is_requested rights) diff --git a/src/proto_014_PtKathma/bin_tx_rollup_client/commands.ml b/src/proto_014_PtKathma/bin_tx_rollup_client/commands.ml index c09f403032ce..585463b9b0ad 100644 --- a/src/proto_014_PtKathma/bin_tx_rollup_client/commands.ml +++ b/src/proto_014_PtKathma/bin_tx_rollup_client/commands.ml @@ -27,7 +27,7 @@ open Tezos_client_base let l1_destination_parameter = Tezos_clic.parameter (fun _ s -> - match Signature.Public_key_hash.of_b58check_opt s with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt s with | Some addr -> return addr | None -> failwith "cannot parse %s to get a valid destination" s) @@ -66,15 +66,15 @@ let alias_or_literal ~from_alias ~from_key = type wallet_entry = { alias : string; - public_key_hash : Bls.Public_key_hash.t; - public_key : Bls.Public_key.t option; + public_key_hash : Tezos_crypto.Bls.Public_key_hash.t; + public_key : Tezos_crypto.Bls.Public_key.t option; secret_key_uri : Client_keys.aggregate_sk_uri option; } let wallet_parameter () = Tezos_clic.parameter (fun cctxt alias -> let open Lwt_result_syntax in - let open Aggregate_signature in + let open Tezos_crypto.Aggregate_signature in let* (Bls12_381 public_key_hash) = Client_keys.Aggregate_alias.Public_key_hash.find cctxt alias in @@ -106,11 +106,14 @@ let bls_pkh_parameter () = in return pkh in - let from_key s = Bls.Public_key_hash.of_b58check s |> Lwt.return in + let from_key s = + Tezos_crypto.Bls.Public_key_hash.of_b58check s |> Lwt.return + in alias_or_literal ~from_alias ~from_key s) let conv_bls_pkh_to_l2_addr pkh = - Bls.Public_key_hash.to_b58check pkh |> Tx_rollup_l2_address.of_b58check_exn + Tezos_crypto.Bls.Public_key_hash.to_b58check pkh + |> Tx_rollup_l2_address.of_b58check_exn let bls_pkh_param ?(name = "public key hash") ?(desc = "bls public key hash to use") = @@ -142,7 +145,8 @@ let bls_sk_uri_param ?(name = "secret key") ?(desc = "Bls secret key to use.") = Tezos_clic.param ~name ~desc (bls_sk_uri_parameter ()) let signature_parameter () = - Tezos_clic.parameter (fun _cctxt s -> Bls.of_b58check s |> Lwt.return) + Tezos_clic.parameter (fun _cctxt s -> + Tezos_crypto.Bls.of_b58check s |> Lwt.return) let signature_arg = Tezos_clic.arg @@ -338,7 +342,7 @@ let craft_withdraw ~counter ~signer ~destination ~ticket_hash ~qty = let aggregate_signature signatures = let open Result_syntax in - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> return res | None -> error_with "aggregate_signature" @@ -439,7 +443,7 @@ let signer_parameter = match Tx_rollup_l2_address.of_b58check_opt s with | Some pkh -> return @@ Tx_rollup_l2_batch.L2_addr pkh | None -> ( - match Bls.Public_key.of_b58check_opt s with + match Tezos_crypto.Bls.Public_key.of_b58check_opt s with | Some pk -> return @@ Tx_rollup_l2_batch.Bls_pk pk | None -> failwith "cannot parse %s to get a valid signer" s)) @@ -820,7 +824,9 @@ let sign_transaction () = in let*? aggregated_signature = aggregate_signature signatures in - let*! () = cctxt#message "@[%a@]" Bls.pp aggregated_signature in + let*! () = + cctxt#message "@[%a@]" Tezos_crypto.Bls.pp aggregated_signature + in return_unit else let*! () = @@ -828,7 +834,7 @@ let sign_transaction () = "@[%a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.pp_print_string ppf ";") - Bls.pp) + Tezos_crypto.Bls.pp) signatures in return_unit) diff --git a/src/proto_014_PtKathma/lib_benchmark/dune b/src/proto_014_PtKathma/lib_benchmark/dune index b6276578efbb..22ade3926b5f 100644 --- a/src/proto_014_PtKathma/lib_benchmark/dune +++ b/src/proto_014_PtKathma/lib_benchmark/dune @@ -30,6 +30,5 @@ -open Tezos_benchmark -open Tezos_benchmark_type_inference_014_PtKathma -open Tezos_protocol_014_PtKathma - -open Tezos_crypto -open Tezos_014_PtKathma_test_helpers) (private_modules kernel rules state_space)) diff --git a/src/proto_014_PtKathma/lib_benchmark/execution_context.ml b/src/proto_014_PtKathma/lib_benchmark/execution_context.ml index 86fbdd7278e7..e9b511c6e38a 100644 --- a/src/proto_014_PtKathma/lib_benchmark/execution_context.ml +++ b/src/proto_014_PtKathma/lib_benchmark/execution_context.ml @@ -53,7 +53,7 @@ let context_init ~rng_state = context_init_memory ~rng_state let make ~rng_state = context_init_memory ~rng_state >>=? fun context -> let amount = Alpha_context.Tez.one in - let chain_id = Chain_id.zero in + let chain_id = Tezos_crypto.Chain_id.zero in let now = Script_timestamp.of_zint Z.zero in let level = Script_int.zero_n in let open Script_interpreter in @@ -88,6 +88,8 @@ let make ~rng_state = let ctxt = Incremental.alpha_ctxt vs in let ctxt = (* Required for eg Create_contract *) - Protocol.Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Protocol.Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in return (ctxt, step_constants) diff --git a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers.ml b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers.ml index e78124e1a27d..fbe05e675e52 100644 --- a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers.ml +++ b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers.ml @@ -520,7 +520,9 @@ end) let seed = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255) in - let _pkh, public_key, _secret_key = Bls.generate_key ~seed () in + let _pkh, public_key, _secret_key = + Tezos_crypto.Bls.generate_key ~seed () + in Tx_rollup_l2_address.Indexable.value (Tx_rollup_l2_address.of_bls_pk public_key) diff --git a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.ml b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.ml index 92ffe284fcee..3f8f301fd1ab 100644 --- a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.ml +++ b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.ml @@ -53,7 +53,7 @@ module type S = sig val nat : Script_int.n Script_int.num sampler - val signature : Signature.t sampler + val signature : Tezos_crypto.Signature.t sampler val string : Script_string.t sampler @@ -81,25 +81,25 @@ end) : S = struct let i = Random.State.int rng_state 4 in match i with | 0 -> ( - let open Ed25519 in + let open Tezos_crypto.Ed25519 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_ed25519 s) + | Some s -> Tezos_crypto.Signature.of_ed25519 s) | 1 -> ( - let open Secp256k1 in + let open Tezos_crypto.Secp256k1 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_secp256k1 s) + | Some s -> Tezos_crypto.Signature.of_secp256k1 s) | 2 -> ( - let open P256 in + let open Tezos_crypto.P256 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_p256 s) + | Some s -> Tezos_crypto.Signature.of_p256 s) | _ -> ( - let open Signature in + let open Tezos_crypto.Signature in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with None -> assert false | Some s -> s) diff --git a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.mli b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.mli index 339ad824e4cc..18a150245cfc 100644 --- a/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.mli +++ b/src/proto_014_PtKathma/lib_benchmark/michelson_samplers_base.mli @@ -47,7 +47,7 @@ module type S = sig val nat : Script_int.n Script_int.num sampler - val signature : Signature.t sampler + val signature : Tezos_crypto.Signature.t sampler val string : Script_string.t sampler diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/dune b/src/proto_014_PtKathma/lib_benchmarks_proto/dune index bfc2a5d4013d..cfdaf729a421 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/dune +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/dune @@ -37,7 +37,6 @@ -open Tezos_benchmark_type_inference_014_PtKathma -open Tezos_protocol_014_PtKathma -open Tezos_protocol_014_PtKathma.Protocol - -open Tezos_crypto -open Tezos_micheline -open Tezos_014_PtKathma_test_helpers -open Tezos_client_014_PtKathma diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_014_PtKathma/lib_benchmarks_proto/encodings_benchmarks.ml index aca7cd266205..f23c15aa19d3 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/encodings_benchmarks.ml @@ -423,7 +423,7 @@ module Timelock = struct Base_samplers.sample_in_interval ~range:{min = 1; max = 10000} rng_state in let chest, chest_key = - Timelock.chest_sampler ~plaintext_size ~time ~rng_state + Tezos_crypto.Timelock.chest_sampler ~plaintext_size ~time ~rng_state in ((chest, chest_key), plaintext_size) @@ -431,7 +431,9 @@ module Timelock = struct Registration_helpers.register @@ make_encode_variable_size_to_string ~name:"ENCODING_Chest" - ~to_string:(Data_encoding.Binary.to_string_exn Timelock.chest_encoding) + ~to_string: + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), plaintext_size = generator rng_state in (chest, {bytes = plaintext_size})) @@ -442,7 +444,8 @@ module Timelock = struct @@ make_encode_fixed_size_to_string ~name:"ENCODING_Chest_key" ~to_string: - (Data_encoding.Binary.to_string_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) @@ -452,12 +455,18 @@ module Timelock = struct Registration_helpers.register @@ make_decode_variable_size_from_bytes ~name:"DECODING_Chest" - ~to_bytes:(Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding) - ~from_bytes:(Data_encoding.Binary.of_bytes_exn Timelock.chest_encoding) + ~to_bytes: + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding) + ~from_bytes: + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), _ = generator rng_state in let b = - Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest in (chest, {bytes = Bytes.length b})) () @@ -467,9 +476,11 @@ module Timelock = struct @@ make_decode_fixed_size_from_bytes ~name:"DECODING_Chest_key" ~to_bytes: - (Data_encoding.Binary.to_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~from_bytes: - (Data_encoding.Binary.of_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_benchmarks.ml index 7e0a37472046..8eae1aac90f6 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -module Timelock_samplers = Timelock +module Timelock_samplers = Tezos_crypto.Timelock open Protocol (* ------------------------------------------------------------------------- *) @@ -2255,13 +2255,15 @@ module Registration_section = struct ~kinstr:(ILevel (dummy_loc, halt)) () - let check_signature (algo : Signature.algo) ~for_intercept = + let check_signature (algo : Tezos_crypto.Signature.algo) ~for_intercept = let name = match algo with - | Signature.Ed25519 -> Interpreter_workload.N_ICheck_signature_ed25519 - | Signature.Secp256k1 -> + | Tezos_crypto.Signature.Ed25519 -> + Interpreter_workload.N_ICheck_signature_ed25519 + | Tezos_crypto.Signature.Secp256k1 -> Interpreter_workload.N_ICheck_signature_secp256k1 - | Signature.P256 -> Interpreter_workload.N_ICheck_signature_p256 + | Tezos_crypto.Signature.P256 -> + Interpreter_workload.N_ICheck_signature_p256 in benchmark_with_stack_sampler ~intercept:for_intercept @@ -2278,7 +2280,9 @@ module Registration_section = struct if for_intercept then Environment.Bytes.empty else Samplers.Random_value.value Script_typed_ir.bytes_t rng_state in - let signed_message = Signature.sign sk unsigned_message in + let signed_message = + Tezos_crypto.Signature.sign sk unsigned_message + in let signed_message = Script_signature.make signed_message in (pk, (signed_message, (unsigned_message, eos)))) () @@ -2287,11 +2291,11 @@ module Registration_section = struct check_signature algo ~for_intercept:true ; check_signature algo ~for_intercept:false - let () = check_signature Signature.Ed25519 + let () = check_signature Tezos_crypto.Signature.Ed25519 - let () = check_signature Signature.Secp256k1 + let () = check_signature Tezos_crypto.Signature.Secp256k1 - let () = check_signature Signature.P256 + let () = check_signature Tezos_crypto.Signature.P256 let () = simple_benchmark @@ -2986,7 +2990,9 @@ module Registration_section = struct ~cont_and_stack_sampler:(fun _cfg _rng_state -> let open Script_typed_ir in let open Alpha_context in - let zero = Contract.Implicit Signature.Public_key_hash.zero in + let zero = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero + in let step_constants = { source = zero; @@ -2994,7 +3000,7 @@ module Registration_section = struct self = Contract_hash.zero; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_workload.ml index ad3a114d248f..08e5aefa47a0 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/interpreter_workload.ml @@ -1337,19 +1337,19 @@ let extract_ir_sized_step : | ILevel (_, _), _ -> Instructions.level | ICheck_signature (_, _), (public_key, (_signature, (message, _))) -> ( match public_key with - | Signature.Ed25519 _pk -> - let pk = Size.of_int Ed25519.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Ed25519 _pk -> + let pk = Size.of_int Tezos_crypto.Ed25519.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_ed25519 pk signature message - | Signature.Secp256k1 _pk -> - let pk = Size.of_int Secp256k1.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Secp256k1 _pk -> + let pk = Size.of_int Tezos_crypto.Secp256k1.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_secp256k1 pk signature message - | Signature.P256 _pk -> - let pk = Size.of_int P256.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.P256 _pk -> + let pk = Size.of_int Tezos_crypto.P256.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_p256 pk signature message) | IHash_key (_, _), _ -> Instructions.hash_key diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_014_PtKathma/lib_benchmarks_proto/sc_rollup_benchmarks.ml index 0231b0e1700f..07daebef59d0 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -212,7 +212,9 @@ module Sc_rollup_add_external_messages_benchmark = struct let ctxt = state.ctxt in (* Necessary to originate rollups. *) let ctxt = - Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in Alpha_context.Internal_for_tests.to_raw ctxt in diff --git a/src/proto_014_PtKathma/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_014_PtKathma/lib_benchmarks_proto/ticket_benchmarks.ml index 5d48c10c3dee..71f39d3be7b0 100644 --- a/src/proto_014_PtKathma/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_014_PtKathma/lib_benchmarks_proto/ticket_benchmarks.ml @@ -152,7 +152,7 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let benchmark rng_state _conf () = let bytes = Base_samplers.bytes rng_state ~size:{min = 32; max = 64} in - let branch = Block_hash.hash_bytes [bytes] in + let branch = Tezos_crypto.Block_hash.hash_bytes [bytes] in let op_hash = Operation.hash_raw {shell = {branch}; proto = bytes} in let nonce = Origination_nonce.Internal_for_tests.initial op_hash in let contract = Contract.Internal_for_tests.originated_contract nonce in @@ -255,7 +255,12 @@ let () = Registration_helpers.register (module Has_tickets_type_benchmark) let ticket_sampler rng_state = let seed = Base_samplers.uniform_bytes ~nbytes:32 rng_state in - let pkh, _, _ = Signature.generate_key ~algo:Signature.Ed25519 ~seed () in + let pkh, _, _ = + Tezos_crypto.Signature.generate_key + ~algo:Tezos_crypto.Signature.Ed25519 + ~seed + () + in let ticketer = Alpha_context.Contract.Implicit pkh in Script_typed_ir. {ticketer; contents = Script_int.zero; amount = Script_int.one_n} diff --git a/src/proto_014_PtKathma/lib_client/client_proto_args.ml b/src/proto_014_PtKathma/lib_client/client_proto_args.ml index 914456728b03..e60eac54177c 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_args.ml +++ b/src/proto_014_PtKathma/lib_client/client_proto_args.ml @@ -549,7 +549,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") @@ -668,7 +668,7 @@ module Tx_rollup = struct let context_hash_parameter = Tezos_clic.parameter (fun _ s -> - match Context_hash.of_b58check_opt s with + match Tezos_crypto.Context_hash.of_b58check_opt s with | Some hash -> return hash | None -> failwith diff --git a/src/proto_014_PtKathma/lib_client/client_proto_args.mli b/src/proto_014_PtKathma/lib_client/client_proto_args.mli index 5aa7bbed8a5e..c6c07437ea69 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_args.mli +++ b/src/proto_014_PtKathma/lib_client/client_proto_args.mli @@ -60,7 +60,8 @@ val entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg val default_entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -117,7 +118,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg @@ -182,7 +183,7 @@ module Tx_rollup : sig ?name:string -> usage:string -> ('a, full) Tezos_clic.params -> - (Context_hash.t -> 'a, full) Tezos_clic.params + (Tezos_crypto.Context_hash.t -> 'a, full) Tezos_clic.params val message_result_path_param : ?name:string -> diff --git a/src/proto_014_PtKathma/lib_client/client_proto_context.ml b/src/proto_014_PtKathma/lib_client/client_proto_context.ml index 13aae0d278ed..cc67c1b7e368 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_context.ml +++ b/src/proto_014_PtKathma/lib_client/client_proto_context.ml @@ -300,7 +300,7 @@ let set_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in delegate_contract cctxt ~chain @@ -507,7 +507,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -518,7 +518,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -548,7 +548,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -596,12 +596,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -626,7 +628,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Operation_result.tez_sym Tez.pp @@ -641,13 +643,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -687,7 +689,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -795,7 +797,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_014_PtKathma/lib_client/client_proto_context.mli b/src/proto_014_PtKathma/lib_client/client_proto_context.mli index b6e5835863f7..e8af7739e8fd 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_context.mli +++ b/src/proto_014_PtKathma/lib_client/client_proto_context.mli @@ -60,8 +60,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -105,7 +105,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t val build_delegate_operation : @@ -308,7 +308,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -356,7 +356,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -394,7 +394,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t val submit_ballot : @@ -406,7 +406,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -416,7 +416,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t val cached_contracts : @@ -456,12 +456,12 @@ val originate_tx_rollup : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_origination Kind.manager contents * Kind.tx_rollup_origination Kind.manager Apply_results.contents_result) tzresult @@ -480,14 +480,14 @@ val submit_tx_rollup_batch : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> content:string -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_submit_batch Kind.manager contents * Kind.tx_rollup_submit_batch Kind.manager Apply_results.contents_result) tzresult @@ -505,8 +505,8 @@ val submit_tx_rollup_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -515,7 +515,7 @@ val submit_tx_rollup_commitment : predecessor:Tx_rollup_commitment_hash.t option -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_commit Kind.manager contents * Kind.tx_rollup_commit Kind.manager Apply_results.contents_result) tzresult @@ -533,13 +533,13 @@ val submit_tx_rollup_finalize_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_finalize_commitment Kind.manager contents * Kind.tx_rollup_finalize_commitment Kind.manager Apply_results.contents_result) @@ -558,13 +558,13 @@ val submit_tx_rollup_remove_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_remove_commitment Kind.manager contents * Kind.tx_rollup_remove_commitment Kind.manager Apply_results.contents_result) tzresult @@ -582,8 +582,8 @@ val submit_tx_rollup_rejection : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -593,12 +593,12 @@ val submit_tx_rollup_rejection : message_path:Tx_rollup_inbox.Merkle.path -> message_result_hash:Tx_rollup_message_result_hash.t -> message_result_path:Tx_rollup_commitment.Merkle.path -> - previous_context_hash:Context_hash.t -> + previous_context_hash:Tezos_crypto.Context_hash.t -> previous_withdraw_list_hash:Tx_rollup_withdraw_list_hash.t -> previous_message_result_path:Tx_rollup_commitment.Merkle.path -> proof:Tx_rollup_l2_proof.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_rejection Kind.manager contents * Kind.tx_rollup_rejection Kind.manager Apply_results.contents_result) tzresult @@ -616,13 +616,13 @@ val submit_tx_rollup_return_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_return_bond Kind.manager contents * Kind.tx_rollup_return_bond Kind.manager Apply_results.contents_result) tzresult @@ -640,18 +640,18 @@ val tx_rollup_dispatch_tickets : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> - context_hash:Context_hash.t -> + context_hash:Tezos_crypto.Context_hash.t -> message_position:int -> message_result_path:Tx_rollup_commitment.Merkle.path -> tickets_info:Tx_rollup_reveal.t list -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_dispatch_tickets Kind.manager contents * Kind.tx_rollup_dispatch_tickets Kind.manager Apply_results.contents_result) tzresult @@ -669,8 +669,8 @@ val transfer_ticket : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> contents:string -> @@ -680,7 +680,7 @@ val transfer_ticket : destination:Contract.t -> entrypoint:Entrypoint.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.transfer_ticket Kind.manager contents * Kind.transfer_ticket Kind.manager Apply_results.contents_result) tzresult @@ -706,7 +706,7 @@ val sc_rollup_originate : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_originate Kind.manager contents * Kind.sc_rollup_originate Kind.manager Apply_results.contents_result, tztrace ) @@ -732,7 +732,7 @@ val sc_rollup_add_messages : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_add_messages Kind.manager contents * Kind.sc_rollup_add_messages Kind.manager Apply_results.contents_result) tzresult @@ -757,7 +757,7 @@ val sc_rollup_cement : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_cement Kind.manager contents * Kind.sc_rollup_cement Kind.manager Apply_results.contents_result) tzresult @@ -782,7 +782,7 @@ val sc_rollup_publish : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_publish Kind.manager contents * Kind.sc_rollup_publish Kind.manager Apply_results.contents_result) tzresult @@ -811,7 +811,7 @@ val sc_rollup_execute_outbox_message : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_execute_outbox_message Kind.manager contents * Kind.sc_rollup_execute_outbox_message Kind.manager Apply_results.contents_result, @@ -831,13 +831,13 @@ val sc_rollup_recover_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> sc_rollup:Sc_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_recover_bond Kind.manager contents * Kind.sc_rollup_recover_bond Kind.manager Apply_results.contents_result) tzresult @@ -862,7 +862,7 @@ val sc_rollup_dal_slot_subscribe : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_dal_slot_subscribe Kind.manager contents * Kind.sc_rollup_dal_slot_subscribe Kind.manager Apply_results.contents_result) tzresult diff --git a/src/proto_014_PtKathma/lib_client/client_proto_multisig.ml b/src/proto_014_PtKathma/lib_client/client_proto_multisig.ml index 45faac04e91d..7a671305c788 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_multisig.ml +++ b/src/proto_014_PtKathma/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -581,11 +585,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) @@ -596,10 +601,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) Data_encoding.(tup2 Contract.encoding Entrypoint.value_encoding) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -704,7 +711,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -780,7 +787,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -807,7 +814,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -817,7 +824,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -844,7 +851,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -856,7 +864,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -877,7 +885,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -894,7 +905,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1042,7 +1057,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1168,7 +1183,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_014_PtKathma/lib_client/client_proto_multisig.mli b/src/proto_014_PtKathma/lib_client/client_proto_multisig.mli index bd2f3d746552..5650cc2355ea 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_multisig.mli +++ b/src/proto_014_PtKathma/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -139,7 +139,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_014_PtKathma/lib_client/client_proto_utils.ml b/src/proto_014_PtKathma/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_utils.ml +++ b/src/proto_014_PtKathma/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_014_PtKathma/lib_client/client_proto_utils.mli b/src/proto_014_PtKathma/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_014_PtKathma/lib_client/client_proto_utils.mli +++ b/src/proto_014_PtKathma/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_client/injection.ml b/src/proto_014_PtKathma/lib_client/injection.ml index 3f258effcde8..cd9ee168b503 100644 --- a/src/proto_014_PtKathma/lib_client/injection.ml +++ b/src/proto_014_PtKathma/lib_client/injection.ml @@ -57,12 +57,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee (contents : packed_contents_list) = let l = Operation.to_list contents in @@ -176,18 +179,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -210,7 +218,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -236,7 +244,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let watermark = match contents with (* TODO-TB sign endorsement? *) - | _ -> Signature.Generic_operation + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -251,7 +259,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -771,7 +779,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -1034,12 +1042,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -1050,7 +1058,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (* Adjust user-provided confirmations with respect to Alpha protocol finality properties *) tenderbake_adjust_confirmations cctxt confirmations >>= fun confirmations -> (match confirmations with @@ -1062,10 +1071,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -1126,10 +1135,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op, result.contents) @@ -1192,10 +1201,10 @@ let pending_applied_operations_of_source (cctxt : #full) chain src : (fun acc (_oph, {protocol_data = Operation_data {contents; _}; _}) -> match contents with | Single (Manager_operation {source; _} as _op) - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | Cons (Manager_operation {source; _}, _rest) as _op - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | _ -> acc) [] @@ -1318,14 +1327,14 @@ let replace_operation (type kind) (cctxt : #full) chain source cctxt#error "Cannot replace! No applied manager operation found for %a in \ mempool@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source >>= fun () -> exit 1 | _ :: _ :: _ as l -> cctxt#error "More than one applied manager operation found for %a in mempool. \ Found %d operations. Are you sure the node is in precheck mode?@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source (List.length l) >>= fun () -> exit 1 @@ -1350,7 +1359,7 @@ let inject_manager_operation cctxt ~chain ~block ?successor_level ?branch ~src_sk ~fee ~gas_limit ~storage_limit ?counter ?(replace_by_fees = false) ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * kind Kind.manager contents_list * kind Kind.manager contents_result_list) diff --git a/src/proto_014_PtKathma/lib_client/injection.mli b/src/proto_014_PtKathma/lib_client/injection.mli index 6275db8033e1..e510735766bb 100644 --- a/src/proto_014_PtKathma/lib_client/injection.mli +++ b/src/proto_014_PtKathma/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -63,7 +63,9 @@ val simulate : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -83,7 +85,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -103,8 +106,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> @@ -113,7 +116,7 @@ val inject_manager_operation : ?replace_by_fees:bool -> fee_parameter:fee_parameter -> 'kind Annotated_manager_operation.annotated_list -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * 'kind Kind.manager contents_list * 'kind Kind.manager contents_result_list) diff --git a/src/proto_014_PtKathma/lib_client/managed_contract.ml b/src/proto_014_PtKathma/lib_client/managed_contract.ml index 6527ad4d7add..d413248efc90 100644 --- a/src/proto_014_PtKathma/lib_client/managed_contract.ml +++ b/src/proto_014_PtKathma/lib_client/managed_contract.ml @@ -49,7 +49,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -60,7 +60,9 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported \ for \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match + Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value + with | Some k -> return k | None -> cctxt#error @@ -87,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -102,7 +106,7 @@ let entrypoint_remove_delegate = Entrypoint.remove_delegate let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = entrypoint_do in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -137,7 +141,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -158,7 +162,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -188,7 +192,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_014_PtKathma/lib_client/mockup.ml b/src/proto_014_PtKathma/lib_client/mockup.ml index 0225f8cccc7b..7cb74c31fe5a 100644 --- a/src/proto_014_PtKathma/lib_client/mockup.ml +++ b/src/proto_014_PtKathma/lib_client/mockup.ml @@ -100,7 +100,7 @@ module Protocol_constants_overrides = struct frozen_deposits_percentage : int option; double_baking_punishment : Tez.t option; ratio_of_frozen_deposits_slashed_per_double_endorsement : Ratio.t option; - testnet_dictator : Signature.Public_key_hash.t option option; + testnet_dictator : Tezos_crypto.Signature.Public_key_hash.t option option; cache_script_size : int option; cache_stake_distribution_cycles : int option; cache_sampler_state_cycles : int option; @@ -108,7 +108,7 @@ module Protocol_constants_overrides = struct dal : Constants.Parametric.dal option; sc_rollup : sc_rollup; (* Additional, "bastard" parameters (they are not protocol constants but partially treated the same way). *) - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; initial_seed : State_hash.t option option; } @@ -409,8 +409,8 @@ module Protocol_constants_overrides = struct Ratio.encoding) (opt "testnet_dictator" - (option Signature.Public_key_hash.encoding)) - (opt "chain_id" Chain_id.encoding) + (option Tezos_crypto.Signature.Public_key_hash.encoding)) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding) (opt "initial_seed" (option State_hash.encoding))) (merge_objs @@ -858,7 +858,12 @@ module Protocol_constants_overrides = struct override_value = o.sc_rollup.challenge_window_in_blocks; pp = pp_print_int; }; - O {name = "chain_id"; override_value = o.chain_id; pp = Chain_id.pp}; + O + { + name = "chain_id"; + override_value = o.chain_id; + pp = Tezos_crypto.Chain_id.pp; + }; O { name = "timestamp"; @@ -1179,7 +1184,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. { @@ -1244,8 +1249,10 @@ module Bootstrap_account = struct ~title:"No delegate" (Tag 0) (obj3 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req + "public_key_hash" + Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding)) (function | {public_key_hash; public_key; amount; delegate_to = None} -> @@ -1257,10 +1264,12 @@ module Bootstrap_account = struct ~title:"With delegate" (Tag 1) (obj4 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req + "public_key_hash" + Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding) - (req "delegate_to" Signature.Public_key_hash.encoding)) + (req "delegate_to" Tezos_crypto.Signature.Public_key_hash.encoding)) (function | {public_key_hash; public_key; amount; delegate_to = Some delegate} -> @@ -1279,7 +1288,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -1340,11 +1349,11 @@ let lib_parameters_json_encoding = (fun (pk, amount) -> { Parameters.public_key = Some pk; - public_key_hash = Signature.Public_key.hash pk; + public_key_hash = Tezos_crypto.Signature.Public_key.hash pk; amount; delegate_to = None; }) - (tup2 Signature.Public_key.encoding Tez.encoding) + (tup2 Tezos_crypto.Signature.Public_key.encoding Tez.encoding) in Data_encoding.( merge_objs @@ -1357,7 +1366,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -1377,14 +1386,14 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end (* ------------------------------------------------------------------------- *) (* RPC context *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" let endorsement_branch_data_encoding = @@ -1393,7 +1402,7 @@ let endorsement_branch_data_encoding = (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (obj2 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "block_payload_hash" Protocol.Block_payload_hash.encoding)) let initial_context chain_id (header : Block_header.shell_header) @@ -1502,7 +1511,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in Protocol_constants_overrides.apply_overrides (cctxt :> Tezos_client_base.Client_context.printer) @@ -1559,10 +1568,13 @@ let mem_init : let protocol_data = let payload_hash = Protocol.Block_payload_hash.hash_bytes - [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] + [ + Tezos_crypto.Block_hash.to_bytes hash; + Tezos_crypto.Operation_list_hash.(to_bytes @@ compute []); + ] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Signature.generate_key () in + let _, _, sk = Tezos_crypto.Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -1582,7 +1594,7 @@ let mem_init : (shell_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_014_PtKathma/lib_client/operation_result.ml b/src/proto_014_PtKathma/lib_client/operation_result.ml index 35d340990a1d..c8a665e3e46e 100644 --- a/src/proto_014_PtKathma/lib_client/operation_result.ml +++ b/src/proto_014_PtKathma/lib_client/operation_result.ml @@ -96,13 +96,13 @@ let pp_internal_operation ppf (Internal_contents {operation; source; _}) = Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Event {ty; tag; payload} -> Format.fprintf ppf @@ -169,7 +169,7 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Reveal key -> Format.fprintf @@ -177,13 +177,13 @@ let pp_manager_operation_content (type kind) source ppf "Revelation of manager public key:@,Contract: %a@,Key: %a" Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Register_global_constant {value} -> Format.fprintf ppf @@ -382,9 +382,12 @@ let pp_balance_updates ppf balance_updates = (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero then - Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero + then Format.fprintf ppf "the baker who will include this operation" + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -866,7 +869,11 @@ let pp_manager_operation_result ppf Manager_operation_result {balance_updates; operation_result; internal_operation_results} ) = Format.fprintf ppf "@[Manager signed operations:" ; - Format.fprintf ppf "@,From: %a" Signature.Public_key_hash.pp source ; + Format.fprintf + ppf + "@,From: %a" + Tezos_crypto.Signature.Public_key_hash.pp + source ; Format.fprintf ppf "@,Fee to the baker: %s%a" tez_sym Tez.pp fee ; Format.fprintf ppf "@,Expected counter: %a" Z.pp_print counter ; Format.fprintf ppf "@,Gas limit: %a" Gas.Arith.pp_integral gas_limit ; @@ -917,9 +924,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -937,7 +944,7 @@ let pp_contents_and_result : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate preendorsement_power | ( Endorsement {level; _}, @@ -953,14 +960,14 @@ let pp_contents_and_result : level pp_balance_updates balance_updates - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate endorsement_power | Dal_slot_availability _, Dal_slot_availability_result {delegate} -> Format.fprintf ppf "@[Slot availability:@,Delegate: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate | ( Double_endorsement_evidence {op1; op2}, Double_endorsement_evidence_result bus ) -> @@ -971,9 +978,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -986,9 +993,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -999,7 +1006,7 @@ let pp_contents_and_result : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -1007,19 +1014,19 @@ let pp_contents_and_result : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Ballot {source; period; proposal; ballot}, Ballot_result -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) diff --git a/src/proto_014_PtKathma/lib_client/proxy.ml b/src/proto_014_PtKathma/lib_client/proxy.ml index 0954933c0a34..4df92d400a6d 100644 --- a/src/proto_014_PtKathma/lib_client/proxy.ml +++ b/src/proto_014_PtKathma/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_context_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_context_commands.ml index b677b7f84fea..075d0ae660ca 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_context_commands.ml @@ -74,7 +74,7 @@ let report_michelson_errors ?(no_print_source = false) ~msg let block_hash_param = Tezos_clic.parameter (fun _ s -> - try return (Block_hash.of_b58check_exn s) + try return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -417,7 +417,7 @@ let commands_ro () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ stop) @@ -458,7 +458,10 @@ let commands_ro () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -476,12 +479,16 @@ let commands_ro () = fprintf ppf "* %a %a %s (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p Tez.pp (Tez.of_mutez_exn w) Operation_result.tez_sym - (if List.mem ~equal:Protocol_hash.equal p known_protos + (if + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; @@ -1475,7 +1482,7 @@ let commands_rw () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> return hash)) @@ prefixes ["to"; "be"; "included"] @@ -1512,7 +1519,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)))) @@ -1574,7 +1581,7 @@ let commands_rw () = Constants.max_proposals_per_delegate ; (match Base.List.find_all_dups - ~compare:Protocol_hash.compare + ~compare:Tezos_crypto.Protocol_hash.compare proposals with | [] -> () @@ -1587,25 +1594,28 @@ let commands_rw () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else error "Protocol %a is not a known proposal." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p) proposals ; if not has_voting_power then error "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -1682,7 +1692,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> return hash)) @@ param @@ -1722,12 +1732,12 @@ let commands_rw () = >>=? fun current_proposal -> (match (info.current_period_kind, current_proposal) with | (Exploration | Promotion), Some current_proposal -> - if Protocol_hash.equal proposal current_proposal then - return_unit + if Tezos_crypto.Protocol_hash.equal proposal current_proposal + then return_unit else (if force then cctxt#warning else cctxt#error) "Unexpected proposal, expected: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp current_proposal >>= fun () -> return_unit | _ -> @@ -1752,7 +1762,7 @@ let commands_rw () = (if force then cctxt#warning else cctxt#error) "Public-key-hash `%a` from account `%s` does not appear to \ have voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name) >>= fun () -> diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_fa12_commands.ml index 7bc5d6b51b03..a239d399e750 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_fa12_commands.ml @@ -109,7 +109,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.Implicit Signature.Public_key_hash.zero +let dummy_callback = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt (caller : Contract.t) = match caller with diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_multisig_commands.ml index 24ad2cebec9a..f89f934b5d07 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_multisig_commands.ml @@ -113,7 +113,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -127,7 +128,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) @@ -324,7 +325,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a lambda for a generic multisig contract." @@ -354,7 +355,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate change for a multisig contract." @@ -383,7 +384,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Sign a delegate withdraw for a multisig contract." @@ -405,7 +406,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc: @@ -441,7 +442,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () >>=? fun prepared_command -> Client_keys.sign cctxt sk prepared_command.bytes >>=? fun signature -> - return @@ Format.printf "%a@." Signature.pp signature); + return @@ Format.printf "%a@." Tezos_crypto.Signature.pp signature); command ~group ~desc:"Transfer tokens using a multisig contract." diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_programs_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_programs_commands.ml index b5ed4dac5d0d..48a2bae7a7f7 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_programs_commands.ml @@ -133,7 +133,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") in @@ -449,8 +449,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -665,8 +665,8 @@ let commands () = @@ prefixes ["for"] @@ Client_keys.Secret_key.source_param @@ stop) (fun () bytes sk cctxt -> Client_keys.sign cctxt sk bytes >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_stresstest_commands.ml index 43b11bc5f7e7..051a12ff345b 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_stresstest_commands.ml @@ -64,14 +64,14 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type source_with_uri = { pkh : public_key_hash; pk : public_key; pk_uri : Client_keys.pk_uri; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; sk_uri : Client_keys.sk_uri; } @@ -85,7 +85,7 @@ type source_origin = {source : source; origin : origin} (** Destination of a call: either an implicit contract or an originated one with all the necessary data (entrypoint and the argument). *) type destination = - | Implicit of Signature.Public_key_hash.t + | Implicit of Tezos_crypto.Signature.Public_key_hash.t | Originated of Smart_contracts.invocation_parameters type transfer = { @@ -100,17 +100,18 @@ type transfer = { type state = { rng_state : Random.State.t; - current_head_on_start : Block_hash.t; + current_head_on_start : Tezos_crypto.Block_hash.t; mutable pool : source_origin list; mutable pool_size : int; mutable shuffled_pool : source list; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; - mutable target_block : Block_hash.t; + mutable target_block : Tezos_crypto.Block_hash.t; (** The block on top of which we are injecting transactions (HEAD~2). *) new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } (** Cost estimations for every kind of transaction used in the stress test. @@ -161,9 +162,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -175,7 +176,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -186,8 +187,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let transaction_costs_encoding = let open Data_encoding in @@ -240,7 +241,7 @@ let parse_strategy s = let normalize_source cctxt = let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -276,8 +277,8 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - cctxt#warning msg Signature.Public_key_hash.pp pkh >>= fun () -> - Lwt.return_none + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + >>= fun () -> Lwt.return_none in (Client_keys.get_key cctxt pkh >>= function | Error _ -> warning "Pkh \"%a\" not found in the wallet" pkh @@ -287,7 +288,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias >>= fun () -> Lwt.return_none @@ -329,13 +330,13 @@ let rec get_source_from_shuffled_pool state cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) >>= fun () -> Lwt.return source | [] -> cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block >>= fun () -> Lwt_condition.wait state.new_block_condition >>= fun () -> @@ -346,7 +347,7 @@ let random_seed rng = let generate_fresh_source state = let seed = random_seed state.rng_state in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in state.pool <- fresh :: state.pool ; state.pool_size <- state.pool_size + 1 ; @@ -357,7 +358,9 @@ let generate_fresh_source state = [promise] resolved when the stream is closed. [stopper ()] closes the stream. *) let heads_iter (cctxt : Protocol_client_context.full) - (f : Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t) : + (f : + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t) : (unit tzresult Lwt.t * Tezos_rpc.Context.stopper) tzresult Lwt.t = let open Lwt_result_syntax in let* heads_stream, stopper = Shell_services.Monitor.heads cctxt `Main in @@ -372,7 +375,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "heads_iter: new block received %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp new_block_hash) in let* protocols = @@ -381,7 +384,10 @@ let heads_iter (cctxt : Protocol_client_context.full) ~block:(`Hash (new_block_hash, 0)) () in - if Protocol_hash.(protocols.current_protocol = Protocol.hash) then + if + Tezos_crypto.Protocol_hash.( + protocols.current_protocol = Protocol.hash) + then let* () = f block_hash_and_header in loop () else @@ -390,7 +396,7 @@ let heads_iter (cctxt : Protocol_client_context.full) cctxt#message "heads_iter: new block on protocol %a. Stopping \ iteration.@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocols.current_protocol) in return_unit) @@ -404,7 +410,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "head iteration for proto %a stopped@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash) in return (promise, stopper) @@ -434,7 +440,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block log Debug (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) >>= fun () -> (* Sampled source has zero balance: the transfer that created that @@ -478,7 +484,11 @@ let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -528,14 +538,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state Shell_services.Blocks.hash cctxt () >>=? fun branch -> Alpha_services.Contract.counter cctxt (`Main, `Head 0) transfer.src.pkh >>=? fun current_counter -> - (if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + (if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; Alpha_services.Contract.manager_key cctxt (`Main, `Head 0) transfer.src.pkh >>=? fun pk_opt -> return (Option.is_some pk_opt))) >>=? fun already_revealed -> @@ -562,7 +577,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print reveal_counter @@ -587,7 +602,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print transf_counter @@ -601,15 +616,18 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Debug (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) >>= fun () -> let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find state.injected_operations branch) in - Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; + Tezos_crypto.Block_hash.Table.replace + state.injected_operations + branch + (op_hash :: ops) ; return_unit | Error e -> log Debug (fun () -> @@ -623,7 +641,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -644,10 +662,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = Shell_services.Blocks.hash cctxt () >>=? fun current_head_on_exit -> let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -675,7 +693,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -688,9 +706,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = log Debug (fun () -> cctxt#message "injected : [%a]@.included: [%a]" - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) included_ops) >>= fun () -> let injected_ops_count = List.length injected_ops in @@ -768,7 +786,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) >>= loop in let on_new_head : - Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t = + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t = (* Because of how Tenderbake works the target block should stay 2 blocks in the past because this guarantees that we are targeting a block that is decided. *) @@ -780,7 +799,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) in fun (new_block_hash, new_block_header) -> update_target_block () >>=? fun () -> - if not (Block_hash.equal new_block_hash state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal new_block_hash state.last_block) + then ( state.last_block <- new_block_hash ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1105,7 +1125,9 @@ let generate_random_transactions = let sources = List.sort_uniq (fun src1 src2 -> - Signature.Secret_key.compare src1.source.sk src2.source.sk) + Tezos_crypto.Signature.Secret_key.compare + src1.source.sk + src2.source.sk) sources in let rng_state = Random.State.make [|parameters.seed|] in @@ -1116,7 +1138,7 @@ let generate_random_transactions = cctxt#error "The level of the head (%a) needs to be greater than 2 and is \ actually %ld." - Block_hash.pp + Tezos_crypto.Block_hash.pp current_head_on_start header_on_start.level else return_unit) @@ -1133,12 +1155,12 @@ let generate_random_transactions = List.shuffle ~rng:rng_state (List.map (fun src_org -> src_org.source) sources); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.level; target_block = current_target_block; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = @@ -1410,14 +1432,14 @@ let load_wallet cctxt ~source_pkh = | [] -> return acc | (alias, pkh, _, _) :: tl when List.exists (String.equal alias) to_ban - || Signature.Public_key_hash.equal pkh source_pkh -> + || Tezos_crypto.Signature.Public_key_hash.equal pkh source_pkh -> aux acc tl | (_, pkh, pk, sk_uri) :: tl -> let* pk_uri = Client_keys.neuterize sk_uri in let payload = Uri.path (sk_uri : Tezos_signer_backends.Unencrypted.sk_uri :> Uri.t) in - let sk = Signature.Secret_key.of_b58check_exn payload in + let sk = Tezos_crypto.Signature.Secret_key.of_b58check_exn payload in aux ({pkh; pk; pk_uri; sk; sk_uri} :: acc) tl in aux [] keys @@ -1430,7 +1452,7 @@ let source_key_arg = "Source key public key hash from which the tokens will be transferred to \ start the funding." (parameter (fun _ s -> - let r = Signature.Public_key_hash.of_b58check s in + let r = Tezos_crypto.Signature.Public_key_hash.of_b58check s in match r with | Ok pkh -> Lwt_result_syntax.return pkh | Error e -> @@ -1715,7 +1737,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command cctxt#message "Starting funding from %a with parameters:@.- batch_size %d@.- \ batches_per_block %d@.- initial_amount %a@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh batch_size batches_per_block @@ -1782,7 +1804,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command source_balance Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh else let*! () = @@ -1791,7 +1813,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command "Transfering %a tz from %a (out of %a)@." Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh Tez.pp source_balance) diff --git a/src/proto_014_PtKathma/lib_client_commands/client_proto_utils_commands.ml b/src/proto_014_PtKathma/lib_client_commands/client_proto_utils_commands.ml index 9ff9765920ad..cd8c924cfff6 100644 --- a/src/proto_014_PtKathma/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_014_PtKathma/lib_client_commands/client_proto_utils_commands.ml @@ -88,8 +88,8 @@ let commands () = Shell_services.Blocks.hash cctxt ~chain:cctxt#chain ~block:block_head () >>=? fun block -> sign_message cctxt ~src_sk ~block ~message >>=? fun signature -> - cctxt#message "Signature: %a" Signature.pp signature >>= fun () -> - return_unit); + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + >>= fun () -> return_unit); command ~group ~desc: @@ -157,5 +157,6 @@ let commands () = (Block_header chain_id)) sk unsigned_header - >>=? fun s -> cctxt#message "%a" Hex.pp (Signature.to_hex s) >>= return); + >>=? fun s -> + cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) >>= return); ] diff --git a/src/proto_014_PtKathma/lib_client_sapling/client_sapling_commands.ml b/src/proto_014_PtKathma/lib_client_sapling/client_sapling_commands.ml index 862335b18cb6..4c8cbdab0c9f 100644 --- a/src/proto_014_PtKathma/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_014_PtKathma/lib_client_sapling/client_sapling_commands.ml @@ -53,7 +53,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -61,7 +61,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Contract_hash.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) (** The shielded tez contract expects the recipient pkh encoded in Micheline @@ -70,7 +70,9 @@ let bound_data_of_public_key_hash cctxt dst = let open Tezos_micheline in let open Protocol.Michelson_v1_primitives in let pkh_bytes = - Data_encoding.Binary.to_bytes_exn Signature.Public_key_hash.encoding dst + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key_hash.encoding + dst in let micheline_bytes = Micheline.(Bytes (0, pkh_bytes) |> strip_locations) in let micheline_pkh_type = @@ -664,7 +666,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_014_PtKathma/lib_client_sapling/context.ml b/src/proto_014_PtKathma/lib_client_sapling/context.ml index 9412ecb6f6e0..1122de030c3a 100644 --- a/src/proto_014_PtKathma/lib_client_sapling/context.ml +++ b/src/proto_014_PtKathma/lib_client_sapling/context.ml @@ -140,7 +140,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_014_PtKathma/lib_delegate/abstract_context_index.ml b/src/proto_014_PtKathma/lib_delegate/abstract_context_index.ml index da5a0d216721..50954c9da376 100644 --- a/src/proto_014_PtKathma/lib_delegate/abstract_context_index.ml +++ b/src/proto_014_PtKathma/lib_delegate/abstract_context_index.ml @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.Context_hash.t -> + Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_014_PtKathma/lib_delegate/abstract_context_index.mli b/src/proto_014_PtKathma/lib_delegate/abstract_context_index.mli index e6d262a8ad03..2d0533b7067b 100644 --- a/src/proto_014_PtKathma/lib_delegate/abstract_context_index.mli +++ b/src/proto_014_PtKathma/lib_delegate/abstract_context_index.mli @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.Context_hash.t -> + Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_014_PtKathma/lib_delegate/baking_cache.ml b/src/proto_014_PtKathma/lib_delegate/baking_cache.ml index af2ac36dc1fc..67fdb2d6a581 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_cache.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_cache.ml @@ -31,7 +31,7 @@ type round = Round.t module Block_cache = (val Ringo.(map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash) + (Tezos_crypto.Block_hash) (** The [Timestamp_of_round_tbl] module allows to create memoization tables to store function calls of [Round.timestamp_of_round]. *) diff --git a/src/proto_014_PtKathma/lib_delegate/baking_commands.ml b/src/proto_014_PtKathma/lib_delegate/baking_commands.ml index c7a844d5ba4f..e07e48e8fca6 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_commands.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_commands.ml @@ -166,7 +166,7 @@ let liquidity_baking_toggle_vote_arg = liquidity_baking_toggle_vote_parameter let get_delegates (cctxt : Protocol_client_context.full) - (pkhs : Signature.public_key_hash list) = + (pkhs : Tezos_crypto.Signature.public_key_hash list) = let proj_delegate (alias, public_key_hash, public_key, secret_key_uri) = { Baking_state.alias = Some alias; diff --git a/src/proto_014_PtKathma/lib_delegate/baking_configuration.ml b/src/proto_014_PtKathma/lib_delegate/baking_configuration.ml index 2b8dca57b0f6..db13c684bf3c 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_configuration.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_configuration.ml @@ -81,7 +81,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -221,7 +221,7 @@ let retries_on_failure_config_encoding = Data_encoding.int31 let user_activate_upgrades_config_encoding = let open Data_encoding in - list (tup2 int32 Protocol_hash.encoding) + list (tup2 int32 Tezos_crypto.Protocol_hash.encoding) let liquidity_baking_toggle_vote_config_encoding = Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote_encoding diff --git a/src/proto_014_PtKathma/lib_delegate/baking_configuration.mli b/src/proto_014_PtKathma/lib_delegate/baking_configuration.mli index a1908d29dd22..cd5b5a445f41 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_configuration.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_configuration.mli @@ -56,7 +56,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -73,7 +73,8 @@ val default_nonce_config : nonce_config val default_retries_on_failure_config : int -val default_user_activated_upgrades : (int32 * Protocol_hash.t) list +val default_user_activated_upgrades : + (int32 * Tezos_crypto.Protocol_hash.t) list val default_liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote @@ -95,7 +96,7 @@ val make : ?nonce:nonce_config -> ?context_path:string -> ?retries_on_failure:int -> - ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> + ?user_activated_upgrades:(int32 * Tezos_crypto.Protocol_hash.t) list -> ?liquidity_baking_toggle_vote: Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote -> ?per_block_vote_file:string -> @@ -114,7 +115,7 @@ val nonce_config_encoding : nonce_config Data_encoding.t val retries_on_failure_config_encoding : int Data_encoding.t val user_activate_upgrades_config_encoding : - (int32 * Protocol_hash.t) list Data_encoding.t + (int32 * Tezos_crypto.Protocol_hash.t) list Data_encoding.t val liquidity_baking_toggle_vote_config_encoding : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote diff --git a/src/proto_014_PtKathma/lib_delegate/baking_events.ml b/src/proto_014_PtKathma/lib_delegate/baking_events.ml index 92f553a366dd..27aeb86ea4a1 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_events.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_events.ml @@ -43,8 +43,8 @@ module State_transitions = struct ~name:"new_head" ~level:Notice ~msg:"received new head {block} at level {level}, round {round}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) ~pp3:Round.pp @@ -119,12 +119,12 @@ module State_transitions = struct ~msg: "proposal {new_proposal} for current round ({current_round}) has \ already been seen {previous_proposal}" - ~pp1:Block_hash.pp - ("new_proposal", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("new_proposal", Tezos_crypto.Block_hash.encoding) ~pp2:Round.pp ("current_round", Round.encoding) - ~pp3:Block_hash.pp - ("previous_proposal", Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("previous_proposal", Tezos_crypto.Block_hash.encoding) let updating_latest_proposal = declare_1 @@ -132,8 +132,8 @@ module State_transitions = struct ~name:"updating_latest_proposal" ~msg:"updating latest proposal to {block_hash}" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let baker_is_ahead_of_node = declare_2 @@ -156,10 +156,10 @@ module State_transitions = struct ~msg: "received a proposal on another branch - current: current \ pred{current_branch}, new pred {new_branch}" - ~pp1:Block_hash.pp - ("current_branch", Block_hash.encoding) - ~pp2:Block_hash.pp - ("new_branch", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("current_branch", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("new_branch", Tezos_crypto.Block_hash.encoding) let switching_branch = declare_0 @@ -215,8 +215,8 @@ module State_transitions = struct ~name:"attempting_preendorsing_proposal" ~level:Info ~msg:"attempting to preendorse proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let skipping_invalid_proposal = declare_0 @@ -232,8 +232,8 @@ module State_transitions = struct ~name:"outdated_proposal" ~level:Debug ~msg:"outdated proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let proposing_fresh_block = declare_2 @@ -271,10 +271,10 @@ module State_transitions = struct ~msg: "unexpected prequorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let unexpected_quorum_received = declare_2 @@ -284,10 +284,10 @@ module State_transitions = struct ~msg: "unexpected quorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let step_current_phase = declare_2 @@ -321,8 +321,8 @@ module Node_rpc = struct ~name:"raw_info" ~level:Debug ~msg:"raw info for {block_hash} at level {level}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) end @@ -451,8 +451,8 @@ module Scheduling = struct ~name:"proposal_in_the_future" ~level:Debug ~msg:"received proposal in the future {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let process_proposal_in_the_future = declare_1 @@ -460,8 +460,8 @@ module Scheduling = struct ~name:"process_proposal_in_the_future" ~level:Debug ~msg:"process proposal received in the future with hash {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) end module Lib = struct @@ -543,8 +543,8 @@ module Actions = struct ~name:"preendorsement_injected" ~level:Notice ~msg:"injected preendorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -554,8 +554,8 @@ module Actions = struct ~name:"endorsement_injected" ~level:Notice ~msg:"injected endorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_delegate ("delegate", Baking_state.delegate_encoding) @@ -565,8 +565,8 @@ module Actions = struct ~name:"synchronizing_round" ~level:Info ~msg:"synchronizing round after block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let forging_block = declare_3 @@ -605,11 +605,11 @@ module Actions = struct ~msg: "block {block} at level {level}, round {round} injected for delegate \ {delegate}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:pp_int32 ~pp3:Round.pp ~pp4:Baking_state.pp_delegate - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("round", Round.encoding) ("delegate", Baking_state.delegate_encoding) @@ -684,8 +684,8 @@ module VDF = struct ("cycle", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let vdf_daemon_start = declare_1 @@ -733,8 +733,8 @@ module Nonces = struct ~name:"found_nonce_to_reveal" ~level:Notice ~msg:"found nonce to reveal for block {block}, level {level}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) @@ -750,8 +750,8 @@ module Nonces = struct ("level", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let cannot_fetch_chain_head_level = declare_0 @@ -825,8 +825,8 @@ module Nonces = struct ~name:"registering_nonce" ~level:Info ~msg:"registering nonce for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let nothing_to_reveal = declare_1 @@ -834,8 +834,8 @@ module Nonces = struct ~name:"nothing_to_reveal" ~level:Info ~msg:"nothing to reveal for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let revelation_worker_started = declare_0 @@ -920,8 +920,8 @@ module Selection = struct ~name:"invalid_operation_filtered" ~level:Warning ~msg:"filtered invalid operation {op}: {errors}" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) @@ -931,6 +931,6 @@ module Selection = struct ~name:"cannot_serialize_operation_metadata" ~level:Warning ~msg:"cannot serialize operation {op} metadata" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) end diff --git a/src/proto_014_PtKathma/lib_delegate/baking_files.ml b/src/proto_014_PtKathma/lib_delegate/baking_files.ml index 38339e2fe555..67ef0c7ea0d4 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_files.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_files.ml @@ -32,6 +32,6 @@ let resolve_location ~chain_id (kind : 'a) : 'a location = | `State -> "baker_state" | `Nonce -> "nonce" in - Format.asprintf "%a_%s" Chain_id.pp_short chain_id basename + Format.asprintf "%a_%s" Tezos_crypto.Chain_id.pp_short chain_id basename let filename x = x diff --git a/src/proto_014_PtKathma/lib_delegate/baking_files.mli b/src/proto_014_PtKathma/lib_delegate/baking_files.mli index 01146f7d0744..82940952da05 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_files.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_files.mli @@ -26,7 +26,7 @@ type _ location val resolve_location : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ([< `Highwatermarks | `Nonce | `State] as 'kind) -> 'kind location diff --git a/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.ml b/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.ml index 91b56b3e50b1..4af172f183fe 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.ml @@ -100,9 +100,9 @@ let () = (fun highwatermark -> Block_previously_endorsed highwatermark) module DelegateMap = Map.Make (struct - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t - let compare = Signature.Public_key_hash.compare + let compare = Tezos_crypto.Signature.Public_key_hash.compare end) let highwatermark_delegate_map_encoding = @@ -113,7 +113,7 @@ let highwatermark_delegate_map_encoding = fun l -> List.fold_left (fun map (k, v) -> add k v map) empty l) (list (obj2 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "highwatermark" highwatermark_encoding))) type highwatermarks = { diff --git a/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.mli b/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.mli index 757b667c58bb..30d4d6f4ea3e 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_highwatermarks.mli @@ -45,7 +45,7 @@ val load : val may_sign_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -53,7 +53,7 @@ val may_sign_block : val may_sign_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -61,7 +61,7 @@ val may_sign_preendorsement : val may_sign_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -69,7 +69,7 @@ val may_sign_endorsement : val record_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -77,7 +77,7 @@ val record_block : val record_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -85,7 +85,7 @@ val record_preendorsement : val record_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_delegate/baking_lib.ml b/src/proto_014_PtKathma/lib_delegate/baking_lib.ml index 7ef044310a5f..c9f72f0814bc 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_lib.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_lib.ml @@ -262,7 +262,7 @@ let propose_at_next_level ~minimal_timestamp state = "Proposed block at round %a on top of %a " Round.pp block_to_bake.round - Block_hash.pp + Tezos_crypto.Block_hash.pp block_to_bake.predecessor.hash in return state @@ -405,7 +405,7 @@ let bake_using_automaton config state block_stream = let*! () = cctxt#message "Block %a (%ld) injected" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash proposal.block.shell.level in diff --git a/src/proto_014_PtKathma/lib_delegate/baking_nonces.ml b/src/proto_014_PtKathma/lib_delegate/baking_nonces.ml index e67e8dca6905..a3b0bf620a2a 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_nonces.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_nonces.ml @@ -33,27 +33,34 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -let empty = Block_hash.Map.empty +let empty = Tezos_crypto.Block_hash.Map.empty let encoding = let open Data_encoding in def "seed_nonce" @@ conv (fun m -> - Block_hash.Map.fold (fun hash nonce acc -> (hash, nonce) :: acc) m []) + Tezos_crypto.Block_hash.Map.fold + (fun hash nonce acc -> (hash, nonce) :: acc) + m + []) (fun l -> List.fold_left - (fun map (hash, nonce) -> Block_hash.Map.add hash nonce map) - Block_hash.Map.empty + (fun map (hash, nonce) -> + Tezos_crypto.Block_hash.Map.add hash nonce map) + Tezos_crypto.Block_hash.Map.empty l) - @@ list (obj2 (req "block" Block_hash.encoding) (req "nonce" Nonce.encoding)) + @@ list + (obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (req "nonce" Nonce.encoding)) let may_migrate (wallet : Protocol_client_context.full) location = let base_dir = wallet#get_base_dir in @@ -78,16 +85,16 @@ let load (wallet : #Client_context.wallet) location = let save (wallet : #Client_context.wallet) location nonces = wallet#write (Baking_files.filename location) nonces encoding -let mem nonces hash = Block_hash.Map.mem hash nonces +let mem nonces hash = Tezos_crypto.Block_hash.Map.mem hash nonces -let find_opt nonces hash = Block_hash.Map.find hash nonces +let find_opt nonces hash = Tezos_crypto.Block_hash.Map.find hash nonces -let add nonces hash nonce = Block_hash.Map.add hash nonce nonces +let add nonces hash nonce = Tezos_crypto.Block_hash.Map.add hash nonce nonces -let remove nonces hash = Block_hash.Map.remove hash nonces +let remove nonces hash = Tezos_crypto.Block_hash.Map.remove hash nonces let remove_all nonces nonces_to_remove = - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash _ acc -> remove acc hash) nonces_to_remove nonces @@ -116,7 +123,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let block_cycle = Int32.(div block_level blocks_per_cycle) in Int32.sub current_cycle block_cycle > Int32.of_int preserved_cycles in - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash nonce acc -> acc >>=? fun (orphans, outdated) -> get_block_level_opt cctxt ~chain ~block:(`Hash (hash, 0)) >>= function @@ -131,7 +138,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let filter_outdated_nonces state nonces = get_outdated_nonces state nonces >>=? fun (orphans, outdated_nonces) -> when_ - (Block_hash.Map.cardinal orphans >= 50) + (Tezos_crypto.Block_hash.Map.cardinal orphans >= 50) (fun () -> Events.( emit too_many_nonces (Baking_files.filename state.nonces_location ^ "s")) @@ -207,7 +214,9 @@ let generate_seed_nonce (nonce_config : Baking_configuration.nonce_config) >>=? fun nonce -> return (Data_encoding.Binary.of_bytes_exn Nonce.encoding nonce) | Random -> ( - match Nonce.of_bytes (Rand.generate Constants.nonce_length) with + match + Nonce.of_bytes (Tezos_crypto.Rand.generate Constants.nonce_length) + with | Error _errs -> assert false | Ok nonce -> return nonce)) >>=? fun nonce -> return (Nonce.hash nonce, nonce) @@ -237,7 +246,9 @@ let inject_seed_nonce_revelation (cctxt : #Protocol_client_context.full) ~chain ~nonce () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Shell_services.Injection.operation ~async:true cctxt ~chain bytes >>=? fun oph -> Events.( @@ -252,8 +263,9 @@ let reveal_potential_nonces state new_proposal = let {cctxt; chain; nonces_location; last_predecessor; _} = state in let new_predecessor_hash = new_proposal.Baking_state.predecessor.hash in if - Block_hash.(last_predecessor <> new_predecessor_hash) - && Protocol_hash.(new_proposal.predecessor.protocol = Protocol.hash) + Tezos_crypto.Block_hash.(last_predecessor <> new_predecessor_hash) + && Tezos_crypto.Protocol_hash.( + new_proposal.predecessor.protocol = Protocol.hash) then ( (* only try revealing nonces when the proposal's predecessor is a new one *) state.last_predecessor <- new_predecessor_hash ; @@ -304,7 +316,7 @@ let start_revelation_worker cctxt config chain_id constants block_stream = constants; config; nonces_location; - last_predecessor = Block_hash.zero; + last_predecessor = Tezos_crypto.Block_hash.zero; } in let rec worker_loop () = diff --git a/src/proto_014_PtKathma/lib_delegate/baking_nonces.mli b/src/proto_014_PtKathma/lib_delegate/baking_nonces.mli index 303a484abe0a..b687950e8cab 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_nonces.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_nonces.mli @@ -32,31 +32,35 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -val empty : Nonce.t Block_hash.Map.t +val empty : Nonce.t Tezos_crypto.Block_hash.Map.t -val encoding : Nonce.t Block_hash.Map.t Data_encoding.t +val encoding : Nonce.t Tezos_crypto.Block_hash.Map.t Data_encoding.t val load : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val save : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> unit tzresult Lwt.t -val mem : Nonce.t Block_hash.Map.t -> Block_hash.t -> bool +val mem : + Nonce.t Tezos_crypto.Block_hash.Map.t -> Tezos_crypto.Block_hash.t -> bool -val find_opt : Nonce.t Block_hash.Map.t -> Block_hash.t -> Nonce.t option +val find_opt : + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Tezos_crypto.Block_hash.t -> + Nonce.t option val get_block_level_opt : #Tezos_rpc.Context.simple -> @@ -66,21 +70,28 @@ val get_block_level_opt : val get_outdated_nonces : t -> - Nonce.t Block_hash.Map.t -> - (Nonce.t Block_hash.Map.t * Nonce.t Block_hash.Map.t) tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Nonce.t Tezos_crypto.Block_hash.Map.t + * Nonce.t Tezos_crypto.Block_hash.Map.t) + tzresult + Lwt.t val filter_outdated_nonces : - t -> Nonce.t Block_hash.Map.t -> Nonce.t Block_hash.Map.t tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val blocks_from_current_cycle : t -> Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t val get_unrevealed_nonces : - t -> Nonce.t Block_hash.Map.t -> (Raw_level.t * Nonce.t) list tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Raw_level.t * Nonce.t) list tzresult Lwt.t val generate_seed_nonce : Baking_configuration.nonce_config -> @@ -90,8 +101,8 @@ val generate_seed_nonce : val register_nonce : #Protocol_client_context.full -> - chain_id:Chain_id.t -> - Block_hash.t -> + chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Block_hash.t -> Nonce.t -> unit tzresult Lwt.t @@ -99,7 +110,7 @@ val inject_seed_nonce_revelation : #Protocol_client_context.full -> chain:Chain_services.chain -> block:Block_services.block -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> (Raw_level.t * Nonce.t) list -> unit tzresult Lwt.t @@ -108,7 +119,7 @@ val reveal_potential_nonces : t -> Baking_state.proposal -> unit tzresult Lwt.t val start_revelation_worker : Protocol_client_context.full -> Baking_configuration.nonce_config -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> Constants.t -> Baking_state.proposal Lwt_stream.t -> Lwt_canceler.t Lwt.t diff --git a/src/proto_014_PtKathma/lib_delegate/baking_pow.ml b/src/proto_014_PtKathma/lib_delegate/baking_pow.ml index 5637988fb52b..d5d4d4be293b 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_pow.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_pow.ml @@ -59,7 +59,7 @@ let init_proof_of_work_nonce () = (* This was used before November 2018 *) (* (\* Random proof of work *\) * let generate_proof_of_work_nonce () = - * Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) + * Tezos_crypto.Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) let empty_proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '\000' diff --git a/src/proto_014_PtKathma/lib_delegate/baking_scheduling.ml b/src/proto_014_PtKathma/lib_delegate/baking_scheduling.ml index 38d42a06cc3d..bca851f697d8 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_scheduling.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_scheduling.ml @@ -211,8 +211,10 @@ let compute_next_round_time state = | None -> state.level_state.latest_proposal | Some {proposal; _} -> proposal in - if Protocol_hash.(proposal.predecessor.next_protocol <> Protocol.hash) then - None + if + Tezos_crypto.Protocol_hash.( + proposal.predecessor.next_protocol <> Protocol.hash) + then None else match state.level_state.next_level_proposed_round with | Some _proposed_round -> @@ -630,7 +632,7 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config >>=? fun next_level_delegate_slots -> let elected_block = if - Protocol_hash.( + Tezos_crypto.Protocol_hash.( current_proposal.block.protocol <> Protocol.hash && current_proposal.block.next_protocol = Protocol.hash) then diff --git a/src/proto_014_PtKathma/lib_delegate/baking_simulator.ml b/src/proto_014_PtKathma/lib_delegate/baking_simulator.ml index 125ab0fbf45c..fa92df32e419 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_simulator.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_simulator.ml @@ -98,9 +98,9 @@ let begin_construction ~timestamp ~protocol_data fitness = pred_shell.fitness; timestamp; level = pred_shell.level; - context = Context_hash.zero (* fake context hash *); + context = Tezos_crypto.Context_hash.zero (* fake context hash *); operations_hash = - Operation_list_list_hash.zero (* fake op hash *); + Tezos_crypto.Operation_list_list_hash.zero (* fake op hash *); } in Lifted_protocol.begin_application diff --git a/src/proto_014_PtKathma/lib_delegate/baking_simulator.mli b/src/proto_014_PtKathma/lib_delegate/baking_simulator.mli index eff536a60cda..5bc2ad516438 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_simulator.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_simulator.mli @@ -39,14 +39,14 @@ val load_context : (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : - Abstract_context_index.t -> Context_hash.t -> unit tzresult Lwt.t + Abstract_context_index.t -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t val begin_construction : timestamp:Time.Protocol.t -> protocol_data:block_header_data -> Abstract_context_index.t -> Baking_state.block_info -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> incremental tzresult Lwt.t val add_operation : diff --git a/src/proto_014_PtKathma/lib_delegate/baking_state.ml b/src/proto_014_PtKathma/lib_delegate/baking_state.ml index bde813946509..65e7d5a5cc88 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_state.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_state.ml @@ -31,8 +31,8 @@ open Protocol_client_context public key, its public key hash, and its secret key. *) type delegate = { alias : string option; - public_key : Signature.Public_key.t; - public_key_hash : Signature.Public_key_hash.t; + public_key : Tezos_crypto.Signature.Public_key.t; + public_key_hash : Tezos_crypto.Signature.Public_key_hash.t; secret_key_uri : Client_keys.sk_uri; } @@ -56,19 +56,24 @@ let delegate_encoding = }) (obj4 (req "alias" (option string)) - (req "public_key" Signature.Public_key.encoding) - (req "public_key_hash" Signature.Public_key_hash.encoding) + (req "public_key" Tezos_crypto.Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) let pp_delegate fmt {alias; public_key_hash; _} = match alias with - | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp public_key_hash + | None -> + Format.fprintf + fmt + "%a" + Tezos_crypto.Signature.Public_key_hash.pp + public_key_hash | Some alias -> Format.fprintf fmt "%s (%a)" alias - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp public_key_hash type validation_mode = Node | Local of Abstract_context_index.t @@ -81,17 +86,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; } type cache = { @@ -105,7 +110,7 @@ type global_state = { (* client context *) cctxt : Protocol_client_context.full; (* chain id *) - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; (* baker configuration *) config : Baking_configuration.t; (* protocol constants *) @@ -193,17 +198,17 @@ let block_info_encoding = }) (merge_objs (obj10 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "shell" Block_header.shell_header_encoding) (req "payload_hash" Block_payload_hash.encoding) (req "payload_round" Round.encoding) (req "round" Round.encoding) - (req "protocol" Protocol_hash.encoding) - (req "next_protocol" Protocol_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) + (req "next_protocol" Tezos_crypto.Protocol_hash.encoding) (req "prequorum" (option prequorum_encoding)) (req "quorum" (list (dynamic_size Operation.encoding))) (req "payload" Operation_pool.payload_encoding)) - (obj1 (req "live_blocks" Block_hash.Set.encoding))) + (obj1 (req "live_blocks" Tezos_crypto.Block_hash.Set.encoding))) let round_of_shell_header shell_header = Environment.wrap_tzresult @@ -217,7 +222,7 @@ module SlotMap : Map.S with type key = Slot.t = Map.Make (Slot) other words the list of rounds when it will be the proposer), and its endorsing power. *) type endorsing_slot = { - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; slots : Slot.t list; endorsing_power : int; } @@ -579,7 +584,7 @@ module DelegateSet = struct type t = delegate let compare {public_key_hash = pkh; _} {public_key_hash = pkh'; _} = - Signature.Public_key_hash.compare pkh pkh' + Tezos_crypto.Signature.Public_key_hash.compare pkh pkh' end) let find_pkh pkh s = @@ -587,8 +592,8 @@ module DelegateSet = struct try iter (fun ({public_key_hash; _} as delegate) -> - if Signature.Public_key_hash.equal pkh public_key_hash then - raise (Found delegate) + if Tezos_crypto.Signature.Public_key_hash.equal pkh public_key_hash + then raise (Found delegate) else ()) s ; None @@ -653,7 +658,7 @@ let pp_global_state fmt {chain_id; config; validation_mode; delegates; _} = fmt "@[Global state:@ chain_id: %a@ @[config:@ %a@]@ \ validation_mode: %a@ @[delegates:@ %a@]@]" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id Baking_configuration.pp config @@ -695,16 +700,16 @@ let pp_block_info fmt "@[Block:@ hash: %a@ payload_hash: %a@ level: %ld@ round: %a@ \ protocol: %a@ next protocol: %a@ prequorum: %a@ quorum: %d endorsements@ \ payload: %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash Block_payload_hash.pp_short payload_hash shell.level Round.pp round - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short next_protocol (pp_option pp_prequorum) prequorum @@ -727,7 +732,7 @@ let pp_endorsable_payload fmt {proposal; prequorum} = Format.fprintf fmt "proposal: %a, prequorum: %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash pp_prequorum prequorum @@ -843,7 +848,7 @@ let pp_event fmt = function round %a" (List.length preendos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched @@ -853,7 +858,7 @@ let pp_event fmt = function "quorum reached with %d endorsements (power: %d) for %a at round %a" (List.length endos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched diff --git a/src/proto_014_PtKathma/lib_delegate/baking_state.mli b/src/proto_014_PtKathma/lib_delegate/baking_state.mli index 45f325e509d1..ef7db2844dd1 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_state.mli +++ b/src/proto_014_PtKathma/lib_delegate/baking_state.mli @@ -28,8 +28,8 @@ open Alpha_context type delegate = { alias : string option; - public_key : Signature.public_key; - public_key_hash : Signature.public_key_hash; + public_key : Tezos_crypto.Signature.public_key; + public_key_hash : Tezos_crypto.Signature.public_key_hash; secret_key_uri : Client_keys.sk_uri; } @@ -47,17 +47,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; (** Set of live blocks for this block that is used to filter old or too recent operations. *) } @@ -71,7 +71,7 @@ type cache = { type global_state = { cctxt : Protocol_client_context.full; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; config : Baking_configuration.t; constants : Constants.t; round_durations : Round.round_durations; @@ -88,7 +88,7 @@ val round_of_shell_header : Block_header.shell_header -> Round.t tzresult module SlotMap : Map.S with type key = Slot.t type endorsing_slot = { - delegate : Signature.public_key_hash; + delegate : Tezos_crypto.Signature.public_key_hash; slots : Slot.t trace; endorsing_power : int; } diff --git a/src/proto_014_PtKathma/lib_delegate/baking_vdf.ml b/src/proto_014_PtKathma/lib_delegate/baking_vdf.ml index b08fd5ebea7b..6dc6d5e9abb1 100644 --- a/src/proto_014_PtKathma/lib_delegate/baking_vdf.ml +++ b/src/proto_014_PtKathma/lib_delegate/baking_vdf.ml @@ -156,7 +156,7 @@ let inject_vdf_revelation cctxt hash chain_id solution = ~solution () in - let bytes = Signature.concat bytes Signature.zero in + let bytes = Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero in Shell_services.Injection.operation cctxt ~chain bytes (* Checks if the VDF setup saved in the state is equal to the one computed @@ -182,7 +182,7 @@ let process_new_block (cctxt : #Protocol_client_context.full) state let* level_info = get_level_info cctxt level in let level_str = Int32.to_string (Raw_level.to_int32 level) in let* () = check_new_cycle state level_info in - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then let*! () = D_Events.(emit protocol_change_detected) () in return_unit else diff --git a/src/proto_014_PtKathma/lib_delegate/block_forge.ml b/src/proto_014_PtKathma/lib_delegate/block_forge.ml index a367b6b655c8..dcd4e7228e82 100644 --- a/src/proto_014_PtKathma/lib_delegate/block_forge.ml +++ b/src/proto_014_PtKathma/lib_delegate/block_forge.ml @@ -52,7 +52,7 @@ let forge_faked_protocol_data ?(payload_hash = Block_payload_hash.zero) proof_of_work_nonce = Baking_pow.empty_proof_of_work_nonce; liquidity_baking_toggle_vote; }; - signature = Signature.zero; + signature = Tezos_crypto.Signature.zero; } let convert_operation (op : packed_operation) : Tezos_base.Operation.t = @@ -112,7 +112,7 @@ let finalize_block_header shell_header timestamp validation_result let retain_live_operations_only ~live_blocks operation_pool = Operation_pool.Prioritized.filter (fun ({shell; _} : packed_operation) -> - Block_hash.Set.mem shell.branch live_blocks) + Tezos_crypto.Block_hash.Set.mem shell.branch live_blocks) operation_pool let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info @@ -136,7 +136,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info | None -> next_protocol | Some hash -> hash in - return Protocol_hash.(Protocol.hash <> next_protocol) + return Tezos_crypto.Protocol_hash.(Protocol.hash <> next_protocol) in let filter_via_node ~operation_pool = let filtered_operations = @@ -168,7 +168,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let operation_list_hash = Stdlib.List.tl operations |> List.flatten |> List.map Tezos_base.Operation.hash - |> Operation_list_hash.compute + |> Tezos_crypto.Operation_list_hash.compute in Block_payload.hash ~predecessor:shell_header.predecessor @@ -242,7 +242,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let operation_list_hash = Stdlib.List.tl operations |> List.flatten |> List.map Tezos_base.Operation.hash - |> Operation_list_hash.compute + |> Tezos_crypto.Operation_list_hash.compute in Block_payload.hash ~predecessor:shell_header.predecessor @@ -297,10 +297,11 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info >>=? fun (incremental, ordered_pool) -> let operations = Operation_pool.ordered_to_list_list ordered_pool in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in (* We need to compute the final [operations_hash] before @@ -384,7 +385,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let unsigned_block_header = { Block_header.shell = shell_header; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in return {unsigned_block_header; operations} diff --git a/src/proto_014_PtKathma/lib_delegate/block_forge.mli b/src/proto_014_PtKathma/lib_delegate/block_forge.mli index b111e27b417c..abf60c86d8f4 100644 --- a/src/proto_014_PtKathma/lib_delegate/block_forge.mli +++ b/src/proto_014_PtKathma/lib_delegate/block_forge.mli @@ -50,7 +50,7 @@ val forge_faked_protocol_data : val forge : #Protocol_client_context.full -> - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> pred_info:Baking_state.block_info -> timestamp:Time.Protocol.t -> liquidity_baking_toggle_vote:Liquidity_baking.liquidity_baking_toggle_vote -> diff --git a/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.ml b/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.ml index d7064545b7bd..e192aa649a72 100644 --- a/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.ml +++ b/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.ml @@ -28,16 +28,16 @@ open Alpha_context open Protocol_client_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } let raw_info cctxt ?(chain = `Main) hash shell_header = @@ -80,9 +80,9 @@ let info cctxt ?(chain = `Main) block = module Block_seen_event = struct type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Tezos_base.Block_header.t; - occurrence : [`Valid_blocks of Chain_id.t | `Heads]; + occurrence : [`Valid_blocks of Tezos_crypto.Chain_id.t | `Heads]; } let make hash header occurrence = {hash; header; occurrence} @@ -101,7 +101,7 @@ module Block_seen_event = struct (function {hash; header; occurrence} -> (hash, occurrence, header)) (fun (hash, occurrence, header) -> make hash header occurrence) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (* Occurrence has to come before header, because: (Invalid_argument "Cannot merge two objects when the left element is of @@ -123,7 +123,7 @@ module Block_seen_event = struct (Tag 1) (obj2 (req "occurrence-kind" (constant "valid-blocks")) - (req "chain-id" Chain_id.encoding)) + (req "chain-id" Tezos_crypto.Chain_id.encoding)) (function | `Valid_blocks ch -> Some ((), ch) | _ -> None) (fun ((), ch) -> `Valid_blocks ch); @@ -133,7 +133,7 @@ module Block_seen_event = struct With_version.(encoding ~name (first_version v0_encoding)) let pp ~short:_ ppf {hash; _} = - Format.fprintf ppf "Saw block %a" Block_hash.pp_short hash + Format.fprintf ppf "Saw block %a" Tezos_crypto.Block_hash.pp_short hash let doc = "Block observed while monitoring a blockchain." @@ -173,7 +173,7 @@ let monitor_heads cctxt ~next_protocols chain = type error += | Unexpected_empty_block_list of { chain : string; - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; length : int; } @@ -190,13 +190,13 @@ let () = "Unexpected empty block list retrieved from chain %s at block %a, \ length %d" chain - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash length) Data_encoding.( obj3 (req "chain" string) - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "length" int31)) (function | Unexpected_empty_block_list {chain; block_hash; length} -> diff --git a/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.mli b/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.mli index c3358f61f82f..07d582b6ed9b 100644 --- a/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.mli +++ b/src/proto_014_PtKathma/lib_delegate/client_baking_blocks.mli @@ -27,16 +27,16 @@ open Protocol open Alpha_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } val info : @@ -48,14 +48,14 @@ val info : val monitor_valid_blocks : #Protocol_client_context.rpc_context -> ?chains:Chain_services.chain list -> - ?protocols:Protocol_hash.t list -> - next_protocols:Protocol_hash.t list option -> + ?protocols:Tezos_crypto.Protocol_hash.t list -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> unit -> (block_info tzresult Lwt_stream.t * Tezos_rpc.Context.stopper) tzresult Lwt.t val monitor_heads : #Protocol_client_context.rpc_context -> - next_protocols:Protocol_hash.t list option -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> Chain_services.chain -> block_info tzresult Lwt_stream.t tzresult Lwt.t @@ -65,4 +65,4 @@ val blocks_from_current_cycle : Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_delegate/client_baking_denunciation.ml b/src/proto_014_PtKathma/lib_delegate/client_baking_denunciation.ml index 4f3638131307..784a4f38989f 100644 --- a/src/proto_014_PtKathma/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_014_PtKathma/lib_delegate/client_baking_denunciation.ml @@ -31,16 +31,16 @@ module Events = Delegate_events.Denunciator module B_Events = Delegate_events.Baking_scheduling module HLevel = Hashtbl.Make (struct - type t = Chain_id.t * Raw_level.t * Round.t + type t = Tezos_crypto.Chain_id.t * Raw_level.t * Round.t let equal (c, l, r) (c', l', r') = - Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' + Tezos_crypto.Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' let hash (c, lvl, r) = Hashtbl.hash (c, lvl, r) end) (* Blocks are associated to the delegates who baked them *) -module Delegate_Map = Map.Make (Signature.Public_key_hash) +module Delegate_Map = Map.Make (Tezos_crypto.Signature.Public_key_hash) (* (pre)endorsements are associated to the slot they are injected with; we rely on the fact that there is a unique canonical slot @@ -49,7 +49,8 @@ module Slot_Map = Slot.Map (* type of operations stream, as returned by monitor_operations RPC *) type ops_stream = - ((Operation_hash.t * packed_operation) * error trace option) list Lwt_stream.t + ((Tezos_crypto.Operation_hash.t * packed_operation) * error trace option) list + Lwt_stream.t type 'a state = { (* Endorsements seen so far *) @@ -57,7 +58,7 @@ type 'a state = { (* Preendorsements seen so far *) preendorsements_table : Kind.preendorsement operation Slot_Map.t HLevel.t; (* Blocks received so far *) - blocks_table : Block_hash.t Delegate_Map.t HLevel.t; + blocks_table : Tezos_crypto.Block_hash.t Delegate_Map.t HLevel.t; (* Maximum delta of level to register *) preserved_levels : int; (* Highest level seen in a block *) @@ -126,7 +127,7 @@ let double_consensus_op_evidence (type kind) : kind consensus_operation_type -> #Protocol_client_context.full -> 'a -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> op1:kind Alpha_context.operation -> op2:kind Alpha_context.operation -> unit -> @@ -159,7 +160,7 @@ let process_consensus_op (type kind) cctxt (Operation.hash new_op, Operation.hash existing_op) in let op1, op2 = - if Operation_hash.(new_op_hash < existing_op_hash) then + if Tezos_crypto.Operation_hash.(new_op_hash < existing_op_hash) then (new_op, existing_op) else (existing_op, new_op) in @@ -175,7 +176,9 @@ let process_consensus_op (type kind) cctxt ~op2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in let double_op_detected, double_op_denounced = Events.( match op_kind with @@ -271,7 +274,8 @@ let process_block (cctxt : #Protocol_client_context.full) state state.blocks_table (chain_id, level, round) (Delegate_Map.add baker new_hash map) - | Some existing_hash when Block_hash.(existing_hash = new_hash) -> + | Some existing_hash + when Tezos_crypto.Block_hash.(existing_hash = new_hash) -> (* This case should never happen *) Events.(emit double_baking_but_not) () >>= fun () -> return @@ -287,7 +291,8 @@ let process_block (cctxt : #Protocol_client_context.full) state let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in let bh1, bh2 = - if Block_hash.(hash1 < hash2) then (bh1, bh2) else (bh2, bh1) + if Tezos_crypto.Block_hash.(hash1 < hash2) then (bh1, bh2) + else (bh2, bh1) in (* If the blocks are on different chains then skip it *) get_block_offset level >>= fun block -> @@ -301,7 +306,9 @@ let process_block (cctxt : #Protocol_client_context.full) state ~bh2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Events.(emit double_baking_detected) () >>= fun () -> Shell_services.Injection.operation cctxt ~chain bytes >>=? fun op_hash -> @@ -346,7 +353,7 @@ let cleanup_old_operations state = *) let process_new_block (cctxt : #Protocol_client_context.full) state {hash; chain_id; level; protocol; next_protocol; _} = - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then Events.(emit protocol_change_detected) () >>= fun () -> return_unit else Events.(emit accuser_saw_block) (level, hash) >>= fun () -> diff --git a/src/proto_014_PtKathma/lib_delegate/client_daemon.ml b/src/proto_014_PtKathma/lib_delegate/client_daemon.ml index ba2cfdac03b3..836c95f1ad9a 100644 --- a/src/proto_014_PtKathma/lib_delegate/client_daemon.ml +++ b/src/proto_014_PtKathma/lib_delegate/client_daemon.ml @@ -91,7 +91,7 @@ module Baker = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> let canceler = Lwt_canceler.create () in @@ -121,7 +121,7 @@ module Accuser = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> Client_baking_blocks.monitor_valid_blocks @@ -159,7 +159,7 @@ module VDF = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash in let* chain_id = Shell_services.Chain.chain_id cctxt ~chain () in diff --git a/src/proto_014_PtKathma/lib_delegate/delegate_events.ml b/src/proto_014_PtKathma/lib_delegate/delegate_events.ml index 20f5d091dd9c..ca4361b2dc96 100644 --- a/src/proto_014_PtKathma/lib_delegate/delegate_events.ml +++ b/src/proto_014_PtKathma/lib_delegate/delegate_events.ml @@ -50,8 +50,8 @@ module Denunciator = struct ~level ~name:"double_endorsement_detected" ~msg:"double endorsement detected" - ("existing_endorsement", Operation_hash.encoding) - ("new_endorsement", Operation_hash.encoding) + ("existing_endorsement", Tezos_crypto.Operation_hash.encoding) + ("new_endorsement", Tezos_crypto.Operation_hash.encoding) let double_endorsement_denounced = declare_2 @@ -59,7 +59,7 @@ module Denunciator = struct ~level ~name:"double_endorsement_denounced" ~msg:"double endorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -69,8 +69,8 @@ module Denunciator = struct ~level ~name:"double_preendorsement_detected" ~msg:"double preendorsement detected" - ("existing_preendorsement", Operation_hash.encoding) - ("new_preendorsement", Operation_hash.encoding) + ("existing_preendorsement", Tezos_crypto.Operation_hash.encoding) + ("new_preendorsement", Tezos_crypto.Operation_hash.encoding) let double_preendorsement_denounced = declare_2 @@ -78,7 +78,7 @@ module Denunciator = struct ~level ~name:"double_preendorsement_denounced" ~msg:"double preendorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -88,7 +88,7 @@ module Denunciator = struct ~level:Error ~name:"inconsistent_endorsement" ~msg:"inconsistent endorsement found {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) let unexpected_pruned_block = declare_1 @@ -96,7 +96,7 @@ module Denunciator = struct ~level:Error ~name:"unexpected_pruned_block" ~msg:"unexpected pruned block: {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let double_baking_but_not = declare_0 @@ -120,7 +120,7 @@ module Denunciator = struct ~level ~name:"double_baking_denounced" ~msg:"double baking evidence injected {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -139,7 +139,7 @@ module Denunciator = struct ~name:"accuser_saw_block" ~msg:"block level: {level}" ("level", Alpha_context.Raw_level.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetch_operations_error = declare_1 @@ -147,8 +147,8 @@ module Denunciator = struct ~level:Error ~name:"fetch_operations_error" ~msg:"error while fetching operations of block {hash}" - ("hash", Block_hash.encoding) - ~pp1:Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp let accuser_processed_block = declare_1 @@ -156,7 +156,7 @@ module Denunciator = struct ~level ~name:"accuser_processed_block" ~msg:"block {hash} registered" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let accuser_block_error = declare_2 @@ -165,7 +165,7 @@ module Denunciator = struct ~name:"accuser_block_error" ~msg:"error while processing block {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) end diff --git a/src/proto_014_PtKathma/lib_delegate/logging.ml b/src/proto_014_PtKathma/lib_delegate/logging.ml index ed9cb18c9db3..6756e73e07e6 100644 --- a/src/proto_014_PtKathma/lib_delegate/logging.ml +++ b/src/proto_014_PtKathma/lib_delegate/logging.ml @@ -147,9 +147,9 @@ let conflicting_endorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) let conflicting_preendorsements_tag = @@ -161,7 +161,7 @@ let conflicting_preendorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) diff --git a/src/proto_014_PtKathma/lib_delegate/node_rpc.ml b/src/proto_014_PtKathma/lib_delegate/node_rpc.ml index badb4fc204d4..96749ae7c4de 100644 --- a/src/proto_014_PtKathma/lib_delegate/node_rpc.ml +++ b/src/proto_014_PtKathma/lib_delegate/node_rpc.ml @@ -70,7 +70,9 @@ let raw_info cctxt ~chain ~block_hash shell payload_hash payload_round >>= fun () -> let open Protocol_client_context in let block = `Hash (block_hash, 0) in - let is_in_protocol = Protocol_hash.(current_protocol = Protocol.hash) in + let is_in_protocol = + Tezos_crypto.Protocol_hash.(current_protocol = Protocol.hash) + in (if is_in_protocol then Alpha_block_services.Operations.operations cctxt ~chain ~block () >>=? fun operations -> @@ -121,7 +123,7 @@ let info cctxt ~chain ~block () = (* Fails if the block's protocol is not the current one *) Shell_services.Blocks.protocols cctxt ~chain ~block () >>=? fun {current_protocol; next_protocol} -> - (if Protocol_hash.(current_protocol <> Protocol.hash) then + (if Tezos_crypto.Protocol_hash.(current_protocol <> Protocol.hash) then Block_services.Header.shell_header cctxt ~chain ~block () >>=? fun shell -> Chain_services.Blocks.Header.raw_protocol_data cctxt ~chain ~block () >>=? fun protocol_data -> @@ -155,7 +157,7 @@ let info cctxt ~chain ~block () = (Chain_services.Blocks.live_blocks cctxt ~chain ~block () >>= function | Error _ -> (* The RPC might fail when a block's metadata is not available *) - Lwt.return Block_hash.Set.empty + Lwt.return Tezos_crypto.Block_hash.Set.empty | Ok live_blocks -> Lwt.return live_blocks) >>= fun live_blocks -> raw_info diff --git a/src/proto_014_PtKathma/lib_delegate/node_rpc.mli b/src/proto_014_PtKathma/lib_delegate/node_rpc.mli index 2dd0468ef6f1..55694e129b55 100644 --- a/src/proto_014_PtKathma/lib_delegate/node_rpc.mli +++ b/src/proto_014_PtKathma/lib_delegate/node_rpc.mli @@ -37,13 +37,13 @@ val inject_block : chain:Shell_services.chain -> Block_header.t -> Tezos_base.Operation.t list list -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t (** Preapply a block using the node validation mechanism.*) val preapply_block : #Protocol_client_context.full -> chain:Shell_services.chain -> - head:Block_hash.t -> + head:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> protocol_data:Protocol.block_header_data -> packed_operation list list -> @@ -58,7 +58,7 @@ val proposal : #Tezos_rpc.Context.simple -> ?cache:Baking_state.block_info Baking_cache.Block_cache.t -> chain:Shell_services.chain -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Baking_state.proposal tzresult Lwt.t (** Monitor proposals from the node.*) diff --git a/src/proto_014_PtKathma/lib_delegate/operation_pool.ml b/src/proto_014_PtKathma/lib_delegate/operation_pool.ml index 12de099b1458..0da51b24a2b1 100644 --- a/src/proto_014_PtKathma/lib_delegate/operation_pool.ml +++ b/src/proto_014_PtKathma/lib_delegate/operation_pool.ml @@ -41,7 +41,7 @@ let compare_op op1 op2 = (* FIXME some operations (e.g. tx_rollup_rejection) pack functional values which could raise an exception. In this specific case, we default to comparing their hashes. *) - Operation_hash.compare + Tezos_crypto.Operation_hash.compare (Alpha_context.Operation.hash_packed op1) (Alpha_context.Operation.hash_packed op2) diff --git a/src/proto_014_PtKathma/lib_delegate/operation_selection.ml b/src/proto_014_PtKathma/lib_delegate/operation_selection.ml index 7747a09a8aa2..eec3576100de 100644 --- a/src/proto_014_PtKathma/lib_delegate/operation_selection.ml +++ b/src/proto_014_PtKathma/lib_delegate/operation_selection.ml @@ -57,7 +57,9 @@ module PrioritizedManagerSet = Set.Make (struct let compare {source; counter; weight; op; _} {source = source'; counter = counter'; weight = weight'; op = op'; _} = (* Be careful with the [compare] *) - let cmp_src = Signature.Public_key_hash.compare source source' in + let cmp_src = + Tezos_crypto.Signature.Public_key_hash.compare source source' + in if cmp_src = 0 then (* we want the smallest counter first *) let c = Z.compare counter counter' in @@ -163,7 +165,7 @@ type simulation_result = { validation_result : Tezos_protocol_environment.validation_result; block_header_metadata : block_header_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } let validate_operation inc op = @@ -248,10 +250,11 @@ let filter_operations_with_simulation initial_inc fees_config >>= fun (inc, managers) -> let operations = [consensus; votes; anonymous; managers] in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in let inc = {inc with header = {inc.header with operations_hash}} in diff --git a/src/proto_014_PtKathma/lib_delegate/operation_selection.mli b/src/proto_014_PtKathma/lib_delegate/operation_selection.mli index 78caab5c158c..3ab72a91347c 100644 --- a/src/proto_014_PtKathma/lib_delegate/operation_selection.mli +++ b/src/proto_014_PtKathma/lib_delegate/operation_selection.mli @@ -31,7 +31,7 @@ type simulation_result = { validation_result : validation_result; block_header_metadata : Apply_results.block_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } val filter_operations_with_simulation : diff --git a/src/proto_014_PtKathma/lib_delegate/operation_worker.ml b/src/proto_014_PtKathma/lib_delegate/operation_worker.ml index 66cec5723476..5589f585649f 100644 --- a/src/proto_014_PtKathma/lib_delegate/operation_worker.ml +++ b/src/proto_014_PtKathma/lib_delegate/operation_worker.ml @@ -145,7 +145,7 @@ module Events = struct end type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } @@ -158,7 +158,7 @@ let candidate_encoding = (fun (hash, round_watched, payload_hash_watched) -> {hash; round_watched; payload_hash_watched}) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "round_watched" Round.encoding) (req "payload_hash_watched" Block_payload_hash.encoding)) @@ -539,7 +539,8 @@ let retrieve_pending_operations cctxt state = state.operation_pool (List.rev_map (fun (_, (op, _)) -> op) - (Operation_hash.Map.bindings pending_mempool.branch_delayed)) ; + (Tezos_crypto.Operation_hash.Map.bindings + pending_mempool.branch_delayed)) ; return_unit let get_current_operations state = state.operation_pool diff --git a/src/proto_014_PtKathma/lib_delegate/operation_worker.mli b/src/proto_014_PtKathma/lib_delegate/operation_worker.mli index eecbc990f2d1..ab66270bfd91 100644 --- a/src/proto_014_PtKathma/lib_delegate/operation_worker.mli +++ b/src/proto_014_PtKathma/lib_delegate/operation_worker.mli @@ -34,7 +34,7 @@ open Alpha_context type t type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } diff --git a/src/proto_014_PtKathma/lib_delegate/state_transitions.ml b/src/proto_014_PtKathma/lib_delegate/state_transitions.ml index dd978072e535..66d906850ba8 100644 --- a/src/proto_014_PtKathma/lib_delegate/state_transitions.ml +++ b/src/proto_014_PtKathma/lib_delegate/state_transitions.ml @@ -47,8 +47,9 @@ let is_acceptable_proposal_for_current_level state let previous_proposal = state.level_state.latest_proposal in if Round.(proposal.block.round = previous_proposal.block.round) - && Block_hash.(proposal.block.hash <> previous_proposal.block.hash) - && Block_hash.( + && Tezos_crypto.Block_hash.( + proposal.block.hash <> previous_proposal.block.hash) + && Tezos_crypto.Block_hash.( proposal.predecessor.hash = previous_proposal.predecessor.hash) then (* An existing proposal was found at the same round: the @@ -117,7 +118,9 @@ let may_update_proposal state (proposal : proposal) = else Lwt.return state let preendorse state proposal = - if Protocol_hash.(proposal.block.protocol <> proposal.block.next_protocol) + if + Tezos_crypto.Protocol_hash.( + proposal.block.protocol <> proposal.block.next_protocol) then (* We do not preendorse the first transition block *) let new_round_state = {state.round_state with current_phase = Idle} in @@ -200,7 +203,7 @@ let rec handle_new_proposal state (new_proposal : proposal) = let's check if it's a valid one for us. *) let current_proposal = state.level_state.latest_proposal in if - Block_hash.( + Tezos_crypto.Block_hash.( current_proposal.predecessor.hash <> new_proposal.predecessor.hash) then Events.( @@ -534,7 +537,8 @@ let end_of_round state current_round = do_nothing new_state | Some (delegate, _) -> let last_proposal = state.level_state.latest_proposal.block in - if Protocol_hash.(last_proposal.protocol <> Protocol.hash) then + if Tezos_crypto.Protocol_hash.(last_proposal.protocol <> Protocol.hash) + then (* Do not inject a block for the previous protocol! (Let the baker of the previous protocol do it.) *) do_nothing new_state @@ -606,7 +610,9 @@ let make_endorse_action state proposal = let prequorum_reached_when_awaiting_preendorsements state candidate preendorsements = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit @@ -646,7 +652,9 @@ let prequorum_reached_when_awaiting_preendorsements state candidate let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit diff --git a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_client_context.ml b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_client_context.ml index ededa688a755..cc090580cdb0 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_client_context.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_client_context.ml @@ -46,8 +46,8 @@ let log _channel msg = print_endline msg ; Lwt.return_unit -class faked_ctxt (hooks : Faked_services.hooks) (chain_id : Chain_id.t) : - Tezos_rpc.Context.generic = +class faked_ctxt (hooks : Faked_services.hooks) + (chain_id : Tezos_crypto.Chain_id.t) : Tezos_rpc.Context.generic = let local_ctxt = let module Services = Faked_services.Make ((val hooks)) in Tezos_mockup_proxy.RPC_client.local_ctxt (Services.directory chain_id) diff --git a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_services.ml index 907d280256fc..ee21b96b07c2 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/faked_services.ml @@ -10,7 +10,7 @@ module type Mocked_services_hooks = sig (** The baker and endorser rely on this stream to be notified of new blocks. *) val monitor_heads : - unit -> (Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream + unit -> (Tezos_crypto.Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream (** Returns current and next protocol for a block. *) val protocols : @@ -30,14 +30,15 @@ module type Mocked_services_hooks = sig [Tezos_shell_services.Injection_services.S.block], after checking that the block header can be deserialized. *) val inject_block : - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t (** [inject_operation] is used by the endorser (or the client) to inject operations, including endorsements. *) - val inject_operation : Operation.t -> Operation_hash.t tzresult Lwt.t + val inject_operation : + Operation.t -> Tezos_crypto.Operation_hash.t tzresult Lwt.t (** [pending_operations] returns the current contents of the mempool. It is used by the baker to fetch operations to potentially include in the @@ -54,7 +55,9 @@ module type Mocked_services_hooks = sig branch_delayed:bool -> branch_refused:bool -> refused:bool -> - ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list + ((Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) + * error trace option) + list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -62,15 +65,16 @@ module type Mocked_services_hooks = sig chain. Optional arguments allow to return the list of predecessors of a given block or of a set of blocks. *) val list_blocks : - heads:Block_hash.t list -> + heads:Tezos_crypto.Block_hash.t list -> length:int option -> min_date:Time.Protocol.t option -> - Block_hash.t list list tzresult Lwt.t + Tezos_crypto.Block_hash.t list list tzresult Lwt.t (** List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block. *) - val live_blocks : Block_services.block -> Block_hash.Set.t tzresult Lwt.t + val live_blocks : + Block_services.block -> Tezos_crypto.Block_hash.Set.t tzresult Lwt.t (** [rpc_context_callback] is used in the implementations of several RPCs (see local_services.ml). It should correspond to the @@ -87,7 +91,7 @@ module type Mocked_services_hooks = sig to all nodes. *) val broadcast_block : ?dests:int list -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t @@ -102,7 +106,8 @@ module type Mocked_services_hooks = sig simulated node is already bootstrapped, returns the current head immediately. *) val monitor_bootstrapped : - unit -> (Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream + unit -> + (Tezos_crypto.Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream end type hooks = (module Mocked_services_hooks) @@ -183,7 +188,7 @@ module Make (Hooks : Mocked_services_hooks) = struct match Block_header.of_bytes bytes with | None -> failwith "faked_services.inject_block: can't deserialize" | Some block_header -> - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in Hooks.inject_block block_hash block_header operations >>=? fun () -> return block_hash) @@ -202,7 +207,7 @@ module Make (Hooks : Mocked_services_hooks) = struct Broadcast_services.S.block (fun () dests (block_header, operations) -> let bytes = Block_header.to_bytes block_header in - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in let dests = match dests#dests with [] -> None | dests -> Some dests in Hooks.broadcast_block ?dests block_hash block_header operations) diff --git a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.ml index aa61c543da1b..2e739c50fc34 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -35,8 +35,10 @@ type chain = block list (** As new blocks and operations are received they are pushed to an Lwt_pipe wrapped into this type. *) type broadcast = - | Broadcast_block of Block_hash.t * Block_header.t * Operation.t list list - | Broadcast_op of Operation_hash.t * Alpha_context.packed_operation + | Broadcast_block of + Tezos_crypto.Block_hash.t * Block_header.t * Operation.t list list + | Broadcast_op of + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation (** The state of a mockup node. *) type state = { @@ -46,29 +48,33 @@ type state = { live_depth : int; (** How many blocks (counting from the head into the past) are considered live? *) mutable chain : chain; (** The chain as seen by this fake "node". *) - mutable mempool : (Operation_hash.t * Mockup.M.Protocol.operation) list; + mutable mempool : + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list; (** Mempool of this fake "node". *) - chain_table : chain Block_hash.Table.t; + chain_table : chain Tezos_crypto.Block_hash.Table.t; (** The chain table of this fake "node". It maps from block hashes to blocks. *) - global_chain_table : block Block_hash.Table.t; + global_chain_table : block Tezos_crypto.Block_hash.Table.t; (** The global chain table that allows us to look up blocks that may be missing in [chain_table], i.e. not known to this particular node. This 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 : Tezos_protocol_environment.rpc_context Context_hash.Table.t; + ctxt_table : + Tezos_protocol_environment.rpc_context Tezos_crypto.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 : + (Tezos_crypto.Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) operations_pipe : - (Operation_hash.t * Mockup.M.Protocol.operation) option Lwt_pipe.Unbounded.t; + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) option + Lwt_pipe.Unbounded.t; (** [operations_pipe] is used to implement the [operations_pipe] RPC. *) mutable streaming_operations : bool; (** A helper flag used to implement the monitor operations RPC. *) broadcast_pipes : broadcast Lwt_pipe.Unbounded.t list; (** Broadcast pipes per node. *) - genesis_block_true_hash : Block_hash.t; + genesis_block_true_hash : Tezos_crypto.Block_hash.t; (** True hash of the genesis block as calculated by the [Block_header.hash] function. *) @@ -76,13 +82,13 @@ type state = { let accounts = Mockup.Protocol_parameters.default_value.bootstrap_accounts -let chain_id = Chain_id.of_string_exn "main" +let chain_id = Tezos_crypto.Chain_id.of_string_exn "main" let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" -let genesis_predecessor_block_hash = Block_hash.zero +let genesis_predecessor_block_hash = Tezos_crypto.Block_hash.zero type propagation = Block | Pass | Delay of float @@ -92,34 +98,40 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -128,7 +140,7 @@ module type Hooks = sig level:int32 -> round:int32 -> chain:chain -> unit tzresult Lwt.t val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t val stop_on_event : Baking_state.event -> bool @@ -149,9 +161,12 @@ let locate_blocks (state : state) block list tzresult Lwt.t = match block with | `Hash (hash, rel) -> ( - match Block_hash.Table.find state.chain_table hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table hash with | None -> - failwith "locate_blocks: can't find the block %a" Block_hash.pp hash + failwith + "locate_blocks: can't find the block %a" + Tezos_crypto.Block_hash.pp + hash | Some chain0 -> let _, chain = List.split_n rel chain0 in return chain) @@ -177,8 +192,8 @@ let live_blocks (state : state) block = (List.fold_left (fun set ({rpc_context; _} : block) -> 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) + Tezos_crypto.Block_hash.Set.add hash set) + (Tezos_crypto.Block_hash.Set.singleton state.genesis_block_true_hash) segment) (** Extract the round number from raw fitness. *) @@ -272,25 +287,27 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : match block with | `Hash (requested_hash, rel) -> Int.equal rel 0 - && Block_hash.equal requested_hash genesis_predecessor_block_hash + && Tezos_crypto.Block_hash.equal + requested_hash + genesis_predecessor_block_hash | _ -> false in (* It is important to tell the baker that the genesis block is not in - the alpha protocol (we use Protocol_hash.zero). This will make the + the alpha protocol (we use Tezos_crypto.Protocol_hash.zero). This will make the baker not try to propose alternatives to that block and just accept - it as final in that Protocol_hash.zero protocol. The same for - predecessor of genesis, it should be in Protocol_hash.zero. *) + it as final in that Tezos_crypto.Protocol_hash.zero protocol. The same for + predecessor of genesis, it should be in Tezos_crypto.Protocol_hash.zero. *) return Tezos_shell_services.Block_services. { current_protocol = (if - Block_hash.equal hash genesis_block_hash + Tezos_crypto.Block_hash.equal hash genesis_block_hash || is_predecessor_of_genesis - then Protocol_hash.zero + then Tezos_crypto.Protocol_hash.zero else Protocol.hash); next_protocol = - (if is_predecessor_of_genesis then Protocol_hash.zero + (if is_predecessor_of_genesis then Tezos_crypto.Protocol_hash.zero else Protocol.hash); } @@ -387,11 +404,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : Mockup.M.Block_services.Mempool. { applied = ops; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; - unprocessed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; + unprocessed = Tezos_crypto.Operation_hash.Map.empty; } let monitor_operations ~applied ~branch_delayed ~branch_refused ~refused = @@ -471,11 +488,12 @@ let clear_mempool state = (fun (_oph, (op : Mockup.M.Protocol.operation)) -> let included_in_head = List.mem - ~equal:Operation_hash.equal + ~equal:Tezos_crypto.Operation_hash.equal (Alpha_context.Operation.hash_packed op) included_ops_hashes in - Block_hash.Set.mem op.shell.branch live_set && not included_in_head) + Tezos_crypto.Block_hash.Set.mem op.shell.branch live_set + && not included_in_head) state.mempool in state.mempool <- mempool ; @@ -510,7 +528,7 @@ let reconstruct_context (rpc_context : Tezos_protocol_environment.rpc_context) validation_state (* The operation hash argument is ignored in protocol environment versions < V7. *) - Operation_hash.zero + Tezos_crypto.Operation_hash.zero op >>=? fun (validation_state, receipt) -> return (validation_state, receipt :: results))) @@ -529,13 +547,17 @@ let rec process_block state block_hash (block_header : Block_header.t) let get_predecessor () = let predecessor_hash = block_header.Block_header.shell.predecessor in head state >>=? fun head -> - match Block_hash.Table.find state.chain_table predecessor_hash with + match + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash + with | None | Some [] -> ( (* Even if the predecessor is not known locally, it might be known by some node in the network. The code below "requests" information about the block by its hash. *) match - Block_hash.Table.find state.global_chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find + state.global_chain_table + predecessor_hash with | None -> failwith "get_predecessor: unknown predecessor block" | Some predecessor -> @@ -578,7 +600,7 @@ let rec process_block state block_hash (block_header : Block_header.t) then return predecessor else failwith "get_predecessor: the predecessor block is too old" in - match Block_hash.Table.find state.chain_table block_hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table block_hash with | Some _ -> (* The block is already known. *) return_unit @@ -596,7 +618,7 @@ let rec process_block state block_hash (block_header : Block_header.t) (fun pass -> List.map (fun (Operation.{shell; proto} as op) -> - let hash : Operation_hash.t = Operation.hash op in + let hash : Tezos_crypto.Operation_hash.t = Operation.hash op in let protocol_data : Alpha_context.packed_protocol_data = Data_encoding.Binary.of_bytes_exn Protocol.operation_data_encoding @@ -623,13 +645,19 @@ let rec process_block state block_hash (block_header : Block_header.t) in let predecessor_hash = block_header.Block_header.shell.predecessor in let tail = - Block_hash.Table.find state.chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash |> WithExceptions.Option.get ~loc:__LOC__ in let new_chain = new_block :: tail in - Block_hash.Table.replace state.chain_table block_hash new_chain ; - Block_hash.Table.replace state.global_chain_table block_hash new_block ; - Context_hash.Table.replace + Tezos_crypto.Block_hash.Table.replace + state.chain_table + block_hash + new_chain ; + Tezos_crypto.Block_hash.Table.replace + state.global_chain_table + block_hash + new_block ; + Tezos_crypto.Context_hash.Table.replace state.ctxt_table rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; @@ -718,7 +746,7 @@ let create_fake_node_state ~i ~live_depth mempool = []; chain = chain0; chain_table = - Block_hash.Table.of_seq + Tezos_crypto.Block_hash.Table.of_seq (List.to_seq [ (rpc_context0.block_hash, chain0); @@ -727,7 +755,7 @@ let create_fake_node_state ~i ~live_depth ]); global_chain_table; ctxt_table = - Context_hash.Table.of_seq + Tezos_crypto.Context_hash.Table.of_seq (List.to_seq [ ( rpc_context0.Tezos_protocol_environment.block_header @@ -787,7 +815,7 @@ let baker_process ~(delegates : Baking_state.delegate list) ~base_dir { checkout_fun = (fun hash -> - Context_hash.Table.find state.ctxt_table hash + Tezos_crypto.Context_hash.Table.find state.ctxt_table hash |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; @@ -807,13 +835,13 @@ let baker_process ~(delegates : Baking_state.delegate list) ~base_dir Lwt.pick [listener_process (); baker_process ()] >>=? fun () -> User_hooks.check_chain_on_success ~chain:state.chain -let genesis_protocol_data (baker_sk : Signature.secret_key) - (predecessor_block_hash : Block_hash.t) +let genesis_protocol_data (baker_sk : Tezos_crypto.Signature.secret_key) + (predecessor_block_hash : Tezos_crypto.Block_hash.t) (block_header : Block_header.shell_header) : Bytes.t = let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in - let operation_list_hash = Operation_list_hash.compute [] in + let operation_list_hash = Tezos_crypto.Operation_list_hash.compute [] in let payload_hash = Protocol.Alpha_context.Block_payload.hash ~predecessor:predecessor_block_hash @@ -837,7 +865,7 @@ let genesis_protocol_data (baker_sk : Signature.secret_key) (block_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) baker_sk @@ -853,7 +881,7 @@ let deduce_baker_sk (Protocol.Alpha_context.Parameters.bootstrap_account * Tezos_mockup_commands.Mockup_wallet.bootstrap_secret) list) (total_accounts : int) (level : int) : - Signature.secret_key tzresult Lwt.t = + Tezos_crypto.Signature.secret_key tzresult Lwt.t = (match (total_accounts, level) with | _, 0 -> return 0 (* apparently this doesn't really matter *) | _ -> @@ -868,7 +896,8 @@ let deduce_baker_sk |> WithExceptions.Option.get ~loc:__LOC__ in let secret_key = - Signature.Secret_key.of_b58check_exn (Uri.path (secret.sk_uri :> Uri.t)) + Tezos_crypto.Signature.Secret_key.of_b58check_exn + (Uri.path (secret.sk_uri :> Uri.t)) in return secret_key @@ -1043,7 +1072,8 @@ type config = { round0 : int64; round1 : int64; timeout : int; - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; initial_seed : State_hash.t option; consensus_committee_size : int; consensus_threshold : int; @@ -1104,7 +1134,7 @@ let run ?(config = default_config) bakers_spec = | Error () -> failwith "impossible: negative length of the baker spec" | Ok xs -> return xs) >>=? fun broadcast_pipes -> - let global_chain_table = Block_hash.Table.create 10 in + let global_chain_table = Tezos_crypto.Block_hash.Table.create 10 in Tezos_mockup_commands.Mockup_wallet.default_bootstrap_accounts >>=? fun bootstrap_secrets -> let accounts_with_secrets = @@ -1179,7 +1209,7 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) (block_header.shell, protocol_data.contents) in if - Signature.check + Tezos_crypto.Signature.check ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) public_key @@ -1189,13 +1219,15 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) else failwith "unexpected signature for %a; tried with %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp public_key type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t let mempool_count_ops ~mempool ~predicate = List.map_es (fun (op_hash, op) -> predicate op_hash op) mempool @@ -1214,7 +1246,7 @@ let mempool_has_op_ref ~mempool ~predicate ~var = if result then var := true ; return_unit -let op_is_signed_by ~public_key (op_hash : Operation_hash.t) +let op_is_signed_by ~public_key (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1226,14 +1258,18 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) Alpha_context.Operation.to_watermark (Endorsement chain_id) | Preendorsement _ -> Alpha_context.Operation.to_watermark (Preendorsement chain_id) - | _ -> Signature.Generic_operation) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> Tezos_crypto.Signature.Generic_operation) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) >>=? fun watermark -> match d.signature with | None -> failwith "did not find a signature for op %a@." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash | Some signature -> let unsigned_operation_bytes = @@ -1242,13 +1278,13 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) (op.shell, Contents_list d.contents) in return - (Signature.check + (Tezos_crypto.Signature.check ~watermark public_key signature unsigned_operation_bytes)) -let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_preendorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1274,9 +1310,13 @@ let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) -let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_endorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1302,7 +1342,11 @@ let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) let op_is_both f g op_hash op = f op_hash op >>=? fun f_result -> diff --git a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.mli index b2119bf6d177..a541c900fe5b 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_014_PtKathma/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -56,20 +56,25 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t (** This function is called on injection of an operation. It is similar to [on_inject_block], which see. *) val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t @@ -77,22 +82,23 @@ module type Hooks = sig a "monitor heads" RPC call. Returning [None] here terminates the process for the baker. *) val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t (** This is called when a new operation is going to be sent as the response to a "monitor operations" RPC call. Returning [None] here indicates that the node has advanced to the next level. *) val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t (** Check a block before processing it in the mockup. *) val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -103,7 +109,7 @@ module type Hooks = sig (** Check operations in the mempool after injecting an operation. *) val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t (** This hook is used to decide when the baker is supposed to shut down. @@ -138,7 +144,8 @@ type config = { (** Maximal duration of the test. If the test takes longer to terminate it'll be aborted with an error. *) - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; (** Desired selection of delegates per level/round *) initial_seed : State_hash.t option; (** Optional initial seed for protocol (used to control delegate selection) *) @@ -170,51 +177,54 @@ val default_config : config to the final result. *) val run : ?config:config -> (int * (module Hooks)) list -> unit tzresult Lwt.t -val bootstrap1 : Signature.public_key +val bootstrap1 : Tezos_crypto.Signature.public_key -val bootstrap2 : Signature.public_key +val bootstrap2 : Tezos_crypto.Signature.public_key -val bootstrap3 : Signature.public_key +val bootstrap3 : Tezos_crypto.Signature.public_key -val bootstrap4 : Signature.public_key +val bootstrap4 : Tezos_crypto.Signature.public_key -val bootstrap5 : Signature.public_key +val bootstrap5 : Tezos_crypto.Signature.public_key (** Check if a block header is signed by a given delegate. *) val check_block_signature : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - public_key:Signature.public_key -> + public_key:Tezos_crypto.Signature.public_key -> unit tzresult Lwt.t (** A shortcut type for predicates on operations. *) type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t (** Count the number of operations in the mempool that satisfy the given predicate. *) val mempool_count_ops : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> int tzresult Lwt.t (** Check if the mempool has at least one operation that satisfies the given predicate. *) val mempool_has_op : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> bool tzresult Lwt.t (** Similar to [mempool_has_op] but instead of returning a [bool] it sets the given [bool ref]. *) val mempool_has_op_ref : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> var:bool ref -> unit tzresult Lwt.t (** Check if an operation is signed by the given delegate. *) -val op_is_signed_by : public_key:Signature.public_key -> op_predicate +val op_is_signed_by : + public_key:Tezos_crypto.Signature.public_key -> op_predicate (** Check that an operation is a preendorsement. *) val op_is_preendorsement : ?level:int32 -> ?round:int32 -> op_predicate diff --git a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.ml b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.ml index a27b9381426c..54054d23b97e 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.ml @@ -26,7 +26,9 @@ open Protocol type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list module LevelRoundMap = Map.Make (struct type t = Level_repr.t * Round_repr.t @@ -103,7 +105,8 @@ let check ctxt ~selection = Delegate_storage.baking_rights_owner ctxt level ~round >|= Environment.wrap_tzresult >>=? fun (ctxt, _, (_, pkh)) -> - if not (Signature.Public_key_hash.equal delegate pkh) then raise Exit + if not (Tezos_crypto.Signature.Public_key_hash.equal delegate pkh) + then raise Exit else return ctxt) selection ctxt diff --git a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.mli b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.mli index 7b6915d2cfd2..c13cc23edb60 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.mli +++ b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/lib/tenderbrute.mli @@ -29,7 +29,9 @@ open Protocol one can provide a public key hash that would be the proposer. All non- specified level and rounds are not constrained. *) type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list (** Brute-force an initial seed nonce for the desired delegate selection. When found, the seed nonce is returned as a byte sequence of size 32. If diff --git a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/tenderbrute_main.ml b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/tenderbrute_main.ml index f3558b1a1985..123db4e59248 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/tenderbrute_main.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/tenderbrute/tenderbrute_main.ml @@ -49,7 +49,7 @@ let delegate_encoding = case ~title:"Public key hash" (Tag 0) - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding (function `Pkh p -> Some p | _ -> None) (fun p -> `Pkh p); case diff --git a/src/proto_014_PtKathma/lib_delegate/test/test_scenario.ml b/src/proto_014_PtKathma/lib_delegate/test/test_scenario.ml index 7543a2b1ab28..f10b60904c24 100644 --- a/src/proto_014_PtKathma/lib_delegate/test/test_scenario.ml +++ b/src/proto_014_PtKathma/lib_delegate/test/test_scenario.ml @@ -1,14 +1,14 @@ open Mockup_simulator -let bootstrap1 = Signature.Public_key.hash bootstrap1 +let bootstrap1 = Tezos_crypto.Signature.Public_key.hash bootstrap1 -let bootstrap2 = Signature.Public_key.hash bootstrap2 +let bootstrap2 = Tezos_crypto.Signature.Public_key.hash bootstrap2 -let bootstrap3 = Signature.Public_key.hash bootstrap3 +let bootstrap3 = Tezos_crypto.Signature.Public_key.hash bootstrap3 -let bootstrap4 = Signature.Public_key.hash bootstrap4 +let bootstrap4 = Tezos_crypto.Signature.Public_key.hash bootstrap4 -let bootstrap5 = Signature.Public_key.hash bootstrap5 +let bootstrap5 = Tezos_crypto.Signature.Public_key.hash bootstrap5 let some_seed s = Some (Protocol.State_hash.of_b58check_exn s) diff --git a/src/proto_014_PtKathma/lib_injector/common.ml b/src/proto_014_PtKathma/lib_injector/common.ml index 1fd54ccb49e3..3612ecfafb28 100644 --- a/src/proto_014_PtKathma/lib_injector/common.ml +++ b/src/proto_014_PtKathma/lib_injector/common.ml @@ -27,8 +27,8 @@ open Protocol_client_context type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -68,7 +68,7 @@ let tezos_reorg fetch_tezos_block ~old_head_hash ~new_head_hash = let open Alpha_block_services in let open Lwt_result_syntax in let rec loop old_chain new_chain old_head_hash new_head_hash = - if Block_hash.(old_head_hash = new_head_hash) then + if Tezos_crypto.Block_hash.(old_head_hash = new_head_hash) then return {old_chain = List.rev old_chain; new_chain = List.rev new_chain} else let* new_head = fetch_tezos_block new_head_hash in diff --git a/src/proto_014_PtKathma/lib_injector/common.mli b/src/proto_014_PtKathma/lib_injector/common.mli index a1f4a55e2c7d..bff16a3f72e1 100644 --- a/src/proto_014_PtKathma/lib_injector/common.mli +++ b/src/proto_014_PtKathma/lib_injector/common.mli @@ -28,8 +28,8 @@ open Protocol_client_context (** The type of signers for operations injected by the injector *) type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -44,7 +44,9 @@ type 'block reorg = { (** Retrieve a signer from the client wallet. *) val get_signer : - #Client_context.wallet -> Signature.public_key_hash -> signer tzresult Lwt.t + #Client_context.wallet -> + Tezos_crypto.Signature.public_key_hash -> + signer tzresult Lwt.t val no_reorg : 'a reorg @@ -57,18 +59,18 @@ type block_info := Alpha_block_services.block_info it from the L1 node otherwise. *) val fetch_tezos_block : find_in_cache: - (Block_hash.t -> - (Block_hash.t -> block_info tzresult Lwt.t) -> + (Tezos_crypto.Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> block_info tzresult Lwt.t) -> #full -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t (** [tezos_reorg fetch ~old_head_hash ~new_head_hash] computes the reorganization of L1 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) val tezos_reorg : - (Block_hash.t -> block_info tzresult Lwt.t) -> - old_head_hash:Block_hash.t -> - new_head_hash:Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> + old_head_hash:Tezos_crypto.Block_hash.t -> + new_head_hash:Tezos_crypto.Block_hash.t -> block_info reorg tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_injector/disk_persistence.ml b/src/proto_014_PtKathma/lib_injector/disk_persistence.ml index 20565456cb64..f82914fa5d9d 100644 --- a/src/proto_014_PtKathma/lib_injector/disk_persistence.ml +++ b/src/proto_014_PtKathma/lib_injector/disk_persistence.ml @@ -276,7 +276,7 @@ end module Make_queue (N : sig val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_014_PtKathma/lib_injector/disk_persistence.mli b/src/proto_014_PtKathma/lib_injector/disk_persistence.mli index 7412450d251c..6e37f06fe507 100644 --- a/src/proto_014_PtKathma/lib_injector/disk_persistence.mli +++ b/src/proto_014_PtKathma/lib_injector/disk_persistence.mli @@ -106,7 +106,7 @@ module Make_queue (N : sig to store the persistent information for this queue. *) val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_014_PtKathma/lib_injector/dune b/src/proto_014_PtKathma/lib_injector/dune index 8e2bcd8ab9a6..07db8fb6ec28 100644 --- a/src/proto_014_PtKathma/lib_injector/dune +++ b/src/proto_014_PtKathma/lib_injector/dune @@ -25,7 +25,6 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_crypto -open Tezos_protocol_014_PtKathma -open Tezos_micheline -open Tezos_client_014_PtKathma diff --git a/src/proto_014_PtKathma/lib_injector/injector_errors.ml b/src/proto_014_PtKathma/lib_injector/injector_errors.ml index f263920da56a..e638807b5154 100644 --- a/src/proto_014_PtKathma/lib_injector/injector_errors.ml +++ b/src/proto_014_PtKathma/lib_injector/injector_errors.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t let () = register_error_kind @@ -35,10 +35,11 @@ let () = Format.fprintf ppf "No worker for source %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp s) `Permanent - Data_encoding.(obj1 (req "source" Signature.Public_key_hash.encoding)) + Data_encoding.( + obj1 (req "source" Tezos_crypto.Signature.Public_key_hash.encoding)) (function No_worker_for_source s -> Some s | _ -> None) (fun s -> No_worker_for_source s) diff --git a/src/proto_014_PtKathma/lib_injector/injector_errors.mli b/src/proto_014_PtKathma/lib_injector/injector_errors.mli index 4745709f70d0..ac6a07279657 100644 --- a/src/proto_014_PtKathma/lib_injector/injector_errors.mli +++ b/src/proto_014_PtKathma/lib_injector/injector_errors.mli @@ -25,7 +25,7 @@ (** Error when the injector has no worker for the source which must inject an operation. *) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t (** Error when the injector has no worker for the tag of the operation to be injected. *) diff --git a/src/proto_014_PtKathma/lib_injector/injector_events.ml b/src/proto_014_PtKathma/lib_injector/injector_events.ml index 71c8c70cada1..7fbfdd1fd99b 100644 --- a/src/proto_014_PtKathma/lib_injector/injector_events.ml +++ b/src/proto_014_PtKathma/lib_injector/injector_events.ml @@ -37,10 +37,10 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 @@ -50,11 +50,11 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -65,12 +65,12 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 enc3 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -113,7 +113,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"new_tezos_head" ~msg:"processing new Tezos head {head}" ~level:Debug - ("head", Block_hash.encoding) + ("head", Tezos_crypto.Block_hash.encoding) let injecting_pending = declare_1 @@ -168,7 +168,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"injected" ~msg:"Injected in {oph}" ~level:Notice - ("oph", Operation_hash.encoding) + ("oph", Tezos_crypto.Operation_hash.encoding) let add_pending = declare_1 @@ -183,7 +183,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"included" ~msg:"Included operations of {block} at level {level}: {operations}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("operations", Data_encoding.list L1_operation.Hash.encoding) ~pp3:pp_operations_hash_list diff --git a/src/proto_014_PtKathma/lib_injector/injector_functor.ml b/src/proto_014_PtKathma/lib_injector/injector_functor.ml index a05ba45c26aa..e5244531d41c 100644 --- a/src/proto_014_PtKathma/lib_injector/injector_functor.ml +++ b/src/proto_014_PtKathma/lib_injector/injector_functor.ml @@ -73,7 +73,7 @@ module Make (Rollup : PARAMETERS) = struct node. *) type injected_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) } @@ -93,20 +93,20 @@ module Make (Rollup : PARAMETERS) = struct let open Data_encoding in conv (fun {op; oph} -> (oph, op)) (fun (oph, op) -> {op; oph}) @@ merge_objs - (obj1 (req "oph" Operation_hash.encoding)) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) L1_operation.encoding end) module Injected_ophs = Disk_persistence.Make_table (struct - include Operation_hash.Table + include Tezos_crypto.Operation_hash.Table type value = L1_operation.Hash.t list let name = "injected_ophs" - let string_of_key = Operation_hash.to_b58check + let string_of_key = Tezos_crypto.Operation_hash.to_b58check - let key_of_string = Operation_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Operation_hash.of_b58check_opt let value_encoding = Data_encoding.list L1_operation.Hash.encoding end) @@ -126,10 +126,10 @@ module Make (Rollup : PARAMETERS) = struct block. *) type included_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) - l1_block : Block_hash.t; + l1_block : Tezos_crypto.Block_hash.t; (** The hash of the L1 block in which the operation was included. *) l1_level : int32; (** The level of [l1_block]. *) } @@ -153,21 +153,21 @@ module Make (Rollup : PARAMETERS) = struct @@ merge_objs L1_operation.encoding (obj3 - (req "oph" Operation_hash.encoding) - (req "l1_block" Block_hash.encoding) + (req "oph" Tezos_crypto.Operation_hash.encoding) + (req "l1_block" Tezos_crypto.Block_hash.encoding) (req "l1_level" int32)) end) module Included_in_blocks = Disk_persistence.Make_table (struct - include Block_hash.Table + include Tezos_crypto.Block_hash.Table type value = int32 * L1_operation.Hash.t list let name = "included_in_blocks" - let string_of_key = Block_hash.to_b58check + let string_of_key = Tezos_crypto.Block_hash.to_b58check - let key_of_string = Block_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Block_hash.of_b58check_opt let value_encoding = let open Data_encoding in @@ -509,7 +509,7 @@ module Make (Rollup : PARAMETERS) = struct let* signature = Client_keys.sign state.cctxt - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation state.signer.sk unsigned_op_bytes in @@ -621,11 +621,13 @@ module Make (Rollup : PARAMETERS) = struct in let signature = match state.signer.pkh with - | Signature.Ed25519 _ -> Signature.of_ed25519 Ed25519.zero - | Secp256k1 _ -> Signature.of_secp256k1 Secp256k1.zero - | P256 _ -> Signature.of_p256 P256.zero + | Tezos_crypto.Signature.Ed25519 _ -> + Tezos_crypto.Signature.of_ed25519 Tezos_crypto.Ed25519.zero + | Secp256k1 _ -> + Tezos_crypto.Signature.of_secp256k1 Tezos_crypto.Secp256k1.zero + | P256 _ -> Tezos_crypto.Signature.of_p256 Tezos_crypto.P256.zero in - let branch = Block_hash.zero in + let branch = Tezos_crypto.Block_hash.zero in let operation = { shell = {branch}; @@ -921,7 +923,9 @@ module Make (Rollup : PARAMETERS) = struct (fun acc (signer, strategy, tags) -> let tags = Tags.of_list tags in let strategy, tags = - match Signature.Public_key_hash.Map.find_opt signer acc with + match + Tezos_crypto.Signature.Public_key_hash.Map.find_opt signer acc + with | None -> (strategy, tags) | Some (other_strategy, other_tags) -> let strategy = @@ -935,11 +939,14 @@ module Make (Rollup : PARAMETERS) = struct in (strategy, Tags.union other_tags tags) in - Signature.Public_key_hash.Map.add signer (strategy, tags) acc) - Signature.Public_key_hash.Map.empty + Tezos_crypto.Signature.Public_key_hash.Map.add + signer + (strategy, tags) + acc) + Tezos_crypto.Signature.Public_key_hash.Map.empty signers in - Signature.Public_key_hash.Map.iter_es + Tezos_crypto.Signature.Public_key_hash.Map.iter_es (fun signer (strategy, tags) -> let+ worker = Worker.launch diff --git a/src/proto_014_PtKathma/lib_injector/injector_worker_types.ml b/src/proto_014_PtKathma/lib_injector/injector_worker_types.ml index 7c6acb7480ca..2f0afaeb7f17 100644 --- a/src/proto_014_PtKathma/lib_injector/injector_worker_types.ml +++ b/src/proto_014_PtKathma/lib_injector/injector_worker_types.ml @@ -84,7 +84,7 @@ module Request = struct Format.fprintf ppf "switching to new Tezos head %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp b.Alpha_block_services.hash ; if r.old_chain <> [] || r.new_chain <> [] then Format.fprintf @@ -98,11 +98,11 @@ end module Name = struct type t = public_key_hash - let encoding = Signature.Public_key_hash.encoding + let encoding = Tezos_crypto.Signature.Public_key_hash.encoding let base = ["tx_rollup_injector"] - let pp = Signature.Public_key_hash.pp_short + let pp = Tezos_crypto.Signature.Public_key_hash.pp_short - let equal = Signature.Public_key_hash.equal + let equal = Tezos_crypto.Signature.Public_key_hash.equal end diff --git a/src/proto_014_PtKathma/lib_injector/l1_operation.ml b/src/proto_014_PtKathma/lib_injector/l1_operation.ml index 2aa9b014171e..6d9776258e79 100644 --- a/src/proto_014_PtKathma/lib_injector/l1_operation.ml +++ b/src/proto_014_PtKathma/lib_injector/l1_operation.ml @@ -145,7 +145,7 @@ module Manager_operation = struct ty pp_lazy_expr contents - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer in Format.fprintf @@ -159,8 +159,8 @@ module Manager_operation = struct end module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "manager_operation_hash" @@ -171,7 +171,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 type hash = Hash.t diff --git a/src/proto_014_PtKathma/lib_injector/l1_operation.mli b/src/proto_014_PtKathma/lib_injector/l1_operation.mli index 73f1886ed737..21b13fbf32ff 100644 --- a/src/proto_014_PtKathma/lib_injector/l1_operation.mli +++ b/src/proto_014_PtKathma/lib_injector/l1_operation.mli @@ -26,7 +26,7 @@ open Protocol.Alpha_context (** Hash with b58check encoding mop(53), for hashes of L1 manager operations *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for L1 operations hashes *) type hash = Hash.t diff --git a/src/proto_014_PtKathma/lib_parameters/default_parameters.ml b/src/proto_014_PtKathma/lib_parameters/default_parameters.ml index 5ab8028bafe4..501895e461a1 100644 --- a/src/proto_014_PtKathma/lib_parameters/default_parameters.ml +++ b/src/proto_014_PtKathma/lib_parameters/default_parameters.ml @@ -333,8 +333,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_014_PtKathma/lib_parameters/default_parameters.mli b/src/proto_014_PtKathma/lib_parameters/default_parameters.mli index 8aeb40866526..64b33d4af4ce 100644 --- a/src/proto_014_PtKathma/lib_parameters/default_parameters.mli +++ b/src/proto_014_PtKathma/lib_parameters/default_parameters.mli @@ -35,10 +35,10 @@ val constants_test : Constants.Parametric.t val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Signature.public_key_hash - * Signature.public_key + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key * Tez.t - * Signature.public_key_hash option -> + * Tezos_crypto.Signature.public_key_hash option -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_014_PtKathma/lib_plugin/RPC.ml b/src/proto_014_PtKathma/lib_plugin/RPC.ml index e20ba5872997..ef87cdc10770 100644 --- a/src/proto_014_PtKathma/lib_plugin/RPC.ml +++ b/src/proto_014_PtKathma/lib_plugin/RPC.ml @@ -162,7 +162,7 @@ module Scripts = struct (req "input" Script.expr_encoding) (req "amount" Tez.encoding) (opt "balance" Tez.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "self" Contract.originated_encoding) @@ -215,7 +215,7 @@ module Scripts = struct (req "contract" Contract.originated_encoding) (req "entrypoint" Entrypoint.simple_encoding) (req "input" Script.expr_encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -231,7 +231,7 @@ module Scripts = struct (req "view" string) (req "input" Script.expr_encoding) (dft "unlimited_gas" bool false) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (opt "source" Contract.encoding) (opt "payer" Contract.encoding) (opt "gas" Gas.Arith.z_integral_encoding) @@ -379,7 +379,7 @@ module Scripts = struct ~input: (obj2 (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding)) + (req "chain_id" Tezos_crypto.Chain_id.encoding)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") @@ -412,7 +412,7 @@ module Scripts = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_operation") @@ -425,7 +425,7 @@ module Scripts = struct (obj4 (opt "blocks_before_activation" int32) (req "operation" Operation.encoding) - (req "chain_id" Chain_id.encoding) + (req "chain_id" Tezos_crypto.Chain_id.encoding) (dft "latency" int16 default_operation_inclusion_latency)) ~output:Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "simulate_tx_rollup_operation") @@ -819,7 +819,7 @@ module Scripts = struct let operation : _ operation = {shell; protocol_data} in let hash = Operation.hash {shell; protocol_data} in let ctxt = Origination_nonce.init ctxt hash in - let payload_producer = Signature.Public_key_hash.zero in + let payload_producer = Tezos_crypto.Signature.Public_key_hash.zero in Validate_operation.TMP_for_plugin .precheck_manager__do_nothing_on_non_manager_op ctxt @@ -914,7 +914,7 @@ module Scripts = struct let register () = let originate_dummy_contract ctxt script balance = - let ctxt = Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero in Contract.fresh_contract_from_current_nonce ctxt >>?= fun (ctxt, dummy_contract_hash) -> let dummy_contract = Contract.Originated dummy_contract_hash in @@ -2456,7 +2456,7 @@ let requested_levels ~default_level ctxt cycles levels = module Baking_rights = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; round : Round.t; timestamp : Timestamp.t option; } @@ -2470,7 +2470,7 @@ module Baking_rights = struct {level; delegate; round; timestamp}) (obj4 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "round" Round.encoding) (opt "estimated_time" Timestamp.encoding)) @@ -2484,7 +2484,7 @@ module Baking_rights = struct type baking_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; max_round : int option; all : bool; } @@ -2559,12 +2559,16 @@ module Baking_rights = struct @@ List.fold_left (fun (acc, previous) r -> if - Signature.Public_key_hash.Set.exists - (Signature.Public_key_hash.equal r.delegate) + Tezos_crypto.Signature.Public_key_hash.Set.exists + (Tezos_crypto.Signature.Public_key_hash.equal r.delegate) previous then (acc, previous) - else (r :: acc, Signature.Public_key_hash.Set.add r.delegate previous)) - ([], Signature.Public_key_hash.Set.empty) + else + ( r :: acc, + Tezos_crypto.Signature.Public_key_hash.Set.add + r.delegate + previous )) + ([], Tezos_crypto.Signature.Public_key_hash.Set.empty) rights let register () = @@ -2598,7 +2602,9 @@ module Baking_rights = struct | [] -> rights | _ :: _ as delegates -> let is_requested p = - List.exists (Signature.Public_key_hash.equal p.delegate) delegates + List.exists + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) + delegates in List.filter is_requested rights) @@ -2614,7 +2620,7 @@ end module Endorsing_rights = struct type delegate_rights = { - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; first_slot : Slot.t; endorsing_power : int; } @@ -2633,7 +2639,7 @@ module Endorsing_rights = struct (fun (delegate, first_slot, endorsing_power) -> {delegate; first_slot; endorsing_power}) (obj3 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "first_slot" Slot.encoding) (req "endorsing_power" uint16)) @@ -2657,7 +2663,7 @@ module Endorsing_rights = struct type endorsing_rights_query = { levels : Raw_level.t list; cycle : Cycle.t option; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let endorsing_rights_query = @@ -2734,7 +2740,7 @@ module Endorsing_rights = struct (fun rights_at_level -> let is_requested p = List.exists - (Signature.Public_key_hash.equal p.delegate) + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) delegates in match @@ -2757,7 +2763,7 @@ end module Validators = struct type t = { level : Raw_level.t; - delegate : Signature.Public_key_hash.t; + delegate : Tezos_crypto.Signature.Public_key_hash.t; slots : Slot.t list; } @@ -2768,7 +2774,7 @@ module Validators = struct (fun (level, delegate, slots) -> {level; delegate; slots}) (obj3 (req "level" Raw_level.encoding) - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "slots" (list Slot.encoding))) module S = struct @@ -2778,7 +2784,7 @@ module Validators = struct type validators_query = { levels : Raw_level.t list; - delegates : Signature.Public_key_hash.t list; + delegates : Tezos_crypto.Signature.Public_key_hash.t list; } let validators_query = @@ -2827,7 +2833,9 @@ module Validators = struct | [] -> rights | _ :: _ as delegates -> let is_requested p = - List.exists (Signature.Public_key_hash.equal p.delegate) delegates + List.exists + (Tezos_crypto.Signature.Public_key_hash.equal p.delegate) + delegates in List.filter is_requested rights) diff --git a/src/proto_014_PtKathma/lib_plugin/mempool.ml b/src/proto_014_PtKathma/lib_plugin/mempool.ml index 3fa2844818fd..8ea7180db2ee 100644 --- a/src/proto_014_PtKathma/lib_plugin/mempool.ml +++ b/src/proto_014_PtKathma/lib_plugin/mempool.ml @@ -177,13 +177,16 @@ let config_encoding : config Data_encoding.t = (modulo replace_by_fee_factor) *) type manager_op_info = { - operation_hash : Operation_hash.t; + operation_hash : Tezos_crypto.Operation_hash.t; gas_limit : Gas.Arith.fp; fee : Tez.t; weight : Q.t; } -type manager_op_weight = {operation_hash : Operation_hash.t; weight : Q.t} +type manager_op_weight = { + operation_hash : Tezos_crypto.Operation_hash.t; + weight : Q.t; +} let op_weight_of_info (info : manager_op_info) : manager_op_weight = {operation_hash = info.operation_hash; weight = info.weight} @@ -195,26 +198,29 @@ module ManagerOpWeightSet = Set.Make (struct let compare op1 op2 = let c = Q.compare op1.weight op2.weight in if c <> 0 then c - else Operation_hash.compare op1.operation_hash op2.operation_hash + else + Tezos_crypto.Operation_hash.compare op1.operation_hash op2.operation_hash end) type state = { grandparent_level_start : Timestamp.t option; round_zero_duration : Period.t option; - op_prechecked_managers : manager_op_info Signature.Public_key_hash.Map.t; + op_prechecked_managers : + manager_op_info Tezos_crypto.Signature.Public_key_hash.Map.t; (** All managers that are the source of manager operations prechecked in the mempool. Each manager in the map is associated to a record of type [manager_op_info] (See for record details above). Each manager in the map should be accessible with an operation hash in [operation_hash_to_manager]. *) - operation_hash_to_manager : Signature.Public_key_hash.t Operation_hash.Map.t; + operation_hash_to_manager : + Tezos_crypto.Signature.Public_key_hash.t Tezos_crypto.Operation_hash.Map.t; (** Map of operation hash to manager used to remove a manager from [op_prechecked_managers] with an operation hash. Each manager in the map should also be in [op_prechecked_managers]. *) prechecked_operations_count : int; (** Number of prechecked manager operations. Invariants: - - [Operation_hash.Map.cardinal operation_hash_to_manager = + - [Tezos_crypto.Operation_hash.Map.cardinal operation_hash_to_manager = prechecked_operations_count] - [prechecked_operations_count <= max_prechecked_manager_operations] *) ops_prechecked : ManagerOpWeightSet.t; @@ -229,8 +235,8 @@ let empty : state = { grandparent_level_start = None; round_zero_duration = None; - op_prechecked_managers = Signature.Public_key_hash.Map.empty; - operation_hash_to_manager = Operation_hash.Map.empty; + op_prechecked_managers = Tezos_crypto.Signature.Public_key_hash.Map.empty; + operation_hash_to_manager = Tezos_crypto.Operation_hash.Map.empty; prechecked_operations_count = 0; ops_prechecked = ManagerOpWeightSet.empty; min_prechecked_op_weight = None; @@ -287,7 +293,7 @@ let on_flush config filter_state ?(validation_state : validation_state option) let remove ~(filter_state : state) oph = let removed_oph_source = ref None in let operation_hash_to_manager = - Operation_hash.Map.update + Tezos_crypto.Operation_hash.Map.update oph (function | None -> None @@ -307,7 +313,7 @@ let remove ~(filter_state : state) oph = in let removed_op = ref None in let op_prechecked_managers = - Signature.Public_key_hash.Map.update + Tezos_crypto.Signature.Public_key_hash.Map.update source (function | None -> None @@ -328,7 +334,7 @@ let remove ~(filter_state : state) oph = match filter_state.min_prechecked_op_weight with | None -> None | Some op -> - if Operation_hash.equal op.operation_hash oph then + if Tezos_crypto.Operation_hash.equal op.operation_hash oph then ManagerOpWeightSet.min_elt ops_prechecked else Some op in @@ -371,7 +377,7 @@ let () = (fun () -> Fees_too_low) type Environment.Error_monad.error += - | Manager_restriction of {oph : Operation_hash.t; fee : Tez.t} + | Manager_restriction of {oph : Tezos_crypto.Operation_hash.t; fee : Tez.t} let () = Environment.Error_monad.register_error_kind @@ -385,21 +391,21 @@ let () = "Only one manager operation per manager per block allowed (found %a \ with %atez fee. You may want to use --replace to provide adequate fee \ and replace it)." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Tez.pp fee) Data_encoding.( obj2 - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation_fee" Tez.encoding)) (function Manager_restriction {oph; fee} -> Some (oph, fee) | _ -> None) (fun (oph, fee) -> Manager_restriction {oph; fee}) type Environment.Error_monad.error += | Manager_operation_replaced of { - old_hash : Operation_hash.t; - new_hash : Operation_hash.t; + old_hash : Tezos_crypto.Operation_hash.t; + new_hash : Tezos_crypto.Operation_hash.t; } let () = @@ -412,13 +418,13 @@ let () = Format.fprintf ppf "The manager operation %a has been replaced with %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_hash - Operation_hash.pp + Tezos_crypto.Operation_hash.pp new_hash) (Data_encoding.obj2 - (Data_encoding.req "old_hash" Operation_hash.encoding) - (Data_encoding.req "new_hash" Operation_hash.encoding)) + (Data_encoding.req "old_hash" Tezos_crypto.Operation_hash.encoding) + (Data_encoding.req "new_hash" Tezos_crypto.Operation_hash.encoding)) (function | Manager_operation_replaced {old_hash; new_hash} -> Some (old_hash, new_hash) @@ -491,7 +497,7 @@ let better_fees_and_ratio = let check_manager_restriction config filter_state source ~fee ~gas_limit = match - Signature.Public_key_hash.Map.find + Tezos_crypto.Signature.Public_key_hash.Map.find source filter_state.op_prechecked_managers with @@ -959,7 +965,7 @@ let precheck_manager : config -> state -> validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Tezos_base.Operation.shell_header -> t Kind.manager protocol_data -> nb_successful_prechecks:int -> @@ -967,7 +973,8 @@ let precheck_manager : gas_limit:Gas.Arith.fp -> public_key_hash -> [> `Prechecked_manager of - [`No_replace | `Replace of Operation_hash.t * error_classification] + [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification ] Lwt.t = fun config @@ -1051,8 +1058,11 @@ let add_manager_restriction filter_state oph info source replacement = | `Replace (oph, _class) -> remove ~filter_state oph in let prechecked_operations_count = - if Operation_hash.Map.mem oph filter_state.operation_hash_to_manager then - filter_state.prechecked_operations_count + if + Tezos_crypto.Operation_hash.Map.mem + oph + filter_state.operation_hash_to_manager + then filter_state.prechecked_operations_count else filter_state.prechecked_operations_count + 1 in let op_weight = op_weight_of_info info in @@ -1065,12 +1075,15 @@ let add_manager_restriction filter_state oph info source replacement = filter_state with op_prechecked_managers = (* Manager not seen yet, record it for next ops *) - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add source info filter_state.op_prechecked_managers; operation_hash_to_manager = - Operation_hash.Map.add oph source filter_state.operation_hash_to_manager + Tezos_crypto.Operation_hash.Map.add + oph + source + filter_state.operation_hash_to_manager (* Record which manager is used for the operation hash. *); ops_prechecked = ManagerOpWeightSet.add op_weight filter_state.ops_prechecked; @@ -1082,13 +1095,14 @@ let precheck : config -> filter_state:state -> validation_state:validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Main.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification | `Undecided ] Lwt.t = diff --git a/src/proto_014_PtKathma/lib_plugin/test/generators.ml b/src/proto_014_PtKathma/lib_plugin/test/generators.ml index 38d6e4e13509..61a08b89bfc9 100644 --- a/src/proto_014_PtKathma/lib_plugin/test/generators.ml +++ b/src/proto_014_PtKathma/lib_plugin/test/generators.ml @@ -26,19 +26,21 @@ let string_gen = QCheck2.Gen.small_string ?gen:None let public_key_hash_gen : - (Signature.public_key_hash * Signature.public_key * Signature.secret_key) + (Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tezos_crypto.Signature.secret_key) QCheck2.Gen.t = let open QCheck2.Gen in let+ seed = string_size (32 -- 64) in let seed = Bytes.of_string seed in - Signature.generate_key ~seed () + Tezos_crypto.Signature.generate_key ~seed () (* TODO: https://gitlab.com/tezos/tezos/-/issues/2407 move this function to an helper file? *) -let operation_hash_gen : Operation_hash.t QCheck2.Gen.t = +let operation_hash_gen : Tezos_crypto.Operation_hash.t QCheck2.Gen.t = let open QCheck2.Gen in let+ s = QCheck2.Gen.string_size (return 32) in - Operation_hash.of_string_exn s + Tezos_crypto.Operation_hash.of_string_exn s let dummy_manager_op_info oph = { @@ -49,7 +51,8 @@ let dummy_manager_op_info oph = } let dummy_manager_op_info_with_key_gen : - (Plugin.Mempool.manager_op_info * Signature.public_key_hash) QCheck2.Gen.t = + (Plugin.Mempool.manager_op_info * Tezos_crypto.Signature.public_key_hash) + QCheck2.Gen.t = let open QCheck2.Gen in let+ oph, (pkh, _, _) = pair operation_hash_gen public_key_hash_gen in (dummy_manager_op_info oph, pkh) @@ -60,13 +63,18 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = let+ inputs = small_list (pair operation_hash_gen public_key_hash_gen) in List.fold_left (fun state (oph, (pkh, _, _)) -> - match Operation_hash.Map.find oph state.operation_hash_to_manager with + match + Tezos_crypto.Operation_hash.Map.find oph state.operation_hash_to_manager + with | Some _ -> state | None -> let info = dummy_manager_op_info oph in let prechecked_operations_count = - if Operation_hash.Map.mem oph state.operation_hash_to_manager then - state.prechecked_operations_count + if + Tezos_crypto.Operation_hash.Map.mem + oph + state.operation_hash_to_manager + then state.prechecked_operations_count else state.prechecked_operations_count + 1 in let op_weight = op_weight_of_info info in @@ -78,12 +86,15 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = { state with op_prechecked_managers = - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add pkh info state.op_prechecked_managers; operation_hash_to_manager = - Operation_hash.Map.add oph pkh state.operation_hash_to_manager; + Tezos_crypto.Operation_hash.Map.add + oph + pkh + state.operation_hash_to_manager; ops_prechecked = ManagerOpWeightSet.add op_weight state.ops_prechecked; prechecked_operations_count; @@ -94,21 +105,24 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = let with_filter_state_operation_gen : Plugin.Mempool.state -> - (Plugin.Mempool.manager_op_info * Signature.public_key_hash) QCheck2.Gen.t = + (Plugin.Mempool.manager_op_info * Tezos_crypto.Signature.public_key_hash) + QCheck2.Gen.t = fun state -> let open QCheck2.Gen in let* use_fresh = bool in let to_ops map = - Operation_hash.Map.bindings map + Tezos_crypto.Operation_hash.Map.bindings map |> List.map (fun (oph, pkh) -> (dummy_manager_op_info oph, pkh)) in - if use_fresh || Operation_hash.Map.is_empty state.operation_hash_to_manager + if + use_fresh + || Tezos_crypto.Operation_hash.Map.is_empty state.operation_hash_to_manager then dummy_manager_op_info_with_key_gen else oneofl (to_ops state.operation_hash_to_manager) let filter_state_with_operation_gen : (Plugin.Mempool.state - * (Plugin.Mempool.manager_op_info * Signature.public_key_hash)) + * (Plugin.Mempool.manager_op_info * Tezos_crypto.Signature.public_key_hash)) QCheck2.Gen.t = let open QCheck2.Gen in filter_state_gen >>= fun state -> diff --git a/src/proto_014_PtKathma/lib_plugin/test/test_filter_state.ml b/src/proto_014_PtKathma/lib_plugin/test/test_filter_state.ml index 24c8b7a86720..fa065244efa8 100644 --- a/src/proto_014_PtKathma/lib_plugin/test/test_filter_state.ml +++ b/src/proto_014_PtKathma/lib_plugin/test/test_filter_state.ml @@ -52,7 +52,7 @@ let test_check_manager_restriction_fresh = { filter_state with op_prechecked_managers = - Signature.Public_key_hash.Map.remove + Tezos_crypto.Signature.Public_key_hash.Map.remove pkh filter_state.op_prechecked_managers; } @@ -71,7 +71,7 @@ let test_check_manager_restriction_fresh = "@[Check manager restriction failed!@,\ %a should not be in the set of precheck managers:@,\ %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state) @@ -93,7 +93,7 @@ let test_check_manager_restriction_fail = { filter_state with op_prechecked_managers = - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add pkh {op_info with fee = Alpha_context.Tez.one} (* We force higher fee than below: [one > zero]. *) @@ -114,7 +114,7 @@ let test_check_manager_restriction_fail = "@[Check manager restriction failed!@,\ %a should be in the set of precheck managers:@,\ %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state @@ -124,11 +124,11 @@ let test_check_manager_restriction_fail = %a is in the set of precheck managers:@,\ %a@,\ but should not replace the old operation:%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_oph) (** Test that [check_manager_restriction] returns [Replace] when we use a known @@ -148,7 +148,7 @@ let test_check_manager_restriction_replace = { filter_state with op_prechecked_managers = - Signature.Public_key_hash.Map.add + Tezos_crypto.Signature.Public_key_hash.Map.add pkh op_info filter_state.op_prechecked_managers; @@ -168,7 +168,7 @@ let test_check_manager_restriction_replace = "@[Check manager restriction failed!@,\ %a should be in the set of precheck managers:@,\ %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state @@ -178,7 +178,7 @@ let test_check_manager_restriction_replace = %a is in the set of prechecked managers:@,\ %a but the old version should have been replaced because the new \ fees(%a) are higher@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state @@ -212,11 +212,11 @@ let test_add_manager_restriction_set = Format.fprintf fmt "%a was not found in prechecked_managers : %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_prechecked_managers set) - ~cond:(Signature.Public_key_hash.Map.mem pkh) + ~cond:(Tezos_crypto.Signature.Public_key_hash.Map.mem pkh) filter_state.op_prechecked_managers ()) @@ -232,10 +232,12 @@ let test_add_manager_restriction_replace = Generators.filter_state_with_operation_gen (fun (filter_state, (op_info, pkh)) -> match - Operation_hash.Map.choose filter_state.operation_hash_to_manager + Tezos_crypto.Operation_hash.Map.choose + filter_state.operation_hash_to_manager with | None -> true - | Some (oph, _) when Operation_hash.equal oph op_info.operation_hash -> + | Some (oph, _) + when Tezos_crypto.Operation_hash.equal oph op_info.operation_hash -> true | Some (oph_to_replace, _) -> let filter_state = @@ -251,11 +253,12 @@ let test_add_manager_restriction_replace = Format.fprintf fmt "%a was not found in prechecked_managers : %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph_to_replace pp_operation_hash_manager map) - ~cond:(fun map -> not (Operation_hash.Map.mem oph_to_replace map)) + ~cond:(fun map -> + not (Tezos_crypto.Operation_hash.Map.mem oph_to_replace map)) filter_state.operation_hash_to_manager ()) @@ -298,7 +301,7 @@ let test_add_manager_restriction_check = "@[Check manager restriction failed!@,\ %a should be in the set of precheck managers:@,\ %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh pp_state filter_state @@ -329,7 +332,7 @@ let test_remove = in let actual_state = remove ~filter_state op_info.operation_hash in let expected_prechecked_managers = - Signature.Public_key_hash.Map.remove + Tezos_crypto.Signature.Public_key_hash.Map.remove pkh filter_state.op_prechecked_managers in @@ -351,7 +354,7 @@ let test_remove_unknown = { filter_state with operation_hash_to_manager = - Operation_hash.Map.remove + Tezos_crypto.Operation_hash.Map.remove op_info.operation_hash filter_state.operation_hash_to_manager; } diff --git a/src/proto_014_PtKathma/lib_plugin/test/test_utils.ml b/src/proto_014_PtKathma/lib_plugin/test/test_utils.ml index cf25d367381e..d7e5811126dc 100644 --- a/src/proto_014_PtKathma/lib_plugin/test/test_utils.ml +++ b/src/proto_014_PtKathma/lib_plugin/test/test_utils.ml @@ -44,15 +44,15 @@ let pp_prechecked_managers fmt set = Format.fprintf ppf "(%a -> (hash:%a,gas:%a,fee:%a))" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_info.operation_hash Alpha_context.Gas.Arith.pp op_info.gas_limit Alpha_context.Tez.pp op_info.fee)) - (Signature.Public_key_hash.Map.bindings set) + (Tezos_crypto.Signature.Public_key_hash.Map.bindings set) let pp_operation_hash_manager fmt map = Format.fprintf @@ -62,17 +62,17 @@ let pp_operation_hash_manager fmt map = Format.fprintf ppf "(%a -> %a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp hash - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh)) - (Operation_hash.Map.bindings map) + (Tezos_crypto.Operation_hash.Map.bindings map) let pp_manager_op_weight fmt weight = Format.fprintf fmt "(oph: %a;weight: %a)" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp weight.operation_hash Q.pp_print weight.weight @@ -113,13 +113,13 @@ let pp_state fmt state = state.min_prechecked_op_weight let eq_prechecked_managers = - Signature.Public_key_hash.Map.equal + Tezos_crypto.Signature.Public_key_hash.Map.equal (fun ({operation_hash = oph1; gas_limit = _; fee = _; weight = _} : manager_op_info) ({operation_hash = oph2; gas_limit = _; fee = _; weight = _} : manager_op_info) - -> Operation_hash.equal oph1 oph2) + -> Tezos_crypto.Operation_hash.equal oph1 oph2) (* This function needs to be updated if the filter state is extended *) let eq_state s1 s2 = @@ -128,12 +128,12 @@ let eq_state s1 s2 = | None, None -> true | Some _, None | None, Some _ -> false | Some w1, Some w2 -> - Operation_hash.equal w1.operation_hash w2.operation_hash + Tezos_crypto.Operation_hash.equal w1.operation_hash w2.operation_hash && Q.equal w1.weight w2.weight in eq_prechecked_managers s1.op_prechecked_managers s2.op_prechecked_managers - && Operation_hash.Map.equal - (fun k1 k2 -> Signature.Public_key_hash.equal k1 k2) + && Tezos_crypto.Operation_hash.Map.equal + (fun k1 k2 -> Tezos_crypto.Signature.Public_key_hash.equal k1 k2) s1.operation_hash_to_manager s2.operation_hash_to_manager && s1.prechecked_operations_count = s2.prechecked_operations_count diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/account.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/account.ml index df85819387f6..f3e5a608dec0 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/account.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/account.ml @@ -27,43 +27,51 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -let known_accounts = Signature.Public_key_hash.Table.create 17 +let known_accounts = Tezos_crypto.Signature.Public_key_hash.Table.create 17 let random_seed ~rng_state = - Bytes.init Hacl.Ed25519.sk_size (fun _i -> + Bytes.init Tezos_crypto.Hacl.Ed25519.sk_size (fun _i -> Char.chr (Random.State.int rng_state 256)) let new_account ?seed () = - let pkh, pk, sk = Signature.generate_key ~algo:Ed25519 ?seed () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ?seed () + in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account ; account let add_account ({pkh; _} as account) = - Signature.Public_key_hash.Table.add known_accounts pkh account + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account let activator_account = let seed = random_seed ~rng_state:(Random.State.make [|0x1337533D|]) in new_account ~seed () let find pkh = - match Signature.Public_key_hash.Table.find known_accounts pkh with + match + Tezos_crypto.Signature.Public_key_hash.Table.find known_accounts pkh + with | Some k -> return k - | None -> failwith "Missing account: %a" Signature.Public_key_hash.pp pkh + | None -> + failwith + "Missing account: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let find_alternate pkh = let exception Found of t in try - Signature.Public_key_hash.Table.iter + Tezos_crypto.Signature.Public_key_hash.Table.iter (fun pkh' account -> - if not (Signature.Public_key_hash.equal pkh pkh') then + if not (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') then raise (Found account)) known_accounts ; raise Not_found @@ -78,8 +86,8 @@ let dummy_account = let default_initial_balance = Tez.of_mutez_exn 4_000_000_000_000L let generate_accounts ?rng_state ?(initial_balances = []) ?bootstrap_delegations - n : (t * Tez.t * Signature.Public_key_hash.t option) list = - Signature.Public_key_hash.Table.clear known_accounts ; + n : (t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list = + Tezos_crypto.Signature.Public_key_hash.Table.clear known_accounts ; let amount i = match List.nth_opt initial_balances i with | None -> default_initial_balance @@ -102,10 +110,16 @@ let generate_accounts ?rng_state ?(initial_balances = []) ?bootstrap_delegations List.map (fun i -> let pkh, pk, sk = - Signature.generate_key ~algo:Ed25519 ~seed:(random_seed ~rng_state) () + Tezos_crypto.Signature.generate_key + ~algo:Ed25519 + ~seed:(random_seed ~rng_state) + () in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add + known_accounts + pkh + account ; (account, amount i, delegate_to pkh)) (0 -- (n - 1)) @@ -115,7 +129,9 @@ let commitment_secret = |> WithExceptions.Option.get ~loc:__LOC__ let new_commitment ?seed () = - let pkh, pk, sk = Signature.generate_key ?seed ~algo:Ed25519 () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ?seed ~algo:Ed25519 () + in let unactivated_account = {pkh; pk; sk} in let open Commitment in let pkh = match pkh with Ed25519 pkh -> pkh | _ -> assert false in diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/account.mli b/src/proto_014_PtKathma/lib_protocol/test/helpers/account.mli index d7064b862fcf..645b55cbbaef 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/account.mli +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/account.mli @@ -27,14 +27,14 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -val known_accounts : t Signature.Public_key_hash.Table.t +val known_accounts : t Tezos_crypto.Signature.Public_key_hash.Table.t val activator_account : account @@ -44,9 +44,9 @@ val new_account : ?seed:Bytes.t -> unit -> account val add_account : t -> unit -val find : Signature.Public_key_hash.t -> t tzresult Lwt.t +val find : Tezos_crypto.Signature.Public_key_hash.t -> t tzresult Lwt.t -val find_alternate : Signature.Public_key_hash.t -> t +val find_alternate : Tezos_crypto.Signature.Public_key_hash.t -> t (** 4.000.000.000 tez *) val default_initial_balance : Tez.t @@ -60,9 +60,11 @@ val generate_accounts : ?rng_state:Random.State.t -> ?initial_balances:int64 list -> ?bootstrap_delegations: - (Signature.Public_key_hash.t * Signature.Public_key_hash.t) list -> + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key_hash.t) + list -> int -> - (t * Tez.t * Signature.Public_key_hash.t option) list + (t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list val commitment_secret : Blinded_public_key_hash.activation_code diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/assert.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/assert.ml index 9aa0c79d9e69..049698c05301 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/assert.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/assert.ml @@ -143,14 +143,14 @@ let not_equal_tez ~loc (a : Alpha_context.Tez.t) (b : Alpha_context.Tez.t) = not_equal ~loc Tez.( = ) "Tez are equal" Tez.pp a b (* pkh *) -let equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in equal ~loc PKH.equal "Public key hashes aren't equal" PKH.pp a b -let not_equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let not_equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in not_equal ~loc PKH.equal "Public key hashes are equal" PKH.pp a b let get_some ~loc = function diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/block.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/block.ml index d435936f91cd..81686aa03301 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/block.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/block.ml @@ -31,7 +31,7 @@ open Alpha_context (* This type collects a block and the context that results from its application *) type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; @@ -81,7 +81,11 @@ let get_next_baker_by_account pkh block = >>=? fun bakers -> (match List.hd bakers with | Some b -> return b - | None -> failwith "No slots found for %a" Signature.Public_key_hash.pp pkh) + | None -> + failwith + "No slots found for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh) >>=? fun {Plugin.RPC.Baking_rights.delegate = pkh; timestamp; round; _} -> Environment.wrap_tzresult (Round.to_int round) >>?= fun round -> return @@ -94,7 +98,10 @@ let get_next_baker_excluding excludes block = @@ List.find (fun {Plugin.RPC.Baking_rights.delegate; _} -> not - (List.mem ~equal:Signature.Public_key_hash.equal delegate excludes)) + (List.mem + ~equal:Tezos_crypto.Signature.Public_key_hash.equal + delegate + excludes)) bakers in Environment.wrap_tzresult (Round.to_int round) >>?= fun round -> @@ -146,7 +153,7 @@ module Forge = struct (* We don't care of the following values, only the shell validates them. *) proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } let set_seed_nonce_hash seed_nonce_hash {baker; shell; contents} = @@ -162,8 +169,9 @@ module Forge = struct (shell, contents) in let signature = - Signature.sign - ~watermark:Block_header.(to_watermark (Block_header Chain_id.zero)) + Tezos_crypto.Signature.sign + ~watermark: + Block_header.(to_watermark (Block_header Tezos_crypto.Chain_id.zero)) delegate.sk unsigned_bytes in @@ -204,7 +212,8 @@ module Forge = struct >|=? fun seed_nonce_hash -> let hashes = List.map Operation.hash_packed operations in let operations_hash = - Operation_list_list_hash.compute [Operation_list_hash.compute hashes] + Tezos_crypto.Operation_list_list_hash.compute + [Tezos_crypto.Operation_list_hash.compute hashes] in let shell = make_shell @@ -219,7 +228,9 @@ module Forge = struct List.concat (match List.tl operations with None -> [] | Some l -> l) in let hashes = List.map Operation.hash_packed non_consensus_operations in - let non_consensus_operations_hash = Operation_list_hash.compute hashes in + let non_consensus_operations_hash = + Tezos_crypto.Operation_list_hash.compute hashes + in let payload_round = match payload_round with None -> round | Some r -> r in @@ -362,13 +373,13 @@ let initial_alpha_context ?(commitments = []) constants ~typecheck ~level ~timestamp - Chain_id.zero + Tezos_crypto.Chain_id.zero ctxt >|= Environment.wrap_tzresult let genesis_with_parameters parameters = let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let fitness = @@ -384,7 +395,7 @@ let genesis_with_parameters parameters = ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in let contents = Forge.make_contents @@ -403,19 +414,23 @@ let genesis_with_parameters parameters = add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> - let chain_id = Chain_id.of_block_hash hash in + let chain_id = Tezos_crypto.Chain_id.of_block_hash hash in Main.init chain_id ctxt shell >|= Environment.wrap_tzresult >|=? fun {context; _} -> { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } let validate_initial_accounts (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) tokens_per_roll = if initial_accounts = [] then Stdlib.failwith "Must have one account with a roll to bake" ; @@ -551,7 +566,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum >>=? fun () -> check_constants_consistency constants >>=? fun () -> let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let level = Option.value ~default:0l level in @@ -568,7 +583,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in validate_initial_accounts initial_accounts constants.tokens_per_roll (* Perhaps this could return a new type signifying its name *) @@ -584,7 +599,8 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum ?tx_rollup_origination_size ?sc_rollup_enable ?dal_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) = + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) + = prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum @@ -609,7 +625,7 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum initial_context ?commitments ?bootstrap_contracts - (Chain_id.of_block_hash hash) + (Tezos_crypto.Chain_id.of_block_hash hash) constants shell initial_accounts @@ -623,14 +639,19 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum in { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } let alpha_context ?commitments ?min_proposal_quorum (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) = + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) + = prepare_initial_context_params ?min_proposal_quorum initial_accounts >>=? fun (constants, shell, _hash) -> initial_alpha_context ?commitments constants shell initial_accounts @@ -645,7 +666,7 @@ let get_application_vstate (pred : t) (operations : Protocol.operation trace) = Forge.sign_header header >>=? fun header -> let open Environment.Error_monad in Main.begin_application - ~chain_id:Chain_id.zero + ~chain_id:Tezos_crypto.Chain_id.zero ~predecessor_context:pred.context ~predecessor_fitness:pred.header.shell.fitness ~predecessor_timestamp:pred.header.shell.timestamp @@ -658,7 +679,7 @@ let get_construction_vstate ?(policy = By_round 0) ?timestamp dispatch_policy policy pred >>=? fun (_pkh, _round, expected_timestamp) -> let timestamp = Option.value ~default:expected_timestamp timestamp in Main.begin_construction - ~chain_id:Chain_id.zero + ~chain_id:Tezos_crypto.Chain_id.zero ~predecessor_context:pred.context ~predecessor_timestamp:pred.header.shell.timestamp ~predecessor_level:pred.header.shell.level @@ -675,7 +696,7 @@ let apply_with_metadata ?(policy = By_round 0) ?(check_size = true) ~baking_mode ( (match baking_mode with | Application -> Main.begin_application - ~chain_id:Chain_id.zero + ~chain_id:Tezos_crypto.Chain_id.zero ~predecessor_context:pred.context ~predecessor_fitness:pred.header.shell.fitness ~predecessor_timestamp:pred.header.shell.timestamp diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/block.mli b/src/proto_014_PtKathma/lib_protocol/test/helpers/block.mli index 79683b6841ea..72b1971d7a26 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/block.mli +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/block.mli @@ -29,7 +29,7 @@ open Protocol open Alpha_context type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; (** Resulting context *) @@ -128,7 +128,7 @@ val genesis : ?dal_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> - (Account.t * Tez.tez * Signature.Public_key_hash.t option) list -> + (Account.t * Tez.tez * Tezos_crypto.Signature.Public_key_hash.t option) list -> block tzresult Lwt.t val genesis_with_parameters : Parameters.t -> block tzresult Lwt.t @@ -140,7 +140,7 @@ val genesis_with_parameters : Parameters.t -> block tzresult Lwt.t val alpha_context : ?commitments:Commitment.t list -> ?min_proposal_quorum:int32 -> - (Account.t * Tez.tez * Signature.Public_key_hash.t option) list -> + (Account.t * Tez.tez * Tezos_crypto.Signature.Public_key_hash.t option) list -> Alpha_context.t tzresult Lwt.t (** @@ -272,8 +272,10 @@ val prepare_initial_context_params : ?dal_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> - (Account.t * Tez.t * Signature.Public_key_hash.t option) list -> - ( Constants.Parametric.t * Block_header.shell_header * Block_hash.t, + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list -> + ( Constants.Parametric.t + * Block_header.shell_header + * Tezos_crypto.Block_hash.t, tztrace ) result Lwt.t diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/context.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/context.ml index e321dca581af..0a6cfc766eca 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/context.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/context.ml @@ -139,7 +139,7 @@ let get_endorsing_power_for_delegate ctxt ?levels pkh = let rec find_slots_for_delegate = function | [] -> return 0 | {Plugin.RPC.Validators.delegate; slots; _} :: t -> - if Signature.Public_key_hash.equal delegate pkh then + if Tezos_crypto.Signature.Public_key_hash.equal delegate pkh then return (List.length slots) else find_slots_for_delegate t in @@ -162,7 +162,8 @@ let get_baker ctxt ~round = let get_first_different_baker baker bakers = WithExceptions.Option.get ~loc:__LOC__ @@ List.find - (fun baker' -> Signature.Public_key_hash.( <> ) baker baker') + (fun baker' -> + Tezos_crypto.Signature.Public_key_hash.( <> ) baker baker') bakers let get_first_different_bakers ctxt = @@ -257,7 +258,7 @@ module Vote = struct type delegate_info = Alpha_context.Vote.delegate_info = { voting_power : Int64.t option; current_ballot : Alpha_context.Vote.ballot option; - current_proposals : Protocol_hash.t list; + current_proposals : Tezos_crypto.Protocol_hash.t list; remaining_proposals : int; } end @@ -532,7 +533,7 @@ let default_raw_context () = >>= fun context -> let typecheck ctxt script_repr = return ((script_repr, None), ctxt) in Init_storage.prepare_first_block - Chain_id.zero + Tezos_crypto.Chain_id.zero context ~level:0l ~timestamp:(Time.Protocol.of_seconds 1643125688L) diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/context.mli b/src/proto_014_PtKathma/lib_protocol/test/helpers/context.mli index 15a3224f0872..052552cec055 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/context.mli +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/context.mli @@ -30,7 +30,7 @@ open Environment type t = B of Block.t | I of Incremental.t -val branch : t -> Block_hash.t +val branch : t -> Tezos_crypto.Block_hash.t val get_level : t -> Raw_level.t tzresult @@ -94,7 +94,8 @@ module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t val get_ballot_list : - t -> (Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t + t -> + (Tezos_crypto.Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t val get_current_period : t -> Voting_period.info tzresult Lwt.t @@ -103,20 +104,21 @@ module Vote : sig val get_participation_ema : Block.t -> int32 tzresult Lwt.t val get_listings : - t -> (Signature.Public_key_hash.t * int64) list tzresult Lwt.t + t -> (Tezos_crypto.Signature.Public_key_hash.t * int64) list tzresult Lwt.t val get_proposals : t -> int64 Protocol_hash.Map.t tzresult Lwt.t - val get_current_proposal : t -> Protocol_hash.t option tzresult Lwt.t + val get_current_proposal : + t -> Tezos_crypto.Protocol_hash.t option tzresult Lwt.t - val get_protocol : Block.t -> Protocol_hash.t Lwt.t + val get_protocol : Block.t -> Tezos_crypto.Protocol_hash.t Lwt.t val set_participation_ema : Block.t -> int32 -> Block.t Lwt.t type delegate_info = Alpha_context.Vote.delegate_info = { voting_power : Int64.t option; current_ballot : Alpha_context.Vote.ballot option; - current_proposals : Protocol_hash.t list; + current_proposals : Tezos_crypto.Protocol_hash.t list; remaining_proposals : int; } end @@ -229,7 +231,9 @@ type 'accounts init := ?min_proposal_quorum:int32 -> ?bootstrap_contracts:Parameters.bootstrap_contract list -> ?bootstrap_delegations: - (Signature.Public_key_hash.t * Signature.Public_key_hash.t) list -> + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key_hash.t) + list -> ?level:int32 -> ?cost_per_byte:Tez.t -> ?liquidity_baking_subsidy:Tez.t -> diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/contract_helpers.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/contract_helpers.ml index aced2a46bffc..bb9badbd08c5 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/contract_helpers.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/contract_helpers.ml @@ -69,7 +69,8 @@ let fake_KT1 = let default_self = fake_KT1 -let default_source = Contract.Implicit Signature.Public_key_hash.zero +let default_source = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero let default_step_constants = Script_interpreter. @@ -79,7 +80,7 @@ let default_step_constants = self = default_self; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/expr_common.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/expr_common.ml index 554bba47ce07..e6444892c600 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/expr_common.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/expr_common.ml @@ -78,7 +78,7 @@ let big_map_id ?(loc = 0) id = int ~loc @@ Big_map.Id.unparse_to_z id let timestamp_of_zint zint = Script_timestamp.of_zint zint let public_key_of_bytes_exn b = - Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding b + Data_encoding.Binary.of_bytes_exn Tezos_crypto.Signature.Public_key.encoding b let address_of_bytes_exn b = Data_encoding.Binary.of_bytes_exn Contract.encoding b diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/incremental.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/incremental.ml index 3d9ee379a617..f8ebb0031198 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/incremental.ml @@ -52,7 +52,7 @@ let rpc_context st = let fitness = (header st).shell.fitness in let result = Alpha_context.finalize st.state.ctxt fitness in { - Environment.Updater.block_hash = Block_hash.zero; + Environment.Updater.block_hash = Tezos_crypto.Block_hash.zero; block_header = {st.header.shell with fitness = result.fitness}; context = result.context; } @@ -88,7 +88,7 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) in let protocol_data = if mempool_mode then None - else Some {Block_header.contents; signature = Signature.zero} + else Some {Block_header.contents; signature = Tezos_crypto.Signature.zero} in let header = { @@ -100,14 +100,14 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) fitness = predecessor.header.shell.fitness; timestamp; level = predecessor.header.shell.level; - context = Context_hash.zero; - operations_hash = Operation_list_list_hash.zero; + context = Tezos_crypto.Context_hash.zero; + operations_hash = Tezos_crypto.Operation_list_list_hash.zero; }; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in begin_construction - ~chain_id:Chain_id.zero + ~chain_id:Tezos_crypto.Chain_id.zero ~predecessor_context:predecessor.context ~predecessor_timestamp:predecessor.header.shell.timestamp ~predecessor_fitness:predecessor.header.shell.fitness @@ -222,8 +222,11 @@ let add_operation ?expect_failure ?expect_apply_failure ?check_size st op = let finalize_block st = let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let shell_header = { @@ -236,8 +239,11 @@ let finalize_block st = Environment.wrap_tzresult x >|? fun (result, _) -> let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let header = { diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/liquidity_baking_machine.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/liquidity_baking_machine.ml index 5afba932e396..06b649b3744b 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/liquidity_baking_machine.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/liquidity_baking_machine.ml @@ -390,13 +390,13 @@ let total_xtz = 32_000_000_000_000L let tzbtc_admin_account : Account.t = { pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; sk = - Signature.Secret_key.of_b58check_exn + Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"; } diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/lqt_fa12_repr.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/lqt_fa12_repr.ml index af27ec2e2e93..168bbb43dac6 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/lqt_fa12_repr.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/lqt_fa12_repr.ml @@ -135,7 +135,7 @@ module Storage = struct { tokens = Big_map.Id.parse_z Z.zero; allowances = Big_map.Id.parse_z Z.one; - admin = Contract.Implicit Signature.Public_key_hash.zero; + admin = Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero; totalSupply = Z.zero; } diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/nonce.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/nonce.ml index 695cdcdbbec9..23edb62e017f 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/nonce.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/nonce.ml @@ -22,7 +22,7 @@ let known_nonces = Table.create 17 let generate () = match Alpha_context.Nonce.of_bytes - @@ Rand.generate Alpha_context.Constants.nonce_length + @@ Tezos_crypto.Rand.generate Alpha_context.Constants.nonce_length with | Ok nonce -> let hash = Alpha_context.Nonce.hash nonce in diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/op.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/op.ml index ccef199cec1e..19e222b0fb30 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/op.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/op.ml @@ -26,14 +26,15 @@ open Protocol open Alpha_context -let sign ?(watermark = Signature.Generic_operation) sk ctxt contents = +let sign ?(watermark = Tezos_crypto.Signature.Generic_operation) sk ctxt + contents = let branch = Context.branch ctxt in let unsigned = Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding ({branch}, Contents_list contents) in - let signature = Some (Signature.sign ~watermark sk unsigned) in + let signature = Some (Tezos_crypto.Signature.sign ~watermark sk unsigned) in ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) (** Generates the block payload hash based on the hash [pred_hash] of @@ -45,7 +46,9 @@ let mk_block_payload_hash pred_hash payload_round (b : Block.t) = List.concat (match List.tl ops with None -> [] | Some l -> l) in let hashes = List.map Operation.hash_packed non_consensus_operations in - let non_consensus_operations_hash = Operation_list_hash.compute hashes in + let non_consensus_operations_hash = + Tezos_crypto.Operation_list_hash.compute hashes + in Block_payload.hash ~predecessor:pred_hash payload_round @@ -80,7 +83,8 @@ let endorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Endorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Endorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -113,7 +117,8 @@ let preendorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Preendorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Preendorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -189,7 +194,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt assert ( List.for_all (fun {shell = {Tezos_base.Operation.branch = b; _}; _} -> - Block_hash.(branch = b)) + Tezos_crypto.Block_hash.(branch = b)) packed_operations) ; (* TODO? : check signatures consistency *) let unpacked_operations = @@ -218,7 +223,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt let reveal_op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -287,7 +292,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter; operation; @@ -303,7 +308,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op_reveal = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -314,7 +319,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter = Z.succ counter; operation; @@ -333,7 +338,7 @@ let revelation ?(fee = Tez.zero) ?(gas_limit = High) ?(storage_limit = Z.zero) let pkh = match forge_pkh with | Some pkh -> pkh - | None -> Signature.Public_key.hash public_key + | None -> Tezos_crypto.Signature.Public_key.hash public_key in resolve_gas_limit ctxt gas_limit >>=? fun gas_limit -> let source = Contract.Implicit pkh in @@ -500,14 +505,15 @@ let increase_paid_storage ?force_reveal ?counter ?fee ?gas_limit ?storage_limit Context.Contract.manager ctxt source >|=? fun account -> sign account.sk ctxt sop -let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code = +let activation ctxt (pkh : Tezos_crypto.Signature.Public_key_hash.t) + activation_code = (match pkh with | Ed25519 edpkh -> return edpkh | _ -> failwith "Wrong public key hash : %a - Commitments must be activated with an \ - Ed25519 encrypted public key hash" - Signature.Public_key_hash.pp + Tezos_crypto.Ed25519 encrypted public key hash" + Tezos_crypto.Signature.Public_key_hash.pp pkh) >|=? fun id -> let contents = Single (Activate_account {id; activation_code}) in diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/op.mli b/src/proto_014_PtKathma/lib_protocol/test/helpers/op.mli index 92eba04681d6..6ffbb9f33c77 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/op.mli +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/op.mli @@ -30,8 +30,8 @@ open Alpha_context Improve documentation of the operation helpers *) val sign : - ?watermark:Signature.watermark -> - Signature.secret_key -> + ?watermark:Tezos_crypto.Signature.watermark -> + Tezos_crypto.Signature.secret_key -> Context.t -> packed_contents_list -> packed_operation @@ -230,7 +230,7 @@ val originated_contract : Operation.packed -> Contract.t val register_global_constant : ?force_reveal:bool -> ?counter:Z.t -> - ?public_key:Signature.public_key -> + ?public_key:Tezos_crypto.Signature.public_key -> ?fee:Tez.tez -> ?gas_limit:gas_limit -> ?storage_limit:Z.t -> @@ -261,7 +261,7 @@ val double_baking : val activation : Context.t -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Blinded_public_key_hash.activation_code -> Operation.packed tzresult Lwt.t @@ -295,14 +295,14 @@ val vdf_revelation : Context.t -> Seed.vdf_solution -> Operation.packed val proposals : Context.t -> Contract.t -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Operation.packed tzresult Lwt.t (** Cast a vote yay, nay or pass *) val ballot : Context.t -> Contract.t -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Operation.packed tzresult Lwt.t @@ -442,7 +442,7 @@ val tx_rollup_dispatch_tickets : message_result_path:Tx_rollup_commitment.Merkle.path -> Tx_rollup.t -> Tx_rollup_level.t -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tx_rollup_reveal.t list -> (packed_operation, tztrace) result Lwt.t diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/sapling_helpers.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/sapling_helpers.ml index 4d07ce051426..0f256cd31ce0 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/sapling_helpers.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/sapling_helpers.ml @@ -117,7 +117,7 @@ module Common = struct let payload_enc = Data_encoding.Binary.to_bytes_exn Data_encoding.bytes - (Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) + (Tezos_crypto.Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) in Data_encoding.Binary.of_bytes_exn Ciphertext.encoding @@ -353,7 +353,12 @@ module Interpreter_helpers = struct let originate_contract_hash file storage src b baker = originate_contract_hash file storage src b baker >|=? fun (dst, b) -> let anti_replay = - Format.asprintf "%a%a" Contract_hash.pp dst Chain_id.pp Chain_id.zero + Format.asprintf + "%a%a" + Contract_hash.pp + dst + Tezos_crypto.Chain_id.pp + Tezos_crypto.Chain_id.zero in (dst, b, anti_replay) diff --git a/src/proto_014_PtKathma/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml b/src/proto_014_PtKathma/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml index 33c9c482b6bb..264b2507fedf 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml @@ -96,10 +96,11 @@ let empty_context : Context_l2.t = empty_storage let rng_state = Random.State.make_self_init () -let gen_l1_address ?seed () = Signature.generate_key ~algo:Ed25519 ?seed () +let gen_l1_address ?seed () = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ?seed () let gen_l2_address () = - let _pkh, public_key, secret_key = Bls.generate_key () in + let _pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key () in (secret_key, public_key, Tx_rollup_l2_address.of_bls_pk public_key) (** [make_unit_ticket_key ctxt ticketer l2_address] computes the key hash of @@ -153,7 +154,7 @@ let gen_n_ticket_hash n = | Error _ -> raise (Invalid_argument "Failed to forge tickets") let sign_transaction : - Bls.Secret_key.t list -> + Tezos_crypto.Bls.Secret_key.t list -> ('signer, 'content) Tx_rollup_l2_batch.V1.transaction -> Tx_rollup_l2_batch.V1.signature list = fun sks transaction -> @@ -165,7 +166,7 @@ let sign_transaction : Tx_rollup_l2_batch.V1.transaction_encoding transaction in - List.map (fun sk -> Bls.sign sk buf) sks + List.map (fun sk -> Tezos_crypto.Bls.sign sk buf) sks type Environment.Error_monad.error += Test_error of string diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_baking.ml index da92ec76574b..63b287f3d84b 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_baking.ml @@ -171,7 +171,7 @@ let get_contract_for_pkh contracts pkh = | [] -> assert false | c :: t -> let c_pkh = Context.Contract.pkh c in - if Signature.Public_key_hash.equal c_pkh pkh then return c + if Tezos_crypto.Signature.Public_key_hash.equal c_pkh pkh then return c else find_contract t in find_contract contracts @@ -226,7 +226,7 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposit -> Context.get_baking_reward_fixed_portion (B b2) >>=? fun baking_reward -> Context.get_bonus_reward (B b2) ~endorsing_power >>=? fun bonus_reward -> - (if Signature.Public_key_hash.equal baker_b2 baker_b1 then + (if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then Context.get_baking_reward_fixed_portion (B b1) else return Tez.zero) >>=? fun reward_for_b1 -> @@ -270,7 +270,8 @@ let test_rewards_block_and_payload_producer () = Context.Delegate.current_frozen_deposits (B b2') baker_b2 >>=? fun frozen_deposit -> let reward_for_b1 = - if Signature.Public_key_hash.equal baker_b2 baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then + baking_reward else Tez.zero in let expected_balance = @@ -287,7 +288,8 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposits' -> Context.get_baker (B genesis) ~round:Round.zero >>=? fun baker_b1 -> let reward_for_b1' = - if Signature.Public_key_hash.equal baker_b2' baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2' baker_b1 then + baking_reward else Tez.zero in let expected_balance' = @@ -396,7 +398,7 @@ let test_committee_sampling () = Format.fprintf ppf "@[- %a %d%a@]@," - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh n (fun ppf failed -> diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_deactivation.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_deactivation.ml index 037c5a408f34..3750866824ba 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_deactivation.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_deactivation.ml @@ -311,7 +311,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a1 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m1.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m1.pkh)) ; let constants = Default_parameters.constants_test in let one_roll = constants.tokens_per_roll in Op.transaction ~force_reveal:true (B b) a1 a3 one_roll >>=? fun transact -> @@ -324,7 +324,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a3 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m3.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m3.pkh)) ; check_active_staking_balance ~loc:__LOC__ ~deactivated:false b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m1 diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_delegation.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_delegation.ml index ab15ba16671f..b7816b92dc6d 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_delegation.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_delegation.ml @@ -305,11 +305,11 @@ let undelegated_originated_bootstrap_contract () = let delegated_implicit_bootstrap_contract () = (* These values are fixed because we use a fixed RNG seed. *) let from_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" in let to_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1MBWU1WkszFfkEER2pgn4ATKXE9ng7x1sR" in let bootstrap_delegations = [(from_pkh, to_pkh)] in diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_baking.ml index 3eb68159fc42..257db7b4a190 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -52,7 +52,7 @@ let block_fork ?policy (contract_a, contract_b) b = let order_block_hashes ~correct_order bh1 bh2 = let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in - let c = Block_hash.compare hash1 hash2 in + let c = Tezos_crypto.Block_hash.compare hash1 hash2 in if correct_order then if c < 0 then (bh1, bh2) else (bh2, bh1) else if c < 0 then (bh2, bh1) else (bh1, bh2) @@ -95,7 +95,7 @@ let test_valid_double_baking_evidence () = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -119,7 +119,7 @@ let test_valid_double_baking_followed_by_double_endorsing () = >>=? fun blk_with_db_evidence -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in @@ -168,7 +168,7 @@ let test_valid_double_endorsing_followed_by_double_baking () = Block.bake blk_2 >>=? fun blk_b -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_endorsement.ml index b91a39c9d528..2a7de51129f4 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -52,7 +52,7 @@ let block_fork b = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -237,8 +237,11 @@ let test_different_delegates () = Context.get_first_different_endorsers (B blk_b) >>=? fun (endorser_b1c, endorser_b2c) -> let endorser_b, b_slots = - if Signature.Public_key_hash.( = ) endorser_a endorser_b1c.delegate then - (endorser_b2c.delegate, endorser_b2c.slots) + if + Tezos_crypto.Signature.Public_key_hash.( = ) + endorser_a + endorser_b1c.delegate + then (endorser_b2c.delegate, endorser_b2c.slots) else (endorser_b1c.delegate, endorser_b1c.slots) in Op.endorsement @@ -275,7 +278,7 @@ let test_wrong_delegate () = Context.get_endorser_n (B blk_b) 0 >>=? fun (endorser0, slots0) -> Context.get_endorser_n (B blk_b) 1 >>=? fun (endorser1, slots1) -> let endorser_b, b_slots = - if Signature.Public_key_hash.equal endorser_a endorser0 then + if Tezos_crypto.Signature.Public_key_hash.equal endorser_a endorser0 then (endorser1, slots1) else (endorser0, slots0) in @@ -295,8 +298,11 @@ let test_freeze_more_with_low_balance = Context.get_endorsers ctxt >>=? function | [d1; d2] -> return - (if Signature.Public_key_hash.equal account d1.delegate then d1 - else if Signature.Public_key_hash.equal account d2.delegate then d2 + (if Tezos_crypto.Signature.Public_key_hash.equal account d1.delegate + then d1 + else if + Tezos_crypto.Signature.Public_key_hash.equal account d2.delegate + then d2 else assert false) .slots | _ -> assert false @@ -327,7 +333,8 @@ let test_freeze_more_with_low_balance = in let check_unique_endorser b account2 = Context.get_endorsers (B b) >>=? function - | [{delegate; _}] when Signature.Public_key_hash.equal account2 delegate -> + | [{delegate; _}] + when Tezos_crypto.Signature.Public_key_hash.equal account2 delegate -> return_unit | _ -> failwith "We are supposed to only have account2 as endorser." in diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_preendorsement.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_preendorsement.ml index 369f52642e52..b7a4f0087a03 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_preendorsement.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_double_preendorsement.ml @@ -134,7 +134,7 @@ end = struct let denun_reward = Test_tez.(lost_deposit /! 2L) in (* if the baker is the endorser, he'll only loose half of the deposits *) let expected_endo_loss = - if Signature.Public_key_hash.equal baker d1 then + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then Test_tez.(lost_deposit -! denun_reward) else lost_deposit in @@ -148,7 +148,8 @@ end = struct burnt deposit of d1, so it's higher *) let high, low = - if Signature.Public_key_hash.equal baker d1 then (bal_good, bal_bad) + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then + (bal_good, bal_bad) else (bal_bad, bal_good) in let diff_baker = Test_tez.(high -! low) in @@ -160,7 +161,7 @@ end = struct let order_preendorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_participation.ml index 7b39c2bfed10..93c4b456c302 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/consensus/test_participation.ml @@ -42,7 +42,7 @@ let bake_and_endorse_once (b_pred, b_cur) baker endorser = List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.equal delegate endorser then + if Tezos_crypto.Signature.Public_key_hash.equal delegate endorser then Some (delegate, slots) else None) endorsers_list diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_costs.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_costs.ml index ab5546d1fe6b..9cd6b83539f3 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_costs.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_costs.ml @@ -54,7 +54,7 @@ let dummy_map = let dummy_timestamp = Script_timestamp.of_zint (Z.of_int 42) let dummy_pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" let dummy_bytes = Bytes.of_string "dummy" diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_levels.ml index 1866f629aead..968abd261fd6 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -198,7 +198,7 @@ let apply_with_gas header ?(operations = []) (pred : Block.t) = let open Alpha_context in (let open Environment.Error_monad in begin_application - ~chain_id:Chain_id.zero + ~chain_id:Tezos_crypto.Chain_id.zero ~predecessor_context:pred.context ~predecessor_fitness:pred.header.shell.fitness ~predecessor_timestamp:pred.header.shell.timestamp diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_interpretation.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_interpretation.ml index 6112dbb07fff..06d13b7b9814 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_interpretation.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_interpretation.ml @@ -201,7 +201,9 @@ let test_json_roundtrip_err name e () = e let error_encoding_tests = - let contract_zero = Contract.Implicit Signature.Public_key_hash.zero in + let contract_zero = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero + in let script_expr_int = Micheline.strip_locations (Micheline.Int (0, Z.zero)) in List.map (fun (name, e) -> diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_sapling.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_sapling.ml index 5700e081805e..8321c3ce9fae 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_sapling.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_sapling.ml @@ -279,7 +279,7 @@ module Raw_context_tests = struct let gen_root () = Data_encoding.Binary.of_bytes_exn Validator.Hash.encoding - (Hacl.Rand.gen 32) + (Tezos_crypto.Hacl.Rand.gen 32) in let roots_ctx = WithExceptions.List.init diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index f8b6638f0a07..b204e70a2322 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -235,7 +235,7 @@ let check_value_size () = =========== *) @ (let show fmt (Script_typed_ir.Script_signature.Signature_tag s) = - Signature.pp fmt s + Tezos_crypto.Signature.pp fmt s in exs ~error:8 nsample show Signature_t ": signature") (* @@ -260,13 +260,13 @@ let check_value_size () = Key_hash_t ========== *) - @ (let show = Signature.Public_key_hash.pp in + @ (let show = Tezos_crypto.Signature.Public_key_hash.pp in exs nsample show Key_hash_t ": key_hash") (* Key_t ===== *) - @ (let show = Signature.Public_key.pp in + @ (let show = Tezos_crypto.Signature.Public_key.pp in exs nsample show Key_t ": key_t") (* Timestamp_t diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_balance.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_balance.ml index f3d74a420ebb..7a50c5383e8b 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_balance.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_balance.ml @@ -40,7 +40,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_manager.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_manager.ml index af141fd7d45d..27c70e08a217 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_manager.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_ticket_manager.ml @@ -46,7 +46,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_timelock.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_timelock.ml index 76f0b047940a..670c67f9a584 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_timelock.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/michelson/test_timelock.ml @@ -25,7 +25,7 @@ (** Testing ------- - Component: Protocol (Timelock) + Component: Protocol (Tezos_crypto.Timelock) Invocation: cd src/proto_alpha/lib_protocol/test/integration/michelson && \ dune exec ./main.exe -- test "^timelock$" Subject: On timelock @@ -36,20 +36,29 @@ open Protocol let wrap e = Lwt.return (Environment.wrap_tzresult e) let simple_test () = - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value in assert (unlocked_value = same_unlocked) ; - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value + in let message = Bytes.create 12 in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let expected_result = Environment.Timelock.Correct message in - let chest_key = Timelock.{unlocked_value; proof} in - let chest = Timelock.{locked_value; rsa_public = public; ciphertext = c} in + let chest_key = Tezos_crypto.Timelock.{unlocked_value; proof} in + let chest = + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} + in let result = Environment.Timelock.open_chest chest chest_key ~time in assert (result = expected_result) ; return_unit @@ -77,30 +86,39 @@ let contract_test () = in Context.init3 ~consensus_threshold:0 () >>=? fun (b, (src, _c2, _c3)) -> originate_contract "contracts/timelock.tz" "0xaa" src b >>=? fun (dst, b) -> - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let _same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value + in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value in - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in let message = Bytes.of_string "this is my message" in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let check_storage chest chest_key expected_storage_hexa = let chest_key_bytes = "0x" ^ Hex.show (Hex.of_bytes (Data_encoding.Binary.to_bytes_exn - Timelock.chest_key_encoding + Tezos_crypto.Timelock.chest_key_encoding chest_key)) in let chest_bytes = "0x" ^ Hex.show (Hex.of_bytes - (Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest)) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest)) in let michelson_string = Format.sprintf "(Pair %s %s )" chest_key_bytes chest_bytes @@ -128,9 +146,9 @@ let contract_test () = assert (to_check = expected_storage_hexa) ; return_unit in - let chest_key_correct = Timelock.{unlocked_value; proof} in + let chest_key_correct = Tezos_crypto.Timelock.{unlocked_value; proof} in let chest_correct = - Timelock.{locked_value; rsa_public = public; ciphertext = c} + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} in check_storage chest_correct @@ -138,25 +156,36 @@ let contract_test () = (Hex.show (Hex.of_bytes message)) >>=? fun () -> (* We redo an RSA parameters generation to create incorrect cipher and proof *) - let public_bogus, secret_bogus = Timelock.gen_rsa_keys () in - let locked_value_bogus = Timelock.gen_locked_value public_bogus in + let public_bogus, secret_bogus = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value_bogus = + Tezos_crypto.Timelock.gen_locked_value public_bogus + in let time = 1000 in let unlocked_value_bogus = - Timelock.unlock_with_secret secret_bogus ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_with_secret + secret_bogus + ~time + locked_value_bogus in let _same_unlocked, proof_bogus = - Timelock.unlock_and_prove_without_secret public ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value_bogus in let sym_key_bogus = - Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus in - let c_bogus = Timelock.encrypt sym_key_bogus message in + let c_bogus = Tezos_crypto.Timelock.encrypt sym_key_bogus message in let chest_incorrect = - Timelock.{locked_value; rsa_public = public; ciphertext = c_bogus} + Tezos_crypto.Timelock. + {locked_value; rsa_public = public; ciphertext = c_bogus} in check_storage chest_incorrect chest_key_correct "00" >>=? fun () -> - let chest_key_incorrect = Timelock.{unlocked_value; proof = proof_bogus} in + let chest_key_incorrect = + Tezos_crypto.Timelock.{unlocked_value; proof = proof_bogus} + in check_storage chest_correct chest_key_incorrect "01" >>=? fun () -> return_unit diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_activation.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_activation.ml index c96449bb68fd..913c679007b3 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_activation.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_activation.ml @@ -85,19 +85,21 @@ let secrets () = let passphrase = Bytes.(cat (of_string email) (of_string password)) in let sk = Tezos_client_base.Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in (pkh, pk, sk) in List.map (fun (mnemonic, secret, amount, pkh, password, email) -> let pkh', pk, sk = read_key mnemonic email password in - let pkh = Signature.Public_key_hash.of_b58check_exn pkh in - assert (Signature.Public_key_hash.equal pkh pkh') ; + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh in + assert (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') ; let account = Account.{pkh; pk; sk} in Account.add_account account ; { @@ -487,7 +489,7 @@ let test_invalid_activation_inexistent_pkh () = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd secrets in let inexistent_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1PeQHGKPWSpNoozvxgqLN9TFsj6rDqNV3o" in Op.activation (B blk) inexistent_pkh activation_code >>=? fun operation -> diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_reveal.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_reveal.ml index a6f16e28c19a..40ef088ef31f 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_reveal.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_reveal.ml @@ -146,12 +146,12 @@ let test_reveal_with_fake_account () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> @@ -228,12 +228,12 @@ let test_reveal_with_fake_account_already_revealed () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_tx_rollup.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_tx_rollup.ml index efc0839283bb..b848fe414f1f 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_tx_rollup.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_tx_rollup.ml @@ -310,7 +310,9 @@ let commitment_hash_testable = Alcotest.testable Tx_rollup_commitment_hash.pp Tx_rollup_commitment_hash.( = ) let public_key_hash_testable = - Alcotest.testable Signature.Public_key_hash.pp Signature.Public_key_hash.( = ) + Alcotest.testable + Tezos_crypto.Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.( = ) let raw_level_testable = Alcotest.testable Raw_level.pp Raw_level.( = ) @@ -326,7 +328,7 @@ let gen_l2_account ?rng_state () = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255)) rng_state in - let _pkh, public_key, secret_key = Bls.generate_key ?seed () in + let _pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key ?seed () in (secret_key, public_key, Tx_rollup_l2_address.of_bls_pk public_key) (** [make_ticket_key ty contents ticketer tx_rollup] computes the ticket hash @@ -410,7 +412,7 @@ let make_deposit b tx_rollup l1_src addr = (** Create an incomplete (but valid) commitment for a given level. It is incomplete in the sense that the Merkle roots for each message are generated - with [Context_hash.hash_string message_index]. In the meantime provides the + with [Tezos_crypto.Context_hash.hash_string message_index]. In the meantime provides the list of withdraw in a association list of [batch_index -> withdraw_list]. Be careful not to provide a too-big withdraw_list as the construction is expensive *) @@ -421,7 +423,8 @@ let make_incomplete_commitment_for_batch context level tx_rollup withdraw_list = Data_encoding.Binary.to_string_exn Tx_rollup_inbox.encoding metadata in List.init ~when_negative_length:[] metadata.inbox_length (fun i -> - Context_hash.hash_string [str_for_context_hash ^ string_of_int i]) + Tezos_crypto.Context_hash.hash_string + [str_for_context_hash ^ string_of_int i]) >>?= fun batches_result -> let messages = List.mapi @@ -1599,7 +1602,7 @@ let test_commitment_duplication () = let batches2 : Tx_rollup_message_result_hash.t list = [Bytes.make 20 '1'; Bytes.make 20 '2'] |> List.map (fun hash -> - let context_hash = Context_hash.hash_bytes [hash] in + let context_hash = Tezos_crypto.Context_hash.hash_bytes [hash] in Tx_rollup_message_result_hash.hash_uncarbonated { context_hash; @@ -2266,7 +2269,7 @@ module Rejection = struct Tx_rollup_message_result_hash.hash_uncarbonated { context_hash = - Context_hash.of_b58check_exn + Tezos_crypto.Context_hash.of_b58check_exn "CoUiEnajKeukmYFUgWTJF2z3v24MycpTaomF8a9hRzVy7as9hvgy"; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; }; @@ -2336,7 +2339,8 @@ module Rejection = struct let* store = init_l2_store () in let* hash_tree = hash_tree_from_store store in assert ( - Context_hash.(hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; + Tezos_crypto.Context_hash.( + hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; return_unit (** [make_proof store msg] applies [msg] on [store] and returns the @@ -2364,7 +2368,7 @@ module Rejection = struct { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } @@ -2687,7 +2691,7 @@ module Rejection = struct let level1 = tx_level 1l in make_invalid_commitment b level0 l2_context_hash >>=? fun (b, commitment0) -> - make_invalid_commitment b level1 Context_hash.zero + make_invalid_commitment b level1 Tezos_crypto.Context_hash.zero >>=? fun (b, commitment1) -> Context.get_constants (B b) >>=? fun constants -> let bond_cost = constants.parametric.tx_rollup.commitment_bond in @@ -2923,7 +2927,7 @@ module Rejection = struct let previous_message_result : Tx_rollup_message_result.t = { (* Expected is Tx_rollup_commitment.empty_l2_context_hash *) - context_hash = Context_hash.zero; + context_hash = Tezos_crypto.Context_hash.zero; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; } in @@ -4493,7 +4497,7 @@ module Withdraw = struct ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - (Context_hash.hash_bytes [Bytes.make 20 'c']) + (Tezos_crypto.Context_hash.hash_bytes [Bytes.make 20 'c']) (* any context hash will fail *) [ticket_info] (* any non-empty list will fail *) diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_voting.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_voting.ml index c02237ef02ea..0b8054530e79 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_voting.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/operations/test_voting.ml @@ -83,10 +83,10 @@ let expected_qr_num participation_ema = *. (of_int qr_max_num -. of_int qr_min_num) /. of_int den) -(* Protocol_hash.zero is "PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i" *) +(* Tezos_crypto.Protocol_hash.zero is "PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i" *) let protos = Array.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [| "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -228,9 +228,9 @@ let equal_delegate_info a b = Option.equal Int64.equal a.Vote.voting_power b.Vote.voting_power && Option.equal Vote.equal_ballot a.current_ballot b.current_ballot && List.equal - Protocol_hash.equal - (List.sort Protocol_hash.compare a.current_proposals) - (List.sort Protocol_hash.compare b.current_proposals) + Tezos_crypto.Protocol_hash.equal + (List.sort Tezos_crypto.Protocol_hash.compare a.current_proposals) + (List.sort Tezos_crypto.Protocol_hash.compare b.current_proposals) && Int.equal a.remaining_proposals b.remaining_proposals let assert_equal_info ~loc a b = @@ -310,8 +310,9 @@ let test_successful_vote num_delegates () = let props = List.map (fun i -> protos.(i)) (2 -- Constants.max_proposals_per_delegate) in - Op.proposals (B b) del1 (Protocol_hash.zero :: props) >>=? fun ops1 -> - Op.proposals (B b) del2 [Protocol_hash.zero] >>=? fun ops2 -> + Op.proposals (B b) del1 (Tezos_crypto.Protocol_hash.zero :: props) + >>=? fun ops1 -> + Op.proposals (B b) del2 [Tezos_crypto.Protocol_hash.zero] >>=? fun ops2 -> Block.bake ~operations:[ops1; ops2] b >>=? fun b -> Context.Delegate.voting_info (B b) pkh1 >>=? fun info1 -> Context.Delegate.voting_info (B b) pkh2 >>=? fun info2 -> @@ -321,7 +322,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow1; current_ballot = None; - current_proposals = Protocol_hash.zero :: props; + current_proposals = Tezos_crypto.Protocol_hash.zero :: props; remaining_proposals = 0; } >>=? fun () -> @@ -331,7 +332,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow2; current_ballot = None; - current_proposals = [Protocol_hash.zero]; + current_proposals = [Tezos_crypto.Protocol_hash.zero]; remaining_proposals = Constants.max_proposals_per_delegate - 1; } >>=? fun () -> @@ -350,7 +351,8 @@ let test_successful_vote num_delegates () = | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* proposing more than maximum_proposals fails *) - Op.proposals (B b) del1 (Protocol_hash.zero :: props) >>=? fun ops -> + Op.proposals (B b) del1 (Tezos_crypto.Protocol_hash.zero :: props) + >>=? fun ops -> Block.bake ~operations:[ops] b >>= fun res -> Assert.proto_error_with_info ~loc:__LOC__ res "Too many proposals" >>=? fun () -> @@ -377,17 +379,17 @@ let test_successful_vote num_delegates () = (* current proposal must be set during exploration period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p2 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p2 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> - Op.ballot (B b) del1 Protocol_hash.zero Vote.Nay >>=? fun op -> + Op.ballot (B b) del1 Tezos_crypto.Protocol_hash.zero Vote.Nay >>=? fun op -> Block.bake ~operations:[op] b >>= fun res -> Context.Delegate.voting_info (B b) pkh1 >>=? fun info1 -> assert_equal_info @@ -448,13 +450,13 @@ let test_successful_vote num_delegates () = (* current proposal must be set during promotion period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p4 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p4 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -489,11 +491,11 @@ let test_successful_vote num_delegates () = Context.Vote.get_protocol b >>= fun p -> Assert.equal ~loc:__LOC__ - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Unexpected proposal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p - Protocol_hash.zero + Tezos_crypto.Protocol_hash.zero >>=? fun () -> return_unit (* given a list of active delegates, @@ -545,7 +547,7 @@ let test_not_enough_quorum_in_exploration num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun ops -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] >>=? fun ops -> Block.bake ~operations:[ops] b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -567,7 +569,7 @@ let test_not_enough_quorum_in_exploration num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -599,7 +601,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun ops -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] >>=? fun ops -> Block.bake ~operations:[ops] b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -615,7 +617,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -646,7 +648,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -671,7 +673,10 @@ let test_multiple_identical_proposals_count_as_one () = context_init 1 () >>=? fun (b, delegates) -> assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd delegates in - Op.proposals (B b) proposer [Protocol_hash.zero; Protocol_hash.zero] + Op.proposals + (B b) + proposer + [Tezos_crypto.Protocol_hash.zero; Tezos_crypto.Protocol_hash.zero] >>=? fun ops -> Block.bake ~operations:[ops] b >>=? fun b -> (* compute the weight of proposals *) @@ -801,7 +806,7 @@ let test_supermajority_in_exploration supermajority () = (* assert our proposal won *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal proposal v) then return_unit + if Tezos_crypto.Protocol_hash.(equal proposal v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> @@ -864,7 +869,7 @@ let test_quorum_capped_maximum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in @@ -904,7 +909,7 @@ let test_quorum_capped_minimum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/test_frozen_bonds.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/test_frozen_bonds.ml index 3717b5e8317a..1a66ef0c7bbe 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/test_frozen_bonds.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/test_frozen_bonds.ml @@ -54,7 +54,7 @@ let very_small_random_amount () = | Some x -> x let nonce_zero = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_tx_rollup ?(nonce = nonce_zero) () = ( Tx_rollup.Internal_for_tests.originated_tx_rollup nonce, @@ -74,13 +74,13 @@ let create_context () = delegate's pkh. *) let init_test ~user_is_delegate = create_context () >>=? fun (ctxt, _) -> - let delegate, delegate_pk, _ = Signature.generate_key () in + let delegate, delegate_pk, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract = Contract.Implicit delegate in let delegate_account = `Contract (Contract.Implicit delegate) in let user_contract = if user_is_delegate then delegate_contract else - let user, _, _ = Signature.generate_key () in + let user, _, _ = Tezos_crypto.Signature.generate_key () in Contract.Implicit user in let user_account = `Contract user_contract in @@ -398,7 +398,7 @@ let test_rpcs () = let test_scenario scenario = init_test ~user_is_delegate:false >>=? fun (ctxt, user_contract, user_account, delegate1) -> - let delegate2, delegate_pk2, _ = Signature.generate_key () in + let delegate2, delegate_pk2, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract2 = Contract.Implicit delegate2 in let delegate_account2 = `Contract delegate_contract2 in let delegate_balance2 = big_random_amount () in diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/test_token.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/test_token.ml index 4a05fb1a885e..e9b9966a4c43 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/test_token.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/test_token.ml @@ -52,7 +52,8 @@ let random_amount () = | None -> assert false | Some x -> x -let nonce = Origination_nonce.Internal_for_tests.initial Operation_hash.zero +let nonce = + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_rollup () = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce @@ -61,7 +62,7 @@ let test_simple_balances () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = `Contract (Contract.Implicit pkh) in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in let amount = Tez.one in wrap (Token.transfer ctxt src dest amount) >>=? fun (ctxt', _) -> @@ -80,7 +81,7 @@ let test_simple_balance_updates () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = Contract.Implicit pkh in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = Tez.one in wrap (Token.transfer ctxt (`Contract src) (`Contract dest) amount) @@ -129,7 +130,7 @@ let test_allocated () = create_context () >>=? fun (ctxt, pkh) -> let dest = `Delegate_balance pkh in test_allocated_and_still_allocated_when_empty ctxt dest true >>=? fun _ -> - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in test_allocated_and_deallocated_when_empty ctxt dest >>=? fun _ -> let dest = `Collected_commitments Blinded_public_key_hash.zero in @@ -182,7 +183,7 @@ let test_transferring_to_sink ctxt sink amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res "Overflowing tez addition" let test_transferring_to_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -201,7 +202,7 @@ let test_transferring_to_collected_commitments ctxt = [(Commitments bpkh, Credited amount, Block_application)] let test_transferring_to_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -211,7 +212,7 @@ let test_transferring_to_delegate_balance ctxt = [(Contract dest, Credited amount, Block_application)] let test_transferring_to_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_to_sink ctxt @@ -253,7 +254,7 @@ let test_transferring_to_burned ctxt = ]) true >>=? fun () -> - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in let p, r = (Random.bool (), Random.bool ()) in wrap (Token.transfer ctxt `Minted (`Lost_endorsing_rewards (pkh, p, r)) amount) @@ -279,7 +280,7 @@ let test_transferring_to_burned ctxt = true let test_transferring_to_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -379,7 +380,7 @@ let test_transferring_from_bounded_source ctxt src amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res error_title let test_transferring_from_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let src = Contract.Implicit pkh in let amount = random_amount () in test_transferring_from_bounded_source @@ -398,7 +399,7 @@ let test_transferring_from_collected_commitments ctxt = [(Commitments bpkh, Debited amount, Block_application)] let test_transferring_from_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in let src = Contract.Implicit pkh in test_transferring_from_bounded_source @@ -408,7 +409,7 @@ let test_transferring_from_delegate_balance ctxt = [(Contract src, Debited amount, Block_application)] let test_transferring_from_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_from_bounded_source ctxt @@ -425,7 +426,7 @@ let test_transferring_from_collected_fees ctxt = [(Block_fees, Debited amount, Block_application)] let test_transferring_from_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -496,13 +497,13 @@ let cast_to_container_type x = let build_test_cases () = create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let baker1, baker1_pk, _ = Signature.generate_key () in + let baker1, baker1_pk, _ = Tezos_crypto.Signature.generate_key () in let baker1c = `Contract (Contract.Implicit baker1) in - let baker2, baker2_pk, _ = Signature.generate_key () in + let baker2, baker2_pk, _ = Tezos_crypto.Signature.generate_key () in let baker2c = `Contract (Contract.Implicit baker2) in (* Allocate contracts for user1, user2, baker1, and baker2. *) wrap (Token.transfer ctxt origin user1c (random_amount ())) @@ -705,13 +706,13 @@ let test_transfer_n_with_non_empty_source () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let user3, _, _ = Signature.generate_key () in + let user3, _, _ = Tezos_crypto.Signature.generate_key () in let user3c = `Contract (Contract.Implicit user3) in - let user4, _, _ = Signature.generate_key () in + let user4, _, _ = Tezos_crypto.Signature.generate_key () in let user4c = `Contract (Contract.Implicit user4) in (* Allocate contracts for user1, user2, user3, and user4. *) let amount = diff --git a/src/proto_014_PtKathma/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_014_PtKathma/lib_protocol/test/integration/validate/manager_operation_helpers.ml index b8a6f9ac3d45..0e15bf9ec8f9 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -823,7 +823,7 @@ let mk_tx_rollup_reject (oinfos : operation_req) (infos : infos) = { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } in @@ -908,7 +908,7 @@ let mk_tx_rollup_dispacth_ticket (oinfos : operation_req) (infos : infos) = ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - Context_hash.zero + Tezos_crypto.Context_hash.zero [reveal] let mk_sc_rollup_origination (oinfos : operation_req) (infos : infos) = @@ -1167,7 +1167,7 @@ let make_tztest_batched ?(fmt = Format.std_formatter) name test subjects increment of the counters aka 1 for a single operation, n for a batch of n manager operations. *) type probes = { - source : Signature.Public_key_hash.t; + source : Tezos_crypto.Signature.Public_key_hash.t; fee : Tez.tez; gas_limit : Gas.Arith.integral; nb_counter : Z.t; diff --git a/src/proto_014_PtKathma/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_014_PtKathma/lib_protocol/test/pbt/test_script_comparison.ml index ce5313b77904..dd8c348f7942 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/pbt/test_script_comparison.ml @@ -57,8 +57,9 @@ let rec reference_compare_comparable : type a. a comparable_ty -> a -> a -> int | Bool_t, x, y -> normalize_compare @@ Compare.Bool.compare x y | Mutez_t, x, y -> normalize_compare @@ Tez.compare x y | Key_hash_t, x, y -> - normalize_compare @@ Signature.Public_key_hash.compare x y - | Key_t, x, y -> normalize_compare @@ Signature.Public_key.compare x y + normalize_compare @@ Tezos_crypto.Signature.Public_key_hash.compare x y + | Key_t, x, y -> + normalize_compare @@ Tezos_crypto.Signature.Public_key.compare x y | Int_t, x, y -> normalize_compare @@ Script_int.compare x y | Nat_t, x, y -> normalize_compare @@ Script_int.compare x y | Timestamp_t, x, y -> normalize_compare @@ Script_timestamp.compare x y diff --git a/src/proto_014_PtKathma/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml b/src/proto_014_PtKathma/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml index c3e10928e679..56c0ba7dc365 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml @@ -48,7 +48,9 @@ let bls_pk = `Hex "8fee216367c463821f82c942a1cee3a01469b1da782736ca269a2accea6e0cc4" |> Hex.to_bytes_exn in - let _pkh, public_key, _secret_key = Bls.generate_key ~seed:ikm () in + let _pkh, public_key, _secret_key = + Tezos_crypto.Bls.generate_key ~seed:ikm () + in public_key let l2_address = Protocol.Tx_rollup_l2_address.of_bls_pk bls_pk @@ -77,7 +79,7 @@ let idx_l2_address_gen = oneof [idx_l2_address_idx_gen; return idx_l2_address_value] let public_key_hash = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" let public_key_hash_gen = @@ -90,7 +92,9 @@ let ticket_hash : Protocol.Alpha_context.Ticket_hash.t = (* TODO: https://gitlab.com/tezos/tezos/-/issues/2592 we could introduce a bit more randomness here *) let ticketer_b58 = "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" in - let ticketer_pkh = Signature.Public_key_hash.of_b58check_exn ticketer_b58 in + let ticketer_pkh = + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn ticketer_b58 + in let ticketer = Protocol.Alpha_context.Contract.Implicit ticketer_pkh in Tx_rollup_l2_helpers.make_unit_ticket_key ticketer l2_address diff --git a/src/proto_014_PtKathma/lib_protocol/test/regression/test_logging.ml b/src/proto_014_PtKathma/lib_protocol/test/regression/test_logging.ml index bd3484c9ff53..e9064038bf9c 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/regression/test_logging.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/regression/test_logging.ml @@ -153,7 +153,8 @@ let test_context () = let* b, _contract = Context.init1 ~consensus_threshold:0 () in let* inc = Incremental.begin_construction b in let ctxt = Incremental.alpha_ctxt inc in - return @@ Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + return + @@ Alpha_context.Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero let run_script {filename; amount; storage; parameter} () = let get_log, logger = logger () in diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_contract_repr.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_contract_repr.ml index 1f7f33a7cfa6..9a758c030b67 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_contract_repr.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_contract_repr.ml @@ -47,7 +47,7 @@ module Test_contract_repr = struct open Contract_repr let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash @@ -61,7 +61,8 @@ module Test_contract_repr = struct in Contract_hash.hash_bytes [data] - let dummy_implicit_contract = Implicit Signature.Public_key_hash.zero + let dummy_implicit_contract = + Implicit Tezos_crypto.Signature.Public_key_hash.zero let dummy_originated_contract = originated_contract @@ dummy_origination_nonce @@ -72,7 +73,7 @@ module Test_contract_repr = struct "%s should have been equal to %" Format.pp_print_string (to_b58check dummy_implicit_contract) - Signature.Public_key_hash.(to_b58check zero) + Tezos_crypto.Signature.Public_key_hash.(to_b58check zero) let test_to_b58check_originated () = Assert.equal diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_destination_repr.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_destination_repr.ml index 6bb7638b99f2..f9d4b2fe1b86 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_destination_repr.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_destination_repr.ml @@ -36,7 +36,7 @@ open Protocol open Tztest let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_receipt.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_receipt.ml index 49854e2054ac..bb2d82de5302 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_receipt.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_receipt.ml @@ -68,7 +68,7 @@ let test_encodings balance = let test_encodings () = let open Receipt in - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in test_encodings (Contract (Contract.Implicit pkh)) >>=? fun () -> test_encodings Block_fees >>=? fun () -> test_encodings (Deposits pkh) >>=? fun () -> @@ -89,7 +89,8 @@ let test_encodings () = test_encodings Initial_commitments >>=? fun () -> test_encodings Minted >>=? fun () -> let nonce = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial + Tezos_crypto.Operation_hash.zero in let tx_rollup = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_arith.ml index 5b11bcf1270e..b4c27a603e8d 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -65,7 +65,8 @@ module Arith_Context = struct let kinded_hash_to_state_hash = function | `Value hash | `Node hash -> - Sc_rollup_repr.State_hash.hash_bytes [Context_hash.to_bytes hash] + Sc_rollup_repr.State_hash.hash_bytes + [Tezos_crypto.Context_hash.to_bytes hash] let proof_before proof = kinded_hash_to_state_hash proof.Context_binary.Proof.before diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml index 9d13f975705f..d87843d0888f 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml @@ -91,7 +91,7 @@ let test_encode_decode_internal_inbox_message () = let source = Result.get_ok ~loc:__LOC__ - (Signature.Public_key_hash.of_b58check + (Tezos_crypto.Signature.Public_key_hash.of_b58check "tz1RjtZUVeLhADFHDL8UwDZA6vjWWhojpu5w") in let*? (Script_typed_ir.Ty_ex_c pair_nat_ticket_string_ty) = diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_storage.ml index 6855cfac1d01..f532dd1b3224 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -51,7 +51,9 @@ let new_context_with_stakers nb_stakers = let state = Incremental.validation_state inc in let ctxt = state.ctxt in (* Necessary to originate rollups. *) - let ctxt = Alpha_context.Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = + Alpha_context.Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero + in let ctxt = Alpha_context.Internal_for_tests.to_raw ctxt in let stakers = List.map @@ -67,7 +69,7 @@ let new_context () = let* ctxt, _stakers = new_context_with_stakers 1 in (* Mint some tez for staker accounts. *) let mint_tez_for ctxt pkh_str = - let pkh = Signature.Public_key_hash.of_b58check_exn pkh_str in + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh_str in let contract = Contract_repr.Implicit pkh in let+ ctxt, _ = lift @@ -341,7 +343,7 @@ let test_deposit_then_withdraw () = let* ctxt = new_context () in let* rollup, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in @@ -359,7 +361,7 @@ let test_withdraw_when_not_staked () = let* ctxt = new_context () in let* rollup, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in assert_fails_with @@ -371,7 +373,7 @@ let test_withdrawing_twice () = let* ctxt = new_context () in let* rollup, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2.ml index b95ed7e35c17..a2368b23c186 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2.ml @@ -518,7 +518,7 @@ module Test_batch_encodings = struct Format.fprintf fmt "@[Withdraw:@ destination=%a,@ ticket_hash=%a,@ qty:%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp destination Alpha_context.Ticket_hash.pp ticket_hash diff --git a/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml b/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml index 94cccfe10ab9..dc16a0e7e123 100644 --- a/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml +++ b/src/proto_014_PtKathma/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml @@ -48,7 +48,7 @@ open Indexable (** {3. Various helpers to facilitate the tests. } *) -let pkh = Signature.Public_key_hash.zero +let pkh = Tezos_crypto.Signature.Public_key_hash.zero let ((_, pk1, addr1) as l2_addr1) = gen_l2_address () @@ -84,7 +84,7 @@ let expect_error_status ~msg error status cont = let aggregate_signature_exn : signature list -> signature = fun signatures -> - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> res | None -> raise (Invalid_argument "aggregate_signature_exn") @@ -127,7 +127,7 @@ let pp_metadata fmt Tx_rollup_l2_context_sig.{counter; public_key} = fmt "{counter=%d; public_key=%a}" counter - Bls.Public_key.pp + Tezos_crypto.Bls.Public_key.pp public_key let eq_metadata = Alcotest.of_pp pp_metadata @@ -155,7 +155,7 @@ let pp_withdrawal fmt = function Format.fprintf fmt "{claimer=%a; ticket_hash=%a; amount=%a}" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer Ticket_hash.pp ticket_hash @@ -281,7 +281,7 @@ let batch_from_transfers inputs = (fun all_sks input -> List.fold_left (fun acc (sk, _, _, _, _, _) -> - if List.mem ~equal:Bls.Secret_key.equal sk acc then acc + if List.mem ~equal:Tezos_crypto.Bls.Secret_key.equal sk acc then acc else sk :: acc) [] input diff --git a/src/proto_014_PtKathma/lib_tx_rollup/RPC.ml b/src/proto_014_PtKathma/lib_tx_rollup/RPC.ml index 24b62373f06a..c7c4f6f78be7 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/RPC.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/RPC.ml @@ -31,7 +31,7 @@ open Alpha_context type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] type context_id = [block_id | `Context of Tx_rollup_l2_context_hash.t] @@ -62,7 +62,7 @@ let context_of_id state context_id = let construct_block_id = function | `Head -> "head" | `L2_block h -> L2block.Hash.to_b58check h - | `Tezos_block h -> Block_hash.to_b58check h + | `Tezos_block h -> Tezos_crypto.Block_hash.to_b58check h | `Level l -> L2block.level_to_string l let destruct_block_id h = @@ -76,7 +76,7 @@ let destruct_block_id h = | Error _ -> Error "Invalid rollup level" | Ok l -> Ok (`Level l)) | None -> ( - match Block_hash.of_b58check_opt h with + match Tezos_crypto.Block_hash.of_b58check_opt h with | Some b -> Ok (`Tezos_block b) | None -> ( match L2block.Hash.of_b58check_opt h with @@ -344,7 +344,8 @@ module Block = struct | None -> return_none | Some block -> ( match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) return_none | _ -> return_some block.inbox) @@ -357,9 +358,13 @@ module Block = struct | Some block -> let*? () = match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) - error_with "The tezos block (%a) has not L2 inbox" Block_hash.pp b + error_with + "The tezos block (%a) has not L2 inbox" + Tezos_crypto.Block_hash.pp + b | _ -> ok () in let*? () = diff --git a/src/proto_014_PtKathma/lib_tx_rollup/RPC.mli b/src/proto_014_PtKathma/lib_tx_rollup/RPC.mli index f15657a1fca1..e3062f64be6b 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/RPC.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/RPC.mli @@ -30,7 +30,7 @@ open Protocol type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] val destruct_block_id : string -> (block_id, string) result diff --git a/src/proto_014_PtKathma/lib_tx_rollup/accuser.mli b/src/proto_014_PtKathma/lib_tx_rollup/accuser.mli index 0db3a12ce1ae..d37405227453 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/accuser.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/accuser.mli @@ -38,7 +38,7 @@ val build_rejection : (** [reject_bad_commitment ~source state commitment] injects a rejection operation with [source] if the [commitment] is rejectable. *) val reject_bad_commitment : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> Tx_rollup_commitment.Full.t -> unit tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_tx_rollup/batcher.ml b/src/proto_014_PtKathma/lib_tx_rollup/batcher.ml index b0dce397ccf0..e3e6d0786461 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/batcher.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/batcher.ml @@ -33,7 +33,7 @@ type state = { constants : Constants.t; batch_burn_limit : Tez.t option; index : Context.index; - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; transactions : Tx_queue.t; mutable incr_context : Context.t; lock : Lwt_mutex.t; @@ -158,7 +158,7 @@ let on_register state ~apply (tr : L2_transaction.t) = let open Lwt_result_syntax in Lwt_mutex.with_lock state.lock @@ fun () -> let*? aggregated_signature = - match Bls.aggregate_signature_opt tr.signatures with + match Tezos_crypto.Bls.aggregate_signature_opt tr.signatures with | Some s -> ok s | None -> error_with "could not aggregate signatures of transaction" in @@ -241,7 +241,7 @@ module Types = struct type nonrec state = state type parameters = { - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; index : Context.index; constants : Constants.t; batch_burn_limit : Tez.t option; diff --git a/src/proto_014_PtKathma/lib_tx_rollup/batcher.mli b/src/proto_014_PtKathma/lib_tx_rollup/batcher.mli index a421b1abce55..6a287c15683f 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/batcher.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/batcher.mli @@ -28,7 +28,7 @@ open Alpha_context (** Initialize the internal state of the batcher. *) val init : rollup:Tx_rollup.t -> - signer:Signature.public_key_hash -> + signer:Tezos_crypto.Signature.public_key_hash -> batch_burn_limit:Tez.t option -> Context.index -> Constants.t -> diff --git a/src/proto_014_PtKathma/lib_tx_rollup/context.ml b/src/proto_014_PtKathma/lib_tx_rollup/context.ml index d34031bfb9ac..bf3f172fc419 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/context.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/context.ml @@ -88,10 +88,12 @@ end include Protocol.Tx_rollup_l2_context.Make (Irmin_storage) let context_hash_to_l2 hash = - Context_hash.to_bytes hash |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn + Tezos_crypto.Context_hash.to_bytes hash + |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn let l2_to_context_hash hash = - Protocol.Tx_rollup_l2_context_hash.to_bytes hash |> Context_hash.of_bytes_exn + Protocol.Tx_rollup_l2_context_hash.to_bytes hash + |> Tezos_crypto.Context_hash.of_bytes_exn let exists index hash = Raw.exists index (l2_to_context_hash hash) @@ -223,7 +225,7 @@ let init_context index = let* tree = Prover_context.Ticket_index.init_counter tree in let tree_hash = hash_tree tree in assert ( - Context_hash.( + Tezos_crypto.Context_hash.( tree_hash = Protocol.Tx_rollup_message_result_repr.empty_l2_context_hash)) ; let* ctxt, _ = add_tree ctxt tree in return ctxt diff --git a/src/proto_014_PtKathma/lib_tx_rollup/context.mli b/src/proto_014_PtKathma/lib_tx_rollup/context.mli index 5c781082268d..154f5818a386 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/context.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/context.mli @@ -119,7 +119,7 @@ val produce_proof : (tree -> 'a produce_proof_result Lwt.t) -> (Protocol.Tx_rollup_l2_proof.t * 'a produce_proof_result) tzresult Lwt.t -val hash_tree : tree -> Context_hash.t +val hash_tree : tree -> Tezos_crypto.Context_hash.t (** [add_tree ctxt tree] adds [tree] in the [ctxt]. In order to perform actions on the tree (e.g. proof production), it needs to be persistent. Thus, @@ -133,7 +133,7 @@ val hash_tree : tree -> Context_hash.t val add_tree : context -> tree -> (context * Protocol.Tx_rollup_l2_context_hash.t) Lwt.t -val tree_hash_of_context : context -> Context_hash.t tzresult Lwt.t +val tree_hash_of_context : context -> Tezos_crypto.Context_hash.t tzresult Lwt.t (** {2 Sub-context for tickets } *) diff --git a/src/proto_014_PtKathma/lib_tx_rollup/dispatcher.mli b/src/proto_014_PtKathma/lib_tx_rollup/dispatcher.mli index 7b23a612ab55..e143b73b8ceb 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/dispatcher.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/dispatcher.mli @@ -26,7 +26,7 @@ (** Produce dispatch of withdrawals operations and sends them to the injector. *) val dispatch_withdrawals : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> L2block.t -> unit tzresult Lwt.t diff --git a/src/proto_014_PtKathma/lib_tx_rollup/dune b/src/proto_014_PtKathma/lib_tx_rollup/dune index 7ce59184d796..1694ad3ab301 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/dune +++ b/src/proto_014_PtKathma/lib_tx_rollup/dune @@ -35,7 +35,6 @@ -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base - -open Tezos_crypto -open Tezos_protocol_014_PtKathma -open Tezos_client_014_PtKathma -open Tezos_client_commands diff --git a/src/proto_014_PtKathma/lib_tx_rollup/error.ml b/src/proto_014_PtKathma/lib_tx_rollup/error.ml index fec8c73affba..6b5f3294a2fb 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/error.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/error.ml @@ -217,8 +217,8 @@ let () = type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } let () = @@ -233,15 +233,15 @@ let () = ppf "Rollup origination on disk (%a) is different from the provided rollup \ genesis (%a)" - Block_hash.pp + Tezos_crypto.Block_hash.pp disk_rollup - Block_hash.pp + Tezos_crypto.Block_hash.pp given_rollup) `Permanent Data_encoding.( obj2 - (req "disk_rollup" Block_hash.encoding) - (req "given_rollup" Block_hash.encoding)) + (req "disk_rollup" Tezos_crypto.Block_hash.encoding) + (req "given_rollup" Tezos_crypto.Block_hash.encoding)) (function | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis} -> @@ -251,7 +251,7 @@ let () = Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis}) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -264,10 +264,10 @@ let () = "The operation receipt of %a is unavailable. Please make sure that the \ history mode of the Tezos node you are connecting to matches the \ requirements." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "context" Operation_hash.encoding)) + Data_encoding.(obj1 (req "context" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_no_operation_metadata o -> Some o | _ -> None) (fun o -> Tx_rollup_no_operation_metadata o) @@ -287,7 +287,7 @@ let () = (function Tx_rollup_mismatch -> Some () | _ -> None) (fun () -> Tx_rollup_mismatch) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -298,10 +298,10 @@ let () = Format.fprintf ppf "The Tezos block %a cannot be fetched from the node." - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_cannot_fetch_tezos_block b -> Some b | _ -> None) (fun b -> Tx_rollup_cannot_fetch_tezos_block b) @@ -396,7 +396,7 @@ let () = type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t let () = register_error_kind @@ -409,13 +409,13 @@ let () = "No inbox on L1 for rollup level %a at block %a" Protocol.Alpha_context.Tx_rollup_level.pp l - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent Data_encoding.( obj2 (req "level" Protocol.Alpha_context.Tx_rollup_level.encoding) - (req "block" Block_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_no_proto_inbox (l, b) -> Some (l, b) | _ -> None) (fun (l, b) -> Tx_rollup_no_proto_inbox (l, b)) @@ -543,7 +543,7 @@ let () = (function Tx_rollup_deposit_not_allowed -> Some () | _ -> None) (fun () -> Tx_rollup_deposit_not_allowed) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -555,9 +555,9 @@ let () = ppf "The deposit for our operator was slashed in operation %a. Aborting to \ investigate." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "operation" Operation_hash.encoding)) + Data_encoding.(obj1 (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_deposit_slashed o -> Some o | _ -> None) (fun o -> Tx_rollup_deposit_slashed o) diff --git a/src/proto_014_PtKathma/lib_tx_rollup/error.mli b/src/proto_014_PtKathma/lib_tx_rollup/error.mli index 097c2a811136..f601f2266c31 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/error.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/error.mli @@ -69,18 +69,18 @@ type error += Tx_rollup_no_rollup_info_on_disk_and_no_rollup_genesis_given different from the given rollup genesis. *) type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } (** Error when operation metadata is not available. *) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t (** Error when rollup stored on disk is different from the expected one. *) type error += Tx_rollup_mismatch (** Error when Tezos block cannot be fetched. *) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t (** Error when the tree is not found in the context. *) type error += Tx_rollup_tree_not_found @@ -102,7 +102,7 @@ type error += (** Error when the tezos node does not know the inbox *) type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t (** Error when the node reconstructed a different inbox than the one stored on L1 *) type error += @@ -131,4 +131,4 @@ type error += type error += Tx_rollup_deposit_not_allowed (** Error (fatal) when we are slashed *) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t diff --git a/src/proto_014_PtKathma/lib_tx_rollup/event.ml b/src/proto_014_PtKathma/lib_tx_rollup/event.ml index e97224f42dfc..9a64f9f15734 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/event.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/event.ml @@ -101,7 +101,7 @@ let new_block = ~name:"tx_rollup_node_new_block" ~msg:"new block with hash: {block_hash}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block = declare_2 @@ -109,8 +109,8 @@ let processing_block = ~name:"tx_rollup_node_processing_block" ~msg:"processing block: {block_hash} (pred: {predecessor_hash})" ~level:Debug - ("block_hash", Block_hash.encoding) - ("predecessor_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) let missing_blocks = declare_1 @@ -126,7 +126,7 @@ let look_for_origination = ~name:"tx_rollup_node_look_for_origination" ~msg:"Looking for rollup origination in block {block} level {level}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let detected_origination = @@ -136,7 +136,7 @@ let detected_origination = ~msg:"Detected rollup {rollup} origination in {block}" ~level:Notice ("rollup", Protocol.Alpha_context.Tx_rollup.encoding) - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let tezos_block_processed = declare_2 @@ -144,7 +144,7 @@ let tezos_block_processed = ~name:"tx_rollup_node_tezos_block_processed" ~msg:"tezos block {block_hash} at level {level} was sucessfully processed" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let block_already_processed = @@ -155,7 +155,7 @@ let block_already_processed = "the block {block_hash} has already been processed, nothing more to be \ done" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block_predecessor = declare_2 @@ -165,7 +165,7 @@ let processing_block_predecessor = "processing block predecessor {predecessor_hash} at level \ {predecessor_level}" ~level:Debug - ("predecessor_hash", Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) ("predecessor_level", Data_encoding.int32) let messages_application = @@ -184,7 +184,7 @@ let rollup_block = ~level:Notice ("level", L2block.level_encoding) ("hash", L2block.Hash.encoding) - ("tezos_hash", Block_hash.encoding) + ("tezos_hash", Tezos_crypto.Block_hash.encoding) let inbox_stored = declare_4 @@ -194,7 +194,7 @@ let inbox_stored = "an inbox with size {cumulated_size} and resulting context hash \ {context_hash} has been stored for {block_hash}: {messages}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("messages", Data_encoding.list Inbox.message_encoding) ("cumulated_size", Data_encoding.int31) ("context_hash", Protocol.Tx_rollup_l2_context_hash.encoding) @@ -213,7 +213,7 @@ let new_tezos_head = ~name:"tx_rollup_node_new_tezos_head" ~msg:"a new tezos head ({tezos_head}) is stored" ~level:Notice - ("tezos_head", Block_hash.encoding) + ("tezos_head", Tezos_crypto.Block_hash.encoding) let inject_wait = declare_1 diff --git a/src/proto_014_PtKathma/lib_tx_rollup/fancy_l2block.ml b/src/proto_014_PtKathma/lib_tx_rollup/fancy_l2block.ml index 20588b557dc0..2d0d77a55050 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/fancy_l2block.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/fancy_l2block.ml @@ -280,7 +280,7 @@ let l2_message_encoding = (req "result" transaction_result_encoding)))) (req "withdrawals" (list Tx_rollup_withdraw.encoding)) (req "indexes" indexes_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Ok_batch { @@ -314,7 +314,7 @@ let l2_message_encoding = "transactions" (list Tx_rollup_l2_batch.V1.transaction_encoding)) (req "errors" Error_monad.trace_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Failing_batch {transactions; reasons; aggregated_signature} -> Some (transactions, reasons, aggregated_signature) diff --git a/src/proto_014_PtKathma/lib_tx_rollup/inbox.ml b/src/proto_014_PtKathma/lib_tx_rollup/inbox.ml index 0129b636d665..40bdec5a250a 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/inbox.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/inbox.ml @@ -34,7 +34,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; } type message = { @@ -71,7 +71,7 @@ let l2_context_hash_encoding = (fun (irmin_hash, tree_hash) -> {irmin_hash; tree_hash}) (obj2 (req "irmin_hash" Tx_rollup_l2_context_hash.encoding) - (req "tree_hash" Context_hash.encoding)) + (req "tree_hash" Tezos_crypto.Context_hash.encoding)) let message_encoding = let open Data_encoding in diff --git a/src/proto_014_PtKathma/lib_tx_rollup/inbox.mli b/src/proto_014_PtKathma/lib_tx_rollup/inbox.mli index 58798b6a839f..9b874b09d866 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/inbox.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/inbox.mli @@ -41,7 +41,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; (** The context hash of the commited context, used for checkout *) - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; (** The tree hash is the hash of the underlying tree in the {!Context}, used to produce proofs *) } diff --git a/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.ml b/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.ml index 7aa2a405931a..ea7f01af7821 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.ml @@ -38,7 +38,7 @@ let encoding = (fun (transaction, signatures) -> {transaction; signatures}) @@ obj2 (req "transaction" Tx_rollup_l2_batch.V1.transaction_encoding) - (req "signatures" (list Bls.encoding)) + (req "signatures" (list Tezos_crypto.Bls.encoding)) let batch l = let contents = List.map (fun {transaction; _} -> transaction) l in @@ -52,8 +52,8 @@ let batch l = ok Tx_rollup_l2_batch.(V1 V1.{contents; aggregated_signature}) module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_transaction_hash" @@ -64,7 +64,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 type hash = Hash.t diff --git a/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.mli b/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.mli index ac8ffa3bdfd9..d431b65218d6 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/l2_transaction.mli @@ -34,7 +34,7 @@ type t = { } (** Hash with b58check encoding txL2(54), for hashes of L2 transactions *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for transaction hash *) type hash = Hash.t diff --git a/src/proto_014_PtKathma/lib_tx_rollup/l2block.ml b/src/proto_014_PtKathma/lib_tx_rollup/l2block.ml index f3a7cce3aa7d..aa1f6ff01081 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/l2block.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/l2block.ml @@ -27,8 +27,8 @@ open Protocol open Alpha_context module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_block_hash" @@ -39,7 +39,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 type hash = Hash.t @@ -47,7 +48,7 @@ type level = Tx_rollup_level.t type header = { level : level; - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; predecessor : hash option; context : Tx_rollup_l2_context_hash.t; commitment : Tx_rollup_commitment_hash.t; @@ -63,8 +64,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } type metadata = { @@ -85,7 +86,7 @@ let header_encoding = {level; tezos_block; predecessor; context; commitment}) (obj5 (req "level" Tx_rollup_level.encoding) - (req "tezos_block" Block_hash.encoding) + (req "tezos_block" Tezos_crypto.Block_hash.encoding) (opt "predecessor" Hash.encoding) (req "context" Tx_rollup_l2_context_hash.encoding) (req "commitment" Tx_rollup_commitment_hash.encoding)) @@ -109,8 +110,8 @@ let commitment_included_info_encoding = (fun {block; operation} -> (block, operation)) (fun (block, operation) -> {block; operation}) (obj2 - (req "block" Block_hash.encoding) - (req "operation" Operation_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding)) let metadata_encoding = let open Data_encoding in diff --git a/src/proto_014_PtKathma/lib_tx_rollup/l2block.mli b/src/proto_014_PtKathma/lib_tx_rollup/l2block.mli index f7ee52d66544..a5176b6a5db6 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/l2block.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/l2block.mli @@ -29,7 +29,7 @@ open Alpha_context (** {2 Types for L2 block and header} *) (** Hash with b58check encoding BTx(53), for hashes of L2 block headers *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for block (header) hashes *) type hash = Hash.t @@ -40,7 +40,7 @@ type level = Tx_rollup_level.t (** Type of L2 block headers *) type header = { level : level; (** The level of the L2 block *) - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; (** The Tezos block on which this L2 block in anchored, i.e. the Tezos block in which the inbox was sent *) predecessor : hash option; (** The hash predecessor L2 block *) @@ -63,8 +63,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } (** Metadata for the block *) diff --git a/src/proto_014_PtKathma/lib_tx_rollup/node_config.ml b/src/proto_014_PtKathma/lib_tx_rollup/node_config.ml index c8f905f9ad8f..80c54b6d5647 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/node_config.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/node_config.ml @@ -38,7 +38,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; @@ -171,28 +171,28 @@ let signers_encoding = (opt ~description:"The operator of the rollup (public key hash) if any" "operator" - Signature.Public_key_hash.encoding) + Tezos_crypto.Signature.Public_key_hash.encoding) (opt "submit_batch" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for batch submission") (opt "finalize_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for finalization of commitments") (opt "remove_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for removals of commitments") (opt "rejection" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for rejections") (opt "dispatch_withdrawals" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for the dispatch of withdrawals") diff --git a/src/proto_014_PtKathma/lib_tx_rollup/node_config.mli b/src/proto_014_PtKathma/lib_tx_rollup/node_config.mli index ae293e66e136..31a006cc418c 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/node_config.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/node_config.mli @@ -50,7 +50,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; diff --git a/src/proto_014_PtKathma/lib_tx_rollup/state.ml b/src/proto_014_PtKathma/lib_tx_rollup/state.ml index ac7b77ed7384..0b0bbc0e99ab 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/state.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/state.ml @@ -33,7 +33,7 @@ module Tezos_blocks_cache = Ringo_lwt.Functors.Make_opt ((val Ringo.( map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash)) + (Tezos_crypto.Block_hash)) type rollup_info = Stores.rollup_info = { rollup_id : Tx_rollup.t; diff --git a/src/proto_014_PtKathma/lib_tx_rollup/state.mli b/src/proto_014_PtKathma/lib_tx_rollup/state.mli index 05ab7d476769..ab43389c6bfd 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/state.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/state.mli @@ -33,7 +33,7 @@ open Common data. *) module Tezos_blocks_cache : - Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Block_hash.t + Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Tezos_crypto.Block_hash.t (** Information about the rollup that is kept in the state. *) type rollup_info = Stores.rollup_info = { @@ -102,10 +102,12 @@ val get_header : t -> L2block.hash -> L2block.header option Lwt.t there is no inbox for an L1 block, we associate to it the L2 block of its predecessor. So [get_tezos_l2_block_hash state h] returns L2 block hash at which the rollup was when the Tezos node was at block [h]. *) -val get_tezos_l2_block_hash : t -> Block_hash.t -> L2block.hash option Lwt.t +val get_tezos_l2_block_hash : + t -> Tezos_crypto.Block_hash.t -> L2block.hash option Lwt.t (** Same as {!get_tezos_block} but retrieves the associated L2 block at the same time. *) -val get_tezos_l2_block : t -> Block_hash.t -> L2block.t option Lwt.t +val get_tezos_l2_block : + t -> Tezos_crypto.Block_hash.t -> L2block.t option Lwt.t (** Same as {!get_level} but retrieves the associated header at the same time. *) val get_level_l2_block_header : @@ -119,7 +121,9 @@ val get_level_l2_block : t -> L2block.level -> L2block.t option Lwt.t block for the Tezos block, or [None] otherwise. It returns [`Unknown] when the Tezos block has never been processed. *) val tezos_block_already_processed : - t -> Block_hash.t -> [> `Known of L2block.t option | `Unknown] Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + [> `Known of L2block.t option | `Unknown] Lwt.t (** Returns the inclusion info for a commitment. *) val get_included_commitment : @@ -145,7 +149,9 @@ val set_head : t -> L2block.t -> L2block.t reorg tzresult Lwt.t (** Set the Tezos head and returns the reorganization of L1 blocks. *) val set_tezos_head : - t -> Block_hash.t -> Alpha_block_services.block_info reorg tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info reorg tzresult Lwt.t (** Save an L2 block to disk: - Save both the header and the inbox @@ -161,18 +167,18 @@ val save_level : t -> L2block.level -> L2block.hash -> unit Lwt.t predecessor as well. *) val save_tezos_block_info : t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> L2block.hash option -> level:int32 -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> unit Lwt.t (** Register a commitment as included on L1. *) val set_commitment_included : t -> Tx_rollup_commitment_hash.t -> - Block_hash.t -> - Operation_hash.t -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Lwt.t (** Register a commitment as not included on L1. *) @@ -197,7 +203,9 @@ val rollup_operation_index : int (** Fetch a Tezos block from the cache or the node *) val fetch_tezos_block : - t -> Block_hash.t -> Alpha_block_services.block_info tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info tzresult Lwt.t (** Compute the reorganization of L2 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) diff --git a/src/proto_014_PtKathma/lib_tx_rollup/stores.ml b/src/proto_014_PtKathma/lib_tx_rollup/stores.ml index 8b79f9b66190..2a010ab01c51 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/stores.ml +++ b/src/proto_014_PtKathma/lib_tx_rollup/stores.ml @@ -308,7 +308,7 @@ end module L2_block_key = struct include L2block.Hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -358,9 +358,9 @@ module L2_level_key = struct end module Operation_key = struct - include Operation_hash + include Tezos_crypto.Operation_hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -461,7 +461,7 @@ module Tezos_block_info = struct type t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } let t = @@ -471,7 +471,8 @@ module Tezos_block_info = struct (fun (l2_block, level, predecessor) -> {l2_block; level; predecessor}) (fun {l2_block; level; predecessor} -> (l2_block, level, predecessor)) - let encoded_size = L2block.Hash.size + 4 (* level *) + Block_hash.size + let encoded_size = + L2block.Hash.size + 4 (* level *) + Tezos_crypto.Block_hash.size let encode v = let dst = Bytes.create encoded_size in @@ -482,7 +483,9 @@ module Tezos_block_info = struct in let offset = blit ~src:l2_block_bytes ~dst 0 in let offset = bytes_set_int32 ~dst ~src:v.level offset in - let _ = blit ~src:(Block_hash.to_bytes v.predecessor) ~dst offset in + let _ = + blit ~src:(Tezos_crypto.Block_hash.to_bytes v.predecessor) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = @@ -493,13 +496,20 @@ module Tezos_block_info = struct in let level, offset = read_int32 str offset in let predecessor, _ = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in {l2_block; level; predecessor} end module Commitment_info = struct - type t = {block : Block_hash.t; operation : Operation_hash.t} + type t = { + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; + } let t = let open Repr in @@ -508,20 +518,31 @@ module Commitment_info = struct (fun (block, operation) -> {block; operation}) (fun {block; operation} -> (block, operation)) - let encoded_size = Block_hash.size + Operation_hash.size + let encoded_size = + Tezos_crypto.Block_hash.size + Tezos_crypto.Operation_hash.size let encode v = let dst = Bytes.create encoded_size in - let offset = blit ~src:(Block_hash.to_bytes v.block) ~dst 0 in - let _ = blit ~src:(Operation_hash.to_bytes v.operation) ~dst offset in + let offset = blit ~src:(Tezos_crypto.Block_hash.to_bytes v.block) ~dst 0 in + let _ = + blit ~src:(Tezos_crypto.Operation_hash.to_bytes v.operation) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = let block, offset = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in let operation, _ = - read_str str ~offset ~len:Operation_hash.size Operation_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Operation_hash.size + Tezos_crypto.Operation_hash.of_string_exn in {block; operation} end @@ -530,7 +551,7 @@ module Tezos_block_store = struct type value = Tezos_block_info.t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } include @@ -548,8 +569,8 @@ module Level_store = module Commitment_store = struct type value = Commitment_info.t = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } include @@ -713,11 +734,11 @@ module Head_store = Make_singleton (struct end) module Tezos_head_store = Make_singleton (struct - type t = Block_hash.t + type t = Tezos_crypto.Block_hash.t let name = "tezos_head" - let encoding = Block_hash.encoding + let encoding = Tezos_crypto.Block_hash.encoding end) type rollup_info = { diff --git a/src/proto_014_PtKathma/lib_tx_rollup/stores.mli b/src/proto_014_PtKathma/lib_tx_rollup/stores.mli index 287ab3861d7c..cae8329b0109 100644 --- a/src/proto_014_PtKathma/lib_tx_rollup/stores.mli +++ b/src/proto_014_PtKathma/lib_tx_rollup/stores.mli @@ -124,10 +124,13 @@ module Tezos_block_store : sig type value = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } - include INDEXABLE_STORE with type key := Block_hash.t and type value := value + include + INDEXABLE_STORE + with type key := Tezos_crypto.Block_hash.t + and type value := value end (** An index store to map L2 block level to L2 block hashes. It is composed @@ -140,9 +143,9 @@ module Level_store : (** An index store to map commitment hashes to their inclusion information. *) module Commitment_store : sig type value = { - block : Block_hash.t; + block : Tezos_crypto.Block_hash.t; (** Tezos block in which the commitment is included. *) - operation : Operation_hash.t; + operation : Tezos_crypto.Operation_hash.t; (** Operation of the block in which the commitment is included. *) } @@ -158,7 +161,8 @@ end module Head_store : SINGLETON_STORE with type value := L2block.hash (** A store composed of a single file on disk to store the current Tezos head *) -module Tezos_head_store : SINGLETON_STORE with type value := Block_hash.t +module Tezos_head_store : + SINGLETON_STORE with type value := Tezos_crypto.Block_hash.t (** Type for on disk information about a rollup *) type rollup_info = { diff --git a/src/proto_015_PtLimaPt/bin_tx_rollup_client/commands.ml b/src/proto_015_PtLimaPt/bin_tx_rollup_client/commands.ml index 37653e577c1d..ad80ad0d1c83 100644 --- a/src/proto_015_PtLimaPt/bin_tx_rollup_client/commands.ml +++ b/src/proto_015_PtLimaPt/bin_tx_rollup_client/commands.ml @@ -27,7 +27,7 @@ open Tezos_client_base let l1_destination_parameter = Tezos_clic.parameter (fun _ s -> - match Signature.Public_key_hash.of_b58check_opt s with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt s with | Some addr -> return addr | None -> failwith "cannot parse %s to get a valid destination" s) @@ -66,15 +66,15 @@ let alias_or_literal ~from_alias ~from_key = type wallet_entry = { alias : string; - public_key_hash : Bls.Public_key_hash.t; - public_key : Bls.Public_key.t option; + public_key_hash : Tezos_crypto.Bls.Public_key_hash.t; + public_key : Tezos_crypto.Bls.Public_key.t option; secret_key_uri : Client_keys.aggregate_sk_uri option; } let wallet_parameter () = Tezos_clic.parameter (fun cctxt alias -> let open Lwt_result_syntax in - let open Aggregate_signature in + let open Tezos_crypto.Aggregate_signature in let* (Bls12_381 public_key_hash) = Client_keys.Aggregate_alias.Public_key_hash.find cctxt alias in @@ -106,11 +106,14 @@ let bls_pkh_parameter () = in return pkh in - let from_key s = Bls.Public_key_hash.of_b58check s |> Lwt.return in + let from_key s = + Tezos_crypto.Bls.Public_key_hash.of_b58check s |> Lwt.return + in alias_or_literal ~from_alias ~from_key s) let conv_bls_pkh_to_l2_addr pkh = - Bls.Public_key_hash.to_b58check pkh |> Tx_rollup_l2_address.of_b58check_exn + Tezos_crypto.Bls.Public_key_hash.to_b58check pkh + |> Tx_rollup_l2_address.of_b58check_exn let bls_pkh_param ?(name = "public key hash") ?(desc = "bls public key hash to use") = @@ -142,7 +145,8 @@ let bls_sk_uri_param ?(name = "secret key") ?(desc = "Bls secret key to use.") = Tezos_clic.param ~name ~desc (bls_sk_uri_parameter ()) let signature_parameter () = - Tezos_clic.parameter (fun _cctxt s -> Bls.of_b58check s |> Lwt.return) + Tezos_clic.parameter (fun _cctxt s -> + Tezos_crypto.Bls.of_b58check s |> Lwt.return) let signature_arg = Tezos_clic.arg @@ -338,7 +342,7 @@ let craft_withdraw ~counter ~signer ~destination ~ticket_hash ~qty = let aggregate_signature signatures = let open Result_syntax in - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> return res | None -> error_with "aggregate_signature" @@ -365,7 +369,7 @@ let conv_counter = let signer_to_address : Tx_rollup_l2_batch.signer -> Tx_rollup_l2_address.t = function - | Bls_pk pk -> Bls.Public_key.hash pk + | Bls_pk pk -> Tezos_crypto.Bls.Public_key.hash pk | L2_addr addr -> addr let wait_for_synchronized ?(quiet = false) @@ -439,7 +443,7 @@ let signer_parameter = match Tx_rollup_l2_address.of_b58check_opt s with | Some pkh -> return @@ Tx_rollup_l2_batch.L2_addr pkh | None -> ( - match Bls.Public_key.of_b58check_opt s with + match Tezos_crypto.Bls.Public_key.of_b58check_opt s with | Some pk -> return @@ Tx_rollup_l2_batch.Bls_pk pk | None -> failwith "cannot parse %s to get a valid signer" s)) @@ -683,7 +687,7 @@ let prepare_operation_parameters cctxt signer counter = | Some pk -> ok pk | None -> error_with "missing signer public key in the wallet" in - let signer_addr = Bls.Public_key.hash signer_pk in + let signer_addr = Tezos_crypto.Bls.Public_key.hash signer_pk in let* () = wait_for_synchronized cctxt in let* counter = match counter with @@ -820,7 +824,9 @@ let sign_transaction () = in let*? aggregated_signature = aggregate_signature signatures in - let*! () = cctxt#message "@[%a@]" Bls.pp aggregated_signature in + let*! () = + cctxt#message "@[%a@]" Tezos_crypto.Bls.pp aggregated_signature + in return_unit else let*! () = @@ -828,7 +834,7 @@ let sign_transaction () = "@[%a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.pp_print_string ppf ";") - Bls.pp) + Tezos_crypto.Bls.pp) signatures in return_unit) diff --git a/src/proto_015_PtLimaPt/lib_benchmark/dune b/src/proto_015_PtLimaPt/lib_benchmark/dune index 2eac0f3449ae..b92aecded649 100644 --- a/src/proto_015_PtLimaPt/lib_benchmark/dune +++ b/src/proto_015_PtLimaPt/lib_benchmark/dune @@ -30,6 +30,5 @@ -open Tezos_benchmark -open Tezos_benchmark_type_inference_015_PtLimaPt -open Tezos_protocol_015_PtLimaPt - -open Tezos_crypto -open Tezos_015_PtLimaPt_test_helpers) (private_modules kernel rules state_space)) diff --git a/src/proto_015_PtLimaPt/lib_benchmark/execution_context.ml b/src/proto_015_PtLimaPt/lib_benchmark/execution_context.ml index a44d25fc8721..4770923fbc71 100644 --- a/src/proto_015_PtLimaPt/lib_benchmark/execution_context.ml +++ b/src/proto_015_PtLimaPt/lib_benchmark/execution_context.ml @@ -53,7 +53,7 @@ let context_init ~rng_state = context_init_memory ~rng_state let make ~rng_state = context_init_memory ~rng_state >>=? fun context -> let amount = Alpha_context.Tez.one in - let chain_id = Chain_id.zero in + let chain_id = Tezos_crypto.Chain_id.zero in let now = Script_timestamp.of_zint Z.zero in let level = Script_int.zero_n in let open Script_interpreter in @@ -88,6 +88,8 @@ let make ~rng_state = let ctxt = Incremental.alpha_ctxt vs in let ctxt = (* Required for eg Create_contract *) - Protocol.Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Protocol.Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in return (ctxt, step_constants) diff --git a/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers.ml b/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers.ml index 82cca5fff8cf..0d51700eabe1 100644 --- a/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers.ml +++ b/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers.ml @@ -608,7 +608,7 @@ end) let seed = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255) in - let pkh, _pk, _sk = Bls.generate_key ~seed () in + let pkh, _pk, _sk = Tezos_crypto.Bls.generate_key ~seed () in Tx_rollup_l2_address.Indexable.value pkh let chain_id rng_state = diff --git a/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers_base.ml b/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers_base.ml index 586c2176e626..3f8f301fd1ab 100644 --- a/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers_base.ml +++ b/src/proto_015_PtLimaPt/lib_benchmark/michelson_samplers_base.ml @@ -81,25 +81,25 @@ end) : S = struct let i = Random.State.int rng_state 4 in match i with | 0 -> ( - let open Ed25519 in + let open Tezos_crypto.Ed25519 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_ed25519 s) + | Some s -> Tezos_crypto.Signature.of_ed25519 s) | 1 -> ( - let open Secp256k1 in + let open Tezos_crypto.Secp256k1 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_secp256k1 s) + | Some s -> Tezos_crypto.Signature.of_secp256k1 s) | 2 -> ( - let open P256 in + let open Tezos_crypto.P256 in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with | None -> assert false - | Some s -> Signature.of_p256 s) + | Some s -> Tezos_crypto.Signature.of_p256 s) | _ -> ( - let open Signature in + let open Tezos_crypto.Signature in let bytes = Base_samplers.uniform_bytes ~nbytes:size rng_state in match of_bytes_opt bytes with None -> assert false | Some s -> s) diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/dune b/src/proto_015_PtLimaPt/lib_benchmarks_proto/dune index ad2a144280cc..1c95e860d135 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/dune +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/dune @@ -37,7 +37,6 @@ -open Tezos_benchmark_type_inference_015_PtLimaPt -open Tezos_protocol_015_PtLimaPt -open Tezos_protocol_015_PtLimaPt.Protocol - -open Tezos_crypto -open Tezos_micheline -open Tezos_015_PtLimaPt_test_helpers -open Tezos_client_015_PtLimaPt diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml index aca7cd266205..f23c15aa19d3 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/encodings_benchmarks.ml @@ -423,7 +423,7 @@ module Timelock = struct Base_samplers.sample_in_interval ~range:{min = 1; max = 10000} rng_state in let chest, chest_key = - Timelock.chest_sampler ~plaintext_size ~time ~rng_state + Tezos_crypto.Timelock.chest_sampler ~plaintext_size ~time ~rng_state in ((chest, chest_key), plaintext_size) @@ -431,7 +431,9 @@ module Timelock = struct Registration_helpers.register @@ make_encode_variable_size_to_string ~name:"ENCODING_Chest" - ~to_string:(Data_encoding.Binary.to_string_exn Timelock.chest_encoding) + ~to_string: + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), plaintext_size = generator rng_state in (chest, {bytes = plaintext_size})) @@ -442,7 +444,8 @@ module Timelock = struct @@ make_encode_fixed_size_to_string ~name:"ENCODING_Chest_key" ~to_string: - (Data_encoding.Binary.to_string_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_string_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) @@ -452,12 +455,18 @@ module Timelock = struct Registration_helpers.register @@ make_decode_variable_size_from_bytes ~name:"DECODING_Chest" - ~to_bytes:(Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding) - ~from_bytes:(Data_encoding.Binary.of_bytes_exn Timelock.chest_encoding) + ~to_bytes: + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding) + ~from_bytes: + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_encoding) ~generator:(fun rng_state -> let (chest, _), _ = generator rng_state in let b = - Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest in (chest, {bytes = Bytes.length b})) () @@ -467,9 +476,11 @@ module Timelock = struct @@ make_decode_fixed_size_from_bytes ~name:"DECODING_Chest_key" ~to_bytes: - (Data_encoding.Binary.to_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~from_bytes: - (Data_encoding.Binary.of_bytes_exn Timelock.chest_key_encoding) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Timelock.chest_key_encoding) ~generator:(fun rng_state -> let (_, chest_key), _w = generator rng_state in chest_key) diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml index d23e5ac5f1e3..fa296e227b09 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -module Timelock_samplers = Timelock +module Timelock_samplers = Tezos_crypto.Timelock open Protocol (* ------------------------------------------------------------------------- *) @@ -2325,13 +2325,15 @@ module Registration_section = struct ~kinstr:(ILevel (dummy_loc, halt)) () - let check_signature (algo : Signature.algo) ~for_intercept = + let check_signature (algo : Tezos_crypto.Signature.algo) ~for_intercept = let name = match algo with - | Signature.Ed25519 -> Interpreter_workload.N_ICheck_signature_ed25519 - | Signature.Secp256k1 -> + | Tezos_crypto.Signature.Ed25519 -> + Interpreter_workload.N_ICheck_signature_ed25519 + | Tezos_crypto.Signature.Secp256k1 -> Interpreter_workload.N_ICheck_signature_secp256k1 - | Signature.P256 -> Interpreter_workload.N_ICheck_signature_p256 + | Tezos_crypto.Signature.P256 -> + Interpreter_workload.N_ICheck_signature_p256 in benchmark_with_stack_sampler ~intercept:for_intercept @@ -2348,7 +2350,9 @@ module Registration_section = struct if for_intercept then Environment.Bytes.empty else Samplers.Random_value.value Script_typed_ir.bytes_t rng_state in - let signed_message = Signature.sign sk unsigned_message in + let signed_message = + Tezos_crypto.Signature.sign sk unsigned_message + in let signed_message = Script_signature.make signed_message in (pk, (signed_message, (unsigned_message, eos)))) () @@ -2357,11 +2361,11 @@ module Registration_section = struct check_signature algo ~for_intercept:true ; check_signature algo ~for_intercept:false - let () = check_signature Signature.Ed25519 + let () = check_signature Tezos_crypto.Signature.Ed25519 - let () = check_signature Signature.Secp256k1 + let () = check_signature Tezos_crypto.Signature.Secp256k1 - let () = check_signature Signature.P256 + let () = check_signature Tezos_crypto.Signature.P256 let () = simple_benchmark @@ -3070,12 +3074,13 @@ module Registration_section = struct let open Alpha_context in let step_constants = { - source = Contract.Implicit Signature.Public_key_hash.zero; - payer = Signature.Public_key_hash.zero; + source = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero; + payer = Tezos_crypto.Signature.Public_key_hash.zero; self = Contract_hash.zero; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_workload.ml index 93d9fae52dee..01a1a59eea37 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/interpreter_workload.ml @@ -1341,19 +1341,19 @@ let extract_ir_sized_step : | ILevel (_, _), _ -> Instructions.level | ICheck_signature (_, _), (public_key, (_signature, (message, _))) -> ( match public_key with - | Signature.Ed25519 _pk -> - let pk = Size.of_int Ed25519.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Ed25519 _pk -> + let pk = Size.of_int Tezos_crypto.Ed25519.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_ed25519 pk signature message - | Signature.Secp256k1 _pk -> - let pk = Size.of_int Secp256k1.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.Secp256k1 _pk -> + let pk = Size.of_int Tezos_crypto.Secp256k1.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_secp256k1 pk signature message - | Signature.P256 _pk -> - let pk = Size.of_int P256.size in - let signature = Size.of_int Signature.size in + | Tezos_crypto.Signature.P256 _pk -> + let pk = Size.of_int Tezos_crypto.P256.size in + let signature = Size.of_int Tezos_crypto.Signature.size in let message = Size.bytes message in Instructions.check_signature_p256 pk signature message) | IHash_key (_, _), _ -> Instructions.hash_key diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml index d635611cad20..d843da786e4a 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -211,7 +211,9 @@ module Sc_rollup_add_external_messages_benchmark = struct let ctxt = Incremental.alpha_ctxt b in (* Necessary to originate rollups. *) let ctxt = - Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in Alpha_context.Internal_for_tests.to_raw ctxt in diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml index 61b48a3fa4e0..7d35f3d0e19c 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/storage_benchmarks.ml @@ -66,7 +66,7 @@ let default_raw_context () = >>= fun context -> let typecheck ctxt script_repr = return ((script_repr, None), ctxt) in Init_storage.prepare_first_block - Chain_id.zero + Tezos_crypto.Chain_id.zero context ~level:0l ~timestamp:(Time.Protocol.of_seconds 1643125688L) diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml index 817eb2531614..5934b358431a 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/ticket_benchmarks.ml @@ -152,7 +152,7 @@ module Compare_key_contract_benchmark : Benchmark.S = struct let benchmark rng_state _conf () = let bytes = Base_samplers.bytes rng_state ~size:{min = 32; max = 64} in - let branch = Block_hash.hash_bytes [bytes] in + let branch = Tezos_crypto.Block_hash.hash_bytes [bytes] in let op_hash = Operation.hash_raw {shell = {branch}; proto = bytes} in let nonce = Origination_nonce.Internal_for_tests.initial op_hash in let contract = Contract.Internal_for_tests.originated_contract nonce in @@ -254,7 +254,12 @@ let () = Registration_helpers.register (module Has_tickets_type_benchmark) let ticket_sampler rng_state = let seed = Base_samplers.uniform_bytes ~nbytes:32 rng_state in - let pkh, _, _ = Signature.generate_key ~algo:Signature.Ed25519 ~seed () in + let pkh, _, _ = + Tezos_crypto.Signature.generate_key + ~algo:Tezos_crypto.Signature.Ed25519 + ~seed + () + in let ticketer = Alpha_context.Contract.Implicit pkh in Script_typed_ir. {ticketer; contents = Script_int.zero; amount = Ticket_amount.one} diff --git a/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml b/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml index f0aa39325c8a..079352eb2f91 100644 --- a/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml +++ b/src/proto_015_PtLimaPt/lib_benchmarks_proto/tx_rollup_benchmarks.ml @@ -254,7 +254,7 @@ let unique_ticket_id = let gen_l2_account rng_state = let seed = Base_samplers.uniform_bytes ~nbytes:32 rng_state in - Bls.generate_key ~seed () + Tezos_crypto.Bls.generate_key ~seed () let hash_key_exn ctxt ~ticketer ~typ ~contents ~owner = let ticketer = Micheline.root @@ Expr.from_string ticketer in diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_args.ml b/src/proto_015_PtLimaPt/lib_client/client_proto_args.ml index d9392ecc228f..4715eb2330e9 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_args.ml +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_args.ml @@ -551,7 +551,7 @@ let no_confirmation = let signature_parameter = Tezos_clic.parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> return s | None -> failwith "Not given a valid signature") @@ -670,7 +670,7 @@ module Tx_rollup = struct let context_hash_parameter = Tezos_clic.parameter (fun _ s -> - match Context_hash.of_b58check_opt s with + match Tezos_crypto.Context_hash.of_b58check_opt s with | Some hash -> return hash | None -> failwith diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_args.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_args.mli index c0a0f0a488ab..568adb1a3855 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_args.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_args.mli @@ -60,7 +60,8 @@ val entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg val default_entrypoint_arg : (Entrypoint.t option, full) Tezos_clic.arg -val delegate_arg : (Signature.Public_key_hash.t option, full) Tezos_clic.arg +val delegate_arg : + (Tezos_crypto.Signature.Public_key_hash.t option, full) Tezos_clic.arg val max_priority_arg : (int option, full) Tezos_clic.arg @@ -117,7 +118,7 @@ val global_constant_param : ('a, full) Tezos_clic.params -> (string -> 'a, full) Tezos_clic.params -val signature_parameter : (Signature.t, full) Tezos_clic.parameter +val signature_parameter : (Tezos_crypto.Signature.t, full) Tezos_clic.parameter module Daemon : sig val baking_switch : (bool, full) Tezos_clic.arg @@ -182,7 +183,7 @@ module Tx_rollup : sig ?name:string -> usage:string -> ('a, full) Tezos_clic.params -> - (Context_hash.t -> 'a, full) Tezos_clic.params + (Tezos_crypto.Context_hash.t -> 'a, full) Tezos_clic.params val message_result_path_param : ?name:string -> diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_context.ml b/src/proto_015_PtLimaPt/lib_client/client_proto_context.ml index a6abe374a7cd..f1226f563a55 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_context.ml +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_context.ml @@ -314,7 +314,7 @@ let build_update_consensus_key ?fee ?gas_limit ?storage_limit consensus_pk = let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?fee ~manager_sk ~fee_parameter ?consensus_pk src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in let delegate_op = build_delegate_operation ?fee (Some source) in match consensus_pk with | None -> ( @@ -375,7 +375,7 @@ let register_as_delegate cctxt ~chain ~block ?confirmations ?dry_run let update_consensus_key cctxt ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ~consensus_pk ~manager_sk ~fee_parameter src_pk = - let source = Signature.Public_key.hash src_pk in + let source = Tezos_crypto.Signature.Public_key.hash src_pk in let operation = build_update_consensus_key ?fee consensus_pk in let operation = Annotated_manager_operation.Single_manager operation in Injection.inject_manager_operation @@ -614,7 +614,7 @@ let register_global_constant (cctxt : #full) ~chain ~block ?confirmations return (oph, op, result) type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -625,7 +625,7 @@ type activation_key = { let raw_activation_key_encoding = let open Data_encoding in obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "activation_code" Blinded_public_key_hash.activation_code_encoding) (req "mnemonic" (list string)) @@ -655,7 +655,7 @@ let activation_key_encoding = ~title:"Deprecated_activation" Json_only (obj6 - (req "pkh" Ed25519.Public_key_hash.encoding) + (req "pkh" Tezos_crypto.Ed25519.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "secret" @@ -703,12 +703,14 @@ let read_key key = in let sk = Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in return (pkh, pk, sk) let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias @@ -733,7 +735,7 @@ let inject_activate_operation cctxt ~chain ~block ?confirmations ?dry_run alias cctxt#message "Account %s (%a) activated with %s%a." alias - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp pkh Operation_result.tez_sym Tez.pp @@ -748,13 +750,13 @@ let activate_account (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?(encrypted = false) ?force key name = read_key key >>=? fun (pkh, pk, sk) -> fail_unless - (Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) + (Tezos_crypto.Signature.Public_key_hash.equal pkh (Ed25519 key.pkh)) (error_of_fmt "@[Inconsistent activation key:@ Computed pkh: %a@ Embedded pkh: \ %a @]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp key.pkh) >>=? fun () -> Tezos_signer_backends.Unencrypted.make_pk pk >>?= fun pk_uri -> @@ -794,7 +796,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -902,7 +904,7 @@ let get_operation_from_block (cctxt : #full) ~chain predecessors operation_hash | Some (block, i, j) -> cctxt#message "Operation found in block: %a (pass: %d, offset: %d)" - Block_hash.pp + Tezos_crypto.Block_hash.pp block i j diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_context.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_context.mli index a5bfcd3923f8..9e2c022e82de 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_context.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_context.mli @@ -81,8 +81,8 @@ val register_global_constant : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> constant:string -> @@ -131,7 +131,7 @@ val get_frozen_deposits_limit : #Protocol_client_context.rpc_context -> chain:Shell_services.chain -> block:Shell_services.block -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Tez.t option tzresult Lwt.t (** Calls {!Injection.prepare_manager_operation} @@ -171,10 +171,10 @@ val update_consensus_key : ?verbose_signing:bool -> ?simulation:bool -> ?fee:Tez.tez -> - consensus_pk:Signature.public_key -> + consensus_pk:Tezos_crypto.Signature.public_key -> manager_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> - Signature.public_key -> + Tezos_crypto.Signature.public_key -> Kind.update_consensus_key Kind.manager Injection.result tzresult Lwt.t val drain_delegate : @@ -186,9 +186,9 @@ val drain_delegate : ?verbose_signing:bool -> ?simulation:bool -> consensus_sk:Client_keys.sk_uri -> - consensus_pkh:Signature.public_key_hash -> - ?destination:Signature.public_key_hash -> - delegate:Signature.public_key_hash -> + consensus_pkh:Tezos_crypto.Signature.public_key_hash -> + ?destination:Tezos_crypto.Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> unit -> Kind.drain_delegate Injection.result tzresult Lwt.t @@ -234,7 +234,7 @@ val increase_paid_storage : Kind.increase_paid_storage Kind.manager Injection.result tzresult Lwt.t (** Same as {!set_delegate} but the [~source] argument of {!Injection.inject_manager_operation} - is {!Signature.Public_key.hash} [src_pk]. *) + is {!Tezos_crypto.Signature.Public_key.hash} [src_pk]. *) val register_as_delegate : #Protocol_client_context.full -> chain:Shell_services.chain -> @@ -398,7 +398,7 @@ val reveal : Kind.reveal Kind.manager Injection.result tzresult Lwt.t type activation_key = { - pkh : Ed25519.Public_key_hash.t; + pkh : Tezos_crypto.Ed25519.Public_key_hash.t; amount : Tez.t; activation_code : Blinded_public_key_hash.activation_code; mnemonic : string list; @@ -450,7 +450,7 @@ type period_info = { current_period_kind : Voting_period.kind; position : Int32.t; remaining : Int32.t; - current_proposal : Protocol_hash.t option; + current_proposal : Tezos_crypto.Protocol_hash.t option; } type ballots_info = { @@ -503,7 +503,7 @@ val submit_proposals : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals Injection.result_list tzresult Lwt.t (** Calls {!Injection.inject_operation} @@ -518,7 +518,7 @@ val submit_ballot : ?confirmations:int -> src_sk:Client_keys.sk_uri -> public_key_hash -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot Injection.result_list tzresult Lwt.t @@ -528,7 +528,7 @@ val display_receipt_for_operation : #Protocol_client_context.full -> chain:Block_services.chain -> ?predecessors:int -> - Operation_list_hash.elt -> + Tezos_crypto.Operation_list_hash.elt -> unit tzresult Lwt.t (** Calls {!Tezos_protocol_alpha.Protocol.Alpha_services.Cache.cached_contracts} *) @@ -572,12 +572,12 @@ val originate_tx_rollup : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_origination Kind.manager contents * Kind.tx_rollup_origination Kind.manager Apply_results.contents_result) tzresult @@ -596,14 +596,14 @@ val submit_tx_rollup_batch : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> content:string -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_submit_batch Kind.manager contents * Kind.tx_rollup_submit_batch Kind.manager Apply_results.contents_result) tzresult @@ -621,8 +621,8 @@ val submit_tx_rollup_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -631,7 +631,7 @@ val submit_tx_rollup_commitment : predecessor:Tx_rollup_commitment_hash.t option -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_commit Kind.manager contents * Kind.tx_rollup_commit Kind.manager Apply_results.contents_result) tzresult @@ -649,13 +649,13 @@ val submit_tx_rollup_finalize_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_finalize_commitment Kind.manager contents * Kind.tx_rollup_finalize_commitment Kind.manager Apply_results.contents_result) @@ -674,13 +674,13 @@ val submit_tx_rollup_remove_commitment : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_remove_commitment Kind.manager contents * Kind.tx_rollup_remove_commitment Kind.manager Apply_results.contents_result) tzresult @@ -698,8 +698,8 @@ val submit_tx_rollup_rejection : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> @@ -709,12 +709,12 @@ val submit_tx_rollup_rejection : message_path:Tx_rollup_inbox.Merkle.path -> message_result_hash:Tx_rollup_message_result_hash.t -> message_result_path:Tx_rollup_commitment.Merkle.path -> - previous_context_hash:Context_hash.t -> + previous_context_hash:Tezos_crypto.Context_hash.t -> previous_withdraw_list_hash:Tx_rollup_withdraw_list_hash.t -> previous_message_result_path:Tx_rollup_commitment.Merkle.path -> proof:Tx_rollup_l2_proof.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_rejection Kind.manager contents * Kind.tx_rollup_rejection Kind.manager Apply_results.contents_result) tzresult @@ -732,13 +732,13 @@ val submit_tx_rollup_return_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_return_bond Kind.manager contents * Kind.tx_rollup_return_bond Kind.manager Apply_results.contents_result) tzresult @@ -756,18 +756,18 @@ val tx_rollup_dispatch_tickets : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> level:Tx_rollup_level.t -> - context_hash:Context_hash.t -> + context_hash:Tezos_crypto.Context_hash.t -> message_position:int -> message_result_path:Tx_rollup_commitment.Merkle.path -> tickets_info:Tx_rollup_reveal.t list -> tx_rollup:Tx_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.tx_rollup_dispatch_tickets Kind.manager contents * Kind.tx_rollup_dispatch_tickets Kind.manager Apply_results.contents_result) tzresult @@ -785,8 +785,8 @@ val transfer_ticket : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> contents:string -> @@ -796,7 +796,7 @@ val transfer_ticket : destination:Contract.t -> entrypoint:Entrypoint.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.transfer_ticket Kind.manager contents * Kind.transfer_ticket Kind.manager Apply_results.contents_result) tzresult @@ -822,7 +822,7 @@ val sc_rollup_originate : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_originate Kind.manager contents * Kind.sc_rollup_originate Kind.manager Apply_results.contents_result, tztrace ) @@ -848,7 +848,7 @@ val sc_rollup_add_messages : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_add_messages Kind.manager contents * Kind.sc_rollup_add_messages Kind.manager Apply_results.contents_result) tzresult @@ -873,7 +873,7 @@ val sc_rollup_cement : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_cement Kind.manager contents * Kind.sc_rollup_cement Kind.manager Apply_results.contents_result) tzresult @@ -898,7 +898,7 @@ val sc_rollup_publish : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_publish Kind.manager contents * Kind.sc_rollup_publish Kind.manager Apply_results.contents_result) tzresult @@ -924,7 +924,7 @@ val sc_rollup_execute_outbox_message : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - ( Operation_hash.t + ( Tezos_crypto.Operation_hash.t * Kind.sc_rollup_execute_outbox_message Kind.manager contents * Kind.sc_rollup_execute_outbox_message Kind.manager Apply_results.contents_result, @@ -944,13 +944,13 @@ val sc_rollup_recover_bond : ?gas_limit:Gas.Arith.integral -> ?storage_limit:Z.t -> ?counter:Z.t -> - source:Signature.public_key_hash -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.public_key_hash -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> sc_rollup:Sc_rollup.t -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_recover_bond Kind.manager contents * Kind.sc_rollup_recover_bond Kind.manager Apply_results.contents_result) tzresult @@ -976,7 +976,7 @@ val sc_rollup_refute : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_refute Kind.manager contents * Kind.sc_rollup_refute Kind.manager Apply_results.contents_result) tzresult @@ -1002,7 +1002,7 @@ val sc_rollup_timeout : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_timeout Kind.manager contents * Kind.sc_rollup_timeout Kind.manager Apply_results.contents_result) tzresult @@ -1027,7 +1027,7 @@ val sc_rollup_dal_slot_subscribe : src_sk:Client_keys.sk_uri -> fee_parameter:Injection.fee_parameter -> unit -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * Kind.sc_rollup_dal_slot_subscribe Kind.manager contents * Kind.sc_rollup_dal_slot_subscribe Kind.manager Apply_results.contents_result) tzresult diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_fa12.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_fa12.mli index f3cafb56ef64..cbfa0e1be8ac 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_fa12.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_fa12.mli @@ -155,7 +155,7 @@ val run_view_action : ?source:Contract.t -> contract:Contract_hash.t -> action:action -> - ?payer:Signature.public_key_hash -> + ?payer:Tezos_crypto.Signature.public_key_hash -> ?gas:Gas.Arith.integral -> unparsing_mode:Script_ir_unparser.unparsing_mode -> unit -> diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.ml b/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.ml index 45faac04e91d..7a671305c788 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.ml +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.ml @@ -136,8 +136,12 @@ let () = "A signature was given for a multisig contract that matched none of the \ public keys of the contract signers" ~pp:(fun ppf s -> - Format.fprintf ppf "Invalid signature %s." (Signature.to_b58check s)) - Data_encoding.(obj1 (req "invalid_signature" Signature.encoding)) + Format.fprintf + ppf + "Invalid signature %s." + (Tezos_crypto.Signature.to_b58check s)) + Data_encoding.( + obj1 (req "invalid_signature" Tezos_crypto.Signature.encoding)) (function Invalid_signature s -> Some s | _ -> None) (fun s -> Invalid_signature s) ; register_error_kind @@ -581,11 +585,12 @@ let lambda_action_t ~loc = lambda_t ~loc (unit_t ~loc) (operations_t ~loc) (* Conversion functions from common types to Script_expr using the optimized representation *) let mutez ~loc (amount : Tez.t) = int ~loc (Z.of_int64 (Tez.to_mutez amount)) -let optimized_key_hash ~loc (key_hash : Signature.Public_key_hash.t) = +let optimized_key_hash ~loc + (key_hash : Tezos_crypto.Signature.Public_key_hash.t) = bytes ~loc (Data_encoding.Binary.to_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding key_hash) let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) @@ -596,10 +601,12 @@ let optimized_address ~loc ~(address : Contract.t) ~(entrypoint : Entrypoint.t) Data_encoding.(tup2 Contract.encoding Entrypoint.value_encoding) (address, entrypoint)) -let optimized_key ~loc (key : Signature.Public_key.t) = +let optimized_key ~loc (key : Tezos_crypto.Signature.Public_key.t) = bytes ~loc - (Data_encoding.Binary.to_bytes_exn Signature.Public_key.encoding key) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key.encoding + key) (** * Actions *) @@ -704,7 +711,7 @@ let action_of_expr_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -780,7 +787,7 @@ let action_of_expr_not_generic e = @@ Change_delegate (Some (Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding s)) | Tezos_micheline.Micheline.Prim ( _, @@ -807,7 +814,7 @@ let action_of_expr_not_generic e = | Tezos_micheline.Micheline.Bytes (_, s) -> return @@ Data_encoding.Binary.of_bytes_exn - Signature.Public_key.encoding + Tezos_crypto.Signature.Public_key.encoding s | _ -> fail ()) key_bytes @@ -817,7 +824,7 @@ let action_of_expr_not_generic e = let action_of_expr ~generic = if generic then action_of_expr_generic else action_of_expr_not_generic -type key_list = Signature.Public_key.t list +type key_list = Tezos_crypto.Signature.Public_key.t list (* The relevant information that we can get about a multisig smart contract *) type multisig_contract_information = { @@ -844,7 +851,8 @@ let multisig_get_information (cctxt : #Protocol_client_context.full) ~chain List.map_es (function | String (_, key_str) -> - return @@ Signature.Public_key.of_b58check_exn key_str + return + @@ Tezos_crypto.Signature.Public_key.of_b58check_exn key_str | _ -> fail (Contract_has_unexpected_storage contract)) key_nodes >>=? fun keys -> return {counter; threshold; keys} @@ -856,7 +864,7 @@ let multisig_create_storage ~counter ~threshold ~keys () : let open Tezos_micheline.Micheline in List.map_es (fun key -> - let key_str = Signature.Public_key.to_b58check key in + let key_str = Tezos_crypto.Signature.Public_key.to_b58check key in return (String (loc, key_str))) keys >>=? fun l -> @@ -877,7 +885,10 @@ let multisig_create_param ~counter ~generic ~action ~optional_signatures () : match sig_opt with | None -> return @@ none ~loc () | Some signature -> - return @@ some ~loc (String (loc, Signature.to_b58check signature))) + return + @@ some + ~loc + (String (loc, Tezos_crypto.Signature.to_b58check signature))) optional_signatures >>=? fun l -> Lwt.return @@ action_to_expr ~loc ~generic action >>=? fun expr -> @@ -894,7 +905,11 @@ let get_contract_address_maybe_chain_id ~descr ~loc ~chain_id contract = in if descr.requires_chain_id then let chain_id_bytes = - bytes ~loc (Data_encoding.Binary.to_bytes_exn Chain_id.encoding chain_id) + bytes + ~loc + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id) in pair ~loc chain_id_bytes address else address @@ -1042,7 +1057,7 @@ let check_multisig_signatures ~bytes ~threshold ~keys signatures = let opt_sigs_arr = Array.make nkeys None in let matching_key_found = ref false in let check_signature_against_key_number signature i key = - if Signature.check key signature bytes then ( + if Tezos_crypto.Signature.check key signature bytes then ( matching_key_found := true ; opt_sigs_arr.(i) <- Some signature) in @@ -1168,7 +1183,9 @@ let action_of_bytes ~multisig_contract ~stored_counter ~descr ~chain_id bytes = contract_bytes in let cid = - Data_encoding.Binary.of_bytes_exn Chain_id.encoding chain_id_bytes + Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Chain_id.encoding + chain_id_bytes in if counter = stored_counter then if multisig_contract = contract && chain_id = cid then diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.mli index bd2f3d746552..5650cc2355ea 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_multisig.mli @@ -112,7 +112,7 @@ val call_multisig : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> action:multisig_action -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> @@ -139,7 +139,7 @@ val call_multisig_on_bytes : src_sk:Client_keys.sk_uri -> multisig_contract:Contract_hash.t -> bytes:Bytes.t -> - signatures:Signature.t list -> + signatures:Tezos_crypto.Signature.t list -> amount:Tez.t -> ?fee:Tez.t -> ?gas_limit:Gas.Arith.integral -> diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_programs.ml b/src/proto_015_PtLimaPt/lib_client/client_proto_programs.ml index 4412d16c001c..3f944c498f9f 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_programs.ml +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_programs.ml @@ -126,7 +126,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Signature.public_key_hash option; + payer : Tezos_crypto.Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_programs.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_programs.mli index 383d2116b10b..8e5c87d2ef5e 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_programs.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_programs.mli @@ -39,7 +39,7 @@ type simulation_params = { now : Script_timestamp.t option; level : Script_int.n Script_int.num option; source : Contract.t option; - payer : Signature.public_key_hash option; + payer : Tezos_crypto.Signature.public_key_hash option; gas : Gas.Arith.integral option; } diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_utils.ml b/src/proto_015_PtLimaPt/lib_client/client_proto_utils.ml index be6844cc5cf7..5f98e3c92286 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_utils.ml +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_utils.ml @@ -40,7 +40,11 @@ let sign_message (cctxt : #full) ~src_sk ~block ~message = let json, bytes = to_json_and_bytes block message in cctxt#message "signed content: @[%a@]" Data_encoding.Json.pp json >>= fun () -> - Client_keys.sign cctxt ~watermark:Signature.Generic_operation src_sk bytes + Client_keys.sign + cctxt + ~watermark:Tezos_crypto.Signature.Generic_operation + src_sk + bytes let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature = @@ -49,7 +53,7 @@ let check_message (cctxt : #full) ~block ~key_locator ~quiet ~message ~signature else cctxt#message "checked content: @[%a@]" Data_encoding.Json.pp json) >>= fun () -> Client_keys.check - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation key_locator signature bytes diff --git a/src/proto_015_PtLimaPt/lib_client/client_proto_utils.mli b/src/proto_015_PtLimaPt/lib_client/client_proto_utils.mli index c535e4b24ecb..e222f1745aff 100644 --- a/src/proto_015_PtLimaPt/lib_client/client_proto_utils.mli +++ b/src/proto_015_PtLimaPt/lib_client/client_proto_utils.mli @@ -26,15 +26,15 @@ val sign_message : #Protocol_client_context.full -> src_sk:Client_keys.sk_uri -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> message:string -> - Signature.t tzresult Lwt.t + Tezos_crypto.Signature.t tzresult Lwt.t val check_message : #Protocol_client_context.full -> - block:Block_hash.t -> + block:Tezos_crypto.Block_hash.t -> key_locator:Client_keys.pk_uri -> quiet:bool -> message:string -> - signature:Signature.t -> + signature:Tezos_crypto.Signature.t -> bool tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_client/injection.ml b/src/proto_015_PtLimaPt/lib_client/injection.ml index bec0a6116392..6189bf830f4c 100644 --- a/src/proto_015_PtLimaPt/lib_client/injection.ml +++ b/src/proto_015_PtLimaPt/lib_client/injection.ml @@ -57,12 +57,15 @@ let get_branch (rpc_config : #Protocol_client_context.full) ~chain return (chain_id, hash) type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result let get_manager_operation_gas_and_fee (contents : packed_contents_list) = let l = Operation.to_list contents in @@ -176,18 +179,23 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_cut ppf () in let hash_pp l = - fprintf ppf "%s" (Base58.raw_encode Blake2B.(hash_bytes l |> to_string)) + fprintf + ppf + "%s" + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes l |> to_string)) in item (fun ppf () -> pp_print_text ppf "Branch: " ; - Block_hash.pp ppf branch) ; + Tezos_crypto.Block_hash.pp ppf branch) ; item (fun ppf () -> fprintf ppf "Watermark: `%a` (0x%s)" - Signature.pp_watermark + Tezos_crypto.Signature.pp_watermark watermark - (Hex.of_bytes (Signature.bytes_of_watermark watermark) |> Hex.show)) ; + (Hex.of_bytes (Tezos_crypto.Signature.bytes_of_watermark watermark) + |> Hex.show)) ; item (fun ppf () -> pp_print_text ppf "Operation bytes: " ; TzString.fold_left (* We split the bytes into lines for display: *) @@ -210,7 +218,7 @@ let print_for_verbose_signing ppf ~watermark ~bytes ~branch ~contents = pp_print_text ppf "Blake 2B Hash (ledger-style, with operation watermark): " ; - hash_pp [Signature.bytes_of_watermark watermark; bytes]) ; + hash_pp [Tezos_crypto.Signature.bytes_of_watermark watermark; bytes]) ; let json = Data_encoding.Json.construct Operation.unsigned_encoding @@ -236,7 +244,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block let watermark = match contents with (* TODO-TB sign endorsement? *) - | _ -> Signature.Generic_operation + | _ -> Tezos_crypto.Signature.Generic_operation in (if verbose_signing then cctxt#message @@ -251,7 +259,7 @@ let preapply (type t) (cctxt : #Protocol_client_context.full) ~chain ~block {shell = {branch}; protocol_data = {contents; signature}} in let oph = Operation.hash op in - let size = Bytes.length bytes + Signature.size in + let size = Bytes.length bytes + Tezos_crypto.Signature.size in (match fee_parameter with | Some fee_parameter -> check_fees cctxt fee_parameter contents size | None -> Lwt.return_unit) @@ -786,7 +794,7 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) + Data_encoding.Binary.length Operation.contents_encoding (Contents op) - + Signature.size + + Tezos_crypto.Signature.size else Data_encoding.Binary.length Operation.contents_encoding @@ -1049,12 +1057,12 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations Data_encoding.Binary.to_bytes_exn Operation.encoding (Operation.pack op) in if dry_run || simulation then - let oph = Operation_hash.hash_bytes [bytes] in + let oph = Tezos_crypto.Operation_hash.hash_bytes [bytes] in cctxt#message "@[Operation: 0x%a@,Operation hash is '%a'@]" Hex.pp (Hex.of_bytes bytes) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph >>= fun () -> cctxt#message @@ -1065,7 +1073,8 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations else Shell_services.Injection.operation cctxt ~chain bytes >>=? fun oph -> cctxt#message "Operation successfully injected in the node." >>= fun () -> - cctxt#message "Operation hash is '%a'" Operation_hash.pp oph >>= fun () -> + cctxt#message "Operation hash is '%a'" Tezos_crypto.Operation_hash.pp oph + >>= fun () -> (* Adjust user-provided confirmations with respect to Alpha protocol finality properties *) tenderbake_adjust_confirmations cctxt confirmations >>= fun confirmations -> (match confirmations with @@ -1077,10 +1086,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer to make sure that it has been \ included.@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch >>= fun () -> return result | Some confirmations -> ( @@ -1141,10 +1150,10 @@ let inject_operation_internal (type kind) cctxt ~chain ~block ?confirmations --branch %a@,\ and/or an external block explorer.@]" number - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph tenderbake_finality_confirmations - Block_hash.pp + Tezos_crypto.Block_hash.pp op.shell.branch) >>= fun () -> return (oph, op, result.contents) @@ -1207,10 +1216,10 @@ let pending_applied_operations_of_source (cctxt : #full) chain src : (fun acc (_oph, {protocol_data = Operation_data {contents; _}; _}) -> match contents with | Single (Manager_operation {source; _} as _op) - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | Cons (Manager_operation {source; _}, _rest) as _op - when Signature.Public_key_hash.equal source src -> + when Tezos_crypto.Signature.Public_key_hash.equal source src -> Contents_list contents :: acc | _ -> acc) [] @@ -1333,14 +1342,14 @@ let replace_operation (type kind) (cctxt : #full) chain source cctxt#error "Cannot replace! No applied manager operation found for %a in \ mempool@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source >>= fun () -> exit 1 | _ :: _ :: _ as l -> cctxt#error "More than one applied manager operation found for %a in mempool. \ Found %d operations. Are you sure the node is in precheck mode?@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source (List.length l) >>= fun () -> exit 1 @@ -1365,7 +1374,7 @@ let inject_manager_operation cctxt ~chain ~block ?successor_level ?branch ~src_sk ~fee ~gas_limit ~storage_limit ?counter ?(replace_by_fees = false) ~fee_parameter (type kind) (operations : kind Annotated_manager_operation.annotated_list) : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * kind Kind.manager contents_list * kind Kind.manager contents_result_list) diff --git a/src/proto_015_PtLimaPt/lib_client/injection.mli b/src/proto_015_PtLimaPt/lib_client/injection.mli index 6275db8033e1..e510735766bb 100644 --- a/src/proto_015_PtLimaPt/lib_client/injection.mli +++ b/src/proto_015_PtLimaPt/lib_client/injection.mli @@ -28,7 +28,7 @@ open Alpha_context open Apply_results type 'kind preapply_result = - Operation_hash.t * 'kind operation * 'kind operation_metadata + Tezos_crypto.Operation_hash.t * 'kind operation * 'kind operation_metadata type fee_parameter = { minimal_fees : Tez.t; @@ -63,7 +63,9 @@ val simulate : 'kind preapply_result tzresult Lwt.t type 'kind result_list = - Operation_hash.t * 'kind contents_list * 'kind contents_result_list + Tezos_crypto.Operation_hash.t + * 'kind contents_list + * 'kind contents_result_list (** /!\ [inject_operation] does not perform automatic patching of gas, storage and fees; use [inject_manager_operation] to inject @@ -83,7 +85,8 @@ val inject_operation : 'kind contents_list -> 'kind result_list tzresult Lwt.t -type 'kind result = Operation_hash.t * 'kind contents * 'kind contents_result +type 'kind result = + Tezos_crypto.Operation_hash.t * 'kind contents * 'kind contents_result val prepare_manager_operation : fee:Tez.t Limit.t -> @@ -103,8 +106,8 @@ val inject_manager_operation : ?verbose_signing:bool -> ?simulation:bool -> ?force:bool -> - source:Signature.Public_key_hash.t -> - src_pk:Signature.public_key -> + source:Tezos_crypto.Signature.Public_key_hash.t -> + src_pk:Tezos_crypto.Signature.public_key -> src_sk:Client_keys.sk_uri -> fee:Tez.t Limit.t -> gas_limit:Gas.Arith.integral Limit.t -> @@ -113,7 +116,7 @@ val inject_manager_operation : ?replace_by_fees:bool -> fee_parameter:fee_parameter -> 'kind Annotated_manager_operation.annotated_list -> - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * 'kind Kind.manager contents_list * 'kind Kind.manager contents_result_list) diff --git a/src/proto_015_PtLimaPt/lib_client/managed_contract.ml b/src/proto_015_PtLimaPt/lib_client/managed_contract.ml index 5d406c127648..3edbaae33415 100644 --- a/src/proto_015_PtLimaPt/lib_client/managed_contract.ml +++ b/src/proto_015_PtLimaPt/lib_client/managed_contract.ml @@ -51,7 +51,7 @@ let get_contract_manager (cctxt : #full) contract = | Prim (_, D_Pair, Bytes (_, bytes) :: _, _) | Bytes (_, bytes) -> ( match Data_encoding.Binary.of_bytes_opt - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding bytes with | Some k -> return k @@ -62,7 +62,7 @@ let get_contract_manager (cctxt : #full) contract = Transfer from scripted contract are currently only supported for \ \"manager\" contract.") | Prim (_, D_Pair, String (_, value) :: _, _) | String (_, value) -> ( - match Signature.Public_key_hash.of_b58check_opt value with + match Tezos_crypto.Signature.Public_key_hash.of_b58check_opt value with | Some k -> return k | None -> cctxt#error @@ -89,7 +89,9 @@ let parse code = let build_lambda_for_set_delegate ~delegate = match delegate with | Some delegate -> - let (`Hex delegate) = Signature.Public_key_hash.to_hex delegate in + let (`Hex delegate) = + Tezos_crypto.Signature.Public_key_hash.to_hex delegate + in Format.asprintf "{ DROP ; NIL operation ; PUSH key_hash 0x%s ; SOME ; SET_DELEGATE ; \ CONS }" @@ -104,7 +106,7 @@ let entrypoint_remove_delegate = Entrypoint.remove_delegate let build_delegate_operation (cctxt : #full) ~chain ~block ?fee contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = let entrypoint = entrypoint_do in (Michelson_v1_entrypoints.contract_entrypoint_type cctxt @@ -139,7 +141,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee match delegate with | Some delegate -> let (`Hex delegate) = - Signature.Public_key_hash.to_hex delegate + Tezos_crypto.Signature.Public_key_hash.to_hex delegate in "0x" ^ delegate | None -> "Unit" @@ -160,7 +162,7 @@ let build_delegate_operation (cctxt : #full) ~chain ~block ?fee let set_delegate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?branch ~fee_parameter ?fee ~source ~src_pk ~src_sk contract (* the KT1 to delegate *) - (delegate : Signature.public_key_hash option) = + (delegate : Tezos_crypto.Signature.public_key_hash option) = build_delegate_operation cctxt ~chain ~block ?fee contract delegate >>=? fun operation -> let operation = Annotated_manager_operation.Single_manager operation in @@ -190,7 +192,9 @@ let t_unit = Micheline.strip_locations (Prim (0, Michelson_v1_primitives.T_unit, [], [])) let build_lambda_for_transfer_to_implicit ~destination ~amount = - let (`Hex destination) = Signature.Public_key_hash.to_hex destination in + let (`Hex destination) = + Tezos_crypto.Signature.Public_key_hash.to_hex destination + in Format.asprintf "{ DROP ; NIL operation ;PUSH key_hash 0x%s; IMPLICIT_ACCOUNT;PUSH mutez \ %Ld ;UNIT;TRANSFER_TOKENS ; CONS }" diff --git a/src/proto_015_PtLimaPt/lib_client/mockup.ml b/src/proto_015_PtLimaPt/lib_client/mockup.ml index 62ed51f59076..ad1b10ea3158 100644 --- a/src/proto_015_PtLimaPt/lib_client/mockup.ml +++ b/src/proto_015_PtLimaPt/lib_client/mockup.ml @@ -35,7 +35,7 @@ module Protocol_constants_overrides = struct (** Equivalent of [Constants.parametric] with additionally [chain_id] and [timestamp]. *) type t = { parametric : Constants.Parametric.t; - chain_id : Chain_id.t option; + chain_id : Tezos_crypto.Chain_id.t option; timestamp : Time.Protocol.t option; } @@ -49,7 +49,7 @@ module Protocol_constants_overrides = struct (merge_objs Constants.Parametric.encoding (obj2 - (opt "chain_id" Chain_id.encoding) + (opt "chain_id" Tezos_crypto.Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding))) let default_value (cctxt : Tezos_client_base.Client_context.full) : @@ -99,7 +99,7 @@ module Parsed_account = struct let to_bootstrap_account repr = Tezos_client_base.Client_keys.neuterize repr.sk_uri >>=? fun pk_uri -> Tezos_client_base.Client_keys.public_key pk_uri >>=? fun public_key -> - let public_key_hash = Signature.Public_key.hash public_key in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in return Parameters. { @@ -165,11 +165,11 @@ module Bootstrap_account = struct (fun (public_key_hash, public_key, amount, delegate_to, consensus_key) -> {public_key_hash; public_key; amount; delegate_to; consensus_key}) (obj5 - (req "public_key_hash" Signature.Public_key_hash.encoding) - (opt "public_key" Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "public_key" Tezos_crypto.Signature.Public_key.encoding) (req "amount" Tez.encoding) - (opt "delegate_to" Signature.Public_key_hash.encoding) - (opt "consensus_key" Signature.Public_key.encoding)) + (opt "delegate_to" Tezos_crypto.Signature.Public_key_hash.encoding) + (opt "consensus_key" Tezos_crypto.Signature.Public_key.encoding)) end module Bootstrap_contract = struct @@ -180,7 +180,7 @@ module Bootstrap_contract = struct (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 - (opt "delegate" Signature.Public_key_hash.encoding) + (opt "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "amount" Tez.encoding) (req "script" Script.encoding)) end @@ -239,7 +239,7 @@ let lib_parameters_json_encoding = (* Blocks *) type block = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Environment.Context.t; @@ -259,14 +259,14 @@ module Forge = struct operations_hash; proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } end (* ------------------------------------------------------------------------- *) (* RPC context *) let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" let endorsement_branch_data_encoding = @@ -275,7 +275,7 @@ let endorsement_branch_data_encoding = (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (fun (block_hash, block_payload_hash) -> (block_hash, block_payload_hash)) (obj2 - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "block_payload_hash" Protocol.Block_payload_hash.encoding)) let initial_context chain_id (header : Block_header.shell_header) @@ -451,7 +451,7 @@ let mem_init : ~predecessor:hash ~timestamp ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in (match bootstrap_accounts_json with | None -> return None @@ -495,10 +495,13 @@ let mem_init : let protocol_data = let payload_hash = Protocol.Block_payload_hash.hash_bytes - [Block_hash.to_bytes hash; Operation_list_hash.(to_bytes @@ compute [])] + [ + Tezos_crypto.Block_hash.to_bytes hash; + Tezos_crypto.Operation_list_hash.(to_bytes @@ compute []); + ] in let open Protocol.Alpha_context.Block_header in - let _, _, sk = Signature.generate_key () in + let _, _, sk = Tezos_crypto.Signature.generate_key () in let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in @@ -518,7 +521,7 @@ let mem_init : (shell_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Protocol.Alpha_context.Block_header.( to_watermark (Block_header chain_id)) diff --git a/src/proto_015_PtLimaPt/lib_client/operation_result.ml b/src/proto_015_PtLimaPt/lib_client/operation_result.ml index 529d0ed8306f..6941577071d5 100644 --- a/src/proto_015_PtLimaPt/lib_client/operation_result.ml +++ b/src/proto_015_PtLimaPt/lib_client/operation_result.ml @@ -96,13 +96,13 @@ let pp_internal_operation ppf (Internal_operation {operation; source; _}) = Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Event {ty; tag; payload} -> Format.fprintf ppf @@ -169,7 +169,7 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "@,Delegate: %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate) | Reveal key -> Format.fprintf @@ -177,13 +177,13 @@ let pp_manager_operation_content (type kind) source ppf "Revelation of manager public key:@,Contract: %a@,Key: %a" Contract.pp source - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp key | Delegation delegate_opt -> ( Format.fprintf ppf "Delegation:@,Contract: %a@,To: " Contract.pp source ; match delegate_opt with | None -> Format.pp_print_string ppf "nobody" - | Some delegate -> Signature.Public_key_hash.pp ppf delegate) + | Some delegate -> Tezos_crypto.Signature.Public_key_hash.pp ppf delegate) | Register_global_constant {value} -> Format.fprintf ppf @@ -213,8 +213,8 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "Update_consensus_key:@,Public key hash: %a" - Signature.Public_key_hash.pp - (Signature.Public_key.hash pk) + Tezos_crypto.Signature.Public_key_hash.pp + (Tezos_crypto.Signature.Public_key.hash pk) | Tx_rollup_origination -> Format.fprintf ppf @@ -326,8 +326,8 @@ let pp_manager_operation_content (type kind) source ppf R.name pp_micheline_from_lazy_expr parameters_ty - Blake2B.pp - (Blake2B.hash_string [boot_sector]) + Tezos_crypto.Blake2B.pp + (Tezos_crypto.Blake2B.hash_string [boot_sector]) | Sc_rollup_add_messages {rollup; messages = _} -> Format.fprintf ppf @@ -429,9 +429,12 @@ let pp_balance_updates ppf balance_updates = (tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU). Instead of printing this key hash, we want to make the result more informative. *) let pp_baker ppf baker = - if Signature.Public_key_hash.equal baker Signature.Public_key_hash.zero then - Format.fprintf ppf "the baker who will include this operation" - else Signature.Public_key_hash.pp ppf baker + if + Tezos_crypto.Signature.Public_key_hash.equal + baker + Tezos_crypto.Signature.Public_key_hash.zero + then Format.fprintf ppf "the baker who will include this operation" + else Tezos_crypto.Signature.Public_key_hash.pp ppf baker in let balance_updates = List.map @@ -997,7 +1000,11 @@ let pp_manager_operation_result ppf Manager_operation_result {balance_updates; operation_result; internal_operation_results} ) = Format.fprintf ppf "@[Manager signed operations:" ; - Format.fprintf ppf "@,From: %a" Signature.Public_key_hash.pp source ; + Format.fprintf + ppf + "@,From: %a" + Tezos_crypto.Signature.Public_key_hash.pp + source ; Format.fprintf ppf "@,Fee to the baker: %s%a" tez_sym Tez.pp fee ; Format.fprintf ppf "@,Expected counter: %a" Z.pp_print counter ; Format.fprintf ppf "@,Gas limit: %a" Gas.Arith.pp_integral gas_limit ; @@ -1048,9 +1055,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh1) - Block_hash.pp + Tezos_crypto.Block_hash.pp (Block_header.hash bh2) pp_balance_updates bus @@ -1092,7 +1099,7 @@ let pp_contents_and_result : Format.fprintf ppf "@[Slot availability:@,Delegate: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate | ( Double_endorsement_evidence {op1; op2}, Double_endorsement_evidence_result bus ) -> @@ -1103,9 +1110,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1118,9 +1125,9 @@ let pp_contents_and_result : Exhibit B: %a@,\ Balance updates:@,\ \ %a@]" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op1) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash op2) pp_balance_updates bus @@ -1131,7 +1138,7 @@ let pp_contents_and_result : Account: %a@,\ Balance updates:@,\ \ %a@]" - Ed25519.Public_key_hash.pp + Tezos_crypto.Ed25519.Public_key_hash.pp id pp_balance_updates bus @@ -1139,19 +1146,19 @@ let pp_contents_and_result : Format.fprintf ppf "@[Proposals:@,From: %a@,Period: %ld@,Protocols:@, @[%a@]@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - (Format.pp_print_list Protocol_hash.pp) + (Format.pp_print_list Tezos_crypto.Protocol_hash.pp) proposals | Ballot {source; period; proposal; ballot}, Ballot_result -> Format.fprintf ppf "@[Ballot:@,From: %a@,Period: %ld@,Protocol: %a@,Vote: %a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source period - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proposal Data_encoding.Json.pp (Data_encoding.Json.construct Vote.ballot_encoding ballot) @@ -1164,11 +1171,11 @@ let pp_contents_and_result : Consensus key hash: %a@,\ Delegate: %a@,\ Destination: %a%s%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp consensus_key - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp destination (if allocated_destination_contract then " (allocated)" else "") pp_balance_updates diff --git a/src/proto_015_PtLimaPt/lib_client/proxy.ml b/src/proto_015_PtLimaPt/lib_client/proxy.ml index d1ee80868ae5..7fc6fc607b08 100644 --- a/src/proto_015_PtLimaPt/lib_client/proxy.ml +++ b/src/proto_015_PtLimaPt/lib_client/proxy.ml @@ -95,7 +95,7 @@ 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) : + (hash : Tezos_crypto.Context_hash.t) : Tezos_protocol_environment.Context.t tzresult Lwt.t = let open Lwt_result_syntax in let*! () = diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_context_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_context_commands.ml index 240cf525ea5d..043591e74abd 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_context_commands.ml @@ -81,7 +81,7 @@ let report_michelson_errors ?(no_print_source = false) ~msg let block_hash_param = Tezos_clic.parameter (fun _ s -> - try Lwt_result_syntax.return (Block_hash.of_b58check_exn s) + try Lwt_result_syntax.return (Tezos_crypto.Block_hash.of_b58check_exn s) with _ -> failwith "Parameter '%s' is an invalid block hash" s) let group = @@ -529,7 +529,7 @@ let commands_ro () = ~name:"operation" ~desc:"Operation to be looked up" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ stop) @@ -573,7 +573,10 @@ let commands_ro () = also on the last block of the exploration and promotion periods when the proposal is not approved *) | Some proposal -> - cctxt#message "Current proposal: %a" Protocol_hash.pp proposal + cctxt#message + "Current proposal: %a" + Tezos_crypto.Protocol_hash.pp + proposal in match info.current_period_kind with | Proposal -> @@ -592,13 +595,16 @@ let commands_ro () = fprintf ppf "* %a %a %s (%sknown by the node)@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p Tez.pp (Tez.of_mutez_exn w) Operation_result.tez_sym (if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem + ~equal:Tezos_crypto.Protocol_hash.equal + p + known_protos then "" else "not ")) ranks ; @@ -1044,7 +1050,7 @@ let commands_rw () = (Some delegate) in let*! (_ : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * _ contents * _ Apply_results.contents_result) option) = @@ -1339,7 +1345,7 @@ let commands_rw () = contents in let*! (_ : - (Operation_hash.t + (Tezos_crypto.Operation_hash.t * packed_operation * _ contents_list * _ Apply_results.contents_result_list) @@ -1804,7 +1810,7 @@ let commands_rw () = ~name:"operation" ~desc:"Operation to be included" (parameter (fun _ x -> - match Operation_hash.of_b58check_opt x with + match Tezos_crypto.Operation_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid operation hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ prefixes ["to"; "be"; "included"] @@ -1813,7 +1819,7 @@ let commands_rw () = operation_hash (ctxt : Protocol_client_context.full) -> let open Lwt_result_syntax in - let* (_ : Block_hash.t * int * int) = + let* (_ : Tezos_crypto.Block_hash.t * int * int) = Client_confirmations.wait_for_operation_inclusion ctxt ~chain:ctxt#chain @@ -1844,7 +1850,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to be submitted" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> Error_monad.failwith "Invalid proposal hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)))) @@ -1908,7 +1914,9 @@ let commands_rw () = (List.length proposals) Constants.max_proposals_per_delegate ; (match - Base.List.find_all_dups ~compare:Protocol_hash.compare proposals + Base.List.find_all_dups + ~compare:Tezos_crypto.Protocol_hash.compare + proposals with | [] -> () | dups -> @@ -1920,22 +1928,25 @@ let commands_rw () = Format.( pp_print_list ~pp_sep:(fun ppf () -> pp_print_string ppf ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) dups) ; List.iter - (fun (p : Protocol_hash.t) -> + (fun (p : Tezos_crypto.Protocol_hash.t) -> if - List.mem ~equal:Protocol_hash.equal p known_protos + List.mem ~equal:Tezos_crypto.Protocol_hash.equal p known_protos || Environment.Protocol_hash.Map.mem p known_proposals then () else - error "Protocol %a is not a known proposal." Protocol_hash.pp p) + error + "Protocol %a is not a known proposal." + Tezos_crypto.Protocol_hash.pp + p) proposals ; if not has_voting_power then error "Public-key-hash `%a` from account `%s` does not appear to have \ voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name ; if !errors <> [] then @@ -2019,7 +2030,7 @@ let commands_rw () = ~name:"proposal" ~desc:"the protocol hash proposal to vote for" (parameter (fun _ x -> - match Protocol_hash.of_b58check_opt x with + match Tezos_crypto.Protocol_hash.of_b58check_opt x with | None -> failwith "Invalid proposal hash: '%s'" x | Some hash -> Lwt_result_syntax.return hash)) @@ param @@ -2059,12 +2070,13 @@ let commands_rw () = let* () = match (info.current_period_kind, current_proposal) with | (Exploration | Promotion), Some current_proposal -> - if Protocol_hash.equal proposal current_proposal then return_unit + if Tezos_crypto.Protocol_hash.equal proposal current_proposal then + return_unit else let*! () = (if force then cctxt#warning else cctxt#error) "Unexpected proposal, expected: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp current_proposal in return_unit @@ -2096,7 +2108,7 @@ let commands_rw () = (if force then cctxt#warning else cctxt#error) "Public-key-hash `%a` from account `%s` does not appear to have \ voting rights." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src_pkh src_name in diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_fa12_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_fa12_commands.ml index ac592f0ac2a5..bac3b401d30d 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_fa12_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_fa12_commands.ml @@ -109,7 +109,8 @@ let view_options = payer_arg (unparsing_mode_arg ~default:"Readable") -let dummy_callback = Contract.Implicit Signature.Public_key_hash.zero +let dummy_callback = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero let get_contract_caller_keys cctxt (caller : Contract.t) = let open Lwt_result_syntax in diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_multisig_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_multisig_commands.ml index ddac6345d160..50f395d6eb77 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_multisig_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_multisig_commands.ml @@ -113,7 +113,8 @@ let prepare_command_display prepared_command bytes_only = Format.fprintf ppf "Blake 2B Hash: '%s'" - (Base58.raw_encode Blake2B.(hash_bytes [x] |> to_string))) + (Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [x] |> to_string))) prepared_command.Client_proto_multisig.bytes (fun ppf z -> Format.fprintf @@ -127,7 +128,7 @@ let prepare_command_display prepared_command bytes_only = "@[<2>Public keys of the signers:@ %a@]" (Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ ") - Signature.Public_key.pp)) + Tezos_crypto.Signature.Public_key.pp)) prepared_command.Client_proto_multisig.keys let get_parameter_type (cctxt : #Protocol_client_context.full) @@ -335,7 +336,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -369,7 +370,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -401,7 +402,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -426,7 +427,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group @@ -466,7 +467,7 @@ let commands_rw () : #Protocol_client_context.full Tezos_clic.command list = () in let* signature = Client_keys.sign cctxt sk prepared_command.bytes in - Format.printf "%a@." Signature.pp signature ; + Format.printf "%a@." Tezos_crypto.Signature.pp signature ; return_unit); command ~group diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_programs_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_programs_commands.ml index 301fb07c2f2a..df0b2eec95f3 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_programs_commands.ml @@ -136,7 +136,7 @@ let commands () = in let signature_parameter = parameter (fun _cctxt s -> - match Signature.of_b58check_opt s with + match Tezos_crypto.Signature.of_b58check_opt s with | Some s -> Lwt_result_syntax.return s | None -> failwith "Not given a valid signature") in @@ -483,8 +483,8 @@ let commands () = Hex.pp (Hex.of_bytes (Script_expr_hash.to_bytes hash)) ); ( "Ledger Blake2b hash", - Base58.raw_encode Blake2B.(hash_bytes [bytes] |> to_string) - ); + Tezos_crypto.Base58.raw_encode + Tezos_crypto.Blake2B.(hash_bytes [bytes] |> to_string) ); ( "Raw Sha256 hash", asprintf "0x%a" @@ -735,7 +735,9 @@ let commands () = (fun () bytes sk cctxt -> let open Lwt_result_syntax in let* signature = Client_keys.sign cctxt sk bytes in - let*! () = cctxt#message "Signature: %a" Signature.pp signature in + let*! () = + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + in return_unit); command ~group diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_stresstest_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_stresstest_commands.ml index b2c39c01dbcd..7b0c266d3ce3 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_stresstest_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_stresstest_commands.ml @@ -64,14 +64,14 @@ type origin = Explicit | Wallet_pkh | Wallet_alias of string type source = { pkh : public_key_hash; pk : public_key; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; } type source_with_uri = { pkh : public_key_hash; pk : public_key; pk_uri : Client_keys.pk_uri; - sk : Signature.secret_key; + sk : Tezos_crypto.Signature.secret_key; sk_uri : Client_keys.sk_uri; } @@ -85,7 +85,7 @@ type source_origin = {source : source; origin : origin} (** Destination of a call: either an implicit contract or an originated one with all the necessary data (entrypoint and the argument). *) type destination = - | Implicit of Signature.Public_key_hash.t + | Implicit of Tezos_crypto.Signature.Public_key_hash.t | Originated of Smart_contracts.invocation_parameters type transfer = { @@ -100,17 +100,18 @@ type transfer = { type state = { rng_state : Random.State.t; - current_head_on_start : Block_hash.t; + current_head_on_start : Tezos_crypto.Block_hash.t; mutable pool : source_origin list; mutable pool_size : int; mutable shuffled_pool : source list; - mutable revealed : Signature.Public_key_hash.Set.t; - mutable last_block : Block_hash.t; + mutable revealed : Tezos_crypto.Signature.Public_key_hash.Set.t; + mutable last_block : Tezos_crypto.Block_hash.t; mutable last_level : int; - mutable target_block : Block_hash.t; + mutable target_block : Tezos_crypto.Block_hash.t; (** The block on top of which we are injecting transactions (HEAD~2). *) new_block_condition : unit Lwt_condition.t; - injected_operations : Operation_hash.t list Block_hash.Table.t; + injected_operations : + Tezos_crypto.Operation_hash.t list Tezos_crypto.Block_hash.Table.t; } (** Cost estimations for every kind of transaction used in the stress test. @@ -161,9 +162,9 @@ let input_source_encoding = ~title:"explicit" (Tag 0) (obj3 - (req "pkh" Signature.Public_key_hash.encoding) - (req "pk" Signature.Public_key.encoding) - (req "sk" Signature.Secret_key.encoding)) + (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding) + (req "pk" Tezos_crypto.Signature.Public_key.encoding) + (req "sk" Tezos_crypto.Signature.Secret_key.encoding)) (function Explicit {pkh; pk; sk} -> Some (pkh, pk, sk) | _ -> None) (fun (pkh, pk, sk) -> Explicit {pkh; pk; sk}); case @@ -175,7 +176,7 @@ let input_source_encoding = case ~title:"pkh" (Tag 2) - (obj1 (req "pkh" Signature.Public_key_hash.encoding)) + (obj1 (req "pkh" Tezos_crypto.Signature.Public_key_hash.encoding)) (function Wallet_pkh pkh -> Some pkh | _ -> None) (fun pkh -> Wallet_pkh pkh); ] @@ -186,8 +187,8 @@ let injected_operations_encoding = let open Data_encoding in list (obj2 - (req "block_hash_when_injected" Block_hash.encoding) - (req "operation_hashes" (list Operation_hash.encoding))) + (req "block_hash_when_injected" Tezos_crypto.Block_hash.encoding) + (req "operation_hashes" (list Tezos_crypto.Operation_hash.encoding))) let transaction_costs_encoding = let open Data_encoding in @@ -241,7 +242,7 @@ let normalize_source cctxt = let open Lwt_syntax in let sk_of_sk_uri sk_uri = match - Signature.Secret_key.of_b58check + Tezos_crypto.Signature.Secret_key.of_b58check (Uri.path (sk_uri : Client_keys.sk_uri :> Uri.t)) with | Ok sk -> Lwt.return_some sk @@ -282,7 +283,9 @@ let normalize_source cctxt = in let key_from_wallet pkh = let warning msg pkh = - let* () = cctxt#warning msg Signature.Public_key_hash.pp pkh in + let* () = + cctxt#warning msg Tezos_crypto.Signature.Public_key_hash.pp pkh + in return_none in let* key = @@ -297,7 +300,7 @@ let normalize_source cctxt = cctxt#warning "Cannot extract the secret key form the pkh \"%a\" (alias: \ \"%s\") of the wallet" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh alias in @@ -343,7 +346,7 @@ let rec get_source_from_shuffled_pool state cctxt#message "sample_transfer: %d unused sources for the block next to %a" (List.length l) - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block) in Lwt.return source @@ -351,7 +354,7 @@ let rec get_source_from_shuffled_pool state let* () = cctxt#message "all available sources have been used for block next to %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp state.last_block in let* () = Lwt_condition.wait state.new_block_condition in @@ -362,7 +365,7 @@ let random_seed rng = let generate_fresh_source state = let seed = random_seed state.rng_state in - let pkh, pk, sk = Signature.generate_key ~seed () in + let pkh, pk, sk = Tezos_crypto.Signature.generate_key ~seed () in let fresh = {source = {pkh; pk; sk}; origin = Explicit} in state.pool <- fresh :: state.pool ; state.pool_size <- state.pool_size + 1 ; @@ -373,7 +376,9 @@ let generate_fresh_source state = [promise] resolved when the stream is closed. [stopper ()] closes the stream. *) let heads_iter (cctxt : Protocol_client_context.full) - (f : Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t) : + (f : + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t) : (unit tzresult Lwt.t * Tezos_rpc.Context.stopper) tzresult Lwt.t = let open Lwt_result_syntax in let* heads_stream, stopper = Shell_services.Monitor.heads cctxt `Main in @@ -388,7 +393,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "heads_iter: new block received %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp new_block_hash) in let* protocols = @@ -397,7 +402,10 @@ let heads_iter (cctxt : Protocol_client_context.full) ~block:(`Hash (new_block_hash, 0)) () in - if Protocol_hash.(protocols.current_protocol = Protocol.hash) then + if + Tezos_crypto.Protocol_hash.( + protocols.current_protocol = Protocol.hash) + then let* () = f block_hash_and_header in loop () else @@ -406,7 +414,7 @@ let heads_iter (cctxt : Protocol_client_context.full) cctxt#message "heads_iter: new block on protocol %a. Stopping \ iteration.@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocols.current_protocol) in return_unit) @@ -420,7 +428,7 @@ let heads_iter (cctxt : Protocol_client_context.full) log Debug (fun () -> cctxt#message "head iteration for proto %a stopped@." - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp Protocol.hash) in return (promise, stopper) @@ -453,7 +461,7 @@ let rec sample_transfer (cctxt : Protocol_client_context.full) chain block log Debug (fun () -> cctxt#message "sample_transfer: invalid balance %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp src.pkh) in (* Sampled source has zero balance: the transfer that created that @@ -499,7 +507,11 @@ let inject_contents (cctxt : Protocol_client_context.full) branch sk contents = ({branch}, Contents_list contents) in let signature = - Some (Signature.sign ~watermark:Signature.Generic_operation sk bytes) + Some + (Tezos_crypto.Signature.sign + ~watermark:Tezos_crypto.Signature.Generic_operation + sk + bytes) in let op : _ Operation.t = {shell = {branch}; protocol_data = {contents; signature}} @@ -552,14 +564,19 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state Alpha_services.Contract.counter cctxt (`Main, `Head 0) transfer.src.pkh in let* already_revealed = - if Signature.Public_key_hash.Set.mem transfer.src.pkh state.revealed then - return true + if + Tezos_crypto.Signature.Public_key_hash.Set.mem + transfer.src.pkh + state.revealed + then return true else ( (* Either the [manager_key] RPC tells us the key is already revealed, or we immediately inject a reveal operation: in any case the key is revealed in the end. *) state.revealed <- - Signature.Public_key_hash.Set.add transfer.src.pkh state.revealed ; + Tezos_crypto.Signature.Public_key_hash.Set.add + transfer.src.pkh + state.revealed ; let* pk_opt = Alpha_services.Contract.manager_key cctxt @@ -593,7 +610,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting reveal+transfer from %a (counters=%a,%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print reveal_counter @@ -619,7 +636,7 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Info (fun () -> cctxt#message "injecting transfer from %a (counter=%a) to %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp transfer.src.pkh Z.pp_print transf_counter @@ -635,15 +652,18 @@ let inject_transfer (cctxt : Protocol_client_context.full) parameters state log Debug (fun () -> cctxt#message "inject_transfer: op injected %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash) in let ops = Option.value ~default:[] - (Block_hash.Table.find state.injected_operations branch) + (Tezos_crypto.Block_hash.Table.find state.injected_operations branch) in - Block_hash.Table.replace state.injected_operations branch (op_hash :: ops) ; + Tezos_crypto.Block_hash.Table.replace + state.injected_operations + branch + (op_hash :: ops) ; return_unit | Error e -> let*! () = @@ -660,7 +680,7 @@ let save_injected_operations (cctxt : Protocol_client_context.full) state = let json = Data_encoding.Json.construct injected_operations_encoding - (Block_hash.Table.fold + (Tezos_crypto.Block_hash.Table.fold (fun k v acc -> (k, v) :: acc) state.injected_operations []) @@ -683,10 +703,10 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = let ratio_injected_included_op () = let* current_head_on_exit = Shell_services.Blocks.hash cctxt () in let inter_cardinal s1 s2 = - Operation_hash.Set.cardinal - (Operation_hash.Set.inter - (Operation_hash.Set.of_list s1) - (Operation_hash.Set.of_list s2)) + Tezos_crypto.Operation_hash.Set.cardinal + (Tezos_crypto.Operation_hash.Set.inter + (Tezos_crypto.Operation_hash.Set.of_list s1) + (Tezos_crypto.Operation_hash.Set.of_list s2)) in let get_included_ops older_block = let rec get_included_ops block acc_included_ops = @@ -718,7 +738,7 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = get_included_ops current_head_on_exit [] in let injected_ops = - Block_hash.Table.fold + Tezos_crypto.Block_hash.Table.fold (fun k l acc -> (* The operations injected during the last block are ignored because they should not be currently included. *) @@ -732,9 +752,9 @@ let stat_on_exit (cctxt : Protocol_client_context.full) state = log Debug (fun () -> cctxt#message "injected : [%a]@.included: [%a]" - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) injected_ops - (Format.pp_print_list ~pp_sep Operation_hash.pp) + (Format.pp_print_list ~pp_sep Tezos_crypto.Operation_hash.pp) included_ops) in let injected_ops_count = List.length injected_ops in @@ -828,7 +848,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) loop () in let on_new_head : - Block_hash.t * Tezos_base.Block_header.t -> unit tzresult Lwt.t = + Tezos_crypto.Block_hash.t * Tezos_base.Block_header.t -> + unit tzresult Lwt.t = (* Because of how Tenderbake works the target block should stay 2 blocks in the past because this guarantees that we are targeting a block that is decided. *) @@ -842,7 +863,8 @@ let launch (cctxt : Protocol_client_context.full) (parameters : parameters) in fun (new_block_hash, new_block_header) -> let* () = update_target_block () in - if not (Block_hash.equal new_block_hash state.last_block) then ( + if not (Tezos_crypto.Block_hash.equal new_block_hash state.last_block) + then ( state.last_block <- new_block_hash ; state.last_level <- Int32.to_int new_block_header.shell.level ; state.shuffled_pool <- @@ -1178,7 +1200,9 @@ let generate_random_transactions = let sources = List.sort_uniq (fun src1 src2 -> - Signature.Secret_key.compare src1.source.sk src2.source.sk) + Tezos_crypto.Signature.Secret_key.compare + src1.source.sk + src2.source.sk) sources in let rng_state = Random.State.make [|parameters.seed|] in @@ -1191,7 +1215,7 @@ let generate_random_transactions = cctxt#error "The level of the head (%a) needs to be greater than 2 and is \ actually %ld." - Block_hash.pp + Tezos_crypto.Block_hash.pp current_head_on_start header_on_start.level else return_unit @@ -1209,12 +1233,12 @@ let generate_random_transactions = List.shuffle ~rng:rng_state (List.map (fun src_org -> src_org.source) sources); - revealed = Signature.Public_key_hash.Set.empty; + revealed = Tezos_crypto.Signature.Public_key_hash.Set.empty; last_block = current_head_on_start; last_level = Int32.to_int header_on_start.level; target_block = current_target_block; new_block_condition = Lwt_condition.create (); - injected_operations = Block_hash.Table.create 1023; + injected_operations = Tezos_crypto.Block_hash.Table.create 1023; } in let exit_callback_id = @@ -1494,14 +1518,14 @@ let load_wallet cctxt ~source_pkh = | [] -> return acc | (alias, pkh, _, _) :: tl when List.exists (String.equal alias) to_ban - || Signature.Public_key_hash.equal pkh source_pkh -> + || Tezos_crypto.Signature.Public_key_hash.equal pkh source_pkh -> aux acc tl | (_, pkh, pk, sk_uri) :: tl -> let* pk_uri = Client_keys.neuterize sk_uri in let payload = Uri.path (sk_uri : Tezos_signer_backends.Unencrypted.sk_uri :> Uri.t) in - let sk = Signature.Secret_key.of_b58check_exn payload in + let sk = Tezos_crypto.Signature.Secret_key.of_b58check_exn payload in aux ({pkh; pk; pk_uri; sk; sk_uri} :: acc) tl in aux [] keys @@ -1514,7 +1538,7 @@ let source_key_arg = "Source key public key hash from which the tokens will be transferred to \ start the funding." (parameter (fun _ s -> - let r = Signature.Public_key_hash.of_b58check s in + let r = Tezos_crypto.Signature.Public_key_hash.of_b58check s in match r with | Ok pkh -> Lwt_result_syntax.return pkh | Error e -> @@ -1799,7 +1823,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command cctxt#message "Starting funding from %a with parameters:@.- batch_size %d@.- \ batches_per_block %d@.- initial_amount %a@." - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh batch_size batches_per_block @@ -1866,7 +1890,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command source_balance Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh else let*! () = @@ -1875,7 +1899,7 @@ let fund_accounts_from_source : Protocol_client_context.full Tezos_clic.command "Transfering %a tz from %a (out of %a)@." Tez.pp req_balance - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp source_pkh Tez.pp source_balance) diff --git a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_utils_commands.ml b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_utils_commands.ml index 0c210d59cfb6..837defaed600 100644 --- a/src/proto_015_PtLimaPt/lib_client_commands/client_proto_utils_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_commands/client_proto_utils_commands.ml @@ -95,7 +95,9 @@ let commands () = () in let* signature = sign_message cctxt ~src_sk ~block ~message in - let*! () = cctxt#message "Signature: %a" Signature.pp signature in + let*! () = + cctxt#message "Signature: %a" Tezos_crypto.Signature.pp signature + in return_unit); command ~group @@ -175,6 +177,8 @@ let commands () = sk unsigned_header in - let*! () = cctxt#message "%a" Hex.pp (Signature.to_hex s) in + let*! () = + cctxt#message "%a" Hex.pp (Tezos_crypto.Signature.to_hex s) + in return_unit); ] diff --git a/src/proto_015_PtLimaPt/lib_client_sapling/client_sapling_commands.ml b/src/proto_015_PtLimaPt/lib_client_sapling/client_sapling_commands.ml index 048c3270689e..6b61dc936cff 100644 --- a/src/proto_015_PtLimaPt/lib_client_sapling/client_sapling_commands.ml +++ b/src/proto_015_PtLimaPt/lib_client_sapling/client_sapling_commands.ml @@ -54,7 +54,7 @@ let viewing_key_of_string s = let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address - (Base58.simple_decode encoding s) + (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) @@ -62,7 +62,7 @@ let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Contract_hash.to_b58check contract in - let chain_id = Chain_id.to_b58check chain_id in + let chain_id = Tezos_crypto.Chain_id.to_b58check chain_id in return (address ^ chain_id) (** The shielded tez contract expects the recipient pkh encoded in Micheline @@ -71,7 +71,9 @@ let bound_data_of_public_key_hash cctxt dst = let open Tezos_micheline in let open Protocol.Michelson_v1_primitives in let pkh_bytes = - Data_encoding.Binary.to_bytes_exn Signature.Public_key_hash.encoding dst + Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Signature.Public_key_hash.encoding + dst in let micheline_bytes = Micheline.(Bytes (0, pkh_bytes) |> strip_locations) in let micheline_pkh_type = @@ -663,7 +665,9 @@ let commands () = Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = - Base58.simple_encode Viewing_key.address_b58check_encoding address + Tezos_crypto.Base58.simple_encode + Viewing_key.address_b58check_encoding + address in cctxt#message "Generated address:@.%s@.at index %Ld" diff --git a/src/proto_015_PtLimaPt/lib_client_sapling/context.ml b/src/proto_015_PtLimaPt/lib_client_sapling/context.ml index 9412ecb6f6e0..1122de030c3a 100644 --- a/src/proto_015_PtLimaPt/lib_client_sapling/context.ml +++ b/src/proto_015_PtLimaPt/lib_client_sapling/context.ml @@ -140,7 +140,7 @@ module Input_set = struct Format.fprintf pp "@[%s %Ld@]" - (Base58.simple_encode + (Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding (F.Input.address i)) (F.Input.amount i) diff --git a/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.ml b/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.ml index da5a0d216721..50954c9da376 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.ml @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.Context_hash.t -> + Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.mli b/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.mli index e6d262a8ad03..2d0533b7067b 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/abstract_context_index.mli @@ -25,7 +25,8 @@ type t = { checkout_fun : - Context_hash.t -> Tezos_protocol_environment.Context.t option Lwt.t; + Tezos_crypto.Context_hash.t -> + Tezos_protocol_environment.Context.t option Lwt.t; finalize_fun : unit -> unit Lwt.t; } diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_cache.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_cache.ml index af2ac36dc1fc..67fdb2d6a581 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_cache.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_cache.ml @@ -31,7 +31,7 @@ type round = Round.t module Block_cache = (val Ringo.(map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash) + (Tezos_crypto.Block_hash) (** The [Timestamp_of_round_tbl] module allows to create memoization tables to store function calls of [Round.timestamp_of_round]. *) diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_commands.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_commands.ml index b827d5b7cadd..9d76b8745fff 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_commands.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_commands.ml @@ -166,7 +166,7 @@ let liquidity_baking_toggle_vote_arg = liquidity_baking_toggle_vote_parameter let get_delegates (cctxt : Protocol_client_context.full) - (pkhs : Signature.public_key_hash list) = + (pkhs : Tezos_crypto.Signature.public_key_hash list) = let proj_delegate (alias, public_key_hash, public_key, secret_key_uri) = { Baking_state.alias = Some alias; diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.ml index 2b8dca57b0f6..db13c684bf3c 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.ml @@ -81,7 +81,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -221,7 +221,7 @@ let retries_on_failure_config_encoding = Data_encoding.int31 let user_activate_upgrades_config_encoding = let open Data_encoding in - list (tup2 int32 Protocol_hash.encoding) + list (tup2 int32 Tezos_crypto.Protocol_hash.encoding) let liquidity_baking_toggle_vote_config_encoding = Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote_encoding diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.mli index a1908d29dd22..cd5b5a445f41 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_configuration.mli @@ -56,7 +56,7 @@ type t = { nonce : nonce_config; validation : validation_config; retries_on_failure : int; - user_activated_upgrades : (int32 * Protocol_hash.t) list; + user_activated_upgrades : (int32 * Tezos_crypto.Protocol_hash.t) list; liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote; per_block_vote_file : string option; @@ -73,7 +73,8 @@ val default_nonce_config : nonce_config val default_retries_on_failure_config : int -val default_user_activated_upgrades : (int32 * Protocol_hash.t) list +val default_user_activated_upgrades : + (int32 * Tezos_crypto.Protocol_hash.t) list val default_liquidity_baking_toggle_vote : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote @@ -95,7 +96,7 @@ val make : ?nonce:nonce_config -> ?context_path:string -> ?retries_on_failure:int -> - ?user_activated_upgrades:(int32 * Protocol_hash.t) list -> + ?user_activated_upgrades:(int32 * Tezos_crypto.Protocol_hash.t) list -> ?liquidity_baking_toggle_vote: Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote -> ?per_block_vote_file:string -> @@ -114,7 +115,7 @@ val nonce_config_encoding : nonce_config Data_encoding.t val retries_on_failure_config_encoding : int Data_encoding.t val user_activate_upgrades_config_encoding : - (int32 * Protocol_hash.t) list Data_encoding.t + (int32 * Tezos_crypto.Protocol_hash.t) list Data_encoding.t val liquidity_baking_toggle_vote_config_encoding : Protocol.Alpha_context.Liquidity_baking.liquidity_baking_toggle_vote diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_events.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_events.ml index 0dd45ce85c65..2f1383b08951 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_events.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_events.ml @@ -43,8 +43,8 @@ module State_transitions = struct ~name:"new_head" ~level:Notice ~msg:"received new head {block} at level {level}, round {round}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) ~pp3:Round.pp @@ -119,12 +119,12 @@ module State_transitions = struct ~msg: "proposal {new_proposal} for current round ({current_round}) has \ already been seen {previous_proposal}" - ~pp1:Block_hash.pp - ("new_proposal", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("new_proposal", Tezos_crypto.Block_hash.encoding) ~pp2:Round.pp ("current_round", Round.encoding) - ~pp3:Block_hash.pp - ("previous_proposal", Block_hash.encoding) + ~pp3:Tezos_crypto.Block_hash.pp + ("previous_proposal", Tezos_crypto.Block_hash.encoding) let updating_latest_proposal = declare_1 @@ -132,8 +132,8 @@ module State_transitions = struct ~name:"updating_latest_proposal" ~msg:"updating latest proposal to {block_hash}" ~level:Info - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let baker_is_ahead_of_node = declare_2 @@ -156,10 +156,10 @@ module State_transitions = struct ~msg: "received a proposal on another branch - current: current \ pred{current_branch}, new pred {new_branch}" - ~pp1:Block_hash.pp - ("current_branch", Block_hash.encoding) - ~pp2:Block_hash.pp - ("new_branch", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("current_branch", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("new_branch", Tezos_crypto.Block_hash.encoding) let switching_branch = declare_0 @@ -215,8 +215,8 @@ module State_transitions = struct ~name:"attempting_preendorsing_proposal" ~level:Info ~msg:"attempting to preendorse proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let skipping_invalid_proposal = declare_0 @@ -232,8 +232,8 @@ module State_transitions = struct ~name:"outdated_proposal" ~level:Debug ~msg:"outdated proposal {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let proposing_fresh_block = declare_2 @@ -271,10 +271,10 @@ module State_transitions = struct ~msg: "unexpected prequorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let unexpected_quorum_received = declare_2 @@ -284,10 +284,10 @@ module State_transitions = struct ~msg: "unexpected quorum received for {received_hash} instead of \ {expected_hash}" - ~pp1:Block_hash.pp - ("received_hash", Block_hash.encoding) - ~pp2:Block_hash.pp - ("expected_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("received_hash", Tezos_crypto.Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("expected_hash", Tezos_crypto.Block_hash.encoding) let step_current_phase = declare_2 @@ -321,8 +321,8 @@ module Node_rpc = struct ~name:"raw_info" ~level:Debug ~msg:"raw info for {block_hash} at level {level}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) end @@ -451,8 +451,8 @@ module Scheduling = struct ~name:"proposal_in_the_future" ~level:Debug ~msg:"received proposal in the future {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) let process_proposal_in_the_future = declare_1 @@ -460,8 +460,8 @@ module Scheduling = struct ~name:"process_proposal_in_the_future" ~level:Debug ~msg:"process proposal received in the future with hash {block_hash}" - ~pp1:Block_hash.pp - ("block_hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block_hash", Tezos_crypto.Block_hash.encoding) end module Lib = struct @@ -543,8 +543,8 @@ module Actions = struct ~name:"preendorsement_injected" ~level:Notice ~msg:"injected preendorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_consensus_key_and_delegate ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -554,8 +554,8 @@ module Actions = struct ~name:"endorsement_injected" ~level:Notice ~msg:"injected endorsement {ophash} for {delegate}" - ~pp1:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) ~pp2:Baking_state.pp_consensus_key_and_delegate ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -565,8 +565,8 @@ module Actions = struct ~name:"synchronizing_round" ~level:Info ~msg:"synchronizing round after block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let forging_block = declare_3 @@ -601,11 +601,11 @@ module Actions = struct ~level:Notice ~msg: "block {block} at level {level}, round {round} injected for {delegate}" - ~pp1:Block_hash.pp + ~pp1:Tezos_crypto.Block_hash.pp ~pp2:pp_int32 ~pp3:Round.pp ~pp4:Baking_state.pp_consensus_key_and_delegate - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("round", Round.encoding) ("delegate", Baking_state.consensus_key_and_delegate_encoding) @@ -680,8 +680,8 @@ module VDF = struct ("cycle", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let vdf_daemon_start = declare_1 @@ -729,8 +729,8 @@ module Nonces = struct ~name:"found_nonce_to_reveal" ~level:Notice ~msg:"found nonce to reveal for block {block}, level {level}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) ~pp2:pp_int32 ("level", Data_encoding.int32) @@ -746,8 +746,8 @@ module Nonces = struct ("level", Data_encoding.int32) ~pp2:Format.pp_print_string ("chain", Data_encoding.string) - ~pp3:Operation_hash.pp - ("ophash", Operation_hash.encoding) + ~pp3:Tezos_crypto.Operation_hash.pp + ("ophash", Tezos_crypto.Operation_hash.encoding) let cannot_fetch_chain_head_level = declare_0 @@ -821,8 +821,8 @@ module Nonces = struct ~name:"registering_nonce" ~level:Info ~msg:"registering nonce for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let nothing_to_reveal = declare_1 @@ -830,8 +830,8 @@ module Nonces = struct ~name:"nothing_to_reveal" ~level:Info ~msg:"nothing to reveal for block {block}" - ~pp1:Block_hash.pp - ("block", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("block", Tezos_crypto.Block_hash.encoding) let revelation_worker_started = declare_0 @@ -916,8 +916,8 @@ module Selection = struct ~name:"invalid_operation_filtered" ~level:Warning ~msg:"filtered invalid operation {op}: {errors}" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) @@ -927,6 +927,6 @@ module Selection = struct ~name:"cannot_serialize_operation_metadata" ~level:Warning ~msg:"cannot serialize operation {op} metadata" - ~pp1:Operation_hash.pp - ("op", Operation_hash.encoding) + ~pp1:Tezos_crypto.Operation_hash.pp + ("op", Tezos_crypto.Operation_hash.encoding) end diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_files.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_files.ml index 38339e2fe555..67ef0c7ea0d4 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_files.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_files.ml @@ -32,6 +32,6 @@ let resolve_location ~chain_id (kind : 'a) : 'a location = | `State -> "baker_state" | `Nonce -> "nonce" in - Format.asprintf "%a_%s" Chain_id.pp_short chain_id basename + Format.asprintf "%a_%s" Tezos_crypto.Chain_id.pp_short chain_id basename let filename x = x diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_files.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_files.mli index 01146f7d0744..82940952da05 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_files.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_files.mli @@ -26,7 +26,7 @@ type _ location val resolve_location : - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> ([< `Highwatermarks | `Nonce | `State] as 'kind) -> 'kind location diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.ml index 91b56b3e50b1..4af172f183fe 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.ml @@ -100,9 +100,9 @@ let () = (fun highwatermark -> Block_previously_endorsed highwatermark) module DelegateMap = Map.Make (struct - type t = Signature.Public_key_hash.t + type t = Tezos_crypto.Signature.Public_key_hash.t - let compare = Signature.Public_key_hash.compare + let compare = Tezos_crypto.Signature.Public_key_hash.compare end) let highwatermark_delegate_map_encoding = @@ -113,7 +113,7 @@ let highwatermark_delegate_map_encoding = fun l -> List.fold_left (fun map (k, v) -> add k v map) empty l) (list (obj2 - (req "delegate" Signature.Public_key_hash.encoding) + (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding) (req "highwatermark" highwatermark_encoding))) type highwatermarks = { diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.mli index 757b667c58bb..30d4d6f4ea3e 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_highwatermarks.mli @@ -45,7 +45,7 @@ val load : val may_sign_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -53,7 +53,7 @@ val may_sign_block : val may_sign_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -61,7 +61,7 @@ val may_sign_preendorsement : val may_sign_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> bool tzresult Lwt.t @@ -69,7 +69,7 @@ val may_sign_endorsement : val record_block : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -77,7 +77,7 @@ val record_block : val record_preendorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t @@ -85,7 +85,7 @@ val record_preendorsement : val record_endorsement : #Protocol_client_context.full -> [`Highwatermarks] Baking_files.location -> - delegate:Signature.public_key_hash -> + delegate:Tezos_crypto.Signature.public_key_hash -> level:int32 -> round:Round.t -> unit tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_lib.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_lib.ml index 7ec3ae000cd5..f1b23c4582c1 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_lib.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_lib.ml @@ -268,7 +268,7 @@ let propose_at_next_level ~minimal_timestamp state = "Proposed block at round %a on top of %a " Round.pp block_to_bake.round - Block_hash.pp + Tezos_crypto.Block_hash.pp block_to_bake.predecessor.hash in return state @@ -411,7 +411,7 @@ let bake_using_automaton config state block_stream = let*! () = cctxt#message "Block %a (%ld) injected" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash proposal.block.shell.level in diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.ml index e8db5ef6965f..3acc87f16377 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.ml @@ -33,27 +33,34 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -let empty = Block_hash.Map.empty +let empty = Tezos_crypto.Block_hash.Map.empty let encoding = let open Data_encoding in def "seed_nonce" @@ conv (fun m -> - Block_hash.Map.fold (fun hash nonce acc -> (hash, nonce) :: acc) m []) + Tezos_crypto.Block_hash.Map.fold + (fun hash nonce acc -> (hash, nonce) :: acc) + m + []) (fun l -> List.fold_left - (fun map (hash, nonce) -> Block_hash.Map.add hash nonce map) - Block_hash.Map.empty + (fun map (hash, nonce) -> + Tezos_crypto.Block_hash.Map.add hash nonce map) + Tezos_crypto.Block_hash.Map.empty l) - @@ list (obj2 (req "block" Block_hash.encoding) (req "nonce" Nonce.encoding)) + @@ list + (obj2 + (req "block" Tezos_crypto.Block_hash.encoding) + (req "nonce" Nonce.encoding)) let may_migrate (wallet : Protocol_client_context.full) location = let base_dir = wallet#get_base_dir in @@ -78,16 +85,16 @@ let load (wallet : #Client_context.wallet) location = let save (wallet : #Client_context.wallet) location nonces = wallet#write (Baking_files.filename location) nonces encoding -let mem nonces hash = Block_hash.Map.mem hash nonces +let mem nonces hash = Tezos_crypto.Block_hash.Map.mem hash nonces -let find_opt nonces hash = Block_hash.Map.find hash nonces +let find_opt nonces hash = Tezos_crypto.Block_hash.Map.find hash nonces -let add nonces hash nonce = Block_hash.Map.add hash nonce nonces +let add nonces hash nonce = Tezos_crypto.Block_hash.Map.add hash nonce nonces -let remove nonces hash = Block_hash.Map.remove hash nonces +let remove nonces hash = Tezos_crypto.Block_hash.Map.remove hash nonces let remove_all nonces nonces_to_remove = - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash _ acc -> remove acc hash) nonces_to_remove nonces @@ -116,7 +123,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let block_cycle = Int32.(div block_level blocks_per_cycle) in Int32.sub current_cycle block_cycle > Int32.of_int preserved_cycles in - Block_hash.Map.fold + Tezos_crypto.Block_hash.Map.fold (fun hash nonce acc -> acc >>=? fun (orphans, outdated) -> get_block_level_opt cctxt ~chain ~block:(`Hash (hash, 0)) >>= function @@ -131,7 +138,7 @@ let get_outdated_nonces {cctxt; constants; chain; _} nonces = let filter_outdated_nonces state nonces = get_outdated_nonces state nonces >>=? fun (orphans, outdated_nonces) -> when_ - (Block_hash.Map.cardinal orphans >= 50) + (Tezos_crypto.Block_hash.Map.cardinal orphans >= 50) (fun () -> Events.( emit too_many_nonces (Baking_files.filename state.nonces_location ^ "s")) @@ -207,7 +214,9 @@ let generate_seed_nonce (nonce_config : Baking_configuration.nonce_config) >>=? fun nonce -> return (Data_encoding.Binary.of_bytes_exn Nonce.encoding nonce) | Random -> ( - match Nonce.of_bytes (Rand.generate Constants.nonce_length) with + match + Nonce.of_bytes (Tezos_crypto.Rand.generate Constants.nonce_length) + with | Error _errs -> assert false | Ok nonce -> return nonce)) >>=? fun nonce -> return (Nonce.hash nonce, nonce) @@ -237,7 +246,9 @@ let inject_seed_nonce_revelation (cctxt : #Protocol_client_context.full) ~chain ~nonce () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Shell_services.Injection.operation ~async:true cctxt ~chain bytes >>=? fun oph -> Events.( @@ -252,8 +263,9 @@ let reveal_potential_nonces state new_proposal = let {cctxt; chain; nonces_location; last_predecessor; _} = state in let new_predecessor_hash = new_proposal.Baking_state.predecessor.hash in if - Block_hash.(last_predecessor <> new_predecessor_hash) - && Protocol_hash.(new_proposal.predecessor.protocol = Protocol.hash) + Tezos_crypto.Block_hash.(last_predecessor <> new_predecessor_hash) + && Tezos_crypto.Protocol_hash.( + new_proposal.predecessor.protocol = Protocol.hash) then ( (* only try revealing nonces when the proposal's predecessor is a new one *) state.last_predecessor <- new_predecessor_hash ; @@ -304,7 +316,7 @@ let start_revelation_worker cctxt config chain_id constants block_stream = constants; config; nonces_location; - last_predecessor = Block_hash.zero; + last_predecessor = Tezos_crypto.Block_hash.zero; } in let rec worker_loop () = diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.mli index 6e69b009180d..df34657eb901 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_nonces.mli @@ -32,31 +32,35 @@ type state = { constants : Constants.t; config : Baking_configuration.nonce_config; nonces_location : [`Nonce] Baking_files.location; - mutable last_predecessor : Block_hash.t; + mutable last_predecessor : Tezos_crypto.Block_hash.t; } type t = state -type nonces = Nonce.t Block_hash.Map.t +type nonces = Nonce.t Tezos_crypto.Block_hash.Map.t -val empty : Nonce.t Block_hash.Map.t +val empty : Nonce.t Tezos_crypto.Block_hash.Map.t -val encoding : Nonce.t Block_hash.Map.t Data_encoding.t +val encoding : Nonce.t Tezos_crypto.Block_hash.Map.t Data_encoding.t val load : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val save : #Client_context.wallet -> [< `Highwatermarks | `Nonce | `State] Baking_files.location -> - Nonce.t Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> unit tzresult Lwt.t -val mem : Nonce.t Block_hash.Map.t -> Block_hash.t -> bool +val mem : + Nonce.t Tezos_crypto.Block_hash.Map.t -> Tezos_crypto.Block_hash.t -> bool -val find_opt : Nonce.t Block_hash.Map.t -> Block_hash.t -> Nonce.t option +val find_opt : + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Tezos_crypto.Block_hash.t -> + Nonce.t option val get_block_level_opt : #Tezos_rpc.Context.simple -> @@ -66,21 +70,28 @@ val get_block_level_opt : val get_outdated_nonces : t -> - Nonce.t Block_hash.Map.t -> - (Nonce.t Block_hash.Map.t * Nonce.t Block_hash.Map.t) tzresult Lwt.t + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Nonce.t Tezos_crypto.Block_hash.Map.t + * Nonce.t Tezos_crypto.Block_hash.Map.t) + tzresult + Lwt.t val filter_outdated_nonces : - t -> Nonce.t Block_hash.Map.t -> Nonce.t Block_hash.Map.t tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + Nonce.t Tezos_crypto.Block_hash.Map.t tzresult Lwt.t val blocks_from_current_cycle : t -> Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t val get_unrevealed_nonces : - t -> Nonce.t Block_hash.Map.t -> (Raw_level.t * Nonce.t) list tzresult Lwt.t + t -> + Nonce.t Tezos_crypto.Block_hash.Map.t -> + (Raw_level.t * Nonce.t) list tzresult Lwt.t val generate_seed_nonce : Baking_configuration.nonce_config -> @@ -90,8 +101,8 @@ val generate_seed_nonce : val register_nonce : #Protocol_client_context.full -> - chain_id:Chain_id.t -> - Block_hash.t -> + chain_id:Tezos_crypto.Chain_id.t -> + Tezos_crypto.Block_hash.t -> Nonce.t -> unit tzresult Lwt.t @@ -99,7 +110,7 @@ val inject_seed_nonce_revelation : #Protocol_client_context.full -> chain:Chain_services.chain -> block:Block_services.block -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> (Raw_level.t * Nonce.t) list -> unit tzresult Lwt.t @@ -108,7 +119,7 @@ val reveal_potential_nonces : t -> Baking_state.proposal -> unit tzresult Lwt.t val start_revelation_worker : Protocol_client_context.full -> Baking_configuration.nonce_config -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> Constants.t -> Baking_state.proposal Lwt_stream.t -> Lwt_canceler.t Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_pow.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_pow.ml index 5637988fb52b..d5d4d4be293b 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_pow.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_pow.ml @@ -59,7 +59,7 @@ let init_proof_of_work_nonce () = (* This was used before November 2018 *) (* (\* Random proof of work *\) * let generate_proof_of_work_nonce () = - * Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) + * Tezos_crypto.Rand.generate Alpha_context.Constants.proof_of_work_nonce_size *) let empty_proof_of_work_nonce = Bytes.make Constants_repr.proof_of_work_nonce_size '\000' diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_scheduling.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_scheduling.ml index 38d42a06cc3d..bca851f697d8 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_scheduling.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_scheduling.ml @@ -211,8 +211,10 @@ let compute_next_round_time state = | None -> state.level_state.latest_proposal | Some {proposal; _} -> proposal in - if Protocol_hash.(proposal.predecessor.next_protocol <> Protocol.hash) then - None + if + Tezos_crypto.Protocol_hash.( + proposal.predecessor.next_protocol <> Protocol.hash) + then None else match state.level_state.next_level_proposed_round with | Some _proposed_round -> @@ -630,7 +632,7 @@ let create_initial_state cctxt ?(synchronize = true) ~chain config >>=? fun next_level_delegate_slots -> let elected_block = if - Protocol_hash.( + Tezos_crypto.Protocol_hash.( current_proposal.block.protocol <> Protocol.hash && current_proposal.block.next_protocol = Protocol.hash) then diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.ml index 957768d1b412..39b641175d45 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.ml @@ -94,9 +94,9 @@ let begin_construction ~timestamp ~protocol_data fitness = pred_shell.fitness; timestamp; level = pred_shell.level; - context = Context_hash.zero (* fake context hash *); + context = Tezos_crypto.Context_hash.zero (* fake context hash *); operations_hash = - Operation_list_list_hash.zero (* fake op hash *); + Tezos_crypto.Operation_list_list_hash.zero (* fake op hash *); } in let mode = diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.mli index 0d0c7ac9f4d2..d6d45255028e 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_simulator.mli @@ -39,14 +39,14 @@ val load_context : (** Make sure that the given context is consistent by trying to read in it *) val check_context_consistency : - Abstract_context_index.t -> Context_hash.t -> unit tzresult Lwt.t + Abstract_context_index.t -> Tezos_crypto.Context_hash.t -> unit tzresult Lwt.t val begin_construction : timestamp:Time.Protocol.t -> protocol_data:block_header_data -> Abstract_context_index.t -> Baking_state.block_info -> - Chain_id.t -> + Tezos_crypto.Chain_id.t -> incremental tzresult Lwt.t val add_operation : diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_state.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_state.ml index 5e87c78b4efd..2902469662c7 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_state.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_state.ml @@ -31,8 +31,8 @@ open Protocol_client_context public key, its public key hash, and its secret key. *) type consensus_key = { alias : string option; - public_key : Signature.Public_key.t; - public_key_hash : Signature.Public_key_hash.t; + public_key : Tezos_crypto.Signature.Public_key.t; + public_key_hash : Tezos_crypto.Signature.Public_key_hash.t; secret_key_uri : Client_keys.sk_uri; } @@ -56,39 +56,48 @@ let consensus_key_encoding = }) (obj4 (req "alias" (option string)) - (req "public_key" Signature.Public_key.encoding) - (req "public_key_hash" Signature.Public_key_hash.encoding) + (req "public_key" Tezos_crypto.Signature.Public_key.encoding) + (req "public_key_hash" Tezos_crypto.Signature.Public_key_hash.encoding) (req "secret_key_uri" string)) let pp_consensus_key fmt {alias; public_key_hash; _} = match alias with - | None -> Format.fprintf fmt "%a" Signature.Public_key_hash.pp public_key_hash + | None -> + Format.fprintf + fmt + "%a" + Tezos_crypto.Signature.Public_key_hash.pp + public_key_hash | Some alias -> Format.fprintf fmt "%s (%a)" alias - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp public_key_hash -type consensus_key_and_delegate = consensus_key * Signature.Public_key_hash.t +type consensus_key_and_delegate = + consensus_key * Tezos_crypto.Signature.Public_key_hash.t let consensus_key_and_delegate_encoding = let open Data_encoding in merge_objs consensus_key_encoding - (obj1 (req "delegate" Signature.Public_key_hash.encoding)) + (obj1 (req "delegate" Tezos_crypto.Signature.Public_key_hash.encoding)) let pp_consensus_key_and_delegate fmt (consensus_key, delegate) = - if Signature.Public_key_hash.equal consensus_key.public_key_hash delegate then - pp_consensus_key fmt consensus_key + if + Tezos_crypto.Signature.Public_key_hash.equal + consensus_key.public_key_hash + delegate + then pp_consensus_key fmt consensus_key else Format.fprintf fmt "%a@,on behalf of %a" pp_consensus_key consensus_key - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp delegate type validation_mode = Node | Local of Abstract_context_index.t @@ -101,17 +110,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; } type cache = { @@ -125,7 +134,7 @@ type global_state = { (* client context *) cctxt : Protocol_client_context.full; (* chain id *) - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; (* baker configuration *) config : Baking_configuration.t; (* protocol constants *) @@ -213,17 +222,17 @@ let block_info_encoding = }) (merge_objs (obj10 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "shell" Block_header.shell_header_encoding) (req "payload_hash" Block_payload_hash.encoding) (req "payload_round" Round.encoding) (req "round" Round.encoding) - (req "protocol" Protocol_hash.encoding) - (req "next_protocol" Protocol_hash.encoding) + (req "protocol" Tezos_crypto.Protocol_hash.encoding) + (req "next_protocol" Tezos_crypto.Protocol_hash.encoding) (req "prequorum" (option prequorum_encoding)) (req "quorum" (list (dynamic_size Operation.encoding))) (req "payload" Operation_pool.payload_encoding)) - (obj1 (req "live_blocks" Block_hash.Set.encoding))) + (obj1 (req "live_blocks" Tezos_crypto.Block_hash.Set.encoding))) let round_of_shell_header shell_header = Environment.wrap_tzresult @@ -595,7 +604,7 @@ module DelegateSet = struct type t = consensus_key let compare {public_key_hash = pkh; _} {public_key_hash = pkh'; _} = - Signature.Public_key_hash.compare pkh pkh' + Tezos_crypto.Signature.Public_key_hash.compare pkh pkh' end) let find_pkh pkh s = @@ -603,8 +612,8 @@ module DelegateSet = struct try iter (fun ({public_key_hash; _} as delegate) -> - if Signature.Public_key_hash.equal pkh public_key_hash then - raise (Found delegate) + if Tezos_crypto.Signature.Public_key_hash.equal pkh public_key_hash + then raise (Found delegate) else ()) s ; None @@ -670,7 +679,7 @@ let pp_global_state fmt {chain_id; config; validation_mode; delegates; _} = fmt "@[Global state:@ chain_id: %a@ @[config:@ %a@]@ \ validation_mode: %a@ @[delegates:@ %a@]@]" - Chain_id.pp + Tezos_crypto.Chain_id.pp chain_id Baking_configuration.pp config @@ -712,16 +721,16 @@ let pp_block_info fmt "@[Block:@ hash: %a@ payload_hash: %a@ level: %ld@ round: %a@ \ protocol: %a@ next protocol: %a@ prequorum: %a@ quorum: %d endorsements@ \ payload: %a@]" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash Block_payload_hash.pp_short payload_hash shell.level Round.pp round - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short protocol - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short next_protocol (pp_option pp_prequorum) prequorum @@ -744,7 +753,7 @@ let pp_endorsable_payload fmt {proposal; prequorum} = Format.fprintf fmt "proposal: %a, prequorum: %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp proposal.block.hash pp_prequorum prequorum @@ -861,7 +870,7 @@ let pp_event fmt = function round %a" (List.length preendos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched @@ -871,7 +880,7 @@ let pp_event fmt = function "quorum reached with %d endorsements (power: %d) for %a at round %a" (List.length endos) voting_power - Block_hash.pp + Tezos_crypto.Block_hash.pp candidate.Operation_worker.hash Round.pp candidate.round_watched diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_state.mli b/src/proto_015_PtLimaPt/lib_delegate/baking_state.mli index 3650fc322708..3936193bb346 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_state.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_state.mli @@ -28,8 +28,8 @@ open Alpha_context type consensus_key = { alias : string option; - public_key : Signature.public_key; - public_key_hash : Signature.public_key_hash; + public_key : Tezos_crypto.Signature.public_key; + public_key_hash : Tezos_crypto.Signature.public_key_hash; secret_key_uri : Client_keys.sk_uri; } @@ -37,7 +37,8 @@ val consensus_key_encoding : consensus_key Data_encoding.t val pp_consensus_key : Format.formatter -> consensus_key -> unit -type consensus_key_and_delegate = consensus_key * Signature.Public_key_hash.t +type consensus_key_and_delegate = + consensus_key * Tezos_crypto.Signature.Public_key_hash.t val consensus_key_and_delegate_encoding : consensus_key_and_delegate Data_encoding.t @@ -55,17 +56,17 @@ type prequorum = { } type block_info = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; shell : Block_header.shell_header; payload_hash : Block_payload_hash.t; payload_round : Round.t; round : Round.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; prequorum : prequorum option; quorum : Kind.endorsement operation list; payload : Operation_pool.payload; - live_blocks : Block_hash.Set.t; + live_blocks : Tezos_crypto.Block_hash.Set.t; (** Set of live blocks for this block that is used to filter old or too recent operations. *) } @@ -79,7 +80,7 @@ type cache = { type global_state = { cctxt : Protocol_client_context.full; - chain_id : Chain_id.t; + chain_id : Tezos_crypto.Chain_id.t; config : Baking_configuration.t; constants : Constants.t; round_durations : Round.round_durations; diff --git a/src/proto_015_PtLimaPt/lib_delegate/baking_vdf.ml b/src/proto_015_PtLimaPt/lib_delegate/baking_vdf.ml index b08fd5ebea7b..6dc6d5e9abb1 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/baking_vdf.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/baking_vdf.ml @@ -156,7 +156,7 @@ let inject_vdf_revelation cctxt hash chain_id solution = ~solution () in - let bytes = Signature.concat bytes Signature.zero in + let bytes = Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero in Shell_services.Injection.operation cctxt ~chain bytes (* Checks if the VDF setup saved in the state is equal to the one computed @@ -182,7 +182,7 @@ let process_new_block (cctxt : #Protocol_client_context.full) state let* level_info = get_level_info cctxt level in let level_str = Int32.to_string (Raw_level.to_int32 level) in let* () = check_new_cycle state level_info in - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then let*! () = D_Events.(emit protocol_change_detected) () in return_unit else diff --git a/src/proto_015_PtLimaPt/lib_delegate/block_forge.ml b/src/proto_015_PtLimaPt/lib_delegate/block_forge.ml index a367b6b655c8..dcd4e7228e82 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/block_forge.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/block_forge.ml @@ -52,7 +52,7 @@ let forge_faked_protocol_data ?(payload_hash = Block_payload_hash.zero) proof_of_work_nonce = Baking_pow.empty_proof_of_work_nonce; liquidity_baking_toggle_vote; }; - signature = Signature.zero; + signature = Tezos_crypto.Signature.zero; } let convert_operation (op : packed_operation) : Tezos_base.Operation.t = @@ -112,7 +112,7 @@ let finalize_block_header shell_header timestamp validation_result let retain_live_operations_only ~live_blocks operation_pool = Operation_pool.Prioritized.filter (fun ({shell; _} : packed_operation) -> - Block_hash.Set.mem shell.branch live_blocks) + Tezos_crypto.Block_hash.Set.mem shell.branch live_blocks) operation_pool let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info @@ -136,7 +136,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info | None -> next_protocol | Some hash -> hash in - return Protocol_hash.(Protocol.hash <> next_protocol) + return Tezos_crypto.Protocol_hash.(Protocol.hash <> next_protocol) in let filter_via_node ~operation_pool = let filtered_operations = @@ -168,7 +168,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let operation_list_hash = Stdlib.List.tl operations |> List.flatten |> List.map Tezos_base.Operation.hash - |> Operation_list_hash.compute + |> Tezos_crypto.Operation_list_hash.compute in Block_payload.hash ~predecessor:shell_header.predecessor @@ -242,7 +242,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let operation_list_hash = Stdlib.List.tl operations |> List.flatten |> List.map Tezos_base.Operation.hash - |> Operation_list_hash.compute + |> Tezos_crypto.Operation_list_hash.compute in Block_payload.hash ~predecessor:shell_header.predecessor @@ -297,10 +297,11 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info >>=? fun (incremental, ordered_pool) -> let operations = Operation_pool.ordered_to_list_list ordered_pool in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in (* We need to compute the final [operations_hash] before @@ -384,7 +385,7 @@ let forge (cctxt : #Protocol_client_context.full) ~chain_id ~pred_info let unsigned_block_header = { Block_header.shell = shell_header; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in return {unsigned_block_header; operations} diff --git a/src/proto_015_PtLimaPt/lib_delegate/block_forge.mli b/src/proto_015_PtLimaPt/lib_delegate/block_forge.mli index b111e27b417c..abf60c86d8f4 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/block_forge.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/block_forge.mli @@ -50,7 +50,7 @@ val forge_faked_protocol_data : val forge : #Protocol_client_context.full -> - chain_id:Chain_id.t -> + chain_id:Tezos_crypto.Chain_id.t -> pred_info:Baking_state.block_info -> timestamp:Time.Protocol.t -> liquidity_baking_toggle_vote:Liquidity_baking.liquidity_baking_toggle_vote -> diff --git a/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.ml b/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.ml index d7064545b7bd..e192aa649a72 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.ml @@ -28,16 +28,16 @@ open Alpha_context open Protocol_client_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } let raw_info cctxt ?(chain = `Main) hash shell_header = @@ -80,9 +80,9 @@ let info cctxt ?(chain = `Main) block = module Block_seen_event = struct type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Tezos_base.Block_header.t; - occurrence : [`Valid_blocks of Chain_id.t | `Heads]; + occurrence : [`Valid_blocks of Tezos_crypto.Chain_id.t | `Heads]; } let make hash header occurrence = {hash; header; occurrence} @@ -101,7 +101,7 @@ module Block_seen_event = struct (function {hash; header; occurrence} -> (hash, occurrence, header)) (fun (hash, occurrence, header) -> make hash header occurrence) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (* Occurrence has to come before header, because: (Invalid_argument "Cannot merge two objects when the left element is of @@ -123,7 +123,7 @@ module Block_seen_event = struct (Tag 1) (obj2 (req "occurrence-kind" (constant "valid-blocks")) - (req "chain-id" Chain_id.encoding)) + (req "chain-id" Tezos_crypto.Chain_id.encoding)) (function | `Valid_blocks ch -> Some ((), ch) | _ -> None) (fun ((), ch) -> `Valid_blocks ch); @@ -133,7 +133,7 @@ module Block_seen_event = struct With_version.(encoding ~name (first_version v0_encoding)) let pp ~short:_ ppf {hash; _} = - Format.fprintf ppf "Saw block %a" Block_hash.pp_short hash + Format.fprintf ppf "Saw block %a" Tezos_crypto.Block_hash.pp_short hash let doc = "Block observed while monitoring a blockchain." @@ -173,7 +173,7 @@ let monitor_heads cctxt ~next_protocols chain = type error += | Unexpected_empty_block_list of { chain : string; - block_hash : Block_hash.t; + block_hash : Tezos_crypto.Block_hash.t; length : int; } @@ -190,13 +190,13 @@ let () = "Unexpected empty block list retrieved from chain %s at block %a, \ length %d" chain - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash length) Data_encoding.( obj3 (req "chain" string) - (req "block_hash" Block_hash.encoding) + (req "block_hash" Tezos_crypto.Block_hash.encoding) (req "length" int31)) (function | Unexpected_empty_block_list {chain; block_hash; length} -> diff --git a/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.mli b/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.mli index c3358f61f82f..07d582b6ed9b 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/client_baking_blocks.mli @@ -27,16 +27,16 @@ open Protocol open Alpha_context type block_info = { - hash : Block_hash.t; - chain_id : Chain_id.t; - predecessor : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; + chain_id : Tezos_crypto.Chain_id.t; + predecessor : Tezos_crypto.Block_hash.t; fitness : Bytes.t list; timestamp : Time.Protocol.t; - protocol : Protocol_hash.t; - next_protocol : Protocol_hash.t; + protocol : Tezos_crypto.Protocol_hash.t; + next_protocol : Tezos_crypto.Protocol_hash.t; proto_level : int; level : Raw_level.t; - context : Context_hash.t; + context : Tezos_crypto.Context_hash.t; } val info : @@ -48,14 +48,14 @@ val info : val monitor_valid_blocks : #Protocol_client_context.rpc_context -> ?chains:Chain_services.chain list -> - ?protocols:Protocol_hash.t list -> - next_protocols:Protocol_hash.t list option -> + ?protocols:Tezos_crypto.Protocol_hash.t list -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> unit -> (block_info tzresult Lwt_stream.t * Tezos_rpc.Context.stopper) tzresult Lwt.t val monitor_heads : #Protocol_client_context.rpc_context -> - next_protocols:Protocol_hash.t list option -> + next_protocols:Tezos_crypto.Protocol_hash.t list option -> Chain_services.chain -> block_info tzresult Lwt_stream.t tzresult Lwt.t @@ -65,4 +65,4 @@ val blocks_from_current_cycle : Block_services.block -> ?offset:int32 -> unit -> - Block_hash.t list tzresult Lwt.t + Tezos_crypto.Block_hash.t list tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_delegate/client_baking_denunciation.ml b/src/proto_015_PtLimaPt/lib_delegate/client_baking_denunciation.ml index 2ebc4af5961e..21b58428d339 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/client_baking_denunciation.ml @@ -31,16 +31,16 @@ module Events = Delegate_events.Denunciator module B_Events = Delegate_events.Baking_scheduling module HLevel = Hashtbl.Make (struct - type t = Chain_id.t * Raw_level.t * Round.t + type t = Tezos_crypto.Chain_id.t * Raw_level.t * Round.t let equal (c, l, r) (c', l', r') = - Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' + Tezos_crypto.Chain_id.equal c c' && Raw_level.equal l l' && Round.equal r r' let hash (c, lvl, r) = Hashtbl.hash (c, lvl, r) end) (* Blocks are associated to the delegates who baked them *) -module Delegate_Map = Map.Make (Signature.Public_key_hash) +module Delegate_Map = Map.Make (Tezos_crypto.Signature.Public_key_hash) (* (pre)endorsements are associated to the slot they are injected with; we rely on the fact that there is a unique canonical slot @@ -49,7 +49,8 @@ module Slot_Map = Slot.Map (* type of operations stream, as returned by monitor_operations RPC *) type ops_stream = - ((Operation_hash.t * packed_operation) * error trace option) list Lwt_stream.t + ((Tezos_crypto.Operation_hash.t * packed_operation) * error trace option) list + Lwt_stream.t type 'a state = { (* Endorsements seen so far *) @@ -57,7 +58,7 @@ type 'a state = { (* Preendorsements seen so far *) preendorsements_table : Kind.preendorsement operation Slot_Map.t HLevel.t; (* Blocks received so far *) - blocks_table : Block_hash.t Delegate_Map.t HLevel.t; + blocks_table : Tezos_crypto.Block_hash.t Delegate_Map.t HLevel.t; (* Maximum delta of level to register *) preserved_levels : int; (* Highest level seen in a block *) @@ -126,7 +127,7 @@ let double_consensus_op_evidence (type kind) : kind consensus_operation_type -> #Protocol_client_context.full -> 'a -> - branch:Block_hash.t -> + branch:Tezos_crypto.Block_hash.t -> op1:kind Alpha_context.operation -> op2:kind Alpha_context.operation -> unit -> @@ -159,7 +160,7 @@ let process_consensus_op (type kind) cctxt (Operation.hash new_op, Operation.hash existing_op) in let op1, op2 = - if Operation_hash.(new_op_hash < existing_op_hash) then + if Tezos_crypto.Operation_hash.(new_op_hash < existing_op_hash) then (new_op, existing_op) else (existing_op, new_op) in @@ -175,7 +176,9 @@ let process_consensus_op (type kind) cctxt ~op2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in let double_op_detected, double_op_denounced = Events.( match op_kind with @@ -271,7 +274,8 @@ let process_block (cctxt : #Protocol_client_context.full) state state.blocks_table (chain_id, level, round) (Delegate_Map.add baker.delegate new_hash map) - | Some existing_hash when Block_hash.(existing_hash = new_hash) -> + | Some existing_hash + when Tezos_crypto.Block_hash.(existing_hash = new_hash) -> (* This case should never happen *) Events.(emit double_baking_but_not) () >>= fun () -> return @@ -287,7 +291,8 @@ let process_block (cctxt : #Protocol_client_context.full) state let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in let bh1, bh2 = - if Block_hash.(hash1 < hash2) then (bh1, bh2) else (bh2, bh1) + if Tezos_crypto.Block_hash.(hash1 < hash2) then (bh1, bh2) + else (bh2, bh1) in (* If the blocks are on different chains then skip it *) get_block_offset level >>= fun block -> @@ -301,7 +306,9 @@ let process_block (cctxt : #Protocol_client_context.full) state ~bh2 () >>=? fun bytes -> - let bytes = Signature.concat bytes Signature.zero in + let bytes = + Tezos_crypto.Signature.concat bytes Tezos_crypto.Signature.zero + in Events.(emit double_baking_detected) () >>= fun () -> Shell_services.Injection.operation cctxt ~chain bytes >>=? fun op_hash -> @@ -346,7 +353,7 @@ let cleanup_old_operations state = *) let process_new_block (cctxt : #Protocol_client_context.full) state {hash; chain_id; level; protocol; next_protocol; _} = - if Protocol_hash.(protocol <> next_protocol) then + if Tezos_crypto.Protocol_hash.(protocol <> next_protocol) then Events.(emit protocol_change_detected) () >>= fun () -> return_unit else Events.(emit accuser_saw_block) (level, hash) >>= fun () -> diff --git a/src/proto_015_PtLimaPt/lib_delegate/client_daemon.ml b/src/proto_015_PtLimaPt/lib_delegate/client_daemon.ml index ba2cfdac03b3..836c95f1ad9a 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/client_daemon.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/client_daemon.ml @@ -91,7 +91,7 @@ module Baker = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> let canceler = Lwt_canceler.create () in @@ -121,7 +121,7 @@ module Accuser = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash >>= fun () -> Client_baking_blocks.monitor_valid_blocks @@ -159,7 +159,7 @@ module VDF = struct Tezos_version.Version.pp Tezos_version.Current_git_info.version Tezos_version.Current_git_info.abbreviated_commit_hash - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short Protocol.hash in let* chain_id = Shell_services.Chain.chain_id cctxt ~chain () in diff --git a/src/proto_015_PtLimaPt/lib_delegate/delegate_events.ml b/src/proto_015_PtLimaPt/lib_delegate/delegate_events.ml index 20f5d091dd9c..ca4361b2dc96 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/delegate_events.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/delegate_events.ml @@ -50,8 +50,8 @@ module Denunciator = struct ~level ~name:"double_endorsement_detected" ~msg:"double endorsement detected" - ("existing_endorsement", Operation_hash.encoding) - ("new_endorsement", Operation_hash.encoding) + ("existing_endorsement", Tezos_crypto.Operation_hash.encoding) + ("new_endorsement", Tezos_crypto.Operation_hash.encoding) let double_endorsement_denounced = declare_2 @@ -59,7 +59,7 @@ module Denunciator = struct ~level ~name:"double_endorsement_denounced" ~msg:"double endorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -69,8 +69,8 @@ module Denunciator = struct ~level ~name:"double_preendorsement_detected" ~msg:"double preendorsement detected" - ("existing_preendorsement", Operation_hash.encoding) - ("new_preendorsement", Operation_hash.encoding) + ("existing_preendorsement", Tezos_crypto.Operation_hash.encoding) + ("new_preendorsement", Tezos_crypto.Operation_hash.encoding) let double_preendorsement_denounced = declare_2 @@ -78,7 +78,7 @@ module Denunciator = struct ~level ~name:"double_preendorsement_denounced" ~msg:"double preendorsement evidence injected: {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -88,7 +88,7 @@ module Denunciator = struct ~level:Error ~name:"inconsistent_endorsement" ~msg:"inconsistent endorsement found {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) let unexpected_pruned_block = declare_1 @@ -96,7 +96,7 @@ module Denunciator = struct ~level:Error ~name:"unexpected_pruned_block" ~msg:"unexpected pruned block: {hash}" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let double_baking_but_not = declare_0 @@ -120,7 +120,7 @@ module Denunciator = struct ~level ~name:"double_baking_denounced" ~msg:"double baking evidence injected {hash}" - ("hash", Operation_hash.encoding) + ("hash", Tezos_crypto.Operation_hash.encoding) ~pp2:pp_ignore ("bytes", Data_encoding.bytes) @@ -139,7 +139,7 @@ module Denunciator = struct ~name:"accuser_saw_block" ~msg:"block level: {level}" ("level", Alpha_context.Raw_level.encoding) - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let fetch_operations_error = declare_1 @@ -147,8 +147,8 @@ module Denunciator = struct ~level:Error ~name:"fetch_operations_error" ~msg:"error while fetching operations of block {hash}" - ("hash", Block_hash.encoding) - ~pp1:Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp let accuser_processed_block = declare_1 @@ -156,7 +156,7 @@ module Denunciator = struct ~level ~name:"accuser_processed_block" ~msg:"block {hash} registered" - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) let accuser_block_error = declare_2 @@ -165,7 +165,7 @@ module Denunciator = struct ~name:"accuser_block_error" ~msg:"error while processing block {hash} {errors}" ~pp2:pp_print_top_error_of_trace - ("hash", Block_hash.encoding) + ("hash", Tezos_crypto.Block_hash.encoding) ("errors", Error_monad.(TzTrace.encoding error_encoding)) end diff --git a/src/proto_015_PtLimaPt/lib_delegate/logging.ml b/src/proto_015_PtLimaPt/lib_delegate/logging.ml index ed9cb18c9db3..6756e73e07e6 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/logging.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/logging.ml @@ -147,9 +147,9 @@ let conflicting_endorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) let conflicting_preendorsements_tag = @@ -161,7 +161,7 @@ let conflicting_preendorsements_tag = fprintf ppf "%a / %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash a) - Operation_hash.pp + Tezos_crypto.Operation_hash.pp (Operation.hash b)) diff --git a/src/proto_015_PtLimaPt/lib_delegate/node_rpc.ml b/src/proto_015_PtLimaPt/lib_delegate/node_rpc.ml index badb4fc204d4..96749ae7c4de 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/node_rpc.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/node_rpc.ml @@ -70,7 +70,9 @@ let raw_info cctxt ~chain ~block_hash shell payload_hash payload_round >>= fun () -> let open Protocol_client_context in let block = `Hash (block_hash, 0) in - let is_in_protocol = Protocol_hash.(current_protocol = Protocol.hash) in + let is_in_protocol = + Tezos_crypto.Protocol_hash.(current_protocol = Protocol.hash) + in (if is_in_protocol then Alpha_block_services.Operations.operations cctxt ~chain ~block () >>=? fun operations -> @@ -121,7 +123,7 @@ let info cctxt ~chain ~block () = (* Fails if the block's protocol is not the current one *) Shell_services.Blocks.protocols cctxt ~chain ~block () >>=? fun {current_protocol; next_protocol} -> - (if Protocol_hash.(current_protocol <> Protocol.hash) then + (if Tezos_crypto.Protocol_hash.(current_protocol <> Protocol.hash) then Block_services.Header.shell_header cctxt ~chain ~block () >>=? fun shell -> Chain_services.Blocks.Header.raw_protocol_data cctxt ~chain ~block () >>=? fun protocol_data -> @@ -155,7 +157,7 @@ let info cctxt ~chain ~block () = (Chain_services.Blocks.live_blocks cctxt ~chain ~block () >>= function | Error _ -> (* The RPC might fail when a block's metadata is not available *) - Lwt.return Block_hash.Set.empty + Lwt.return Tezos_crypto.Block_hash.Set.empty | Ok live_blocks -> Lwt.return live_blocks) >>= fun live_blocks -> raw_info diff --git a/src/proto_015_PtLimaPt/lib_delegate/node_rpc.mli b/src/proto_015_PtLimaPt/lib_delegate/node_rpc.mli index 2dd0468ef6f1..55694e129b55 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/node_rpc.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/node_rpc.mli @@ -37,13 +37,13 @@ val inject_block : chain:Shell_services.chain -> Block_header.t -> Tezos_base.Operation.t list list -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t (** Preapply a block using the node validation mechanism.*) val preapply_block : #Protocol_client_context.full -> chain:Shell_services.chain -> - head:Block_hash.t -> + head:Tezos_crypto.Block_hash.t -> timestamp:Time.Protocol.t -> protocol_data:Protocol.block_header_data -> packed_operation list list -> @@ -58,7 +58,7 @@ val proposal : #Tezos_rpc.Context.simple -> ?cache:Baking_state.block_info Baking_cache.Block_cache.t -> chain:Shell_services.chain -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Baking_state.proposal tzresult Lwt.t (** Monitor proposals from the node.*) diff --git a/src/proto_015_PtLimaPt/lib_delegate/operation_pool.ml b/src/proto_015_PtLimaPt/lib_delegate/operation_pool.ml index 7e0a7612054e..16ec9eda7cdb 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/operation_pool.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/operation_pool.ml @@ -41,7 +41,7 @@ let compare_op op1 op2 = (* FIXME some operations (e.g. tx_rollup_rejection) pack functional values which could raise an exception. In this specific case, we default to comparing their hashes. *) - Operation_hash.compare + Tezos_crypto.Operation_hash.compare (Alpha_context.Operation.hash_packed op1) (Alpha_context.Operation.hash_packed op2) diff --git a/src/proto_015_PtLimaPt/lib_delegate/operation_selection.ml b/src/proto_015_PtLimaPt/lib_delegate/operation_selection.ml index a658661df026..acbe2bbcf5de 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/operation_selection.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/operation_selection.ml @@ -57,7 +57,9 @@ module PrioritizedManagerSet = Set.Make (struct let compare {source; counter; weight; op; _} {source = source'; counter = counter'; weight = weight'; op = op'; _} = (* Be careful with the [compare] *) - let cmp_src = Signature.Public_key_hash.compare source source' in + let cmp_src = + Tezos_crypto.Signature.Public_key_hash.compare source source' + in if cmp_src = 0 then (* we want the smallest counter first *) let c = Z.compare counter counter' in @@ -163,7 +165,7 @@ type simulation_result = { validation_result : Tezos_protocol_environment.validation_result; block_header_metadata : block_header_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } let validate_operation inc op = @@ -248,10 +250,11 @@ let filter_operations_with_simulation initial_inc fees_config >>= fun (inc, managers) -> let operations = [consensus; votes; anonymous; managers] in let operations_hash = - Operation_list_list_hash.compute + Tezos_crypto.Operation_list_list_hash.compute (List.map (fun sl -> - Operation_list_hash.compute (List.map Operation.hash_packed sl)) + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed sl)) operations) in let inc = {inc with header = {inc.header with operations_hash}} in diff --git a/src/proto_015_PtLimaPt/lib_delegate/operation_selection.mli b/src/proto_015_PtLimaPt/lib_delegate/operation_selection.mli index 78caab5c158c..3ab72a91347c 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/operation_selection.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/operation_selection.mli @@ -31,7 +31,7 @@ type simulation_result = { validation_result : validation_result; block_header_metadata : Apply_results.block_metadata; operations : packed_operation list list; - operations_hash : Operation_list_list_hash.t; + operations_hash : Tezos_crypto.Operation_list_list_hash.t; } val filter_operations_with_simulation : diff --git a/src/proto_015_PtLimaPt/lib_delegate/operation_worker.ml b/src/proto_015_PtLimaPt/lib_delegate/operation_worker.ml index 66cec5723476..5589f585649f 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/operation_worker.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/operation_worker.ml @@ -145,7 +145,7 @@ module Events = struct end type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } @@ -158,7 +158,7 @@ let candidate_encoding = (fun (hash, round_watched, payload_hash_watched) -> {hash; round_watched; payload_hash_watched}) (obj3 - (req "hash" Block_hash.encoding) + (req "hash" Tezos_crypto.Block_hash.encoding) (req "round_watched" Round.encoding) (req "payload_hash_watched" Block_payload_hash.encoding)) @@ -539,7 +539,8 @@ let retrieve_pending_operations cctxt state = state.operation_pool (List.rev_map (fun (_, (op, _)) -> op) - (Operation_hash.Map.bindings pending_mempool.branch_delayed)) ; + (Tezos_crypto.Operation_hash.Map.bindings + pending_mempool.branch_delayed)) ; return_unit let get_current_operations state = state.operation_pool diff --git a/src/proto_015_PtLimaPt/lib_delegate/operation_worker.mli b/src/proto_015_PtLimaPt/lib_delegate/operation_worker.mli index eecbc990f2d1..ab66270bfd91 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/operation_worker.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/operation_worker.mli @@ -34,7 +34,7 @@ open Alpha_context type t type candidate = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; round_watched : Round.t; payload_hash_watched : Block_payload_hash.t; } diff --git a/src/proto_015_PtLimaPt/lib_delegate/state_transitions.ml b/src/proto_015_PtLimaPt/lib_delegate/state_transitions.ml index 6e8dd27e6284..71c79251fe67 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/state_transitions.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/state_transitions.ml @@ -47,8 +47,9 @@ let is_acceptable_proposal_for_current_level state let previous_proposal = state.level_state.latest_proposal in if Round.(proposal.block.round = previous_proposal.block.round) - && Block_hash.(proposal.block.hash <> previous_proposal.block.hash) - && Block_hash.( + && Tezos_crypto.Block_hash.( + proposal.block.hash <> previous_proposal.block.hash) + && Tezos_crypto.Block_hash.( proposal.predecessor.hash = previous_proposal.predecessor.hash) then (* An existing proposal was found at the same round: the @@ -117,7 +118,9 @@ let may_update_proposal state (proposal : proposal) = else Lwt.return state let preendorse state proposal = - if Protocol_hash.(proposal.block.protocol <> proposal.block.next_protocol) + if + Tezos_crypto.Protocol_hash.( + proposal.block.protocol <> proposal.block.next_protocol) then (* We do not preendorse the first transition block *) let new_round_state = {state.round_state with current_phase = Idle} in @@ -200,7 +203,7 @@ let rec handle_new_proposal state (new_proposal : proposal) = let's check if it's a valid one for us. *) let current_proposal = state.level_state.latest_proposal in if - Block_hash.( + Tezos_crypto.Block_hash.( current_proposal.predecessor.hash <> new_proposal.predecessor.hash) then Events.( @@ -534,7 +537,8 @@ let end_of_round state current_round = do_nothing new_state | Some (delegate, _) -> let last_proposal = state.level_state.latest_proposal.block in - if Protocol_hash.(last_proposal.protocol <> Protocol.hash) then + if Tezos_crypto.Protocol_hash.(last_proposal.protocol <> Protocol.hash) + then (* Do not inject a block for the previous protocol! (Let the baker of the previous protocol do it.) *) do_nothing new_state @@ -606,7 +610,9 @@ let make_endorse_action state proposal = let prequorum_reached_when_awaiting_preendorsements state candidate preendorsements = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit @@ -646,7 +652,9 @@ let prequorum_reached_when_awaiting_preendorsements state candidate let quorum_reached_when_waiting_endorsements state candidate endorsement_qc = let latest_proposal = state.level_state.latest_proposal in - if Block_hash.(candidate.Operation_worker.hash <> latest_proposal.block.hash) + if + Tezos_crypto.Block_hash.( + candidate.Operation_worker.hash <> latest_proposal.block.hash) then Events.( emit diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_client_context.ml b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_client_context.ml index ededa688a755..cc090580cdb0 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_client_context.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_client_context.ml @@ -46,8 +46,8 @@ let log _channel msg = print_endline msg ; Lwt.return_unit -class faked_ctxt (hooks : Faked_services.hooks) (chain_id : Chain_id.t) : - Tezos_rpc.Context.generic = +class faked_ctxt (hooks : Faked_services.hooks) + (chain_id : Tezos_crypto.Chain_id.t) : Tezos_rpc.Context.generic = let local_ctxt = let module Services = Faked_services.Make ((val hooks)) in Tezos_mockup_proxy.RPC_client.local_ctxt (Services.directory chain_id) diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_services.ml b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_services.ml index 907d280256fc..ee21b96b07c2 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_services.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/faked_services.ml @@ -10,7 +10,7 @@ module type Mocked_services_hooks = sig (** The baker and endorser rely on this stream to be notified of new blocks. *) val monitor_heads : - unit -> (Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream + unit -> (Tezos_crypto.Block_hash.t * Block_header.t) Tezos_rpc.Answer.stream (** Returns current and next protocol for a block. *) val protocols : @@ -30,14 +30,15 @@ module type Mocked_services_hooks = sig [Tezos_shell_services.Injection_services.S.block], after checking that the block header can be deserialized. *) val inject_block : - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t (** [inject_operation] is used by the endorser (or the client) to inject operations, including endorsements. *) - val inject_operation : Operation.t -> Operation_hash.t tzresult Lwt.t + val inject_operation : + Operation.t -> Tezos_crypto.Operation_hash.t tzresult Lwt.t (** [pending_operations] returns the current contents of the mempool. It is used by the baker to fetch operations to potentially include in the @@ -54,7 +55,9 @@ module type Mocked_services_hooks = sig branch_delayed:bool -> branch_refused:bool -> refused:bool -> - ((Operation_hash.t * Mockup.M.Protocol.operation) * error trace option) list + ((Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) + * error trace option) + list Tezos_rpc.Answer.stream (** Lists block hashes from the chain, up to the last checkpoint, sorted @@ -62,15 +65,16 @@ module type Mocked_services_hooks = sig chain. Optional arguments allow to return the list of predecessors of a given block or of a set of blocks. *) val list_blocks : - heads:Block_hash.t list -> + heads:Tezos_crypto.Block_hash.t list -> length:int option -> min_date:Time.Protocol.t option -> - Block_hash.t list list tzresult Lwt.t + Tezos_crypto.Block_hash.t list list tzresult Lwt.t (** List the ancestors of the given block which, if referred to as the branch in an operation header, are recent enough for that operation to be included in the current block. *) - val live_blocks : Block_services.block -> Block_hash.Set.t tzresult Lwt.t + val live_blocks : + Block_services.block -> Tezos_crypto.Block_hash.Set.t tzresult Lwt.t (** [rpc_context_callback] is used in the implementations of several RPCs (see local_services.ml). It should correspond to the @@ -87,7 +91,7 @@ module type Mocked_services_hooks = sig to all nodes. *) val broadcast_block : ?dests:int list -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> Block_header.t -> Operation.t trace trace -> unit tzresult Lwt.t @@ -102,7 +106,8 @@ module type Mocked_services_hooks = sig simulated node is already bootstrapped, returns the current head immediately. *) val monitor_bootstrapped : - unit -> (Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream + unit -> + (Tezos_crypto.Block_hash.t * Time.Protocol.t) Tezos_rpc.Answer.stream end type hooks = (module Mocked_services_hooks) @@ -183,7 +188,7 @@ module Make (Hooks : Mocked_services_hooks) = struct match Block_header.of_bytes bytes with | None -> failwith "faked_services.inject_block: can't deserialize" | Some block_header -> - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in Hooks.inject_block block_hash block_header operations >>=? fun () -> return block_hash) @@ -202,7 +207,7 @@ module Make (Hooks : Mocked_services_hooks) = struct Broadcast_services.S.block (fun () dests (block_header, operations) -> let bytes = Block_header.to_bytes block_header in - let block_hash = Block_hash.hash_bytes [bytes] in + let block_hash = Tezos_crypto.Block_hash.hash_bytes [bytes] in let dests = match dests#dests with [] -> None | dests -> Some dests in Hooks.broadcast_block ?dests block_hash block_header operations) diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.ml index c242225bd69c..e6cad8f09673 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -35,8 +35,10 @@ type chain = block list (** As new blocks and operations are received they are pushed to an Lwt_pipe wrapped into this type. *) type broadcast = - | Broadcast_block of Block_hash.t * Block_header.t * Operation.t list list - | Broadcast_op of Operation_hash.t * Alpha_context.packed_operation + | Broadcast_block of + Tezos_crypto.Block_hash.t * Block_header.t * Operation.t list list + | Broadcast_op of + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation (** The state of a mockup node. *) type state = { @@ -46,29 +48,33 @@ type state = { live_depth : int; (** How many blocks (counting from the head into the past) are considered live? *) mutable chain : chain; (** The chain as seen by this fake "node". *) - mutable mempool : (Operation_hash.t * Mockup.M.Protocol.operation) list; + mutable mempool : + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list; (** Mempool of this fake "node". *) - chain_table : chain Block_hash.Table.t; + chain_table : chain Tezos_crypto.Block_hash.Table.t; (** The chain table of this fake "node". It maps from block hashes to blocks. *) - global_chain_table : block Block_hash.Table.t; + global_chain_table : block Tezos_crypto.Block_hash.Table.t; (** The global chain table that allows us to look up blocks that may be missing in [chain_table], i.e. not known to this particular node. This 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 : Tezos_protocol_environment.rpc_context Context_hash.Table.t; + ctxt_table : + Tezos_protocol_environment.rpc_context Tezos_crypto.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 : + (Tezos_crypto.Block_hash.t * Block_header.t) Lwt_pipe.Unbounded.t; (** [heads_pipe] is used to implement the [monitor_heads] RPC. *) operations_pipe : - (Operation_hash.t * Mockup.M.Protocol.operation) option Lwt_pipe.Unbounded.t; + (Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) option + Lwt_pipe.Unbounded.t; (** [operations_pipe] is used to implement the [operations_pipe] RPC. *) mutable streaming_operations : bool; (** A helper flag used to implement the monitor operations RPC. *) broadcast_pipes : broadcast Lwt_pipe.Unbounded.t list; (** Broadcast pipes per node. *) - genesis_block_true_hash : Block_hash.t; + genesis_block_true_hash : Tezos_crypto.Block_hash.t; (** True hash of the genesis block as calculated by the [Block_header.hash] function. *) @@ -76,13 +82,13 @@ type state = { let accounts = Mockup.Protocol_parameters.default_value.bootstrap_accounts -let chain_id = Chain_id.of_string_exn "main" +let chain_id = Tezos_crypto.Chain_id.of_string_exn "main" let genesis_block_hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" -let genesis_predecessor_block_hash = Block_hash.zero +let genesis_predecessor_block_hash = Tezos_crypto.Block_hash.zero type propagation = Block | Pass | Delay of float @@ -92,34 +98,40 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -128,7 +140,7 @@ module type Hooks = sig level:int32 -> round:int32 -> chain:chain -> unit tzresult Lwt.t val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t val stop_on_event : Baking_state.event -> bool @@ -149,9 +161,12 @@ let locate_blocks (state : state) block list tzresult Lwt.t = match block with | `Hash (hash, rel) -> ( - match Block_hash.Table.find state.chain_table hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table hash with | None -> - failwith "locate_blocks: can't find the block %a" Block_hash.pp hash + failwith + "locate_blocks: can't find the block %a" + Tezos_crypto.Block_hash.pp + hash | Some chain0 -> let _, chain = List.split_n rel chain0 in return chain) @@ -177,8 +192,8 @@ let live_blocks (state : state) block = (List.fold_left (fun set ({rpc_context; _} : block) -> 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) + Tezos_crypto.Block_hash.Set.add hash set) + (Tezos_crypto.Block_hash.Set.singleton state.genesis_block_true_hash) segment) (** Extract the round number from raw fitness. *) @@ -272,25 +287,27 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : match block with | `Hash (requested_hash, rel) -> Int.equal rel 0 - && Block_hash.equal requested_hash genesis_predecessor_block_hash + && Tezos_crypto.Block_hash.equal + requested_hash + genesis_predecessor_block_hash | _ -> false in (* It is important to tell the baker that the genesis block is not in - the alpha protocol (we use Protocol_hash.zero). This will make the + the alpha protocol (we use Tezos_crypto.Protocol_hash.zero). This will make the baker not try to propose alternatives to that block and just accept - it as final in that Protocol_hash.zero protocol. The same for - predecessor of genesis, it should be in Protocol_hash.zero. *) + it as final in that Tezos_crypto.Protocol_hash.zero protocol. The same for + predecessor of genesis, it should be in Tezos_crypto.Protocol_hash.zero. *) return Tezos_shell_services.Block_services. { current_protocol = (if - Block_hash.equal hash genesis_block_hash + Tezos_crypto.Block_hash.equal hash genesis_block_hash || is_predecessor_of_genesis - then Protocol_hash.zero + then Tezos_crypto.Protocol_hash.zero else Protocol.hash); next_protocol = - (if is_predecessor_of_genesis then Protocol_hash.zero + (if is_predecessor_of_genesis then Tezos_crypto.Protocol_hash.zero else Protocol.hash); } @@ -387,11 +404,11 @@ let make_mocked_services_hooks (state : state) (user_hooks : (module Hooks)) : Mockup.M.Block_services.Mempool. { applied = ops; - refused = Operation_hash.Map.empty; - outdated = Operation_hash.Map.empty; - branch_refused = Operation_hash.Map.empty; - branch_delayed = Operation_hash.Map.empty; - unprocessed = Operation_hash.Map.empty; + refused = Tezos_crypto.Operation_hash.Map.empty; + outdated = Tezos_crypto.Operation_hash.Map.empty; + branch_refused = Tezos_crypto.Operation_hash.Map.empty; + branch_delayed = Tezos_crypto.Operation_hash.Map.empty; + unprocessed = Tezos_crypto.Operation_hash.Map.empty; } let monitor_operations ~applied ~branch_delayed ~branch_refused ~refused = @@ -471,11 +488,12 @@ let clear_mempool state = (fun (_oph, (op : Mockup.M.Protocol.operation)) -> let included_in_head = List.mem - ~equal:Operation_hash.equal + ~equal:Tezos_crypto.Operation_hash.equal (Alpha_context.Operation.hash_packed op) included_ops_hashes in - Block_hash.Set.mem op.shell.branch live_set && not included_in_head) + Tezos_crypto.Block_hash.Set.mem op.shell.branch live_set + && not included_in_head) state.mempool in state.mempool <- mempool ; @@ -549,13 +567,17 @@ let rec process_block state block_hash (block_header : Block_header.t) let get_predecessor () = let predecessor_hash = block_header.Block_header.shell.predecessor in head state >>=? fun head -> - match Block_hash.Table.find state.chain_table predecessor_hash with + match + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash + with | None | Some [] -> ( (* Even if the predecessor is not known locally, it might be known by some node in the network. The code below "requests" information about the block by its hash. *) match - Block_hash.Table.find state.global_chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find + state.global_chain_table + predecessor_hash with | None -> failwith "get_predecessor: unknown predecessor block" | Some predecessor -> @@ -598,7 +620,7 @@ let rec process_block state block_hash (block_header : Block_header.t) then return predecessor else failwith "get_predecessor: the predecessor block is too old" in - match Block_hash.Table.find state.chain_table block_hash with + match Tezos_crypto.Block_hash.Table.find state.chain_table block_hash with | Some _ -> (* The block is already known. *) return_unit @@ -616,7 +638,7 @@ let rec process_block state block_hash (block_header : Block_header.t) (fun pass -> List.map (fun (Operation.{shell; proto} as op) -> - let hash : Operation_hash.t = Operation.hash op in + let hash : Tezos_crypto.Operation_hash.t = Operation.hash op in let protocol_data : Alpha_context.packed_protocol_data = Data_encoding.Binary.of_bytes_exn Protocol.operation_data_encoding @@ -643,13 +665,19 @@ let rec process_block state block_hash (block_header : Block_header.t) in let predecessor_hash = block_header.Block_header.shell.predecessor in let tail = - Block_hash.Table.find state.chain_table predecessor_hash + Tezos_crypto.Block_hash.Table.find state.chain_table predecessor_hash |> WithExceptions.Option.get ~loc:__LOC__ in let new_chain = new_block :: tail in - Block_hash.Table.replace state.chain_table block_hash new_chain ; - Block_hash.Table.replace state.global_chain_table block_hash new_block ; - Context_hash.Table.replace + Tezos_crypto.Block_hash.Table.replace + state.chain_table + block_hash + new_chain ; + Tezos_crypto.Block_hash.Table.replace + state.global_chain_table + block_hash + new_block ; + Tezos_crypto.Context_hash.Table.replace state.ctxt_table rpc_context.Tezos_protocol_environment.block_header.context rpc_context ; @@ -738,7 +766,7 @@ let create_fake_node_state ~i ~live_depth mempool = []; chain = chain0; chain_table = - Block_hash.Table.of_seq + Tezos_crypto.Block_hash.Table.of_seq (List.to_seq [ (rpc_context0.block_hash, chain0); @@ -747,7 +775,7 @@ let create_fake_node_state ~i ~live_depth ]); global_chain_table; ctxt_table = - Context_hash.Table.of_seq + Tezos_crypto.Context_hash.Table.of_seq (List.to_seq [ ( rpc_context0.Tezos_protocol_environment.block_header @@ -807,7 +835,7 @@ let baker_process ~(delegates : Baking_state.consensus_key list) ~base_dir { checkout_fun = (fun hash -> - Context_hash.Table.find state.ctxt_table hash + Tezos_crypto.Context_hash.Table.find state.ctxt_table hash |> Option.map (fun Tezos_protocol_environment.{context; _} -> context) |> Lwt.return); finalize_fun = Lwt.return; @@ -827,13 +855,13 @@ let baker_process ~(delegates : Baking_state.consensus_key list) ~base_dir Lwt.pick [listener_process (); baker_process ()] >>=? fun () -> User_hooks.check_chain_on_success ~chain:state.chain -let genesis_protocol_data (baker_sk : Signature.secret_key) - (predecessor_block_hash : Block_hash.t) +let genesis_protocol_data (baker_sk : Tezos_crypto.Signature.secret_key) + (predecessor_block_hash : Tezos_crypto.Block_hash.t) (block_header : Block_header.shell_header) : Bytes.t = let proof_of_work_nonce = Bytes.create Protocol.Alpha_context.Constants.proof_of_work_nonce_size in - let operation_list_hash = Operation_list_hash.compute [] in + let operation_list_hash = Tezos_crypto.Operation_list_hash.compute [] in let payload_hash = Protocol.Alpha_context.Block_payload.hash ~predecessor:predecessor_block_hash @@ -857,7 +885,7 @@ let genesis_protocol_data (baker_sk : Signature.secret_key) (block_header, contents) in let signature = - Signature.sign + Tezos_crypto.Signature.sign ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) baker_sk @@ -873,7 +901,7 @@ let deduce_baker_sk (Protocol.Alpha_context.Parameters.bootstrap_account * Tezos_mockup_commands.Mockup_wallet.bootstrap_secret) list) (total_accounts : int) (level : int) : - Signature.secret_key tzresult Lwt.t = + Tezos_crypto.Signature.secret_key tzresult Lwt.t = (match (total_accounts, level) with | _, 0 -> return 0 (* apparently this doesn't really matter *) | _ -> @@ -888,7 +916,8 @@ let deduce_baker_sk |> WithExceptions.Option.get ~loc:__LOC__ in let secret_key = - Signature.Secret_key.of_b58check_exn (Uri.path (secret.sk_uri :> Uri.t)) + Tezos_crypto.Signature.Secret_key.of_b58check_exn + (Uri.path (secret.sk_uri :> Uri.t)) in return secret_key @@ -1063,7 +1092,8 @@ type config = { round0 : int64; round1 : int64; timeout : int; - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; initial_seed : State_hash.t option; consensus_committee_size : int; consensus_threshold : int; @@ -1124,7 +1154,7 @@ let run ?(config = default_config) bakers_spec = | Error () -> failwith "impossible: negative length of the baker spec" | Ok xs -> return xs) >>=? fun broadcast_pipes -> - let global_chain_table = Block_hash.Table.create 10 in + let global_chain_table = Tezos_crypto.Block_hash.Table.create 10 in Tezos_mockup_commands.Mockup_wallet.default_bootstrap_accounts >>=? fun bootstrap_secrets -> let accounts_with_secrets = @@ -1199,7 +1229,7 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) (block_header.shell, protocol_data.contents) in if - Signature.check + Tezos_crypto.Signature.check ~watermark: Alpha_context.Block_header.(to_watermark (Block_header chain_id)) public_key @@ -1209,13 +1239,15 @@ let check_block_signature ~block_hash ~(block_header : Block_header.t) else failwith "unexpected signature for %a; tried with %a@." - Block_hash.pp + Tezos_crypto.Block_hash.pp block_hash - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp public_key type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t let mempool_count_ops ~mempool ~predicate = List.map_es (fun (op_hash, op) -> predicate op_hash op) mempool @@ -1234,7 +1266,7 @@ let mempool_has_op_ref ~mempool ~predicate ~var = if result then var := true ; return_unit -let op_is_signed_by ~public_key (op_hash : Operation_hash.t) +let op_is_signed_by ~public_key (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1246,14 +1278,18 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) Alpha_context.Operation.to_watermark (Endorsement chain_id) | Preendorsement _ -> Alpha_context.Operation.to_watermark (Preendorsement chain_id) - | _ -> Signature.Generic_operation) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> Tezos_crypto.Signature.Generic_operation) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) >>=? fun watermark -> match d.signature with | None -> failwith "did not find a signature for op %a@." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op_hash | Some signature -> let unsigned_operation_bytes = @@ -1262,13 +1298,13 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) (op.shell, Contents_list d.contents) in return - (Signature.check + (Tezos_crypto.Signature.check ~watermark public_key signature unsigned_operation_bytes)) -let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_preendorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1294,9 +1330,13 @@ let op_is_preendorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) -let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) +let op_is_endorsement ?level ?round (op_hash : Tezos_crypto.Operation_hash.t) (op : Alpha_context.packed_operation) = match op.protocol_data with | Operation_data d -> ( @@ -1322,7 +1362,11 @@ let op_is_endorsement ?level ?round (op_hash : Operation_hash.t) in return (right_level && right_round) | _ -> return false) - | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) + | _ -> + failwith + "unexpected contents in %a@." + Tezos_crypto.Operation_hash.pp + op_hash) let op_is_both f g op_hash op = f op_hash op >>=? fun f_result -> diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.mli b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.mli index 57d24764bc7c..42a13cae3af4 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/test/mockup_simulator/mockup_simulator.mli @@ -56,20 +56,25 @@ module type Hooks = sig val on_inject_block : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> operations:Operation.t list list -> protocol_data:Alpha_context.Block_header.protocol_data -> - (Block_hash.t * Block_header.t * Operation.t list list * propagation_vector) + (Tezos_crypto.Block_hash.t + * Block_header.t + * Operation.t list list + * propagation_vector) tzresult Lwt.t (** This function is called on injection of an operation. It is similar to [on_inject_block], which see. *) val on_inject_operation : - op_hash:Operation_hash.t -> + op_hash:Tezos_crypto.Operation_hash.t -> op:Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation * propagation_vector) + (Tezos_crypto.Operation_hash.t + * Alpha_context.packed_operation + * propagation_vector) tzresult Lwt.t @@ -77,22 +82,23 @@ module type Hooks = sig a "monitor heads" RPC call. Returning [None] here terminates the process for the baker. *) val on_new_head : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - (Block_hash.t * Block_header.t) option Lwt.t + (Tezos_crypto.Block_hash.t * Block_header.t) option Lwt.t (** This is called when a new operation is going to be sent as the response to a "monitor operations" RPC call. Returning [None] here indicates that the node has advanced to the next level. *) val on_new_operation : - Operation_hash.t * Alpha_context.packed_operation -> - (Operation_hash.t * Alpha_context.packed_operation) option Lwt.t + Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation -> + (Tezos_crypto.Operation_hash.t * Alpha_context.packed_operation) option + Lwt.t (** Check a block before processing it in the mockup. *) val check_block_before_processing : level:int32 -> round:int32 -> - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> protocol_data:Alpha_context.Block_header.protocol_data -> unit tzresult Lwt.t @@ -103,7 +109,7 @@ module type Hooks = sig (** Check operations in the mempool after injecting an operation. *) val check_mempool_after_processing : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> unit tzresult Lwt.t (** This hook is used to decide when the baker is supposed to shut down. @@ -138,7 +144,8 @@ type config = { (** Maximal duration of the test. If the test takes longer to terminate it'll be aborted with an error. *) - delegate_selection : (int32 * (int32 * Signature.public_key_hash) list) list; + delegate_selection : + (int32 * (int32 * Tezos_crypto.Signature.public_key_hash) list) list; (** Desired selection of delegates per level/round *) initial_seed : State_hash.t option; (** Optional initial seed for protocol (used to control delegate selection) *) @@ -170,51 +177,54 @@ val default_config : config to the final result. *) val run : ?config:config -> (int * (module Hooks)) list -> unit tzresult Lwt.t -val bootstrap1 : Signature.public_key +val bootstrap1 : Tezos_crypto.Signature.public_key -val bootstrap2 : Signature.public_key +val bootstrap2 : Tezos_crypto.Signature.public_key -val bootstrap3 : Signature.public_key +val bootstrap3 : Tezos_crypto.Signature.public_key -val bootstrap4 : Signature.public_key +val bootstrap4 : Tezos_crypto.Signature.public_key -val bootstrap5 : Signature.public_key +val bootstrap5 : Tezos_crypto.Signature.public_key (** Check if a block header is signed by a given delegate. *) val check_block_signature : - block_hash:Block_hash.t -> + block_hash:Tezos_crypto.Block_hash.t -> block_header:Block_header.t -> - public_key:Signature.public_key -> + public_key:Tezos_crypto.Signature.public_key -> unit tzresult Lwt.t (** A shortcut type for predicates on operations. *) type op_predicate = - Operation_hash.t -> Alpha_context.packed_operation -> bool tzresult Lwt.t + Tezos_crypto.Operation_hash.t -> + Alpha_context.packed_operation -> + bool tzresult Lwt.t (** Count the number of operations in the mempool that satisfy the given predicate. *) val mempool_count_ops : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> int tzresult Lwt.t (** Check if the mempool has at least one operation that satisfies the given predicate. *) val mempool_has_op : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> bool tzresult Lwt.t (** Similar to [mempool_has_op] but instead of returning a [bool] it sets the given [bool ref]. *) val mempool_has_op_ref : - mempool:(Operation_hash.t * Mockup.M.Protocol.operation) list -> + mempool:(Tezos_crypto.Operation_hash.t * Mockup.M.Protocol.operation) list -> predicate:op_predicate -> var:bool ref -> unit tzresult Lwt.t (** Check if an operation is signed by the given delegate. *) -val op_is_signed_by : public_key:Signature.public_key -> op_predicate +val op_is_signed_by : + public_key:Tezos_crypto.Signature.public_key -> op_predicate (** Check that an operation is a preendorsement. *) val op_is_preendorsement : ?level:int32 -> ?round:int32 -> op_predicate diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.ml b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.ml index ce3f8bba6380..fdc0a6dc5abb 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.ml @@ -26,7 +26,9 @@ open Protocol type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list module LevelRoundMap = Map.Make (struct type t = Level_repr.t * Round_repr.t @@ -103,8 +105,12 @@ let check ctxt ~selection = Delegate_sampler.baking_rights_owner ctxt level ~round >|= Environment.wrap_tzresult >>=? fun (ctxt, _, pk) -> - if not (Signature.Public_key_hash.equal delegate pk.delegate) then - raise Exit + if + not + (Tezos_crypto.Signature.Public_key_hash.equal + delegate + pk.delegate) + then raise Exit else return ctxt) selection ctxt diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.mli b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.mli index 7b6915d2cfd2..c13cc23edb60 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.mli +++ b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/lib/tenderbrute.mli @@ -29,7 +29,9 @@ open Protocol one can provide a public key hash that would be the proposer. All non- specified level and rounds are not constrained. *) type delegate_selection = - (Raw_level_repr.t * (Round_repr.t * Signature.public_key_hash) list) list + (Raw_level_repr.t + * (Round_repr.t * Tezos_crypto.Signature.public_key_hash) list) + list (** Brute-force an initial seed nonce for the desired delegate selection. When found, the seed nonce is returned as a byte sequence of size 32. If diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/tenderbrute_main.ml b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/tenderbrute_main.ml index f3558b1a1985..123db4e59248 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/tenderbrute_main.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/tenderbrute/tenderbrute_main.ml @@ -49,7 +49,7 @@ let delegate_encoding = case ~title:"Public key hash" (Tag 0) - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding (function `Pkh p -> Some p | _ -> None) (fun p -> `Pkh p); case diff --git a/src/proto_015_PtLimaPt/lib_delegate/test/test_scenario.ml b/src/proto_015_PtLimaPt/lib_delegate/test/test_scenario.ml index 7543a2b1ab28..f10b60904c24 100644 --- a/src/proto_015_PtLimaPt/lib_delegate/test/test_scenario.ml +++ b/src/proto_015_PtLimaPt/lib_delegate/test/test_scenario.ml @@ -1,14 +1,14 @@ open Mockup_simulator -let bootstrap1 = Signature.Public_key.hash bootstrap1 +let bootstrap1 = Tezos_crypto.Signature.Public_key.hash bootstrap1 -let bootstrap2 = Signature.Public_key.hash bootstrap2 +let bootstrap2 = Tezos_crypto.Signature.Public_key.hash bootstrap2 -let bootstrap3 = Signature.Public_key.hash bootstrap3 +let bootstrap3 = Tezos_crypto.Signature.Public_key.hash bootstrap3 -let bootstrap4 = Signature.Public_key.hash bootstrap4 +let bootstrap4 = Tezos_crypto.Signature.Public_key.hash bootstrap4 -let bootstrap5 = Signature.Public_key.hash bootstrap5 +let bootstrap5 = Tezos_crypto.Signature.Public_key.hash bootstrap5 let some_seed s = Some (Protocol.State_hash.of_b58check_exn s) diff --git a/src/proto_015_PtLimaPt/lib_injector/disk_persistence.ml b/src/proto_015_PtLimaPt/lib_injector/disk_persistence.ml index 20565456cb64..f82914fa5d9d 100644 --- a/src/proto_015_PtLimaPt/lib_injector/disk_persistence.ml +++ b/src/proto_015_PtLimaPt/lib_injector/disk_persistence.ml @@ -276,7 +276,7 @@ end module Make_queue (N : sig val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_015_PtLimaPt/lib_injector/disk_persistence.mli b/src/proto_015_PtLimaPt/lib_injector/disk_persistence.mli index 7412450d251c..6e37f06fe507 100644 --- a/src/proto_015_PtLimaPt/lib_injector/disk_persistence.mli +++ b/src/proto_015_PtLimaPt/lib_injector/disk_persistence.mli @@ -106,7 +106,7 @@ module Make_queue (N : sig to store the persistent information for this queue. *) val name : string end) -(K : S.HASH) (V : sig +(K : Tezos_crypto.S.HASH) (V : sig type t val encoding : t Data_encoding.t diff --git a/src/proto_015_PtLimaPt/lib_injector/dune b/src/proto_015_PtLimaPt/lib_injector/dune index 2793d310d2f6..dedd275bf0b0 100644 --- a/src/proto_015_PtLimaPt/lib_injector/dune +++ b/src/proto_015_PtLimaPt/lib_injector/dune @@ -25,7 +25,6 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_crypto -open Tezos_protocol_015_PtLimaPt -open Tezos_micheline -open Tezos_client_015_PtLimaPt diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_common.ml b/src/proto_015_PtLimaPt/lib_injector/injector_common.ml index 924c679032c9..b6177f871e7a 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_common.ml +++ b/src/proto_015_PtLimaPt/lib_injector/injector_common.ml @@ -27,8 +27,8 @@ open Protocol_client_context type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -76,7 +76,7 @@ let fetch_tezos_block ~find_in_cache (cctxt : #full) hash : i.e. calls {!fetch} for cache misses. *) error_with "Fetching Tezos block %a failed unexpectedly" - Block_hash.pp + Tezos_crypto.Block_hash.pp hash | None, Some errs -> Error errs | Some block, _ -> Ok block @@ -87,7 +87,7 @@ let tezos_reorg fetch_tezos_block ~old_head_hash ~new_head_hash = let open Alpha_block_services in let open Lwt_result_syntax in let rec loop old_chain new_chain old_head_hash new_head_hash = - if Block_hash.(old_head_hash = new_head_hash) then + if Tezos_crypto.Block_hash.(old_head_hash = new_head_hash) then return {old_chain = List.rev old_chain; new_chain = List.rev new_chain} else let* new_head = fetch_tezos_block new_head_hash in diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_common.mli b/src/proto_015_PtLimaPt/lib_injector/injector_common.mli index 4a1651ede2f7..6519834b301f 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_common.mli +++ b/src/proto_015_PtLimaPt/lib_injector/injector_common.mli @@ -28,8 +28,8 @@ open Protocol_client_context (** The type of signers for operations injected by the injector *) type signer = { alias : string; - pkh : Signature.public_key_hash; - pk : Signature.public_key; + pkh : Tezos_crypto.Signature.public_key_hash; + pk : Tezos_crypto.Signature.public_key; sk : Client_keys.sk_uri; } @@ -44,7 +44,9 @@ type 'block reorg = { (** Retrieve a signer from the client wallet. *) val get_signer : - #Client_context.wallet -> Signature.public_key_hash -> signer tzresult Lwt.t + #Client_context.wallet -> + Tezos_crypto.Signature.public_key_hash -> + signer tzresult Lwt.t val no_reorg : 'a reorg @@ -59,18 +61,18 @@ type block_info := Alpha_block_services.block_info {!Ringo_lwt.Sigs.CACHE_MAP_RESULT}. *) val fetch_tezos_block : find_in_cache: - (Block_hash.t -> - (Block_hash.t -> block_info option Lwt.t) -> + (Tezos_crypto.Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info option Lwt.t) -> block_info option Lwt.t) -> #full -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t (** [tezos_reorg fetch ~old_head_hash ~new_head_hash] computes the reorganization of L1 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) val tezos_reorg : - (Block_hash.t -> block_info tzresult Lwt.t) -> - old_head_hash:Block_hash.t -> - new_head_hash:Block_hash.t -> + (Tezos_crypto.Block_hash.t -> block_info tzresult Lwt.t) -> + old_head_hash:Tezos_crypto.Block_hash.t -> + new_head_hash:Tezos_crypto.Block_hash.t -> block_info reorg tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_errors.ml b/src/proto_015_PtLimaPt/lib_injector/injector_errors.ml index c6c9f590ef93..b2e5b98bebc3 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_errors.ml +++ b/src/proto_015_PtLimaPt/lib_injector/injector_errors.ml @@ -23,7 +23,7 @@ (* *) (*****************************************************************************) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t let () = register_error_kind @@ -35,10 +35,11 @@ let () = Format.fprintf ppf "No worker for source %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp s) `Permanent - Data_encoding.(obj1 (req "source" Signature.Public_key_hash.encoding)) + Data_encoding.( + obj1 (req "source" Tezos_crypto.Signature.Public_key_hash.encoding)) (function No_worker_for_source s -> Some s | _ -> None) (fun s -> No_worker_for_source s) diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_errors.mli b/src/proto_015_PtLimaPt/lib_injector/injector_errors.mli index e3e0f56666c9..1c39b4ffc53a 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_errors.mli +++ b/src/proto_015_PtLimaPt/lib_injector/injector_errors.mli @@ -25,7 +25,7 @@ (** Error when the injector has no worker for the source which must inject an operation. *) -type error += No_worker_for_source of Signature.Public_key_hash.t +type error += No_worker_for_source of Tezos_crypto.Signature.Public_key_hash.t (** Error when the injector has no worker for the tag of the operation to be injected. *) diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_events.ml b/src/proto_015_PtLimaPt/lib_injector/injector_events.ml index 71b9d45181b0..520fce71ea2f 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_events.ml +++ b/src/proto_015_PtLimaPt/lib_injector/injector_events.ml @@ -37,10 +37,10 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 @@ -50,11 +50,11 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -65,12 +65,12 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name ~msg:("[{signer}: {tags}] " ^ msg) ~level - ("signer", Signature.Public_key_hash.encoding) + ("signer", Tezos_crypto.Signature.Public_key_hash.encoding) ("tags", Tags.encoding) enc1 enc2 enc3 - ~pp1:Signature.Public_key_hash.pp_short + ~pp1:Tezos_crypto.Signature.Public_key_hash.pp_short ~pp2:Tags.pp ?pp3:pp1 ?pp4:pp2 @@ -113,7 +113,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"new_tezos_head" ~msg:"processing new Tezos head {head}" ~level:Debug - ("head", Block_hash.encoding) + ("head", Tezos_crypto.Block_hash.encoding) let injecting_pending = declare_1 @@ -169,7 +169,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~msg:"Injected {nb} operations in {oph}" ~level:Notice ("nb", Data_encoding.int31) - ("oph", Operation_hash.encoding) + ("oph", Tezos_crypto.Operation_hash.encoding) let add_pending = declare_1 @@ -184,7 +184,7 @@ module Make (Rollup : Injector_sigs.PARAMETERS) = struct ~name:"included" ~msg:"Included operations of {block} at level {level}: {operations}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) ("operations", Data_encoding.list L1_operation.Hash.encoding) ~pp3:pp_operations_hash_list diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_functor.ml b/src/proto_015_PtLimaPt/lib_injector/injector_functor.ml index a8cdf8742c90..b8129d3070a3 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_functor.ml +++ b/src/proto_015_PtLimaPt/lib_injector/injector_functor.ml @@ -73,7 +73,7 @@ module Make (Rollup : PARAMETERS) = struct node. *) type injected_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) } @@ -93,20 +93,20 @@ module Make (Rollup : PARAMETERS) = struct let open Data_encoding in conv (fun {op; oph} -> (oph, op)) (fun (oph, op) -> {op; oph}) @@ merge_objs - (obj1 (req "oph" Operation_hash.encoding)) + (obj1 (req "oph" Tezos_crypto.Operation_hash.encoding)) L1_operation.encoding end) module Injected_ophs = Disk_persistence.Make_table (struct - include Operation_hash.Table + include Tezos_crypto.Operation_hash.Table type value = L1_operation.Hash.t list let name = "injected_ophs" - let string_of_key = Operation_hash.to_b58check + let string_of_key = Tezos_crypto.Operation_hash.to_b58check - let key_of_string = Operation_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Operation_hash.of_b58check_opt let value_encoding = Data_encoding.list L1_operation.Hash.encoding end) @@ -126,10 +126,10 @@ module Make (Rollup : PARAMETERS) = struct block. *) type included_info = { op : L1_operation.t; (** The L1 manager operation. *) - oph : Operation_hash.t; + oph : Tezos_crypto.Operation_hash.t; (** The hash of the operation which contains [op] (this can be an L1 batch of several manager operations). *) - l1_block : Block_hash.t; + l1_block : Tezos_crypto.Block_hash.t; (** The hash of the L1 block in which the operation was included. *) l1_level : int32; (** The level of [l1_block]. *) } @@ -153,21 +153,21 @@ module Make (Rollup : PARAMETERS) = struct @@ merge_objs L1_operation.encoding (obj3 - (req "oph" Operation_hash.encoding) - (req "l1_block" Block_hash.encoding) + (req "oph" Tezos_crypto.Operation_hash.encoding) + (req "l1_block" Tezos_crypto.Block_hash.encoding) (req "l1_level" int32)) end) module Included_in_blocks = Disk_persistence.Make_table (struct - include Block_hash.Table + include Tezos_crypto.Block_hash.Table type value = int32 * L1_operation.Hash.t list let name = "included_in_blocks" - let string_of_key = Block_hash.to_b58check + let string_of_key = Tezos_crypto.Block_hash.to_b58check - let key_of_string = Block_hash.of_b58check_opt + let key_of_string = Tezos_crypto.Block_hash.of_b58check_opt let value_encoding = let open Data_encoding in @@ -543,7 +543,7 @@ module Make (Rollup : PARAMETERS) = struct let* signature = Client_keys.sign state.cctxt - ~watermark:Signature.Generic_operation + ~watermark:Tezos_crypto.Signature.Generic_operation state.signer.sk unsigned_op_bytes in @@ -659,11 +659,13 @@ module Make (Rollup : PARAMETERS) = struct in let signature = match state.signer.pkh with - | Signature.Ed25519 _ -> Signature.of_ed25519 Ed25519.zero - | Secp256k1 _ -> Signature.of_secp256k1 Secp256k1.zero - | P256 _ -> Signature.of_p256 P256.zero + | Tezos_crypto.Signature.Ed25519 _ -> + Tezos_crypto.Signature.of_ed25519 Tezos_crypto.Ed25519.zero + | Secp256k1 _ -> + Tezos_crypto.Signature.of_secp256k1 Tezos_crypto.Secp256k1.zero + | P256 _ -> Tezos_crypto.Signature.of_p256 Tezos_crypto.P256.zero in - let branch = Block_hash.zero in + let branch = Tezos_crypto.Block_hash.zero in let operation = { shell = {branch}; @@ -960,7 +962,9 @@ module Make (Rollup : PARAMETERS) = struct (fun acc (signer, strategy, tags) -> let tags = Tags.of_list tags in let strategy, tags = - match Signature.Public_key_hash.Map.find_opt signer acc with + match + Tezos_crypto.Signature.Public_key_hash.Map.find_opt signer acc + with | None -> (strategy, tags) | Some (other_strategy, other_tags) -> let strategy = @@ -974,11 +978,14 @@ module Make (Rollup : PARAMETERS) = struct in (strategy, Tags.union other_tags tags) in - Signature.Public_key_hash.Map.add signer (strategy, tags) acc) - Signature.Public_key_hash.Map.empty + Tezos_crypto.Signature.Public_key_hash.Map.add + signer + (strategy, tags) + acc) + Tezos_crypto.Signature.Public_key_hash.Map.empty signers in - Signature.Public_key_hash.Map.iter_es + Tezos_crypto.Signature.Public_key_hash.Map.iter_es (fun signer (strategy, tags) -> let+ worker = Worker.launch diff --git a/src/proto_015_PtLimaPt/lib_injector/injector_worker_types.ml b/src/proto_015_PtLimaPt/lib_injector/injector_worker_types.ml index fca7eed3f8ff..7f86e158a775 100644 --- a/src/proto_015_PtLimaPt/lib_injector/injector_worker_types.ml +++ b/src/proto_015_PtLimaPt/lib_injector/injector_worker_types.ml @@ -84,7 +84,7 @@ module Request = struct Format.fprintf ppf "switching to new Tezos head %a" - Block_hash.pp + Tezos_crypto.Block_hash.pp b.Alpha_block_services.hash ; if r.old_chain <> [] || r.new_chain <> [] then Format.fprintf @@ -98,11 +98,11 @@ end module Name = struct type t = public_key_hash - let encoding = Signature.Public_key_hash.encoding + let encoding = Tezos_crypto.Signature.Public_key_hash.encoding let base = ["tx_rollup_injector"] - let pp = Signature.Public_key_hash.pp_short + let pp = Tezos_crypto.Signature.Public_key_hash.pp_short - let equal = Signature.Public_key_hash.equal + let equal = Tezos_crypto.Signature.Public_key_hash.equal end diff --git a/src/proto_015_PtLimaPt/lib_injector/l1_operation.ml b/src/proto_015_PtLimaPt/lib_injector/l1_operation.ml index e82d6668f88d..aa0ae008f78f 100644 --- a/src/proto_015_PtLimaPt/lib_injector/l1_operation.ml +++ b/src/proto_015_PtLimaPt/lib_injector/l1_operation.ml @@ -150,7 +150,7 @@ module Manager_operation = struct ty pp_lazy_expr contents - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer in Format.fprintf @@ -188,8 +188,8 @@ module Manager_operation = struct end module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "manager_operation_hash" @@ -200,7 +200,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "mop" 53 type hash = Hash.t diff --git a/src/proto_015_PtLimaPt/lib_injector/l1_operation.mli b/src/proto_015_PtLimaPt/lib_injector/l1_operation.mli index 73f1886ed737..21b13fbf32ff 100644 --- a/src/proto_015_PtLimaPt/lib_injector/l1_operation.mli +++ b/src/proto_015_PtLimaPt/lib_injector/l1_operation.mli @@ -26,7 +26,7 @@ open Protocol.Alpha_context (** Hash with b58check encoding mop(53), for hashes of L1 manager operations *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for L1 operations hashes *) type hash = Hash.t diff --git a/src/proto_015_PtLimaPt/lib_parameters/default_parameters.ml b/src/proto_015_PtLimaPt/lib_parameters/default_parameters.ml index 884ed4c287a0..fd5a927f3a4a 100644 --- a/src/proto_015_PtLimaPt/lib_parameters/default_parameters.ml +++ b/src/proto_015_PtLimaPt/lib_parameters/default_parameters.ml @@ -370,8 +370,8 @@ let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let compute_accounts = List.map (fun s -> - let public_key = Signature.Public_key.of_b58check_exn s in - let public_key_hash = Signature.Public_key.hash public_key in + let public_key = Tezos_crypto.Signature.Public_key.of_b58check_exn s in + let public_key_hash = Tezos_crypto.Signature.Public_key.hash public_key in Parameters. { public_key_hash; diff --git a/src/proto_015_PtLimaPt/lib_parameters/default_parameters.mli b/src/proto_015_PtLimaPt/lib_parameters/default_parameters.mli index eff7da674972..f930bc38fd87 100644 --- a/src/proto_015_PtLimaPt/lib_parameters/default_parameters.mli +++ b/src/proto_015_PtLimaPt/lib_parameters/default_parameters.mli @@ -35,11 +35,11 @@ val constants_test : Constants.Parametric.t val test_commitments : Commitment.t list lazy_t val make_bootstrap_account : - Signature.public_key_hash - * Signature.public_key + Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key * Tez.t - * Signature.public_key_hash option - * Signature.public_key option -> + * Tezos_crypto.Signature.public_key_hash option + * Tezos_crypto.Signature.public_key option -> Parameters.bootstrap_account val parameters_of_constants : diff --git a/src/proto_015_PtLimaPt/lib_plugin/mempool.ml b/src/proto_015_PtLimaPt/lib_plugin/mempool.ml index 369082de7e34..066dbc16f8fa 100644 --- a/src/proto_015_PtLimaPt/lib_plugin/mempool.ml +++ b/src/proto_015_PtLimaPt/lib_plugin/mempool.ml @@ -190,7 +190,10 @@ type manager_op_info = { in [state] when appropriate. *) } -type manager_op_weight = {operation_hash : Operation_hash.t; weight : Q.t} +type manager_op_weight = { + operation_hash : Tezos_crypto.Operation_hash.t; + weight : Q.t; +} (** Build a {!manager_op_weight} from operation hash and {!manager_op_info}. *) let mk_op_weight oph (info : manager_op_info) = @@ -199,7 +202,7 @@ let mk_op_weight oph (info : manager_op_info) = let compare_manager_op_weight op1 op2 = let c = Q.compare op1.weight op2.weight in if c <> 0 then c - else Operation_hash.compare op1.operation_hash op2.operation_hash + else Tezos_crypto.Operation_hash.compare op1.operation_hash op2.operation_hash module ManagerOpWeightSet = Set.Make (struct type t = manager_op_weight @@ -224,10 +227,10 @@ type state = { (** Number of prechecked manager operations. Invariants: - [prechecked_manager_op_count - = Operation_hash.Map.cardinal prechecked_manager_ops + = Tezos_crypto.Operation_hash.Map.cardinal prechecked_manager_ops = ManagerOpWeightSet.cardinal prechecked_op_weights] - [prechecked_manager_op_count <= max_prechecked_manager_operations] *) - prechecked_manager_ops : manager_op_info Operation_hash.Map.t; + prechecked_manager_ops : manager_op_info Tezos_crypto.Operation_hash.Map.t; (** All prechecked manager operations. See {!manager_op_info}. *) prechecked_op_weights : ManagerOpWeightSet.t; (** The {!manager_op_weight} of all prechecked manager operations. *) @@ -242,7 +245,7 @@ let empty : state = { state_info = None; prechecked_manager_op_count = 0; - prechecked_manager_ops = Operation_hash.Map.empty; + prechecked_manager_ops = Tezos_crypto.Operation_hash.Map.empty; prechecked_op_weights = ManagerOpWeightSet.empty; min_prechecked_op_weight = None; } @@ -329,7 +332,7 @@ let () = (fun () -> Fees_too_low) type Environment.Error_monad.error += - | Manager_restriction of {oph : Operation_hash.t; fee : Tez.t} + | Manager_restriction of {oph : Tezos_crypto.Operation_hash.t; fee : Tez.t} let () = Environment.Error_monad.register_error_kind @@ -343,21 +346,21 @@ let () = "Only one manager operation per manager per block allowed (found %a \ with %atez fee. You may want to use --replace to provide adequate fee \ and replace it)." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Tez.pp fee) Data_encoding.( obj2 - (req "operation_hash" Operation_hash.encoding) + (req "operation_hash" Tezos_crypto.Operation_hash.encoding) (req "operation_fee" Tez.encoding)) (function Manager_restriction {oph; fee} -> Some (oph, fee) | _ -> None) (fun (oph, fee) -> Manager_restriction {oph; fee}) type Environment.Error_monad.error += | Manager_operation_replaced of { - old_hash : Operation_hash.t; - new_hash : Operation_hash.t; + old_hash : Tezos_crypto.Operation_hash.t; + new_hash : Tezos_crypto.Operation_hash.t; } let () = @@ -370,13 +373,13 @@ let () = Format.fprintf ppf "The manager operation %a has been replaced with %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp old_hash - Operation_hash.pp + Tezos_crypto.Operation_hash.pp new_hash) (Data_encoding.obj2 - (Data_encoding.req "old_hash" Operation_hash.encoding) - (Data_encoding.req "new_hash" Operation_hash.encoding)) + (Data_encoding.req "old_hash" Tezos_crypto.Operation_hash.encoding) + (Data_encoding.req "new_hash" Tezos_crypto.Operation_hash.encoding)) (function | Manager_operation_replaced {old_hash; new_hash} -> Some (old_hash, new_hash) @@ -911,7 +914,7 @@ let proto_validate_manager_operation validation_state oph ~nb_successful_prechecks (operation : 'a Kind.manager Alpha_context.operation) : ( [> `Success of validation_state - | `Conflict of Operation_hash.t * error_classification ], + | `Conflict of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -961,7 +964,8 @@ let validate_manager_operation_and_handle_conflicts config filter_state validation_state oph ~nb_successful_prechecks fee gas_limit (operation : 'manager_kind Kind.manager operation) : ( validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification], + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -998,7 +1002,7 @@ let validate_manager_operation_and_handle_conflicts config filter_state branch_delayed ring is bounded to 1000, so we may loose operations. We can probably do better. *) match - Operation_hash.Map.find + Tezos_crypto.Operation_hash.Map.find min_weight_oph filter_state.prechecked_manager_ops with @@ -1027,7 +1031,9 @@ let validate_manager_operation_and_handle_conflicts config filter_state from the same manager. We look at the fees and gas limits of both operations to decide whether to replace the old one. *) match - Operation_hash.Map.find old_oph filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.find + old_oph + filter_state.prechecked_manager_ops with | None -> (* This only occurs for a [Drain_delegate] operation: it has @@ -1079,13 +1085,17 @@ let validate_manager_operation_and_handle_conflicts config filter_state (** Remove a manager operation hash from the filter state. Do nothing if the operation was not in the state. *) let remove ~filter_state oph = - match Operation_hash.Map.find oph filter_state.prechecked_manager_ops with + match + Tezos_crypto.Operation_hash.Map.find oph filter_state.prechecked_manager_ops + with | None -> (* Not present in the filter_state: nothing to do. *) filter_state | Some info -> let prechecked_manager_ops = - Operation_hash.Map.remove oph filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.remove + oph + filter_state.prechecked_manager_ops in let prechecked_manager_op_count = filter_state.prechecked_manager_op_count - 1 @@ -1099,8 +1109,9 @@ let remove ~filter_state oph = match filter_state.min_prechecked_op_weight with | None -> None | Some min_op_weight -> - if Operation_hash.equal min_op_weight.operation_hash oph then - ManagerOpWeightSet.min_elt prechecked_op_weights + if + Tezos_crypto.Operation_hash.equal min_op_weight.operation_hash oph + then ManagerOpWeightSet.min_elt prechecked_op_weights else Some min_op_weight in { @@ -1119,15 +1130,18 @@ let add_manager_op filter_state oph info replacement = | `No_replace -> filter_state | `Replace (oph, _classification) -> remove ~filter_state oph in - if Operation_hash.Map.mem oph filter_state.prechecked_manager_ops then - (* Already present in the filter_state: nothing to do. *) + if Tezos_crypto.Operation_hash.Map.mem oph filter_state.prechecked_manager_ops + then (* Already present in the filter_state: nothing to do. *) filter_state else let prechecked_manager_op_count = filter_state.prechecked_manager_op_count + 1 in let prechecked_manager_ops = - Operation_hash.Map.add oph info filter_state.prechecked_manager_ops + Tezos_crypto.Operation_hash.Map.add + oph + info + filter_state.prechecked_manager_ops in let op_weight = mk_op_weight oph info in let prechecked_op_weights = @@ -1159,7 +1173,8 @@ let precheck_manager_result config filter_state validation_state oph : ( state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification], + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ], error_classification ) result Lwt.t = @@ -1198,7 +1213,8 @@ let precheck_manager config filter_state validation_state oph [> `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | error_classification ] Lwt.t = precheck_manager_result @@ -1253,13 +1269,14 @@ let precheck : config -> filter_state:state -> validation_state:validation_state -> - Operation_hash.t -> + Tezos_crypto.Operation_hash.t -> Main.operation -> nb_successful_prechecks:int -> [ `Passed_precheck of state * validation_state - * [`No_replace | `Replace of Operation_hash.t * error_classification] + * [ `No_replace + | `Replace of Tezos_crypto.Operation_hash.t * error_classification ] | `Undecided | error_classification ] Lwt.t = diff --git a/src/proto_015_PtLimaPt/lib_plugin/test/generators.ml b/src/proto_015_PtLimaPt/lib_plugin/test/generators.ml index 014defb7a366..64ef40d9afe3 100644 --- a/src/proto_015_PtLimaPt/lib_plugin/test/generators.ml +++ b/src/proto_015_PtLimaPt/lib_plugin/test/generators.ml @@ -28,26 +28,28 @@ module Mempool = Plugin.Mempool let string_gen = QCheck2.Gen.small_string ?gen:None let public_key_hash_gen : - (Signature.public_key_hash * Signature.public_key * Signature.secret_key) + (Tezos_crypto.Signature.public_key_hash + * Tezos_crypto.Signature.public_key + * Tezos_crypto.Signature.secret_key) QCheck2.Gen.t = let open QCheck2.Gen in let+ seed = string_size (32 -- 64) in let seed = Bytes.of_string seed in - Signature.generate_key ~seed () + Tezos_crypto.Signature.generate_key ~seed () (* TODO: https://gitlab.com/tezos/tezos/-/issues/2407 move this function to an helper file? *) -let operation_hash_gen : Operation_hash.t QCheck2.Gen.t = +let operation_hash_gen : Tezos_crypto.Operation_hash.t QCheck2.Gen.t = let open QCheck2.Gen in let+ s = QCheck2.Gen.string_size (return 32) in - Operation_hash.of_string_exn s + Tezos_crypto.Operation_hash.of_string_exn s let dummy_manager_op_info = let fee = Alpha_context.Tez.zero in let gas_limit = Alpha_context.Gas.Arith.zero in let manager_op = let open Alpha_context in - let source = Signature.Public_key_hash.zero in + let source = Tezos_crypto.Signature.Public_key_hash.zero in let counter = Z.zero in let storage_limit = Z.zero in let operation = Set_deposits_limit None in @@ -56,8 +58,10 @@ let dummy_manager_op_info = {source; fee; counter; operation; gas_limit; storage_limit} in let contents = Single contents in - let protocol_data = {contents; signature = Some Signature.zero} in - let branch = Block_hash.zero in + let protocol_data = + {contents; signature = Some Tezos_crypto.Signature.zero} + in + let branch = Tezos_crypto.Block_hash.zero in Mempool.Manager_op {shell = {branch}; protocol_data} in Mempool.{manager_op; fee; gas_limit; weight = Q.zero} @@ -73,7 +77,8 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = let+ ops = small_list oph_and_info_gen in List.fold_left (fun state (oph, info) -> - if Operation_hash.Map.mem oph state.prechecked_manager_ops then state + if Tezos_crypto.Operation_hash.Map.mem oph state.prechecked_manager_ops + then state else let prechecked_manager_op_count = state.prechecked_manager_op_count + 1 @@ -90,7 +95,10 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = state with prechecked_manager_op_count; prechecked_manager_ops = - Operation_hash.Map.add oph info state.prechecked_manager_ops; + Tezos_crypto.Operation_hash.Map.add + oph + info + state.prechecked_manager_ops; prechecked_op_weights = ManagerOpWeightSet.add op_weight state.prechecked_op_weights; min_prechecked_op_weight; @@ -102,19 +110,25 @@ let filter_state_gen : Plugin.Mempool.state QCheck2.Gen.t = even odds of belonging to the given filter_state or being fresh. *) let with_filter_state_operation_gen : Plugin.Mempool.state -> - (Operation_hash.t * Plugin.Mempool.manager_op_info) QCheck2.Gen.t = + (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info) + QCheck2.Gen.t = fun state -> let open QCheck2.Gen in let* use_fresh = bool in - if use_fresh || Operation_hash.Map.is_empty state.prechecked_manager_ops then - oph_and_info_gen - else oneofl (Operation_hash.Map.bindings state.prechecked_manager_ops) + if + use_fresh + || Tezos_crypto.Operation_hash.Map.is_empty state.prechecked_manager_ops + then oph_and_info_gen + else + oneofl + (Tezos_crypto.Operation_hash.Map.bindings state.prechecked_manager_ops) (** Generate both a filter_state, and a pair of operation hash and manager_op_info. The pair has even odds of belonging to the filter_state or being fresh. *) let filter_state_with_operation_gen : - (Plugin.Mempool.state * (Operation_hash.t * Plugin.Mempool.manager_op_info)) + (Plugin.Mempool.state + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info)) QCheck2.Gen.t = let open QCheck2.Gen in filter_state_gen >>= fun state -> @@ -125,8 +139,8 @@ let filter_state_with_operation_gen : to the filter_state or being fresh. *) let filter_state_with_two_operations_gen : (Plugin.Mempool.state - * (Operation_hash.t * Plugin.Mempool.manager_op_info) - * (Operation_hash.t * Plugin.Mempool.manager_op_info)) + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info) + * (Tezos_crypto.Operation_hash.t * Plugin.Mempool.manager_op_info)) QCheck2.Gen.t = let open QCheck2.Gen in let* filter_state = filter_state_gen in diff --git a/src/proto_015_PtLimaPt/lib_plugin/test/test_filter_state.ml b/src/proto_015_PtLimaPt/lib_plugin/test/test_filter_state.ml index 032e46ae902f..7f112195af83 100644 --- a/src/proto_015_PtLimaPt/lib_plugin/test/test_filter_state.ml +++ b/src/proto_015_PtLimaPt/lib_plugin/test/test_filter_state.ml @@ -46,13 +46,14 @@ let check_filter_state_invariants filter_state = filter_state) ~cond:(fun filter_state -> filter_state.prechecked_manager_op_count - = Operation_hash.Map.cardinal filter_state.prechecked_manager_ops + = Tezos_crypto.Operation_hash.Map.cardinal + filter_state.prechecked_manager_ops && filter_state.prechecked_manager_op_count = ManagerOpWeightSet.cardinal filter_state.prechecked_op_weights && ManagerOpWeightSet.for_all (fun {operation_hash; weight} -> match - Operation_hash.Map.find + Tezos_crypto.Operation_hash.Map.find operation_hash filter_state.prechecked_manager_ops with @@ -79,7 +80,7 @@ let test_add_manager_op = already present in [filter_state] or fresh. *) let replacement = if should_replace then ( - assume (not (Operation_hash.equal oph_to_replace oph)) ; + assume (not (Tezos_crypto.Operation_hash.equal oph_to_replace oph)) ; `Replace (oph_to_replace, ())) else `No_replace in @@ -90,11 +91,11 @@ let test_add_manager_op = Format.fprintf fmt "%a was not found in prechecked_manager_ops: %a" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph pp_prechecked_manager_ops set) - ~cond:(Operation_hash.Map.mem oph) + ~cond:(Tezos_crypto.Operation_hash.Map.mem oph) filter_state.prechecked_manager_ops () && @@ -104,11 +105,11 @@ let test_add_manager_op = Format.fprintf fmt "%a should have been removed from prechecked_manager_ops." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph_to_replace) ~cond:(fun () -> not - (Operation_hash.Map.mem + (Tezos_crypto.Operation_hash.Map.mem oph_to_replace filter_state.prechecked_manager_ops)) () @@ -131,7 +132,10 @@ let test_remove_present = -> (* Add a fresh operation [oph] to the state. *) assume - (not (Operation_hash.Map.mem oph initial_state.prechecked_manager_ops)) ; + (not + (Tezos_crypto.Operation_hash.Map.mem + oph + initial_state.prechecked_manager_ops)) ; let replacement = if should_replace then `Replace (oph_to_replace, ()) else `No_replace in @@ -147,11 +151,11 @@ let test_remove_present = Format.fprintf fmt "%a should have been removed from prechecked_manager_ops." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph) ~cond:(fun () -> not - (Operation_hash.Map.mem + (Tezos_crypto.Operation_hash.Map.mem oph filter_state.prechecked_manager_ops)) () @@ -179,7 +183,10 @@ let test_remove_unknown = (Gen.pair Generators.filter_state_gen Generators.operation_hash_gen) (fun (initial_state, oph) -> assume - (not (Operation_hash.Map.mem oph initial_state.prechecked_manager_ops)) ; + (not + (Tezos_crypto.Operation_hash.Map.mem + oph + initial_state.prechecked_manager_ops)) ; let filter_state = remove ~filter_state:initial_state oph in qcheck_eq ~pp:pp_state ~eq:eq_state initial_state filter_state) diff --git a/src/proto_015_PtLimaPt/lib_plugin/test/test_utils.ml b/src/proto_015_PtLimaPt/lib_plugin/test/test_utils.ml index 57402233a49e..0b92f1f4ca4c 100644 --- a/src/proto_015_PtLimaPt/lib_plugin/test/test_utils.ml +++ b/src/proto_015_PtLimaPt/lib_plugin/test/test_utils.ml @@ -44,7 +44,7 @@ let pp_prechecked_manager_ops fmt set = Format.fprintf ppf "(%a -> {fee: %a; gas: %a; weight: %a})" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp oph Alpha_context.Tez.pp op_info.fee @@ -52,13 +52,13 @@ let pp_prechecked_manager_ops fmt set = op_info.gas_limit Q.pp_print op_info.weight)) - (Operation_hash.Map.bindings set) + (Tezos_crypto.Operation_hash.Map.bindings set) let pp_manager_op_weight fmt weight = Format.fprintf fmt "{oph: %a; weight: %a}" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp weight.operation_hash Q.pp_print weight.weight @@ -95,7 +95,7 @@ let pp_state fmt state = state.min_prechecked_op_weight let eq_prechecked_manager_ops = - Operation_hash.Map.equal + Tezos_crypto.Operation_hash.Map.equal (fun {manager_op = _; fee = fee1; gas_limit = gas1; weight = w1} {manager_op = _; fee = fee2; gas_limit = gas2; weight = w2} @@ -103,7 +103,9 @@ let eq_prechecked_manager_ops = let eq_op_weight_opt = Option.equal (fun op_weight1 op_weight2 -> - Operation_hash.equal op_weight1.operation_hash op_weight2.operation_hash + Tezos_crypto.Operation_hash.equal + op_weight1.operation_hash + op_weight2.operation_hash && Q.equal op_weight1.weight op_weight2.weight) (* This function needs to be updated if the filter state is extended *) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.ml index a157f16435bb..17f6fe9696a2 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.ml @@ -27,43 +27,51 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -let known_accounts = Signature.Public_key_hash.Table.create 17 +let known_accounts = Tezos_crypto.Signature.Public_key_hash.Table.create 17 let random_seed ~rng_state = - Bytes.init Hacl.Ed25519.sk_size (fun _i -> + Bytes.init Tezos_crypto.Hacl.Ed25519.sk_size (fun _i -> Char.chr (Random.State.int rng_state 256)) let new_account ?seed () = - let pkh, pk, sk = Signature.generate_key ~algo:Ed25519 ?seed () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ?seed () + in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account ; account let add_account ({pkh; _} as account) = - Signature.Public_key_hash.Table.add known_accounts pkh account + Tezos_crypto.Signature.Public_key_hash.Table.add known_accounts pkh account let activator_account = let seed = random_seed ~rng_state:(Random.State.make [|0x1337533D|]) in new_account ~seed () let find pkh = - match Signature.Public_key_hash.Table.find known_accounts pkh with + match + Tezos_crypto.Signature.Public_key_hash.Table.find known_accounts pkh + with | Some k -> return k - | None -> failwith "Missing account: %a" Signature.Public_key_hash.pp pkh + | None -> + failwith + "Missing account: %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh let find_alternate pkh = let exception Found of t in try - Signature.Public_key_hash.Table.iter + Tezos_crypto.Signature.Public_key_hash.Table.iter (fun pkh' account -> - if not (Signature.Public_key_hash.equal pkh pkh') then + if not (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') then raise (Found account)) known_accounts ; raise Not_found @@ -78,8 +86,8 @@ let dummy_account = let default_initial_balance = Tez.of_mutez_exn 4_000_000_000_000L let generate_accounts ?rng_state ?(initial_balances = []) ?bootstrap_delegations - n : (t * Tez.t * Signature.Public_key_hash.t option) list = - Signature.Public_key_hash.Table.clear known_accounts ; + n : (t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list = + Tezos_crypto.Signature.Public_key_hash.Table.clear known_accounts ; let amount i = match List.nth_opt initial_balances i with | None -> default_initial_balance @@ -102,10 +110,16 @@ let generate_accounts ?rng_state ?(initial_balances = []) ?bootstrap_delegations List.map (fun i -> let pkh, pk, sk = - Signature.generate_key ~algo:Ed25519 ~seed:(random_seed ~rng_state) () + Tezos_crypto.Signature.generate_key + ~algo:Ed25519 + ~seed:(random_seed ~rng_state) + () in let account = {pkh; pk; sk} in - Signature.Public_key_hash.Table.add known_accounts pkh account ; + Tezos_crypto.Signature.Public_key_hash.Table.add + known_accounts + pkh + account ; (account, amount i, delegate_to pkh)) (0 -- (n - 1)) @@ -115,7 +129,9 @@ let commitment_secret = |> WithExceptions.Option.get ~loc:__LOC__ let new_commitment ?seed () = - let pkh, pk, sk = Signature.generate_key ?seed ~algo:Ed25519 () in + let pkh, pk, sk = + Tezos_crypto.Signature.generate_key ?seed ~algo:Ed25519 () + in let unactivated_account = {pkh; pk; sk} in let open Commitment in let pkh = match pkh with Ed25519 pkh -> pkh | _ -> assert false in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.mli b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.mli index 6d3aeb79ca41..4cb885e6d277 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.mli +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/account.mli @@ -27,14 +27,14 @@ open Protocol open Alpha_context type t = { - pkh : Signature.Public_key_hash.t; - pk : Signature.Public_key.t; - sk : Signature.Secret_key.t; + pkh : Tezos_crypto.Signature.Public_key_hash.t; + pk : Tezos_crypto.Signature.Public_key.t; + sk : Tezos_crypto.Signature.Secret_key.t; } type account = t -val known_accounts : t Signature.Public_key_hash.Table.t +val known_accounts : t Tezos_crypto.Signature.Public_key_hash.Table.t val activator_account : account @@ -44,9 +44,9 @@ val new_account : ?seed:Bytes.t -> unit -> account val add_account : t -> unit -val find : Signature.Public_key_hash.t -> t tzresult Lwt.t +val find : Tezos_crypto.Signature.Public_key_hash.t -> t tzresult Lwt.t -val find_alternate : Signature.Public_key_hash.t -> t +val find_alternate : Tezos_crypto.Signature.Public_key_hash.t -> t (** 4.000.000.000 tez *) val default_initial_balance : Tez.t @@ -60,9 +60,11 @@ val generate_accounts : ?rng_state:Random.State.t -> ?initial_balances:int64 list -> ?bootstrap_delegations: - (Signature.Public_key_hash.t * Signature.Public_key_hash.t) list -> + (Tezos_crypto.Signature.Public_key_hash.t + * Tezos_crypto.Signature.Public_key_hash.t) + list -> int -> - (t * Tez.t * Signature.Public_key_hash.t option) list + (t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list val commitment_secret : Blinded_public_key_hash.activation_code @@ -70,4 +72,4 @@ val new_commitment : ?seed:Bytes.t -> unit -> (account * Commitment.t) tzresult Lwt.t (** Fails if the contract is not an implicit one *) -val pkh_of_contract_exn : Contract.t -> Signature.Public_key_hash.t +val pkh_of_contract_exn : Contract.t -> Tezos_crypto.Signature.Public_key_hash.t diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/assert.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/assert.ml index 49b4e62d7998..02d5f8c7d0c0 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/assert.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/assert.ml @@ -160,32 +160,34 @@ let not_equal_tez ~loc (a : Alpha_context.Tez.t) (b : Alpha_context.Tez.t) = not_equal ~loc Tez.( = ) "Tez are equal" Tez.pp a b (* pkh *) -let equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in equal ~loc PKH.equal "Public key hashes aren't equal" PKH.pp a b -let not_equal_pkh ~loc (a : Signature.Public_key_hash.t) - (b : Signature.Public_key_hash.t) = - let module PKH = Signature.Public_key_hash in +let not_equal_pkh ~loc (a : Tezos_crypto.Signature.Public_key_hash.t) + (b : Tezos_crypto.Signature.Public_key_hash.t) = + let module PKH = Tezos_crypto.Signature.Public_key_hash in not_equal ~loc PKH.equal "Public key hashes are equal" PKH.pp a b (* protocol hash *) -let equal_protocol_hash ~loc (a : Protocol_hash.t) (b : Protocol_hash.t) = +let equal_protocol_hash ~loc (a : Tezos_crypto.Protocol_hash.t) + (b : Tezos_crypto.Protocol_hash.t) = equal ~loc - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Protocol hashes aren't equal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp a b -let not_equal_protocol_hash ~loc (a : Protocol_hash.t) (b : Protocol_hash.t) = +let not_equal_protocol_hash ~loc (a : Tezos_crypto.Protocol_hash.t) + (b : Tezos_crypto.Protocol_hash.t) = not_equal ~loc - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Protocol hashes are equal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp a b diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.ml index 78ef6d167556..4c54c10a347c 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.ml @@ -31,7 +31,7 @@ open Alpha_context (* This type collects a block and the context that results from its application *) type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; @@ -93,7 +93,11 @@ let get_next_baker_by_account pkh block = >>=? fun bakers -> (match List.hd bakers with | Some b -> return b - | None -> failwith "No slots found for %a" Signature.Public_key_hash.pp pkh) + | None -> + failwith + "No slots found for %a" + Tezos_crypto.Signature.Public_key_hash.pp + pkh) >>=? fun { Plugin.RPC.Baking_rights.delegate = pkh; consensus_key; @@ -122,7 +126,7 @@ let get_next_baker_excluding excludes block = (fun {Plugin.RPC.Baking_rights.consensus_key; _} -> not (List.mem - ~equal:Signature.Public_key_hash.equal + ~equal:Tezos_crypto.Signature.Public_key_hash.equal consensus_key excludes)) bakers @@ -181,7 +185,7 @@ module Forge = struct (* We don't care of the following values, only the shell validates them. *) proto_level = 0; validation_passes = 0; - context = Context_hash.zero; + context = Tezos_crypto.Context_hash.zero; } let set_seed_nonce_hash seed_nonce_hash @@ -199,8 +203,9 @@ module Forge = struct (shell, contents) in let signature = - Signature.sign - ~watermark:Block_header.(to_watermark (Block_header Chain_id.zero)) + Tezos_crypto.Signature.sign + ~watermark: + Block_header.(to_watermark (Block_header Tezos_crypto.Chain_id.zero)) signer_account.sk unsigned_bytes in @@ -242,7 +247,8 @@ module Forge = struct >|=? fun seed_nonce_hash -> let hashes = List.map Operation.hash_packed operations in let operations_hash = - Operation_list_list_hash.compute [Operation_list_hash.compute hashes] + Tezos_crypto.Operation_list_list_hash.compute + [Tezos_crypto.Operation_list_hash.compute hashes] in let shell = make_shell @@ -257,7 +263,9 @@ module Forge = struct List.concat (match List.tl operations with None -> [] | Some l -> l) in let hashes = List.map Operation.hash_packed non_consensus_operations in - let non_consensus_operations_hash = Operation_list_hash.compute hashes in + let non_consensus_operations_hash = + Tezos_crypto.Operation_list_hash.compute hashes + in let payload_round = match payload_round with None -> round | Some r -> r in @@ -399,13 +407,13 @@ let initial_alpha_context ?(commitments = []) constants ~typecheck ~level ~timestamp - Chain_id.zero + Tezos_crypto.Chain_id.zero ctxt >|= Environment.wrap_tzresult let genesis_with_parameters parameters = let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let fitness = @@ -421,7 +429,7 @@ let genesis_with_parameters parameters = ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in let contents = Forge.make_contents @@ -440,19 +448,23 @@ let genesis_with_parameters parameters = add empty ["version"] (Bytes.of_string "genesis") >>= fun ctxt -> add ctxt protocol_param_key proto_params) >>= fun ctxt -> - let chain_id = Chain_id.of_block_hash hash in + let chain_id = Tezos_crypto.Chain_id.of_block_hash hash in Main.init chain_id ctxt shell >|= Environment.wrap_tzresult >|=? fun {context; _} -> { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } let validate_initial_accounts (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) minimal_stake = if initial_accounts = [] then Stdlib.failwith "Must have one account with minimal_stake to bake" ; @@ -608,7 +620,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum >>=? fun () -> check_constants_consistency constants >>=? fun () -> let hash = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisCCCCCeZiLHU" in let level = Option.value ~default:0l level in @@ -625,7 +637,7 @@ let prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum ~predecessor:hash ~timestamp:Time.Protocol.epoch ~fitness - ~operations_hash:Operation_list_list_hash.zero + ~operations_hash:Tezos_crypto.Operation_list_list_hash.zero in validate_initial_accounts initial_accounts constants.minimal_stake (* Perhaps this could return a new type signifying its name *) @@ -642,7 +654,8 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum ?sc_rollup_max_number_of_messages_per_commitment_period ?dal_enable ?zk_rollup_enable ?hard_gas_limit_per_block ?nonce_revelation_threshold (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) = + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) + = prepare_initial_context_params ?consensus_threshold ?min_proposal_quorum @@ -669,7 +682,7 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum initial_context ?commitments ?bootstrap_contracts - (Chain_id.of_block_hash hash) + (Tezos_crypto.Chain_id.of_block_hash hash) constants shell initial_accounts @@ -683,14 +696,19 @@ let genesis ?commitments ?consensus_threshold ?min_proposal_quorum in { hash; - header = {shell; protocol_data = {contents; signature = Signature.zero}}; + header = + { + shell; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; + }; operations = []; context; } let alpha_context ?commitments ?min_proposal_quorum (initial_accounts : - (Account.t * Tez.t * Signature.Public_key_hash.t option) list) = + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list) + = prepare_initial_context_params ?min_proposal_quorum initial_accounts >>=? fun (constants, shell, _hash) -> initial_alpha_context ?commitments constants shell initial_accounts @@ -709,7 +727,7 @@ let get_application_vstate (pred : t) (operations : Protocol.operation trace) = let open Environment.Error_monad in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >|= Environment.wrap_tzresult @@ -731,7 +749,7 @@ let get_construction_vstate ?(policy = By_round 0) ?timestamp in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero mode ~predecessor:pred.header.shell >|= Environment.wrap_tzresult @@ -756,7 +774,7 @@ let apply_with_metadata ?(policy = By_round 0) ?(check_size = true) ~baking_mode | Application -> begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >|= Environment.wrap_tzresult diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.mli b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.mli index 768c698dc105..d272a1538baf 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.mli +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/block.mli @@ -29,7 +29,7 @@ open Protocol open Alpha_context type t = { - hash : Block_hash.t; + hash : Tezos_crypto.Block_hash.t; header : Block_header.t; operations : Operation.packed list; context : Tezos_protocol_environment.Context.t; (** Resulting context *) @@ -103,7 +103,7 @@ module Forge : sig (** Sets the baker that will sign the header to an arbitrary pkh *) val set_baker : public_key_hash -> - ?consensus_key:Signature.public_key_hash -> + ?consensus_key:Tezos_crypto.Signature.public_key_hash -> header -> header @@ -141,7 +141,7 @@ val genesis : ?zk_rollup_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> - (Account.t * Tez.tez * Signature.Public_key_hash.t option) list -> + (Account.t * Tez.tez * Tezos_crypto.Signature.Public_key_hash.t option) list -> block tzresult Lwt.t val genesis_with_parameters : Parameters.t -> block tzresult Lwt.t @@ -153,7 +153,7 @@ val genesis_with_parameters : Parameters.t -> block tzresult Lwt.t val alpha_context : ?commitments:Commitment.t list -> ?min_proposal_quorum:int32 -> - (Account.t * Tez.tez * Signature.Public_key_hash.t option) list -> + (Account.t * Tez.tez * Tezos_crypto.Signature.Public_key_hash.t option) list -> Alpha_context.t tzresult Lwt.t (** @@ -289,8 +289,10 @@ val prepare_initial_context_params : ?zk_rollup_enable:bool -> ?hard_gas_limit_per_block:Gas.Arith.integral -> ?nonce_revelation_threshold:int32 -> - (Account.t * Tez.t * Signature.Public_key_hash.t option) list -> - ( Constants.Parametric.t * Block_header.shell_header * Block_hash.t, + (Account.t * Tez.t * Tezos_crypto.Signature.Public_key_hash.t option) list -> + ( Constants.Parametric.t + * Block_header.shell_header + * Tezos_crypto.Block_hash.t, tztrace ) result Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.ml index bfcda92a7df6..1f7ae6753b44 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.ml @@ -136,7 +136,8 @@ let get_endorser_slot ctxt pkh = List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.(delegate = pkh) then Some slots + if Tezos_crypto.Signature.Public_key_hash.(delegate = pkh) then + Some slots else None) endorsers @@ -152,7 +153,7 @@ let get_endorsing_power_for_delegate ctxt ?levels pkh = let rec find_slots_for_delegate = function | [] -> return 0 | {Plugin.RPC.Validators.delegate; slots; _} :: t -> - if Signature.Public_key_hash.equal delegate pkh then + if Tezos_crypto.Signature.Public_key_hash.equal delegate pkh then return (List.length slots) else find_slots_for_delegate t in @@ -175,7 +176,8 @@ let get_baker ctxt ~round = let get_first_different_baker baker bakers = WithExceptions.Option.get ~loc:__LOC__ @@ List.find - (fun baker' -> Signature.Public_key_hash.( <> ) baker baker') + (fun baker' -> + Tezos_crypto.Signature.Public_key_hash.( <> ) baker baker') bakers let get_first_different_bakers ctxt = @@ -270,7 +272,7 @@ module Vote = struct type delegate_info = Alpha_context.Vote.delegate_info = { voting_power : Int64.t option; current_ballot : Alpha_context.Vote.ballot option; - current_proposals : Protocol_hash.t list; + current_proposals : Tezos_crypto.Protocol_hash.t list; remaining_proposals : int; } @@ -349,8 +351,9 @@ module Delegate = struct deactivated : bool; grace_period : Cycle.t; voting_info : Alpha_context.Vote.delegate_info; - active_consensus_key : Signature.Public_key_hash.t; - pending_consensus_keys : (Cycle.t * Signature.Public_key_hash.t) list; + active_consensus_key : Tezos_crypto.Signature.Public_key_hash.t; + pending_consensus_keys : + (Cycle.t * Tezos_crypto.Signature.Public_key_hash.t) list; } let info ctxt pkh = Delegate_services.info rpc_ctxt ctxt pkh @@ -606,7 +609,7 @@ let default_raw_context () = >>= fun context -> let typecheck ctxt script_repr = return ((script_repr, None), ctxt) in Init_storage.prepare_first_block - Chain_id.zero + Tezos_crypto.Chain_id.zero context ~level:0l ~timestamp:(Time.Protocol.of_seconds 1643125688L) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.mli b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.mli index c122c4a5d55e..04930bd2ed66 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.mli +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/context.mli @@ -30,7 +30,7 @@ open Environment type t = B of Block.t | I of Incremental.t -val branch : t -> Block_hash.t +val branch : t -> Tezos_crypto.Block_hash.t val get_level : t -> Raw_level.t tzresult @@ -112,7 +112,8 @@ module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t val get_ballot_list : - t -> (Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t + t -> + (Tezos_crypto.Signature.Public_key_hash.t * Vote.ballot) list tzresult Lwt.t val get_current_period : t -> Voting_period.info tzresult Lwt.t @@ -121,13 +122,14 @@ module Vote : sig val get_participation_ema : Block.t -> int32 tzresult Lwt.t val get_listings : - t -> (Signature.Public_key_hash.t * int64) list tzresult Lwt.t + t -> (Tezos_crypto.Signature.Public_key_hash.t * int64) list tzresult Lwt.t val get_proposals : t -> int64 Protocol_hash.Map.t tzresult Lwt.t - val get_current_proposal : t -> Protocol_hash.t option tzresult Lwt.t + val get_current_proposal : + t -> Tezos_crypto.Protocol_hash.t option tzresult Lwt.t - val get_protocol : Block.t -> Protocol_hash.t Lwt.t + val get_protocol : Block.t -> Tezos_crypto.Protocol_hash.t Lwt.t val set_participation_ema : Block.t -> int32 -> Block.t Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/contract_helpers.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/contract_helpers.ml index f7d8dd45bc64..f7d6c63dab2a 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/contract_helpers.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/contract_helpers.ml @@ -67,7 +67,7 @@ let fake_KT1 = let default_self = fake_KT1 -let default_payer = Signature.Public_key_hash.zero +let default_payer = Tezos_crypto.Signature.Public_key_hash.zero let default_source = Contract.Implicit default_payer @@ -79,7 +79,7 @@ let default_step_constants = self = default_self; amount = Tez.zero; balance = Tez.zero; - chain_id = Chain_id.zero; + chain_id = Tezos_crypto.Chain_id.zero; now = Script_timestamp.of_zint Z.zero; level = Script_int.zero_n; } diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/dummy_zk_rollup.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/dummy_zk_rollup.ml index 070d69de6c60..4e1eafefa0dc 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/dummy_zk_rollup.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/dummy_zk_rollup.ml @@ -201,8 +201,8 @@ module Types = struct conv (fun pkhu -> pkhu) (fun w -> w) - (encoding_to_scalar Signature.Public_key_hash.encoding) - (encoding_of_scalar Signature.Public_key_hash.encoding) + (encoding_to_scalar Tezos_crypto.Signature.Public_key_hash.encoding) + (encoding_of_scalar Tezos_crypto.Signature.Public_key_hash.encoding) scalar_encoding let amount_encoding ~safety = Bounded_e.encoding ~safety Bound.bound_amount @@ -445,7 +445,7 @@ end = struct {id; amount = Z.zero}); l1_dst = Data_encoding.Binary.of_bytes_exn - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding dummy_l1_dst; rollup_id = Data_encoding.Binary.of_bytes_exn diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/expr_common.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/expr_common.ml index 554bba47ce07..e6444892c600 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/expr_common.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/expr_common.ml @@ -78,7 +78,7 @@ let big_map_id ?(loc = 0) id = int ~loc @@ Big_map.Id.unparse_to_z id let timestamp_of_zint zint = Script_timestamp.of_zint zint let public_key_of_bytes_exn b = - Data_encoding.Binary.of_bytes_exn Signature.Public_key.encoding b + Data_encoding.Binary.of_bytes_exn Tezos_crypto.Signature.Public_key.encoding b let address_of_bytes_exn b = Data_encoding.Binary.of_bytes_exn Contract.encoding b diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/incremental.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/incremental.ml index da83665012c4..e9e10da350af 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/incremental.ml @@ -54,7 +54,7 @@ let rpc_context st = let fitness = (header st).shell.fitness in let result = Alpha_context.finalize (alpha_ctxt st) fitness in { - Environment.Updater.block_hash = Block_hash.zero; + Environment.Updater.block_hash = Tezos_crypto.Block_hash.zero; block_header = {st.header.shell with fitness = result.fitness}; context = result.context; } @@ -100,7 +100,7 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) Partial_construction {predecessor_hash = predecessor.hash; timestamp} else let block_header_data = - {Block_header.contents; signature = Signature.zero} + {Block_header.contents; signature = Tezos_crypto.Signature.zero} in Construction {predecessor_hash = predecessor.hash; timestamp; block_header_data} @@ -115,15 +115,15 @@ let begin_construction ?timestamp ?seed_nonce_hash ?(mempool_mode = false) fitness = predecessor.header.shell.fitness; timestamp; level = predecessor.header.shell.level; - context = Context_hash.zero; - operations_hash = Operation_list_list_hash.zero; + context = Tezos_crypto.Context_hash.zero; + operations_hash = Tezos_crypto.Operation_list_list_hash.zero; }; - protocol_data = {contents; signature = Signature.zero}; + protocol_data = {contents; signature = Tezos_crypto.Signature.zero}; } in begin_validation_and_application predecessor.context - Chain_id.zero + Tezos_crypto.Chain_id.zero mode ~predecessor:predecessor.header.shell >|= fun state -> @@ -240,8 +240,11 @@ let finalize_block st = let open Lwt_result_syntax in let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let shell_header = { @@ -256,8 +259,11 @@ let finalize_block st = let*? validation_result, _ = Environment.wrap_tzresult res in let operations = List.rev st.rev_operations in let operations_hash = - Operation_list_list_hash.compute - [Operation_list_hash.compute (List.map Operation.hash_packed operations)] + Tezos_crypto.Operation_list_list_hash.compute + [ + Tezos_crypto.Operation_list_hash.compute + (List.map Operation.hash_packed operations); + ] in let header = { diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/liquidity_baking_machine.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/liquidity_baking_machine.ml index 9f6efcb453da..723f26ae43c0 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/liquidity_baking_machine.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/liquidity_baking_machine.ml @@ -390,13 +390,13 @@ let total_xtz = 32_000_000_000_000L let tzbtc_admin_account : Account.t = { pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav"; sk = - Signature.Secret_key.of_b58check_exn + Tezos_crypto.Signature.Secret_key.of_b58check_exn "edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh"; } diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/lqt_fa12_repr.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/lqt_fa12_repr.ml index af27ec2e2e93..168bbb43dac6 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/lqt_fa12_repr.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/lqt_fa12_repr.ml @@ -135,7 +135,7 @@ module Storage = struct { tokens = Big_map.Id.parse_z Z.zero; allowances = Big_map.Id.parse_z Z.one; - admin = Contract.Implicit Signature.Public_key_hash.zero; + admin = Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero; totalSupply = Z.zero; } diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/nonce.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/nonce.ml index 695cdcdbbec9..23edb62e017f 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/nonce.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/nonce.ml @@ -22,7 +22,7 @@ let known_nonces = Table.create 17 let generate () = match Alpha_context.Nonce.of_bytes - @@ Rand.generate Alpha_context.Constants.nonce_length + @@ Tezos_crypto.Rand.generate Alpha_context.Constants.nonce_length with | Ok nonce -> let hash = Alpha_context.Nonce.hash nonce in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.ml index 8276637eaa4d..fac515505e1f 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.ml @@ -31,14 +31,15 @@ let pack_operation ctxt signature contents = Operation.pack ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) -let sign ?(watermark = Signature.Generic_operation) sk ctxt contents = +let sign ?(watermark = Tezos_crypto.Signature.Generic_operation) sk ctxt + contents = let branch = Context.branch ctxt in let unsigned = Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding ({branch}, Contents_list contents) in - let signature = Some (Signature.sign ~watermark sk unsigned) in + let signature = Some (Tezos_crypto.Signature.sign ~watermark sk unsigned) in ({shell = {branch}; protocol_data = {contents; signature}} : _ Operation.t) (** Generates the block payload hash based on the hash [pred_hash] of @@ -50,7 +51,9 @@ let mk_block_payload_hash pred_hash payload_round (b : Block.t) = List.concat (match List.tl ops with None -> [] | Some l -> l) in let hashes = List.map Operation.hash_packed non_consensus_operations in - let non_consensus_operations_hash = Operation_list_hash.compute hashes in + let non_consensus_operations_hash = + Tezos_crypto.Operation_list_hash.compute hashes + in Block_payload.hash ~predecessor:pred_hash payload_round @@ -85,7 +88,8 @@ let endorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Endorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Endorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -118,7 +122,8 @@ let preendorsement ?delegate ?slot ?level ?round ?block_payload_hash Account.find delegate_pkh >>=? fun delegate -> return (sign - ~watermark:Operation.(to_watermark (Preendorsement Chain_id.zero)) + ~watermark: + Operation.(to_watermark (Preendorsement Tezos_crypto.Chain_id.zero)) delegate.sk signing_context op) @@ -194,7 +199,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt assert ( List.for_all (fun {shell = {Tezos_base.Operation.branch = b; _}; _} -> - Block_hash.(branch = b)) + Tezos_crypto.Block_hash.(branch = b)) packed_operations) ; (* TODO? : check signatures consistency *) let unpacked_operations = @@ -223,7 +228,7 @@ let combine_operations ?public_key ?counter ?spurious_operation ~source ctxt let reveal_op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -292,7 +297,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter; operation; @@ -308,7 +313,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op_reveal = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee = Tez.zero; counter; operation = Reveal public_key; @@ -319,7 +324,7 @@ let manager_operation ?(force_reveal = false) ?counter ?(fee = Tez.zero) let op = Manager_operation { - source = Signature.Public_key.hash public_key; + source = Tezos_crypto.Signature.Public_key.hash public_key; fee; counter = Z.succ counter; operation; @@ -338,7 +343,7 @@ let revelation ?(fee = Tez.zero) ?(gas_limit = High) ?(storage_limit = Z.zero) let pkh = match forge_pkh with | Some pkh -> pkh - | None -> Signature.Public_key.hash public_key + | None -> Tezos_crypto.Signature.Public_key.hash public_key in resolve_gas_limit ctxt gas_limit >>=? fun gas_limit -> let source = Contract.Implicit pkh in @@ -505,14 +510,15 @@ let increase_paid_storage ?force_reveal ?counter ?fee ?gas_limit ?storage_limit Context.Contract.manager ctxt source >|=? fun account -> sign account.sk ctxt sop -let activation ctxt (pkh : Signature.Public_key_hash.t) activation_code = +let activation ctxt (pkh : Tezos_crypto.Signature.Public_key_hash.t) + activation_code = (match pkh with | Ed25519 edpkh -> return edpkh | _ -> failwith "Wrong public key hash : %a - Commitments must be activated with an \ - Ed25519 encrypted public key hash" - Signature.Public_key_hash.pp + Tezos_crypto.Ed25519 encrypted public key hash" + Tezos_crypto.Signature.Public_key_hash.pp pkh) >|=? fun id -> let contents = Single (Activate_account {id; activation_code}) in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.mli b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.mli index 8b4b79bbf999..d96033bfbcba 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.mli +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/op.mli @@ -45,8 +45,8 @@ val pack_operation : Context.t -> signature option -> 'a contents_list -> packed_operation val sign : - ?watermark:Signature.watermark -> - Signature.secret_key -> + ?watermark:Tezos_crypto.Signature.watermark -> + Tezos_crypto.Signature.secret_key -> Context.t -> packed_contents_list -> packed_operation @@ -245,7 +245,7 @@ val originated_contract : Operation.packed -> Contract.t val register_global_constant : ?force_reveal:bool -> ?counter:Z.t -> - ?public_key:Signature.public_key -> + ?public_key:Tezos_crypto.Signature.public_key -> ?fee:Tez.tez -> ?gas_limit:gas_limit -> ?storage_limit:Z.t -> @@ -276,7 +276,7 @@ val double_baking : val activation : Context.t -> - Signature.Public_key_hash.t -> + Tezos_crypto.Signature.Public_key_hash.t -> Blinded_public_key_hash.activation_code -> Operation.packed tzresult Lwt.t @@ -316,7 +316,7 @@ val proposals_contents : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Kind.proposals contents_list tzresult Lwt.t (** Craft a Proposals operation. @@ -329,7 +329,7 @@ val proposals : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t list -> + Tezos_crypto.Protocol_hash.t list -> Operation.packed tzresult Lwt.t (** Craft the [contents_list] for a Ballot operation. @@ -342,7 +342,7 @@ val ballot_contents : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Kind.ballot contents_list tzresult Lwt.t @@ -356,7 +356,7 @@ val ballot : Context.t -> Contract.t -> ?period:int32 -> - Protocol_hash.t -> + Tezos_crypto.Protocol_hash.t -> Vote.ballot -> Operation.packed tzresult Lwt.t @@ -496,7 +496,7 @@ val tx_rollup_dispatch_tickets : message_result_path:Tx_rollup_commitment.Merkle.path -> Tx_rollup.t -> Tx_rollup_level.t -> - Context_hash.t -> + Tezos_crypto.Context_hash.t -> Tx_rollup_reveal.t list -> (packed_operation, tztrace) result Lwt.t @@ -762,9 +762,9 @@ val update_consensus_key : val drain_delegate : Context.t -> - consensus_key:Signature.Public_key_hash.t -> - delegate:Signature.Public_key_hash.t -> - destination:Signature.Public_key_hash.t -> + consensus_key:Tezos_crypto.Signature.Public_key_hash.t -> + delegate:Tezos_crypto.Signature.Public_key_hash.t -> + destination:Tezos_crypto.Signature.Public_key_hash.t -> packed_operation tzresult Lwt.t (** [zk_rollup_publish ctxt source ~zk_rollup ~op] tries to add an operation diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/operation_generator.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/operation_generator.ml index 0272ea915ded..7e59308338f7 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/operation_generator.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/operation_generator.ml @@ -122,7 +122,7 @@ let pp_kind fmt k = let block_hashes = List.map - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn [ "BLbcVY1kYiKQy2MJJfoHJMN2xRk5QPG1PEKWMDSyW2JMxBsMmiL"; "BLFhLKqQQn32Cc9QXqtEqysYqWNCowNKaypVHP5zEyZcywbXcHo"; @@ -142,7 +142,7 @@ let random_payload_hash = QCheck2.Gen.oneofl payload_hashes let signatures = List.map - Signature.of_b58check_exn + Tezos_crypto.Signature.of_b58check_exn [ "sigaNsiye7D8dJHKSQZBwDbS2aQNXipDP7bw8uQnMgnaXi5pcnoPZRKXrDeFRx4FjWJD2xfyUA9CuBXhwPHhVs7LxkL4vT32"; "sigvtPBMQvk2DgNtu3AKFU1ZRsagGxsoiZVQyQhJNEojReBY2vE5sDwt3H7Mh8RMe27QHBjemxqhMVVszZqpNsdDux6KAELX"; @@ -153,7 +153,7 @@ let random_signature = QCheck2.Gen.oneofl signatures let pkhs = List.map - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn [ "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx"; "tz1b7tUupMgCNw2cCLpKTkSD1NZzB5TkP2sv"; @@ -164,7 +164,7 @@ let random_pkh = QCheck2.Gen.oneofl pkhs let pks = List.map - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn [ "edpkuSLWfVU1Vq7Jg9FucPyKmma6otcMHac9zG4oU1KMHSTBpJuGQ2"; "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n"; @@ -228,7 +228,7 @@ let random_sc_rollup = QCheck2.Gen.oneofl sc_rollups let protos = List.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [ "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -430,7 +430,11 @@ let generate_activate_account = let open QCheck2.Gen in let* activation_code = random_code in let+ id = random_pkh in - let id = match id with Signature.Ed25519 pkh -> pkh | _ -> assert false in + let id = + match id with + | Tezos_crypto.Signature.Ed25519 pkh -> pkh + | _ -> assert false + in Activate_account {id; activation_code} let random_period = @@ -564,7 +568,7 @@ let generate_tx_rollup_rejection = { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } in @@ -602,7 +606,7 @@ let generate_tx_dispatch_tickets = let level = Tx_rollup_level.root in let message_index = 0 in let message_result_path = Tx_rollup_commitment.Merkle.dummy_path in - let context_hash = Context_hash.zero in + let context_hash = Tezos_crypto.Context_hash.zero in let reveal = Tx_rollup_reveal. { diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/sapling_helpers.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/sapling_helpers.ml index 4d07ce051426..0f256cd31ce0 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/sapling_helpers.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/sapling_helpers.ml @@ -117,7 +117,7 @@ module Common = struct let payload_enc = Data_encoding.Binary.to_bytes_exn Data_encoding.bytes - (Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) + (Tezos_crypto.Hacl.Rand.gen (memo_size + 4 + 16 + 11 + 32 + 8)) in Data_encoding.Binary.of_bytes_exn Ciphertext.encoding @@ -353,7 +353,12 @@ module Interpreter_helpers = struct let originate_contract_hash file storage src b baker = originate_contract_hash file storage src b baker >|=? fun (dst, b) -> let anti_replay = - Format.asprintf "%a%a" Contract_hash.pp dst Chain_id.pp Chain_id.zero + Format.asprintf + "%a%a" + Contract_hash.pp + dst + Tezos_crypto.Chain_id.pp + Tezos_crypto.Chain_id.zero in (dst, b, anti_replay) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml index af75636ef346..22acc5dfcb67 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/helpers/tx_rollup_l2_helpers.ml @@ -96,10 +96,11 @@ let empty_context : Context_l2.t = empty_storage let rng_state = Random.State.make_self_init () -let gen_l1_address ?seed () = Signature.generate_key ~algo:Ed25519 ?seed () +let gen_l1_address ?seed () = + Tezos_crypto.Signature.generate_key ~algo:Ed25519 ?seed () let gen_l2_address () = - let pkh, public_key, secret_key = Bls.generate_key () in + let pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key () in (secret_key, public_key, pkh) (** [make_unit_ticket_key ctxt ticketer l2_address] computes the key hash of @@ -153,7 +154,7 @@ let gen_n_ticket_hash n = | Error _ -> raise (Invalid_argument "Failed to forge tickets") let sign_transaction : - Bls.Secret_key.t list -> + Tezos_crypto.Bls.Secret_key.t list -> ('signer, 'content) Tx_rollup_l2_batch.V1.transaction -> Tx_rollup_l2_batch.V1.signature list = fun sks transaction -> @@ -165,7 +166,7 @@ let sign_transaction : Tx_rollup_l2_batch.V1.transaction_encoding transaction in - List.map (fun sk -> Bls.sign sk buf) sks + List.map (fun sk -> Tezos_crypto.Bls.sign sk buf) sks type Environment.Error_monad.error += Test_error of string diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_baking.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_baking.ml index 75cc4075c188..3e58da9b774a 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_baking.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_baking.ml @@ -171,7 +171,7 @@ let get_contract_for_pkh contracts pkh = | [] -> assert false | c :: t -> let c_pkh = Context.Contract.pkh c in - if Signature.Public_key_hash.equal c_pkh pkh then return c + if Tezos_crypto.Signature.Public_key_hash.equal c_pkh pkh then return c else find_contract t in find_contract contracts @@ -226,7 +226,7 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposit -> Context.get_baking_reward_fixed_portion (B b2) >>=? fun baking_reward -> Context.get_bonus_reward (B b2) ~endorsing_power >>=? fun bonus_reward -> - (if Signature.Public_key_hash.equal baker_b2 baker_b1 then + (if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then Context.get_baking_reward_fixed_portion (B b1) else return Tez.zero) >>=? fun reward_for_b1 -> @@ -270,7 +270,8 @@ let test_rewards_block_and_payload_producer () = Context.Delegate.current_frozen_deposits (B b2') baker_b2 >>=? fun frozen_deposit -> let reward_for_b1 = - if Signature.Public_key_hash.equal baker_b2 baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2 baker_b1 then + baking_reward else Tez.zero in let expected_balance = @@ -287,7 +288,8 @@ let test_rewards_block_and_payload_producer () = >>=? fun frozen_deposits' -> Context.get_baker (B genesis) ~round:Round.zero >>=? fun baker_b1 -> let reward_for_b1' = - if Signature.Public_key_hash.equal baker_b2' baker_b1 then baking_reward + if Tezos_crypto.Signature.Public_key_hash.equal baker_b2' baker_b1 then + baking_reward else Tez.zero in let expected_balance' = @@ -396,7 +398,7 @@ let test_committee_sampling () = Format.fprintf ppf "@[- %a %d%a@]@," - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh n (fun ppf failed -> diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_deactivation.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_deactivation.ml index 393330708fea..a8fa7b8e547b 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_deactivation.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_deactivation.ml @@ -311,7 +311,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a1 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m1.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m1.pkh)) ; let constants = Default_parameters.constants_test in let minimal_stake = constants.minimal_stake in Op.transaction ~force_reveal:true (B b) a1 a3 minimal_stake @@ -325,7 +325,7 @@ let test_delegation () = Context.Contract.delegate_opt (B b) a3 >>=? fun delegate -> (match delegate with | None -> assert false - | Some pkh -> assert (Signature.Public_key_hash.equal pkh m3.pkh)) ; + | Some pkh -> assert (Tezos_crypto.Signature.Public_key_hash.equal pkh m3.pkh)) ; check_active_staking_balance ~loc:__LOC__ ~deactivated:false b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m3 >>=? fun () -> check_stake ~loc:__LOC__ b m1 diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_delegation.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_delegation.ml index d5ea2b7cf10d..d244716cc9aa 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_delegation.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_delegation.ml @@ -306,11 +306,11 @@ let undelegated_originated_bootstrap_contract () = let delegated_implicit_bootstrap_contract () = (* These values are fixed because we use a fixed RNG seed. *) let from_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1TDZG4vFoA2xutZMYauUnS4HVucnAGQSpZ" in let to_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1MBWU1WkszFfkEER2pgn4ATKXE9ng7x1sR" in let bootstrap_delegations = [(from_pkh, to_pkh)] in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_baking.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_baking.ml index afae5660e2a3..0bd2f536a376 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_baking.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_baking.ml @@ -52,7 +52,7 @@ let block_fork ?policy (contract_a, contract_b) b = let order_block_hashes ~correct_order bh1 bh2 = let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in - let c = Block_hash.compare hash1 hash2 in + let c = Tezos_crypto.Block_hash.compare hash1 hash2 in if correct_order then if c < 0 then (bh1, bh2) else (bh2, bh1) else if c < 0 then (bh2, bh1) else (bh1, bh2) @@ -95,7 +95,7 @@ let test_valid_double_baking_evidence () = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -119,7 +119,7 @@ let test_valid_double_baking_followed_by_double_endorsing () = >>=? fun blk_with_db_evidence -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in @@ -168,7 +168,7 @@ let test_valid_double_endorsing_followed_by_double_baking () = Block.bake blk_2 >>=? fun blk_b -> Context.get_first_different_endorsers (B blk_a) >>=? fun (e1, e2) -> let delegate = - if Signature.Public_key_hash.( = ) e1.delegate baker1 then + if Tezos_crypto.Signature.Public_key_hash.( = ) e1.delegate baker1 then (e1.delegate, e1.slots) else (e2.delegate, e2.slots) in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_endorsement.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_endorsement.ml index c6e9e3510366..cbb03ebeb28a 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_endorsement.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_endorsement.ml @@ -52,7 +52,7 @@ let block_fork b = let order_endorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) @@ -253,8 +253,11 @@ let test_different_delegates () = Context.get_first_different_endorsers (B blk_b) >>=? fun (endorser_b1c, endorser_b2c) -> let endorser_b, b_slots = - if Signature.Public_key_hash.( = ) endorser_a endorser_b1c.delegate then - (endorser_b2c.delegate, endorser_b2c.slots) + if + Tezos_crypto.Signature.Public_key_hash.( = ) + endorser_a + endorser_b1c.delegate + then (endorser_b2c.delegate, endorser_b2c.slots) else (endorser_b1c.delegate, endorser_b1c.slots) in Op.endorsement @@ -295,7 +298,7 @@ let test_wrong_delegate () = Context.get_endorser_n (B blk_b) 0 >>=? fun (endorser0, slots0) -> Context.get_endorser_n (B blk_b) 1 >>=? fun (endorser1, slots1) -> let endorser_b, b_slots = - if Signature.Public_key_hash.equal endorser_a endorser0 then + if Tezos_crypto.Signature.Public_key_hash.equal endorser_a endorser0 then (endorser1, slots1) else (endorser0, slots0) in @@ -319,8 +322,11 @@ let test_freeze_more_with_low_balance = Context.get_endorsers ctxt >>=? function | [d1; d2] -> return - (if Signature.Public_key_hash.equal account d1.delegate then d1 - else if Signature.Public_key_hash.equal account d2.delegate then d2 + (if Tezos_crypto.Signature.Public_key_hash.equal account d1.delegate + then d1 + else if + Tezos_crypto.Signature.Public_key_hash.equal account d2.delegate + then d2 else assert false) .slots | _ -> assert false @@ -351,7 +357,8 @@ let test_freeze_more_with_low_balance = in let check_unique_endorser b account2 = Context.get_endorsers (B b) >>=? function - | [{delegate; _}] when Signature.Public_key_hash.equal account2 delegate -> + | [{delegate; _}] + when Tezos_crypto.Signature.Public_key_hash.equal account2 delegate -> return_unit | _ -> failwith "We are supposed to only have account2 as endorser." in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_preendorsement.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_preendorsement.ml index 59af65007267..1f10336eb2b8 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_preendorsement.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_double_preendorsement.ml @@ -150,7 +150,7 @@ end = struct let denun_reward = Test_tez.(lost_deposit /! 2L) in (* if the baker is the endorser, he'll only loose half of the deposits *) let expected_endo_loss = - if Signature.Public_key_hash.equal baker d1 then + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then Test_tez.(lost_deposit -! denun_reward) else lost_deposit in @@ -164,7 +164,8 @@ end = struct burnt deposit of d1, so it's higher *) let high, low = - if Signature.Public_key_hash.equal baker d1 then (bal_good, bal_bad) + if Tezos_crypto.Signature.Public_key_hash.equal baker d1 then + (bal_good, bal_bad) else (bal_bad, bal_good) in let diff_baker = Test_tez.(high -! low) in @@ -176,7 +177,7 @@ end = struct let order_preendorsements ~correct_order op1 op2 = let oph1 = Operation.hash op1 in let oph2 = Operation.hash op2 in - let c = Operation_hash.compare oph1 oph2 in + let c = Tezos_crypto.Operation_hash.compare oph1 oph2 in if correct_order then if c < 0 then (op1, op2) else (op2, op1) else if c < 0 then (op2, op1) else (op1, op2) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_participation.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_participation.ml index 7b39c2bfed10..93c4b456c302 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_participation.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/consensus/test_participation.ml @@ -42,7 +42,7 @@ let bake_and_endorse_once (b_pred, b_cur) baker endorser = List.find_map (function | {Plugin.RPC.Validators.delegate; slots; _} -> - if Signature.Public_key_hash.equal delegate endorser then + if Tezos_crypto.Signature.Public_key_hash.equal delegate endorser then Some (delegate, slots) else None) endorsers_list diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_costs.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_costs.ml index c7c7f2ed7729..9fe85ead49c5 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_costs.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_costs.ml @@ -54,7 +54,7 @@ let dummy_map = let dummy_timestamp = Script_timestamp.of_zint (Z.of_int 42) let dummy_pk = - Signature.Public_key.of_b58check_exn + Tezos_crypto.Signature.Public_key.of_b58check_exn "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU" let dummy_bytes = Bytes.of_string "dummy" diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_levels.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_levels.ml index 678a6c79844c..76118c5804b3 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_levels.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/gas/test_gas_levels.ml @@ -218,7 +218,7 @@ let apply_with_gas header ?(operations = []) (pred : Block.t) = (let open Environment.Error_monad in begin_validation_and_application pred.context - Chain_id.zero + Tezos_crypto.Chain_id.zero (Application header) ~predecessor:pred.header.shell >>=? fun vstate -> diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_interpretation.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_interpretation.ml index 4a4f86d4e631..f852060242d4 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_interpretation.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_interpretation.ml @@ -200,7 +200,9 @@ let test_json_roundtrip_err name e () = e let error_encoding_tests = - let contract_zero = Contract.Implicit Signature.Public_key_hash.zero in + let contract_zero = + Contract.Implicit Tezos_crypto.Signature.Public_key_hash.zero + in let script_expr_int = Micheline.strip_locations (Micheline.Int (0, Z.zero)) in List.map (fun (name, e) -> diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_sapling.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_sapling.ml index 4f96057cf12d..be87ed1b2533 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_sapling.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_sapling.ml @@ -279,7 +279,7 @@ module Raw_context_tests = struct let gen_root () = Data_encoding.Binary.of_bytes_exn Validator.Hash.encoding - (Hacl.Rand.gen 32) + (Tezos_crypto.Hacl.Rand.gen 32) in let roots_ctx = WithExceptions.List.init diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index 1e0342d85d7b..aa4d3bb45afa 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -234,7 +234,7 @@ let check_value_size () = =========== *) @ (let show fmt (Script_typed_ir.Script_signature.Signature_tag s) = - Signature.pp fmt s + Tezos_crypto.Signature.pp fmt s in exs ~error:8 nsample show Signature_t ": signature") (* @@ -259,13 +259,13 @@ let check_value_size () = Key_hash_t ========== *) - @ (let show = Signature.Public_key_hash.pp in + @ (let show = Tezos_crypto.Signature.Public_key_hash.pp in exs nsample show Key_hash_t ": key_hash") (* Key_t ===== *) - @ (let show = Signature.Public_key.pp in + @ (let show = Tezos_crypto.Signature.Public_key.pp in exs nsample show Key_t ": key_t") (* Timestamp_t diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_balance.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_balance.ml index b8ae0972f0ef..aedf33233b86 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_balance.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_balance.ml @@ -40,7 +40,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_manager.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_manager.ml index f8984e995394..c2b972eed982 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_manager.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_ticket_manager.ml @@ -46,7 +46,7 @@ let wrap m = m >|= Environment.wrap_tzresult type init_env = { block : Block.t; - baker : Signature.public_key_hash; + baker : Tezos_crypto.Signature.public_key_hash; contract : Contract.t; } diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_timelock.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_timelock.ml index 7e548766f55d..cc22968c847f 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_timelock.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/michelson/test_timelock.ml @@ -25,7 +25,7 @@ (** Testing ------- - Component: Protocol (Timelock) + Component: Protocol (Tezos_crypto.Timelock) Invocation: cd src/proto_alpha/lib_protocol/test/integration/michelson && \ dune exec ./main.exe -- test "^timelock$" Subject: On timelock @@ -37,20 +37,29 @@ open Lwt_result_syntax let wrap e = Lwt.return (Environment.wrap_tzresult e) let simple_test () = - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value in assert (unlocked_value = same_unlocked) ; - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value + in let message = Bytes.create 12 in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let expected_result = Environment.Timelock.Correct message in - let chest_key = Timelock.{unlocked_value; proof} in - let chest = Timelock.{locked_value; rsa_public = public; ciphertext = c} in + let chest_key = Tezos_crypto.Timelock.{unlocked_value; proof} in + let chest = + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} + in let result = Environment.Timelock.open_chest chest chest_key ~time in assert (result = expected_result) ; return_unit @@ -93,30 +102,39 @@ let contract_test () = ~baker block in - let public, secret = Timelock.gen_rsa_keys () in - let locked_value = Timelock.gen_locked_value public in + let public, secret = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value = Tezos_crypto.Timelock.gen_locked_value public in let time = 1000 in - let unlocked_value = Timelock.unlock_with_secret secret ~time locked_value in + let unlocked_value = + Tezos_crypto.Timelock.unlock_with_secret secret ~time locked_value + in let _same_unlocked, proof = - Timelock.unlock_and_prove_without_secret public ~time locked_value + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value + in + let sym_key = + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value in - let sym_key = Timelock.unlocked_value_to_symmetric_key unlocked_value in let message = Bytes.of_string "this is my message" in - let c = Timelock.encrypt sym_key message in + let c = Tezos_crypto.Timelock.encrypt sym_key message in let check_storage chest chest_key expected_storage_hexa = let chest_key_bytes = "0x" ^ Hex.show (Hex.of_bytes (Data_encoding.Binary.to_bytes_exn - Timelock.chest_key_encoding + Tezos_crypto.Timelock.chest_key_encoding chest_key)) in let chest_bytes = "0x" ^ Hex.show (Hex.of_bytes - (Data_encoding.Binary.to_bytes_exn Timelock.chest_encoding chest)) + (Data_encoding.Binary.to_bytes_exn + Tezos_crypto.Timelock.chest_encoding + chest)) in let michelson_string = Format.sprintf "(Pair %s %s )" chest_key_bytes chest_bytes @@ -150,9 +168,9 @@ let contract_test () = assert (to_check = expected_storage_hexa) ; return_unit in - let chest_key_correct = Timelock.{unlocked_value; proof} in + let chest_key_correct = Tezos_crypto.Timelock.{unlocked_value; proof} in let chest_correct = - Timelock.{locked_value; rsa_public = public; ciphertext = c} + Tezos_crypto.Timelock.{locked_value; rsa_public = public; ciphertext = c} in check_storage chest_correct @@ -160,25 +178,36 @@ let contract_test () = (Hex.show (Hex.of_bytes message)) >>=? fun () -> (* We redo an RSA parameters generation to create incorrect cipher and proof *) - let public_bogus, secret_bogus = Timelock.gen_rsa_keys () in - let locked_value_bogus = Timelock.gen_locked_value public_bogus in + let public_bogus, secret_bogus = Tezos_crypto.Timelock.gen_rsa_keys () in + let locked_value_bogus = + Tezos_crypto.Timelock.gen_locked_value public_bogus + in let time = 1000 in let unlocked_value_bogus = - Timelock.unlock_with_secret secret_bogus ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_with_secret + secret_bogus + ~time + locked_value_bogus in let _same_unlocked, proof_bogus = - Timelock.unlock_and_prove_without_secret public ~time locked_value_bogus + Tezos_crypto.Timelock.unlock_and_prove_without_secret + public + ~time + locked_value_bogus in let sym_key_bogus = - Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus + Tezos_crypto.Timelock.unlocked_value_to_symmetric_key unlocked_value_bogus in - let c_bogus = Timelock.encrypt sym_key_bogus message in + let c_bogus = Tezos_crypto.Timelock.encrypt sym_key_bogus message in let chest_incorrect = - Timelock.{locked_value; rsa_public = public; ciphertext = c_bogus} + Tezos_crypto.Timelock. + {locked_value; rsa_public = public; ciphertext = c_bogus} in check_storage chest_incorrect chest_key_correct "00" >>=? fun () -> - let chest_key_incorrect = Timelock.{unlocked_value; proof = proof_bogus} in + let chest_key_incorrect = + Tezos_crypto.Timelock.{unlocked_value; proof = proof_bogus} + in check_storage chest_correct chest_key_incorrect "01" >>=? fun () -> return_unit diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_activation.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_activation.ml index 5e995ec1c01a..9580be0be296 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_activation.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_activation.ml @@ -85,19 +85,21 @@ let secrets () = let passphrase = Bytes.(cat (of_string email) (of_string password)) in let sk = Tezos_client_base.Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in (pkh, pk, sk) in List.map (fun (mnemonic, secret, amount, pkh, password, email) -> let pkh', pk, sk = read_key mnemonic email password in - let pkh = Signature.Public_key_hash.of_b58check_exn pkh in - assert (Signature.Public_key_hash.equal pkh pkh') ; + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh in + assert (Tezos_crypto.Signature.Public_key_hash.equal pkh pkh') ; let account = Account.{pkh; pk; sk} in Account.add_account account ; { @@ -491,7 +493,7 @@ let test_invalid_activation_inexistent_pkh () = WithExceptions.Option.get ~loc:__LOC__ @@ List.hd secrets in let inexistent_pkh = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1PeQHGKPWSpNoozvxgqLN9TFsj6rDqNV3o" in Op.activation (B blk) inexistent_pkh activation_code >>=? fun operation -> diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_reveal.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_reveal.ml index d6ea32c30912..ad764995f8fa 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_reveal.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_reveal.ml @@ -146,12 +146,12 @@ let test_reveal_with_fake_account () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> @@ -228,12 +228,12 @@ let test_reveal_with_fake_account_already_revealed () = These preambles are too verbose and boilerplate. We should factor out revealing fresh unrevealed accounts. *) - when_ (Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> + when_ (Tezos_crypto.Signature.Public_key_hash.equal a_pkh b_pkh) (fun () -> failwith "Expected different pkhs: got %a %a" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a_pkh - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp b_pkh) >>=? fun () -> Op.transaction (B blk) bootstrap a_contract Tez.one >>=? fun oa -> diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_sc_rollup.ml index 0a977a29a2a5..dd03b4d1f8e0 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -1570,7 +1570,7 @@ let test_timeout () = number_of_ticks = number_of_ticks_exn 4L; compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["first"]); + (Tezos_crypto.Context_hash.hash_string ["first"]); } in let commitment2 = @@ -1579,7 +1579,7 @@ let test_timeout () = number_of_ticks = number_of_ticks_exn 4L; compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["second"]); + (Tezos_crypto.Context_hash.hash_string ["second"]); } in @@ -1608,17 +1608,17 @@ let test_timeout () = (%ld, %a)] but got [Sc_rollup_timeout_level_not_reached (%ld, \ %a)]" expected_block_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh1 blocks_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp staker | _ -> failwith "It should have failed with [Sc_rollup_timeout_level_not_reached \ (%ld, %a)]" expected_block_left - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp pkh1 in let* timeout = Op.sc_rollup_timeout (B block) account3 rollup game_index in @@ -1677,14 +1677,14 @@ let init_with_conflict () = let* block, rollup = sc_originate block account1 "unit" in let compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["first"]) + (Tezos_crypto.Context_hash.hash_string ["first"]) in let* commitment1 = dummy_commitment ~compressed_state ~number_of_ticks:1L (B block) rollup in let compressed_state = Sc_rollup.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["second"]) + (Tezos_crypto.Context_hash.hash_string ["second"]) in let* commitment2 = dummy_commitment ~compressed_state ~number_of_ticks:1L (B block) rollup diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_tx_rollup.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_tx_rollup.ml index 71a4b068209e..640a74bf1bd5 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_tx_rollup.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_tx_rollup.ml @@ -310,7 +310,9 @@ let commitment_hash_testable = Alcotest.testable Tx_rollup_commitment_hash.pp Tx_rollup_commitment_hash.( = ) let public_key_hash_testable = - Alcotest.testable Signature.Public_key_hash.pp Signature.Public_key_hash.( = ) + Alcotest.testable + Tezos_crypto.Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.( = ) let raw_level_testable = Alcotest.testable Raw_level.pp Raw_level.( = ) @@ -325,7 +327,7 @@ let gen_l2_account ?rng_state () = Bytes.init 32 (fun _ -> char_of_int @@ Random.State.int rng_state 255)) rng_state in - let pkh, public_key, secret_key = Bls.generate_key ?seed () in + let pkh, public_key, secret_key = Tezos_crypto.Bls.generate_key ?seed () in (secret_key, public_key, pkh) (** [make_ticket_key ty contents ticketer tx_rollup] computes the ticket hash @@ -409,7 +411,7 @@ let make_deposit b tx_rollup l1_src addr = (** Create an incomplete (but valid) commitment for a given level. It is incomplete in the sense that the Merkle roots for each message are generated - with [Context_hash.hash_string message_index]. In the meantime provides the + with [Tezos_crypto.Context_hash.hash_string message_index]. In the meantime provides the list of withdraw in a association list of [batch_index -> withdraw_list]. Be careful not to provide a too-big withdraw_list as the construction is expensive *) @@ -420,7 +422,8 @@ let make_incomplete_commitment_for_batch context level tx_rollup withdraw_list = Data_encoding.Binary.to_string_exn Tx_rollup_inbox.encoding metadata in List.init ~when_negative_length:[] metadata.inbox_length (fun i -> - Context_hash.hash_string [str_for_context_hash ^ string_of_int i]) + Tezos_crypto.Context_hash.hash_string + [str_for_context_hash ^ string_of_int i]) >>?= fun batches_result -> let messages = List.mapi @@ -1599,7 +1602,7 @@ let test_commitment_duplication () = let batches2 : Tx_rollup_message_result_hash.t list = [Bytes.make 20 '1'; Bytes.make 20 '2'] |> List.map (fun hash -> - let context_hash = Context_hash.hash_bytes [hash] in + let context_hash = Tezos_crypto.Context_hash.hash_bytes [hash] in Tx_rollup_message_result_hash.hash_uncarbonated { context_hash; @@ -2266,7 +2269,7 @@ module Rejection = struct Tx_rollup_message_result_hash.hash_uncarbonated { context_hash = - Context_hash.of_b58check_exn + Tezos_crypto.Context_hash.of_b58check_exn "CoUiEnajKeukmYFUgWTJF2z3v24MycpTaomF8a9hRzVy7as9hvgy"; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; }; @@ -2336,7 +2339,8 @@ module Rejection = struct let* store = init_l2_store () in let* hash_tree = hash_tree_from_store store in assert ( - Context_hash.(hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; + Tezos_crypto.Context_hash.( + hash_tree = Tx_rollup_message_result.empty_l2_context_hash)) ; return_unit (** [make_proof store msg] applies [msg] on [store] and returns the @@ -2364,7 +2368,7 @@ module Rejection = struct { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } @@ -2498,7 +2502,9 @@ module Rejection = struct let signatures = Tx_rollup_l2_helpers.sign_transaction signers transaction in - let signature = assert_some @@ Bls.aggregate_signature_opt signatures in + let signature = + assert_some @@ Tezos_crypto.Bls.aggregate_signature_opt signatures + in let batch = Tx_rollup_l2_batch.V1. {contents = [transaction]; aggregated_signature = signature} @@ -2740,7 +2746,7 @@ module Rejection = struct let level1 = tx_level 1l in make_invalid_commitment b level0 l2_context_hash >>=? fun (b, commitment0) -> - make_invalid_commitment b level1 Context_hash.zero + make_invalid_commitment b level1 Tezos_crypto.Context_hash.zero >>=? fun (b, commitment1) -> Context.get_constants (B b) >>=? fun constants -> let bond_cost = constants.parametric.tx_rollup.commitment_bond in @@ -2976,7 +2982,7 @@ module Rejection = struct let previous_message_result : Tx_rollup_message_result.t = { (* Expected is Tx_rollup_commitment.empty_l2_context_hash *) - context_hash = Context_hash.zero; + context_hash = Tezos_crypto.Context_hash.zero; withdraw_list_hash = Tx_rollup_withdraw_list_hash.empty; } in @@ -4554,7 +4560,7 @@ module Withdraw = struct ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - (Context_hash.hash_bytes [Bytes.make 20 'c']) + (Tezos_crypto.Context_hash.hash_bytes [Bytes.make 20 'c']) (* any context hash will fail *) [ticket_info] (* any non-empty list will fail *) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_voting.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_voting.ml index 6d1f908f3d35..fa1038f416fb 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_voting.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/operations/test_voting.ml @@ -77,7 +77,7 @@ let expected_qr_num participation_ema = (* Protocol_hash.zero is "PrihK96nBAFSxVL1GLJTVhu9YnzkMFiBeuJRPA8NwuZVZCE1L6i" *) let protos = Array.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [| "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -230,9 +230,9 @@ let equal_delegate_info a b = Option.equal Int64.equal a.Vote.voting_power b.Vote.voting_power && Option.equal Vote.equal_ballot a.current_ballot b.current_ballot && List.equal - Protocol_hash.equal - (List.sort Protocol_hash.compare a.current_proposals) - (List.sort Protocol_hash.compare b.current_proposals) + Tezos_crypto.Protocol_hash.equal + (List.sort Tezos_crypto.Protocol_hash.compare a.current_proposals) + (List.sort Tezos_crypto.Protocol_hash.compare b.current_proposals) && Int.equal a.remaining_proposals b.remaining_proposals let assert_equal_info ~loc a b = @@ -470,8 +470,9 @@ let test_successful_vote num_delegates () = let props = List.map (fun i -> protos.(i)) (2 -- Constants.max_proposals_per_delegate) in - Op.proposals (B b) del1 (Protocol_hash.zero :: props) >>=? fun ops1 -> - Op.proposals (B b) del2 [Protocol_hash.zero] >>=? fun ops2 -> + Op.proposals (B b) del1 (Tezos_crypto.Protocol_hash.zero :: props) + >>=? fun ops1 -> + Op.proposals (B b) del2 [Tezos_crypto.Protocol_hash.zero] >>=? fun ops2 -> Block.bake ~operations:[ops1; ops2] b >>=? fun b -> Context.Delegate.voting_info (B b) pkh1 >>=? fun info1 -> Context.Delegate.voting_info (B b) pkh2 >>=? fun info2 -> @@ -481,7 +482,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow1; current_ballot = None; - current_proposals = Protocol_hash.zero :: props; + current_proposals = Tezos_crypto.Protocol_hash.zero :: props; remaining_proposals = 0; } >>=? fun () -> @@ -491,7 +492,7 @@ let test_successful_vote num_delegates () = { voting_power = Some pow2; current_ballot = None; - current_proposals = [Protocol_hash.zero]; + current_proposals = [Tezos_crypto.Protocol_hash.zero]; remaining_proposals = Constants.max_proposals_per_delegate - 1; } >>=? fun () -> @@ -513,7 +514,7 @@ let test_successful_vote num_delegates () = assert_validate_proposals_fails ~expected_error:too_many_proposals ~proposer:del1 - ~proposals:(Protocol_hash.zero :: props) + ~proposals:(Tezos_crypto.Protocol_hash.zero :: props) b __LOC__ >>=? fun () -> @@ -544,13 +545,13 @@ let test_successful_vote num_delegates () = (* current proposal must be set during exploration period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p2 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p2 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -571,7 +572,7 @@ let test_successful_vote num_delegates () = assert_validate_ballot_fails ~expected_error:already_submitted_a_ballot ~voter:del1 - ~proposal:Protocol_hash.zero + ~proposal:Tezos_crypto.Protocol_hash.zero ~ballot:Vote.Nay b __LOC__ @@ -622,13 +623,13 @@ let test_successful_vote num_delegates () = (* current proposal must be set during promotion period *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal zero v) then return_unit + if Tezos_crypto.Protocol_hash.(equal zero v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> (* unanimous vote: all delegates --active when p4 started-- vote *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) delegates_p4 >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -663,11 +664,11 @@ let test_successful_vote num_delegates () = Context.Vote.get_protocol b >>= fun p -> Assert.equal ~loc:__LOC__ - Protocol_hash.equal + Tezos_crypto.Protocol_hash.equal "Unexpected proposal" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp p - Protocol_hash.zero + Tezos_crypto.Protocol_hash.zero >>=? fun () -> return_unit (* given a list of active delegates, @@ -719,7 +720,8 @@ let test_not_enough_quorum_in_exploration num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun operation -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] + >>=? fun operation -> Block.bake ~operation b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -741,7 +743,7 @@ let test_not_enough_quorum_in_exploration num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -773,7 +775,8 @@ let test_not_enough_quorum_in_promotion num_delegates () = let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in - Op.proposals (B b) proposer [Protocol_hash.zero] >>=? fun operation -> + Op.proposals (B b) proposer [Tezos_crypto.Protocol_hash.zero] + >>=? fun operation -> Block.bake ~operation b >>=? fun b -> (* skip to exploration period *) bake_until_first_block_of_next_period b >>=? fun b -> @@ -789,7 +792,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -820,7 +823,7 @@ let test_not_enough_quorum_in_promotion num_delegates () = (* all voters_without_quorum vote, for yays; no nays, so supermajority is satisfied *) List.map_es - (fun del -> Op.ballot (B b) del Protocol_hash.zero Vote.Yay) + (fun del -> Op.ballot (B b) del Tezos_crypto.Protocol_hash.zero Vote.Yay) voters_without_quorum >>=? fun operations -> Block.bake ~operations b >>=? fun b -> @@ -944,7 +947,7 @@ let test_supermajority_in_exploration supermajority () = (* assert our proposal won *) (Context.Vote.get_current_proposal (B b) >>=? function | Some v -> - if Protocol_hash.(equal proposal v) then return_unit + if Tezos_crypto.Protocol_hash.(equal proposal v) then return_unit else failwith "%s - Wrong proposal" __LOC__ | None -> failwith "%s - Missing proposal" __LOC__) >>=? fun () -> @@ -1007,7 +1010,7 @@ let test_quorum_capped_maximum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in @@ -1047,7 +1050,7 @@ let test_quorum_capped_minimum num_delegates () = let open Alpha_context in assert_period ~expected_kind:Proposal b __LOC__ >>=? fun () -> (* propose a new protocol *) - let protocol = Protocol_hash.zero in + let protocol = Tezos_crypto.Protocol_hash.zero in let proposer = WithExceptions.Option.get ~loc:__LOC__ @@ List.nth delegates 0 in @@ -1259,7 +1262,9 @@ let test_proposals_invalid_signature () = let open Lwt_result_syntax in let* block, proposer = context_init1 () in let* contents = Op.proposals_contents (B block) proposer [protos.(0)] in - let op = Op.pack_operation (B block) (Some Signature.zero) contents in + let op = + Op.pack_operation (B block) (Some Tezos_crypto.Signature.zero) contents + in Incremental.assert_validate_operation_fails (invalid_signature __LOC__) op @@ -1276,7 +1281,7 @@ let test_proposals_wrong_voting_period_index () = assert_validate_proposals_fails ~expected_error:(wrong_voting_period_index ~current_index ~op_index) ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] ~period:op_index block __LOC__ @@ -1336,14 +1341,14 @@ let test_proposals_source_not_in_vote_listings () = assert_validate_proposals_fails ~expected_error:proposals_from_unregistered_delegate ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] block in let assert_fails_with_source_not_in_vote_listings block = assert_validate_proposals_fails ~expected_error:source_not_in_vote_listings ~proposer - ~proposals:[Protocol_hash.zero] + ~proposals:[Tezos_crypto.Protocol_hash.zero] block in (* Fail when the source has no contract in the storage. *) @@ -1690,7 +1695,9 @@ let test_ballot_invalid_signature () = let open Lwt_result_syntax in let* block, voter, proposal = context_init_exploration () in let* contents = Op.ballot_contents (B block) voter proposal Vote.Yay in - let op = Op.pack_operation (B block) (Some Signature.zero) contents in + let op = + Op.pack_operation (B block) (Some Tezos_crypto.Signature.zero) contents + in Incremental.assert_validate_operation_fails (invalid_signature __LOC__) op @@ -1912,7 +1919,7 @@ let observe_ballot pre_state post_state op caller_loc = let* current_proposal = Assert.get_some ~loc:(make_loc __LOC__) current_proposal in - assert (Protocol_hash.equal proposal current_proposal) ; + assert (Tezos_crypto.Protocol_hash.equal proposal current_proposal) ; (* Observations *) let* post_voting_infos = Context.Delegate.voting_info (B post_state) source in let* recorded_ballot = diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_frozen_bonds.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_frozen_bonds.ml index 3704c98b187e..aca5cf883269 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_frozen_bonds.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_frozen_bonds.ml @@ -54,7 +54,7 @@ let very_small_random_amount () = | Some x -> x let nonce_zero = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_tx_rollup ?(nonce = nonce_zero) () = ( Tx_rollup.Internal_for_tests.originated_tx_rollup nonce, @@ -74,13 +74,13 @@ let create_context () = delegate's pkh. *) let init_test ~user_is_delegate = create_context () >>=? fun (ctxt, _) -> - let delegate, delegate_pk, _ = Signature.generate_key () in + let delegate, delegate_pk, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract = Contract.Implicit delegate in let delegate_account = `Contract (Contract.Implicit delegate) in let user_contract = if user_is_delegate then delegate_contract else - let user, _, _ = Signature.generate_key () in + let user, _, _ = Tezos_crypto.Signature.generate_key () in Contract.Implicit user in let user_account = `Contract user_contract in @@ -398,7 +398,7 @@ let test_rpcs () = let test_scenario scenario = init_test ~user_is_delegate:false >>=? fun (ctxt, user_contract, user_account, delegate1) -> - let delegate2, delegate_pk2, _ = Signature.generate_key () in + let delegate2, delegate_pk2, _ = Tezos_crypto.Signature.generate_key () in let delegate_contract2 = Contract.Implicit delegate2 in let delegate_account2 = `Contract delegate_contract2 in let delegate_balance2 = big_random_amount () in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_token.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_token.ml index 1d3edd5f6c2f..f828639aae7d 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_token.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_token.ml @@ -52,7 +52,8 @@ let random_amount () = | None -> assert false | Some x -> x -let nonce = Origination_nonce.Internal_for_tests.initial Operation_hash.zero +let nonce = + Origination_nonce.Internal_for_tests.initial Tezos_crypto.Operation_hash.zero let mk_rollup () = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce @@ -61,7 +62,7 @@ let test_simple_balances () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = `Contract (Contract.Implicit pkh) in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in let amount = Tez.one in wrap (Token.transfer ctxt src dest amount) >>=? fun (ctxt', _) -> @@ -80,7 +81,7 @@ let test_simple_balance_updates () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let src = Contract.Implicit pkh in - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = Tez.one in wrap (Token.transfer ctxt (`Contract src) (`Contract dest) amount) @@ -129,7 +130,7 @@ let test_allocated () = create_context () >>=? fun (ctxt, pkh) -> let dest = `Delegate_balance pkh in test_allocated_and_still_allocated_when_empty ctxt dest true >>=? fun _ -> - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = `Contract (Contract.Implicit pkh) in test_allocated_and_deallocated_when_empty ctxt dest >>=? fun _ -> let dest = `Collected_commitments Blinded_public_key_hash.zero in @@ -182,7 +183,7 @@ let test_transferring_to_sink ctxt sink amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res "Overflowing tez addition" let test_transferring_to_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -201,7 +202,7 @@ let test_transferring_to_collected_commitments ctxt = [(Commitments bpkh, Credited amount, Block_application)] let test_transferring_to_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let dest = Contract.Implicit pkh in let amount = random_amount () in test_transferring_to_sink @@ -211,7 +212,7 @@ let test_transferring_to_delegate_balance ctxt = [(Contract dest, Credited amount, Block_application)] let test_transferring_to_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_to_sink ctxt @@ -253,7 +254,7 @@ let test_transferring_to_burned ctxt = ]) true >>=? fun () -> - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in let p, r = (Random.bool (), Random.bool ()) in wrap (Token.transfer ctxt `Minted (`Lost_endorsing_rewards (pkh, p, r)) amount) @@ -279,7 +280,7 @@ let test_transferring_to_burned ctxt = true let test_transferring_to_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -379,7 +380,7 @@ let test_transferring_from_bounded_source ctxt src amount expected_bupds = Assert.proto_error_with_info ~loc:__LOC__ res error_title let test_transferring_from_contract ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let src = Contract.Implicit pkh in let amount = random_amount () in test_transferring_from_bounded_source @@ -398,7 +399,7 @@ let test_transferring_from_collected_commitments ctxt = [(Commitments bpkh, Debited amount, Block_application)] let test_transferring_from_delegate_balance ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in let src = Contract.Implicit pkh in test_transferring_from_bounded_source @@ -408,7 +409,7 @@ let test_transferring_from_delegate_balance ctxt = [(Contract src, Debited amount, Block_application)] let test_transferring_from_frozen_deposits ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let amount = random_amount () in test_transferring_from_bounded_source ctxt @@ -425,7 +426,7 @@ let test_transferring_from_collected_fees ctxt = [(Block_fees, Debited amount, Block_application)] let test_transferring_from_frozen_bonds ctxt = - let pkh, _pk, _sk = Signature.generate_key () in + let pkh, _pk, _sk = Tezos_crypto.Signature.generate_key () in let contract = Contract.Implicit pkh in let tx_rollup = mk_rollup () in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in @@ -496,13 +497,13 @@ let cast_to_container_type x = let build_test_cases () = create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let baker1, baker1_pk, _ = Signature.generate_key () in + let baker1, baker1_pk, _ = Tezos_crypto.Signature.generate_key () in let baker1c = `Contract (Contract.Implicit baker1) in - let baker2, baker2_pk, _ = Signature.generate_key () in + let baker2, baker2_pk, _ = Tezos_crypto.Signature.generate_key () in let baker2c = `Contract (Contract.Implicit baker2) in (* Allocate contracts for user1, user2, baker1, and baker2. *) wrap (Token.transfer ctxt origin user1c (random_amount ())) @@ -705,13 +706,13 @@ let test_transfer_n_with_non_empty_source () = Random.init 0 ; create_context () >>=? fun (ctxt, pkh) -> let origin = `Contract (Contract.Implicit pkh) in - let user1, _, _ = Signature.generate_key () in + let user1, _, _ = Tezos_crypto.Signature.generate_key () in let user1c = `Contract (Contract.Implicit user1) in - let user2, _, _ = Signature.generate_key () in + let user2, _, _ = Tezos_crypto.Signature.generate_key () in let user2c = `Contract (Contract.Implicit user2) in - let user3, _, _ = Signature.generate_key () in + let user3, _, _ = Tezos_crypto.Signature.generate_key () in let user3c = `Contract (Contract.Implicit user3) in - let user4, _, _ = Signature.generate_key () in + let user4, _, _ = Tezos_crypto.Signature.generate_key () in let user4c = `Contract (Contract.Implicit user4) in (* Allocate contracts for user1, user2, user3, and user4. *) let amount = diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.ml index d33e29fc1868..52f430772629 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -42,7 +42,7 @@ type state = { voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; - protocol_hashes : Protocol_hash.t list; + protocol_hashes : Tezos_crypto.Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; dbl_endorsement : dbl_endorsement_state; @@ -128,7 +128,10 @@ let ballot_exploration_prelude state = let* props = List.map_es (fun voter -> - Op.proposals (B state.block) voter [Protocol_hash.zero]) + Op.proposals + (B state.block) + voter + [Tezos_crypto.Protocol_hash.zero]) voters in return (prop :: props, state) @@ -179,7 +182,11 @@ let ballot_exploration_descriptor = in assert (voting_period_info.voting_period.kind = Exploration) ; let ballot = pick_one ballots in - Op.ballot (B state.block) contract Protocol_hash.zero ballot + Op.ballot + (B state.block) + contract + Tezos_crypto.Protocol_hash.zero + ballot in List.map_es gen state.voters); } @@ -200,7 +207,10 @@ let proposal_descriptor = Context.Vote.get_current_period (B state.block) in assert (voting_period_info.voting_period.kind = Proposal) ; - Op.proposals (B state.block) contract [Protocol_hash.zero] + Op.proposals + (B state.block) + contract + [Tezos_crypto.Protocol_hash.zero] in List.map_es gen state.voters); } @@ -245,7 +255,11 @@ let ballot_promotion_descriptor = let* ops = List.map_es (fun voter -> - Op.ballot (B state.block) voter Protocol_hash.zero Vote.Yay) + Op.ballot + (B state.block) + voter + Tezos_crypto.Protocol_hash.zero + Vote.Yay) state.voters in return (ops, state) @@ -259,7 +273,11 @@ let ballot_promotion_descriptor = in assert (voting_period_info.voting_period.kind = Promotion) ; let ballot = Stdlib.List.hd ballots in - Op.ballot (B state.block) contract Protocol_hash.zero ballot + Op.ballot + (B state.block) + contract + Tezos_crypto.Protocol_hash.zero + ballot in List.map_es gen state.voters); } @@ -359,7 +377,9 @@ let dbl_endorsement_prelude state = in let op1, op2 = let comp = - Operation_hash.compare (Operation.hash op1) (Operation.hash op2) + Tezos_crypto.Operation_hash.compare + (Operation.hash op1) + (Operation.hash op2) in assert (comp <> 0) ; if comp < 0 then (op1, op2) else (op2, op1) @@ -375,7 +395,9 @@ let dbl_endorsement_prelude state = in let op3, op4 = let comp = - Operation_hash.compare (Operation.hash op3) (Operation.hash op4) + Tezos_crypto.Operation_hash.compare + (Operation.hash op3) + (Operation.hash op4) in assert (comp <> 0) ; if comp < 0 then (op3, op4) else (op4, op3) @@ -423,7 +445,7 @@ let double_baking_descriptor = let order_block_header bh1 bh2 = let hash1 = Block_header.hash bh1 in let hash2 = Block_header.hash bh2 in - let c = Block_hash.compare hash1 hash2 in + let c = Tezos_crypto.Block_hash.compare hash1 hash2 in if c < 0 then (bh1, bh2) else (bh2, bh1) in let* ctxt = Context.to_alpha_ctxt (B state.block) in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.mli b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.mli index df118ca15c6f..1b9add80bfa6 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.mli +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/generator_descriptors.mli @@ -57,7 +57,7 @@ type state = { voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; - protocol_hashes : Protocol_hash.t list; + protocol_hashes : Tezos_crypto.Protocol_hash.t list; slashable_bakes : (block_header * block_header) list; vdf : bool; dbl_endorsement : dbl_endorsement_state; diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/manager_operation_helpers.ml index 8213576d46a6..4aa5fad6f7bc 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -898,7 +898,7 @@ let mk_tx_rollup_reject (oinfos : operation_req) (infos : infos) = { version = 1; before = `Value Tx_rollup_message_result.empty_l2_context_hash; - after = `Value Context_hash.zero; + after = `Value Tezos_crypto.Context_hash.zero; state = Seq.empty; } in @@ -983,7 +983,7 @@ let mk_tx_rollup_dispacth_ticket (oinfos : operation_req) (infos : infos) = ~message_result_path:Tx_rollup_commitment.Merkle.dummy_path tx_rollup Tx_rollup_level.root - Context_hash.zero + Tezos_crypto.Context_hash.zero [reveal] let mk_sc_rollup_origination (oinfos : operation_req) (infos : infos) = @@ -1247,7 +1247,7 @@ let make_tztest_batched ?(fmt = Format.std_formatter) name test subjects increment of the counters aka 1 for a single operation, n for a batch of n manager operations. *) type probes = { - source : Signature.Public_key_hash.t; + source : Tezos_crypto.Signature.Public_key_hash.t; fee : Tez.tez; gas_limit : Gas.Arith.integral; nb_counter : Z.t; diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/test_mempool.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/test_mempool.ml index f4d4699d7ccb..3630b43d1918 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/test_mempool.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/test_mempool.ml @@ -84,14 +84,16 @@ let assert_operation_present_in_mempool ~__LOC__ mempool ophl = let resulting_mempool_operations = Environment.Operation_hash.Map.bindings operations |> List.map fst - |> List.sort Operation_hash.compare + |> List.sort Tezos_crypto.Operation_hash.compare + in + let expected_operations = + List.sort Tezos_crypto.Operation_hash.compare ophl in - let expected_operations = List.sort Operation_hash.compare ophl in Assert.assert_equal_list ~loc:__LOC__ - Operation_hash.equal + Tezos_crypto.Operation_hash.equal "operations present in mempool" - Operation_hash.pp + Tezos_crypto.Operation_hash.pp resulting_mempool_operations expected_operations @@ -106,7 +108,7 @@ let test_simple () = let vs, mempool = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -138,7 +140,7 @@ let test_imcompatible_mempool () = let _vs, mempool1 = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -154,7 +156,7 @@ let test_imcompatible_mempool () = let _vs, mempool2 = Mempool.init ctxt2 - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash:predecessor_hash2 @@ -183,7 +185,7 @@ let test_merge () = let vs, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -275,7 +277,7 @@ let test_add_invalid_operation () = let vs, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -300,7 +302,7 @@ let test_add_and_replace () = let info, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash @@ -352,7 +354,7 @@ let test_remove_operation () = let info, mempool_i = Mempool.init ctxt - Chain_id.zero + Tezos_crypto.Chain_id.zero ~predecessor_level ~predecessor_round ~predecessor_hash diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/validate_helpers.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/validate_helpers.ml index be0326836db7..3ad0af08a87c 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/validate_helpers.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/validate/validate_helpers.ml @@ -61,7 +61,7 @@ let ballots = Vote.[Yay; Nay; Pass] let protos = List.map - (fun s -> Protocol_hash.of_b58check_exn s) + (fun s -> Tezos_crypto.Protocol_hash.of_b58check_exn s) [ "ProtoALphaALphaALphaALphaALphaALphaALpha61322gcLUGH"; "ProtoALphaALphaALphaALphaALphaALphaALphabc2a7ebx6WB"; @@ -88,7 +88,7 @@ let protos = type secret_account = { blinded_public_key_hash : Blinded_public_key_hash.t; - account : Ed25519.Public_key_hash.t; + account : Tezos_crypto.Ed25519.Public_key_hash.t; activation_code : Blinded_public_key_hash.activation_code; amount : Tez.t; } @@ -103,19 +103,21 @@ let secrets = let passphrase = Bytes.(cat (of_string email) (of_string password)) in let sk = Tezos_client_base.Bip39.to_seed ~passphrase t in let sk = Bytes.sub sk 0 32 in - let sk : Signature.Secret_key.t = + let sk : Tezos_crypto.Signature.Secret_key.t = Ed25519 - (Data_encoding.Binary.of_bytes_exn Ed25519.Secret_key.encoding sk) + (Data_encoding.Binary.of_bytes_exn + Tezos_crypto.Ed25519.Secret_key.encoding + sk) in - let pk = Signature.Secret_key.to_public_key sk in - let pkh = Signature.Public_key.hash pk in + let pk = Tezos_crypto.Signature.Secret_key.to_public_key sk in + let pkh = Tezos_crypto.Signature.Public_key.hash pk in (pkh, pk, sk) in List.map (fun (mnemonic, secret, amount, pkh, password, email) -> let pkh', pk, sk = read_key mnemonic email password in - let pkh = Ed25519.Public_key_hash.of_b58check_exn pkh in - assert (Signature.Public_key_hash.equal (Ed25519 pkh) pkh') ; + let pkh = Tezos_crypto.Ed25519.Public_key_hash.of_b58check_exn pkh in + assert (Tezos_crypto.Signature.Public_key_hash.equal (Ed25519 pkh) pkh') ; let activation_code = Stdlib.Option.get (Blinded_public_key_hash.activation_code_of_hex secret) diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_script_comparison.ml b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_script_comparison.ml index c2ce81cca514..06c47e5e5ac8 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_script_comparison.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_script_comparison.ml @@ -57,8 +57,9 @@ let rec reference_compare_comparable : type a. a comparable_ty -> a -> a -> int | Bool_t, x, y -> normalize_compare @@ Compare.Bool.compare x y | Mutez_t, x, y -> normalize_compare @@ Tez.compare x y | Key_hash_t, x, y -> - normalize_compare @@ Signature.Public_key_hash.compare x y - | Key_t, x, y -> normalize_compare @@ Signature.Public_key.compare x y + normalize_compare @@ Tezos_crypto.Signature.Public_key_hash.compare x y + | Key_t, x, y -> + normalize_compare @@ Tezos_crypto.Signature.Public_key.compare x y | Int_t, x, y -> normalize_compare @@ Script_int.compare x y | Nat_t, x, y -> normalize_compare @@ Script_int.compare x y | Timestamp_t, x, y -> normalize_compare @@ Script_timestamp.compare x y diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml index fcf89c89ec43..440ffd952908 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_tx_rollup_l2_encoding.ml @@ -47,7 +47,9 @@ let l2_address, bls_pk = `Hex "8fee216367c463821f82c942a1cee3a01469b1da782736ca269a2accea6e0cc4" |> Hex.to_bytes_exn in - let pkh, public_key, _secret_key = Bls.generate_key ~seed:ikm () in + let pkh, public_key, _secret_key = + Tezos_crypto.Bls.generate_key ~seed:ikm () + in (pkh, public_key) let signer_gen : Signer_indexable.either QCheck2.Gen.t = @@ -74,7 +76,7 @@ let idx_l2_address_gen = oneof [idx_l2_address_idx_gen; return idx_l2_address_value] let public_key_hash = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" let public_key_hash_gen = @@ -87,7 +89,9 @@ let ticket_hash : Protocol.Alpha_context.Ticket_hash.t = (* TODO: https://gitlab.com/tezos/tezos/-/issues/2592 we could introduce a bit more randomness here *) let ticketer_b58 = "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" in - let ticketer_pkh = Signature.Public_key_hash.of_b58check_exn ticketer_b58 in + let ticketer_pkh = + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn ticketer_b58 + in let ticketer = Protocol.Alpha_context.Contract.Implicit ticketer_pkh in Tx_rollup_l2_helpers.make_unit_ticket_key ticketer l2_address diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_zk_rollup_encoding.ml b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_zk_rollup_encoding.ml index 042fe450eb13..9d55fd7125bb 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_zk_rollup_encoding.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/pbt/test_zk_rollup_encoding.ml @@ -98,7 +98,7 @@ let gen_ticket_hash = Ticket_hash_repr.of_bytes_exn bytes let gen_pkh = - let pkh, _, _ = Signature.generate_key ~algo:Ed25519 () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key ~algo:Ed25519 () in Gen.return pkh let gen_z = diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/regression/test_logging.ml b/src/proto_015_PtLimaPt/lib_protocol/test/regression/test_logging.ml index 6ab68e63171f..7a72864cc718 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/regression/test_logging.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/regression/test_logging.ml @@ -219,7 +219,9 @@ let run_script transaction () = let* inc = Incremental.begin_construction b in let ctxt = Incremental.alpha_ctxt inc in let ctxt = - Alpha_context.Origination_nonce.init ctxt Operation_hash.zero + Alpha_context.Origination_nonce.init + ctxt + Tezos_crypto.Operation_hash.zero in return (parameter, ctxt) in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_consensus_key.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_consensus_key.ml index a6769ed0648b..7e7800af4004 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_consensus_key.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_consensus_key.ml @@ -77,18 +77,18 @@ module Assert = struct let equal_pkh ~__LOC__ a b = Assert.equal ~loc:__LOC__ - Signature.Public_key_hash.equal + Tezos_crypto.Signature.Public_key_hash.equal "pkh" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp a b let equal_pk ~__LOC__ a b = Assert.equal ~loc:__LOC__ - Signature.Public_key.equal + Tezos_crypto.Signature.Public_key.equal "pk" - Signature.Public_key.pp + Tezos_crypto.Signature.Public_key.pp a b diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_contract_repr.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_contract_repr.ml index 1f7f33a7cfa6..9a758c030b67 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_contract_repr.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_contract_repr.ml @@ -47,7 +47,7 @@ module Test_contract_repr = struct open Contract_repr let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash @@ -61,7 +61,8 @@ module Test_contract_repr = struct in Contract_hash.hash_bytes [data] - let dummy_implicit_contract = Implicit Signature.Public_key_hash.zero + let dummy_implicit_contract = + Implicit Tezos_crypto.Signature.Public_key_hash.zero let dummy_originated_contract = originated_contract @@ dummy_origination_nonce @@ -72,7 +73,7 @@ module Test_contract_repr = struct "%s should have been equal to %" Format.pp_print_string (to_b58check dummy_implicit_contract) - Signature.Public_key_hash.(to_b58check zero) + Tezos_crypto.Signature.Public_key_hash.(to_b58check zero) let test_to_b58check_originated () = Assert.equal diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_destination_repr.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_destination_repr.ml index 830251241aec..fa610715c7c6 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_destination_repr.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_destination_repr.ml @@ -36,7 +36,7 @@ open Protocol open Tztest let dummy_operation_hash = - Operation_hash.of_bytes_exn + Tezos_crypto.Operation_hash.of_bytes_exn (Bytes.of_string "test-operation-hash-of-length-32") let dummy_origination_nonce = Origination_nonce.initial dummy_operation_hash diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_receipt.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_receipt.ml index 1aa4c7bce8f3..245ae17b0a54 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_receipt.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_receipt.ml @@ -68,7 +68,7 @@ let test_encodings balance = let test_encodings () = let open Receipt in - let pkh = Signature.Public_key_hash.zero in + let pkh = Tezos_crypto.Signature.Public_key_hash.zero in test_encodings (Contract (Contract.Implicit pkh)) >>=? fun () -> test_encodings Block_fees >>=? fun () -> test_encodings (Deposits pkh) >>=? fun () -> @@ -89,7 +89,8 @@ let test_encodings () = test_encodings Initial_commitments >>=? fun () -> test_encodings Minted >>=? fun () -> let nonce = - Origination_nonce.Internal_for_tests.initial Operation_hash.zero + Origination_nonce.Internal_for_tests.initial + Tezos_crypto.Operation_hash.zero in let tx_rollup = Tx_rollup.Internal_for_tests.originated_tx_rollup nonce in let bond_id = Bond_id.Tx_rollup_bond_id tx_rollup in diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_game.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_game.ml index 6e828799992d..19cbc3fe4bdb 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_game.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_game.ml @@ -59,7 +59,7 @@ let check_reason ~loc (game_result : Sc_rollup_game_repr.game_result option) s = let tick_of_int_exn n = match Tick.of_int n with None -> assert false | Some t -> t -let context_hash_of_string s = Context_hash.hash_string [s] +let context_hash_of_string s = Tezos_crypto.Context_hash.hash_string [s] let hash_string s = Sc_rollup_repr.State_hash.context_hash_to_state_hash diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml index e5f1cf1e62e0..66c69757f1e4 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml @@ -110,7 +110,7 @@ let test_encode_decode_internal_inbox_message () = let source = Result.get_ok ~loc:__LOC__ - (Signature.Public_key_hash.of_b58check + (Tezos_crypto.Signature.Public_key_hash.of_b58check "tz1RjtZUVeLhADFHDL8UwDZA6vjWWhojpu5w") in let*? (Script_typed_ir.Ty_ex_c pair_nat_ticket_string_ty) = diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_storage.ml index 1846fd0353ae..0a3889d6c408 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -60,7 +60,9 @@ let new_context_with_stakers nb_stakers = let+ inc = Incremental.begin_construction b in let ctxt = Incremental.alpha_ctxt inc in (* Necessary to originate rollups. *) - let ctxt = Alpha_context.Origination_nonce.init ctxt Operation_hash.zero in + let ctxt = + Alpha_context.Origination_nonce.init ctxt Tezos_crypto.Operation_hash.zero + in let ctxt = Alpha_context.Internal_for_tests.to_raw ctxt in let stakers = List.map @@ -76,7 +78,7 @@ let new_context () = let* ctxt, _stakers = new_context_with_stakers 1 in (* Mint some tez for staker accounts. *) let mint_tez_for ctxt pkh_str = - let pkh = Signature.Public_key_hash.of_b58check_exn pkh_str in + let pkh = Tezos_crypto.Signature.Public_key_hash.of_b58check_exn pkh_str in let contract = Contract_repr.Implicit pkh in let+ ctxt, _ = lift @@ -427,7 +429,7 @@ let test_deposit_then_withdraw () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in @@ -445,7 +447,7 @@ let test_withdraw_when_not_staked () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in assert_fails_with @@ -457,7 +459,7 @@ let test_withdrawing_twice () = let* ctxt = new_context () in let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = - Signature.Public_key_hash.of_b58check_exn + Tezos_crypto.Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker in @@ -2357,7 +2359,7 @@ let test_zero_tick_commitment_cannot_change_state () = number_of_ticks = number_of_ticks_exn 0L; compressed_state = Sc_rollup_repr.State_hash.context_hash_to_state_hash - (Context_hash.hash_string ["wxyz"]); + (Tezos_crypto.Context_hash.hash_string ["wxyz"]); } in let* () = diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2.ml index b95ed7e35c17..a2368b23c186 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2.ml @@ -518,7 +518,7 @@ module Test_batch_encodings = struct Format.fprintf fmt "@[Withdraw:@ destination=%a,@ ticket_hash=%a,@ qty:%a@]" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp destination Alpha_context.Ticket_hash.pp ticket_hash diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml index ab4b08d5ac9b..767190f5ba0e 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_tx_rollup_l2_apply.ml @@ -48,7 +48,7 @@ open Indexable (** {3. Various helpers to facilitate the tests. } *) -let pkh = Signature.Public_key_hash.zero +let pkh = Tezos_crypto.Signature.Public_key_hash.zero let ((_, pk1, addr1) as l2_addr1) = gen_l2_address () @@ -84,7 +84,7 @@ let expect_error_status ~msg error status cont = let aggregate_signature_exn : signature list -> signature = fun signatures -> - match Bls.aggregate_signature_opt signatures with + match Tezos_crypto.Bls.aggregate_signature_opt signatures with | Some res -> res | None -> raise (Invalid_argument "aggregate_signature_exn") @@ -127,7 +127,7 @@ let pp_metadata fmt Tx_rollup_l2_context_sig.{counter; public_key} = fmt "{counter=%d; public_key=%a}" counter - Bls.Public_key.pp + Tezos_crypto.Bls.Public_key.pp public_key let eq_metadata = Alcotest.of_pp pp_metadata @@ -154,7 +154,7 @@ let pp_withdrawal fmt = function Format.fprintf fmt "{claimer=%a; ticket_hash=%a; amount=%a}" - Signature.Public_key_hash.pp + Tezos_crypto.Signature.Public_key_hash.pp claimer Ticket_hash.pp ticket_hash @@ -280,7 +280,7 @@ let batch_from_transfers inputs = (fun all_sks input -> List.fold_left (fun acc (sk, _, _, _, _, _) -> - if List.mem ~equal:Bls.Secret_key.equal sk acc then acc + if List.mem ~equal:Tezos_crypto.Bls.Secret_key.equal sk acc then acc else sk :: acc) [] input diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_zk_rollup_storage.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_zk_rollup_storage.ml index f776e4c9cc6c..dfff16df2926 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_zk_rollup_storage.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_zk_rollup_storage.ml @@ -45,9 +45,9 @@ let batch_size = 10 module ZKRU = struct include Alpha_context.Zk_rollup - type pkh = Signature.Public_key_hash.t + type pkh = Tezos_crypto.Signature.Public_key_hash.t - let pkh_encoding = Signature.Public_key_hash.encoding + let pkh_encoding = Tezos_crypto.Signature.Public_key_hash.encoding type ticket_hash = Alpha_context.Ticket_hash.t @@ -103,7 +103,7 @@ module Raw_context_tests = struct ~predecessor_timestamp:b.header.shell.timestamp ~timestamp:b.header.shell.timestamp in - let nonce = Operation_hash.hash_string ["nonce_hash"] in + let nonce = Tezos_crypto.Operation_hash.hash_string ["nonce_hash"] in return (Raw_context.init_origination_nonce ctx nonce, contract) (* Context with an originated ZKRU *) @@ -141,7 +141,7 @@ module Raw_context_tests = struct let pending_list_append () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _, _ = Signature.generate_key () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. @@ -170,7 +170,7 @@ module Raw_context_tests = struct let pending_list_append_errors () = let open Lwt_result_syntax in let* ctx, rollup, _contract = originate_ctx () in - let pkh, _, _ = Signature.generate_key () in + let pkh, _, _ = Tezos_crypto.Signature.generate_key () in let op = no_ticket Zk_rollup_operation_repr. diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.ml index 9c36bf00f67a..7b683e61678b 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.ml @@ -31,7 +31,7 @@ open Alpha_context type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] type context_id = [block_id | `Context of Tx_rollup_l2_context_hash.t] @@ -62,7 +62,7 @@ let context_of_id state context_id = let construct_block_id = function | `Head -> "head" | `L2_block h -> L2block.Hash.to_b58check h - | `Tezos_block h -> Block_hash.to_b58check h + | `Tezos_block h -> Tezos_crypto.Block_hash.to_b58check h | `Level l -> L2block.level_to_string l let destruct_block_id h = @@ -76,7 +76,7 @@ let destruct_block_id h = | Error _ -> Error "Invalid rollup level" | Ok l -> Ok (`Level l)) | None -> ( - match Block_hash.of_b58check_opt h with + match Tezos_crypto.Block_hash.of_b58check_opt h with | Some b -> Ok (`Tezos_block b) | None -> ( match L2block.Hash.of_b58check_opt h with @@ -344,7 +344,8 @@ module Block = struct | None -> return_none | Some block -> ( match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) return_none | _ -> return_some block.inbox) @@ -357,9 +358,13 @@ module Block = struct | Some block -> let*? () = match block_id with - | `Tezos_block b when Block_hash.(block.header.tezos_block <> b) -> + | `Tezos_block b + when Tezos_crypto.Block_hash.(block.header.tezos_block <> b) -> (* Tezos block has no l2 inbox *) - error_with "The tezos block (%a) has not L2 inbox" Block_hash.pp b + error_with + "The tezos block (%a) has not L2 inbox" + Tezos_crypto.Block_hash.pp + b | _ -> ok () in let*? () = @@ -413,7 +418,7 @@ module Context_RPC = struct type address_metadata = { index : Tx_rollup_l2_context_sig.address_index; counter : int64; - public_key : Bls.Public_key.t; + public_key : Tezos_crypto.Bls.Public_key.t; } let address_metadata_encoding = @@ -424,7 +429,7 @@ module Context_RPC = struct @@ obj3 (req "index" Tx_rollup_l2_address.Indexable.index_encoding) (req "counter" int64) - (req "public_key" Bls.Public_key.encoding)) + (req "public_key" Tezos_crypto.Bls.Public_key.encoding)) let balance = Tezos_rpc.Service.get_service @@ -496,7 +501,7 @@ module Context_RPC = struct "Get the BLS public key associated to the given address, or null if \ the address has not performed any transfer or withdraw on the rollup." ~query:Tezos_rpc.Query.empty - ~output:(Data_encoding.option Bls.Public_key.encoding) + ~output:(Data_encoding.option Tezos_crypto.Bls.Public_key.encoding) Tezos_rpc.Path.( path / "addresses" /: Arg.address_indexable / "public_key") diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.mli index f15657a1fca1..e3062f64be6b 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/RPC.mli @@ -30,7 +30,7 @@ open Protocol type block_id = [ `Head | `L2_block of L2block.hash - | `Tezos_block of Block_hash.t + | `Tezos_block of Tezos_crypto.Block_hash.t | `Level of L2block.level ] val destruct_block_id : string -> (block_id, string) result diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/accuser.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/accuser.mli index 3183dc73ad38..23e56026d7d4 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/accuser.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/accuser.mli @@ -40,7 +40,7 @@ val build_rejection : (** [reject_bad_commitment ~source state commitment] injects a rejection operation with [source] if the [commitment] is rejectable. *) val reject_bad_commitment : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> Tx_rollup_commitment.Full.t -> unit tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.ml index b0dce397ccf0..e3e6d0786461 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.ml @@ -33,7 +33,7 @@ type state = { constants : Constants.t; batch_burn_limit : Tez.t option; index : Context.index; - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; transactions : Tx_queue.t; mutable incr_context : Context.t; lock : Lwt_mutex.t; @@ -158,7 +158,7 @@ let on_register state ~apply (tr : L2_transaction.t) = let open Lwt_result_syntax in Lwt_mutex.with_lock state.lock @@ fun () -> let*? aggregated_signature = - match Bls.aggregate_signature_opt tr.signatures with + match Tezos_crypto.Bls.aggregate_signature_opt tr.signatures with | Some s -> ok s | None -> error_with "could not aggregate signatures of transaction" in @@ -241,7 +241,7 @@ module Types = struct type nonrec state = state type parameters = { - signer : Signature.public_key_hash; + signer : Tezos_crypto.Signature.public_key_hash; index : Context.index; constants : Constants.t; batch_burn_limit : Tez.t option; diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.mli index a421b1abce55..6a287c15683f 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/batcher.mli @@ -28,7 +28,7 @@ open Alpha_context (** Initialize the internal state of the batcher. *) val init : rollup:Tx_rollup.t -> - signer:Signature.public_key_hash -> + signer:Tezos_crypto.Signature.public_key_hash -> batch_burn_limit:Tez.t option -> Context.index -> Constants.t -> diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/context.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/context.ml index d34031bfb9ac..bf3f172fc419 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/context.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/context.ml @@ -88,10 +88,12 @@ end include Protocol.Tx_rollup_l2_context.Make (Irmin_storage) let context_hash_to_l2 hash = - Context_hash.to_bytes hash |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn + Tezos_crypto.Context_hash.to_bytes hash + |> Protocol.Tx_rollup_l2_context_hash.of_bytes_exn let l2_to_context_hash hash = - Protocol.Tx_rollup_l2_context_hash.to_bytes hash |> Context_hash.of_bytes_exn + Protocol.Tx_rollup_l2_context_hash.to_bytes hash + |> Tezos_crypto.Context_hash.of_bytes_exn let exists index hash = Raw.exists index (l2_to_context_hash hash) @@ -223,7 +225,7 @@ let init_context index = let* tree = Prover_context.Ticket_index.init_counter tree in let tree_hash = hash_tree tree in assert ( - Context_hash.( + Tezos_crypto.Context_hash.( tree_hash = Protocol.Tx_rollup_message_result_repr.empty_l2_context_hash)) ; let* ctxt, _ = add_tree ctxt tree in return ctxt diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/context.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/context.mli index 5c781082268d..154f5818a386 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/context.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/context.mli @@ -119,7 +119,7 @@ val produce_proof : (tree -> 'a produce_proof_result Lwt.t) -> (Protocol.Tx_rollup_l2_proof.t * 'a produce_proof_result) tzresult Lwt.t -val hash_tree : tree -> Context_hash.t +val hash_tree : tree -> Tezos_crypto.Context_hash.t (** [add_tree ctxt tree] adds [tree] in the [ctxt]. In order to perform actions on the tree (e.g. proof production), it needs to be persistent. Thus, @@ -133,7 +133,7 @@ val hash_tree : tree -> Context_hash.t val add_tree : context -> tree -> (context * Protocol.Tx_rollup_l2_context_hash.t) Lwt.t -val tree_hash_of_context : context -> Context_hash.t tzresult Lwt.t +val tree_hash_of_context : context -> Tezos_crypto.Context_hash.t tzresult Lwt.t (** {2 Sub-context for tickets } *) diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/dispatcher.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/dispatcher.mli index 7b23a612ab55..e143b73b8ceb 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/dispatcher.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/dispatcher.mli @@ -26,7 +26,7 @@ (** Produce dispatch of withdrawals operations and sends them to the injector. *) val dispatch_withdrawals : - source:Signature.Public_key_hash.t -> + source:Tezos_crypto.Signature.Public_key_hash.t -> State.t -> L2block.t -> unit tzresult Lwt.t diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/dune b/src/proto_015_PtLimaPt/lib_tx_rollup/dune index 42d177484f5b..337fa04d0e65 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/dune +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/dune @@ -35,7 +35,6 @@ -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base - -open Tezos_crypto -open Tezos_protocol_015_PtLimaPt -open Tezos_client_015_PtLimaPt -open Tezos_client_commands diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/error.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/error.ml index 13277743addf..5e95ec3c32f2 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/error.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/error.ml @@ -217,8 +217,8 @@ let () = type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } let () = @@ -233,15 +233,15 @@ let () = ppf "Rollup origination on disk (%a) is different from the provided rollup \ genesis (%a)" - Block_hash.pp + Tezos_crypto.Block_hash.pp disk_rollup - Block_hash.pp + Tezos_crypto.Block_hash.pp given_rollup) `Permanent Data_encoding.( obj2 - (req "disk_rollup" Block_hash.encoding) - (req "given_rollup" Block_hash.encoding)) + (req "disk_rollup" Tezos_crypto.Block_hash.encoding) + (req "given_rollup" Tezos_crypto.Block_hash.encoding)) (function | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis} -> @@ -251,7 +251,7 @@ let () = Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis {disk_rollup_origination; given_rollup_genesis}) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -264,10 +264,10 @@ let () = "The operation receipt of %a is unavailable. Please make sure that the \ history mode of the Tezos node you are connecting to matches the \ requirements." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "context" Operation_hash.encoding)) + Data_encoding.(obj1 (req "context" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_no_operation_metadata o -> Some o | _ -> None) (fun o -> Tx_rollup_no_operation_metadata o) @@ -287,7 +287,7 @@ let () = (function Tx_rollup_mismatch -> Some () | _ -> None) (fun () -> Tx_rollup_mismatch) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t let () = register_error_kind @@ -298,10 +298,10 @@ let () = Format.fprintf ppf "The Tezos block %a cannot be fetched from the node." - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent - Data_encoding.(obj1 (req "block" Block_hash.encoding)) + Data_encoding.(obj1 (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_cannot_fetch_tezos_block b -> Some b | _ -> None) (fun b -> Tx_rollup_cannot_fetch_tezos_block b) @@ -396,7 +396,7 @@ let () = type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t let () = register_error_kind @@ -409,13 +409,13 @@ let () = "No inbox on L1 for rollup level %a at block %a" Protocol.Alpha_context.Tx_rollup_level.pp l - Block_hash.pp + Tezos_crypto.Block_hash.pp b) `Permanent Data_encoding.( obj2 (req "level" Protocol.Alpha_context.Tx_rollup_level.encoding) - (req "block" Block_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding)) (function Tx_rollup_no_proto_inbox (l, b) -> Some (l, b) | _ -> None) (fun (l, b) -> Tx_rollup_no_proto_inbox (l, b)) @@ -543,7 +543,7 @@ let () = (function Tx_rollup_deposit_not_allowed -> Some () | _ -> None) (fun () -> Tx_rollup_deposit_not_allowed) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t let () = register_error_kind @@ -555,10 +555,10 @@ let () = ppf "The deposit for our operator was slashed in operation %a. Aborting to \ investigate." - Operation_hash.pp + Tezos_crypto.Operation_hash.pp op) `Permanent - Data_encoding.(obj1 (req "operation" Operation_hash.encoding)) + Data_encoding.(obj1 (req "operation" Tezos_crypto.Operation_hash.encoding)) (function Tx_rollup_deposit_slashed o -> Some o | _ -> None) (fun o -> Tx_rollup_deposit_slashed o) diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/error.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/error.mli index 5c396b5a3671..2d2f7286b60f 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/error.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/error.mli @@ -69,18 +69,18 @@ type error += Tx_rollup_no_rollup_info_on_disk_and_no_rollup_genesis_given different from the given rollup genesis. *) type error += | Tx_rollup_different_disk_stored_origination_rollup_and_given_rollup_genesis of { - disk_rollup_origination : Block_hash.t; - given_rollup_genesis : Block_hash.t; + disk_rollup_origination : Tezos_crypto.Block_hash.t; + given_rollup_genesis : Tezos_crypto.Block_hash.t; } (** Error when operation metadata is not available. *) -type error += Tx_rollup_no_operation_metadata of Operation_hash.t +type error += Tx_rollup_no_operation_metadata of Tezos_crypto.Operation_hash.t (** Error when rollup stored on disk is different from the expected one. *) type error += Tx_rollup_mismatch (** Error when Tezos block cannot be fetched. *) -type error += Tx_rollup_cannot_fetch_tezos_block of Block_hash.t +type error += Tx_rollup_cannot_fetch_tezos_block of Tezos_crypto.Block_hash.t (** Error when the tree is not found in the context. *) type error += Tx_rollup_tree_not_found @@ -102,7 +102,7 @@ type error += (** Error when the tezos node does not know the inbox *) type error += | Tx_rollup_no_proto_inbox of - Protocol.Alpha_context.Tx_rollup_level.t * Block_hash.t + Protocol.Alpha_context.Tx_rollup_level.t * Tezos_crypto.Block_hash.t (** Error when the node reconstructed a different inbox than the one stored on L1 *) type error += @@ -131,6 +131,6 @@ type error += type error += Tx_rollup_deposit_not_allowed (** Error (fatal) when we are slashed *) -type error += Tx_rollup_deposit_slashed of Operation_hash.t +type error += Tx_rollup_deposit_slashed of Tezos_crypto.Operation_hash.t type error += Wrong_deposit_parameters diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/event.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/event.ml index e97224f42dfc..9a64f9f15734 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/event.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/event.ml @@ -101,7 +101,7 @@ let new_block = ~name:"tx_rollup_node_new_block" ~msg:"new block with hash: {block_hash}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block = declare_2 @@ -109,8 +109,8 @@ let processing_block = ~name:"tx_rollup_node_processing_block" ~msg:"processing block: {block_hash} (pred: {predecessor_hash})" ~level:Debug - ("block_hash", Block_hash.encoding) - ("predecessor_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) let missing_blocks = declare_1 @@ -126,7 +126,7 @@ let look_for_origination = ~name:"tx_rollup_node_look_for_origination" ~msg:"Looking for rollup origination in block {block} level {level}" ~level:Notice - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let detected_origination = @@ -136,7 +136,7 @@ let detected_origination = ~msg:"Detected rollup {rollup} origination in {block}" ~level:Notice ("rollup", Protocol.Alpha_context.Tx_rollup.encoding) - ("block", Block_hash.encoding) + ("block", Tezos_crypto.Block_hash.encoding) let tezos_block_processed = declare_2 @@ -144,7 +144,7 @@ let tezos_block_processed = ~name:"tx_rollup_node_tezos_block_processed" ~msg:"tezos block {block_hash} at level {level} was sucessfully processed" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("level", Data_encoding.int32) let block_already_processed = @@ -155,7 +155,7 @@ let block_already_processed = "the block {block_hash} has already been processed, nothing more to be \ done" ~level:Debug - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) let processing_block_predecessor = declare_2 @@ -165,7 +165,7 @@ let processing_block_predecessor = "processing block predecessor {predecessor_hash} at level \ {predecessor_level}" ~level:Debug - ("predecessor_hash", Block_hash.encoding) + ("predecessor_hash", Tezos_crypto.Block_hash.encoding) ("predecessor_level", Data_encoding.int32) let messages_application = @@ -184,7 +184,7 @@ let rollup_block = ~level:Notice ("level", L2block.level_encoding) ("hash", L2block.Hash.encoding) - ("tezos_hash", Block_hash.encoding) + ("tezos_hash", Tezos_crypto.Block_hash.encoding) let inbox_stored = declare_4 @@ -194,7 +194,7 @@ let inbox_stored = "an inbox with size {cumulated_size} and resulting context hash \ {context_hash} has been stored for {block_hash}: {messages}" ~level:Notice - ("block_hash", Block_hash.encoding) + ("block_hash", Tezos_crypto.Block_hash.encoding) ("messages", Data_encoding.list Inbox.message_encoding) ("cumulated_size", Data_encoding.int31) ("context_hash", Protocol.Tx_rollup_l2_context_hash.encoding) @@ -213,7 +213,7 @@ let new_tezos_head = ~name:"tx_rollup_node_new_tezos_head" ~msg:"a new tezos head ({tezos_head}) is stored" ~level:Notice - ("tezos_head", Block_hash.encoding) + ("tezos_head", Tezos_crypto.Block_hash.encoding) let inject_wait = declare_1 diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/fancy_l2block.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/fancy_l2block.ml index caf3d41391aa..196a618b57d6 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/fancy_l2block.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/fancy_l2block.ml @@ -102,7 +102,7 @@ let signer_value ctxt signer = | Left _ -> assert false) | Right Tx_rollup_l2_batch.(L2_addr _) -> return signer | Right Tx_rollup_l2_batch.(Bls_pk pk) -> - let addr = Bls.Public_key.hash pk in + let addr = Tezos_crypto.Bls.Public_key.hash pk in return (value (Tx_rollup_l2_batch.L2_addr addr) |> forget) let transaction_replace_indexes ctxt transaction = @@ -280,7 +280,7 @@ let l2_message_encoding = (req "result" transaction_result_encoding)))) (req "withdrawals" (list Tx_rollup_withdraw.encoding)) (req "indexes" indexes_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Ok_batch { @@ -314,7 +314,7 @@ let l2_message_encoding = "transactions" (list Tx_rollup_l2_batch.V1.transaction_encoding)) (req "errors" Error_monad.trace_encoding) - (req "aggregated_signature" Bls.encoding)) + (req "aggregated_signature" Tezos_crypto.Bls.encoding)) (function | Failing_batch {transactions; reasons; aggregated_signature} -> Some (transactions, reasons, aggregated_signature) diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.ml index 0129b636d665..40bdec5a250a 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.ml @@ -34,7 +34,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; } type message = { @@ -71,7 +71,7 @@ let l2_context_hash_encoding = (fun (irmin_hash, tree_hash) -> {irmin_hash; tree_hash}) (obj2 (req "irmin_hash" Tx_rollup_l2_context_hash.encoding) - (req "tree_hash" Context_hash.encoding)) + (req "tree_hash" Tezos_crypto.Context_hash.encoding)) let message_encoding = let open Data_encoding in diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.mli index 58798b6a839f..9b874b09d866 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/inbox.mli @@ -41,7 +41,7 @@ type message_result = type l2_context_hash = { irmin_hash : Tx_rollup_l2_context_hash.t; (** The context hash of the commited context, used for checkout *) - tree_hash : Context_hash.t; + tree_hash : Tezos_crypto.Context_hash.t; (** The tree hash is the hash of the underlying tree in the {!Context}, used to produce proofs *) } diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.ml index e772948c9265..15aa8a7e9041 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.ml @@ -38,13 +38,13 @@ let encoding = (fun (transaction, signatures) -> {transaction; signatures}) @@ obj2 (req "transaction" Tx_rollup_l2_batch.V1.transaction_encoding) - (req "signatures" (list Bls.encoding)) + (req "signatures" (list Tezos_crypto.Bls.encoding)) let batch l = let contents = List.map (fun {transaction; _} -> transaction) l in let aggregated_signature = List.concat_map (fun {signatures; _} -> signatures) l - |> Bls.aggregate_signature_opt + |> Tezos_crypto.Bls.aggregate_signature_opt in match aggregated_signature with | None -> error_with "Cannot aggregate signatures" @@ -52,8 +52,8 @@ let batch l = ok Tx_rollup_l2_batch.(V1 V1.{contents; aggregated_signature}) module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_transaction_hash" @@ -64,7 +64,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "txL2" 54 type hash = Hash.t diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.mli index ac8ffa3bdfd9..d431b65218d6 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/l2_transaction.mli @@ -34,7 +34,7 @@ type t = { } (** Hash with b58check encoding txL2(54), for hashes of L2 transactions *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for transaction hash *) type hash = Hash.t diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.ml index f3a7cce3aa7d..aa1f6ff01081 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.ml @@ -27,8 +27,8 @@ open Protocol open Alpha_context module Hash = - Blake2B.Make - (Base58) + Tezos_crypto.Blake2B.Make + (Tezos_crypto.Base58) (struct let name = "tx_rollup_l2_block_hash" @@ -39,7 +39,8 @@ module Hash = let size = None end) -let () = Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 +let () = + Tezos_crypto.Base58.check_encoded_prefix Hash.b58check_encoding "BTx" 53 type hash = Hash.t @@ -47,7 +48,7 @@ type level = Tx_rollup_level.t type header = { level : level; - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; predecessor : hash option; context : Tx_rollup_l2_context_hash.t; commitment : Tx_rollup_commitment_hash.t; @@ -63,8 +64,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } type metadata = { @@ -85,7 +86,7 @@ let header_encoding = {level; tezos_block; predecessor; context; commitment}) (obj5 (req "level" Tx_rollup_level.encoding) - (req "tezos_block" Block_hash.encoding) + (req "tezos_block" Tezos_crypto.Block_hash.encoding) (opt "predecessor" Hash.encoding) (req "context" Tx_rollup_l2_context_hash.encoding) (req "commitment" Tx_rollup_commitment_hash.encoding)) @@ -109,8 +110,8 @@ let commitment_included_info_encoding = (fun {block; operation} -> (block, operation)) (fun (block, operation) -> {block; operation}) (obj2 - (req "block" Block_hash.encoding) - (req "operation" Operation_hash.encoding)) + (req "block" Tezos_crypto.Block_hash.encoding) + (req "operation" Tezos_crypto.Operation_hash.encoding)) let metadata_encoding = let open Data_encoding in diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.mli index f7ee52d66544..a5176b6a5db6 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/l2block.mli @@ -29,7 +29,7 @@ open Alpha_context (** {2 Types for L2 block and header} *) (** Hash with b58check encoding BTx(53), for hashes of L2 block headers *) -module Hash : S.HASH +module Hash : Tezos_crypto.S.HASH (** Alias for block (header) hashes *) type hash = Hash.t @@ -40,7 +40,7 @@ type level = Tx_rollup_level.t (** Type of L2 block headers *) type header = { level : level; (** The level of the L2 block *) - tezos_block : Block_hash.t; + tezos_block : Tezos_crypto.Block_hash.t; (** The Tezos block on which this L2 block in anchored, i.e. the Tezos block in which the inbox was sent *) predecessor : hash option; (** The hash predecessor L2 block *) @@ -63,8 +63,8 @@ type 'inbox block = { type t = Inbox.t block type commitment_included_info = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } (** Metadata for the block *) diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.ml index c8f905f9ad8f..80c54b6d5647 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.ml @@ -38,7 +38,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; @@ -171,28 +171,28 @@ let signers_encoding = (opt ~description:"The operator of the rollup (public key hash) if any" "operator" - Signature.Public_key_hash.encoding) + Tezos_crypto.Signature.Public_key_hash.encoding) (opt "submit_batch" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for batch submission") (opt "finalize_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for finalization of commitments") (opt "remove_commitment" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for removals of commitments") (opt "rejection" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description:"The public key hash of the signer for rejections") (opt "dispatch_withdrawals" - Signature.Public_key_hash.encoding + Tezos_crypto.Signature.Public_key_hash.encoding ~description: "The public key hash of the signer for the dispatch of withdrawals") diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.mli index ae293e66e136..31a006cc418c 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/node_config.mli @@ -50,7 +50,7 @@ type 'a purposed = { dispatch_withdrawals : 'a; } -type signers = Signature.public_key_hash option purposed +type signers = Tezos_crypto.Signature.public_key_hash option purposed type cost_caps = { fee_cap : Protocol.Alpha_context.Tez.t; diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/state.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/state.ml index c1a0193678eb..4f36987d28e2 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/state.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/state.ml @@ -33,7 +33,7 @@ module Tezos_blocks_cache = Ringo_lwt.Functors.Make_opt ((val Ringo.( map_maker ~replacement:LRU ~overflow:Strong ~accounting:Precise)) - (Block_hash)) + (Tezos_crypto.Block_hash)) type rollup_info = Stores.rollup_info = { rollup_id : Tx_rollup.t; diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/state.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/state.mli index 38850fdfb931..31f435535905 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/state.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/state.mli @@ -33,7 +33,7 @@ open Injector_common data. *) module Tezos_blocks_cache : - Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Block_hash.t + Ringo_lwt.Sigs.CACHE_MAP_OPT with type key = Tezos_crypto.Block_hash.t (** Information about the rollup that is kept in the state. *) type rollup_info = Stores.rollup_info = { @@ -102,10 +102,12 @@ val get_header : t -> L2block.hash -> L2block.header option Lwt.t there is no inbox for an L1 block, we associate to it the L2 block of its predecessor. So [get_tezos_l2_block_hash state h] returns L2 block hash at which the rollup was when the Tezos node was at block [h]. *) -val get_tezos_l2_block_hash : t -> Block_hash.t -> L2block.hash option Lwt.t +val get_tezos_l2_block_hash : + t -> Tezos_crypto.Block_hash.t -> L2block.hash option Lwt.t (** Same as {!get_tezos_block} but retrieves the associated L2 block at the same time. *) -val get_tezos_l2_block : t -> Block_hash.t -> L2block.t option Lwt.t +val get_tezos_l2_block : + t -> Tezos_crypto.Block_hash.t -> L2block.t option Lwt.t (** Same as {!get_level} but retrieves the associated header at the same time. *) val get_level_l2_block_header : @@ -119,7 +121,9 @@ val get_level_l2_block : t -> L2block.level -> L2block.t option Lwt.t block for the Tezos block, or [None] otherwise. It returns [`Unknown] when the Tezos block has never been processed. *) val tezos_block_already_processed : - t -> Block_hash.t -> [> `Known of L2block.t option | `Unknown] Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + [> `Known of L2block.t option | `Unknown] Lwt.t (** Returns the inclusion info for a commitment. *) val get_included_commitment : @@ -145,7 +149,9 @@ val set_head : t -> L2block.t -> L2block.t reorg tzresult Lwt.t (** Set the Tezos head and returns the reorganization of L1 blocks. *) val set_tezos_head : - t -> Block_hash.t -> Alpha_block_services.block_info reorg tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info reorg tzresult Lwt.t (** Save an L2 block to disk: - Save both the header and the inbox @@ -161,18 +167,18 @@ val save_level : t -> L2block.level -> L2block.hash -> unit Lwt.t predecessor as well. *) val save_tezos_block_info : t -> - Block_hash.t -> + Tezos_crypto.Block_hash.t -> L2block.hash option -> level:int32 -> - predecessor:Block_hash.t -> + predecessor:Tezos_crypto.Block_hash.t -> unit Lwt.t (** Register a commitment as included on L1. *) val set_commitment_included : t -> Tx_rollup_commitment_hash.t -> - Block_hash.t -> - Operation_hash.t -> + Tezos_crypto.Block_hash.t -> + Tezos_crypto.Operation_hash.t -> unit Lwt.t (** Register a commitment as not included on L1. *) @@ -197,7 +203,9 @@ val rollup_operation_index : int (** Fetch a Tezos block from the cache or the node *) val fetch_tezos_block : - t -> Block_hash.t -> Alpha_block_services.block_info tzresult Lwt.t + t -> + Tezos_crypto.Block_hash.t -> + Alpha_block_services.block_info tzresult Lwt.t (** Compute the reorganization of L2 blocks from the chain whose head is [old_head_hash] and the chain whose head [new_head_hash]. *) diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/stores.ml b/src/proto_015_PtLimaPt/lib_tx_rollup/stores.ml index 8b79f9b66190..2a010ab01c51 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/stores.ml +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/stores.ml @@ -308,7 +308,7 @@ end module L2_block_key = struct include L2block.Hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -358,9 +358,9 @@ module L2_level_key = struct end module Operation_key = struct - include Operation_hash + include Tezos_crypto.Operation_hash - (* [hash] in Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) + (* [hash] in Tezos_crypto.Blake2B.Make is {!Stdlib.Hashtbl.hash} which is 30 bits *) let hash_size = 30 (* in bits *) let t = @@ -461,7 +461,7 @@ module Tezos_block_info = struct type t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } let t = @@ -471,7 +471,8 @@ module Tezos_block_info = struct (fun (l2_block, level, predecessor) -> {l2_block; level; predecessor}) (fun {l2_block; level; predecessor} -> (l2_block, level, predecessor)) - let encoded_size = L2block.Hash.size + 4 (* level *) + Block_hash.size + let encoded_size = + L2block.Hash.size + 4 (* level *) + Tezos_crypto.Block_hash.size let encode v = let dst = Bytes.create encoded_size in @@ -482,7 +483,9 @@ module Tezos_block_info = struct in let offset = blit ~src:l2_block_bytes ~dst 0 in let offset = bytes_set_int32 ~dst ~src:v.level offset in - let _ = blit ~src:(Block_hash.to_bytes v.predecessor) ~dst offset in + let _ = + blit ~src:(Tezos_crypto.Block_hash.to_bytes v.predecessor) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = @@ -493,13 +496,20 @@ module Tezos_block_info = struct in let level, offset = read_int32 str offset in let predecessor, _ = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in {l2_block; level; predecessor} end module Commitment_info = struct - type t = {block : Block_hash.t; operation : Operation_hash.t} + type t = { + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; + } let t = let open Repr in @@ -508,20 +518,31 @@ module Commitment_info = struct (fun (block, operation) -> {block; operation}) (fun {block; operation} -> (block, operation)) - let encoded_size = Block_hash.size + Operation_hash.size + let encoded_size = + Tezos_crypto.Block_hash.size + Tezos_crypto.Operation_hash.size let encode v = let dst = Bytes.create encoded_size in - let offset = blit ~src:(Block_hash.to_bytes v.block) ~dst 0 in - let _ = blit ~src:(Operation_hash.to_bytes v.operation) ~dst offset in + let offset = blit ~src:(Tezos_crypto.Block_hash.to_bytes v.block) ~dst 0 in + let _ = + blit ~src:(Tezos_crypto.Operation_hash.to_bytes v.operation) ~dst offset + in Bytes.unsafe_to_string dst let decode str offset = let block, offset = - read_str str ~offset ~len:Block_hash.size Block_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Block_hash.size + Tezos_crypto.Block_hash.of_string_exn in let operation, _ = - read_str str ~offset ~len:Operation_hash.size Operation_hash.of_string_exn + read_str + str + ~offset + ~len:Tezos_crypto.Operation_hash.size + Tezos_crypto.Operation_hash.of_string_exn in {block; operation} end @@ -530,7 +551,7 @@ module Tezos_block_store = struct type value = Tezos_block_info.t = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } include @@ -548,8 +569,8 @@ module Level_store = module Commitment_store = struct type value = Commitment_info.t = { - block : Block_hash.t; - operation : Operation_hash.t; + block : Tezos_crypto.Block_hash.t; + operation : Tezos_crypto.Operation_hash.t; } include @@ -713,11 +734,11 @@ module Head_store = Make_singleton (struct end) module Tezos_head_store = Make_singleton (struct - type t = Block_hash.t + type t = Tezos_crypto.Block_hash.t let name = "tezos_head" - let encoding = Block_hash.encoding + let encoding = Tezos_crypto.Block_hash.encoding end) type rollup_info = { diff --git a/src/proto_015_PtLimaPt/lib_tx_rollup/stores.mli b/src/proto_015_PtLimaPt/lib_tx_rollup/stores.mli index 287ab3861d7c..cae8329b0109 100644 --- a/src/proto_015_PtLimaPt/lib_tx_rollup/stores.mli +++ b/src/proto_015_PtLimaPt/lib_tx_rollup/stores.mli @@ -124,10 +124,13 @@ module Tezos_block_store : sig type value = { l2_block : L2block.hash option; level : int32; - predecessor : Block_hash.t; + predecessor : Tezos_crypto.Block_hash.t; } - include INDEXABLE_STORE with type key := Block_hash.t and type value := value + include + INDEXABLE_STORE + with type key := Tezos_crypto.Block_hash.t + and type value := value end (** An index store to map L2 block level to L2 block hashes. It is composed @@ -140,9 +143,9 @@ module Level_store : (** An index store to map commitment hashes to their inclusion information. *) module Commitment_store : sig type value = { - block : Block_hash.t; + block : Tezos_crypto.Block_hash.t; (** Tezos block in which the commitment is included. *) - operation : Operation_hash.t; + operation : Tezos_crypto.Operation_hash.t; (** Operation of the block in which the commitment is included. *) } @@ -158,7 +161,8 @@ end module Head_store : SINGLETON_STORE with type value := L2block.hash (** A store composed of a single file on disk to store the current Tezos head *) -module Tezos_head_store : SINGLETON_STORE with type value := Block_hash.t +module Tezos_head_store : + SINGLETON_STORE with type value := Tezos_crypto.Block_hash.t (** Type for on disk information about a rollup *) type rollup_info = { diff --git a/src/proto_alpha/lib_benchmark/dune b/src/proto_alpha/lib_benchmark/dune index 3a29e3bb29ae..7866df984092 100644 --- a/src/proto_alpha/lib_benchmark/dune +++ b/src/proto_alpha/lib_benchmark/dune @@ -30,5 +30,6 @@ -open Tezos_benchmark -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha + -open Tezos_crypto -open Tezos_alpha_test_helpers) (private_modules kernel rules state_space)) diff --git a/src/proto_alpha/lib_benchmarks_proto/dune b/src/proto_alpha/lib_benchmarks_proto/dune index ec271df25f9f..dfd091391e1e 100644 --- a/src/proto_alpha/lib_benchmarks_proto/dune +++ b/src/proto_alpha/lib_benchmarks_proto/dune @@ -37,6 +37,7 @@ -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha -open Tezos_protocol_alpha.Protocol + -open Tezos_crypto -open Tezos_micheline -open Tezos_alpha_test_helpers -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index 8fe34ddecfc3..e3f58247522d 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/proto_alpha/lib_injector/dune @@ -26,6 +26,7 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix + -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_micheline -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_tx_rollup/dune b/src/proto_alpha/lib_tx_rollup/dune index a922e7feda9e..00d94f969ec0 100644 --- a/src/proto_alpha/lib_tx_rollup/dune +++ b/src/proto_alpha/lib_tx_rollup/dune @@ -35,6 +35,7 @@ -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base + -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_client_alpha -open Tezos_client_commands diff --git a/src/proto_demo_counter/lib_client/client_proto_commands.ml b/src/proto_demo_counter/lib_client/client_proto_commands.ml index 1ddfebc381ab..162b65edaa13 100644 --- a/src/proto_demo_counter/lib_client/client_proto_commands.ml +++ b/src/proto_demo_counter/lib_client/client_proto_commands.ml @@ -51,8 +51,8 @@ let bake (cctxt : Protocol_client_context.full) message : unit tzresult Lwt.t = let operations = [List.map snd preapply_result.applied] in Shell_services.Injection.block cctxt header_encoded operations >>=? fun block_hash -> - cctxt#message "Injected block %a" Block_hash.pp_short block_hash >>= fun () -> - return_unit + cctxt#message "Injected block %a" Tezos_crypto.Block_hash.pp_short block_hash + >>= fun () -> return_unit let operation_encoding = let open Data_encoding in @@ -63,7 +63,8 @@ let operation_encoding = let forge_op = Data_encoding.Binary.to_bytes_exn operation_encoding let inject_op (cctxt : Protocol_client_context.full) (pop : Proto_operation.t) = - Demo_block_services.hash cctxt () >>=? fun (block_hash : Block_hash.t) -> + Demo_block_services.hash cctxt () + >>=? fun (block_hash : Tezos_crypto.Block_hash.t) -> let shell_header : Operation.shell_header = Operation.{branch = block_hash} in let op : operation = {shell = shell_header; protocol_data = pop} in Demo_block_services.Helpers.Preapply.operations cctxt [op] >>=? function @@ -72,7 +73,7 @@ let inject_op (cctxt : Protocol_client_context.full) (pop : Proto_operation.t) = cctxt#message "Operation receipt: %s" receipt_str >>= fun () -> let mbytes = forge_op (shell_header, pop) in Shell_services.Injection.operation cctxt mbytes >>=? fun op_hash -> - let injected = Operation_hash.to_short_b58check op_hash in + let injected = Tezos_crypto.Operation_hash.to_short_b58check op_hash in cctxt#message "Injected: %s" injected >>= fun () -> return_unit | _ -> assert false diff --git a/src/proto_genesis/lib_client/client_proto_main.ml b/src/proto_genesis/lib_client/client_proto_main.ml index 2dfc17a716b4..d6a9e9685a83 100644 --- a/src/proto_genesis/lib_client/client_proto_main.ml +++ b/src/proto_genesis/lib_client/client_proto_main.ml @@ -32,7 +32,7 @@ let bake cctxt ?timestamp block command sk = | Some t -> t | None -> Time.System.(to_protocol (Tezos_base.Time.System.now ())) in - let protocol_data = {command; signature = Signature.zero} in + let protocol_data = {command; signature = Tezos_crypto.Signature.zero} in Genesis_block_services.Helpers.Preapply.block cctxt ~block @@ -119,7 +119,7 @@ let proto_param ~name ~desc t = ~name ~desc (Tezos_clic.parameter (fun _ str -> - Lwt.return (Protocol_hash.of_b58check str))) + Lwt.return (Tezos_crypto.Protocol_hash.of_b58check str))) t let commands () = @@ -176,8 +176,8 @@ let commands () = (Activate {protocol = hash; fitness; protocol_parameters}) sk >>=? fun hash -> - cctxt#answer "Injected %a" Block_hash.pp_short hash >>= fun () -> - return_unit); + cctxt#answer "Injected %a" Tezos_crypto.Block_hash.pp_short hash + >>= fun () -> return_unit); command ~desc:"Fork a test protocol" (args2 timestamp_arg test_delay_arg) @@ -215,8 +215,8 @@ let commands () = {protocol = hash; fitness; protocol_parameters; delay}) sk >>=? fun hash -> - cctxt#answer "Injected %a" Block_hash.pp_short hash >>= fun () -> - return_unit); + cctxt#answer "Injected %a" Tezos_crypto.Block_hash.pp_short hash + >>= fun () -> return_unit); ] let () = Client_commands.register Protocol.hash @@ fun _network -> commands () diff --git a/src/proto_genesis/lib_client/client_proto_main.mli b/src/proto_genesis/lib_client/client_proto_main.mli index d6df9e2403a3..902704cb1064 100644 --- a/src/proto_genesis/lib_client/client_proto_main.mli +++ b/src/proto_genesis/lib_client/client_proto_main.mli @@ -31,4 +31,4 @@ val bake : Shell_services.block -> Data.Command.t -> Client_keys.sk_uri -> - Block_hash.t tzresult Lwt.t + Tezos_crypto.Block_hash.t tzresult Lwt.t diff --git a/src/proto_genesis/lib_client/proxy.ml b/src/proto_genesis/lib_client/proxy.ml index 2649b7df9593..1a7f6779feed 100644 --- a/src/proto_genesis/lib_client/proxy.ml +++ b/src/proto_genesis/lib_client/proxy.ml @@ -65,7 +65,7 @@ let () = let directory = Tezos_rpc.Directory.empty let initial_context (ctx : Tezos_proxy.Proxy_getter.rpc_context_args) - (hash : Context_hash.t) = + (hash : Tezos_crypto.Context_hash.t) = let open Lwt_result_syntax in let p_rpc = (module ProtoRpc : Tezos_proxy.Proxy_proto.PROTO_RPC) in let* (module ProxyDelegation) = -- GitLab From b9dfeb4b13579c56a7ed17ba88f0fab1835481b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 11:10:50 +0200 Subject: [PATCH 22/30] manifest/protos:unopen Crypto --- manifest/main.ml | 8 ++++---- src/proto_alpha/lib_benchmark/dune | 1 - src/proto_alpha/lib_benchmarks_proto/dune | 1 - src/proto_alpha/lib_injector/dune | 1 - src/proto_alpha/lib_tx_rollup/dune | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/manifest/main.ml b/manifest/main.ml index fbba596a6d42..2ee045a9f7d1 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -4724,7 +4724,7 @@ module Protocol = Protocol |> open_; octez_base_unix; octez_stdlib_unix |> open_; - octez_crypto |> open_; + octez_crypto; main |> open_; octez_micheline |> open_; client |> if_some |> open_; @@ -4864,7 +4864,7 @@ module Protocol = Protocol octez_base |> open_ ~m:"TzPervasives" |> open_ ~m:"TzPervasives.Error_monad.Legacy_monad_globals" |> open_; - octez_crypto |> open_; + octez_crypto; main |> open_; client |> if_some |> open_; octez_client_commands |> open_; @@ -5023,7 +5023,7 @@ module Protocol = Protocol octez_benchmark |> open_; benchmark_type_inference |> if_some |> open_; main |> open_; - octez_crypto |> open_; + octez_crypto; parameters |> if_some; hashcons; test_helpers |> open_; @@ -5095,7 +5095,7 @@ module Protocol = Protocol benchmark |> if_some |> open_; benchmark_type_inference |> if_some |> open_; main |> open_ |> open_ ~m:"Protocol"; - octez_crypto |> open_; + octez_crypto; octez_shell_benchmarks; octez_micheline |> open_; test_helpers |> open_; diff --git a/src/proto_alpha/lib_benchmark/dune b/src/proto_alpha/lib_benchmark/dune index 7866df984092..3a29e3bb29ae 100644 --- a/src/proto_alpha/lib_benchmark/dune +++ b/src/proto_alpha/lib_benchmark/dune @@ -30,6 +30,5 @@ -open Tezos_benchmark -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha - -open Tezos_crypto -open Tezos_alpha_test_helpers) (private_modules kernel rules state_space)) diff --git a/src/proto_alpha/lib_benchmarks_proto/dune b/src/proto_alpha/lib_benchmarks_proto/dune index dfd091391e1e..ec271df25f9f 100644 --- a/src/proto_alpha/lib_benchmarks_proto/dune +++ b/src/proto_alpha/lib_benchmarks_proto/dune @@ -37,7 +37,6 @@ -open Tezos_benchmark_type_inference_alpha -open Tezos_protocol_alpha -open Tezos_protocol_alpha.Protocol - -open Tezos_crypto -open Tezos_micheline -open Tezos_alpha_test_helpers -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_injector/dune b/src/proto_alpha/lib_injector/dune index e3f58247522d..8fe34ddecfc3 100644 --- a/src/proto_alpha/lib_injector/dune +++ b/src/proto_alpha/lib_injector/dune @@ -26,7 +26,6 @@ -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base -open Tezos_stdlib_unix - -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_micheline -open Tezos_client_alpha diff --git a/src/proto_alpha/lib_tx_rollup/dune b/src/proto_alpha/lib_tx_rollup/dune index 00d94f969ec0..a922e7feda9e 100644 --- a/src/proto_alpha/lib_tx_rollup/dune +++ b/src/proto_alpha/lib_tx_rollup/dune @@ -35,7 +35,6 @@ -open Tezos_base.TzPervasives -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals -open Tezos_base - -open Tezos_crypto -open Tezos_protocol_alpha -open Tezos_client_alpha -open Tezos_client_commands -- GitLab From 6dbf185bbc8b191fab380394c5217ecc25542384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 26 Sep 2022 11:47:35 +0200 Subject: [PATCH 23/30] Client: unopen Crypto --- src/bin_client/client_protocols_commands.ml | 19 ++++++++++++------- src/bin_client/main_client.ml | 6 +++--- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/bin_client/client_protocols_commands.ml b/src/bin_client/client_protocols_commands.ml index e5e967625962..54f20a0d5518 100644 --- a/src/bin_client/client_protocols_commands.ml +++ b/src/bin_client/client_protocols_commands.ml @@ -31,7 +31,7 @@ let proto_param ~name ~desc t = ~name ~desc (Tezos_clic.parameter (fun _ str -> - Lwt.return (Protocol_hash.of_b58check str))) + Lwt.return (Tezos_crypto.Protocol_hash.of_b58check str))) t let commands () = @@ -51,7 +51,9 @@ let commands () = (fun () (cctxt : #Client_context.full) -> let* protos = Shell_services.Protocol.list cctxt in let*! () = - List.iter_s (fun ph -> cctxt#message "%a" Protocol_hash.pp ph) protos + List.iter_s + (fun ph -> cctxt#message "%a" Tezos_crypto.Protocol_hash.pp ph) + protos in return_unit); command @@ -78,7 +80,7 @@ let commands () = let*! () = cctxt#message "Injected protocol %a successfully" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp hash in return_unit @@ -105,12 +107,15 @@ let commands () = let* proto = Shell_services.Protocol.contents cctxt ph in let* () = Tezos_base_unix.Protocol_files.write_dir - (Protocol_hash.to_short_b58check ph) + (Tezos_crypto.Protocol_hash.to_short_b58check ph) ~hash:ph proto in let*! () = - cctxt#message "Extracted protocol %a" Protocol_hash.pp_short ph + cctxt#message + "Extracted protocol %a" + Tezos_crypto.Protocol_hash.pp_short + ph in return_unit); command @@ -125,7 +130,7 @@ let commands () = let*! () = cctxt#message "Protocol %a uses environment %s" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol_hash (Protocol.module_name_of_env_version env) in @@ -144,7 +149,7 @@ let commands () = let*! () = cctxt#message "Protocol %a successfully fetched." - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short hash in return_unit diff --git a/src/bin_client/main_client.ml b/src/bin_client/main_client.ml index 6f02d400f1e1..8574f3481d61 100644 --- a/src/bin_client/main_client.ml +++ b/src/bin_client/main_client.ml @@ -141,15 +141,15 @@ let get_commands_for_version ~timeout ctxt network chain block protocol = return (Some version, Client_commands.commands_for_version version network) | Some given_version -> - if not (Protocol_hash.equal version given_version) then + if not (Tezos_crypto.Protocol_hash.equal version given_version) then Format.eprintf "@[@{@{Warning@}@}@,\ The protocol provided via `--protocol` (%a)@,\ is not the one retrieved from the node (%a).@]@\n\ @." - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short given_version - Protocol_hash.pp_short + Tezos_crypto.Protocol_hash.pp_short version ; return ( Some version, -- GitLab From 5a500d7224c61030f6b7ca41af27b45131a48cb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 12:22:29 +0200 Subject: [PATCH 24/30] Snoop: unopen Crypto --- src/bin_snoop/cmdline.ml | 4 ++-- src/bin_snoop/commands.ml | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin_snoop/cmdline.ml b/src/bin_snoop/cmdline.ml index cf4d1f831b31..e6dd2f0e58d7 100644 --- a/src/bin_snoop/cmdline.ml +++ b/src/bin_snoop/cmdline.ml @@ -33,7 +33,7 @@ type determinizer_option = Percentile of int | Mean type storage_kind = | Memory | Disk of { - source : Signature.public_key_hash; + source : Tezos_crypto.Signature.public_key_hash; base_dir : string; header_json : string; } @@ -114,7 +114,7 @@ let storage_kind_encoding : storage_kind Data_encoding.t = case ~title:"disk" (Tag 1) - (tup3 Signature.Public_key_hash.encoding string string) + (tup3 Tezos_crypto.Signature.Public_key_hash.encoding string string) (function | Memory -> None | Disk {source; base_dir; header_json} -> diff --git a/src/bin_snoop/commands.ml b/src/bin_snoop/commands.ml index 0350880898d6..6e3a66dae9d9 100644 --- a/src/bin_snoop/commands.ml +++ b/src/bin_snoop/commands.ml @@ -84,7 +84,10 @@ module Benchmark_cmd = struct | Memory -> "Mem" | Disk {source; base_dir; header_json} -> let pp_src = - Format.asprintf "%a" Signature.Public_key_hash.pp source + Format.asprintf + "%a" + Tezos_crypto.Signature.Public_key_hash.pp + source in sprintf "Disk { source = %s ; base_dir = %s ; header_json = %s }" -- GitLab From 8b9314734f134aa0cbada987f22ee36395b0582f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 12:22:43 +0200 Subject: [PATCH 25/30] Node: unopen Crypto --- src/bin_node/node_identity_file.ml | 29 +++++++++++++++---------- src/bin_node/node_replay_command.ml | 18 +++++++-------- src/bin_node/node_run_command.ml | 4 ++-- src/bin_node/node_snapshot_command.ml | 2 +- src/bin_node/node_storage_command.ml | 8 +++---- src/lib_node_config/node_config_file.ml | 25 +++++++++++---------- 6 files changed, 46 insertions(+), 40 deletions(-) diff --git a/src/bin_node/node_identity_file.ml b/src/bin_node/node_identity_file.ml index 5710d11b371a..81b8c3e2138b 100644 --- a/src/bin_node/node_identity_file.ml +++ b/src/bin_node/node_identity_file.ml @@ -30,13 +30,13 @@ type error += Insufficient_proof_of_work of {expected : float} type error += | Identity_mismatch of { filename : string; - peer_id : Crypto_box.Public_key_hash.t; + peer_id : Tezos_crypto.Crypto_box.Public_key_hash.t; } type error += | Identity_keys_mismatch of { filename : string; - expected_key : Crypto_box.public_key; + expected_key : Tezos_crypto.Crypto_box.public_key; } let () = @@ -89,12 +89,12 @@ let () = "The current identity (public key hash) does not match the keys in %s.\n\ \ Expected identity %a." file - Crypto_box.Public_key_hash.pp + Tezos_crypto.Crypto_box.Public_key_hash.pp public_key_hash) Data_encoding.( obj2 (req "file" string) - (req "public_key_hash" Crypto_box.Public_key_hash.encoding)) + (req "public_key_hash" Tezos_crypto.Crypto_box.Public_key_hash.encoding)) (function | Identity_mismatch {filename; peer_id} -> Some (filename, peer_id) | _ -> None) @@ -115,10 +115,12 @@ let () = public key pair is not valid).\n\ \ Expected public key %a." file - Crypto_box.pp_pk + Tezos_crypto.Crypto_box.pp_pk public_key) Data_encoding.( - obj2 (req "file" string) (req "public_key" Crypto_box.public_key_encoding)) + obj2 + (req "file" string) + (req "public_key" Tezos_crypto.Crypto_box.public_key_encoding)) (function | Identity_keys_mismatch {filename; expected_key} -> Some (filename, expected_key) @@ -133,22 +135,25 @@ let read ?expected_pow filename = else let* json = Lwt_utils_unix.Json.read_file filename in let id = Data_encoding.Json.destruct P2p_identity.encoding json in - let pkh = Crypto_box.hash id.public_key in + let pkh = Tezos_crypto.Crypto_box.hash id.public_key in (* check public_key hash *) - if not (Crypto_box.Public_key_hash.equal pkh id.peer_id) then + if not (Tezos_crypto.Crypto_box.Public_key_hash.equal pkh id.peer_id) then tzfail (Identity_mismatch {filename; peer_id = pkh}) (* check public/private keys correspondence *) - else if not Crypto_box.(equal (neuterize id.secret_key) id.public_key) then + else if + not + Tezos_crypto.Crypto_box.(equal (neuterize id.secret_key) id.public_key) + then tzfail (Identity_keys_mismatch {filename; expected_key = id.public_key}) else (* check PoW level *) match expected_pow with | None -> return id | Some expected -> - let target = Crypto_box.make_pow_target expected in + let target = Tezos_crypto.Crypto_box.make_pow_target expected in if not - (Crypto_box.check_proof_of_work + (Tezos_crypto.Crypto_box.check_proof_of_work id.public_key id.proof_of_work_stamp target) @@ -211,7 +216,7 @@ let generate identity_file expected_pow = if Sys.file_exists identity_file then tzfail (Existent_identity_file identity_file) else - let target = Crypto_box.make_pow_target expected_pow in + let target = Tezos_crypto.Crypto_box.make_pow_target expected_pow in Format.eprintf "Generating a new identity... (level: %.2f) " expected_pow ; let*! id = generate_with_animation Format.err_formatter target in let* () = write identity_file id in diff --git a/src/bin_node/node_replay_command.ml b/src/bin_node/node_replay_command.ml index 258d7dcfeb17..f17d0d54742d 100644 --- a/src/bin_node/node_replay_command.ml +++ b/src/bin_node/node_replay_command.ml @@ -39,8 +39,8 @@ module Event = struct | None -> () | Some alias -> Format.fprintf fmt "%s: " alias) ("alias", Data_encoding.(option string)) - ~pp2:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp2:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) ~pp3:(fun fmt level -> Format.fprintf fmt "%ld" level) ("level", Data_encoding.int32) @@ -61,10 +61,10 @@ module Event = struct "inconsistent context hash - expected: {expected}, replay result: \ {replay_result}" ~level:Error - ~pp1:Context_hash.pp - ("expected", Context_hash.encoding) - ~pp2:Context_hash.pp - ("replay_result", Context_hash.encoding) + ~pp1:Tezos_crypto.Context_hash.pp + ("expected", Tezos_crypto.Context_hash.encoding) + ~pp2:Tezos_crypto.Context_hash.pp + ("replay_result", Tezos_crypto.Context_hash.encoding) let pp_json ppf json = Format.fprintf @@ -117,8 +117,8 @@ module Event = struct "unexpected receipts layout for block {hash} - expected: {expected}, \ replay result: {replay_result}" ~level:Error - ~pp1:Block_hash.pp - ("hash", Block_hash.encoding) + ~pp1:Tezos_crypto.Block_hash.pp + ("hash", Tezos_crypto.Block_hash.encoding) ~pp2:pp_list_lengths ("expected", Data_encoding.(list int31)) ~pp3:pp_list_lengths @@ -254,7 +254,7 @@ let replay_one_block strict main_chain_store validator_process block = let* () = when_ (not - (Context_hash.equal + (Tezos_crypto.Context_hash.equal expected_context_hash result.validation_store.context_hash)) (fun () -> diff --git a/src/bin_node/node_run_command.ml b/src/bin_node/node_run_command.ml index a3e560da5002..0598505dbf8e 100644 --- a/src/bin_node/node_run_command.ml +++ b/src/bin_node/node_run_command.ml @@ -294,7 +294,7 @@ let init_node ?sandbox ?target ~identity ~singleprocess reconnection_config = config.p2p.reconnection_config; identity; proof_of_work_target = - Crypto_box.make_pow_target config.p2p.expected_pow; + Tezos_crypto.Crypto_box.make_pow_target config.p2p.expected_pow; trust_discovered_peers = sandbox <> None; } in @@ -626,7 +626,7 @@ let process sandbox verbosity target singleprocess force_history_mode_switch let target = match l with | [block_hash; level] -> - ( Block_hash.of_b58check_exn block_hash, + ( Tezos_crypto.Block_hash.of_b58check_exn block_hash, Int32.of_string level ) | _ -> assert false in diff --git a/src/bin_node/node_snapshot_command.ml b/src/bin_node/node_snapshot_command.ml index fc6d0a22af18..f789ec6d75aa 100644 --- a/src/bin_node/node_snapshot_command.ml +++ b/src/bin_node/node_snapshot_command.ml @@ -251,7 +251,7 @@ module Term = struct let* block = match block with | Some s -> ( - match Block_hash.of_b58check_opt s with + match Tezos_crypto.Block_hash.of_b58check_opt s with | Some bh -> return_some bh | None -> failwith "%s is not a valid block identifier." s) | None -> return_none diff --git a/src/bin_node/node_storage_command.ml b/src/bin_node/node_storage_command.ml index cc35fd437f81..298fe6b06ddd 100644 --- a/src/bin_node/node_storage_command.ml +++ b/src/bin_node/node_storage_command.ml @@ -122,7 +122,7 @@ module Term = struct Context.Checks.Pack.Reconstruct_index.run ~root ~output ~index_log_size () ; return_unit) - let to_context_hash chain_store (hash : Block_hash.t) = + let to_context_hash chain_store (hash : Tezos_crypto.Block_hash.t) = let open Lwt_result_syntax in let* block = Store.Block.read_block chain_store hash in return (Store.Block.context_hash block) @@ -140,19 +140,19 @@ module Term = struct Store.init ~store_dir ~context_dir ~allow_testchains:false genesis in let genesis = cfg.blockchain_network.genesis in - let chain_id = Chain_id.of_block_hash genesis.block in + let chain_id = Tezos_crypto.Chain_id.of_block_hash genesis.block in let* chain_store = Store.get_chain_store store chain_id in let to_context_hash = to_context_hash chain_store in let* block_hash = match block with - | Some block -> Lwt.return (Block_hash.of_b58check block) + | Some block -> Lwt.return (Tezos_crypto.Block_hash.of_b58check block) | None -> let*! head = Store.Chain.current_head chain_store in return (Store.Block.hash head) in let* context_hash = to_context_hash block_hash in let*! () = Store.close_store store in - return (Context_hash.to_b58check context_hash) + return (Tezos_crypto.Context_hash.to_b58check context_hash) let integrity_check_inodes config_file data_dir block = Node_shared_arg.process_command diff --git a/src/lib_node_config/node_config_file.ml b/src/lib_node_config/node_config_file.ml index 7522fbae41f9..b4d5a10fb668 100644 --- a/src/lib_node_config/node_config_file.ml +++ b/src/lib_node_config/node_config_file.ml @@ -70,12 +70,13 @@ let make_blockchain_network ~alias ~chain_name ?old_chain_name sandboxed_chain_name = of_string sandboxed_chain_name; user_activated_upgrades = List.map - (fun (l, h) -> (l, Protocol_hash.of_b58check_exn h)) + (fun (l, h) -> (l, Tezos_crypto.Protocol_hash.of_b58check_exn h)) user_activated_upgrades; user_activated_protocol_overrides = List.map (fun (a, b) -> - (Protocol_hash.of_b58check_exn a, Protocol_hash.of_b58check_exn b)) + ( Tezos_crypto.Protocol_hash.of_b58check_exn a, + Tezos_crypto.Protocol_hash.of_b58check_exn b )) user_activated_protocol_overrides; default_bootstrap_peers; } @@ -102,10 +103,10 @@ let blockchain_network_mainnet = { time = Time.Protocol.of_notation_exn "2018-06-30T16:07:32Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } ~chain_name:"TEZOS_MAINNET" @@ -131,10 +132,10 @@ let blockchain_network_ghostnet = { time = Time.Protocol.of_notation_exn "2022-01-25T15:00:00Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesis1db77eJNeJ9"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } ~genesis_parameters: @@ -172,10 +173,10 @@ let blockchain_network_limanet = { time = Time.Protocol.of_notation_exn "2022-10-13T15:00:00Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BL3LAGwnWoNFM2H5ZA3Mbd622CVWMe8Kzfkksws4roKDD9WwBmf"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } ~genesis_parameters: @@ -207,10 +208,10 @@ let blockchain_network_kathmandunet = { time = Time.Protocol.of_notation_exn "2022-07-28T15:00:00Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLPZJvbTNPG2kgX97n2eCzPAFicqbxZNWSf6BkWsud5uihNua3a"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } ~genesis_parameters: @@ -241,10 +242,10 @@ let blockchain_network_sandbox = { time = Time.Protocol.of_notation_exn "2018-06-30T16:07:32Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im"; } ~genesis_parameters: -- GitLab From d78e9967c27391f3a8659c7b436093c41e88b3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 12:25:24 +0200 Subject: [PATCH 26/30] Docgen: unopen Crypto --- docs/doc_gen/node_helpers.ml | 4 ++-- docs/doc_gen/p2p_doc.ml | 2 +- docs/doc_gen/rpc_doc.ml | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/doc_gen/node_helpers.ml b/docs/doc_gen/node_helpers.ml index c51ee26a54bc..ad9916fdde94 100644 --- a/docs/doc_gen/node_helpers.ml +++ b/docs/doc_gen/node_helpers.ml @@ -27,10 +27,10 @@ let genesis : Genesis.t = { time = Time.Protocol.of_notation_exn "2018-04-17T11:46:23Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisa52f8bUWPcg"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "ProtoGenesisGenesisGenesisGenesisGenesisGenesk612im"; } diff --git a/docs/doc_gen/p2p_doc.ml b/docs/doc_gen/p2p_doc.ml index dbe39a52365f..4c74aee57948 100644 --- a/docs/doc_gen/p2p_doc.ml +++ b/docs/doc_gen/p2p_doc.ml @@ -56,7 +56,7 @@ let main () = (Data_encoding.Binary.describe Operation.encoding) ; List.iter (fun (_name, hash) -> - let hash = Protocol_hash.of_b58check_exn hash in + let hash = Tezos_crypto.Protocol_hash.of_b58check_exn hash in let (module Proto) = match Registered_protocol.get hash with | None -> assert false diff --git a/docs/doc_gen/rpc_doc.ml b/docs/doc_gen/rpc_doc.ml index 1e0aa910cb6a..956696aab291 100644 --- a/docs/doc_gen/rpc_doc.ml +++ b/docs/doc_gen/rpc_doc.ml @@ -383,14 +383,17 @@ let make_index node required_version = let protocol_dirs = List.map (fun (version, name, intro, hash) -> - let hash = Protocol_hash.of_b58check_exn hash in + let hash = Tezos_crypto.Protocol_hash.of_b58check_exn hash in let (module Proto) = match Registered_protocol.get hash with | None -> (* This is probably an indication that a line for the requested protocol is missing in the dune file of this repository *) - Format.eprintf "Hash not found: %a" Protocol_hash.pp hash ; + Format.eprintf + "Hash not found: %a" + Tezos_crypto.Protocol_hash.pp + hash ; assert false | Some proto -> proto in -- GitLab From 735813def80e83d4083b48e27ad6c91a50ba0faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 14:08:29 +0200 Subject: [PATCH 27/30] Tezt: unopen Crypto --- tezt/lib_tezos/operation_core.ml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tezt/lib_tezos/operation_core.ml b/tezt/lib_tezos/operation_core.ml index 575479ff13ef..2ab37fe4622d 100644 --- a/tezt/lib_tezos/operation_core.ml +++ b/tezt/lib_tezos/operation_core.ml @@ -81,15 +81,14 @@ module Tezos_operation = Tezos_base.TzPervasives.Operation let to_raw_operation t client : Tezos_operation.t Lwt.t = let open Tezos_base.TzPervasives in - let branch = Block_hash.of_b58check_exn t.branch in + let branch = Tezos_crypto.Block_hash.of_b58check_exn t.branch in let* raw = hex t client in return Tezos_operation.{shell = {branch}; proto = Hex.to_bytes_exn raw} let hash t client : [`OpHash of string] Lwt.t = - let open Tezos_base.TzPervasives in let* op = to_raw_operation t client in let hash = Tezos_operation.hash op in - return (`OpHash (Operation_hash.to_string hash)) + return (`OpHash (Tezos_crypto.Operation_hash.to_string hash)) let inject ?(request = `Inject) ?(force = false) ?signature ?error t client : [`OpHash of string] Lwt.t = -- GitLab From f4fa7576b6fd116ec6993866231826ae916a3891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 14:08:42 +0200 Subject: [PATCH 28/30] devtools: unopen Crypto --- devtools/get_contracts/config.ml | 12 +++---- devtools/get_contracts/get_contracts.ml | 19 +++++++---- devtools/yes_wallet/sigs.ml | 12 +++---- .../yes_wallet/test/bench_signature_perf.ml | 34 ++++++++++++------- devtools/yes_wallet/yes_wallet_lib.ml | 20 ++++++----- 5 files changed, 57 insertions(+), 40 deletions(-) diff --git a/devtools/get_contracts/config.ml b/devtools/get_contracts/config.ml index 640771aab63f..5cc0564a541a 100644 --- a/devtools/get_contracts/config.ml +++ b/devtools/get_contracts/config.ml @@ -40,10 +40,10 @@ let mainnet_genesis = { time = Time.Protocol.of_notation_exn "2018-06-30T16:07:32Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } @@ -52,10 +52,10 @@ let jakartanet_genesis = { time = Time.Protocol.of_notation_exn "2022-04-27T15:00:00Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisbd16dciJxo9"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } @@ -64,10 +64,10 @@ let ghostnet_genesis = { time = Time.Protocol.of_notation_exn "2022-01-25T15:00:00Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesis1db77eJNeJ9"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } diff --git a/devtools/get_contracts/get_contracts.ml b/devtools/get_contracts/get_contracts.ml index e874667c402d..a530eb42b972 100644 --- a/devtools/get_contracts/get_contracts.ml +++ b/devtools/get_contracts/get_contracts.ml @@ -553,7 +553,11 @@ module Make (P : Sigs.PROTOCOL) : Sigs.MAIN = struct let main ~output_dir ctxt ~head : unit tzresult Lwt.t = let open Lwt_result_syntax in let head_hash, head_level = Tezos_store.Store.Block.descriptor head in - Format.printf "Head is %a, level %ld\n%!" Block_hash.pp head_hash head_level ; + Format.printf + "Head is %a, level %ld\n%!" + Tezos_crypto.Block_hash.pp + head_hash + head_level ; let predecessor_timestamp = Tezos_store.Store.Block.timestamp head in let timestamp = Time.Protocol.add predecessor_timestamp 10000L in print_endline "Preparing raw context..." ; @@ -722,14 +726,14 @@ let get_main proto_hash = match List.find (fun (module Proto : Sigs.PROTOCOL) -> - Protocol_hash.(Proto.hash = proto_hash)) + Tezos_crypto.Protocol_hash.(Proto.hash = proto_hash)) (Known_protocols.get_all ()) with | None -> Format.kasprintf invalid_arg "Unknown protocol: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp proto_hash | Some (module Proto) -> let module Main = Make (Proto) in @@ -778,16 +782,19 @@ let commands = Printf.printf "Getting main chain storage and head...\n%!" ; let chain_store = Tezos_store.Store.main_chain_store store in let chain_id = Tezos_store.Store.Chain.chain_id chain_store in - Format.printf "Chain id: %a\n%!" Chain_id.pp chain_id ; + Format.printf "Chain id: %a\n%!" Tezos_crypto.Chain_id.pp chain_id ; let*! head = Tezos_store.Store.Chain.current_head chain_store in Format.printf "Head block: %a\n%!" - Block_hash.pp + Tezos_crypto.Block_hash.pp (Tezos_store.Store.Block.hash head) ; let* proto_hash = Tezos_store.Store.Block.protocol_hash chain_store head in - Format.printf "Protocol hash: %a\n%!" Protocol_hash.pp proto_hash ; + Format.printf + "Protocol hash: %a\n%!" + Tezos_crypto.Protocol_hash.pp + proto_hash ; let*! ctxt = Tezos_store.Store.Block.context_exn chain_store head in print_endline "Pre-preparing raw context..." ; let (module Main : Sigs.MAIN) = get_main proto_hash in diff --git a/devtools/yes_wallet/sigs.ml b/devtools/yes_wallet/sigs.ml index 4ac28e64d714..c2221bf854e7 100644 --- a/devtools/yes_wallet/sigs.ml +++ b/devtools/yes_wallet/sigs.ml @@ -43,22 +43,22 @@ module type PROTOCOL = sig context -> order:[`Sorted | `Undefined] -> init:'a -> - f:(Signature.public_key_hash -> 'a -> 'a Lwt.t) -> + f:(Tezos_crypto.Signature.public_key_hash -> 'a -> 'a Lwt.t) -> 'a Lwt.t val pubkey : context -> - Signature.public_key_hash -> - Signature.public_key tzresult Lwt.t + Tezos_crypto.Signature.public_key_hash -> + Tezos_crypto.Signature.public_key tzresult Lwt.t val staking_balance : - context -> Signature.public_key_hash -> Tez.t tzresult Lwt.t + context -> Tezos_crypto.Signature.public_key_hash -> Tez.t tzresult Lwt.t val deactivated : - context -> Signature.public_key_hash -> bool tzresult Lwt.t + context -> Tezos_crypto.Signature.public_key_hash -> bool tzresult Lwt.t end - val hash : Protocol_hash.t + val hash : Tezos_crypto.Protocol_hash.t val prepare_context : Tezos_protocol_environment.Context.t -> diff --git a/devtools/yes_wallet/test/bench_signature_perf.ml b/devtools/yes_wallet/test/bench_signature_perf.ml index 074786d8d2d0..eaa5c48e18f9 100644 --- a/devtools/yes_wallet/test/bench_signature_perf.ml +++ b/devtools/yes_wallet/test/bench_signature_perf.ml @@ -29,16 +29,22 @@ let time f = (stop -. start, res) let keys = - let keys_p = Signature.generate_key ~algo:P256 () in - let keys_e = Signature.generate_key ~algo:Ed25519 () in - let keys_s = Signature.generate_key ~algo:Secp256k1 () in - function Signature.P256 -> keys_p | Ed25519 -> keys_e | Secp256k1 -> keys_s + let keys_p = Tezos_crypto.Signature.generate_key ~algo:P256 () in + let keys_e = Tezos_crypto.Signature.generate_key ~algo:Ed25519 () in + let keys_s = Tezos_crypto.Signature.generate_key ~algo:Secp256k1 () in + function + | Tezos_crypto.Signature.P256 -> keys_p + | Ed25519 -> keys_e + | Secp256k1 -> keys_s let wrong_keys = - let keys_p = Signature.generate_key ~algo:P256 () in - let keys_e = Signature.generate_key ~algo:Ed25519 () in - let keys_s = Signature.generate_key ~algo:Secp256k1 () in - function Signature.P256 -> keys_p | Ed25519 -> keys_e | Secp256k1 -> keys_s + let keys_p = Tezos_crypto.Signature.generate_key ~algo:P256 () in + let keys_e = Tezos_crypto.Signature.generate_key ~algo:Ed25519 () in + let keys_s = Tezos_crypto.Signature.generate_key ~algo:Secp256k1 () in + function + | Tezos_crypto.Signature.P256 -> keys_p + | Ed25519 -> keys_e + | Secp256k1 -> keys_s let wrong_pk algo = let _, pk, _ = wrong_keys algo in @@ -70,7 +76,7 @@ let check signed datas key f = combine acc (time (fun () -> - let b = Signature.check key l r in + let b = Tezos_crypto.Signature.check key l r in assert (f b) ; b))) (0., true) @@ -93,14 +99,16 @@ module Ko = struct end let str_of_algo = function - | Signature.Ed25519 -> "Ed25519" - | Signature.Secp256k1 -> "Secp256k1" - | Signature.P256 -> "P256" + | Tezos_crypto.Signature.Ed25519 -> "Ed25519" + | Tezos_crypto.Signature.Secp256k1 -> "Secp256k1" + | Tezos_crypto.Signature.P256 -> "P256" let time ~yes_crypto ~algo size datas = Format.eprintf "generating signatures...@?" ; let sign msg = - Signature.sign (if yes_crypto then fake_sk algo else sk algo) msg + Tezos_crypto.Signature.sign + (if yes_crypto then fake_sk algo else sk algo) + msg in let signed = List.rev @@ List.rev_map sign datas in Format.eprintf "Compacting memory...@?" ; diff --git a/devtools/yes_wallet/yes_wallet_lib.ml b/devtools/yes_wallet/yes_wallet_lib.ml index 743420b813da..bb030cab2d6c 100644 --- a/devtools/yes_wallet/yes_wallet_lib.ml +++ b/devtools/yes_wallet/yes_wallet_lib.ml @@ -34,7 +34,8 @@ - creates a 'yes-wallet' directory to be passed to tezos-client -d option *) -let pp_protocol ppf (module P : Sigs.PROTOCOL) = Protocol_hash.pp ppf P.hash +let pp_protocol ppf (module P : Sigs.PROTOCOL) = + Tezos_crypto.Protocol_hash.pp ppf P.hash let pkh_json (alias, pkh, _pk) = Ezjsonm.(dict [("name", string alias); ("value", string pkh)]) @@ -225,7 +226,8 @@ let get_delegates (module P : Sigs.PROTOCOL) context let protocol_of_hash protocol_hash = List.find - (fun (module P : Sigs.PROTOCOL) -> Protocol_hash.equal P.hash protocol_hash) + (fun (module P : Sigs.PROTOCOL) -> + Tezos_crypto.Protocol_hash.equal P.hash protocol_hash) (Known_protocols.get_all ()) (** [load_mainnet_bakers_public_keys base_dir active_backers_only] checkouts @@ -245,10 +247,10 @@ let load_mainnet_bakers_public_keys base_dir active_bakers_only { Genesis.time = Time.Protocol.of_notation_exn "2018-06-30T16:07:32Z"; block = - Block_hash.of_b58check_exn + Tezos_crypto.Block_hash.of_b58check_exn "BLockGenesisGenesisGenesisGenesisGenesisf79b5d1CoW2"; protocol = - Protocol_hash.of_b58check_exn + Tezos_crypto.Protocol_hash.of_b58check_exn "Ps9mPmXaRzmzk35gbAYNCAw6UXdE2qoABTHbN2oEEc1qM7CwT9P"; } in @@ -264,7 +266,7 @@ let load_mainnet_bakers_public_keys base_dir active_bakers_only let*! block = Tezos_store.Store.Chain.current_head main_chain_store in Format.printf "@[<h>Head block:@;<17 0>%a@]@." - Block_hash.pp + Tezos_crypto.Block_hash.pp (Tezos_store.Store.Block.hash block) ; let header = Store.Block.header block in let*! context = @@ -278,12 +280,12 @@ let load_mainnet_bakers_public_keys base_dir active_bakers_only | None -> Error_monad.failwith "Unknown protocol hash: %a.@;Known protocols are: %a" - Protocol_hash.pp + Tezos_crypto.Protocol_hash.pp protocol_hash Format.( pp_print_list ~pp_sep:(fun fmt () -> pp_print_string fmt ", ") - Protocol_hash.pp) + Tezos_crypto.Protocol_hash.pp) (List.map (fun (module P : Sigs.PROTOCOL) -> P.hash) @@ Known_protocols.get_all ()) | Some protocol -> @@ -302,8 +304,8 @@ let load_mainnet_bakers_public_keys base_dir active_bakers_only return @@ List.mapi (fun i (pkh, pk, stake) -> - let pkh = Signature.Public_key_hash.to_b58check pkh in - let pk = Signature.Public_key.to_b58check pk in + let pkh = Tezos_crypto.Signature.Public_key_hash.to_b58check pkh in + let pk = Tezos_crypto.Signature.Public_key.to_b58check pk in let alias = List.find_map (fun (alias, pkh', _) -> -- GitLab From da77cbcf55e73051a1e412607e27953bbd747429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Mon, 26 Sep 2022 15:49:19 +0200 Subject: [PATCH 29/30] Crypto: namespace module --- src/lib_crypto/tezos_crypto.ml | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/lib_crypto/tezos_crypto.ml diff --git a/src/lib_crypto/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml new file mode 100644 index 000000000000..0c9e27ba5c44 --- /dev/null +++ b/src/lib_crypto/tezos_crypto.ml @@ -0,0 +1,53 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs <contact@nomadic-labs.com> *) +(* *) +(* 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 Aggregate_signature = Aggregate_signature +module Base58 = Base58 +module Blake2B = Blake2B +module Block_hash = Block_hash +module Block_metadata_hash = Block_metadata_hash +module Bls = Bls +module Chain_id = Chain_id +module Context_hash = Context_hash +module Crypto_box = Crypto_box +module Ed25519 = Ed25519 +module Hacl = Hacl +module Helpers = Helpers +module Operation_hash = Operation_hash +module Operation_list_hash = Operation_list_hash +module Operation_list_list_hash = Operation_list_list_hash +module Operation_metadata_hash = Operation_metadata_hash +module Operation_metadata_list_hash = Operation_metadata_list_hash +module Operation_metadata_list_list_hash = Operation_metadata_list_list_hash +module P256 = P256 +module Protocol_hash = Protocol_hash +module Rand = Rand +module Secp256k1_group = Secp256k1_group +module Secp256k1 = Secp256k1 +module Signature = Signature +module S = S +module Timelock = Timelock +module Znz = Znz +module Zplus = Zplus -- GitLab From 42f0aec1749a3c4951205cbe12383e6f6bd8313c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= <code@bnwr.net> Date: Wed, 26 Oct 2022 08:15:07 +0200 Subject: [PATCH 30/30] Crypto: remove internal modules from external interface --- src/lib_crypto/tezos_crypto.ml | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/lib_crypto/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml index 0c9e27ba5c44..1aec237a9237 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -44,10 +44,7 @@ module Operation_metadata_list_list_hash = Operation_metadata_list_list_hash module P256 = P256 module Protocol_hash = Protocol_hash module Rand = Rand -module Secp256k1_group = Secp256k1_group module Secp256k1 = Secp256k1 module Signature = Signature module S = S module Timelock = Timelock -module Znz = Znz -module Zplus = Zplus -- GitLab