Include validator indices in attestation logs
## Issue Addressed
Fixes
## Proposed Changes
Collect validator indices alongside attestations when creating signed
attestations (and aggregates) for inclusion in the logs.
## Additional Info
This is my first time looking at Lighthouse source code and using Rust, so newbie feedback appreciated!
@@ -389,12 +389,13 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
)
.await
{
- Ok(()) => Some(attestation),
+ Ok(()) => Some((attestation, duty.validator_index)),
Err(e) => {
crit!(
log,
"Failed to sign attestation";
"error" => ?e,
+ "validator" => ?duty.pubkey,
"committee_index" => committee_index,
"slot" => slot.as_u64(),
);
@@ -404,11 +405,11 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
});
// Execute all the futures in parallel, collecting any successful results.
- let attestations = &join_all(signing_futures)
+ let (ref attestations, ref validator_indices): (Vec<_>, Vec<_>) = join_all(signing_futures)
.await
.into_iter()
.flatten()
- .collect::<Vec<Attestation<E>>>();
+ .unzip();
// Post the attestations to the BN.
match self
@@ -428,6 +429,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
log,
"Successfully published attestations";
"count" => attestations.len(),
+ "validator_indices" => ?validator_indices,
"head_block" => ?attestation_data.beacon_block_root,
"committee_index" => attestation_data.index,
"slot" => attestation_data.slot.as_u64(),
@@ -549,7 +551,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
let attestation = &signed_aggregate_and_proof.message.aggregate;
info!(
log,
- "Successfully published attestations";
+ "Successfully published attestation";
"aggregator" => signed_aggregate_and_proof.message.aggregator_index,
"signatures" => attestation.aggregation_bits.num_set_bits(),
"head_block" => format!("{:?}", attestation.data.beacon_block_root),
@@ -566,6 +568,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
log,
"Failed to publish attestation";
"error" => %e,
+ "aggregator" => signed_aggregate_and_proof.message.aggregator_index,
"committee_index" => attestation.data.index,
"slot" => attestation.data.slot.as_u64(),
"type" => "aggregated",
