From 5b0e33ca799806c4ee723c6ac3fc767f07507ea1 Mon Sep 17 00:00:00 2001 From: dorimedini-starkware Date: Tue, 19 Nov 2024 14:53:15 +0200 Subject: [PATCH] refactor(blockifier): move logic to function (#2121) --- crates/blockifier/src/execution/call_info.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index d67271d23d..e6f8d84693 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -157,6 +157,16 @@ impl CallInfo { CallInfoIter { call_infos } } + fn specific_event_summary(&self) -> EventSummary { + let mut event_summary = + EventSummary { n_events: self.execution.events.len(), ..Default::default() }; + for OrderedEvent { event, .. } in self.execution.events.iter() { + event_summary.total_event_data_size += u64_from_usize(event.data.0.len()); + event_summary.total_event_keys += u64_from_usize(event.keys.len()); + } + event_summary + } + pub fn summarize(&self) -> ExecutionSummary { let mut executed_class_hashes: HashSet = HashSet::new(); let mut visited_storage_entries: HashSet = HashSet::new(); @@ -186,14 +196,7 @@ impl CallInfo { ); // Events. - event_summary.n_events += call_info.execution.events.len(); - for OrderedEvent { event, .. } in call_info.execution.events.iter() { - // TODO(barak: 18/03/2024): Once we start charging per byte - // change to num_bytes_keys - // and num_bytes_data. - event_summary.total_event_data_size += u64_from_usize(event.data.0.len()); - event_summary.total_event_keys += u64_from_usize(event.keys.len()); - } + event_summary += call_info.specific_event_summary(); } ExecutionSummary {