From 708707081142545ca7047ba3f8b7049846567275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 24 Jul 2024 08:33:07 +0200 Subject: [PATCH 1/5] DAL/Node: Define alias on the CLI --- src/bin_dal_node/cli.ml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index 8f2c3b04fdcc..13c94c04d3cf 100644 --- a/src/bin_dal_node/cli.ml +++ b/src/bin_dal_node/cli.ml @@ -178,7 +178,7 @@ module Term = struct Arg.( value & opt (list attester_profile_arg) [] - & info ~docs ~doc ~docv:"PKH1,PKH2,..." ["attester-profiles"]) + & info ~docs ~doc ~docv:"PKH1,PKH2,..." ["attester-profiles"; "attester"]) let producer_profile = let open Cmdliner in @@ -186,7 +186,11 @@ module Term = struct Arg.( value & opt (list producer_profile_arg) [] - & info ~docs ~doc ~docv:"INDEX1,INDEX2,..." ["producer-profiles"]) + & info + ~docs + ~doc + ~docv:"INDEX1,INDEX2,..." + ["producer-profiles"; "producer"; "operator"]) let observer_profile = let open Cmdliner in @@ -194,7 +198,11 @@ module Term = struct Arg.( value & opt (list observer_profile_arg) [] - & info ~docs ~doc ~docv:"INDEX1,INDEX2,..." ["observer-profiles"]) + & info + ~docs + ~doc + ~docv:"INDEX1,INDEX2,..." + ["observer-profiles"; "observer"]) let bootstrap_profile = let open Cmdliner in @@ -202,7 +210,7 @@ module Term = struct "The Octez DAL node bootstrap node profile. Note that a bootstrap node \ cannot also be an attester or a slot producer" in - Arg.(value & flag & info ~docs ~doc ["bootstrap-profile"]) + Arg.(value & flag & info ~docs ~doc ["bootstrap-profile"; "bootstrap"]) let peers = let open Cmdliner in -- GitLab From a649ba1ded3ebeb22fd286cf1891e78dfe1afc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 24 Jul 2024 08:37:51 +0200 Subject: [PATCH 2/5] DAL/Node: Better error message when incompatible CLI flags are given --- src/bin_dal_node/cli.ml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index 13c94c04d3cf..a992eda00a25 100644 --- a/src/bin_dal_node/cli.ml +++ b/src/bin_dal_node/cli.ml @@ -379,7 +379,9 @@ let make ~run = | true, _ -> `Error ( false, - "A bootstrap node cannot also be an attester or a slot producer." ) + "a bootstrap node (option '--bootstrap') cannot be an attester \ + (option '--attester'), an operator (option '--operator') nor an \ + observer (option '--observer')" ) in let default = Cmdliner.Term.(ret (const (`Help (`Pager, None)))) in let info = -- GitLab From 4fa463a5cbf85158f3b9b2d7f5f9807e88f62d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 24 Jul 2024 08:49:17 +0200 Subject: [PATCH 3/5] DAL/Node: Export the 'random_observer' profile --- src/bin_dal_node/profile_manager.ml | 2 ++ src/bin_dal_node/profile_manager.mli | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/bin_dal_node/profile_manager.ml b/src/bin_dal_node/profile_manager.ml index b79302675b18..72a42d79a59d 100644 --- a/src/bin_dal_node/profile_manager.ml +++ b/src/bin_dal_node/profile_manager.ml @@ -33,6 +33,8 @@ let encoding = Types.profile_encoding let bootstrap = Types.Bootstrap +let random_observer = Types.Random_observer + let operator operator_profile = Types.Operator operator_profile let is_empty = function diff --git a/src/bin_dal_node/profile_manager.mli b/src/bin_dal_node/profile_manager.mli index 206d0e1bb51b..4683bd9085a3 100644 --- a/src/bin_dal_node/profile_manager.mli +++ b/src/bin_dal_node/profile_manager.mli @@ -50,6 +50,8 @@ val empty : t val bootstrap : t +val random_observer : t + (** [operator op] returns an operator with the profile described by [op] *) val operator : Operator_profile.t -> t -- GitLab From a224605541a4026aadf550a5a9e8b025f8b932d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Wed, 24 Jul 2024 08:49:32 +0200 Subject: [PATCH 4/5] DAL/Node: Attach the random observer to CLI arguments --- src/bin_dal_node/cli.ml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index a992eda00a25..2ded2d733007 100644 --- a/src/bin_dal_node/cli.ml +++ b/src/bin_dal_node/cli.ml @@ -197,7 +197,7 @@ module Term = struct let doc = "The Octez DAL node observer profiles for given slot indexes." in Arg.( value - & opt (list observer_profile_arg) [] + & opt (some' (list observer_profile_arg)) None & info ~docs ~doc @@ -370,13 +370,18 @@ let make ~run = history_mode; } in - let profile = Operator_profile.make ~attesters ~producers ~observers () in - match (bootstrap_flag, profile) with - | false, profiles when Operator_profile.is_empty profiles -> run None - | true, profiles when Operator_profile.is_empty profiles -> + let profile = Operator_profile.make ~attesters ~producers ?observers () in + match (bootstrap_flag, observers, profile) with + | false, None, profiles when Operator_profile.is_empty profiles -> run None + | false, Some _, profiles when Operator_profile.is_empty profiles -> + (* The user only mentioned '--observer' without any slot and + without any other profile. It will be assigned to random + slots. *) + run (Some Profile_manager.random_observer) + | false, _, _ -> run @@ Some (Profile_manager.operator profile) + | true, None, profiles when Operator_profile.is_empty profiles -> run @@ Some Profile_manager.bootstrap - | false, profiles -> run @@ Some (Profile_manager.operator profiles) - | true, _ -> + | true, _, _ -> `Error ( false, "a bootstrap node (option '--bootstrap') cannot be an attester \ -- GitLab From b50a2e124d66d1c8fddd79c0c43a62dbec2f1e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Thir=C3=A9?= Date: Thu, 25 Jul 2024 11:55:48 +0200 Subject: [PATCH 5/5] DAL/Node: Update the new profile encoding --- src/lib_dal_node_services/operator_profile.ml | 7 ++++--- src/lib_dal_node_services/types.ml | 6 +++--- tezt/lib_tezos/dal_common.ml | 8 ++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/lib_dal_node_services/operator_profile.ml b/src/lib_dal_node_services/operator_profile.ml index 097241f867fb..d8eabeb62e43 100644 --- a/src/lib_dal_node_services/operator_profile.ml +++ b/src/lib_dal_node_services/operator_profile.ml @@ -92,7 +92,8 @@ let encoding = attesters = Pkh_set.of_list attesters; }) (obj3 - (req "producers" (list int31)) + (* Use the new name in the encoding. *) + (req "operators" (list int31)) (req "observers" (list int31)) (req "attesters" (list Signature.Public_key_hash.encoding))) @@ -162,13 +163,13 @@ let encoding = union [ case - ~title:"operator_profile_encoding" + ~title:"profile_encoding" Json_only encoding (fun v -> Some v) (fun v -> v); case - ~title:"legacy_operator_profile_encoding" + ~title:"legacy_profile_encoding" Json_only (conv (fun _ -> assert false) from_legacy Legacy.encoding) (fun _ -> None) diff --git a/src/lib_dal_node_services/types.ml b/src/lib_dal_node_services/types.ml index bae69013b837..d920643b4544 100644 --- a/src/lib_dal_node_services/types.ml +++ b/src/lib_dal_node_services/types.ml @@ -409,11 +409,11 @@ let profile_encoding = (function Bootstrap -> Some () | _ -> None) (function () -> Bootstrap); case - ~title:"Operator" + ~title:"Controller" (Tag 2) (obj2 - (req "kind" (constant "operator")) - (req "operator_profiles" Operator_profile.encoding)) + (req "kind" (constant "controller")) + (req "controller_profiles" Operator_profile.encoding)) (function | Operator operator_profiles -> Some ((), operator_profiles) | _ -> None) diff --git a/tezt/lib_tezos/dal_common.ml b/tezt/lib_tezos/dal_common.ml index c9ea62645210..9d494158d27c 100644 --- a/tezt/lib_tezos/dal_common.ml +++ b/tezt/lib_tezos/dal_common.ml @@ -259,14 +259,14 @@ module Dal_RPC = struct `O [ ("attesters", `A (List.rev attesters)); - ("producers", `A (List.rev producers)); + ("operators", `A (List.rev producers)); ("observers", `A (List.rev observers)); ] let operator_profile_of_json json = let open JSON in let attesters = json |-> "attesters" |> as_list |> List.map as_string in - let producers = json |-> "producers" |> as_list |> List.map as_int in + let producers = json |-> "operators" |> as_list |> List.map as_int in let observers = json |-> "observers" |> as_list |> List.map as_int in List.map (fun pkh -> Attester pkh) attesters @ List.map (fun i -> Producer i) producers @@ -276,9 +276,9 @@ module Dal_RPC = struct let open JSON in match json |-> "kind" |> as_string with | "bootstrap" -> Bootstrap - | "operator" -> + | "controller" -> let operator_profiles = - operator_profile_of_json (json |-> "operator_profiles") + operator_profile_of_json (json |-> "controller_profiles") in Operator operator_profiles | _ -> failwith "invalid case" -- GitLab