From 444c7486037b1eb929f5a136bcedf6e4b7dfbec6 Mon Sep 17 00:00:00 2001 From: Alex Ostrovski Date: Fri, 14 Jun 2024 12:57:05 +0300 Subject: [PATCH] Improve log structure --- core/lib/state/src/catchup.rs | 6 +-- .../state_keeper/src/state_keeper_storage.rs | 42 ++++++++----------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/core/lib/state/src/catchup.rs b/core/lib/state/src/catchup.rs index 77ead8973abe..139e10ea19fd 100644 --- a/core/lib/state/src/catchup.rs +++ b/core/lib/state/src/catchup.rs @@ -139,12 +139,10 @@ impl AsyncCatchupTask { /// # Errors /// /// Propagates RocksDB and Postgres errors. + #[tracing::instrument(name = "catch_up", skip_all, fields(target_l1_batch = ?self.to_l1_batch_number))] pub async fn run(self, stop_receiver: watch::Receiver) -> anyhow::Result<()> { let started_at = Instant::now(); - tracing::debug!( - "Catching up RocksDB asynchronously to L1 batch #{:?}", - self.to_l1_batch_number - ); + tracing::info!("Catching up RocksDB asynchronously"); let mut rocksdb_builder = RocksdbStorage::builder_with_options( self.state_keeper_db_path.as_ref(), diff --git a/core/node/state_keeper/src/state_keeper_storage.rs b/core/node/state_keeper/src/state_keeper_storage.rs index 8e9c313b56af..13cedc3a58a8 100644 --- a/core/node/state_keeper/src/state_keeper_storage.rs +++ b/core/node/state_keeper/src/state_keeper_storage.rs @@ -21,7 +21,23 @@ pub struct AsyncRocksdbCache { } impl AsyncRocksdbCache { - async fn access_storage_inner( + pub fn new( + pool: ConnectionPool, + state_keeper_db_path: String, + state_keeper_db_options: RocksdbStorageOptions, + ) -> (Self, AsyncCatchupTask) { + let (task, rocksdb_cell) = AsyncCatchupTask::new(pool.clone(), state_keeper_db_path); + ( + Self { pool, rocksdb_cell }, + task.with_db_options(state_keeper_db_options), + ) + } +} + +#[async_trait] +impl ReadStorageFactory for AsyncRocksdbCache { + #[tracing::instrument(skip(self, stop_receiver))] + async fn access_storage( &self, stop_receiver: &watch::Receiver, l1_batch_number: L1BatchNumber, @@ -63,28 +79,4 @@ impl AsyncRocksdbCache { )) } } - - pub fn new( - pool: ConnectionPool, - state_keeper_db_path: String, - state_keeper_db_options: RocksdbStorageOptions, - ) -> (Self, AsyncCatchupTask) { - let (task, rocksdb_cell) = AsyncCatchupTask::new(pool.clone(), state_keeper_db_path); - ( - Self { pool, rocksdb_cell }, - task.with_db_options(state_keeper_db_options), - ) - } -} - -#[async_trait] -impl ReadStorageFactory for AsyncRocksdbCache { - async fn access_storage( - &self, - stop_receiver: &watch::Receiver, - l1_batch_number: L1BatchNumber, - ) -> anyhow::Result>> { - self.access_storage_inner(stop_receiver, l1_batch_number) - .await - } }