diff --git a/src/lib_agnostic_baker/commands.ml b/src/lib_agnostic_baker/commands.ml index 5a15289296fcd697afeda506a664ac237a7dcfbf..66f10017df7b67f1e34cff5e60675f972f01ff5c 100644 --- a/src/lib_agnostic_baker/commands.ml +++ b/src/lib_agnostic_baker/commands.ml @@ -120,8 +120,10 @@ module Dal = struct let verbose = switch_to_clic verbose_switch + let ignore_topics = arg_list_to_clic ignore_topics_arg + let args = - Tezos_clic.args22 + Tezos_clic.args23 data_dir rpc_addr expected_pow @@ -144,6 +146,7 @@ module Dal = struct verbose ignore_l1_config_peers disable_amplification + ignore_topics let commands = let open Tezos_clic in @@ -176,13 +179,15 @@ module Dal = struct disable_shard_validation, verbose, ignore_l1_config_peers, - disable_amplification ) + disable_amplification, + ignore_topics ) _cctxt -> let attester_profile = Option.value ~default:[] attester_profile in let operator_profile = Option.value ~default:[] operator_profile in let http_backup_uris = Option.value ~default:[] http_backup_uris in let peers = Option.value ~default:[] peers in + let ignore_topics = Option.value ~default:[] ignore_topics in let options = Cli.cli_options_to_options data_dir @@ -207,6 +212,7 @@ module Dal = struct verbose ignore_l1_config_peers disable_amplification + ignore_topics in match options with | Ok options -> Cli.run ~disable_logging:true cmd options diff --git a/src/lib_dal_node/cli.ml b/src/lib_dal_node/cli.ml index 8a2c446b21bf295afb70ed58904e91aeaa65eff9..04675802ecdb8bdbeeb17c0c598c697da3e5b498 100644 --- a/src/lib_dal_node/cli.ml +++ b/src/lib_dal_node/cli.ml @@ -25,6 +25,12 @@ module Types = Tezos_dal_node_services.Types +let env_value_starts_with_yes ~env_var = + match Sys.getenv_opt env_var with + | None -> false + | Some x -> ( + match String.lowercase_ascii x with "yes" | "y" -> true | _ -> false) + (** This variable is used to disable DAL shard validation at runtime. When activated, Gossipsub messages (i.e. shards) are always considered valid. This can be risky as the DAL node would no longer validate the shards and therefore should be used @@ -33,10 +39,15 @@ let disable_shard_validation_environment_variable = "TEZOS_DISABLE_SHARD_VALIDATION_I_KNOW_WHAT_I_AM_DOING" let disable_shard_validation = - match Sys.getenv_opt disable_shard_validation_environment_variable with - | None -> false - | Some x -> ( - match String.lowercase_ascii x with "yes" | "y" -> true | _ -> false) + env_value_starts_with_yes + ~env_var:disable_shard_validation_environment_variable + +(** This variable is used to instruct the DAL node to not propagate messages + belonging to certain topics. This activates only when the variable is used + in conjunction with the corresponding CLI argument. *) +let env_var_ignore_topics = "TEZOS_IGNORE_TOPICS_I_KNOW_WHAT_I_AM_DOING" + +let env_ignore_topics = env_value_starts_with_yes ~env_var:env_var_ignore_topics module Term = struct type env = {docs : string; doc : string; name : string} @@ -318,7 +329,7 @@ module Term = struct else arg in match Signature.Public_key_hash.of_b58check_opt arg with - | None -> Error "Unrecognized profile" + | None -> Error "Unrecognized pkh format" | Some pkh -> Ok pkh in (decoder, attester_profile_printer) @@ -539,6 +550,19 @@ module Term = struct let disable_amplification = switch_to_cmdliner disable_amplification_switch + let ignore_topics_arg = + let parse, pp = attester_profile_format in + make_arg_list + ~doc: + "The producer Octez DAL node will not publish shards for the provided \ + pkhs. This argument is for testing purposes only." + ~placeholder:"PKH1,PKH2,..." + ~pp + ~parse + "ignore-topics" + + let ignore_topics = arg_list_to_cmdliner ignore_topics_arg + let term process = Cmdliner.Term.( ret @@ -547,7 +571,8 @@ module Term = struct $ metrics_addr $ attester_profile $ operator_profile $ observer_profile $ bootstrap_profile $ peers $ history_mode $ service_name $ service_namespace $ fetch_trusted_setup $ disable_shard_validation - $ verbose $ ignore_l1_config_peers $ disable_amplification)) + $ verbose $ ignore_l1_config_peers $ disable_amplification + $ ignore_topics)) end type t = Run | Config_init | Config_update | Debug_print_store_schemas @@ -711,13 +736,14 @@ type options = { verbose : bool; ignore_l1_config_peers : bool; disable_amplification : bool; + ignore_topics : Signature.public_key_hash list; } let cli_options_to_options data_dir rpc_addr expected_pow listen_addr public_addr endpoint slots_backup_uris trust_slots_backup_uris metrics_addr attesters operators observers bootstrap_flag peers history_mode service_name service_namespace fetch_trusted_setup disable_shard_validation verbose - ignore_l1_config_peers disable_amplification = + ignore_l1_config_peers disable_amplification ignore_topics = let open Result_syntax in let profile = Controller_profiles.make ~attesters ~operators ?observers () in let* profile = @@ -761,6 +787,7 @@ let cli_options_to_options data_dir rpc_addr expected_pow listen_addr verbose; ignore_l1_config_peers; disable_amplification; + ignore_topics; } let merge_experimental_features _ _configuration = () @@ -787,6 +814,7 @@ let merge verbose; ignore_l1_config_peers; disable_amplification; + ignore_topics = _; } configuration = let profile = match profile with @@ -872,9 +900,26 @@ let run ?disable_logging subcommand cli_options = disable_shard_validation_environment_variable else return_unit in + let* ignore_pkhs = + if env_ignore_topics && List.is_empty cli_options.ignore_topics then + failwith + "The environment variable to ignore topics %s was set, but the \ + option '--ignore-topics' was not provided." + env_var_ignore_topics + else if + (not env_ignore_topics) + && (not @@ List.is_empty cli_options.ignore_topics) + then + failwith + "The option '--ignore-topics' was provided, but the environment \ + variable to ignore topics %s was not set." + env_var_ignore_topics + else return cli_options.ignore_topics + in Daemon.run ?disable_logging ~disable_shard_validation + ~ignore_pkhs ~data_dir ~configuration_override:(merge cli_options) () @@ -905,7 +950,7 @@ let commands = endpoint slots_backup_uris trust_slots_backup_uris metrics_addr attesters operators observers bootstrap_flag peers history_mode service_name service_namespace fetch_trusted_setup disable_shard_validation verbose - ignore_l1_config_peers disable_amplification = + ignore_l1_config_peers disable_amplification ignore_pkhs = match cli_options_to_options data_dir @@ -930,6 +975,7 @@ let commands = verbose ignore_l1_config_peers disable_amplification + ignore_pkhs with | Ok options -> main_run subcommand options | Error msg -> `Error msg diff --git a/src/lib_dal_node/cli.mli b/src/lib_dal_node/cli.mli index 4c9aad5e1e3710d6669a2f9b40f5a7b7b01b205b..47d01d432eb9d07de8edcd53edc4dcdf5c71fcf0 100644 --- a/src/lib_dal_node/cli.mli +++ b/src/lib_dal_node/cli.mli @@ -97,6 +97,8 @@ module Term : sig val disable_amplification_switch : switch val verbose_switch : switch + + val ignore_topics_arg : Signature.public_key_hash arg_list end (** {2 Command-line options} *) @@ -147,6 +149,8 @@ type options = { (** Ignore the boot(strap) peers provided by L1. *) disable_amplification : bool; (** Disable amplification. Default value is false. *) + ignore_topics : Signature.public_key_hash list; + (** Do not distribute shards of these pkhs. *) } (** Subcommands that can be used by the DAL node. In the future this type @@ -164,7 +168,7 @@ val cli_options_to_options : Uri.t list -> bool -> P2p_point.Id.t option -> - Signature.public_key_hash trace -> + Signature.public_key_hash list -> int trace -> int trace option -> bool -> @@ -177,6 +181,7 @@ val cli_options_to_options : bool -> bool -> bool -> + Signature.public_key_hash list -> (options, bool * string) result val run : ?disable_logging:bool -> t -> options -> unit tzresult Lwt.t diff --git a/src/lib_dal_node/daemon.ml b/src/lib_dal_node/daemon.ml index 6dc3b59c6eaf8403c60df4109ceffa4eb51360a0..c19c32e657df60b78698829338462f406b3d25c4 100644 --- a/src/lib_dal_node/daemon.ml +++ b/src/lib_dal_node/daemon.ml @@ -231,8 +231,8 @@ let update_and_register_profiles ctxt = let*! () = Node_context.set_profile_ctxt ctxt profile_ctxt in return_unit -let run ?(disable_logging = false) ?(disable_shard_validation = false) ~data_dir - ~configuration_override () = +let run ?(disable_logging = false) ?(disable_shard_validation = false) + ~ignore_pkhs ~data_dir ~configuration_override () = let open Lwt_result_syntax in let*! () = if disable_logging then Lwt.return_unit @@ -443,6 +443,12 @@ let run ?(disable_logging = false) ?(disable_shard_validation = false) ~data_dir if disable_shard_validation then Event.emit_shard_validation_is_disabled () else Lwt.return_unit in + let*! () = + if not @@ List.is_empty ignore_pkhs then + Event.emit_ignoring_pkhs ~pkhs:ignore_pkhs + else Lwt.return_unit + in + let ignore_pkhs = Signature.Public_key_hash.Set.of_list ignore_pkhs in let ctxt = Node_context.init config @@ -457,6 +463,7 @@ let run ?(disable_logging = false) ?(disable_shard_validation = false) ~data_dir ~last_finalized_level:head_level ~network_name ~disable_shard_validation + ~ignore_pkhs () in let* () = diff --git a/src/lib_dal_node/daemon.mli b/src/lib_dal_node/daemon.mli index 532fa769d94168426732411eeee37c7f585b9f08..87a416e0122ea4bac2714b50f4333b024f892390 100644 --- a/src/lib_dal_node/daemon.mli +++ b/src/lib_dal_node/daemon.mli @@ -6,9 +6,9 @@ (* *) (*****************************************************************************) -(** [run ?disable_logging ?disable_shard_validation ~data_dir ~configuration_override ()] - starts a DAL node with the given data directory and function to generate an initial - configuration. +(** [run ?disable_logging ?disable_shard_validation ~ignore_pkhs ~data_dir + ~configuration_override ()] starts a DAL node with the given data directory + and function to generate an initial configuration. This function performs the following steps: @@ -32,10 +32,13 @@ - Connects the Gossipsub worker with the P2P layer and to the crawler; - Can disable the shard validation using [?disable_shard_validation]. + + - Does not propagate message with topics related to the pkhs in [ignore_pkhs]. *) val run : ?disable_logging:bool -> ?disable_shard_validation:bool -> + ignore_pkhs:Signature.public_key_hash list -> data_dir:string -> configuration_override:(Configuration_file.t -> Configuration_file.t) -> unit -> diff --git a/src/lib_dal_node/event.ml b/src/lib_dal_node/event.ml index bc7e32e2485602f7503eb8bdaf5c49c157a3f358..714717e3fcf7c04c6cc8e250b9ed7d18111132d1 100644 --- a/src/lib_dal_node/event.ml +++ b/src/lib_dal_node/event.ml @@ -32,6 +32,13 @@ let pp_int_list fmt l = fmt l +let pp_pkh_list fmt l = + Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.pp_print_string fmt ", ") + Signature.Public_key_hash.pp + fmt + l + (* DAL node event definitions *) open struct @@ -1091,6 +1098,16 @@ open struct ~msg:"shard validation is disabled" ~level:Warning () + + let ignoring_pkhs = + declare_1 + ~section + ~prefix_name_with_section:true + ~name:"ignoring_pkhs" + ~msg:"The node will not propagate shards assigned to {delegates}." + ~level:Warning + ("delegates", Data_encoding.list Signature.Public_key_hash.encoding) + ~pp1:pp_pkh_list end (* DAL node event emission functions *) @@ -1391,3 +1408,5 @@ let emit_catching_up ~current_level = emit catching_up current_level let emit_end_catchup () = emit end_catchup () let emit_shard_validation_is_disabled () = emit shard_validation_is_disabled () + +let emit_ignoring_pkhs ~pkhs = emit ignoring_pkhs pkhs diff --git a/src/lib_dal_node/node_context.ml b/src/lib_dal_node/node_context.ml index 50e899e8b6145dd63b1a160e997a19c45135778c..7cafc11a5b486a2e0d29d669e342f562f4795a95 100644 --- a/src/lib_dal_node/node_context.ml +++ b/src/lib_dal_node/node_context.ml @@ -44,11 +44,13 @@ type t = { it is the highest level the node is aware of) *) mutable l1_crawler_status : L1_crawler_status.t; disable_shard_validation : bool; + ignore_pkhs : Signature.Public_key_hash.Set.t; } let init config ~network_name profile_ctxt cryptobox shards_proofs_precomputation proto_plugins store gs_worker transport_layer - cctxt ~last_finalized_level ?(disable_shard_validation = false) () = + cctxt ~last_finalized_level ?(disable_shard_validation = false) ~ignore_pkhs + () = { config; network_name; @@ -67,6 +69,7 @@ let init config ~network_name profile_ctxt cryptobox last_finalized_level; l1_crawler_status = Unknown; disable_shard_validation; + ignore_pkhs; } let get_tezos_node_cctxt ctxt = ctxt.tezos_node_cctxt @@ -188,6 +191,8 @@ let get_ongoing_amplifications ctxt = ctxt.ongoing_amplifications let set_ongoing_amplifications ctxt ongoing_amplifications = ctxt.ongoing_amplifications <- ongoing_amplifications +let get_ignore_pkhs ctxt = ctxt.ignore_pkhs + let fetch_committee ctxt ~level = let open Lwt_result_syntax in let {tezos_node_cctxt = cctxt; committee_cache = cache; _} = ctxt in diff --git a/src/lib_dal_node/node_context.mli b/src/lib_dal_node/node_context.mli index 7d3898978874bb1ba92274ecfc0e61e82e9eb9d4..4e7d46d108e0046dd79033ed41c5dbff00711554 100644 --- a/src/lib_dal_node/node_context.mli +++ b/src/lib_dal_node/node_context.mli @@ -42,6 +42,7 @@ val init : Tezos_rpc.Context.generic -> last_finalized_level:int32 -> ?disable_shard_validation:bool -> + ignore_pkhs:Signature.Public_key_hash.Set.t -> unit -> t @@ -158,6 +159,9 @@ val get_ongoing_amplifications : t -> Types.Slot_id.Set.t which there are ongoing amplifications. *) val set_ongoing_amplifications : t -> Types.Slot_id.Set.t -> unit +(** Retrieves the set of pkhs whose messages are not propagated. *) +val get_ignore_pkhs : t -> Signature.Public_key_hash.Set.t + (** [storage_period ctxt proto_parameters] returns for how many levels should the node store data about attested slots. This depends on the node's profile and its history mode. *) diff --git a/src/lib_dal_node/slot_manager.ml b/src/lib_dal_node/slot_manager.ml index 22f70047a67f99d6d46eb7b8d7e4de2b0616357e..524177586b3856ae0a945e73f910c177afb691d4 100644 --- a/src/lib_dal_node/slot_manager.ml +++ b/src/lib_dal_node/slot_manager.ml @@ -664,6 +664,7 @@ let publish_proved_shards ctxt (slot_id : Types.slot_id) ~level_committee in let* committee = level_committee ~level:attestation_level in let attester_of_shard = shards_to_attesters committee in + let ignore_pkhs = Node_context.get_ignore_pkhs ctxt in shards |> Seq.iter_ep (fun Cryptobox.{index = shard_index; share} -> match @@ -706,9 +707,10 @@ let publish_proved_shards ctxt (slot_id : Types.slot_id) ~level_committee message_id message in - Gossipsub.Worker.( - Publish_message {message; topic; message_id} - |> app_input gs_worker) ; + (if not @@ Signature.Public_key_hash.Set.mem pkh ignore_pkhs then + Gossipsub.Worker.( + Publish_message {message; topic; message_id} + |> app_input gs_worker)) ; return_unit) (** This function publishes the shards of a commitment that is waiting diff --git a/tezt/lib_tezos/dal_node.ml b/tezt/lib_tezos/dal_node.ml index f675b1ee3d0524bf05ea6ef837af89b99bf48769..319b62a52607be7975795892e1e7830637e8f1ab 100644 --- a/tezt/lib_tezos/dal_node.ml +++ b/tezt/lib_tezos/dal_node.ml @@ -35,6 +35,7 @@ module Parameters = struct l1_node_endpoint : Endpoint.t; disable_shard_validation : bool; disable_amplification : bool; + ignore_pkhs : string list option; mutable pending_ready : unit option Lwt.u list; runner : Runner.t option; } @@ -54,6 +55,9 @@ include Daemon.Make (Parameters) let disable_shard_validation_environment_variable = "TEZOS_DISABLE_SHARD_VALIDATION_I_KNOW_WHAT_I_AM_DOING" +let ignore_topics_environment_variable = + "TEZOS_IGNORE_TOPICS_I_KNOW_WHAT_I_AM_DOING" + let check_error ?exit_code ?msg dal_node = match dal_node.status with | Not_running -> @@ -312,7 +316,7 @@ let create_from_endpoint ?runner ?(path = Uses.path Constant.octez_dal_node) ?name ?color ?data_dir ?event_pipe ?(rpc_host = Constant.default_host) ?rpc_port ?listen_addr ?public_addr ?metrics_addr ?(disable_shard_validation = false) ?(disable_amplification = false) - ~l1_node_endpoint () = + ?ignore_pkhs ~l1_node_endpoint () = let name = match name with None -> fresh_name () | Some name -> name in let data_dir = match data_dir with None -> Temp.dir name | Some dir -> dir @@ -347,6 +351,7 @@ let create_from_endpoint ?runner ?(path = Uses.path Constant.octez_dal_node) pending_ready = []; disable_shard_validation; disable_amplification; + ignore_pkhs; l1_node_endpoint; runner; } @@ -358,7 +363,7 @@ let create_from_endpoint ?runner ?(path = Uses.path Constant.octez_dal_node) let create ?runner ?(path = Uses.path Constant.octez_dal_node) ?name ?color ?data_dir ?event_pipe ?(rpc_host = Constant.default_host) ?rpc_port ?listen_addr ?public_addr ?metrics_addr ?disable_shard_validation - ?disable_amplification ~node () = + ?disable_amplification ?ignore_pkhs ~node () = create_from_endpoint ?runner ~path @@ -373,6 +378,7 @@ let create ?runner ?(path = Uses.path Constant.octez_dal_node) ?name ?color ?metrics_addr ?disable_shard_validation ?disable_amplification + ?ignore_pkhs ~l1_node_endpoint:(Node.as_rpc_endpoint node) () @@ -398,10 +404,13 @@ let make_arguments node = @ (if node.persistent_state.disable_shard_validation then ["--disable-shard-validation"] else []) - @ - if node.persistent_state.disable_amplification then - ["--disable-amplification"] - else [] + @ (if node.persistent_state.disable_amplification then + ["--disable-amplification"] + else []) + @ Option.fold + ~none:[] + ~some:(fun pkhs -> "--ignore-topics" :: [String.concat "," pkhs]) + node.persistent_state.ignore_pkhs let do_runlike_command ?env ?(event_level = `Debug) node arguments = if node.status <> Not_running then diff --git a/tezt/lib_tezos/dal_node.mli b/tezt/lib_tezos/dal_node.mli index f7c63681bccc713115b67bef563149c948140e25..f4b5774fe962eb91ca661630e837c1cccacd3c23 100644 --- a/tezt/lib_tezos/dal_node.mli +++ b/tezt/lib_tezos/dal_node.mli @@ -36,8 +36,9 @@ type history_mode = Full | Auto | Custom of int val disable_shard_validation_environment_variable : string -(** Creates a DAL node *) +val ignore_topics_environment_variable : string +(** Creates a DAL node *) val create : ?runner:Runner.t -> ?path:string -> @@ -52,6 +53,7 @@ val create : ?metrics_addr:string -> ?disable_shard_validation:bool -> ?disable_amplification:bool -> + ?ignore_pkhs:string list -> node:Node.t -> unit -> t @@ -70,6 +72,7 @@ val create_from_endpoint : ?metrics_addr:string -> ?disable_shard_validation:bool -> ?disable_amplification:bool -> + ?ignore_pkhs:string list -> l1_node_endpoint:Endpoint.t -> unit -> t @@ -100,6 +103,9 @@ val metrics_port : t -> int (** Get the data-dir of an dal node. *) val data_dir : t -> string +(** Get the identity file of a dal node. *) +val identity_file : t -> string + (** [run ?wait_ready ?env ?event_level node] launches the given dal node where env is a map of environment variable. @@ -107,12 +113,7 @@ val data_dir : t -> string [true] by default. [event_level] allows to determine the printed levels. By default, - it is set to [`Debug] by default. -*) - -(** Get the identity file of a dal node. *) -val identity_file : t -> string - + it is set to [`Debug]. *) val run : ?wait_ready:bool -> ?env:string String_map.t -> diff --git a/tezt/tests/cloud/dal.ml b/tezt/tests/cloud/dal.ml index ec0d0a32a0fc165349e0cff95a29c9d3ceb8cd25..ebd979c1b9b25bf718268b3e337b2b6de9508cf1 100644 --- a/tezt/tests/cloud/dal.ml +++ b/tezt/tests/cloud/dal.ml @@ -513,8 +513,8 @@ type configuration = { bootstrap_node_identity_file : string option; bootstrap_dal_node_identity_file : string option; external_rpc : bool; - dal_incentives : bool; disable_shard_validation : bool; + ignore_pkhs : string list; } type bootstrap = { @@ -2477,19 +2477,7 @@ let init_sandbox_and_activate_protocol cloud (configuration : configuration) (producer_accounts @ etherlink_rollup_operator_key @ etherlink_batching_operator_keys) in - let overrides = - if configuration.dal_incentives then - [ - (["dal_parametric"; "incentives_enable"], `Bool true); - (["dal_parametric"; "rewards_ratio"; "numerator"], `String "1"); - (["dal_parametric"; "rewards_ratio"; "denominator"], `String "10"); - (* This one is derived from the two constants above. *) - (["issuance_weights"; "dal_rewards_weight"], `Int 5120); - (* This parameter should be lower than blocks_per_cycle *) - (["nonce_revelation_threshold"], `Int 4); - ] - else [] - in + let overrides = [] in Protocol.write_parameter_file ~bootstrap_accounts ~additional_bootstrap_accounts @@ -2739,11 +2727,16 @@ let init_producer cloud configuration ~bootstrap teztale account i slot_index let () = toplog "Init producer %s: wait for DAL node to be ready" name in let otel = Cloud.open_telemetry_endpoint cloud in let is_ready = + let ignore_pkhs = + if configuration.ignore_pkhs = [] then None + else Some configuration.ignore_pkhs + in Dal_node.Agent.run ?otel ~memtrace:configuration.memtrace ~event_level:`Notice ~disable_shard_validation:configuration.disable_shard_validation + ?ignore_pkhs dal_node in let () = toplog "Init producer %s: DAL node is ready" name in @@ -3736,6 +3729,7 @@ let register (module Cli : Scenarios_cli.Dal) = let data_dir = Cli.data_dir in let producer_key = Cli.producer_key in let producers_delay = Cli.producers_delay in + let ignore_pkhs = Cli.ignore_pkhs in let fundraiser = Option.fold ~none:(Sys.getenv_opt "TEZT_CLOUD_FUNDRAISER") @@ -3762,7 +3756,6 @@ let register (module Cli : Scenarios_cli.Dal) = let with_dal = Cli.with_dal in let bakers = Cli.bakers in let external_rpc = Cli.node_external_rpc_server in - let dal_incentives = Cli.dal_incentives in let disable_shard_validation = Cli.disable_shard_validation in let t = { @@ -3789,8 +3782,8 @@ let register (module Cli : Scenarios_cli.Dal) = bootstrap_node_identity_file; bootstrap_dal_node_identity_file; external_rpc; - dal_incentives; disable_shard_validation; + ignore_pkhs; } in (t, etherlink) diff --git a/tezt/tests/cloud/scenarios_cli.ml b/tezt/tests/cloud/scenarios_cli.ml index a31917252f5ea45419f4b798d53505256c0c3dd9..6d0d9e9213240d84cc7ac99c9a8be712681ef0ad 100644 --- a/tezt/tests/cloud/scenarios_cli.ml +++ b/tezt/tests/cloud/scenarios_cli.ml @@ -84,11 +84,11 @@ module type Dal = sig val with_dal : bool - val dal_incentives : bool - val proxy_localhost : bool val disable_shard_validation : bool + + val ignore_pkhs : string list end module Dal () : Dal = struct @@ -402,15 +402,6 @@ module Dal () : Dal = struct such as [--producers]." true - let dal_incentives = - Clap.flag - ~section - ~set_long:"dal-incentives" - ~unset_long:"no-dal-incentives" - ~description:"Activate the DAL incentives" - (* Activate by default DAL incentives on Alpha. *) - (protocol = Protocol.Alpha) - let proxy_localhost = Clap.flag ~section @@ -428,6 +419,16 @@ module Dal () : Dal = struct ~set_long:"disable-shard-validation" ~description:"All DAL nodes will bypass the shard validation stage." false + + let ignore_pkhs = + Clap.list_string + ~section + ~long:"ignore-pkhs" + ~placeholder:" " + ~description: + "Specify a list of public key hashes for which all the producers will \ + not publish the associated shards." + () end module type Layer1 = sig diff --git a/tezt/tests/cloud/tezos.ml b/tezt/tests/cloud/tezos.ml index 1615c1aa304eb2ead8cfe4edc816b7f04135da1c..737c812b7ee2acfb3a23b99e70a3742da3069281 100644 --- a/tezt/tests/cloud/tezos.ml +++ b/tezt/tests/cloud/tezos.ml @@ -228,7 +228,7 @@ module Dal_node = struct agent let run ?otel ?(memtrace = false) ?event_level - ?(disable_shard_validation = false) dal_node = + ?(disable_shard_validation = false) ?ignore_pkhs dal_node = let name = name dal_node in let filename = Format.asprintf "%s/%s-trace.ctf" Path.tmp_dir name in let env = @@ -250,14 +250,25 @@ module Dal_node = struct let disable_shard_validation_env = if disable_shard_validation then String_map.singleton - "TEZOS_DISABLE_SHARD_VALIDATION_I_KNOW_WHAT_I_AM_DOING" + Dal_node.disable_shard_validation_environment_variable "yes" else String_map.empty in + let ignore_topics_env = + match ignore_pkhs with + | Some (_ :: _) -> + String_map.singleton + Dal_node.ignore_topics_environment_variable + "yes" + | _ -> String_map.empty + in String_map.union (fun _ _ _ -> None) (String_map.union (fun _ _ _ -> None) otel_env memtrace_env) - disable_shard_validation_env + (String_map.union + (fun _ _ _ -> None) + disable_shard_validation_env + ignore_topics_env) in let* () = run ~env ?event_level dal_node in (* Update the state in the service manager *) diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index b1835e612f1b5b23603fceadf0d3ad5da6fff17b..718eb533f6543a113b8095c2a23ae7f2f9e4e828 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -596,13 +596,14 @@ let with_fresh_rollup ?(pvm_name = "arith") ?dal_node f tezos_node tezos_client let make_dal_node ?name ?peers ?attester_profiles ?operator_profiles ?bootstrap_profile ?history_mode ?(wait_ready = true) ?env ?disable_shard_validation ?(event_level = `Debug) ?slots_backup_uris - ?trust_slots_backup_uris ?disable_amplification tezos_node = + ?trust_slots_backup_uris ?disable_amplification ?ignore_pkhs tezos_node = let dal_node = Dal_node.create ?name ?disable_shard_validation - ~node:tezos_node ?disable_amplification + ?ignore_pkhs + ~node:tezos_node () in let* () = @@ -621,7 +622,7 @@ let make_dal_node ?name ?peers ?attester_profiles ?operator_profiles let with_dal_node ?peers ?attester_profiles ?operator_profiles ?bootstrap_profile ?history_mode ?wait_ready ?env ?disable_shard_validation - ?disable_amplification tezos_node f key = + ?disable_amplification ?ignore_pkhs tezos_node f key = let* dal_node = make_dal_node ?peers @@ -633,6 +634,7 @@ let with_dal_node ?peers ?attester_profiles ?operator_profiles ?env ?disable_shard_validation ?disable_amplification + ?ignore_pkhs tezos_node in f key dal_node @@ -689,7 +691,7 @@ let scenario_with_layer1_and_dal_nodes ?regression ?(tags = []) ?dal_rewards_weight ?activation_timestamp ?bootstrap_profile ?event_sections_levels ?operator_profiles ?history_mode ?prover ?l1_history_mode ?wait_ready ?env ?disable_shard_validation - ?disable_amplification variant scenario = + ?disable_amplification ?ignore_pkhs variant scenario = let description = "Testing DAL node" in let tags = if List.mem team tags then tags else team :: tags in test @@ -735,6 +737,7 @@ let scenario_with_layer1_and_dal_nodes ?regression ?(tags = []) ?env ?disable_shard_validation ?disable_amplification + ?ignore_pkhs node @@ fun _key dal_node -> scenario protocol parameters cryptobox node client dal_node) @@ -10498,6 +10501,28 @@ let test_disable_shard_validation_wrong_env _protocol _parameters _cryptobox was not set.*" Dal_node.disable_shard_validation_environment_variable) +let test_ignore_topics_wrong_cli _protocol _parameters _cryptobox _node _client + dal_node = + Dal_node.check_error + dal_node + ~msg: + (rex + @@ Format.sprintf + ".* The environment variable to ignore topics %s was set, but the \ + option '--ignore-topics' was not provided.*" + Dal_node.ignore_topics_environment_variable) + +let test_ignore_topics_wrong_env _protocol _parameters _cryptobox _node _client + dal_node = + Dal_node.check_error + dal_node + ~msg: + (rex + @@ Format.sprintf + ".* The option '--ignore-topics' was provided, but the environment \ + variable to ignore topics %s was not set.*" + Dal_node.ignore_topics_environment_variable) + let register ~protocols = (* Tests with Layer1 node only *) scenario_with_layer1_node @@ -10948,6 +10973,41 @@ let register ~protocols = "yes") ~disable_shard_validation:true "DAL node disable shard validation correct CLI" + (fun _protocol _parameters _cryptobox _node _client dal_node -> + Dal_node.terminate dal_node) + protocols ; + + (* Scenarios for --ignore-topics *) + scenario_with_layer1_and_dal_nodes + ~operator_profiles:[0] + ~wait_ready:false + ~env: + (String_map.singleton Dal_node.ignore_topics_environment_variable "yes") + "DAL node ignore topics wrong CLI" + test_ignore_topics_wrong_cli + protocols ; + scenario_with_layer1_and_dal_nodes + ~operator_profiles:[0] + ~wait_ready:false + ~ignore_pkhs: + [ + Constant.bootstrap1.Account.public_key_hash; + Constant.bootstrap2.Account.public_key_hash; + ] + "DAL node ignore topics wrong env" + test_ignore_topics_wrong_env + protocols ; + scenario_with_layer1_and_dal_nodes + ~operator_profiles:[0] + ~wait_ready:true + ~env: + (String_map.singleton Dal_node.ignore_topics_environment_variable "yes") + ~ignore_pkhs: + [ + Constant.bootstrap1.Account.public_key_hash; + Constant.bootstrap2.Account.public_key_hash; + ] + "DAL node ignore topics correct CLI" (fun _protocol _parameters _cryptobox _node _client dal_node -> Dal_node.terminate dal_node) protocols