From 140abec6ef80e64c8fa58254bf99ad8ad8d6e6c2 Mon Sep 17 00:00:00 2001 From: behzad nouri Date: Sat, 14 Aug 2021 00:47:44 +0000 Subject: [PATCH] exempts node-instances from shred-version check (#19190) Clusters are kept separate using the shred-versions obtained from contact-infos. However, this mechanism breaks if there are 2 instances of the same identity key running on different clusters, because then one of the two contact-infos have the right shred-version. If a node has the contact-info with the matching shred-version, then it will pass all associated crds values even if they belong to the other instance. So the shred-version check breaks. As a result we cannot support 2 instances of the same identity key running on different clusters. To prevent that, this commit is exempting node-instances from shred-version check so that they are always propagated across clusters and halt one of the running duplicate instances. --- gossip/src/cluster_info.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index e1414afdef..a9a0c0555c 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -2922,18 +2922,24 @@ fn filter_on_shred_version( ) -> Option { let filter_values = |from: &Pubkey, values: &mut Vec, skipped_counter: &Counter| { let num_values = values.len(); + // Node-instances are always exempted from shred-version check so that: + // * their propagation across cluster is expedited. + // * prevent two running instances of the same identity key cross + // contaminate gossip between clusters. if crds.get_shred_version(from) == Some(self_shred_version) { - // Retain values with the same shred-vesion, or those which are - // contact-info so that shred-versions can be updated. values.retain(|value| match &value.data { + // Allow contact-infos so that shred-versions are updated. CrdsData::ContactInfo(_) => true, + CrdsData::NodeInstance(_) => true, + // Only retain values with the same shred version. _ => crds.get_shred_version(&value.pubkey()) == Some(self_shred_version), }) } else { - // Only allow node to update its own contact info in case their - // shred-version changes. values.retain(|value| match &value.data { + // Allow node to update its own contact info in case their + // shred-version changes CrdsData::ContactInfo(node) => node.id == *from, + CrdsData::NodeInstance(_) => true, _ => false, }) }