Skip to content

Commit 4819415

Browse files
committed
stop the execution loop before stopping the node
1 parent db9c4cb commit 4819415

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

networks/movement/movement-full-node/src/node/manager.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ impl Manager {
5252
.await
5353
.context("Failed to create the executor")?;
5454

55-
let join_handle = tokio::spawn(node.run(mempool_commit_tx_receiver));
56-
57-
// Use tokio::select! to wait for either the handle or a cancellation signal
58-
tokio::select! {
59-
_ = stop_rx.changed() =>(),
60-
// manage Movement node execution return.
61-
res = join_handle => {
62-
res??;
63-
},
64-
};
55+
let join_handle = tokio::spawn(node.run(mempool_commit_tx_receiver, stop_rx));
56+
join_handle.await??;
57+
// // Use tokio::select! to wait for either the handle or a cancellation signal
58+
// tokio::select! {
59+
// _ = stop_rx.changed() =>(),
60+
// // manage Movement node execution return.
61+
// res = join_handle => {
62+
// res??;
63+
// },
64+
// };
6565

6666
Ok(())
6767
}

networks/movement/movement-full-node/src/node/partial.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ where
3939
pub async fn run(
4040
self,
4141
mempool_commit_tx_receiver: UnboundedReceiver<Vec<TxExecutionResult>>,
42+
stop_rx: tokio::sync::watch::Receiver<()>,
4243
) -> Result<(), anyhow::Error> {
4344
let (context, exec_background) = self
4445
.executor
@@ -89,6 +90,7 @@ where
8990
self.config.da_db.allow_sync_from_zero,
9091
propagate_execution_state,
9192
&da_signer,
93+
stop_rx,
9294
)
9395
.await
9496
}

networks/movement/movement-full-node/src/node/tasks/execute_settle.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ where
7171
allow_sync_from_zero: bool,
7272
propagate_execution_state: bool,
7373
da_batch_signer: &SignerIdentifier,
74+
mut stop_rx: tokio::sync::watch::Receiver<()>,
7475
) -> anyhow::Result<()> {
7576
let synced_height = self.da_db.get_synced_height()?;
7677
// Sync Da from 0 is rejected by default. Only if forced it's allowed.
@@ -163,6 +164,8 @@ where
163164
tracing::error!("Da client stream channel timeout because it's idle. Exit");
164165
break;
165166
}
167+
// Stop the node. No block are executing at this point.
168+
_ = stop_rx.changed() => break,
166169
else => break,
167170
}
168171
}

0 commit comments

Comments
 (0)