From 74ee2ab1da714d98bfec46332bd43dd285d0eba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Gonz=C3=A1lez=20Calder=C3=B3n?= Date: Fri, 6 Dec 2024 16:20:06 -0300 Subject: [PATCH] Handle time zero bug --- replay/src/benchmark.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/replay/src/benchmark.rs b/replay/src/benchmark.rs index 4986e5e..4537be1 100644 --- a/replay/src/benchmark.rs +++ b/replay/src/benchmark.rs @@ -135,16 +135,22 @@ fn get_class_executions(call: CallInfo) -> Vec { // class hash can initially be None, but it is always added before execution let class_hash = call.call.class_hash.unwrap(); - let mut time = call.time; + let mut inner_time = Duration::ZERO; + let mut classes = call .inner_calls .into_iter() .flat_map(|call| { - time -= call.time; + inner_time += call.time; get_class_executions(call) }) .collect::>(); + if call.time.is_zero() { + panic!("contract time should never be zero, there is a bug somewhere") + } + let time = call.time - inner_time; + let top_class = ClassExecutionInfo { class_hash, selector: call.call.entry_point_selector,