From 926a7d03b61bf5f0038e4953f584b46cc94863e6 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Thu, 20 Oct 2022 12:10:12 +0200 Subject: [PATCH 1/2] Tests: derive DAL cryptobox (smaller) parameters from mainnet ones --- .../lib_protocol/test/helpers/dal_helpers.ml | 9 +++++++++ .../lib_protocol/test/helpers/dal_helpers.mli | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml index 68b5d3571414..d833c46adca5 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml @@ -56,6 +56,15 @@ let mk_cryptobox dal_params = | Ok dal -> return dal | Error (`Fail s) -> fail [Test_failure s] +let derive_dal_parameters (reference : Cryptobox.parameters) ~redundancy_factor + ~constants_divider = + { + Hist.redundancy_factor; + page_size = reference.page_size / constants_divider; + slot_size = reference.slot_size / constants_divider; + number_of_shards = reference.number_of_shards / constants_divider; + } + module Make (Parameters : sig val dal_parameters : Alpha_context.Constants.Parametric.dal diff --git a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli index 770ed1203f2a..20c6454aebc5 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli @@ -28,6 +28,16 @@ open Protocol (** Returns an object of type {!Cryptobox.t} from the given DAL paramters. *) val mk_cryptobox : Cryptobox.parameters -> Cryptobox.t tzresult +(** Derive new DAL parameters from the given ones by: + - setting the given redundancy factor ; + - dividing the other fields by the given factor. +*) +val derive_dal_parameters : + Cryptobox.parameters -> + redundancy_factor:int -> + constants_divider:int -> + Cryptobox.parameters + module Make (P : sig val dal_parameters : Alpha_context.Constants.Parametric.dal -- GitLab From a924cab7916ae6ebdca12ce56225e671980751c9 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Thu, 20 Oct 2022 12:10:38 +0200 Subject: [PATCH 2/2] Tests: only run unit & pbt DAL tests with custom/small parameters --- .../test/pbt/test_dal_slot_proof.ml | 21 ++++++++++++++++++- .../test/unit/test_dal_slot_proof.ml | 21 +++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml b/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml index 34b05e7b2091..4e22bd172699 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml @@ -228,5 +228,24 @@ let () = let dal_parameters = constants_mainnet.dal end) in - let tests = Sandbox.tests @ Test.tests @ Mainnet.tests in + let module Custom = Make (struct + let name = "custom" + + let count = 5 + + let dal_parameters = + let dal_mainnet = constants_mainnet.dal in + { + dal_mainnet with + cryptobox_parameters = + Dal_helpers.derive_dal_parameters + dal_mainnet.cryptobox_parameters + ~redundancy_factor:4 + ~constants_divider:64; + } + end) in + (* TODO/DAL: Enable these tests to cover more protocol parameters if we manage + to run DAL crypto part faster. *) + ignore @@ Sandbox.tests @ Test.tests @ Mainnet.tests ; + let tests = Custom.tests in Alcotest_lwt.run "Refutation_game" tests |> Lwt_main.run diff --git a/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml b/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml index a481d5d2d372..fff2e8efbe5f 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml @@ -318,7 +318,7 @@ struct Tztest.tztest (mk_title title) `Quick test_function in let qcheck2 title gen test = - Tztest.tztest_qcheck2 ~name:(mk_title title) ~count:1 gen test + Tztest.tztest_qcheck2 ~name:(mk_title title) ~count:2 gen test in let bool = QCheck2.Gen.bool in let ordering_tests = @@ -399,4 +399,21 @@ let tests = let dal_parameters = constants_mainnet.dal end) in - Sandbox.tests @ Test.tests @ Mainnet.tests + let module Custom = Make (struct + let name = "custom" + + let dal_parameters = + let dal_mainnet = constants_mainnet.dal in + { + dal_mainnet with + cryptobox_parameters = + Dal_helpers.derive_dal_parameters + dal_mainnet.cryptobox_parameters + ~redundancy_factor:4 + ~constants_divider:64; + } + end) in + (* TODO/DAL: Enable these tests to cover more protocol parameters if we manage + to run DAL crypto part faster. *) + ignore @@ Sandbox.tests @ Test.tests @ Mainnet.tests ; + Custom.tests -- GitLab