Skip to content

Commit 79367de

Browse files
dknopikThreeHrSleep
andcommitted
Manually merge tracing PR for beacon_node_fallback
Co-authored-by: ThreeHrSleep <[email protected]>
1 parent b49845a commit 79367de

File tree

5 files changed

+48
-83
lines changed

5 files changed

+48
-83
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

validator_client/beacon_node_fallback/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ eth2 = { workspace = true }
1313
futures = { workspace = true }
1414
itertools = { workspace = true }
1515
serde = { workspace = true }
16-
slog = { workspace = true }
1716
slot_clock = { workspace = true }
1817
strum = { workspace = true }
1918
task_executor = { workspace = true }
2019
tokio = { workspace = true }
20+
tracing = { workspace = true }
2121
types = { workspace = true }
2222
validator_metrics = { workspace = true }

validator_client/beacon_node_fallback/src/beacon_node_health.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use super::CandidateError;
22
use eth2::BeaconNodeHttpClient;
33
use itertools::Itertools;
44
use serde::{Deserialize, Serialize};
5-
use slog::{warn, Logger};
65
use std::cmp::Ordering;
76
use std::fmt::{Debug, Display, Formatter};
87
use std::str::FromStr;
8+
use tracing::warn;
99
use types::Slot;
1010

1111
/// Sync distances between 0 and DEFAULT_SYNC_TOLERANCE are considered `synced`.
@@ -290,15 +290,13 @@ impl BeaconNodeHealth {
290290

291291
pub async fn check_node_health(
292292
beacon_node: &BeaconNodeHttpClient,
293-
log: &Logger,
294293
) -> Result<(Slot, bool, bool), CandidateError> {
295294
let resp = match beacon_node.get_node_syncing().await {
296295
Ok(resp) => resp,
297296
Err(e) => {
298297
warn!(
299-
log,
300-
"Unable connect to beacon node";
301-
"error" => %e
298+
error = %e,
299+
"Unable connect to beacon node"
302300
);
303301

304302
return Err(CandidateError::Offline);

validator_client/beacon_node_fallback/src/lib.rs

Lines changed: 43 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use beacon_node_health::{
1010
use eth2::BeaconNodeHttpClient;
1111
use futures::future;
1212
use serde::{ser::SerializeStruct, Deserialize, Serialize, Serializer};
13-
use slog::{debug, error, warn, Logger};
1413
use slot_clock::SlotClock;
1514
use std::cmp::Ordering;
1615
use std::fmt;
@@ -21,6 +20,7 @@ use std::time::{Duration, Instant};
2120
use strum::{EnumString, EnumVariantNames};
2221
use task_executor::TaskExecutor;
2322
use tokio::{sync::RwLock, time::sleep};
23+
use tracing::{debug, error, warn};
2424
use types::{ChainSpec, Config as ConfigSpec, EthSpec, Slot};
2525
use validator_metrics::{inc_counter_vec, ENDPOINT_ERRORS, ENDPOINT_REQUESTS};
2626

@@ -216,15 +216,14 @@ impl CandidateBeaconNode {
216216
distance_tiers: &BeaconNodeSyncDistanceTiers,
217217
slot_clock: Option<&T>,
218218
spec: &ChainSpec,
219-
log: &Logger,
220219
) -> Result<(), CandidateError> {
221-
if let Err(e) = self.is_compatible::<E>(spec, log).await {
220+
if let Err(e) = self.is_compatible::<E>(spec).await {
222221
*self.health.write().await = Err(e);
223222
return Err(e);
224223
}
225224

226225
if let Some(slot_clock) = slot_clock {
227-
match check_node_health(&self.beacon_node, log).await {
226+
match check_node_health(&self.beacon_node).await {
228227
Ok((head, is_optimistic, el_offline)) => {
229228
let Some(slot_clock_head) = slot_clock.now() else {
230229
let e = match slot_clock.is_prior_to_genesis() {
@@ -282,84 +281,73 @@ impl CandidateBeaconNode {
282281
}
283282

284283
/// Checks if the node has the correct specification.
285-
async fn is_compatible<E: EthSpec>(
286-
&self,
287-
spec: &ChainSpec,
288-
log: &Logger,
289-
) -> Result<(), CandidateError> {
284+
async fn is_compatible<E: EthSpec>(&self, spec: &ChainSpec) -> Result<(), CandidateError> {
290285
let config = self
291286
.beacon_node
292287
.get_config_spec::<ConfigSpec>()
293288
.await
294289
.map_err(|e| {
295290
error!(
296-
log,
297-
"Unable to read spec from beacon node";
298-
"error" => %e,
299-
"endpoint" => %self.beacon_node,
291+
error = %e,
292+
endpoint = %self.beacon_node,
293+
"Unable to read spec from beacon node"
300294
);
301295
CandidateError::Offline
302296
})?
303297
.data;
304298

305299
let beacon_node_spec = ChainSpec::from_config::<E>(&config).ok_or_else(|| {
306300
error!(
307-
log,
301+
endpoint = %self.beacon_node,
308302
"The minimal/mainnet spec type of the beacon node does not match the validator \
309-
client. See the --network command.";
310-
"endpoint" => %self.beacon_node,
303+
client. See the --network command."
304+
311305
);
312306
CandidateError::Incompatible
313307
})?;
314308

315309
if beacon_node_spec.genesis_fork_version != spec.genesis_fork_version {
316310
error!(
317-
log,
318-
"Beacon node is configured for a different network";
319-
"endpoint" => %self.beacon_node,
320-
"bn_genesis_fork" => ?beacon_node_spec.genesis_fork_version,
321-
"our_genesis_fork" => ?spec.genesis_fork_version,
311+
endpoint = %self.beacon_node,
312+
bn_genesis_fork = ?beacon_node_spec.genesis_fork_version,
313+
our_genesis_fork = ?spec.genesis_fork_version,
314+
"Beacon node is configured for a different network"
322315
);
323316
return Err(CandidateError::Incompatible);
324317
} else if beacon_node_spec.altair_fork_epoch != spec.altair_fork_epoch {
325318
warn!(
326-
log,
327-
"Beacon node has mismatched Altair fork epoch";
328-
"endpoint" => %self.beacon_node,
329-
"endpoint_altair_fork_epoch" => ?beacon_node_spec.altair_fork_epoch,
330-
"hint" => UPDATE_REQUIRED_LOG_HINT,
319+
endpoint = %self.beacon_node,
320+
endpoint_altair_fork_epoch = ?beacon_node_spec.altair_fork_epoch,
321+
hint = UPDATE_REQUIRED_LOG_HINT,
322+
"Beacon node has mismatched Altair fork epoch"
331323
);
332324
} else if beacon_node_spec.bellatrix_fork_epoch != spec.bellatrix_fork_epoch {
333325
warn!(
334-
log,
335-
"Beacon node has mismatched Bellatrix fork epoch";
336-
"endpoint" => %self.beacon_node,
337-
"endpoint_bellatrix_fork_epoch" => ?beacon_node_spec.bellatrix_fork_epoch,
338-
"hint" => UPDATE_REQUIRED_LOG_HINT,
326+
endpoint = %self.beacon_node,
327+
endpoint_bellatrix_fork_epoch = ?beacon_node_spec.bellatrix_fork_epoch,
328+
hint = UPDATE_REQUIRED_LOG_HINT,
329+
"Beacon node has mismatched Bellatrix fork epoch"
339330
);
340331
} else if beacon_node_spec.capella_fork_epoch != spec.capella_fork_epoch {
341332
warn!(
342-
log,
343-
"Beacon node has mismatched Capella fork epoch";
344-
"endpoint" => %self.beacon_node,
345-
"endpoint_capella_fork_epoch" => ?beacon_node_spec.capella_fork_epoch,
346-
"hint" => UPDATE_REQUIRED_LOG_HINT,
333+
endpoint = %self.beacon_node,
334+
endpoint_capella_fork_epoch = ?beacon_node_spec.capella_fork_epoch,
335+
hint = UPDATE_REQUIRED_LOG_HINT,
336+
"Beacon node has mismatched Capella fork epoch"
347337
);
348338
} else if beacon_node_spec.deneb_fork_epoch != spec.deneb_fork_epoch {
349339
warn!(
350-
log,
351-
"Beacon node has mismatched Deneb fork epoch";
352-
"endpoint" => %self.beacon_node,
353-
"endpoint_deneb_fork_epoch" => ?beacon_node_spec.deneb_fork_epoch,
354-
"hint" => UPDATE_REQUIRED_LOG_HINT,
340+
endpoint = %self.beacon_node,
341+
endpoint_deneb_fork_epoch = ?beacon_node_spec.deneb_fork_epoch,
342+
hint = UPDATE_REQUIRED_LOG_HINT,
343+
"Beacon node has mismatched Deneb fork epoch"
355344
);
356345
} else if beacon_node_spec.electra_fork_epoch != spec.electra_fork_epoch {
357346
warn!(
358-
log,
359-
"Beacon node has mismatched Electra fork epoch";
360-
"endpoint" => %self.beacon_node,
361-
"endpoint_electra_fork_epoch" => ?beacon_node_spec.electra_fork_epoch,
362-
"hint" => UPDATE_REQUIRED_LOG_HINT,
347+
endpoint = %self.beacon_node,
348+
endpoint_electra_fork_epoch = ?beacon_node_spec.electra_fork_epoch,
349+
hint = UPDATE_REQUIRED_LOG_HINT,
350+
"Beacon node has mismatched Electra fork epoch"
363351
);
364352
}
365353

@@ -377,7 +365,6 @@ pub struct BeaconNodeFallback<T> {
377365
slot_clock: Option<T>,
378366
broadcast_topics: Vec<ApiTopic>,
379367
spec: Arc<ChainSpec>,
380-
log: Logger,
381368
}
382369

383370
impl<T: SlotClock> BeaconNodeFallback<T> {
@@ -386,7 +373,6 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
386373
config: Config,
387374
broadcast_topics: Vec<ApiTopic>,
388375
spec: Arc<ChainSpec>,
389-
log: Logger,
390376
) -> Self {
391377
let distance_tiers = config.sync_tolerances;
392378
Self {
@@ -395,7 +381,6 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
395381
slot_clock: None,
396382
broadcast_topics,
397383
spec,
398-
log,
399384
}
400385
}
401386

@@ -478,7 +463,6 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
478463
&self.distance_tiers,
479464
self.slot_clock.as_ref(),
480465
&self.spec,
481-
&self.log,
482466
));
483467
nodes.push(candidate.beacon_node.to_string());
484468
}
@@ -491,10 +475,9 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
491475
if let Err(e) = result {
492476
if *e != CandidateError::PreGenesis {
493477
warn!(
494-
self.log,
495-
"A connected beacon node errored during routine health check";
496-
"error" => ?e,
497-
"endpoint" => node,
478+
error = ?e,
479+
endpoint = %node,
480+
"A connected beacon node errored during routine health check"
498481
);
499482
}
500483
}
@@ -566,11 +549,7 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
566549

567550
// Run `func` using a `candidate`, returning the value or capturing errors.
568551
for candidate in candidates.iter() {
569-
futures.push(Self::run_on_candidate(
570-
candidate.beacon_node.clone(),
571-
&func,
572-
&self.log,
573-
));
552+
futures.push(Self::run_on_candidate(candidate.beacon_node.clone(), &func));
574553
}
575554
drop(candidates);
576555

@@ -588,11 +567,7 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
588567

589568
// Run `func` using a `candidate`, returning the value or capturing errors.
590569
for candidate in candidates.iter() {
591-
futures.push(Self::run_on_candidate(
592-
candidate.beacon_node.clone(),
593-
&func,
594-
&self.log,
595-
));
570+
futures.push(Self::run_on_candidate(candidate.beacon_node.clone(), &func));
596571
}
597572
drop(candidates);
598573

@@ -611,7 +586,6 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
611586
async fn run_on_candidate<F, R, Err, O>(
612587
candidate: BeaconNodeHttpClient,
613588
func: F,
614-
log: &Logger,
615589
) -> Result<O, (String, Error<Err>)>
616590
where
617591
F: Fn(BeaconNodeHttpClient) -> R,
@@ -626,10 +600,9 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
626600
Ok(val) => Ok(val),
627601
Err(e) => {
628602
debug!(
629-
log,
630-
"Request to beacon node failed";
631-
"node" => %candidate,
632-
"error" => ?e,
603+
node = %candidate,
604+
error = ?e,
605+
"Request to beacon node failed"
633606
);
634607
inc_counter_vec(&ENDPOINT_ERRORS, &[candidate.as_ref()]);
635608
Err((candidate.to_string(), Error::RequestFailed(e)))
@@ -656,11 +629,7 @@ impl<T: SlotClock> BeaconNodeFallback<T> {
656629

657630
// Run `func` using a `candidate`, returning the value or capturing errors.
658631
for candidate in candidates.iter() {
659-
futures.push(Self::run_on_candidate(
660-
candidate.beacon_node.clone(),
661-
&func,
662-
&self.log,
663-
));
632+
futures.push(Self::run_on_candidate(candidate.beacon_node.clone(), &func));
664633
}
665634
drop(candidates);
666635

validator_client/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,13 @@ impl<E: EthSpec> ProductionValidatorClient<E> {
390390
config.beacon_node_fallback,
391391
config.broadcast_topics.clone(),
392392
context.eth2_config.spec.clone(),
393-
log.clone(),
394393
);
395394

396395
let mut proposer_nodes: BeaconNodeFallback<_> = BeaconNodeFallback::new(
397396
proposer_candidates,
398397
config.beacon_node_fallback,
399398
config.broadcast_topics.clone(),
400399
context.eth2_config.spec.clone(),
401-
log.clone(),
402400
);
403401

404402
// Perform some potentially long-running initialization tasks.

0 commit comments

Comments
 (0)