Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(torii): improve log messages #2463

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use tokio::sync::broadcast::Sender;
use tokio::sync::mpsc::Sender as BoundedSender;
use tokio::sync::Semaphore;
use tokio::task::JoinSet;
use tokio::time::sleep;
use tokio::time::{sleep, Instant};
use tracing::{debug, error, info, trace, warn};

use crate::processors::event_message::EventMessageProcessor;
Expand Down Expand Up @@ -171,6 +171,7 @@ impl<P: Provider + Send + Sync + std::fmt::Debug + 'static> Engine<P> {
res = self.fetch_data(head, last_pending_block_world_tx, last_pending_block_tx) => {
match res {
Ok(fetch_result) => {
let instant = Instant::now();
if erroring_out {
erroring_out = false;
backoff_delay = Duration::from_secs(1);
Expand All @@ -188,6 +189,7 @@ impl<P: Provider + Send + Sync + std::fmt::Debug + 'static> Engine<P> {
}
}
}
debug!(target: LOG_TARGET, duration = ?instant.elapsed(), "Processed fetched data.");
}
Err(e) => {
erroring_out = true;
Expand All @@ -210,16 +212,18 @@ impl<P: Provider + Send + Sync + std::fmt::Debug + 'static> Engine<P> {
last_pending_block_world_tx: Option<Felt>,
last_pending_block_tx: Option<Felt>,
) -> Result<FetchDataResult> {
let instant = Instant::now();
let latest_block_number = self.provider.block_hash_and_number().await?.block_number;

let result = if from < latest_block_number {
let from = if from == 0 { from } else { from + 1 };
debug!(target: LOG_TARGET, from = %from, to = %latest_block_number, "Fetching data for range.");
let data =
self.fetch_range(from, latest_block_number, last_pending_block_world_tx).await?;
debug!(target: LOG_TARGET, duration = ?instant.elapsed(), from = %from, to = %latest_block_number, "Fetched data for range.");
FetchDataResult::Range(data)
} else if self.config.index_pending {
let data = self.fetch_pending(latest_block_number + 1, last_pending_block_tx).await?;
debug!(target: LOG_TARGET, duration = ?instant.elapsed(), latest_block_number = %latest_block_number, "Fetched pending data.");
if let Some(data) = data {
FetchDataResult::Pending(data)
} else {
Expand Down
Loading