diff --git a/node/bft/src/sync/mod.rs b/node/bft/src/sync/mod.rs index 753e62cbb2..cf01843ed2 100644 --- a/node/bft/src/sync/mod.rs +++ b/node/bft/src/sync/mod.rs @@ -309,17 +309,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. diff --git a/node/bft/src/worker.rs b/node/bft/src/worker.rs index c2fe485ad9..60a256f11b 100644 --- a/node/bft/src/worker.rs +++ b/node/bft/src/worker.rs @@ -15,6 +15,7 @@ use crate::{ events::{Event, TransmissionRequest, TransmissionResponse}, helpers::{fmt_id, max_redundant_requests, Pending, Ready, Storage, WorkerReceiver}, + spawn_blocking, ProposedBatch, Transport, MAX_FETCH_TIMEOUT_IN_MS, @@ -376,7 +377,11 @@ impl Worker { self.spawn(async move { while let Some((peer_ip, transmission_response)) = rx_transmission_response.recv().await { // Process the transmission response. - self_.finish_transmission_request(peer_ip, transmission_response); + let self__ = self_.clone(); + let _ = spawn_blocking!({ + self__.finish_transmission_request(peer_ip, transmission_response); + Ok(()) + }); } }); }