Skip to content

Commit

Permalink
refactor(blockifier): move logic to function (#2121)
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimedini-starkware authored Nov 19, 2024
1 parent b652ffa commit 5b0e33c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions crates/blockifier/src/execution/call_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClassHash> = HashSet::new();
let mut visited_storage_entries: HashSet<StorageEntry> = HashSet::new();
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5b0e33c

Please sign in to comment.