From ec51a88fee9fdbea2dd38b1d90bf7ee8161e24d1 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Thu, 8 Sep 2022 18:16:23 +0100 Subject: [PATCH 1/5] TzString: chunk sequence of bytes in list of strings --- src/lib_stdlib/test/test_tzString.ml | 100 ++++++++++++++++++++++++++- src/lib_stdlib/tzString.ml | 32 +++++++++ src/lib_stdlib/tzString.mli | 15 ++++ 3 files changed, 146 insertions(+), 1 deletion(-) diff --git a/src/lib_stdlib/test/test_tzString.ml b/src/lib_stdlib/test/test_tzString.ml index a18ed992f15b..0b1da29f35fb 100644 --- a/src/lib_stdlib/test/test_tzString.ml +++ b/src/lib_stdlib/test/test_tzString.ml @@ -1,3 +1,37 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. *) +(* Copyright (c) 2022 Trili Tech *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Testing + _______ + + Invocation: dune build @src/lib_stdlib/test/runtest + *) + +module Assert = Lib_test.Assert + (* Verify the default behavior of split is handling multiple instances of the separator in a row *) @@ -35,4 +69,68 @@ let split_tests = [("handles a duplicated separator", `Quick, test_split_duplicated_separator)] @ Lib_test.Qcheck2_helpers.qcheck_wrap [test_split] -let () = Alcotest.run "TzString" [("split", split_tests)] +let test_chunk_empty () = + match TzString.chunk_bytes 1 Bytes.empty with + | Error _ -> assert false + | Ok strings -> Assert.equal_list ~loc:__LOC__ strings [] + +let test_chunk_no_error_on_partial_chunk () = + match TzString.chunk_bytes 2 @@ Bytes.of_string "Hello World" with + | Error _ -> assert false + | Ok strings -> + Assert.equal_list ~loc:__LOC__ strings ["He"; "ll"; "o "; "Wo"; "rl"; "d"] + +let test_chunk_error_on_partial_chunk () = + let error_on_partial_chunk = "Partial chunk detected!" in + match + TzString.chunk_bytes ~error_on_partial_chunk 2 + @@ Bytes.of_string "Hello World" + with + | Error e -> Assert.equal ~loc:__LOC__ e error_on_partial_chunk + | Ok _ -> assert false + +let test_chunk_no_error_if_complete_chunks () = + match TzString.chunk_bytes 2 @@ Bytes.of_string "Hello World!" with + | Error _ -> assert false + | Ok strings -> + Assert.equal_list + ~loc:__LOC__ + strings + ["He"; "ll"; "o "; "Wo"; "rl"; "d!"] + +let test_chunk_concat = + let open QCheck2 in + let gen = + let open Gen in + let* str = string_size ~gen:printable (6 -- 128) in + let* chunk_size = 1 -- 32 in + return (str, chunk_size) + in + Test.make + ~name:"TzString.chunk_bytes chunks bytes correctly" + gen + (fun (s, chunk_size) -> + match TzString.chunk_bytes chunk_size @@ String.to_bytes s with + | Error _ -> false + | Ok chunks -> + String.concat "" chunks = s && List.hd (List.rev chunks) <> "") + +let chunk_bytes_tests = + [ + ("Returns empty list when splitting empty bytes", `Quick, test_chunk_empty); + ( "Chunks a sequence of bytes - no error, partial chunk", + `Quick, + test_chunk_no_error_on_partial_chunk ); + ( "Errors if last chunk is uncomplete - error passed as argument", + `Quick, + test_chunk_error_on_partial_chunk ); + ( "Chunks a sequence of bytes - error passed as arguments, no partial chunk", + `Quick, + test_chunk_no_error_if_complete_chunks ); + ] + @ Lib_test.Qcheck2_helpers.qcheck_wrap [test_chunk_concat] + +let () = + Alcotest.run + "TzString" + [("split", split_tests); ("chunk_bytes", chunk_bytes_tests)] diff --git a/src/lib_stdlib/tzString.ml b/src/lib_stdlib/tzString.ml index d48ab1fac955..746ed04587ab 100644 --- a/src/lib_stdlib/tzString.ml +++ b/src/lib_stdlib/tzString.ml @@ -58,6 +58,38 @@ let split_no_empty delim ?(limit = max_int) path = in if limit > 0 then do_slashes [] limit 0 else [path] +let chunk_bytes_strict error_on_partial_chunk n b = + let l = Bytes.length b in + if l mod n <> 0 then Error error_on_partial_chunk + else + let rec split seq offset = + if offset = l then List.rev seq + else + let s = Bytes.sub_string b offset n in + split (s :: seq) (offset + n) + in + Ok (split [] 0) + +let chunk_bytes_loose n b = + let l = Bytes.length b in + let rec split seq offset = + if offset = l then List.rev seq + else if offset + n > l then + List.rev (Bytes.sub_string b offset (l - offset) :: seq) + else + let s = Bytes.sub_string b offset n in + split (s :: seq) (offset + n) + in + split [] 0 + +let chunk_bytes ?error_on_partial_chunk n b = + if n <= 0 then raise @@ Invalid_argument "chunk_bytes" + else + match error_on_partial_chunk with + | Some error_on_partial_chunk -> + chunk_bytes_strict error_on_partial_chunk n b + | None -> Ok (chunk_bytes_loose n b) + let has_prefix ~prefix s = let x = String.length prefix in let n = String.length s in diff --git a/src/lib_stdlib/tzString.mli b/src/lib_stdlib/tzString.mli index 90e50a925d0e..0d602f1080f4 100644 --- a/src/lib_stdlib/tzString.mli +++ b/src/lib_stdlib/tzString.mli @@ -44,6 +44,21 @@ val split : char -> ?limit:int -> string -> string list [split_no_empty ',' ",hello,,world,"] returns ["hello"; "world"] *) val split_no_empty : char -> ?limit:int -> string -> string list +(** [chunk_bytes n b] chunks the sequence of bytes [b] into a list of strings, + each of length [n]. The last chunk may be a non-empty string of length less + than [n], in which case the behaviour of the function depends on whether + [error_on_partial_chunk] is set: + {ul + {li If [error_on_partial_chunk] is set, then the function returns + [Error error_on_partial_chunk], + {li Otherwise, the function return the list of chunks, where the + last chunk is a non-empty string of length less than [n].} + } + + @raise Invalid_argument if [n <= 0]. *) +val chunk_bytes : + ?error_on_partial_chunk:'a -> int -> bytes -> (string list, 'a) result + (** [true] if input has prefix *) val has_prefix : prefix:string -> string -> bool -- GitLab From e5aa2d5051083f7941467446ea56938bbea23685 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Fri, 26 Aug 2022 16:27:06 +0200 Subject: [PATCH 2/5] Dal/Node: endpoint to fetch slot segments --- src/bin_dal_node/RPC_server.ml | 20 ++++++++++++++++--- src/bin_dal_node/slot_manager.ml | 28 ++++++++++++++++++++++++++- src/bin_dal_node/slot_manager.mli | 14 ++++++++++++++ src/lib_dal_node_services/services.ml | 7 +++++++ 4 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index b7a390f5c96a..edf3e083f72c 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -48,10 +48,16 @@ let handle_slot initial_constants dal_constants store (_, commitment) trim () = let slot = if trim then Slot_manager.Utils.trim_x00 slot else slot in return (String.of_bytes slot) +let handle_slot_segments initial_constants dal_constants store (_, commitment) + () () = + Slot_manager.get_slot_segments + initial_constants + dal_constants + store + commitment + let handle_shard store ((_, commitment), shard) () () = - let open Lwt_result_syntax in - let* shard = Slot_manager.get_shard store commitment shard in - return shard + Slot_manager.get_shard store commitment shard let register_split_slot {Node_context.dal_parameters; dal_constants; _} store dir = @@ -67,6 +73,13 @@ let register_show_slot {Node_context.dal_parameters; dal_constants; _} store dir (Services.slot ()) (handle_slot dal_parameters dal_constants store) +let register_show_slot_segments {Node_context.dal_parameters; dal_constants; _} + store dir = + RPC_directory.register + dir + (Services.slot_segments ()) + (handle_slot_segments dal_parameters dal_constants store) + let register_shard store dir = RPC_directory.register dir (Services.shard ()) (handle_shard store) @@ -75,6 +88,7 @@ let register ctxt store = |> register_split_slot ctxt store |> register_show_slot ctxt store |> register_shard store + |> register_show_slot_segments ctxt store let start configuration dir = let open Lwt_syntax in diff --git a/src/bin_dal_node/slot_manager.ml b/src/bin_dal_node/slot_manager.ml index b05757ae53aa..384616c8ed6c 100644 --- a/src/bin_dal_node/slot_manager.ml +++ b/src/bin_dal_node/slot_manager.ml @@ -30,6 +30,7 @@ type error += | Missing_shards | Illformed_shard | Slot_not_found + | Illformed_segments let () = register_error_kind @@ -86,7 +87,17 @@ let () = ~pp:(fun ppf () -> Format.fprintf ppf "Illformed shard found in the store") Data_encoding.(unit) (function Illformed_shard -> Some () | _ -> None) - (fun () -> Illformed_shard) + (fun () -> Illformed_shard) ; + register_error_kind + `Permanent + ~id:"dal.node.illformed_segments" + ~title:"Illformed segments" + ~description:"Illformed segments found in the store" + ~pp:(fun ppf () -> + Format.fprintf ppf "Illformed segments found in the store") + Data_encoding.(unit) + (function Illformed_segments -> Some () | _ -> None) + (fun () -> Illformed_segments) type slot = bytes @@ -191,6 +202,21 @@ let get_slot initial_constants dal_constants store slot_header = in return slot +let get_slot_segments ({Cryptobox.segment_size; _} as initial_constants) + dal_constants store slot_header = + let open Lwt_result_syntax in + let* slot = get_slot initial_constants dal_constants store slot_header in + (* The slot size `Bytes.length slot` should be an exact multiple of `segment_size`. + If this is not the case, we throw an `Illformed_segments` error. + *) + let*? segments = + String.chunk_bytes + segment_size + slot + ~error_on_partial_chunk:(TzTrace.make Illformed_segments) + in + return segments + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3405 This can work only if a slot never ends with a `\000`. But I am not diff --git a/src/bin_dal_node/slot_manager.mli b/src/bin_dal_node/slot_manager.mli index e4e6bd1d3c9e..5fd7a1724394 100644 --- a/src/bin_dal_node/slot_manager.mli +++ b/src/bin_dal_node/slot_manager.mli @@ -53,6 +53,20 @@ val get_slot : Cryptobox.commitment -> slot tzresult Lwt.t +(** [get_slot_segments] behaves as [get_slot], except that it also + splits the slot into segments before returning them. + + Returns an [Error _] if the length of the slot associated to the + [Cryptobox.commitment] is ill-formed. Specifically, when its + length is not a multiple of the segment-size specified in the + [Cryptobox.parameters] argument. *) +val get_slot_segments : + Cryptobox.parameters -> + Cryptobox.t -> + Store.t -> + Cryptobox.commitment -> + string list tzresult Lwt.t + module Utils : sig (** [trim_x00 s] removes trailing '\000' at the end of [s] and returns a new [slot]. This function is needed to debug the fetched slot and diff --git a/src/lib_dal_node_services/services.ml b/src/lib_dal_node_services/services.ml index 2ac54048f2d8..02d5df795f59 100644 --- a/src/lib_dal_node_services/services.ml +++ b/src/lib_dal_node_services/services.ml @@ -52,6 +52,13 @@ let slot () = ~output:Data_encoding.string RPC_path.(open_root / "slot" / "content" /: Cryptobox.Commitment.rpc_arg) +let slot_segments () = + RPC_service.get_service + ~description:"Fetch slot as list of segments" + ~query:RPC_query.empty + ~output:(Data_encoding.list Data_encoding.string) + RPC_path.(open_root / "slot" / "segments" /: Cryptobox.Commitment.rpc_arg) + let shard () = let shard_arg = RPC_arg.int in RPC_service.get_service -- GitLab From 72d49534a36bd0a46c9ad89caa989060c708863d Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Thu, 1 Sep 2022 11:31:33 +0200 Subject: [PATCH 3/5] Dal/Tezt: check that call to retrieve slot segments is successful --- tezt/lib_tezos/rollup.ml | 4 ++++ tezt/lib_tezos/rollup.mli | 3 +++ tezt/tests/dal.ml | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/tezt/lib_tezos/rollup.ml b/tezt/lib_tezos/rollup.ml index 329ab3b63ccb..c32efcd4d5ba 100644 --- a/tezt/lib_tezos/rollup.ml +++ b/tezt/lib_tezos/rollup.ml @@ -557,6 +557,10 @@ module Dal = struct ["slot"; "content"; slot_header] ~query_string:[("trim", "")] JSON.as_string + + let slot_segments slot_header = + make GET ["slot"; "segments"; slot_header] (fun segments -> + segments |> JSON.as_list |> List.map JSON.as_string) end module Cryptobox = Tezos_crypto_dal.Cryptobox diff --git a/tezt/lib_tezos/rollup.mli b/tezt/lib_tezos/rollup.mli index b153e4abdb66..100b708e6d9c 100644 --- a/tezt/lib_tezos/rollup.mli +++ b/tezt/lib_tezos/rollup.mli @@ -234,6 +234,9 @@ module Dal : sig (** [slot_content slot_header] gets slot/content of [slot_header] *) val slot_content : string -> (Dal_node.t, string) RPC_core.t + + (** [slot_segments slot_header] gets slot/segments of [slot_header] *) + val slot_segments : string -> (Dal_node.t, string list) RPC_core.t end module Cryptobox = Tezos_crypto_dal.Cryptobox diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index ac3fb9d6f89c..5f6996442cc4 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -472,6 +472,12 @@ let test_dal_node_slot_management = let* received_slot_content = RPC.call dal_node (Rollup.Dal.RPC.slot_content slot_header) in + (* DAL/FIXME: https://gitlab.com/tezos/tezos/-/issues/3804 + Only check that the function to retrieve segments succeeds, actual + contents will be checked in a test upcoming. *) + let* _slots_as_segments = + RPC.call dal_node (Rollup.Dal.RPC.slot_segments slot_header) + in assert (slot_content = received_slot_content) ; return () -- GitLab From e9fab5f0205ac57fb74d297e5e3ed710e4335bc2 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 12 Sep 2022 11:46:41 +0100 Subject: [PATCH 4/5] Dal: Rename segment to page across dal related codebase --- src/bin_dal_node/RPC_server.ml | 18 ++- src/bin_dal_node/slot_manager.ml | 31 +++--- src/bin_dal_node/slot_manager.mli | 8 +- src/lib_crypto_dal/cryptobox.ml | 104 +++++++++--------- src/lib_crypto_dal/cryptobox.mli | 21 ++-- src/lib_crypto_dal/cryptobox_intf.ml | 28 ++--- src/lib_crypto_dal/test/test_dal_cryptobox.ml | 10 +- src/lib_dal_node_services/services.ml | 6 +- src/lib_protocol_environment/sigs/v7.ml | 28 ++--- src/lib_protocol_environment/sigs/v7/dal.mli | 28 ++--- .../lib_dal/dal_plugin_registration.ml | 4 +- .../lib_parameters/default_parameters.ml | 4 +- .../lib_protocol/alpha_context.mli | 2 +- .../lib_protocol/constants_parametric_repr.ml | 12 +- .../constants_parametric_repr.mli | 2 +- src/proto_alpha/lib_protocol/raw_context.ml | 2 +- tezt/lib_tezos/rollup.ml | 18 ++- tezt/lib_tezos/rollup.mli | 6 +- tezt/tests/dal.ml | 6 +- 19 files changed, 163 insertions(+), 175 deletions(-) diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index edf3e083f72c..0477087de050 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -48,13 +48,9 @@ let handle_slot initial_constants dal_constants store (_, commitment) trim () = let slot = if trim then Slot_manager.Utils.trim_x00 slot else slot in return (String.of_bytes slot) -let handle_slot_segments initial_constants dal_constants store (_, commitment) - () () = - Slot_manager.get_slot_segments - initial_constants - dal_constants - store - commitment +let handle_slot_pages initial_constants dal_constants store (_, commitment) () + () = + Slot_manager.get_slot_pages initial_constants dal_constants store commitment let handle_shard store ((_, commitment), shard) () () = Slot_manager.get_shard store commitment shard @@ -73,12 +69,12 @@ let register_show_slot {Node_context.dal_parameters; dal_constants; _} store dir (Services.slot ()) (handle_slot dal_parameters dal_constants store) -let register_show_slot_segments {Node_context.dal_parameters; dal_constants; _} +let register_show_slot_pages {Node_context.dal_parameters; dal_constants; _} store dir = RPC_directory.register dir - (Services.slot_segments ()) - (handle_slot_segments dal_parameters dal_constants store) + (Services.slot_pages ()) + (handle_slot_pages dal_parameters dal_constants store) let register_shard store dir = RPC_directory.register dir (Services.shard ()) (handle_shard store) @@ -88,7 +84,7 @@ let register ctxt store = |> register_split_slot ctxt store |> register_show_slot ctxt store |> register_shard store - |> register_show_slot_segments ctxt store + |> register_show_slot_pages ctxt store let start configuration dir = let open Lwt_syntax in diff --git a/src/bin_dal_node/slot_manager.ml b/src/bin_dal_node/slot_manager.ml index 384616c8ed6c..580e76cfc7bc 100644 --- a/src/bin_dal_node/slot_manager.ml +++ b/src/bin_dal_node/slot_manager.ml @@ -30,7 +30,7 @@ type error += | Missing_shards | Illformed_shard | Slot_not_found - | Illformed_segments + | Illformed_pages let () = register_error_kind @@ -90,14 +90,13 @@ let () = (fun () -> Illformed_shard) ; register_error_kind `Permanent - ~id:"dal.node.illformed_segments" - ~title:"Illformed segments" - ~description:"Illformed segments found in the store" - ~pp:(fun ppf () -> - Format.fprintf ppf "Illformed segments found in the store") + ~id:"dal.node.illformed_pages" + ~title:"Illformed pages" + ~description:"Illformed pages found in the store" + ~pp:(fun ppf () -> Format.fprintf ppf "Illformed pages found in the store") Data_encoding.(unit) - (function Illformed_segments -> Some () | _ -> None) - (fun () -> Illformed_segments) + (function Illformed_pages -> Some () | _ -> None) + (fun () -> Illformed_pages) type slot = bytes @@ -202,20 +201,20 @@ let get_slot initial_constants dal_constants store slot_header = in return slot -let get_slot_segments ({Cryptobox.segment_size; _} as initial_constants) - dal_constants store slot_header = +let get_slot_pages ({Cryptobox.page_size; _} as initial_constants) dal_constants + store slot_header = let open Lwt_result_syntax in let* slot = get_slot initial_constants dal_constants store slot_header in - (* The slot size `Bytes.length slot` should be an exact multiple of `segment_size`. - If this is not the case, we throw an `Illformed_segments` error. + (* The slot size `Bytes.length slot` should be an exact multiple of `page_size`. + If this is not the case, we throw an `Illformed_pages` error. *) - let*? segments = + let*? pages = String.chunk_bytes - segment_size + page_size slot - ~error_on_partial_chunk:(TzTrace.make Illformed_segments) + ~error_on_partial_chunk:(TzTrace.make Illformed_pages) in - return segments + return pages (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3405 diff --git a/src/bin_dal_node/slot_manager.mli b/src/bin_dal_node/slot_manager.mli index 5fd7a1724394..ebff339846a8 100644 --- a/src/bin_dal_node/slot_manager.mli +++ b/src/bin_dal_node/slot_manager.mli @@ -53,14 +53,14 @@ val get_slot : Cryptobox.commitment -> slot tzresult Lwt.t -(** [get_slot_segments] behaves as [get_slot], except that it also - splits the slot into segments before returning them. +(** [get_slot_pages] behaves as [get_slot], except that it also + splits the slot into pages before returning them. Returns an [Error _] if the length of the slot associated to the [Cryptobox.commitment] is ill-formed. Specifically, when its - length is not a multiple of the segment-size specified in the + length is not a multiple of the page-size specified in the [Cryptobox.parameters] argument. *) -val get_slot_segments : +val get_slot_pages : Cryptobox.parameters -> Cryptobox.t -> Store.t -> diff --git a/src/lib_crypto_dal/cryptobox.ml b/src/lib_crypto_dal/cryptobox.ml index d798653b61f9..559e503a16df 100644 --- a/src/lib_crypto_dal/cryptobox.ml +++ b/src/lib_crypto_dal/cryptobox.ml @@ -105,7 +105,7 @@ let initialisation_parameters_from_files ~g1_path ~g2_path = type srs = { raw : initialisation_parameters; kate_amortized_srs_g2_shards : Bls12_381.G2.t; - kate_amortized_srs_g2_segments : Bls12_381.G2.t; + kate_amortized_srs_g2_pages : Bls12_381.G2.t; } module Inner = struct @@ -135,9 +135,9 @@ module Inner = struct type _proof_single = Bls12_381.G1.t - type segment_proof = Bls12_381.G1.t + type page_proof = Bls12_381.G1.t - type segment = {index : int; content : bytes} + type page = {index : int; content : bytes} type share = Scalar.t array @@ -145,7 +145,7 @@ module Inner = struct type shard = {index : int; share : share} - type shards_proofs_precomputation = Scalar.t array * segment_proof array array + type shards_proofs_precomputation = Scalar.t array * page_proof array array module Encoding = struct open Data_encoding @@ -167,7 +167,7 @@ module Inner = struct let _proof_single_encoding = g1_encoding - let segment_proof_encoding = g1_encoding + let page_proof_encoding = g1_encoding let share_encoding = array fr_encoding @@ -269,7 +269,7 @@ module Inner = struct type t = { redundancy_factor : int; slot_size : int; - segment_size : int; + page_size : int; number_of_shards : int; k : int; n : int; @@ -281,9 +281,9 @@ module Inner = struct (* Domain for the FFT on erasure encoded slots (as polynomials). *) shard_size : int; (* Length of a shard in terms of scalar elements. *) - nb_segments : int; - (* Number of slot segments. *) - segment_length : int; + nb_pages : int; + (* Number of slot pages. *) + page_length : int; remaining_bytes : int; evaluations_log : int; (* Log of the number of evaluations that constitute an erasure encoded @@ -303,11 +303,10 @@ module Inner = struct in if not - (is_pow_of_two t.slot_size - && is_pow_of_two t.segment_size - && is_pow_of_two t.n) + (is_pow_of_two t.slot_size && is_pow_of_two t.page_size + && is_pow_of_two t.n) then - (* According to the specification the lengths of a slot a slot segment are + (* According to the specification the lengths of a slot page are in MiB *) fail (`Fail "Wrong slot size: expected MiB") else if not (Z.(log2 (of_int t.n)) <= 32 && is_pow_of_two t.k && t.n > t.k) @@ -329,21 +328,21 @@ module Inner = struct type parameters = { redundancy_factor : int; - segment_size : int; + page_size : int; slot_size : int; number_of_shards : int; } (* Error cases of this functions are not encapsulated into `tzresult` for modularity reasons. *) - let make {redundancy_factor; slot_size; segment_size; number_of_shards} = + let make {redundancy_factor; slot_size; page_size; number_of_shards} = let open Result_syntax in let k = slot_as_polynomial_length ~slot_size in let n = redundancy_factor * k in let shard_size = n / number_of_shards in let evaluations_log = Z.(log2 (of_int n)) in let evaluations_per_proof_log = Z.(log2 (of_int shard_size)) in - let segment_length = Int.div segment_size scalar_bytes_amount + 1 in + let page_length = Int.div page_size scalar_bytes_amount + 1 in let* srs = match !initialisation_parameters with | None -> fail (`Fail "Dal_cryptobox.make: DAL was not initialisated.") @@ -353,15 +352,15 @@ module Inner = struct raw; kate_amortized_srs_g2_shards = Srs_g2.get raw.srs_g2 (1 lsl evaluations_per_proof_log); - kate_amortized_srs_g2_segments = - Srs_g2.get raw.srs_g2 (1 lsl Z.(log2up (of_int segment_length))); + kate_amortized_srs_g2_pages = + Srs_g2.get raw.srs_g2 (1 lsl Z.(log2up (of_int page_length))); } in let t = { redundancy_factor; slot_size; - segment_size; + page_size; number_of_shards; k; n; @@ -369,9 +368,9 @@ module Inner = struct domain_2k = make_domain (2 * k); domain_n = make_domain n; shard_size; - nb_segments = slot_size / segment_size; - segment_length; - remaining_bytes = segment_size mod scalar_bytes_amount; + nb_pages = slot_size / page_size; + page_length; + remaining_bytes = page_size mod scalar_bytes_amount; evaluations_log; evaluations_per_proof_log; proofs_log = evaluations_log - evaluations_per_proof_log; @@ -389,7 +388,7 @@ module Inner = struct let evaluations = List.map (evaluation_fft d) ps in interpolation_fft d (mul_c ~evaluations ()) - (* We encode by segments of [segment_size] bytes each. The segments + (* We encode by pages of [page_size] bytes each. The pages are arranged in cosets to evaluate in batch with Kate amortized. *) let polynomial_from_bytes' (t : t) slot = @@ -400,19 +399,19 @@ module Inner = struct else let offset = ref 0 in let res = Array.init t.k (fun _ -> Scalar.(copy zero)) in - for segment = 0 to t.nb_segments - 1 do - for elt = 0 to t.segment_length - 1 do + for page = 0 to t.nb_pages - 1 do + for elt = 0 to t.page_length - 1 do if !offset > t.slot_size then () - else if elt = t.segment_length - 1 then ( + else if elt = t.page_length - 1 then ( let dst = Bytes.create t.remaining_bytes in Bytes.blit slot !offset dst 0 t.remaining_bytes ; offset := !offset + t.remaining_bytes ; - res.((elt * t.nb_segments) + segment) <- Scalar.of_bytes_exn dst) + res.((elt * t.nb_pages) + page) <- Scalar.of_bytes_exn dst) else let dst = Bytes.create scalar_bytes_amount in Bytes.blit slot !offset dst 0 scalar_bytes_amount ; offset := !offset + scalar_bytes_amount ; - res.((elt * t.nb_segments) + segment) <- Scalar.of_bytes_exn dst + res.((elt * t.nb_pages) + page) <- Scalar.of_bytes_exn dst done done ; Ok res @@ -422,11 +421,11 @@ module Inner = struct let* data = polynomial_from_bytes' t slot in Ok (Evaluations.interpolation_fft2 t.domain_k data) - let eval_coset t eval slot offset segment = - for elt = 0 to t.segment_length - 1 do - let idx = (elt * t.nb_segments) + segment in + let eval_coset t eval slot offset page = + for elt = 0 to t.page_length - 1 do + let idx = (elt * t.nb_pages) + page in let coeff = Scalar.to_bytes (Array.get eval idx) in - if elt = t.segment_length - 1 then ( + if elt = t.page_length - 1 then ( Bytes.blit coeff 0 slot !offset t.remaining_bytes ; offset := !offset + t.remaining_bytes) else ( @@ -434,14 +433,14 @@ module Inner = struct offset := !offset + scalar_bytes_amount) done - (* The segments are arranged in cosets to evaluate in batch with Kate + (* The pages are arranged in cosets to evaluate in batch with Kate amortized. *) let polynomial_to_bytes t p = let eval = Evaluations.(evaluation_fft t.domain_k p |> to_array) in let slot = Bytes.init t.slot_size (fun _ -> '0') in let offset = ref 0 in - for segment = 0 to t.nb_segments - 1 do - eval_coset t eval slot offset segment + for page = 0 to t.nb_pages - 1 do + eval_coset t eval slot offset page done ; slot @@ -790,42 +789,41 @@ module Inner = struct (proof, G2.(add h_secret (negate (mul (copy one) point)))); ]) - let prove_segment t p segment_index = - if segment_index < 0 || segment_index >= t.nb_segments then + let prove_page t p page_index = + if page_index < 0 || page_index >= t.nb_pages then Error `Segment_index_out_of_range else - let l = 1 lsl Z.(log2up (of_int t.segment_length)) in - let wi = Domains.get t.domain_k segment_index in + let l = 1 lsl Z.(log2up (of_int t.page_length)) in + let wi = Domains.get t.domain_k page_index in let quotient, _ = Polynomials.(division_xn p l Scalar.(negate (pow wi (Z.of_int l)))) in Ok (commit t quotient) - (* Parses the [slot_segment] to get the evaluations that it contains. The - evaluation points are given by the [slot_segment_index]. *) - let verify_segment t cm {index = slot_segment_index; content = slot_segment} - proof = - if slot_segment_index < 0 || slot_segment_index >= t.nb_segments then + (* Parses the [slot_page] to get the evaluations that it contains. The + evaluation points are given by the [slot_page_index]. *) + let verify_page t cm {index = slot_page_index; content = slot_page} proof = + if slot_page_index < 0 || slot_page_index >= t.nb_pages then Error `Segment_index_out_of_range else - let domain = Domains.build ~log:Z.(log2up (of_int t.segment_length)) in - let slot_segment_evaluations = + let domain = Domains.build ~log:Z.(log2up (of_int t.page_length)) in + let slot_page_evaluations = Array.init - (1 lsl Z.(log2up (of_int t.segment_length))) + (1 lsl Z.(log2up (of_int t.page_length))) (function - | i when i < t.segment_length - 1 -> + | i when i < t.page_length - 1 -> let dst = Bytes.create scalar_bytes_amount in Bytes.blit - slot_segment + slot_page (i * scalar_bytes_amount) dst 0 scalar_bytes_amount ; Scalar.of_bytes_exn dst - | i when i = t.segment_length - 1 -> + | i when i = t.page_length - 1 -> let dst = Bytes.create t.remaining_bytes in Bytes.blit - slot_segment + slot_page (i * scalar_bytes_amount) dst 0 @@ -837,9 +835,9 @@ module Inner = struct (verify t cm - t.srs.kate_amortized_srs_g2_segments + t.srs.kate_amortized_srs_g2_pages domain - (Domains.get t.domain_k slot_segment_index, slot_segment_evaluations) + (Domains.get t.domain_k slot_page_index, slot_page_evaluations) proof) end diff --git a/src/lib_crypto_dal/cryptobox.mli b/src/lib_crypto_dal/cryptobox.mli index 0694fb1eac42..9be137a21ddf 100644 --- a/src/lib_crypto_dal/cryptobox.mli +++ b/src/lib_crypto_dal/cryptobox.mli @@ -29,7 +29,7 @@ open Cryptobox_intf a value of type [t] *) type parameters = { redundancy_factor : int; - segment_size : int; + page_size : int; slot_size : int; number_of_shards : int; } @@ -49,7 +49,7 @@ type t 1. A proof that a commitment is valid - 2. A proof that a segment is valid + 2. A proof that a page is valid A technicality is that the economic protocol is able to configure those cryptographic primitives via several constants. Also, an SRS @@ -111,8 +111,8 @@ type scalar 1. A commitment ensures that the size of the [slot] has a bounded size (typically [slot_size]). - 2. A commitment can be used to verify that a segment of fixed size - (typically [segment_size]) is part of the original slot. *) + 2. A commitment can be used to verify that a page of fixed size + (typically [page_size]) is part of the original slot. *) type polynomial (** [polynomial_degree polynomial] returns the degree of the @@ -185,14 +185,11 @@ val verify_shard : t -> commitment -> shard -> shard_proof -> bool maximum slot size. *) val prove_commitment : t -> polynomial -> commitment_proof -(** [prove_segment] produces a proof that the [n]th segment computed - is part of a commitment. This segment corresponds to the original - data and are split into [C.segment_size]. *) -val prove_segment : - t -> - polynomial -> - int -> - (segment_proof, [> `Segment_index_out_of_range]) result +(** [prove_page] produces a proof that the [n]th page computed + is part of a commitment. This page corresponds to the original + data and are split into [C.page_size]. *) +val prove_page : + t -> polynomial -> int -> (page_proof, [> `Segment_index_out_of_range]) result (** [prove_shards] computes the proofs for all the [shards] that each [shard] is a valid piece of data associated to a polynomial diff --git a/src/lib_crypto_dal/cryptobox_intf.ml b/src/lib_crypto_dal/cryptobox_intf.ml index a7db897600a6..ad5744acbbc6 100644 --- a/src/lib_crypto_dal/cryptobox_intf.ml +++ b/src/lib_crypto_dal/cryptobox_intf.ml @@ -53,7 +53,7 @@ module type VERIFIER = sig (** Parameters to build a value of type [t] *) type parameters = { redundancy_factor : int; - segment_size : int; + page_size : int; slot_size : int; number_of_shards : int; } @@ -80,28 +80,28 @@ module type VERIFIER = sig exceed [C.slot_size]. The verification time is constant. *) val verify_commitment : t -> commitment -> commitment_proof -> bool - (** The original slot can be split into a list of segments of size - [segment_size]. A segment is consequently encoded as a pair of an - [index] and the content of this segment. *) - type segment = {index : int; content : bytes} + (** The original slot can be split into a list of pages of size + [page_size]. A page is consequently encoded as a pair of an + [index] and the content of this page. *) + type page = {index : int; content : bytes} (** A proof that the evaluation of points of a polynomial is part of a commitment. *) - type segment_proof + type page_proof - (** An encoding for the proof of a segment. *) - val segment_proof_encoding : segment_proof Data_encoding.t + (** An encoding for the proof of a page. *) + val page_proof_encoding : page_proof Data_encoding.t - (** [verify_segment t srs commitment segment segment_proof] returns [Ok - true] if the [proof] certifies that the [slot_segment] is indeed + (** [verify_page t srs commitment page page_proof] returns [Ok + true] if the [proof] certifies that the [slot_page] is indeed included in the slot committed with commitment [commitment]. Returns [Ok false] otherwise. - Fails if the index of the segment is out of range. *) - val verify_segment : + Fails if the index of the page is out of range. *) + val verify_page : t -> commitment -> - segment -> - segment_proof -> + page -> + page_proof -> (bool, [> `Segment_index_out_of_range]) Result.t end diff --git a/src/lib_crypto_dal/test/test_dal_cryptobox.ml b/src/lib_crypto_dal/test/test_dal_cryptobox.ml index eb77c32ffe51..2ee000305b6a 100644 --- a/src/lib_crypto_dal/test/test_dal_cryptobox.ml +++ b/src/lib_crypto_dal/test/test_dal_cryptobox.ml @@ -28,7 +28,7 @@ module Test = struct (* We take mainnet parameters we divide by [16] to speed up the test. *) let number_of_shards = 2048 / 16 in let slot_size = 1048576 / 16 in - let segment_size = 4096 / 16 in + let page_size = 4096 / 16 in let msg_size = slot_size in let msg = Bytes.create msg_size in for i = 0 to (msg_size / 8) - 1 do @@ -43,14 +43,14 @@ module Test = struct (fun redundancy_factor -> let* t = Cryptobox.make - {redundancy_factor; slot_size; segment_size; number_of_shards} + {redundancy_factor; slot_size; page_size; number_of_shards} in let* p = Cryptobox.polynomial_from_slot t msg in let cm = Cryptobox.commit t p in - let* pi = Cryptobox.prove_segment t p 1 in - let segment = Bytes.sub msg segment_size segment_size in + let* pi = Cryptobox.prove_page t p 1 in + let page = Bytes.sub msg page_size page_size in let* check = - Cryptobox.verify_segment t cm {index = 1; content = segment} pi + Cryptobox.verify_page t cm {index = 1; content = page} pi in assert check ; diff --git a/src/lib_dal_node_services/services.ml b/src/lib_dal_node_services/services.ml index 02d5df795f59..da0f86a53da7 100644 --- a/src/lib_dal_node_services/services.ml +++ b/src/lib_dal_node_services/services.ml @@ -52,12 +52,12 @@ let slot () = ~output:Data_encoding.string RPC_path.(open_root / "slot" / "content" /: Cryptobox.Commitment.rpc_arg) -let slot_segments () = +let slot_pages () = RPC_service.get_service - ~description:"Fetch slot as list of segments" + ~description:"Fetch slot as list of pages" ~query:RPC_query.empty ~output:(Data_encoding.list Data_encoding.string) - RPC_path.(open_root / "slot" / "segments" /: Cryptobox.Commitment.rpc_arg) + RPC_path.(open_root / "slot" / "pages" /: Cryptobox.Commitment.rpc_arg) let shard () = let shard_arg = RPC_arg.int in diff --git a/src/lib_protocol_environment/sigs/v7.ml b/src/lib_protocol_environment/sigs/v7.ml index 858a6365c401..69f09c0323ac 100644 --- a/src/lib_protocol_environment/sigs/v7.ml +++ b/src/lib_protocol_environment/sigs/v7.ml @@ -11741,7 +11741,7 @@ type t (** Parameters to build a value of type [t] *) type parameters = { redundancy_factor : int; - segment_size : int; + page_size : int; slot_size : int; number_of_shards : int; } @@ -11786,29 +11786,29 @@ val commitment_proof_encoding : commitment_proof Data_encoding.t exceed [C.slot_size]. The verification time is constant. *) val verify_commitment : t -> commitment -> commitment_proof -> bool -(** The original slot can be split into a list of segments of size - [segment_size]. A segment is consequently encoded as a pair of an - [index] and the content of this segment. *) -type segment = {index : int; content : bytes} +(** The original slot can be split into a list of pages of size + [page_size]. A page is consequently encoded as a pair of an + [index] and the content of this page. *) +type page = {index : int; content : bytes} (** A proof that the evaluation of points of a polynomial is part of a commitment. *) -type segment_proof +type page_proof -(** An encoding for the proof of a segment. *) -val segment_proof_encoding : segment_proof Data_encoding.t +(** An encoding for the proof of a page. *) +val page_proof_encoding : page_proof Data_encoding.t -(** [verify_segment t commitment segment segment_proof] returns [Ok - true] if the [proof] certifies that the [slot_segment] is indeed +(** [verify_page t commitment page page_proof] returns [Ok + true] if the [proof] certifies that the [slot_page] is indeed included in the slot committed with commitment [commitment]. Returns [Ok false] otherwise. - Fails if the index of the segment is out of range. *) -val verify_segment : + Fails if the index of the page is out of range. *) +val verify_page : t -> commitment -> - segment -> - segment_proof -> + page -> + page_proof -> ( bool, [> `Degree_exceeds_srs_length of string | `Segment_index_out_of_range] ) Result.t diff --git a/src/lib_protocol_environment/sigs/v7/dal.mli b/src/lib_protocol_environment/sigs/v7/dal.mli index 60680553abc0..3d4566627d53 100644 --- a/src/lib_protocol_environment/sigs/v7/dal.mli +++ b/src/lib_protocol_environment/sigs/v7/dal.mli @@ -29,7 +29,7 @@ type t (** Parameters to build a value of type [t] *) type parameters = { redundancy_factor : int; - segment_size : int; + page_size : int; slot_size : int; number_of_shards : int; } @@ -74,29 +74,29 @@ val commitment_proof_encoding : commitment_proof Data_encoding.t exceed [C.slot_size]. The verification time is constant. *) val verify_commitment : t -> commitment -> commitment_proof -> bool -(** The original slot can be split into a list of segments of size - [segment_size]. A segment is consequently encoded as a pair of an - [index] and the content of this segment. *) -type segment = {index : int; content : bytes} +(** The original slot can be split into a list of pages of size + [page_size]. A page is consequently encoded as a pair of an + [index] and the content of this page. *) +type page = {index : int; content : bytes} (** A proof that the evaluation of points of a polynomial is part of a commitment. *) -type segment_proof +type page_proof -(** An encoding for the proof of a segment. *) -val segment_proof_encoding : segment_proof Data_encoding.t +(** An encoding for the proof of a page. *) +val page_proof_encoding : page_proof Data_encoding.t -(** [verify_segment t commitment segment segment_proof] returns [Ok - true] if the [proof] certifies that the [slot_segment] is indeed +(** [verify_page t commitment page page_proof] returns [Ok + true] if the [proof] certifies that the [slot_page] is indeed included in the slot committed with commitment [commitment]. Returns [Ok false] otherwise. - Fails if the index of the segment is out of range. *) -val verify_segment : + Fails if the index of the page is out of range. *) +val verify_page : t -> commitment -> - segment -> - segment_proof -> + page -> + page_proof -> ( bool, [> `Degree_exceeds_srs_length of string | `Segment_index_out_of_range] ) Result.t diff --git a/src/proto_alpha/lib_dal/dal_plugin_registration.ml b/src/proto_alpha/lib_dal/dal_plugin_registration.ml index 17490442a541..5419fac02d36 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -31,12 +31,12 @@ module Plugin = struct let open Lwt_result_syntax in let* constants = Protocol.Constants_services.all cpctxt (chain, block) in let Protocol.Alpha_context.Constants.Parametric. - {redundancy_factor; segment_size; slot_size; number_of_shards; _} = + {redundancy_factor; page_size; slot_size; number_of_shards; _} = constants.parametric.dal in return Environment.Dal. - {redundancy_factor; segment_size; slot_size; number_of_shards} + {redundancy_factor; page_size; slot_size; number_of_shards} end let () = Dal_constants_plugin.register (module Plugin) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 1e71aca49e0b..1e333ec15d8e 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -68,7 +68,7 @@ let default_dal = availability_threshold = 50; slot_size = 1 lsl 20; redundancy_factor = 16; - segment_size = 4096; + page_size = 4096; } let constants_mainnet = @@ -252,7 +252,7 @@ let default_dal_sandbox = availability_threshold = 50; slot_size = 1 lsl 16; redundancy_factor = 4; - segment_size = 4096; + page_size = 4096; } let constants_sandbox = diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 48b4e04fb96b..02d9d09902aa 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -781,7 +781,7 @@ module Constants : sig availability_threshold : int; slot_size : int; redundancy_factor : int; - segment_size : int; + page_size : int; } val dal_encoding : dal Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index d5744558b6d4..b443b19048e7 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -33,7 +33,7 @@ type dal = { availability_threshold : int; slot_size : int; redundancy_factor : int; - segment_size : int; + page_size : int; } let dal_encoding = @@ -47,7 +47,7 @@ let dal_encoding = availability_threshold; slot_size; redundancy_factor; - segment_size; + page_size; } -> ( feature_enable, number_of_slots, @@ -56,7 +56,7 @@ let dal_encoding = availability_threshold, slot_size, redundancy_factor, - segment_size )) + page_size )) (fun ( feature_enable, number_of_slots, number_of_shards, @@ -64,7 +64,7 @@ let dal_encoding = availability_threshold, slot_size, redundancy_factor, - segment_size ) -> + page_size ) -> { feature_enable; number_of_slots; @@ -73,7 +73,7 @@ let dal_encoding = availability_threshold; slot_size; redundancy_factor; - segment_size; + page_size; }) (obj8 (req "feature_enable" Data_encoding.bool) @@ -83,7 +83,7 @@ let dal_encoding = (req "availability_threshold" Data_encoding.int16) (req "slot_size" Data_encoding.int31) (req "redundancy_factor" Data_encoding.uint8) - (req "segment_size" Data_encoding.uint16)) + (req "page_size" Data_encoding.uint16)) (* The encoded representation of this type is stored in the context as bytes. Changing the encoding, or the value of these constants from diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 7c0de926e551..132226d6b584 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -33,7 +33,7 @@ type dal = { availability_threshold : int; slot_size : int; redundancy_factor : int; - segment_size : int; + page_size : int; } val dal_encoding : dal Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index dc5a33e10d10..d1d4786e14a9 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -942,7 +942,7 @@ let prepare_first_block ~level ~timestamp ctxt = availability_threshold = 50; slot_size = 1 lsl 20; redundancy_factor = 16; - segment_size = 4096; + page_size = 4096; } in (* Inherit values that existed in previous protocol and haven't changed. diff --git a/tezt/lib_tezos/rollup.ml b/tezt/lib_tezos/rollup.ml index c32efcd4d5ba..1b9242fefffe 100644 --- a/tezt/lib_tezos/rollup.ml +++ b/tezt/lib_tezos/rollup.ml @@ -510,7 +510,7 @@ module Dal = struct number_of_shards : int; redundancy_factor : int; slot_size : int; - segment_size : int; + page_size : int; } let parameter_file protocol = @@ -525,8 +525,8 @@ module Dal = struct let number_of_shards = JSON.(json |-> "number_of_shards" |> as_int) in let redundancy_factor = JSON.(json |-> "redundancy_factor" |> as_int) in let slot_size = JSON.(json |-> "slot_size" |> as_int) in - let segment_size = JSON.(json |-> "segment_size" |> as_int) in - return {number_of_shards; redundancy_factor; slot_size; segment_size} + let page_size = JSON.(json |-> "page_size" |> as_int) in + return {number_of_shards; redundancy_factor; slot_size; page_size} end module RPC = struct @@ -558,9 +558,9 @@ module Dal = struct ~query_string:[("trim", "")] JSON.as_string - let slot_segments slot_header = - make GET ["slot"; "segments"; slot_header] (fun segments -> - segments |> JSON.as_list |> List.map JSON.as_string) + let slot_pages slot_header = + make GET ["slot"; "pages"; slot_header] (fun pages -> + pages |> JSON.as_list |> List.map JSON.as_string) end module Cryptobox = Tezos_crypto_dal.Cryptobox @@ -568,16 +568,14 @@ module Dal = struct let make ?(on_error = fun msg -> Test.fail "Rollup.Dal.make: Unexpected error: %s" msg) - Parameters.{redundancy_factor; number_of_shards; slot_size; segment_size} - = + Parameters.{redundancy_factor; number_of_shards; slot_size; page_size} = let initialisation_parameters = Cryptobox.Internal_for_tests.initialisation_parameters_from_slot_size ~slot_size in Cryptobox.Internal_for_tests.load_parameters initialisation_parameters ; match - Cryptobox.make - {redundancy_factor; slot_size; segment_size; number_of_shards} + Cryptobox.make {redundancy_factor; slot_size; page_size; number_of_shards} with | Ok cryptobox -> cryptobox | Error (`Fail msg) -> on_error msg diff --git a/tezt/lib_tezos/rollup.mli b/tezt/lib_tezos/rollup.mli index 100b708e6d9c..ea717b79c063 100644 --- a/tezt/lib_tezos/rollup.mli +++ b/tezt/lib_tezos/rollup.mli @@ -220,7 +220,7 @@ module Dal : sig number_of_shards : int; redundancy_factor : int; slot_size : int; - segment_size : int; + page_size : int; } val parameter_file : Protocol.t -> string Lwt.t @@ -235,8 +235,8 @@ module Dal : sig (** [slot_content slot_header] gets slot/content of [slot_header] *) val slot_content : string -> (Dal_node.t, string) RPC_core.t - (** [slot_segments slot_header] gets slot/segments of [slot_header] *) - val slot_segments : string -> (Dal_node.t, string list) RPC_core.t + (** [slot_pages slot_header] gets slot/pages of [slot_header] *) + val slot_pages : string -> (Dal_node.t, string list) RPC_core.t end module Cryptobox = Tezos_crypto_dal.Cryptobox diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 5f6996442cc4..47acab5eb83b 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -473,10 +473,10 @@ let test_dal_node_slot_management = RPC.call dal_node (Rollup.Dal.RPC.slot_content slot_header) in (* DAL/FIXME: https://gitlab.com/tezos/tezos/-/issues/3804 - Only check that the function to retrieve segments succeeds, actual + Only check that the function to retrieve pages succeeds, actual contents will be checked in a test upcoming. *) - let* _slots_as_segments = - RPC.call dal_node (Rollup.Dal.RPC.slot_segments slot_header) + let* _slots_as_pages = + RPC.call dal_node (Rollup.Dal.RPC.slot_pages slot_header) in assert (slot_content = received_slot_content) ; return () -- GitLab From d45bf1305b38cda3f50b0ee36d64d6e5cb643a1f Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Mon, 12 Sep 2022 16:43:43 +0100 Subject: [PATCH 5/5] Tezt: reset regressions --- ... (mode client) RPC regression tests- misc_protocol.out | 4 ++-- ...- (mode light) RPC regression tests- misc_protocol.out | 4 ++-- ...- (mode proxy) RPC regression tests- misc_protocol.out | 4 ++-- ...rver_data_dir) RPC regression tests- misc_protocol.out | 4 ++-- ...xy_server_rpc) RPC regression tests- misc_protocol.out | 4 ++-- ...orrect handling of commitments (no_commitment_publ.out | 8 ++++---- ...e - correct handling of commitments (no_commitment.out | 8 ++++---- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 6525d5b7078b..4b7bfce805f5 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -47,8 +47,8 @@ { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": false, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index e68a8fa77f19..edca068fe4d4 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -47,8 +47,8 @@ { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": false, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index a25d314cd6c1..b1a503fbc82b 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -47,8 +47,8 @@ { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": false, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out index 8778a17acf54..145023ae968d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- misc_protocol.out @@ -47,8 +47,8 @@ { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": false, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out index 8778a17acf54..145023ae968d 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- misc_protocol.out @@ -47,8 +47,8 @@ { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": false, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": false, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 20160, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out index 624aa4211358..b2b3dbdbb69f 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (no_commitment_publ.out @@ -103,8 +103,8 @@ This sequence of operations was run: { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": true, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", @@ -213,8 +213,8 @@ This sequence of operations was run: { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": true, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out index 59b6588fd50a..2cec2632b274 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out @@ -103,8 +103,8 @@ This sequence of operations was run: { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": true, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", @@ -213,8 +213,8 @@ This sequence of operations was run: { "feature_enable": false, "number_of_slots": 16, "number_of_shards": 256, "endorsement_lag": 1, "availability_threshold": 50, "slot_size": 65536, - "redundancy_factor": 4, "segment_size": 4096 }, - "sc_rollup_enable": true, "sc_rollup_origination_size": 6314, + "redundancy_factor": 4, "page_size": 4096 }, "sc_rollup_enable": true, + "sc_rollup_origination_size": 6314, "sc_rollup_challenge_window_in_blocks": 1, "sc_rollup_max_number_of_messages_per_commitment_period": 300000000, "sc_rollup_stake_amount": "10000000000", -- GitLab