diff --git a/.gitlab/ci/jobs/packaging/opam_package.yml b/.gitlab/ci/jobs/packaging/opam_package.yml index 4f538e9bc66ac2a23e9bd6b36b6cb53e456c7d1a..91ea225aac79dbddafd311d1ee349735c3a3af1e 100644 --- a/.gitlab/ci/jobs/packaging/opam_package.yml +++ b/.gitlab/ci/jobs/packaging/opam_package.yml @@ -605,6 +605,8 @@ opam:tezos-crypto-dal: variables: package: tezos-crypto-dal +# Ignoring unreleased package tezos-dac-alpha. + # Ignoring unreleased package tezos-dal-016-PtMumbai. # Ignoring unreleased package tezos-dal-alpha. diff --git a/dune-project b/dune-project index cf43b111b5ca4061aa938c4c6fbe5596c9e02229..cc119d8769408c97c1a5f675474a96eb5302f483 100644 --- a/dune-project +++ b/dune-project @@ -76,6 +76,7 @@ (package (name tezos-context-ops)) (package (name tezos-crypto)) (package (name tezos-crypto-dal)) +(package (name tezos-dac-alpha)) (package (name tezos-dal-016-PtMumbai)) (package (name tezos-dal-alpha)) (package (name tezos-dal-node-lib)(allow_empty)) diff --git a/manifest/main.ml b/manifest/main.ml index 649decdd5128d850aae1c6ce9bdde3eafa3ccfd8..6150545ca4da850bfe89e24b36082224df090aa6 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -3421,6 +3421,8 @@ module Protocol : sig val dal : t -> target option + val dac : t -> target option + val parameters_exn : t -> target val benchmarks_proto_exn : t -> target @@ -3535,6 +3537,7 @@ end = struct plugin : target option; plugin_registerer : target option; dal : target option; + dac : target option; test_helpers : target option; parameters : target option; benchmarks_proto : target option; @@ -3542,7 +3545,7 @@ end = struct } let make ?client ?client_commands ?client_commands_registration - ?baking_commands_registration ?plugin ?plugin_registerer ?dal + ?baking_commands_registration ?plugin ?plugin_registerer ?dal ?dac ?test_helpers ?parameters ?benchmarks_proto ?baking ~status ~name ~main ~embedded () = { @@ -3557,6 +3560,7 @@ end = struct plugin; plugin_registerer; dal; + dac; test_helpers; parameters; benchmarks_proto; @@ -3611,6 +3615,8 @@ end = struct let dal p = p.dal + let dac p = p.dac + let parameters_exn p = mandatory "parameters" p p.parameters let benchmarks_proto_exn p = mandatory "benchmarks_proto" p p.benchmarks_proto @@ -5053,6 +5059,50 @@ module Protocol = Protocol alcotest_lwt; ] in + let dac = + (* [~link_all:true] is necessary to ensure that the dac plugin + registration happens when running the dal node. Removing this + option would cause DAL related tezts to fail because the DAC + plugin cannot be resolved. *) + only_if (active && N.(number >= 017)) @@ fun () -> + public_lib + (sf "tezos-dac-%s" name_dash) + ~path:(path // "lib_dac") + ~synopsis: + "Tezos/Protocol: protocol specific library for the Data availability \ + Committee" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives" + |> open_ ~m:"TzPervasives.Error_monad.Legacy_monad_globals"; + octez_protocol_compiler_registerer |> open_; + octez_stdlib_unix |> open_; + octez_dal_node_lib |> open_; + client |> if_some |> open_; + embedded |> open_; + layer2_utils |> if_some |> open_; + main |> open_; + ] + ~inline_tests:ppx_expect + ~linkall:true + in + let _dac_tests = + only_if (active && N.(number >= 017)) @@ fun () -> + test + "main" + ~path:(path // "lib_dac/test") + ~opam:(sf "tezos-dac-%s" name_dash) + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives" + |> open_ ~m:"TzPervasives.Error_monad.Legacy_monad_globals"; + dac |> if_some |> open_; + main |> open_; + octez_base_test_helpers |> open_; + test_helpers |> if_some |> open_; + alcotest_lwt; + ] + in let benchmark_type_inference = only_if active @@ fun () -> public_lib @@ -5217,6 +5267,7 @@ module Protocol = Protocol ?plugin ?plugin_registerer ?dal + ?dac ?test_helpers ?parameters ?benchmarks_proto @@ -5969,7 +6020,9 @@ let _octez_dal_node = (* Other protocols are optional. *) true in - let targets = List.filter_map Fun.id [Protocol.dal protocol] in + let targets = + List.filter_map Fun.id [Protocol.dal protocol; Protocol.dac protocol] + in if is_optional then List.map optional targets else targets in List.map deps_for_protocol Protocol.all |> List.flatten diff --git a/opam/octez-dal-node.opam b/opam/octez-dal-node.opam index 726ae6a440c61603e02840addad3e1395ca809a5..d7c2bc8366355f7869b68486ead97b8c3295edbe 100644 --- a/opam/octez-dal-node.opam +++ b/opam/octez-dal-node.opam @@ -30,6 +30,7 @@ depends: [ ] depopts: [ "tezos-dal-alpha" + "tezos-dac-alpha" ] build: [ ["rm" "-r" "vendors"] diff --git a/opam/tezos-dac-alpha.opam b/opam/tezos-dac-alpha.opam new file mode 100644 index 0000000000000000000000000000000000000000..d11ebbbb5c3e0f5fbbf29072c9df6de981e25352 --- /dev/null +++ b/opam/tezos-dac-alpha.opam @@ -0,0 +1,30 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.0" } + "ppx_expect" + "tezos-base" + "octez-protocol-compiler" + "tezos-stdlib-unix" + "tezos-dal-node-lib" + "tezos-client-alpha" + "tezos-embedded-protocol-alpha" + "tezos-layer2-utils-alpha" + "tezos-protocol-alpha" + "tezos-base-test-helpers" {with-test} + "tezos-alpha-test-helpers" {with-test} + "alcotest-lwt" { with-test & >= "1.5.0" } +] +build: [ + ["rm" "-r" "vendors"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "Tezos/Protocol: protocol specific library for the Data availability Committee" diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index b75f506635d3aca0a1d449369d327c9efdc2a5a0..bc5d8b04d4a1182a2f614f7751b1be3a0ca5accf 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -195,13 +195,16 @@ let start configuration cctxt ctxt dac_pks_opt dac_sk_uris = configuration in let dir = register ctxt in + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4558 + Rename "plugin" prefix to "dac". + *) let plugin_prefix = Tezos_rpc.Path.(open_root / "plugin") in let dir = Tezos_rpc.Directory.register_dynamic_directory dir plugin_prefix (fun () -> match Node_context.get_status ctxt with - | Ready {plugin = (module Plugin); _} -> + | Ready {dac_plugin = (module Dac_plugin); _} -> Lwt.return - (Plugin.RPC.rpc_services + (Dac_plugin.RPC.rpc_services ~reveal_data_dir cctxt dac_pks_opt diff --git a/src/bin_dal_node/dac_manager.ml b/src/bin_dal_node/dac_manager.ml index 99960e3a301fe250e8192245d8d45efc67d8c5ba..01262a1ad73a53b09b86bd305ea8b5f0ac40d1a5 100644 --- a/src/bin_dal_node/dac_manager.ml +++ b/src/bin_dal_node/dac_manager.ml @@ -110,3 +110,22 @@ module Storage = struct else tzfail @@ Cannot_create_reveal_data_dir reveal_data_dir | _ -> tzfail @@ Cannot_create_reveal_data_dir reveal_data_dir) end + +let resolve_plugin + (protocols : Tezos_shell_services.Chain_services.Blocks.protocols) = + let open Lwt_syntax in + let plugin_opt = + Option.either + (Dac_plugin.get protocols.current_protocol) + (Dac_plugin.get protocols.next_protocol) + in + Option.map_s + (fun dac_plugin -> + let (module Dac_plugin : Dac_plugin.T) = dac_plugin in + let* () = + Event.emit_protocol_plugin_resolved + ~plugin_name:"dac" + Dac_plugin.Proto.hash + in + return dac_plugin) + plugin_opt diff --git a/src/bin_dal_node/dac_manager.mli b/src/bin_dal_node/dac_manager.mli index 03b5976504381f6b121edb055ed4959eaf64f896..c40c51fe6472b5447f1fe1d1e159b04e29ca4846 100644 --- a/src/bin_dal_node/dac_manager.mli +++ b/src/bin_dal_node/dac_manager.mli @@ -62,3 +62,9 @@ module Storage : sig *) val ensure_reveal_data_dir_exists : string -> unit tzresult Lwt.t end + +(* TODO: https://gitlab.com/tezos/tezos/-/issues/4626 + Unify this function and resolve_dal_plugin in Dal node daemon. *) +val resolve_plugin : + Tezos_shell_services.Chain_services.Blocks.protocols -> + (module Dac_plugin.T) option Lwt.t diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 25f448fcbc0d8e5fdbf43bde6697319233afc2f3..46ef4bda5a39fbf4058c3fc967461fcb5254d282 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -23,15 +23,24 @@ (* *) (*****************************************************************************) -let resolve_plugin cctxt = - let open Lwt_result_syntax in - let* protocols = - Tezos_shell_services.Chain_services.Blocks.protocols cctxt () +let resolve_dal_plugin + (protocols : Tezos_shell_services.Chain_services.Blocks.protocols) = + let open Lwt_syntax in + let plugin_opt = + Option.either + (Dal_plugin.get protocols.current_protocol) + (Dal_plugin.get protocols.next_protocol) in - return - @@ Option.either - (Dal_plugin.get protocols.current_protocol) - (Dal_plugin.get protocols.next_protocol) + Option.map_s + (fun dal_plugin -> + let (module Dal_plugin : Dal_plugin.T) = dal_plugin in + let* () = + Event.emit_protocol_plugin_resolved + ~plugin_name:"dal" + Dal_plugin.Proto.hash + in + return dal_plugin) + plugin_opt type error += | Cryptobox_initialisation_failed of string @@ -97,7 +106,7 @@ module Handler = struct in return (go (), stopper) - let resolve_plugin_and_set_ready config ctxt cctxt = + let resolve_plugins_and_set_ready config ctxt cctxt = (* Monitor heads and try resolve the DAL protocol plugin corresponding to the protocol of the targeted node. *) (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3605 @@ -105,22 +114,32 @@ module Handler = struct let open Lwt_result_syntax in let handler stopper (_block_hash, (_block_header : Tezos_base.Block_header.t)) = - let* plugin = resolve_plugin cctxt in - match plugin with - | Some plugin -> - let (module Plugin : Dal_plugin.T) = plugin in - let*! () = Event.emit_protocol_plugin_resolved Plugin.Proto.hash in + let* protocols = + Tezos_shell_services.Chain_services.Blocks.protocols cctxt () + in + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4627 + Register only one plugin according to mode of operation. *) + let*! dal_plugin = resolve_dal_plugin protocols in + let*! dac_plugin = Dac_manager.resolve_plugin protocols in + match (dal_plugin, dac_plugin) with + | Some dal_plugin, Some dac_plugin -> + let (module Dal_plugin : Dal_plugin.T) = dal_plugin in let* proto_parameters = - Plugin.get_constants cctxt#chain cctxt#block cctxt + Dal_plugin.get_constants cctxt#chain cctxt#block cctxt in let* cryptobox = init_cryptobox config.Configuration.use_unsafe_srs proto_parameters in - Node_context.set_ready ctxt (module Plugin) cryptobox proto_parameters ; + Node_context.set_ready + ctxt + ~dal_plugin + ~dac_plugin + cryptobox + proto_parameters ; let*! () = Event.(emit node_is_ready ()) in stopper () ; return_unit - | None -> return_unit + | _, _ -> return_unit in let handler stopper el = match Node_context.get_status ctxt with @@ -138,15 +157,17 @@ module Handler = struct let handler _stopper (block_hash, (header : Tezos_base.Block_header.t)) = match Node_context.get_status ctxt with | Starting -> return_unit - | Ready {plugin = (module Plugin); proto_parameters; _} -> + | Ready {dal_plugin = (module Dal_plugin); proto_parameters; _} -> let block_level = header.shell.level in let* block_info = - Plugin.block_info + Dal_plugin.block_info cctxt ~block:(`Hash (block_hash, 0)) ~metadata:`Always in - let* slot_headers = Plugin.get_published_slot_headers block_info in + let* slot_headers = + Dal_plugin.get_published_slot_headers block_info + in let*! () = Slot_manager.store_slot_headers ~block_level @@ -155,7 +176,7 @@ module Handler = struct (Node_context.get_store ctxt) in let*? attested_slots = - Plugin.attested_slot_headers + Dal_plugin.attested_slot_headers block_hash block_info ~number_of_slots:proto_parameters.number_of_slots @@ -264,7 +285,7 @@ let run ~data_dir cctxt = in (* Start daemon to resolve current protocol plugin *) let* () = - daemonize [Handler.resolve_plugin_and_set_ready config ctxt cctxt] + daemonize [Handler.resolve_plugins_and_set_ready config ctxt cctxt] in (* Start never-ending monitoring daemons *) daemonize (Handler.new_head ctxt cctxt :: Handler.new_slot_header ctxt) diff --git a/src/bin_dal_node/dune b/src/bin_dal_node/dune index e37e55fe114627d7262d0fc39c2670449fece14f..6c96ca3234da379987fc17c0b66640efde2be038 100644 --- a/src/bin_dal_node/dune +++ b/src/bin_dal_node/dune @@ -29,7 +29,10 @@ tezos-dal-016-PtMumbai (select void_for_linking-tezos-dal-alpha from (tezos-dal-alpha -> void_for_linking-tezos-dal-alpha.empty) - (-> void_for_linking-tezos-dal-alpha.empty))) + (-> void_for_linking-tezos-dal-alpha.empty)) + (select void_for_linking-tezos-dac-alpha from + (tezos-dac-alpha -> void_for_linking-tezos-dac-alpha.empty) + (-> void_for_linking-tezos-dac-alpha.empty))) (link_flags (:standard) (:include %{workspace_root}/static-link-flags.sexp)) @@ -47,4 +50,8 @@ -open Tezos_layer2_store -open Tezos_crypto_dal)) -(rule (action (progn (write-file void_for_linking-tezos-dal-alpha.empty "")))) +(rule + (action + (progn + (write-file void_for_linking-tezos-dal-alpha.empty "") + (write-file void_for_linking-tezos-dac-alpha.empty "")))) diff --git a/src/bin_dal_node/event_legacy.ml b/src/bin_dal_node/event_legacy.ml index 1c620c60e5861fca73f72b1a898f8d676cec1994..3fe5312294273a6acb5cd3fd37a6228242f1d7ba 100644 --- a/src/bin_dal_node/event_legacy.ml +++ b/src/bin_dal_node/event_legacy.ml @@ -122,11 +122,12 @@ let layer1_node_tracking_started = () let protocol_plugin_resolved = - declare_1 + declare_2 ~section ~name:"dal_node_plugin_resolved" - ~msg:"Resolved plugin on protocol {proto_hash}" + ~msg:"Resolved plugin for {plugin_name} on protocol {proto_hash}" ~level:Notice + ("plugin_name", Data_encoding.string) ("proto_hash", Data_encoding.string) let daemon_error = @@ -173,5 +174,5 @@ let dac_account_cannot_sign = let proto_short_hash_string hash = Format.asprintf "%a" Tezos_crypto.Protocol_hash.pp_short hash -let emit_protocol_plugin_resolved hash = - emit protocol_plugin_resolved (proto_short_hash_string hash) +let emit_protocol_plugin_resolved ~plugin_name hash = + emit protocol_plugin_resolved (plugin_name, proto_short_hash_string hash) diff --git a/src/bin_dal_node/node_context.ml b/src/bin_dal_node/node_context.ml index 1bdc63d5e9bd903702419c91e1455365a8a4c26e..a963c78bebc1afab0868f2161d3176dbba481eee 100644 --- a/src/bin_dal_node/node_context.ml +++ b/src/bin_dal_node/node_context.ml @@ -28,7 +28,8 @@ exception Status_already_ready type ready_ctxt = { cryptobox : Cryptobox.t; proto_parameters : Dal_plugin.proto_parameters; - plugin : (module Dal_plugin.T); + dal_plugin : (module Dal_plugin.T); + dac_plugin : (module Dac_plugin.T); } type status = Ready of ready_ctxt | Starting @@ -59,9 +60,10 @@ let init config store cctxt = Committee_cache.create ~max_size:Constants.committee_cache_size; } -let set_ready ctxt plugin cryptobox proto_parameters = +let set_ready ctxt ~dal_plugin ~dac_plugin cryptobox proto_parameters = match ctxt.status with - | Starting -> ctxt.status <- Ready {plugin; cryptobox; proto_parameters} + | Starting -> + ctxt.status <- Ready {dac_plugin; dal_plugin; cryptobox; proto_parameters} | Ready _ -> raise Status_already_ready type error += Node_not_ready @@ -103,7 +105,7 @@ let fetch_assigned_shard_indicies ctxt ~level ~pkh = match Committee_cache.find cache ~level with | Some committee -> return committee | None -> - let*? {plugin = (module Plugin); _} = get_ready ctxt in + let*? {dal_plugin = (module Plugin); _} = get_ready ctxt in let+ committee = Plugin.get_committee cctxt ~level in let committee = Tezos_crypto.Signature.Public_key_hash.Map.map diff --git a/src/bin_dal_node/node_context.mli b/src/bin_dal_node/node_context.mli index 04e7356ee43b5df17d672d8668bcec8d83a98bf5..d8b75b332c9868a0f3fc9ba7c96a39c375d043fc 100644 --- a/src/bin_dal_node/node_context.mli +++ b/src/bin_dal_node/node_context.mli @@ -24,12 +24,13 @@ (*****************************************************************************) (** A [ready_ctx] value contains globally needed informations for a running dal - node. It is available when both cryptobox is initialized and dal plugin is - loaded. *) + node. It is available when both cryptobox is initialized and the plugins + for dal and dac have been loaded. *) type ready_ctxt = { cryptobox : Cryptobox.t; proto_parameters : Dal_plugin.proto_parameters; - plugin : (module Dal_plugin.T); + dal_plugin : (module Dal_plugin.T); + dac_plugin : (module Dac_plugin.T); } (** The status of the dal node *) @@ -47,14 +48,15 @@ val init : Configuration.t -> Store.node_store -> Client_context.full -> t (** Raised by [set_ready] when the status is already [Ready _] *) exception Status_already_ready -(** [set_ready ctxt plugin cryptobox proto_parameters] updates in place the - status value to [Ready], and initializes the inner [ready_ctxt] value with - the given parameters. +(** [set_ready ctxt ~dal_plugin ~dac_plugin cryptobox proto_parameters] updates + in place the status value to [Ready], and initializes the inner + [ready_ctxt] value with the given parameters. @raise Status_already_ready when the status is already [Ready _] *) val set_ready : t -> - (module Tezos_dal_node_lib.Dal_plugin.T) -> + dal_plugin:(module Tezos_dal_node_lib.Dal_plugin.T) -> + dac_plugin:(module Tezos_dal_node_lib.Dac_plugin.T) -> Cryptobox.t -> Dal_plugin.proto_parameters -> unit diff --git a/src/lib_dal_node/dac_plugin.ml b/src/lib_dal_node/dac_plugin.ml new file mode 100644 index 0000000000000000000000000000000000000000..7b298b3f8a2ac1ac35ee48d46982b032696d5d30 --- /dev/null +++ b/src/lib_dal_node/dac_plugin.ml @@ -0,0 +1,47 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 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. *) +(* *) +(*****************************************************************************) + +module type T = sig + module Proto : Registered_protocol.T + + module RPC : sig + val rpc_services : + reveal_data_dir:string -> + #Client_context.wallet -> + Tezos_crypto.Aggregate_signature.public_key option list -> + Client_keys.aggregate_sk_uri option list -> + int -> + unit Tezos_rpc.Directory.directory + end +end + +let table : (module T) Tezos_crypto.Protocol_hash.Table.t = + Tezos_crypto.Protocol_hash.Table.create 5 + +let register (module Plugin : T) = + assert (not (Tezos_crypto.Protocol_hash.Table.mem table Plugin.Proto.hash)) ; + Tezos_crypto.Protocol_hash.Table.add table Plugin.Proto.hash (module Plugin) + +let get hash = Tezos_crypto.Protocol_hash.Table.find table hash diff --git a/src/lib_dal_node/dac_plugin.mli b/src/lib_dal_node/dac_plugin.mli new file mode 100644 index 0000000000000000000000000000000000000000..4de3ee0faeb5381da07568df1b12106a720760b9 --- /dev/null +++ b/src/lib_dal_node/dac_plugin.mli @@ -0,0 +1,42 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 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. *) +(* *) +(*****************************************************************************) + +module type T = sig + module Proto : Registered_protocol.T + + module RPC : sig + val rpc_services : + reveal_data_dir:string -> + #Client_context.wallet -> + Tezos_crypto.Aggregate_signature.public_key option list -> + Client_keys.aggregate_sk_uri option list -> + int -> + unit Tezos_rpc.Directory.directory + end +end + +val register : (module T) -> unit + +val get : Tezos_crypto.Protocol_hash.Table.key -> (module T) option diff --git a/src/lib_dal_node/dal_plugin.ml b/src/lib_dal_node/dal_plugin.ml index db134b0522e049d7c070292c621e8cc98280b660..8319ceca61a13315b6b5c922405f120190cc17c4 100644 --- a/src/lib_dal_node/dal_plugin.ml +++ b/src/lib_dal_node/dal_plugin.ml @@ -74,16 +74,6 @@ module type T = sig block_info -> number_of_slots:int -> slot_index list tzresult - - module RPC : sig - val rpc_services : - reveal_data_dir:string -> - #Client_context.wallet -> - Tezos_crypto.Aggregate_signature.public_key option list -> - Client_keys.aggregate_sk_uri option list -> - int -> - unit Tezos_rpc.Directory.directory - end end let table : (module T) Tezos_crypto.Protocol_hash.Table.t = diff --git a/src/lib_dal_node/dal_plugin.mli b/src/lib_dal_node/dal_plugin.mli index 230294a2c4d73f85b360ed94ccd53440dd617cc1..31b430af3f00f5917aebecee58a5bff39f74e068 100644 --- a/src/lib_dal_node/dal_plugin.mli +++ b/src/lib_dal_node/dal_plugin.mli @@ -100,16 +100,6 @@ module type T = sig block_info -> number_of_slots:int -> slot_index list tzresult - - module RPC : sig - val rpc_services : - reveal_data_dir:string -> - #Client_context.wallet -> - Tezos_crypto.Aggregate_signature.public_key option list -> - Client_keys.aggregate_sk_uri option list -> - int -> - unit Tezos_rpc.Directory.directory - end end val register : (module T) -> unit diff --git a/src/proto_alpha/lib_dal/RPC.ml b/src/proto_alpha/lib_dac/RPC.ml similarity index 100% rename from src/proto_alpha/lib_dal/RPC.ml rename to src/proto_alpha/lib_dac/RPC.ml diff --git a/src/proto_alpha/lib_dal/dac_external_message_manager.ml b/src/proto_alpha/lib_dac/dac_external_message_manager.ml similarity index 100% rename from src/proto_alpha/lib_dal/dac_external_message_manager.ml rename to src/proto_alpha/lib_dac/dac_external_message_manager.ml diff --git a/src/proto_alpha/lib_dal/dac_manager.ml b/src/proto_alpha/lib_dac/dac_manager.ml similarity index 100% rename from src/proto_alpha/lib_dal/dac_manager.ml rename to src/proto_alpha/lib_dac/dac_manager.ml diff --git a/src/proto_alpha/lib_dal/dac_pages_encoding.ml b/src/proto_alpha/lib_dac/dac_pages_encoding.ml similarity index 100% rename from src/proto_alpha/lib_dal/dac_pages_encoding.ml rename to src/proto_alpha/lib_dac/dac_pages_encoding.ml diff --git a/src/proto_alpha/lib_dac/dac_plugin_registration.ml b/src/proto_alpha/lib_dac/dac_plugin_registration.ml new file mode 100644 index 0000000000000000000000000000000000000000..9cb87ec6180a51d36b0a2516987a3924a7ce2e43 --- /dev/null +++ b/src/proto_alpha/lib_dac/dac_plugin_registration.ml @@ -0,0 +1,31 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +module Plugin = struct + module Proto = Registerer.Registered + module RPC = RPC +end + +let () = Dac_plugin.register (module Plugin) diff --git a/src/proto_alpha/lib_dal/dac_preimage_data_manager.ml b/src/proto_alpha/lib_dac/dac_preimage_data_manager.ml similarity index 100% rename from src/proto_alpha/lib_dal/dac_preimage_data_manager.ml rename to src/proto_alpha/lib_dac/dac_preimage_data_manager.ml diff --git a/src/proto_alpha/lib_dal/dac_signature_manager.ml b/src/proto_alpha/lib_dac/dac_signature_manager.ml similarity index 100% rename from src/proto_alpha/lib_dal/dac_signature_manager.ml rename to src/proto_alpha/lib_dac/dac_signature_manager.ml diff --git a/src/proto_alpha/lib_dac/dune b/src/proto_alpha/lib_dac/dune new file mode 100644 index 0000000000000000000000000000000000000000..fd122828bdf6672aee6e0e42b832c7c66af74b8f --- /dev/null +++ b/src/proto_alpha/lib_dac/dune @@ -0,0 +1,30 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_dac_alpha) + (public_name tezos-dac-alpha) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + octez-protocol-compiler.registerer + tezos-stdlib-unix + tezos_dal_node_lib + tezos-client-alpha + tezos-embedded-protocol-alpha + tezos-layer2-utils-alpha + tezos-protocol-alpha) + (inline_tests (flags -verbose) (modes native)) + (preprocess (pps ppx_expect)) + (library_flags (:standard -linkall)) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals + -open Tezos_protocol_registerer + -open Tezos_stdlib_unix + -open Tezos_dal_node_lib + -open Tezos_client_alpha + -open Tezos_embedded_protocol_alpha + -open Tezos_layer2_utils_alpha + -open Tezos_protocol_alpha)) diff --git a/src/proto_alpha/lib_dac/test/dune b/src/proto_alpha/lib_dac/test/dune new file mode 100644 index 0000000000000000000000000000000000000000..0b4377db31661fd5c2745a7fdeb5f08b6058c293 --- /dev/null +++ b/src/proto_alpha/lib_dac/test/dune @@ -0,0 +1,25 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(executable + (name main) + (libraries + tezos-base + tezos-dac-alpha + tezos-protocol-alpha + tezos-base-test-helpers + tezos-alpha-test-helpers + alcotest-lwt) + (flags + (:standard) + -open Tezos_base.TzPervasives + -open Tezos_base.TzPervasives.Error_monad.Legacy_monad_globals + -open Tezos_dac_alpha + -open Tezos_protocol_alpha + -open Tezos_base_test_helpers + -open Tezos_alpha_test_helpers)) + +(rule + (alias runtest) + (package tezos-dac-alpha) + (action (run %{dep:./main.exe}))) diff --git a/src/proto_alpha/lib_dac/test/main.ml b/src/proto_alpha/lib_dac/test/main.ml new file mode 100644 index 0000000000000000000000000000000000000000..11bbabc8c5bb489e2d804bcee01000bdc75fc5de --- /dev/null +++ b/src/proto_alpha/lib_dac/test/main.ml @@ -0,0 +1,51 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* 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. *) +(* *) +(*****************************************************************************) + +module Unit_test : sig + (** + * Example: [spec "Dac_pages_encoding.ml" Test_dac_pages_encoding.tests] + * Unit tests needs tag in log (like "[UNIT] some test description here...") + * This function handles such meta data *) + val spec : + string -> + unit Alcotest_lwt.test_case list -> + string * unit Alcotest_lwt.test_case list + + (** Tests with description string without [Unit] are skipped *) + val _skip : + string -> + unit Alcotest_lwt.test_case list -> + string * unit Alcotest_lwt.test_case list +end = struct + let spec unit_name test_cases = ("[Unit] " ^ unit_name, test_cases) + + let _skip unit_name test_cases = ("[SKIPPED] " ^ unit_name, test_cases) +end + +let () = + Alcotest_lwt.run + "protocol > unit" + [Unit_test.spec "Dac_pages_encoding.ml" Test_dac_pages_encoding.tests] + |> Lwt_main.run diff --git a/src/proto_alpha/lib_dal/test/test_dac_pages_encoding.ml b/src/proto_alpha/lib_dac/test/test_dac_pages_encoding.ml similarity index 99% rename from src/proto_alpha/lib_dal/test/test_dac_pages_encoding.ml rename to src/proto_alpha/lib_dac/test/test_dac_pages_encoding.ml index c167e60f3d557a893833e27e8d2b6f8cab7ccb4f..9460eb4b060022013b889c62de4f0764e4c9c791 100644 --- a/src/proto_alpha/lib_dal/test/test_dac_pages_encoding.ml +++ b/src/proto_alpha/lib_dac/test/test_dac_pages_encoding.ml @@ -26,7 +26,7 @@ (** Testing ------- Component: Dal_node Slot_frame_encoding - Invocation: dune exec src/proto_alpha/lib_dal/test/main.exe \ + Invocation: dune exec src/proto_alpha/lib_dac/test/main.exe \ -- test "^\[Unit\] Dac_pages_encoding.ml$" Subject: Tests for the SCORU storage module *) diff --git a/src/proto_alpha/lib_dal/dal_plugin_registration.ml b/src/proto_alpha/lib_dal/dal_plugin_registration.ml index 63c78694dcb6b358fc70ef2ada1c4c316cdd33a1..935a70af0325e29707a5bf202dc4546ad3b46f3c 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -127,8 +127,6 @@ module Plugin = struct in List.filter (Dal.Attestation.is_attested confirmed_slots) all_slots |> Dal.Slot_index.to_int_list |> return - - module RPC = RPC end let () = Dal_plugin.register (module Plugin) diff --git a/src/proto_alpha/lib_dal/test/main.ml b/src/proto_alpha/lib_dal/test/main.ml index e79b23050e174d37d2ebef53e6d3915c7b7f19b1..16eba46a8df5ae43a0b31caa8e323790ec505494 100644 --- a/src/proto_alpha/lib_dal/test/main.ml +++ b/src/proto_alpha/lib_dal/test/main.ml @@ -51,6 +51,5 @@ let () = Unit_test.spec "Slot_framing_protocol.ml" Test_dal_slot_frame_encoding.tests; - Unit_test.spec "Dac_pages_encoding.ml" Test_dac_pages_encoding.tests; ] |> Lwt_main.run