diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 153e6556b3..608e152417 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -325,17 +325,21 @@ impl Sync { // Acquire the sync lock. let _lock = self.sync_lock.lock().await; - // Check the next block. - self.ledger.check_next_block(&block)?; - // Attempt to advance to the next block. - self.ledger.advance_to_next_block(&block)?; - - // Sync the height with the block. - self.storage.sync_height_with_block(block.height()); - // Sync the round with the block. - self.storage.sync_round_with_block(block.round()); - - Ok(()) + let self_ = self.clone(); + tokio::task::spawn_blocking(move || { + // Check the next block. + self_.ledger.check_next_block(&block)?; + // Attempt to advance to the next block. + self_.ledger.advance_to_next_block(&block)?; + + // Sync the height with the block. + self_.storage.sync_height_with_block(block.height()); + // Sync the round with the block. + self_.storage.sync_round_with_block(block.round()); + + Ok(()) + }) + .await? } /// Syncs the storage with the given blocks.