From 4544dff940acfb0378ff0c130c1d25d3f7f60a73 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Tue, 18 Mar 2025 08:17:12 +0100 Subject: [PATCH 1/3] DAL: GS/P2P interface takes argument of type Distributed_db_version.Name.t for network_name --- src/bin_dal_node/daemon.ml | 5 ++++- src/bin_dal_node/node_context.ml | 5 ++++- src/lib_dal_node/gossipsub/gossipsub.mli | 4 ++-- src/lib_dal_node/gossipsub/transport_layer_interface.ml | 9 ++++++--- src/lib_dal_node/gossipsub/transport_layer_interface.mli | 4 ++-- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index fa0614bdbcff..bcfc097437a3 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -1544,7 +1544,10 @@ let run ~data_dir ~configuration_override = (* Create a transport (P2P) layer instance. *) let* transport_layer = (* WIP: will be fixed in the next MR. *) - let network_name = Configuration_file.default_network_name in + let network_name = + Distributed_db_version.Name.of_string + Configuration_file.default_network_name + in Gossipsub.Transport_layer.create ~public_addr ~is_bootstrap_peer:(profile = Profile_manager.bootstrap) diff --git a/src/bin_dal_node/node_context.ml b/src/bin_dal_node/node_context.ml index ed6222141b83..e18733ecdb10 100644 --- a/src/bin_dal_node/node_context.ml +++ b/src/bin_dal_node/node_context.ml @@ -214,7 +214,10 @@ let get_fetched_assigned_shard_indices ctxt ~level ~pkh = let version _t = (* WIP: will be fixed in the next MR. *) - let network_name = Configuration_file.default_network_name in + let network_name = + Distributed_db_version.Name.of_string + Configuration_file.default_network_name + in Types.Version.make ~network_version:(Gossipsub.version ~network_name) let warn_if_attesters_not_delegates ctxt operator_profiles = diff --git a/src/lib_dal_node/gossipsub/gossipsub.mli b/src/lib_dal_node/gossipsub/gossipsub.mli index f5bef9de2d5e..49cf272b6034 100644 --- a/src/lib_dal_node/gossipsub/gossipsub.mli +++ b/src/lib_dal_node/gossipsub/gossipsub.mli @@ -85,7 +85,7 @@ module Transport_layer : sig creates a new instance of type {!t}. It is a wrapper on top of {!P2p.create}. *) val create : - network_name:string -> + network_name:Distributed_db_version.Name.t -> public_addr:P2p_point.Id.t -> is_bootstrap_peer:bool -> P2p.config -> @@ -198,4 +198,4 @@ module Transport_layer_hooks : sig end (** [version ~network_name] returns the current version of the P2P. *) -val version : network_name:string -> Network_version.t +val version : network_name:Distributed_db_version.Name.t -> Network_version.t diff --git a/src/lib_dal_node/gossipsub/transport_layer_interface.ml b/src/lib_dal_node/gossipsub/transport_layer_interface.ml index f8a0323b0670..a59fd98a6dc3 100644 --- a/src/lib_dal_node/gossipsub/transport_layer_interface.ml +++ b/src/lib_dal_node/gossipsub/transport_layer_interface.ml @@ -210,14 +210,17 @@ module P2p_message_V1 = struct let distributed_db_versions = [distributed_db_version] let message_config ~network_name : p2p_message P2p_params.message_config = - let chain_name = Distributed_db_version.Name.of_string network_name in - {encoding = p2p_message_app_encoding; chain_name; distributed_db_versions} + { + encoding = p2p_message_app_encoding; + chain_name = network_name; + distributed_db_versions; + } end let version ~network_name = Network_version. { - chain_name = Distributed_db_version.Name.of_string network_name; + chain_name = network_name; distributed_db_version = P2p_message_V1.distributed_db_version; p2p_version = P2p_version.one; } diff --git a/src/lib_dal_node/gossipsub/transport_layer_interface.mli b/src/lib_dal_node/gossipsub/transport_layer_interface.mli index 508275946999..c99e531791cc 100644 --- a/src/lib_dal_node/gossipsub/transport_layer_interface.mli +++ b/src/lib_dal_node/gossipsub/transport_layer_interface.mli @@ -51,7 +51,7 @@ val pp_p2p_message : (** A P2P message config is parameterized by the network's name. *) val message_config : - network_name:string -> + network_name:Distributed_db_version.Name.t -> Gs_interface.Worker_instance.p2p_message P2p_params.message_config -val version : network_name:string -> Network_version.t +val version : network_name:Distributed_db_version.Name.t -> Network_version.t -- GitLab From 4191bbe283769568458fadc00c22a835bd9c9ef6 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 17 Mar 2025 16:57:43 +0100 Subject: [PATCH 2/3] DAL/Node: introduce a function infer_dal_network_name This function, which will be used in the next commit, allows to infer the DAL network name from the L1 chain. --- src/bin_dal_node/daemon.ml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index bcfc097437a3..7ea5b8cdb54c 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -58,6 +58,23 @@ let fetch_dal_config cctxt = ~rpc:Config_services.dal_config ~requested_info:"DAL config" +let fetch_l1_version_info cctxt = + fetch_info_from_l1 + cctxt + ~rpc:Version_services.version + ~requested_info:"version info" + +(* Infers the DAL network name based on the L1 chain name. + + This function queries the L1 node to retrieve its chain name, then constructs + the corresponding DAL network name by prefixing it with "DAL_". The resulting + name is returned as a [Distributed_db_version.Name.t]. *) +let _infer_dal_network_name cctxt = + let open Lwt_result_syntax in + let+ l1_version = fetch_l1_version_info cctxt in + Format.sprintf "DAL_%s" (l1_version.network_version.chain_name :> string) + |> Distributed_db_version.Name.of_string + let init_cryptobox config proto_parameters = let open Lwt_result_syntax in let prover_srs = -- GitLab From f037fa0383bc841e3c6f0271abd648f85eb33a0e Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Tue, 18 Mar 2025 13:42:53 +0100 Subject: [PATCH 3/3] DAL/Node: (may) infer and use the DAL network name at startup following migration plan We follow the plan below for the migration: - Step 1 (V22 release): Nodes advertise the old "dal-sandbox" name but accept both "dal-sandbox" and "DAL_*" network names. - Step 2 (V23 release): Nodes advertise the new "DAL_*" name while still accepting both "dal-sandbox" and "DAL_*" network names. - Step 3 (V24 release): Nodes advertise and accept only the new "DAL_*" network names. This commit implements part of this logic, the other part is implemented on the P2P side in MR https://gitlab.com/tezos/tezos/-/merge_requests/17330. --- src/bin_dal_node/configuration_file.ml | 6 ++-- src/bin_dal_node/configuration_file.mli | 2 +- src/bin_dal_node/daemon.ml | 40 +++++++++++++++++-------- src/bin_dal_node/node_context.ml | 14 ++++----- src/bin_dal_node/node_context.mli | 1 + 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/bin_dal_node/configuration_file.ml b/src/bin_dal_node/configuration_file.ml index 38fd918fc406..872f43630893 100644 --- a/src/bin_dal_node/configuration_file.ml +++ b/src/bin_dal_node/configuration_file.ml @@ -106,7 +106,7 @@ let default_peers = [] let default_expected_pow = Gossipsub.Transport_layer.Default_parameters.P2p_config.expected_pow -let default_network_name = "dal-sandbox" +let legacy_network_name = "dal-sandbox" let default_endpoint = Uri.of_string "http://localhost:8732" @@ -372,7 +372,7 @@ module V0 = struct (dft "neighbors" (list neighbor_encoding) default_neighbors) (dft "peers" (list string) default_peers) (dft "expected-pow" float default_expected_pow) - (dft "network-name" string default_network_name) + (dft "network-name" string legacy_network_name) (dft "endpoint" endpoint_encoding default_endpoint) (dft "metrics-addr" P2p_point.Id.encoding default_metrics_addr)) (obj2 @@ -463,7 +463,7 @@ module V1 = struct (dft "neighbors" (list neighbor_encoding) default_neighbors) (dft "peers" (list string) default_peers) (dft "expected-pow" float default_expected_pow) - (dft "network-name" string default_network_name) + (dft "network-name" string legacy_network_name) (dft "endpoint" endpoint_encoding default_endpoint) (dft "metrics-addr" (Encoding.option P2p_point.Id.encoding) None)) (obj8 diff --git a/src/bin_dal_node/configuration_file.mli b/src/bin_dal_node/configuration_file.mli index f378c2382c3b..2c05ffc89ae5 100644 --- a/src/bin_dal_node/configuration_file.mli +++ b/src/bin_dal_node/configuration_file.mli @@ -92,4 +92,4 @@ val identity_file : t -> string file of the DAL node, based on the configuration [config]. *) val peers_file : t -> string -val default_network_name : string +val legacy_network_name : string diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 7ea5b8cdb54c..eedd1fcedb2c 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -64,16 +64,33 @@ let fetch_l1_version_info cctxt = ~rpc:Version_services.version ~requested_info:"version info" -(* Infers the DAL network name based on the L1 chain name. +(* TODO: https://gitlab.com/tezos/tezos/-/issues/7851 - This function queries the L1 node to retrieve its chain name, then constructs - the corresponding DAL network name by prefixing it with "DAL_". The resulting - name is returned as a [Distributed_db_version.Name.t]. *) -let _infer_dal_network_name cctxt = + Remove the legacy case from this function once the migration to V23 is complete. + + The function below infers the DAL network name based on the L1 chain name and + the DAL node version. + + - For DAL node versions <= V22, the legacy "dal-sandbox" network name is used. + - For versions >= V23, the new naming scheme "DAL_" is used. + + This ensures a smooth transition during the migration period. + + For the new naming scheme, the function queries the L1 node to retrieve its + chain name and constructs the corresponding DAL network name by prefixing + it with "DAL_". +*) +let infer_dal_network_name cctxt = let open Lwt_result_syntax in - let+ l1_version = fetch_l1_version_info cctxt in - Format.sprintf "DAL_%s" (l1_version.network_version.chain_name :> string) - |> Distributed_db_version.Name.of_string + let version = Tezos_version_value.Current_git_info.octez_version in + if version.major <= 22 then + return + (Distributed_db_version.Name.of_string + Configuration_file.legacy_network_name) (* legacy "dal-sandbox" *) + else + let+ l1_version = fetch_l1_version_info cctxt in + Format.sprintf "DAL_%s" (l1_version.network_version.chain_name :> string) + |> Distributed_db_version.Name.of_string let init_cryptobox config proto_parameters = let open Lwt_result_syntax in @@ -1468,6 +1485,7 @@ let run ~data_dir ~configuration_override = let*! () = Event.emit_configuration_loaded () in let cctxt = Rpc_context.make endpoint in let* dal_config = fetch_dal_config cctxt in + let* network_name = infer_dal_network_name cctxt in let bootstrap_names = points @ dal_config.bootstrap_peers in let*! () = if bootstrap_names = [] then Event.emit_config_error_no_bootstrap () @@ -1560,11 +1578,6 @@ let run ~data_dir ~configuration_override = let points = get_bootstrap_points () in (* Create a transport (P2P) layer instance. *) let* transport_layer = - (* WIP: will be fixed in the next MR. *) - let network_name = - Distributed_db_version.Name.of_string - Configuration_file.default_network_name - in Gossipsub.Transport_layer.create ~public_addr ~is_bootstrap_peer:(profile = Profile_manager.bootstrap) @@ -1649,6 +1662,7 @@ let run ~data_dir ~configuration_override = transport_layer cctxt ~last_finalized_level:head_level + ~network_name in let* () = match Profile_manager.get_profiles profile_ctxt with diff --git a/src/bin_dal_node/node_context.ml b/src/bin_dal_node/node_context.ml index e18733ecdb10..60c243ceda9a 100644 --- a/src/bin_dal_node/node_context.ml +++ b/src/bin_dal_node/node_context.ml @@ -26,6 +26,7 @@ type t = { config : Configuration_file.t; + network_name : Distributed_db_version.Name.t; cryptobox : Cryptobox.t; shards_proofs_precomputation : Cryptobox.shards_proofs_precomputation option; mutable proto_plugins : Proto_plugins.t; @@ -44,8 +45,9 @@ type t = { it is the highest level the node is aware of) *) } -let init config profile_ctxt cryptobox shards_proofs_precomputation - proto_plugins store gs_worker transport_layer cctxt ~last_finalized_level = +let init config ~network_name profile_ctxt cryptobox + shards_proofs_precomputation proto_plugins store gs_worker transport_layer + cctxt ~last_finalized_level = let neighbors_cctxts = (* TODO: This early feature is not used anymore. An MR that cleans this part of the code has been opened here: @@ -54,6 +56,7 @@ let init config profile_ctxt cryptobox shards_proofs_precomputation in { config; + network_name; cryptobox; shards_proofs_precomputation; proto_plugins; @@ -212,12 +215,7 @@ let get_fetched_assigned_shard_indices ctxt ~level ~pkh = |> Option.value ~default:[]) (Committee_cache.find ctxt.committee_cache ~level) -let version _t = - (* WIP: will be fixed in the next MR. *) - let network_name = - Distributed_db_version.Name.of_string - Configuration_file.default_network_name - in +let version {network_name; _} = Types.Version.make ~network_version:(Gossipsub.version ~network_name) let warn_if_attesters_not_delegates ctxt operator_profiles = diff --git a/src/bin_dal_node/node_context.mli b/src/bin_dal_node/node_context.mli index e3666648a30d..7afa2f5a8855 100644 --- a/src/bin_dal_node/node_context.mli +++ b/src/bin_dal_node/node_context.mli @@ -31,6 +31,7 @@ type t (** [init] creates a [t] value based on the given arguments. *) val init : Configuration_file.t -> + network_name:Distributed_db_version.Name.t -> Profile_manager.t -> Cryptobox.t -> Cryptobox.shards_proofs_precomputation option -> -- GitLab