Skip to content

Commit bd8ccec

Browse files
michaelsproulisaac.asimov
authored and
isaac.asimov
committed
Avoid excessive logging of BN online status (sigp#4315)
## Issue Addressed sigp#4309 (comment) ## Proposed Changes Log the `Connected to beacon node` message only if the node was previously offline. This avoids a regression in logging after sigp#4295, whereby the `Connected to beacon node` message would be logged every slot. The new reduced logging is _slightly different_ from what we had prior to my changes in sigp#4295. The main difference is that we used to log the `Connected` message whenever a node was online and subject to a health check (for being unhealthy in some other way). I think the new behaviour is reasonable, as the `Connected` message isn't particularly helpful if the BN is unhealthy, and the specific reason for unhealthiness will be logged by the warnings for `is_compatible`/`is_synced`.
1 parent 85c3e68 commit bd8ccec

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

validator_client/src/beacon_node_fallback.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ impl<E: EthSpec> CandidateBeaconNode<E> {
182182
spec: &ChainSpec,
183183
log: &Logger,
184184
) -> Result<(), CandidateError> {
185-
let new_status = if let Err(e) = self.is_online(log).await {
185+
let previous_status = self.status(RequireSynced::Yes).await;
186+
let was_offline = matches!(previous_status, Err(CandidateError::Offline));
187+
188+
let new_status = if let Err(e) = self.is_online(was_offline, log).await {
186189
Err(e)
187190
} else if let Err(e) = self.is_compatible(spec, log).await {
188191
Err(e)
@@ -202,7 +205,7 @@ impl<E: EthSpec> CandidateBeaconNode<E> {
202205
}
203206

204207
/// Checks if the node is reachable.
205-
async fn is_online(&self, log: &Logger) -> Result<(), CandidateError> {
208+
async fn is_online(&self, was_offline: bool, log: &Logger) -> Result<(), CandidateError> {
206209
let result = self
207210
.beacon_node
208211
.get_node_version()
@@ -211,12 +214,14 @@ impl<E: EthSpec> CandidateBeaconNode<E> {
211214

212215
match result {
213216
Ok(version) => {
214-
info!(
215-
log,
216-
"Connected to beacon node";
217-
"version" => version,
218-
"endpoint" => %self.beacon_node,
219-
);
217+
if was_offline {
218+
info!(
219+
log,
220+
"Connected to beacon node";
221+
"version" => version,
222+
"endpoint" => %self.beacon_node,
223+
);
224+
}
220225
Ok(())
221226
}
222227
Err(e) => {

0 commit comments

Comments
 (0)