From 9b487dc46f897c57d453a113f069eac1b71a787e Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Wed, 19 Mar 2025 13:51:29 +0100 Subject: [PATCH] P2P: temporarily allow network names DAL_* and dal-sandbox compatibility --- src/lib_p2p/p2p_connect_handler.ml | 55 ++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/src/lib_p2p/p2p_connect_handler.ml b/src/lib_p2p/p2p_connect_handler.ml index 3a167c5a83ec..25b01d360072 100644 --- a/src/lib_p2p/p2p_connect_handler.ml +++ b/src/lib_p2p/p2p_connect_handler.ml @@ -338,12 +338,63 @@ let may_select_version ~compare accepted_versions remote_version motive = then return remote_version else P2p_rejection.rejecting motive +(* TODO: https://gitlab.com/tezos/tezos/-/issues/7851 + + The function [is_compatible_chain] below is temporary compatibility code to + support the migration of Tezos DAL nodes to the new network naming scheme + introduced in MR !17288 on master. + + Before MR !17288, DAL nodes used the hardcoded "dal-sandbox" network name on + any Tezos network, which was incorrect. The fix in the MR above introduces a + proper naming scheme where the DAL network name is derived from the L1 chain + name and prefixed with "DAL_", e.g., "TEZOS_MAINNET" -> "DAL_TEZOS_MAINNET". + + This breaking change would prevents old and new DAL nodes from connecting + during the handshake due to mismatched network names. Consequently, the new + naming scheme will only be activated starting with the V23 release, while + this temporary compatibility function [is_compatible_chain] will introduced + in V22. + + More precisely, to handle this transition smoothly, we follow a phased + migration plan inspired by past L1 P2P migrations: + + - Step 1 (V22 release): DAL 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. + + Once all nodes have migrated and Step 3 is reached, this compatibility + function should be removed and replaced with a strict equality check + [local = remote]. + + Note: L1 nodes and existing L1 networks are not affected by this workaround, + as their names do not start with "dal-" or "DAL_". +*) +let is_compatible_chain = + let open Distributed_db_version in + let open String in + let is_legacy_dal_network_name = equal "dal-sandbox" in + fun ~(local : Name.t) ~(remote : Name.t) -> + let local = (local :> string) in + let remote = (remote :> string) in + equal local remote + || (is_legacy_dal_network_name local && starts_with ~prefix:"DAL_" remote) + || (is_legacy_dal_network_name remote && starts_with ~prefix:"DAL_" local) + let select ~chain_name ~distributed_db_versions ~p2p_versions remote = let open Error_monad.Result_syntax in assert (distributed_db_versions <> []) ; assert (p2p_versions <> []) ; - if chain_name <> remote.Network_version.chain_name then - P2p_rejection.rejecting Unknown_chain_name + if + not + (is_compatible_chain + ~local:chain_name + ~remote:remote.Network_version.chain_name) + then P2p_rejection.rejecting Unknown_chain_name else let+ distributed_db_version = may_select_version -- GitLab