From 3afd71614c10cee6715f3def1f9627ecfc9392b7 Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Fri, 17 Jan 2025 07:36:36 -0600 Subject: [PATCH] fix: replaying transactions fixed (#544) --- crates/cli/src/main.rs | 11 ++++++++--- crates/core/src/node/in_memory.rs | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index cb1d7f80..c4480b11 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -268,6 +268,14 @@ async fn main() -> anyhow::Result<()> { storage_key_layout, ); + // We start the node executor now so it can receive and handle commands + // during replay. Otherwise, replay would send commands and hang. + tokio::spawn(async move { + if let Err(err) = node_executor.run().await { + tracing::error!("node executor ended with error: {:?}", err); + } + }); + if let Some(ref bytecodes_dir) = config.override_bytecodes_dir { override_bytecodes(&node, bytecodes_dir.to_string()) .await @@ -391,9 +399,6 @@ async fn main() -> anyhow::Result<()> { _ = any_server_stopped => { tracing::trace!("node server was stopped") }, - _ = node_executor.run() => { - tracing::trace!("node executor was stopped") - }, _ = block_sealer.run() => { tracing::trace!("block sealer was stopped") }, diff --git a/crates/core/src/node/in_memory.rs b/crates/core/src/node/in_memory.rs index 0e3d94cf..b9fa6782 100644 --- a/crates/core/src/node/in_memory.rs +++ b/crates/core/src/node/in_memory.rs @@ -337,12 +337,12 @@ impl InMemoryNode { .iter() .map(|tx| tx.hash()) .collect::>(); - let block_numer = self.node_handle.seal_block_sync(tx_batch).await?; + let block_number = self.node_handle.seal_block_sync(tx_batch).await?; // Fetch the block that was just sealed let block = self .blockchain - .get_block_by_number(block_numer) + .get_block_by_number(block_number) .await .expect("freshly sealed block could not be found in storage");