diff --git a/src/bin_dal_node/cli.ml b/src/bin_dal_node/cli.ml index 8f2c3b04fdcc0a47f8f7fcacfa7e142868993f05..2ded2d73300711ffc9901af43878b1e0656fe805 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,15 +186,23 @@ 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 let doc = "The Octez DAL node observer profiles for given slot indexes." in Arg.( value - & opt (list observer_profile_arg) [] - & info ~docs ~doc ~docv:"INDEX1,INDEX2,..." ["observer-profiles"]) + & opt (some' (list observer_profile_arg)) None + & 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 @@ -362,16 +370,23 @@ 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 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 = diff --git a/src/bin_dal_node/profile_manager.ml b/src/bin_dal_node/profile_manager.ml index b79302675b185493e0a2bfee231eef0afb90bfe4..72a42d79a59d55c7c12e41f587f3ead9349adad1 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 206d0e1bb51b5ec740486c6d0dc466490140fd3b..4683bd9085a3858a286057a0d29988f022f550f1 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 diff --git a/src/lib_dal_node_services/operator_profile.ml b/src/lib_dal_node_services/operator_profile.ml index 097241f867fbf8cc3926bf35f24fdb32e78e31ab..d8eabeb62e430a869c827145fe86ddedf601e411 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 bae69013b83760ecd7fae7bfd803a4e1b8c9e275..d920643b454402101d8e1f612e6c1b2ce1de2b4b 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 c9ea62645210081e90120a24c34ae84e5623bba1..9d494158d27cc4dc0c049baeed385f3f48927ddb 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"