Skip to content

Commit

Permalink
refactor(blockifier): move logic to function
Browse files Browse the repository at this point in the history
  • Loading branch information
dorimedini-starkware committed Nov 18, 2024
1 parent e97d2d4 commit 65e10b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -136,6 +136,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 @@ -165,14 +175,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 65e10b3

Please sign in to comment.