mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Integrate tracing (#6339)
Tracing Integration
- [reference](5bbf1859e9/projects/project-ideas.md (L297))
- [x] replace slog & log with tracing throughout the codebase
- [x] implement custom crit log
- [x] make relevant changes in the formatter
- [x] replace sloggers
- [x] re-write SSE logging components
cc: @macladson @eserilev
This commit is contained in:
@@ -7,7 +7,6 @@ use crate::data_availability_checker::overflow_lru_cache::{
|
||||
};
|
||||
use crate::{metrics, BeaconChain, BeaconChainTypes, BeaconStore};
|
||||
use kzg::Kzg;
|
||||
use slog::{debug, error, Logger};
|
||||
use slot_clock::SlotClock;
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
@@ -16,6 +15,7 @@ use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use task_executor::TaskExecutor;
|
||||
use tokio::sync::oneshot;
|
||||
use tracing::{debug, error, info_span, Instrument};
|
||||
use types::blob_sidecar::{BlobIdentifier, BlobSidecar, FixedBlobSidecarList};
|
||||
use types::{
|
||||
BlobSidecarList, ChainSpec, DataColumnIdentifier, DataColumnSidecar, DataColumnSidecarList,
|
||||
@@ -75,7 +75,6 @@ pub struct DataAvailabilityChecker<T: BeaconChainTypes> {
|
||||
slot_clock: T::SlotClock,
|
||||
kzg: Arc<Kzg>,
|
||||
spec: Arc<ChainSpec>,
|
||||
log: Logger,
|
||||
}
|
||||
|
||||
pub type AvailabilityAndReconstructedColumns<E> = (Availability<E>, DataColumnSidecarList<E>);
|
||||
@@ -114,7 +113,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
store: BeaconStore<T>,
|
||||
import_all_data_columns: bool,
|
||||
spec: Arc<ChainSpec>,
|
||||
log: Logger,
|
||||
) -> Result<Self, AvailabilityCheckError> {
|
||||
let custody_group_count = spec.custody_group_count(import_all_data_columns);
|
||||
// This should only panic if the chain spec contains invalid values.
|
||||
@@ -133,7 +131,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
slot_clock,
|
||||
kzg,
|
||||
spec,
|
||||
log,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -218,7 +215,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
.map_err(AvailabilityCheckError::InvalidBlobs)?;
|
||||
|
||||
self.availability_cache
|
||||
.put_kzg_verified_blobs(block_root, verified_blobs, &self.log)
|
||||
.put_kzg_verified_blobs(block_root, verified_blobs)
|
||||
}
|
||||
|
||||
/// Put a list of custody columns received via RPC into the availability cache. This performs KZG
|
||||
@@ -238,11 +235,8 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
.map(KzgVerifiedCustodyDataColumn::from_asserted_custody)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
self.availability_cache.put_kzg_verified_data_columns(
|
||||
block_root,
|
||||
verified_custody_columns,
|
||||
&self.log,
|
||||
)
|
||||
self.availability_cache
|
||||
.put_kzg_verified_data_columns(block_root, verified_custody_columns)
|
||||
}
|
||||
|
||||
/// Put a list of blobs received from the EL pool into the availability cache.
|
||||
@@ -262,7 +256,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
block_root,
|
||||
block_epoch,
|
||||
data_columns_recv,
|
||||
&self.log,
|
||||
)
|
||||
} else {
|
||||
let seen_timestamp = self
|
||||
@@ -272,7 +265,6 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
self.availability_cache.put_kzg_verified_blobs(
|
||||
block_root,
|
||||
KzgVerifiedBlobList::from_verified(blobs.iter().flatten().cloned(), seen_timestamp),
|
||||
&self.log,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -286,11 +278,8 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
&self,
|
||||
gossip_blob: GossipVerifiedBlob<T>,
|
||||
) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> {
|
||||
self.availability_cache.put_kzg_verified_blobs(
|
||||
gossip_blob.block_root(),
|
||||
vec![gossip_blob.into_inner()],
|
||||
&self.log,
|
||||
)
|
||||
self.availability_cache
|
||||
.put_kzg_verified_blobs(gossip_blob.block_root(), vec![gossip_blob.into_inner()])
|
||||
}
|
||||
|
||||
/// Check if we've cached other data columns for this block. If it satisfies the custody requirement and we also
|
||||
@@ -309,11 +298,8 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
.map(|c| KzgVerifiedCustodyDataColumn::from_asserted_custody(c.into_inner()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
self.availability_cache.put_kzg_verified_data_columns(
|
||||
block_root,
|
||||
custody_columns,
|
||||
&self.log,
|
||||
)
|
||||
self.availability_cache
|
||||
.put_kzg_verified_data_columns(block_root, custody_columns)
|
||||
}
|
||||
|
||||
/// Check if we have all the blobs for a block. Returns `Availability` which has information
|
||||
@@ -323,7 +309,7 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
executed_block: AvailabilityPendingExecutedBlock<T::EthSpec>,
|
||||
) -> Result<Availability<T::EthSpec>, AvailabilityCheckError> {
|
||||
self.availability_cache
|
||||
.put_pending_executed_block(executed_block, &self.log)
|
||||
.put_pending_executed_block(executed_block)
|
||||
}
|
||||
|
||||
pub fn remove_pending_components(&self, block_root: Hash256) {
|
||||
@@ -563,10 +549,9 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
)
|
||||
.map_err(|e| {
|
||||
error!(
|
||||
self.log,
|
||||
"Error reconstructing data columns";
|
||||
"block_root" => ?block_root,
|
||||
"error" => ?e
|
||||
?block_root,
|
||||
error = ?e,
|
||||
"Error reconstructing data columns"
|
||||
);
|
||||
self.availability_cache
|
||||
.handle_reconstruction_failure(block_root);
|
||||
@@ -601,14 +586,15 @@ impl<T: BeaconChainTypes> DataAvailabilityChecker<T> {
|
||||
data_columns_to_publish.len() as u64,
|
||||
);
|
||||
|
||||
debug!(self.log, "Reconstructed columns";
|
||||
"count" => data_columns_to_publish.len(),
|
||||
"block_root" => ?block_root,
|
||||
"slot" => slot,
|
||||
debug!(
|
||||
count = data_columns_to_publish.len(),
|
||||
?block_root,
|
||||
%slot,
|
||||
"Reconstructed columns"
|
||||
);
|
||||
|
||||
self.availability_cache
|
||||
.put_kzg_verified_data_columns(*block_root, data_columns_to_publish.clone(), &self.log)
|
||||
.put_kzg_verified_data_columns(*block_root, data_columns_to_publish.clone())
|
||||
.map(|availability| {
|
||||
DataColumnReconstructionResult::Success((
|
||||
availability,
|
||||
@@ -635,14 +621,18 @@ pub fn start_availability_cache_maintenance_service<T: BeaconChainTypes>(
|
||||
if chain.spec.deneb_fork_epoch.is_some() {
|
||||
let overflow_cache = chain.data_availability_checker.availability_cache.clone();
|
||||
executor.spawn(
|
||||
async move { availability_cache_maintenance_service(chain, overflow_cache).await },
|
||||
async move {
|
||||
availability_cache_maintenance_service(chain, overflow_cache)
|
||||
.instrument(info_span!(
|
||||
"DataAvailabilityChecker",
|
||||
service = "data_availability_checker"
|
||||
))
|
||||
.await
|
||||
},
|
||||
"availability_cache_service",
|
||||
);
|
||||
} else {
|
||||
debug!(
|
||||
chain.log,
|
||||
"Deneb fork not configured, not starting availability cache maintenance service"
|
||||
);
|
||||
debug!("Deneb fork not configured, not starting availability cache maintenance service");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,10 +656,7 @@ async fn availability_cache_maintenance_service<T: BeaconChainTypes>(
|
||||
break;
|
||||
};
|
||||
|
||||
debug!(
|
||||
chain.log,
|
||||
"Availability cache maintenance service firing";
|
||||
);
|
||||
debug!("Availability cache maintenance service firing");
|
||||
let Some(current_epoch) = chain
|
||||
.slot_clock
|
||||
.now()
|
||||
@@ -699,11 +686,11 @@ async fn availability_cache_maintenance_service<T: BeaconChainTypes>(
|
||||
);
|
||||
|
||||
if let Err(e) = overflow_cache.do_maintenance(cutoff_epoch) {
|
||||
error!(chain.log, "Failed to maintain availability cache"; "error" => ?e);
|
||||
error!(error = ?e,"Failed to maintain availability cache");
|
||||
}
|
||||
}
|
||||
None => {
|
||||
error!(chain.log, "Failed to read slot clock");
|
||||
error!("Failed to read slot clock");
|
||||
// If we can't read the slot clock, just wait another slot.
|
||||
tokio::time::sleep(chain.slot_clock.slot_duration()).await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user