From a1c960b8f2197f5a2b9ab401b497b2721d656243 Mon Sep 17 00:00:00 2001 From: yukang Date: Tue, 16 Jan 2024 10:43:57 +0800 Subject: [PATCH] clean up verify vms --- script/src/verify.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/script/src/verify.rs b/script/src/verify.rs index 7a4b4f6bae..caad36b4bd 100644 --- a/script/src/verify.rs +++ b/script/src/verify.rs @@ -698,7 +698,7 @@ impl, + command_rx: &mut Receiver, ) -> Result { let mut cycles = 0; @@ -1041,7 +1041,7 @@ impl, + command_rx: &mut Receiver, ) -> Result { if group.script.code_hash() == TYPE_ID_CODE_HASH.pack() && Into::::into(group.script.hash_type()) == Into::::into(ScriptHashType::Type) @@ -1145,7 +1145,7 @@ impl, + command_rx: &mut Receiver, ) -> Result { let context: Arc> = Default::default(); @@ -1382,7 +1382,7 @@ fn run_vms( } } -// Run a series of VMs that are just freshly resumed +// Run a series of VMs with control signal, will only return when verification finished async fn run_vms_with_signal( script_group: &ScriptGroup, max_cycles: Cycle, @@ -1409,11 +1409,13 @@ async fn run_vms_with_signal( loop { tokio::select! { _ = signal.changed() => { - let state = signal.borrow().to_owned(); - if state == ChunkCommand::Suspend { - pause.interrupt(); - } else if state == ChunkCommand::Resume { - child_sender.send(ChunkCommand::Resume).unwrap(); + match signal.borrow().to_owned() { + ChunkCommand::Suspend => { + pause.interrupt(); + } + ChunkCommand::Resume => { + child_sender.send(ChunkCommand::Resume).unwrap(); + } } } Some(res) = finished_recv.recv() => { @@ -1500,8 +1502,8 @@ async fn run_vms_child( new_suspended_machines.reverse(); machines.push(machine); machines.append(&mut new_suspended_machines); - // wait for Resume command to begin next loop iteration eprintln!("suspend here: {:?}", machines.len()); + // break to wait for Resume command to begin next loop iteration break; } _ => {