From 565271dd043b6371c1fc2e4edce0754a3058c1bb Mon Sep 17 00:00:00 2001 From: Daniil Polyakov Date: Tue, 16 Jan 2024 19:02:57 +0300 Subject: [PATCH] [fix] #4211: Fix async blocking bug when starting Sumeragi Signed-off-by: Daniil Polyakov --- cli/src/lib.rs | 10 +++++++--- core/src/query/store.rs | 3 +++ core/src/sumeragi/mod.rs | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 47e6faf5a7b..18ceae7caac 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -251,9 +251,9 @@ impl Iroha { let kura_thread_handler = Kura::start(Arc::clone(&kura)); - let sumeragi = SumeragiHandle::start(SumeragiStartArgs { + let start_args = SumeragiStartArgs { chain_id: config.chain_id.clone(), - configuration: &config.sumeragi, + configuration: config.sumeragi.clone(), events_sender: events_sender.clone(), wsv, queue: Arc::clone(&queue), @@ -261,7 +261,11 @@ impl Iroha { network: network.clone(), genesis_network: genesis, block_count, - }); + }; + // Starting Sumeragi requires no async context enabled + let sumeragi = tokio::task::spawn_blocking(move || SumeragiHandle::start(start_args)) + .await + .expect("Failed to join task with Sumeragi start"); let block_sync = BlockSynchronizer::from_configuration( &config.block_sync, diff --git a/core/src/query/store.rs b/core/src/query/store.rs index ae1957da793..8e8c83c0687 100644 --- a/core/src/query/store.rs +++ b/core/src/query/store.rs @@ -16,6 +16,7 @@ use iroha_data_model::{ }, BatchedResponse, BatchedResponseV1, HasMetadata, IdentifiableBox, ValidationFail, Value, }; +use iroha_logger::trace; use parity_scale_codec::{Decode, Encode}; use serde::{Deserialize, Serialize}; use tokio::sync::{mpsc, oneshot}; @@ -220,12 +221,14 @@ impl LiveQueryStoreHandle { } fn insert(&self, query_id: QueryId, live_query: LiveQuery) -> Result<()> { + trace!(%query_id, "Inserting"); self.message_sender .blocking_send(Message::Insert(query_id, live_query)) .map_err(|_| Error::ConnectionClosed) } fn remove(&self, query_id: QueryId) -> Result> { + trace!(%query_id, "Removing"); let (sender, receiver) = oneshot::channel(); self.message_sender diff --git a/core/src/sumeragi/mod.rs b/core/src/sumeragi/mod.rs index 883636b6c59..c939e89bac1 100644 --- a/core/src/sumeragi/mod.rs +++ b/core/src/sumeragi/mod.rs @@ -420,9 +420,9 @@ impl VotingBlock { /// Arguments for [`SumeragiHandle::start`] function #[allow(missing_docs)] -pub struct SumeragiStartArgs<'args> { +pub struct SumeragiStartArgs { pub chain_id: ChainId, - pub configuration: &'args Configuration, + pub configuration: Box, pub events_sender: EventsSender, pub wsv: WorldStateView, pub queue: Arc,