From 9cc5ee411375c0435e91f27a8f2288f39e166971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 21 Nov 2022 18:29:20 +0100 Subject: [PATCH 1/4] Env-v8/data-encoding: shadow string/bytes with string'/bytes' --- .../environment_V8.ml | 2 +- src/lib_protocol_environment/sigs/v8.ml | 44 +++++-------------- .../sigs/v8/data_encoding.mli | 44 +++++-------------- .../structs/v8_data_encoding.ml | 28 ++++++++++++ .../test/test_data_encoding.ml | 2 +- 5 files changed, 52 insertions(+), 68 deletions(-) diff --git a/src/lib_protocol_environment/environment_V8.ml b/src/lib_protocol_environment/environment_V8.ml index 699fbb819a32..0aa570ec5941 100644 --- a/src/lib_protocol_environment/environment_V8.ml +++ b/src/lib_protocol_environment/environment_V8.ml @@ -658,7 +658,7 @@ struct ~description:"Exception safely wrapped in an error" ~pp:(fun ppf s -> Format.fprintf ppf "@[%a@]" Format.pp_print_text s) - Data_encoding.(obj1 (req "msg" string)) + Data_encoding.(obj1 (req "msg" @@ string Plain)) (function | Exn (Failure msg) -> Some msg | Exn exn -> Some (Printexc.to_string exn) diff --git a/src/lib_protocol_environment/sigs/v8.ml b/src/lib_protocol_environment/sigs/v8.ml index 7c2669649a3c..442d10addfb4 100644 --- a/src/lib_protocol_environment/sigs/v8.ml +++ b/src/lib_protocol_environment/sigs/v8.ml @@ -3669,23 +3669,17 @@ val bool : bool encoding [length_kind] parameter (default [`Uint30]). - in JSON when [string_json_repr = Plain], encoded as a string - in JSON when [string_json_repr = Hex], encoded via hex. *) -val string' : +val string : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> string encoding -(** Encoding of arbitrary bytes. See [string'] *) -val bytes' : +(** Encoding of arbitrary bytes. See [string] *) +val bytes : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> Bytes.t encoding -(** same as [string' Plain] *) -val string : string encoding - -(** same as [bytes' Hex] *) -val bytes : Bytes.t encoding - (** {3 Descriptor combinators} *) (** Combinator to make an optional value @@ -4333,16 +4327,10 @@ val string_enum : (string * 'a) list -> 'a encoding See the preamble for an explanation. *) module Fixed : sig (** @raise Invalid_argument if the argument is less or equal to zero. *) - val string : int -> string encoding - - (** @raise Invalid_argument if the argument is less or equal to zero. *) - val string' : string_json_repr -> int -> string encoding - - (** @raise Invalid_argument if the argument is less or equal to zero. *) - val bytes : int -> Bytes.t encoding + val string : string_json_repr -> int -> string encoding (** @raise Invalid_argument if the argument is less or equal to zero. *) - val bytes' : string_json_repr -> int -> Bytes.t encoding + val bytes : string_json_repr -> int -> Bytes.t encoding (** [add_padding e n] is a padded version of the encoding [e]. In Binary, there are [n] null bytes ([\000]) added after the value encoded by [e]. @@ -4422,13 +4410,9 @@ end (** Create encodings that produce data of a variable length when binary encoded. See the preamble for an explanation. *) module Variable : sig - val string : string encoding - - val string' : string_json_repr -> string encoding - - val bytes : Bytes.t encoding + val string : string_json_repr -> string encoding - val bytes' : string_json_repr -> Bytes.t encoding + val bytes : string_json_repr -> Bytes.t encoding (** @raise Invalid_argument if the encoding argument is variable length or may lead to zero-width representation in binary. *) @@ -4453,28 +4437,22 @@ module Bounded : sig @raise Invalid_argument if [length_kind] is set but it cannot accommodate the specified bound. E.g., - [Bounded.string' ~length_kind:`Uint8 Hex 1000] raises. + [Bounded.string ~length_kind:`Uint8 Hex 1000] raises. @raise Invalid_argument if [length_kind] is unset and the specified bound is larger than 2^30. *) - val string' : + val string : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> int -> string encoding - (** Same as [string' Plain] *) - val string : int -> string encoding - - (** See {!string'} above. *) - val bytes' : + (** See {!string} above. *) + val bytes : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> int -> Bytes.t encoding - - (** Same as [bytes' Hex] *) - val bytes : int -> Bytes.t encoding end (** Mark an encoding as being of dynamic size. diff --git a/src/lib_protocol_environment/sigs/v8/data_encoding.mli b/src/lib_protocol_environment/sigs/v8/data_encoding.mli index 9cbc2f07c8d6..56c9564e74c2 100644 --- a/src/lib_protocol_environment/sigs/v8/data_encoding.mli +++ b/src/lib_protocol_environment/sigs/v8/data_encoding.mli @@ -189,23 +189,17 @@ val bool : bool encoding [length_kind] parameter (default [`Uint30]). - in JSON when [string_json_repr = Plain], encoded as a string - in JSON when [string_json_repr = Hex], encoded via hex. *) -val string' : +val string : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> string encoding -(** Encoding of arbitrary bytes. See [string'] *) -val bytes' : +(** Encoding of arbitrary bytes. See [string] *) +val bytes : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> Bytes.t encoding -(** same as [string' Plain] *) -val string : string encoding - -(** same as [bytes' Hex] *) -val bytes : Bytes.t encoding - (** {3 Descriptor combinators} *) (** Combinator to make an optional value @@ -853,16 +847,10 @@ val string_enum : (string * 'a) list -> 'a encoding See the preamble for an explanation. *) module Fixed : sig (** @raise Invalid_argument if the argument is less or equal to zero. *) - val string : int -> string encoding - - (** @raise Invalid_argument if the argument is less or equal to zero. *) - val string' : string_json_repr -> int -> string encoding - - (** @raise Invalid_argument if the argument is less or equal to zero. *) - val bytes : int -> Bytes.t encoding + val string : string_json_repr -> int -> string encoding (** @raise Invalid_argument if the argument is less or equal to zero. *) - val bytes' : string_json_repr -> int -> Bytes.t encoding + val bytes : string_json_repr -> int -> Bytes.t encoding (** [add_padding e n] is a padded version of the encoding [e]. In Binary, there are [n] null bytes ([\000]) added after the value encoded by [e]. @@ -942,13 +930,9 @@ end (** Create encodings that produce data of a variable length when binary encoded. See the preamble for an explanation. *) module Variable : sig - val string : string encoding - - val string' : string_json_repr -> string encoding - - val bytes : Bytes.t encoding + val string : string_json_repr -> string encoding - val bytes' : string_json_repr -> Bytes.t encoding + val bytes : string_json_repr -> Bytes.t encoding (** @raise Invalid_argument if the encoding argument is variable length or may lead to zero-width representation in binary. *) @@ -973,28 +957,22 @@ module Bounded : sig @raise Invalid_argument if [length_kind] is set but it cannot accommodate the specified bound. E.g., - [Bounded.string' ~length_kind:`Uint8 Hex 1000] raises. + [Bounded.string ~length_kind:`Uint8 Hex 1000] raises. @raise Invalid_argument if [length_kind] is unset and the specified bound is larger than 2^30. *) - val string' : + val string : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> int -> string encoding - (** Same as [string' Plain] *) - val string : int -> string encoding - - (** See {!string'} above. *) - val bytes' : + (** See {!string} above. *) + val bytes : ?length_kind:[`N | `Uint30 | `Uint16 | `Uint8] -> string_json_repr -> int -> Bytes.t encoding - - (** Same as [bytes' Hex] *) - val bytes : int -> Bytes.t encoding end (** Mark an encoding as being of dynamic size. diff --git a/src/lib_protocol_environment/structs/v8_data_encoding.ml b/src/lib_protocol_environment/structs/v8_data_encoding.ml index b41733a0b9a1..dd8397d7314c 100644 --- a/src/lib_protocol_environment/structs/v8_data_encoding.ml +++ b/src/lib_protocol_environment/structs/v8_data_encoding.ml @@ -28,6 +28,10 @@ include Data_encoding module Encoding = struct include Encoding + let string = string' + + let bytes = bytes' + let lazy_encoding encoding = let binary = lazy_encoding encoding in let json = @@ -57,6 +61,30 @@ module Encoding = struct repr_agnostic_custom {write; read} ~schema:Json_schema.any in Data_encoding__Encoding.raw_splitted ~json ~binary + + module Bounded = struct + include Bounded + + let string = string' + + let bytes = bytes' + end + + module Variable = struct + include Variable + + let string = string' + + let bytes = bytes' + end + + module Fixed = struct + include Fixed + + let string = string' + + let bytes = bytes' + end end include Encoding diff --git a/src/lib_protocol_environment/test/test_data_encoding.ml b/src/lib_protocol_environment/test/test_data_encoding.ml index 79f9fa769823..a7f3e7e3162f 100644 --- a/src/lib_protocol_environment/test/test_data_encoding.ml +++ b/src/lib_protocol_environment/test/test_data_encoding.ml @@ -36,7 +36,7 @@ open Tezos_protocol_environment_structs.V8 type t = {x : int; y : string Data_encoding.lazy_t} let test_unparsable_lazyexpr () = - let parsed_encoding = Data_encoding.(lazy_encoding (Fixed.string 3)) in + let parsed_encoding = Data_encoding.(lazy_encoding (Fixed.string Plain 3)) in let enc = let open Data_encoding in conv -- GitLab From e942cd6dd5aa96f61486b1aac143253cc1b40158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 21 Nov 2022 19:06:30 +0100 Subject: [PATCH 2/4] Alpha: adapt to env's data-encoding's new shadowing --- src/proto_alpha/lib_dal/RPC.ml | 2 +- src/proto_alpha/lib_plugin/RPC.ml | 14 ++++++++------ .../lib_protocol/blinded_public_key_hash.ml | 3 ++- src/proto_alpha/lib_protocol/block_header_repr.ml | 2 +- src/proto_alpha/lib_protocol/constants_repr.ml | 2 +- src/proto_alpha/lib_protocol/contract_repr.ml | 4 ++-- src/proto_alpha/lib_protocol/contract_storage.ml | 2 +- src/proto_alpha/lib_protocol/dal_slot_repr.ml | 8 ++++---- src/proto_alpha/lib_protocol/destination_repr.ml | 4 ++-- src/proto_alpha/lib_protocol/entrypoint_repr.ml | 8 ++++---- .../lib_protocol/michelson_v1_primitives.ml | 6 +++--- src/proto_alpha/lib_protocol/operation_repr.ml | 14 +++++++------- src/proto_alpha/lib_protocol/raw_context.ml | 14 +++++++------- src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml | 6 +++--- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 6 +++--- ...rollup_inbox_merkelized_payload_hashes_repr.ml | 4 ++-- .../lib_protocol/sc_rollup_inbox_message_repr.ml | 2 +- .../lib_protocol/sc_rollup_inbox_repr.ml | 6 +++--- .../lib_protocol/sc_rollup_proof_repr.ml | 4 ++-- src/proto_alpha/lib_protocol/sc_rollup_repr.ml | 4 ++-- .../lib_protocol/script_ir_translator.ml | 3 ++- src/proto_alpha/lib_protocol/script_string.ml | 2 +- .../lib_protocol/script_tc_errors_registration.ml | 8 ++++---- src/proto_alpha/lib_protocol/seed_repr.ml | 15 +++++++++------ src/proto_alpha/lib_protocol/ticket_accounting.ml | 2 +- .../lib_protocol/tx_rollup_errors_repr.ml | 2 +- .../lib_protocol/tx_rollup_l2_proof.ml | 2 +- .../lib_protocol/tx_rollup_message_repr.ml | 2 +- src/proto_alpha/lib_protocol/tx_rollup_repr.ml | 4 ++-- .../lib_protocol/zk_rollup_account_repr.ml | 2 +- .../lib_protocol/zk_rollup_update_repr.ml | 6 ++++-- 31 files changed, 86 insertions(+), 77 deletions(-) diff --git a/src/proto_alpha/lib_dal/RPC.ml b/src/proto_alpha/lib_dal/RPC.ml index 91057e5cf153..64ed6eee8ade 100644 --- a/src/proto_alpha/lib_dal/RPC.ml +++ b/src/proto_alpha/lib_dal/RPC.ml @@ -39,7 +39,7 @@ module DAC = struct RPC_service.put_service ~description:"Split DAC reveal data" ~query:RPC_query.empty - ~input:Data_encoding.bytes + ~input:Data_encoding.(bytes Hex) ~output:Hashing_scheme.hash_encoding RPC_path.(open_root / "dac" / "store_preimage") end diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 29dd4b57827e..392ba0d9f8b5 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -232,7 +232,7 @@ module Scripts = struct merge_objs (obj10 (req "contract" Contract.originated_encoding) - (req "view" string) + (req "view" (string Plain)) (req "input" Script.expr_encoding) (dft "unlimited_gas" bool false) (req "chain_id" Tezos_crypto.Chain_id.encoding) @@ -333,7 +333,7 @@ module Scripts = struct (req "data" Script.expr_encoding) (req "type" Script.expr_encoding) (opt "gas" Gas.Arith.z_integral_encoding)) - ~output:(obj2 (req "packed" bytes) (req "gas" Gas.encoding)) + ~output:(obj2 (req "packed" (bytes Hex)) (req "gas" Gas.encoding)) ~query:RPC_query.empty RPC_path.(path / "pack_data") @@ -1987,7 +1987,7 @@ module Sc_rollup = struct RPC_service.get_service ~description:"Boot sector of smart-contract rollup" ~query:RPC_query.empty - ~output:Data_encoding.string + ~output:Data_encoding.(string Plain) RPC_path.(path_sc_rollup / "boot_sector") let genesis_info = @@ -2488,7 +2488,7 @@ module Forge = struct ~description:"Forge an operation" ~query:RPC_query.empty ~input:Operation.unsigned_encoding - ~output:bytes + ~output:(bytes Hex) RPC_path.(path / "operations") let empty_proof_of_work_nonce = @@ -2505,14 +2505,16 @@ module Forge = struct (opt "nonce_hash" Nonce_hash.encoding) (dft "proof_of_work_nonce" - (Fixed.bytes Alpha_context.Constants.proof_of_work_nonce_size) + (Fixed.bytes + Hex + Alpha_context.Constants.proof_of_work_nonce_size) empty_proof_of_work_nonce) Liquidity_baking.( dft "liquidity_baking_toggle_vote" liquidity_baking_toggle_vote_encoding LB_pass)) - ~output:(obj1 (req "protocol_data" bytes)) + ~output:(obj1 (req "protocol_data" (bytes Hex))) RPC_path.(path / "protocol_data") module Tx_rollup = struct diff --git a/src/proto_alpha/lib_protocol/blinded_public_key_hash.ml b/src/proto_alpha/lib_protocol/blinded_public_key_hash.ml index 7b0a3272cc6e..005e8d3d365b 100644 --- a/src/proto_alpha/lib_protocol/blinded_public_key_hash.ml +++ b/src/proto_alpha/lib_protocol/blinded_public_key_hash.ml @@ -52,7 +52,8 @@ type activation_code = bytes let activation_code_size = Ed25519.Public_key_hash.size -let activation_code_encoding = Data_encoding.Fixed.bytes activation_code_size +let activation_code_encoding = + Data_encoding.Fixed.(bytes Hex) activation_code_size let activation_code_of_hex h = if Compare.Int.(String.length h <> activation_code_size * 2) then None diff --git a/src/proto_alpha/lib_protocol/block_header_repr.ml b/src/proto_alpha/lib_protocol/block_header_repr.ml index 39b6375d1afd..41b5988a7f9b 100644 --- a/src/proto_alpha/lib_protocol/block_header_repr.ml +++ b/src/proto_alpha/lib_protocol/block_header_repr.ml @@ -101,7 +101,7 @@ let contents_encoding = (req "payload_round" Round_repr.encoding) (req "proof_of_work_nonce" - (Fixed.bytes Constants_repr.proof_of_work_nonce_size)) + (Fixed.bytes Hex Constants_repr.proof_of_work_nonce_size)) (opt "seed_nonce_hash" Nonce_hash.encoding) (req "liquidity_baking_toggle_vote" diff --git a/src/proto_alpha/lib_protocol/constants_repr.ml b/src/proto_alpha/lib_protocol/constants_repr.ml index 7bd942b9bec7..124860373fef 100644 --- a/src/proto_alpha/lib_protocol/constants_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_repr.ml @@ -159,7 +159,7 @@ let () = ~description:"The provided protocol constants are not coherent." ~pp:(fun ppf reason -> Format.fprintf ppf "Invalid protocol constants: %s" reason) - Data_encoding.(obj1 (req "reason" string)) + Data_encoding.(obj1 (req "reason" @@ string Plain)) (function Invalid_protocol_constants reason -> Some reason | _ -> None) (fun reason -> Invalid_protocol_constants reason) diff --git a/src/proto_alpha/lib_protocol/contract_repr.ml b/src/proto_alpha/lib_protocol/contract_repr.ml index eff662ff50bc..13b3c490230f 100644 --- a/src/proto_alpha/lib_protocol/contract_repr.ml +++ b/src/proto_alpha/lib_protocol/contract_repr.ml @@ -131,7 +131,7 @@ let encoding_gen ~id_extra ~title_extra ~can_be ~cases ~to_b58check ~of_b58data match of_b58check_gen ~of_b58data s with | Ok s -> s | Error _ -> Json.cannot_destruct "Invalid contract notation.") - string) + (string Plain)) let encoding = encoding_gen @@ -169,7 +169,7 @@ let () = ~pp:(fun ppf x -> Format.fprintf ppf "Invalid contract notation %S" x) ~description: "A malformed contract notation was given to an RPC or in a script." - (obj1 (req "notation" string)) + (obj1 (req "notation" (string Plain))) (function Invalid_contract_notation loc -> Some loc | _ -> None) (fun loc -> Invalid_contract_notation loc) diff --git a/src/proto_alpha/lib_protocol/contract_storage.ml b/src/proto_alpha/lib_protocol/contract_storage.ml index 7364f0a6b7b0..324b38ac02c0 100644 --- a/src/proto_alpha/lib_protocol/contract_storage.ml +++ b/src/proto_alpha/lib_protocol/contract_storage.ml @@ -168,7 +168,7 @@ let () = ~title:"Contract storage failure" ~description:"Unexpected contract storage error" ~pp:(fun ppf s -> Format.fprintf ppf "Contract_storage.Failure %S" s) - Data_encoding.(obj1 (req "message" string)) + Data_encoding.(obj1 (req "message" @@ string Plain)) (function Failure s -> Some s | _ -> None) (fun s -> Failure s) ; register_error_kind diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml index af0696b1d06b..45b6bc3cb197 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -172,7 +172,7 @@ module Page = struct let proof_encoding = Dal.page_proof_encoding - let content_encoding = Data_encoding.bytes + let content_encoding = Data_encoding.(bytes Hex) let pp fmt {slot_id = {published_level; index}; page_index} = Format.fprintf @@ -541,7 +541,7 @@ module History = struct (req "kind" (constant "confirmed")) (req "target_cell" history_encoding) (req "inc_proof" (list history_encoding)) - (req "page_data" bytes) + (req "page_data" (bytes Hex)) (req "page_proof" Page.proof_encoding)) (function | Page_confirmed {target_cell; inc_proof; page_data; page_proof} -> @@ -577,7 +577,7 @@ module History = struct (** DAL/FIXME: https://gitlab.com/tezos/tezos/-/issues/4084 DAL proof's encoding should be bounded *) - let proof_encoding = Data_encoding.bytes + let proof_encoding = Data_encoding.(bytes Hex) type error += Dal_invalid_proof_serialization @@ -662,7 +662,7 @@ module History = struct ~title:"Dal proof error" ~description:"Error occurred during Dal proof production or validation" ~pp:(fun ppf e -> Format.fprintf ppf "Dal proof error: %s" e) - (obj1 (req "error" string)) + (obj1 (req "error" (string Plain))) (function Dal_proof_error e -> Some e | _ -> None) (fun e -> Dal_proof_error e) diff --git a/src/proto_alpha/lib_protocol/destination_repr.ml b/src/proto_alpha/lib_protocol/destination_repr.ml index 96cf0f862b1a..4c2859e2134e 100644 --- a/src/proto_alpha/lib_protocol/destination_repr.ml +++ b/src/proto_alpha/lib_protocol/destination_repr.ml @@ -77,7 +77,7 @@ let () = ~title:"Destination decoding failed" ~description: "Failed to read a valid destination from a b58check_encoding data" - (obj1 (req "input" string)) + (obj1 (req "input" (string Plain))) (function Invalid_destination_b58check x -> Some x | _ -> None) (fun x -> Invalid_destination_b58check x) @@ -145,7 +145,7 @@ let encoding = | Error _ -> Data_encoding.Json.cannot_destruct "Invalid destination notation.") - string) + (string Plain)) let pp : Format.formatter -> t -> unit = fun fmt -> function diff --git a/src/proto_alpha/lib_protocol/entrypoint_repr.ml b/src/proto_alpha/lib_protocol/entrypoint_repr.ml index 03662185f7a6..7931a57a42c4 100644 --- a/src/proto_alpha/lib_protocol/entrypoint_repr.ml +++ b/src/proto_alpha/lib_protocol/entrypoint_repr.ml @@ -53,7 +53,7 @@ let () = ~title:"Entrypoint name too long (type error)" ~description: "An entrypoint name exceeds the maximum length of 31 characters." - Data_encoding.(obj1 (req "name" string)) + Data_encoding.(obj1 (req "name" @@ string Plain)) (function Name_too_long entrypoint -> Some entrypoint | _ -> None) (fun entrypoint -> Name_too_long entrypoint) @@ -181,13 +181,13 @@ let simple_encoding = Data_encoding.conv_with_guard (fun (name : t) -> (name :> string)) of_string_lax' - Data_encoding.string + Data_encoding.(string Plain) let value_encoding = Data_encoding.conv_with_guard (fun name -> if is_default name then "" else (name :> string)) of_string_strict' - Data_encoding.Variable.string + Data_encoding.Variable.(string Plain) let smart_encoding = let open Data_encoding in @@ -215,7 +215,7 @@ let smart_encoding = case (Tag 255) ~title:"named" - (Bounded.string 31) + (Bounded.string Plain 31) (fun (name : Pre_entrypoint.t) -> Some (name :> string)) of_string_lax_exn; ] diff --git a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml index b8ae12fc1997..e699d4c9e3c8 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml +++ b/src/proto_alpha/lib_protocol/michelson_v1_primitives.ml @@ -787,7 +787,7 @@ let () = ~title:"Unknown primitive name" ~description:"In a script or data expression, a primitive was unknown." ~pp:(fun ppf n -> Format.fprintf ppf "Unknown primitive %s." n) - Data_encoding.(obj1 (req "wrong_primitive_name" string)) + Data_encoding.(obj1 (req "wrong_primitive_name" @@ string Plain)) (function Unknown_primitive_name got -> Some got | _ -> None) (fun got -> Unknown_primitive_name got) ; register_error_kind @@ -798,7 +798,7 @@ let () = "In a script or data expression, a primitive name is neither uppercase, \ lowercase or capitalized." ~pp:(fun ppf n -> Format.fprintf ppf "Primitive %s has invalid case." n) - Data_encoding.(obj1 (req "wrong_primitive_name" string)) + Data_encoding.(obj1 (req "wrong_primitive_name" @@ string Plain)) (function Invalid_case name -> Some name | _ -> None) (fun name -> Invalid_case name) ; register_error_kind @@ -813,7 +813,7 @@ let () = obj2 (req "expression" - (Micheline.canonical_encoding ~variant:"generic" string)) + (Micheline.canonical_encoding ~variant:"generic" @@ string Plain)) (req "location" Micheline.canonical_location_encoding)) (function | Invalid_primitive_name (expr, loc) -> Some (expr, loc) | _ -> None) diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index c524f5951e0e..c0d35adfd418 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -812,7 +812,7 @@ module Encoding = struct encoding = obj3 (req "rollup" Tx_rollup_repr.encoding) - (req "content" (string' Hex)) + (req "content" (string Hex)) (opt "burn_limit" Tez_repr.encoding); select = (function @@ -1128,8 +1128,8 @@ module Encoding = struct encoding = obj4 (req "pvm_kind" Sc_rollups.Kind.encoding) - (req "boot_sector" (string' Hex)) - (req "origination_proof" (string' Hex)) + (req "boot_sector" (string Hex)) + (req "origination_proof" (string Hex)) (req "parameters_ty" Script_repr.lazy_expr_encoding); select = (function @@ -1164,7 +1164,7 @@ module Encoding = struct { tag = sc_rollup_operation_add_message_tag; name = "sc_rollup_add_messages"; - encoding = obj1 (req "message" (list (string' Hex))); + encoding = obj1 (req "message" (list (string Hex))); select = (function | Manager (Sc_rollup_add_messages _ as op) -> Some op | _ -> None); @@ -1261,7 +1261,7 @@ module Encoding = struct (req "cemented_commitment" Sc_rollup_commitment_repr.Hash.encoding) - (req "output_proof" (string' Hex)); + (req "output_proof" (string Hex)); select = (function | Manager (Sc_rollup_execute_outbox_message _ as op) -> Some op @@ -1580,7 +1580,7 @@ module Encoding = struct { tag = 17; name = "failing_noop"; - encoding = obj1 (req "arbitrary" (string' Hex)); + encoding = obj1 (req "arbitrary" (string Hex)); select = (function Contents (Failing_noop _ as op) -> Some op | _ -> None); proj = (function Failing_noop message -> message); @@ -1939,7 +1939,7 @@ let () = ppf "An operation contents list has an unexpected shape: %s" s) - Data_encoding.(obj1 (req "message" (string' Hex))) + Data_encoding.(obj1 (req "message" (string Hex))) (function Contents_list_error s -> Some s | _ -> None) (fun s -> Contents_list_error s) diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 3ca2c5123afa..ef4e6137aad9 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -435,7 +435,7 @@ let () = Format.fprintf ppf "The stake distribution for the current cycle is not set.") - Data_encoding.(empty) + empty (function Stake_distribution_not_set -> Some () | _ -> None) (fun () -> Stake_distribution_not_set) ; register_error_kind @@ -577,14 +577,14 @@ let storage_error_encoding = case (Tag 0) ~title:"Incompatible_protocol_version" - (obj1 (req "incompatible_protocol_version" string)) + (obj1 (req "incompatible_protocol_version" @@ string Plain)) (function Incompatible_protocol_version arg -> Some arg | _ -> None) (fun arg -> Incompatible_protocol_version arg); case (Tag 1) ~title:"Missing_key" (obj2 - (req "missing_key" (list string)) + (req "missing_key" (list @@ string Plain)) (req "function" (string_enum @@ -594,13 +594,13 @@ let storage_error_encoding = case (Tag 2) ~title:"Existing_key" - (obj1 (req "existing_key" (list string))) + (obj1 (req "existing_key" (list @@ string Plain))) (function Existing_key key -> Some key | _ -> None) (fun key -> Existing_key key); case (Tag 3) ~title:"Corrupted_data" - (obj1 (req "corrupted_data" (list string))) + (obj1 (req "corrupted_data" (list @@ string Plain))) (function Corrupted_data key -> Some key | _ -> None) (fun key -> Corrupted_data key); ] @@ -705,7 +705,7 @@ let () = ppf "@[Cannot parse the protocol parameter:@ %s@]" (Bytes.to_string bytes)) - Data_encoding.(obj1 (req "contents" bytes)) + Data_encoding.(obj1 (req "contents" @@ bytes Hex)) (function Failed_to_parse_parameter data -> Some data | _ -> None) (fun data -> Failed_to_parse_parameter data) ; register_error_kind @@ -720,7 +720,7 @@ let () = msg Data_encoding.Json.pp json) - Data_encoding.(obj2 (req "contents" json) (req "error" string)) + Data_encoding.(obj2 (req "contents" json) (req "error" @@ string Plain)) (function | Failed_to_decode_parameter (json, msg) -> Some (json, msg) | _ -> None) (fun (json, msg) -> Failed_to_decode_parameter (json, msg)) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml index b7ed6fdb7f7e..7a044fbb0905 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -102,7 +102,7 @@ let inbox_message_encoding = (obj3 (req "inbox_level" Raw_level_repr.encoding) (req "message_counter" n) - (req "payload" (string' Hex))) + (req "payload" (string Hex))) let reveal_data_encoding = let open Data_encoding in @@ -116,7 +116,7 @@ let reveal_data_encoding = "raw_data" (check_size Constants_repr.sc_rollup_message_size_limit - (string' Hex)))) + (string Hex)))) (function Raw_data m -> Some ((), m) | _ -> None) (fun ((), m) -> Raw_data m) and case_metadata = @@ -135,7 +135,7 @@ let reveal_data_encoding = (Tag 2) (obj2 (req "reveal_data_kind" (constant "dal_page")) - (req "dal_page_content" (option bytes))) + (req "dal_page_content" (option (bytes Hex)))) (function Dal_page p -> Some ((), p) | _ -> None) (fun ((), p) -> Dal_page p) in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 96133f425f37..7df9e544e8e9 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -557,7 +557,7 @@ module Make (Context : P) : case ~title:"store" (Tag 2) - Data_encoding.string + Data_encoding.(string Plain) (function IStore x -> Some x | _ -> None) (fun x -> IStore x); ]) @@ -570,7 +570,7 @@ module Make (Context : P) : let initial = "" - let encoding = Data_encoding.string + let encoding = Data_encoding.(string Plain) let pp fmt s = Format.fprintf fmt "%s" s end) @@ -685,7 +685,7 @@ module Make (Context : P) : let initial = None - let encoding = Data_encoding.(option string) + let encoding = Data_encoding.(option (string Plain)) let name = "next_message" diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml index 44f2efee02df..4d265f187d30 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml @@ -33,7 +33,7 @@ let () = "Internal error: error occurred during proof production or validation" ~description:"A merkelized payload hashes proof error." ~pp:(fun ppf e -> Format.fprintf ppf "Proof error: %s" e) - (obj1 (req "error" string)) + (obj1 (req "error" (string Plain))) (function Merkelized_payload_hashes_proof_error e -> Some e | _ -> None) (fun e -> Merkelized_payload_hashes_proof_error e) @@ -116,7 +116,7 @@ let merkelized_and_payload_encoding = merkelized; payload = Sc_rollup_inbox_message_repr.unsafe_of_string payload; }) - (merge_objs encoding (obj1 (req "payload" string))) + (merge_objs encoding (obj1 (req "payload" (string Plain)))) module History = struct include diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml index b5b9b35a2dec..37f2d9604dd8 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml @@ -131,7 +131,7 @@ let encoding = case (Tag 1) ~title:"External" - Variable.(string' Hex) + Variable.(string Hex) (function External msg -> Some msg | Internal _ -> None) (fun msg -> External msg); ]) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index 7d8ca5009c0b..bc8175a7f942 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -77,7 +77,7 @@ let () = "Internal error: error occurred during proof production or validation" ~description:"An inbox proof error." ~pp:(fun ppf e -> Format.fprintf ppf "Inbox proof error: %s" e) - (obj1 (req "error" string)) + (obj1 (req "error" (string Plain))) (function Inbox_proof_error e -> Some e | _ -> None) (fun e -> Inbox_proof_error e) ; @@ -343,7 +343,7 @@ let to_versioned inbox = V1 inbox [@@inline] type serialized_proof = string -let serialized_proof_encoding = Data_encoding.(string' Hex) +let serialized_proof_encoding = Data_encoding.(string Hex) type level_tree_proof = { proof : Sc_rollup_inbox_merkelized_payload_hashes_repr.proof; @@ -364,7 +364,7 @@ let level_tree_proof_encoding = (req "proof" Sc_rollup_inbox_merkelized_payload_hashes_repr.proof_encoding) - (opt "payload" string)) + (opt "payload" (string Plain))) let add_message inbox payload level_tree_history level_tree = let open Result_syntax in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml index 4dd15a754a49..75e8c46e0f34 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -35,7 +35,7 @@ let () = ~title:"Invalid proof" ~description:"An invalid proof has been submitted" ~pp:(fun fmt msg -> Format.fprintf fmt "Invalid proof: %s" msg) - Data_encoding.(obj1 @@ req "reason" string) + Data_encoding.(obj1 @@ req "reason" (string Plain)) (function Sc_rollup_proof_check msg -> Some msg | _ -> None) (fun msg -> Sc_rollup_proof_check msg) ; @@ -69,7 +69,7 @@ let reveal_proof_encoding = "raw_data" (check_size Constants_repr.sc_rollup_message_size_limit - (string' Hex)))) + (string Hex)))) (function Raw_data_proof s -> Some ((), s) | _ -> None) (fun ((), s) -> Raw_data_proof s) and case_metadata_proof = diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index df431b7219a9..7e992ce3f689 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -128,7 +128,7 @@ let () = ~pp:(fun ppf x -> Format.fprintf ppf "Invalid smart contract rollup address %S" x) ~description:error_description - (obj1 (req "address" string)) + (obj1 (req "address" (string Plain))) (function Invalid_sc_rollup_address loc -> Some loc | _ -> None) (fun loc -> Invalid_sc_rollup_address loc) @@ -145,7 +145,7 @@ let encoding = "rollup_address" ~title:"A smart contract rollup address" ~description - (conv_with_guard Address.to_b58check of_b58check string) + (conv_with_guard Address.to_b58check of_b58check (string Plain)) let rpc_arg = let construct = Address.to_b58check in diff --git a/src/proto_alpha/lib_protocol/script_ir_translator.ml b/src/proto_alpha/lib_protocol/script_ir_translator.ml index 80ec18fbe31f..1e5c2dd0c044 100644 --- a/src/proto_alpha/lib_protocol/script_ir_translator.ml +++ b/src/proto_alpha/lib_protocol/script_ir_translator.ml @@ -154,7 +154,8 @@ let check_comparable : let pack_node unparsed ctxt = let bytes = - Data_encoding.(Binary.to_bytes_exn (tup2 (Fixed.string 1) expr_encoding)) + Data_encoding.( + Binary.to_bytes_exn (tup2 (Fixed.string Plain 1) expr_encoding)) ("\x05", unparsed) in (bytes, ctxt) diff --git a/src/proto_alpha/lib_protocol/script_string.ml b/src/proto_alpha/lib_protocol/script_string.ml index b3108eb31ef2..8585be293466 100644 --- a/src/proto_alpha/lib_protocol/script_string.ml +++ b/src/proto_alpha/lib_protocol/script_string.ml @@ -50,7 +50,7 @@ let () = s pos (Char.code s.[pos])) - (obj2 (req "position" int31) (req "string" string)) + (obj2 (req "position" int31) (req "string" (string Plain))) (function Non_printable_character (pos, s) -> Some (pos, s) | _ -> None) (fun (pos, s) -> Non_printable_character (pos, s)) diff --git a/src/proto_alpha/lib_protocol/script_tc_errors_registration.ml b/src/proto_alpha/lib_protocol/script_tc_errors_registration.ml index 3b873c9f6406..1aa670624d13 100644 --- a/src/proto_alpha/lib_protocol/script_tc_errors_registration.ml +++ b/src/proto_alpha/lib_protocol/script_tc_errors_registration.ml @@ -509,7 +509,7 @@ let () = ~id:"michelson_v1.view_name_too_long" ~title:"View name too long (type error)" ~description:"A view name exceeds the maximum length of 31 characters." - (obj1 (req "name" string)) + (obj1 (req "name" (string Plain))) (function View_name_too_long name -> Some name | _ -> None) (fun name -> View_name_too_long name) ; (* Duplicated view name *) @@ -529,7 +529,7 @@ let () = ~description:"A compile-time constant was invalid for its expected form." (located (obj2 - (req "expected_form" string) + (req "expected_form" (string Plain)) (req "wrong_expression" Script.expr_encoding))) (function | Invalid_syntactic_constant (loc, expr, expected) -> @@ -724,7 +724,7 @@ let () = "The toplevel error thrown when trying to typecheck a data expression \ against a given type (always followed by more precise errors)." (obj3 - (opt "identifier" string) + (opt "identifier" (string Plain)) (req "expected_type" Script.expr_encoding) (req "ill_typed_expression" Script.expr_encoding)) (function @@ -739,7 +739,7 @@ let () = "The toplevel error thrown when trying to parse a type expression \ (always followed by more precise errors)." (obj3 - (opt "identifier" string) + (opt "identifier" (string Plain)) (req "ill_formed_expression" Script.expr_encoding) (req "location" Script.location_encoding)) (function diff --git a/src/proto_alpha/lib_protocol/seed_repr.ml b/src/proto_alpha/lib_protocol/seed_repr.ml index 2149807533e3..b84736293e3a 100644 --- a/src/proto_alpha/lib_protocol/seed_repr.ml +++ b/src/proto_alpha/lib_protocol/seed_repr.ml @@ -50,7 +50,7 @@ let vdf_setup_encoding = Option.to_result ~none:"VDF discriminant could not be deserialised" (Vdf.discriminant_of_bytes_opt b)) - (Fixed.bytes Vdf.discriminant_size_bytes) + (Fixed.(bytes Hex) Vdf.discriminant_size_bytes) in let vdf_challenge_encoding = conv_with_guard @@ -59,7 +59,7 @@ let vdf_setup_encoding = Option.to_result ~none:"VDF challenge could not be deserialised" (Vdf.challenge_of_bytes_opt b)) - (Fixed.bytes Vdf.form_size_bytes) + (Fixed.(bytes Hex) Vdf.form_size_bytes) in tup2 vdf_discriminant_encoding vdf_challenge_encoding @@ -72,7 +72,7 @@ let vdf_solution_encoding = Option.to_result ~none:"VDF result could not be deserialised" (Vdf.result_of_bytes_opt b)) - (Fixed.bytes Vdf.form_size_bytes) + (Fixed.(bytes Hex) Vdf.form_size_bytes) in let vdf_proof_encoding = conv_with_guard @@ -81,7 +81,7 @@ let vdf_solution_encoding = Option.to_result ~none:"VDF proof could not be deserialised" (Vdf.proof_of_bytes_opt b)) - (Fixed.bytes Vdf.form_size_bytes) + (Fixed.(bytes Hex) Vdf.form_size_bytes) in tup2 vdf_result_encoding vdf_proof_encoding @@ -99,13 +99,16 @@ let pp_solution ppf solution = (Hex.of_bytes (Vdf.proof_to_bytes proof)) ; Format.fprintf ppf "@]" -let nonce_encoding = Data_encoding.Fixed.bytes Constants_repr.nonce_length +let nonce_encoding = Data_encoding.Fixed.(bytes Hex) Constants_repr.nonce_length let zero_bytes = Bytes.make Nonce_hash.size '\000' let state_hash_encoding = let open Data_encoding in - conv State_hash.to_bytes State_hash.of_bytes_exn (Fixed.bytes Nonce_hash.size) + conv + State_hash.to_bytes + State_hash.of_bytes_exn + (Fixed.(bytes Hex) Nonce_hash.size) let seed_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/ticket_accounting.ml b/src/proto_alpha/lib_protocol/ticket_accounting.ml index 329d402c4031..ae2b6f756b90 100644 --- a/src/proto_alpha/lib_protocol/ticket_accounting.ml +++ b/src/proto_alpha/lib_protocol/ticket_accounting.ml @@ -41,7 +41,7 @@ let () = Z.pp_print amount ticketer) - (obj2 (req "ticketer" string) (req "amount" z)) + (obj2 (req "ticketer" (string Plain)) (req "amount" z)) (function | Invalid_ticket_transfer {ticketer; amount} -> Some (ticketer, amount) | _ -> None) diff --git a/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml b/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml index f3814a468f8e..3c71b9c8a080 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_errors_repr.ml @@ -376,7 +376,7 @@ let () = ~id:"tx_rollup_internal_error" ~title:"An internal error occurred" ~description:"An internal error occurred" - (obj1 (req "description" string)) + (obj1 (req "description" (string Plain))) (function Internal_error str -> Some str | _ -> None) (fun str -> Internal_error str) ; (* Wrong_message_position *) diff --git a/src/proto_alpha/lib_protocol/tx_rollup_l2_proof.ml b/src/proto_alpha/lib_protocol/tx_rollup_l2_proof.ml index 806ab8da15ee..12d54391045b 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_l2_proof.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_l2_proof.ml @@ -32,7 +32,7 @@ type serialized = string let length = String.length -let serialized_encoding = Data_encoding.(string' Hex) +let serialized_encoding = Data_encoding.(string Hex) let proof_of_serialized_opt = Data_encoding.Binary.of_string_opt encoding diff --git a/src/proto_alpha/lib_protocol/tx_rollup_message_repr.ml b/src/proto_alpha/lib_protocol/tx_rollup_message_repr.ml index c86c770d68dc..a4a79ada9046 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_message_repr.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_message_repr.ml @@ -55,7 +55,7 @@ let encoding = case (Tag 0) ~title:"Batch" - (obj1 (req "batch" (string' Hex))) + (obj1 (req "batch" (string Hex))) (function Batch batch -> Some batch | _ -> None) (fun batch -> Batch batch); case diff --git a/src/proto_alpha/lib_protocol/tx_rollup_repr.ml b/src/proto_alpha/lib_protocol/tx_rollup_repr.ml index 5e4416e66982..f9e8e568dc43 100644 --- a/src/proto_alpha/lib_protocol/tx_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/tx_rollup_repr.ml @@ -36,7 +36,7 @@ let () = ~pp:(fun ppf x -> Format.fprintf ppf "Invalid tx rollup notation %S" x) ~description: "A malformed tx rollup notation was given to an RPC or in a script." - (obj1 (req "notation" string)) + (obj1 (req "notation" (string Plain))) (function Invalid_rollup_notation loc -> Some loc | _ -> None) (fun loc -> Invalid_rollup_notation loc) @@ -108,7 +108,7 @@ let encoding = match of_b58check s with | Ok s -> s | Error _ -> Json.cannot_destruct "Invalid tx rollup notation.") - string) + (string Plain)) let originated_tx_rollup nonce = let data = diff --git a/src/proto_alpha/lib_protocol/zk_rollup_account_repr.ml b/src/proto_alpha/lib_protocol/zk_rollup_account_repr.ml index 18d96d4a516b..70efc0015660 100644 --- a/src/proto_alpha/lib_protocol/zk_rollup_account_repr.ml +++ b/src/proto_alpha/lib_protocol/zk_rollup_account_repr.ml @@ -82,7 +82,7 @@ let circuits_info_encoding : [`Public | `Private | `Fee] SMap.t Data_encoding.t Compare.List_length_with.(l <> SMap.cardinal m) then Error "Zk_rollup_origination: circuits_info has duplicated keys" else Ok m) - (list (tup2 string variant_encoding)) + (list (tup2 (string Plain) variant_encoding)) let encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/zk_rollup_update_repr.ml b/src/proto_alpha/lib_protocol/zk_rollup_update_repr.ml index 0f81f441a20a..5357f923beb2 100644 --- a/src/proto_alpha/lib_protocol/zk_rollup_update_repr.ml +++ b/src/proto_alpha/lib_protocol/zk_rollup_update_repr.ml @@ -78,7 +78,9 @@ let encoding : t Data_encoding.t = (fun (pending_pis, private_pis, fee_pi, proof) -> {pending_pis; private_pis; fee_pi; proof}) (obj4 - (req "pending_pis" (list @@ tup2 string op_pi_encoding)) - (req "private_pis" (list @@ tup2 string private_inner_pi_encoding)) + (req "pending_pis" (list @@ tup2 (string Plain) op_pi_encoding)) + (req + "private_pis" + (list @@ tup2 (string Plain) private_inner_pi_encoding)) (req "fee_pi" fee_pi_encoding) (req "proof" Plonk.proof_encoding))) -- GitLab From d1ea890872e1f0417f4a5d5b246ed174adf0d581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Mon, 21 Nov 2022 19:06:55 +0100 Subject: [PATCH 3/4] Demos: adapt to env's data-encoding's new shadowing --- src/proto_demo_counter/lib_protocol/error.ml | 2 +- src/proto_demo_counter/lib_protocol/header.ml | 2 +- src/proto_demo_counter/lib_protocol/receipt.ml | 2 +- src/proto_demo_noops/lib_protocol/main.ml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/proto_demo_counter/lib_protocol/error.ml b/src/proto_demo_counter/lib_protocol/error.ml index 22c77c05c413..6b76defe4ad1 100644 --- a/src/proto_demo_counter/lib_protocol/error.ml +++ b/src/proto_demo_counter/lib_protocol/error.ml @@ -44,7 +44,7 @@ let () = ppf "Cannot parse the protocol parameter: %s" (Bytes.to_string bytes)) - (obj1 (req "contents" bytes)) + (obj1 (req "contents" (bytes Hex))) (function Failed_to_parse_parameter data -> Some data | _ -> None) (fun data -> Failed_to_parse_parameter data) ; register_error_kind diff --git a/src/proto_demo_counter/lib_protocol/header.ml b/src/proto_demo_counter/lib_protocol/header.ml index f68e63ecec9b..a996aa54b8d9 100644 --- a/src/proto_demo_counter/lib_protocol/header.ml +++ b/src/proto_demo_counter/lib_protocol/header.ml @@ -26,6 +26,6 @@ type t = string -let encoding = Data_encoding.(obj1 (req "demo_block_header_data" string)) +let encoding = Data_encoding.(obj1 (req "demo_block_header_data" (string Plain))) let create s = s diff --git a/src/proto_demo_counter/lib_protocol/receipt.ml b/src/proto_demo_counter/lib_protocol/receipt.ml index a54ab290d747..7b6a936ded56 100644 --- a/src/proto_demo_counter/lib_protocol/receipt.ml +++ b/src/proto_demo_counter/lib_protocol/receipt.ml @@ -30,4 +30,4 @@ let create t = t let to_string t = t -let encoding = Data_encoding.(obj1 (req "demo_operation_receipt" string)) +let encoding = Data_encoding.(obj1 (req "demo_operation_receipt" (string Plain))) diff --git a/src/proto_demo_noops/lib_protocol/main.ml b/src/proto_demo_noops/lib_protocol/main.ml index f194751ac3a6..854f4bb09bb4 100644 --- a/src/proto_demo_noops/lib_protocol/main.ml +++ b/src/proto_demo_noops/lib_protocol/main.ml @@ -34,7 +34,7 @@ let acceptable_pass _op = None type block_header_data = string let block_header_data_encoding = - Data_encoding.(obj1 (req "block_header_data" string)) + Data_encoding.(obj1 (req "block_header_data" (string Plain))) type block_header = { shell : Block_header.shell_header; -- GitLab From 2dde902f7810b02462a7732cc46b7183eab702c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 23 Nov 2022 08:49:04 +0100 Subject: [PATCH 4/4] Client/injection-test: adapt to env's data-encoding's new shadowing --- src/bin_client/test/proto_test_injection/main.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin_client/test/proto_test_injection/main.ml b/src/bin_client/test/proto_test_injection/main.ml index dc3c67868fba..1f1fbcf51b4c 100644 --- a/src/bin_client/test/proto_test_injection/main.ml +++ b/src/bin_client/test/proto_test_injection/main.ml @@ -31,7 +31,7 @@ type block_header = { } let block_header_data_encoding = - Data_encoding.(obj1 (req "random_data" Variable.bytes)) + Data_encoding.(obj1 (req "random_data" (Variable.bytes Hex))) type block_header_metadata = unit -- GitLab