Skip to content

Commit

Permalink
[fix] hyperledger-iroha#4211: Fix async blocking bug when starting Su…
Browse files Browse the repository at this point in the history
…meragi

Signed-off-by: Daniil Polyakov <arjentix@gmail.com>
  • Loading branch information
Arjentix committed Jan 18, 2024
1 parent cd4d6f1 commit 565271d
Showing 3 changed files with 12 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -251,17 +251,21 @@ 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),
kura: Arc::clone(&kura),
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,
3 changes: 3 additions & 0 deletions core/src/query/store.rs
Original file line number Diff line number Diff line change
@@ -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<Option<LiveQuery>> {
trace!(%query_id, "Removing");
let (sender, receiver) = oneshot::channel();

self.message_sender
4 changes: 2 additions & 2 deletions core/src/sumeragi/mod.rs
Original file line number Diff line number Diff line change
@@ -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<Configuration>,
pub events_sender: EventsSender,
pub wsv: WorldStateView,
pub queue: Arc<Queue>,

0 comments on commit 565271d

Please sign in to comment.