From ce4df50af55522bd7748d0b50174c99a71510f79 Mon Sep 17 00:00:00 2001 From: Mac L Date: Tue, 13 Jun 2023 17:35:18 +1000 Subject: [PATCH] Tie-break with sync distance for non-synced nodes --- validator_client/src/beacon_node_health.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/validator_client/src/beacon_node_health.rs b/validator_client/src/beacon_node_health.rs index 3ab6b473e0..33940102c1 100644 --- a/validator_client/src/beacon_node_health.rs +++ b/validator_client/src/beacon_node_health.rs @@ -98,7 +98,19 @@ impl Display for BeaconNodeHealthTier { impl Ord for BeaconNodeHealthTier { fn cmp(&self, other: &Self) -> Ordering { - self.tier.cmp(&other.tier) + let ordering = self.tier.cmp(&other.tier); + if ordering == Ordering::Equal { + // These tiers represent `synced`. + if [1, 3, 5, 6].contains(&self.tier) { + // Don't tie-break on sync distance in these cases. + // This ensures validator clients don't artificially prefer one node. + ordering + } else { + self.sync_distance.cmp(&other.sync_distance) + } + } else { + ordering + } } }