Skip to content

Commit ee25fbe

Browse files
committed
add tracing to validator_client
1 parent 3ca3cfe commit ee25fbe

22 files changed

+618
-857
lines changed

validator_client/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ serde_json = { workspace = true }
2525
slog = { workspace = true }
2626
tokio = { workspace = true }
2727
tokio-stream = { workspace = true }
28+
tracing = {workspace = true}
2829
futures = { workspace = true }
2930
dirs = { workspace = true }
3031
directory = { workspace = true }

validator_client/slashing_protection/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ serde_json = { workspace = true }
2020
ethereum_serde_utils = { workspace = true }
2121
filesystem = { workspace = true }
2222
arbitrary = { workspace = true, features = ["derive"] }
23+
tracing = {workspace = true}
2324

2425
[dev-dependencies]
2526
rayon = { workspace = true }

validator_client/src/attestation_service.rs

Lines changed: 67 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use crate::{
77
};
88
use environment::RuntimeContext;
99
use futures::future::join_all;
10-
use slog::{crit, debug, error, info, trace, warn};
10+
use logging::crit;
1111
use slot_clock::SlotClock;
1212
use std::collections::HashMap;
1313
use std::ops::Deref;
1414
use std::sync::Arc;
1515
use tokio::time::{sleep, sleep_until, Duration, Instant};
16+
use tracing::{debug, error, info, trace, warn};
1617
use tree_hash::TreeHash;
1718
use types::{Attestation, AttestationData, ChainSpec, CommitteeIndex, EthSpec, Slot};
1819

@@ -130,9 +131,8 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
130131
.ok_or("Unable to determine duration to next slot")?;
131132

132133
info!(
133-
log,
134-
"Attestation production service started";
135-
"next_update_millis" => duration_to_next_slot.as_millis()
134+
next_update_millis = duration_to_next_slot.as_millis(),
135+
"Attestation production service started"
136136
);
137137

138138
let executor = self.context.executor.clone();
@@ -144,19 +144,12 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
144144
let log = self.context.log();
145145

146146
if let Err(e) = self.spawn_attestation_tasks(slot_duration) {
147-
crit!(
148-
log,
149-
"Failed to spawn attestation tasks";
150-
"error" => e
151-
)
147+
crit!(error = e, "Failed to spawn attestation tasks")
152148
} else {
153-
trace!(
154-
log,
155-
"Spawned attestation tasks";
156-
)
149+
trace!("Spawned attestation tasks")
157150
}
158151
} else {
159-
error!(log, "Failed to read slot clock");
152+
error!("Failed to read slot clock");
160153
// If we can't read the slot clock, just wait another slot.
161154
sleep(slot_duration).await;
162155
continue;
@@ -258,11 +251,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
258251
.await
259252
.map_err(move |e| {
260253
crit!(
261-
log,
262-
"Error during attestation routine";
263-
"error" => format!("{:?}", e),
264-
"committee_index" => committee_index,
265-
"slot" => slot.as_u64(),
254+
error = format!("{:?}", e),
255+
committee_index,
256+
slot = slot.as_u64(),
257+
"Error during attestation routine"
266258
)
267259
})?;
268260

@@ -295,11 +287,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
295287
.await
296288
.map_err(move |e| {
297289
crit!(
298-
log,
299-
"Error during attestation routine";
300-
"error" => format!("{:?}", e),
301-
"committee_index" => committee_index,
302-
"slot" => slot.as_u64(),
290+
error = format!("{:?}", e),
291+
committee_index,
292+
slot = slot.as_u64(),
293+
"Error during attestation routine"
303294
)
304295
})?;
305296
}
@@ -366,13 +357,12 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
366357
// Ensure that the attestation matches the duties.
367358
if !duty.match_attestation_data::<E>(attestation_data, &self.context.eth2_config.spec) {
368359
crit!(
369-
log,
370-
"Inconsistent validator duties during signing";
371-
"validator" => ?duty.pubkey,
372-
"duty_slot" => duty.slot,
373-
"attestation_slot" => attestation_data.slot,
374-
"duty_index" => duty.committee_index,
375-
"attestation_index" => attestation_data.index,
360+
validator = ?duty.pubkey,
361+
?duty.slot,
362+
attestation_slot = ?attestation_data.slot,
363+
duty_index = duty.committee_index,
364+
attestation_index = attestation_data.index,
365+
"Inconsistent validator duties during signing"
376366
);
377367
return None;
378368
}
@@ -389,11 +379,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
389379
Ok(attestation) => attestation,
390380
Err(err) => {
391381
crit!(
392-
log,
393-
"Invalid validator duties during signing";
394-
"validator" => ?duty.pubkey,
395-
"duty" => ?duty,
396-
"err" => ?err,
382+
validator = ?duty.pubkey,
383+
?duty,
384+
?err,
385+
"Invalid validator duties during signing"
397386
);
398387
return None;
399388
}
@@ -414,24 +403,22 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
414403
// A pubkey can be missing when a validator was recently
415404
// removed via the API.
416405
warn!(
417-
log,
418-
"Missing pubkey for attestation";
419-
"info" => "a validator may have recently been removed from this VC",
420-
"pubkey" => ?pubkey,
421-
"validator" => ?duty.pubkey,
422-
"committee_index" => committee_index,
423-
"slot" => slot.as_u64(),
406+
info = "a validator may have recently been removed from this VC",
407+
?pubkey,
408+
validator = ?duty.pubkey,
409+
committee_index = committee_index,
410+
slot = slot.as_u64(),
411+
"Missing pubkey for attestation"
424412
);
425413
None
426414
}
427415
Err(e) => {
428416
crit!(
429-
log,
430-
"Failed to sign attestation";
431-
"error" => ?e,
432-
"validator" => ?duty.pubkey,
433-
"committee_index" => committee_index,
434-
"slot" => slot.as_u64(),
417+
error = ?e,
418+
validator = ?duty.pubkey,
419+
committee_index,
420+
slot = slot.as_u64(),
421+
"Failed to sign attestation"
435422
);
436423
None
437424
}
@@ -446,7 +433,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
446433
.unzip();
447434

448435
if attestations.is_empty() {
449-
warn!(log, "No attestations were published");
436+
warn!("No attestations were published");
450437
return Ok(None);
451438
}
452439
let fork_name = self
@@ -481,22 +468,20 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
481468
.await
482469
{
483470
Ok(()) => info!(
484-
log,
485-
"Successfully published attestations";
486-
"count" => attestations.len(),
487-
"validator_indices" => ?validator_indices,
488-
"head_block" => ?attestation_data.beacon_block_root,
489-
"committee_index" => attestation_data.index,
490-
"slot" => attestation_data.slot.as_u64(),
491-
"type" => "unaggregated",
471+
count = attestations.len(),
472+
?validator_indices,
473+
head_block = ?attestation_data.beacon_block_root,
474+
committee_index = attestation_data.index,
475+
slot = attestation_data.slot.as_u64(),
476+
r#type = "unaggregated",
477+
"Successfully published attestations"
492478
),
493479
Err(e) => error!(
494-
log,
495-
"Unable to publish attestations";
496-
"error" => %e,
497-
"committee_index" => attestation_data.index,
498-
"slot" => slot.as_u64(),
499-
"type" => "unaggregated",
480+
error = %e,
481+
committee_index = attestation_data.index,
482+
slot = slot.as_u64(),
483+
r#type = "unaggregated",
484+
"Unable to publish attestations"
500485
),
501486
}
502487

@@ -589,7 +574,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
589574
let selection_proof = duty_and_proof.selection_proof.as_ref()?;
590575

591576
if !duty.match_attestation_data::<E>(attestation_data, &self.context.eth2_config.spec) {
592-
crit!(log, "Inconsistent validator duties during signing");
577+
crit!("Inconsistent validator duties during signing");
593578
return None;
594579
}
595580

@@ -607,19 +592,14 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
607592
Err(ValidatorStoreError::UnknownPubkey(pubkey)) => {
608593
// A pubkey can be missing when a validator was recently
609594
// removed via the API.
610-
debug!(
611-
log,
612-
"Missing pubkey for aggregate";
613-
"pubkey" => ?pubkey,
614-
);
595+
debug!(?pubkey, "Missing pubkey for aggregate");
615596
None
616597
}
617598
Err(e) => {
618599
crit!(
619-
log,
620-
"Failed to sign aggregate";
621-
"error" => ?e,
622-
"pubkey" => ?duty.pubkey,
600+
error = ?e,
601+
pubkey = ?duty.pubkey,
602+
"Failed to sign aggregate"
623603
);
624604
None
625605
}
@@ -667,28 +647,26 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
667647
for signed_aggregate_and_proof in signed_aggregate_and_proofs {
668648
let attestation = signed_aggregate_and_proof.message().aggregate();
669649
info!(
670-
log,
671-
"Successfully published attestation";
672-
"aggregator" => signed_aggregate_and_proof.message().aggregator_index(),
673-
"signatures" => attestation.num_set_aggregation_bits(),
674-
"head_block" => format!("{:?}", attestation.data().beacon_block_root),
675-
"committee_index" => attestation.committee_index(),
676-
"slot" => attestation.data().slot.as_u64(),
677-
"type" => "aggregated",
650+
aggregator = signed_aggregate_and_proof.message().aggregator_index(),
651+
signatures = attestation.num_set_aggregation_bits(),
652+
head_block = format!("{:?}", attestation.data().beacon_block_root),
653+
committee_index = attestation.committee_index(),
654+
slot = attestation.data().slot.as_u64(),
655+
r#type = "aggregated",
656+
"Successfully published attestation"
678657
);
679658
}
680659
}
681660
Err(e) => {
682661
for signed_aggregate_and_proof in signed_aggregate_and_proofs {
683662
let attestation = &signed_aggregate_and_proof.message().aggregate();
684663
crit!(
685-
log,
686-
"Failed to publish attestation";
687-
"error" => %e,
688-
"aggregator" => signed_aggregate_and_proof.message().aggregator_index(),
689-
"committee_index" => attestation.committee_index(),
690-
"slot" => attestation.data().slot.as_u64(),
691-
"type" => "aggregated",
664+
error = %e,
665+
aggregator = signed_aggregate_and_proof.message().aggregator_index(),
666+
committee_index = attestation.committee_index(),
667+
slot = attestation.data().slot.as_u64(),
668+
r#type = "aggregated",
669+
"Failed to publish attestation"
692670
);
693671
}
694672
}

0 commit comments

Comments
 (0)