diff --git a/validator_client/src/beacon_node_fallback.rs b/validator_client/src/beacon_node_fallback.rs index 18780c3092..d4f7c6c874 100644 --- a/validator_client/src/beacon_node_fallback.rs +++ b/validator_client/src/beacon_node_fallback.rs @@ -162,19 +162,23 @@ impl CandidateBeaconNode { spec: &ChainSpec, log: &Logger, ) -> Result<(), CandidateError> { - let mut status = self.status.write().await; - - if let Err(e) = self.is_online(log).await { - *status = Err(e); + let new_status = if let Err(e) = self.is_online(log).await { + Err(e) } else if let Err(e) = self.is_compatible(spec, log).await { - *status = Err(e); + Err(e) } else if let Err(e) = self.is_synced(slot_clock, log).await { - *status = Err(e); + Err(e) } else { - *status = Ok(()) - } + Ok(()) + }; - *status + // In case of concurrent use, the latest value will always be used. It's possible that a + // long time out might over-ride a recent successful response, leading to a falsely-offline + // status. I deem this edge-case acceptable in return for the concurrency benefits of not + // holding a write-lock whilst we check the online status of the node. + *self.status.write().await = new_status; + + new_status } /// Checks if the node is reachable.