Skip to content

Commit

Permalink
fix tracing targets
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin committed Oct 1, 2024
1 parent 169235d commit 168a4a1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
11 changes: 8 additions & 3 deletions crates/exex/exex/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ impl ExExHandle {
// I.e., the ExEx has already processed the notification.
if finished_height.number >= new.tip().number {
debug!(
target: "exex::manager",
exex_id = %self.id,
%notification_id,
?finished_height,
Expand All @@ -135,6 +136,7 @@ impl ExExHandle {
}

debug!(
target: "exex::manager",
exex_id = %self.id,
%notification_id,
"Reserving slot for notification"
Expand All @@ -145,6 +147,7 @@ impl ExExHandle {
}

debug!(
target: "exex::manager",
exex_id = %self.id,
%notification_id,
"Sending notification"
Expand Down Expand Up @@ -327,7 +330,7 @@ where
/// This function checks if all ExExes are on the canonical chain and finalizes the WAL if
/// necessary.
fn finalize_wal(&self, finalized_header: SealedHeader) -> eyre::Result<()> {
debug!(header = ?finalized_header.num_hash(), "Received finalized header");
debug!(target: "exex::manager", header = ?finalized_header.num_hash(), "Received finalized header");

// Check if all ExExes are on the canonical chain
let exex_finished_heights = self
Expand Down Expand Up @@ -368,6 +371,7 @@ where
f(&format_args!("{exex_id:?} = {num_hash:?}"))
});
debug!(
target: "exex::manager",
%unfinalized_exexes,
"Not all ExExes are on the canonical chain, can't finalize the WAL"
);
Expand Down Expand Up @@ -400,7 +404,7 @@ where
// Handle incoming ExEx events
for exex in &mut this.exex_handles {
while let Poll::Ready(Some(event)) = exex.receiver.poll_recv(cx) {
debug!(exex_id = %exex.id, ?event, "Received event from ExEx");
debug!(target: "exex::manager", exex_id = %exex.id, ?event, "Received event from ExEx");
exex.metrics.events_sent_total.increment(1);
match event {
ExExEvent::FinishedHeight(height) => exex.finished_height = Some(height),
Expand All @@ -421,6 +425,7 @@ where
while this.buffer.len() < this.max_capacity {
if let Poll::Ready(Some(notification)) = this.handle_rx.poll_recv(cx) {
debug!(
target: "exex::manager",
committed_tip = ?notification.committed_chain().map(|chain| chain.tip().number),
reverted_tip = ?notification.reverted_chain().map(|chain| chain.tip().number),
"Received new notification"
Expand Down Expand Up @@ -457,7 +462,7 @@ where
}

// Remove processed buffered notifications
debug!(%min_id, "Updating lowest notification id in buffer");
debug!(target: "exex::manager", %min_id, "Updating lowest notification id in buffer");
this.buffer.retain(|&(id, _)| id >= min_id);
this.min_id = min_id;

Expand Down
6 changes: 3 additions & 3 deletions crates/exex/exex/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,21 @@ where
/// - ExEx is at the same block number as the node head (`node_head.number ==
/// exex_head.number`). Nothing to do.
fn check_backfill(&mut self) -> eyre::Result<()> {
debug!(target: "exex::manager", "Synchronizing ExEx head");
debug!(target: "exex::notifications", "Synchronizing ExEx head");

let backfill_job_factory =
BackfillJobFactory::new(self.executor.clone(), self.provider.clone());
match self.exex_head.block.number.cmp(&self.node_head.number) {
std::cmp::Ordering::Less => {
// ExEx is behind the node head, start backfill
debug!(target: "exex::manager", "ExEx is behind the node head and on the canonical chain, starting backfill");
debug!(target: "exex::notifications", "ExEx is behind the node head and on the canonical chain, starting backfill");
let backfill = backfill_job_factory
.backfill(self.exex_head.block.number + 1..=self.node_head.number)
.into_stream();
self.backfill_job = Some(backfill);
}
std::cmp::Ordering::Equal => {
debug!(target: "exex::manager", "ExEx is at the node head");
debug!(target: "exex::notifications", "ExEx is at the node head");
}
std::cmp::Ordering::Greater => {
return Err(eyre::eyre!("ExEx is ahead of the node head"))
Expand Down
12 changes: 6 additions & 6 deletions crates/exex/exex/src/wal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl WalInner {
}

/// Fills the block cache with the notifications from the storage.
#[instrument(target = "exex::wal", skip(self))]
#[instrument(skip(self))]
fn fill_block_cache(&mut self) -> eyre::Result<()> {
let Some(files_range) = self.storage.files_range()? else { return Ok(()) };
self.next_file_id.store(files_range.end() + 1, Ordering::Relaxed);
Expand All @@ -119,7 +119,7 @@ impl WalInner {
Ok(())
}

#[instrument(target = "exex::wal", skip_all, fields(
#[instrument(skip_all, fields(
reverted_block_range = ?notification.reverted_chain().as_ref().map(|chain| chain.range()),
committed_block_range = ?notification.committed_chain().as_ref().map(|chain| chain.range())
))]
Expand All @@ -129,24 +129,24 @@ impl WalInner {
let file_id = self.next_file_id.fetch_add(1, Ordering::Relaxed);
self.storage.write_notification(file_id, notification)?;

debug!(?file_id, "Inserting notification blocks into the block cache");
debug!(target: "exex::wal", ?file_id, "Inserting notification blocks into the block cache");
block_cache.insert_notification_blocks_with_file_id(file_id, notification);

Ok(())
}

#[instrument(target = "exex::wal", skip(self))]
#[instrument(skip(self))]
fn finalize(&self, to_block: BlockNumHash) -> eyre::Result<()> {
let file_ids = self.block_cache.write().remove_before(to_block.number);

// Remove notifications from the storage.
if file_ids.is_empty() {
debug!("No notifications were finalized from the storage");
debug!(target: "exex::wal", "No notifications were finalized from the storage");
return Ok(())
}

let removed_notifications = self.storage.remove_notifications(file_ids)?;
debug!(?removed_notifications, "Storage was finalized");
debug!(target: "exex::wal", ?removed_notifications, "Storage was finalized");

Ok(())
}
Expand Down
14 changes: 7 additions & 7 deletions crates/exex/exex/src/wal/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ impl Storage {
}

/// Removes notification for the given file ID from the storage.
#[instrument(target = "exex::wal::storage", skip(self))]
#[instrument(skip(self))]
fn remove_notification(&self, file_id: u32) -> bool {
match reth_fs_util::remove_file(self.file_path(file_id)) {
Ok(()) => {
debug!("Notification was removed from the storage");
debug!(target: "exex::wal::storage", "Notification was removed from the storage");
true
}
Err(err) => {
debug!(?err, "Failed to remove notification from the storage");
debug!(target: "exex::wal::storage", ?err, "Failed to remove notification from the storage");
false
}
}
Expand Down Expand Up @@ -105,10 +105,10 @@ impl Storage {
}

/// Reads the notification from the file with the given ID.
#[instrument(target = "exex::wal::storage", skip(self))]
#[instrument(skip(self))]
pub(super) fn read_notification(&self, file_id: u32) -> eyre::Result<Option<ExExNotification>> {
let file_path = self.file_path(file_id);
debug!(?file_path, "Reading notification from WAL");
debug!(target: "exex::wal::storage", ?file_path, "Reading notification from WAL");

let mut file = match File::open(&file_path) {
Ok(file) => file,
Expand All @@ -127,14 +127,14 @@ impl Storage {
}

/// Writes the notification to the file with the given ID.
#[instrument(target = "exex::wal::storage", skip(self, notification))]
#[instrument(skip(self, notification))]
pub(super) fn write_notification(
&self,
file_id: u32,
notification: &ExExNotification,
) -> eyre::Result<()> {
let file_path = self.file_path(file_id);
debug!(?file_path, "Writing notification to WAL");
debug!(target: "exex::wal::storage", ?file_path, "Writing notification to WAL");

// Serialize using the bincode- and msgpack-compatible serde wrapper
let notification =
Expand Down

0 comments on commit 168a4a1

Please sign in to comment.