Skip to content

Commit 6cbd20d

Browse files
committed
put finalized_block fix behind #[cfg(feature = test-utils)]
1 parent b503a8e commit 6cbd20d

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

crates/watcher/src/lib.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ where
317317
if self.is_synced {
318318
tokio::time::sleep(SLOW_SYNC_INTERVAL).await;
319319
} else if self.current_block_number == self.l1_state.head {
320-
// if we have synced to the head of the L1, notify the channel and set the
321-
// `is_synced`` flag.
320+
// if we have synced to the head of the L1, notify the channel and set the `is_synced`` flag.
322321
#[cfg(feature = "test-utils")]
323322
let should_skip = self.test_mode_skip_synced_notification;
324323
#[cfg(not(feature = "test-utils"))]
@@ -815,24 +814,31 @@ where
815814

816815
/// Returns the finalized L1 block.
817816
async fn finalized_block(&self) -> L1WatcherResult<Block> {
818-
// We do not use BlockNumberOrTag::Finalized because because there is an issue with Anvil.
819-
// See https://github.com/foundry-rs/foundry/issues/12645.
820-
// Ok(self
821-
// .execution_provider
822-
// .get_block(BlockNumberOrTag::Finalized.into())
823-
// .await?
824-
// .expect("finalized block should always exist"))
825-
let block = self
826-
.execution_provider
827-
.get_block(BlockNumberOrTag::Finalized.into())
828-
.await?
829-
.expect("finalized block should always exist");
817+
#[cfg(not(feature = "test-utils"))]
818+
{
819+
Ok(self
820+
.execution_provider
821+
.get_block(BlockNumberOrTag::Finalized.into())
822+
.await?
823+
.expect("finalized block should always exist"))
824+
}
830825

831-
Ok(self
832-
.execution_provider
833-
.get_block(block.number().into())
834-
.await?
835-
.expect("finalized block should always exist"))
826+
#[cfg(feature = "test-utils")]
827+
{
828+
// We do not use BlockNumberOrTag::Finalized directly because there is an issue with Anvil.
829+
// See https://github.com/foundry-rs/foundry/issues/12645.
830+
let block = self
831+
.execution_provider
832+
.get_block(BlockNumberOrTag::Finalized.into())
833+
.await?
834+
.expect("finalized block should always exist");
835+
836+
Ok(self
837+
.execution_provider
838+
.get_block(block.number().into())
839+
.await?
840+
.expect("finalized block should always exist"))
841+
}
836842
}
837843

838844
/// Returns the next range of logs, for the block range in

0 commit comments

Comments
 (0)