Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions crates/blockifier/src/execution/call_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,12 +517,7 @@ impl CallInfo {
executed_class_hashes.insert(class_hash);

// Storage entries.
let call_storage_entries = call_info
.storage_access_tracker
.accessed_storage_keys
.iter()
.map(|storage_key| (call_info.call.storage_address, *storage_key));
visited_storage_entries.extend(call_storage_entries);
visited_storage_entries.extend(call_info.get_visited_storage_entries());

// Messages.
l2_to_l1_payload_lengths.extend(
Expand Down Expand Up @@ -582,6 +577,14 @@ impl CallInfo {
})
}

pub fn get_visited_storage_entries(&self) -> impl Iterator<Item = StorageEntry> + '_ {
let storage_address = self.call.storage_address;
self.storage_access_tracker
.accessed_storage_keys
.iter()
.map(move |key| (storage_address, *key))
}

/// Returns a vector of Starknet Event objects collected during the execution, sorted by the
/// order in which they were emitted.
pub fn get_sorted_events(&self) -> Vec<Event> {
Expand Down
24 changes: 23 additions & 1 deletion crates/blockifier/src/transaction/objects.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
use std::collections::HashSet;

use cairo_vm::types::builtin_name::BuiltinName;
use cairo_vm::vm::runners::cairo_runner::ExecutionResources;
use starknet_api::block::{BlockInfo, FeeType};
use starknet_api::block_hash::block_hash_calculator::TransactionOutputForHash;
use starknet_api::core::{ContractAddress, Nonce};
use starknet_api::core::{ContractAddress, Nonce, BLOCK_HASH_TABLE_ADDRESS};
use starknet_api::data_availability::DataAvailabilityMode;
use starknet_api::execution_resources::GasVector;
use starknet_api::state::StorageKey;
use starknet_api::transaction::constants::VALIDATE_DEPLOY_ENTRY_POINT_SELECTOR;
use starknet_api::transaction::fields::{
AccountDeploymentData,
Expand Down Expand Up @@ -42,6 +45,7 @@ use crate::execution::stack_trace::ErrorStack;
use crate::fee::fee_checks::FeeCheckError;
use crate::fee::fee_utils::get_fee_by_gas_vector;
use crate::fee::receipt::TransactionReceipt;
use crate::state::cached_state::StorageEntry;
use crate::transaction::errors::{TransactionExecutionError, TransactionPreValidationError};
use crate::utils::add_maps;

Expand Down Expand Up @@ -267,6 +271,24 @@ impl TransactionExecutionInfo {
CallInfo::summarize_many(self.non_optional_call_infos(), versioned_constants)
}

/// Returns the set of storage entries (contract_address, key) visited by this transaction.
/// Mirrors the Python `TransactionExecutionInfo.get_visited_storage_entries`.
///
/// Includes (BLOCK_HASH_TABLE_ADDRESS, block_number) entries for each block whose hash was read
/// via `get_block_hash`.
pub fn get_visited_storage_entries(&self) -> HashSet<StorageEntry> {
self.non_optional_call_infos()
.flat_map(|call_info| call_info.iter())
.flat_map(|call_info| {
let block_hash_entries =
call_info.storage_access_tracker.accessed_blocks.iter().map(|block_number| {
(BLOCK_HASH_TABLE_ADDRESS, StorageKey::from(block_number.0))
});
call_info.get_visited_storage_entries().chain(block_hash_entries)
})
.collect()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New public method has no callers in codebase

Low Severity

TransactionExecutionInfo::get_visited_storage_entries is a newly added pub method with zero callers anywhere in the codebase. A grep for all usages of get_visited_storage_entries shows that the only call sites invoke the CallInfo method, not this TransactionExecutionInfo method. The associated imports (HashSet, BLOCK_HASH_TABLE_ADDRESS, StorageKey, StorageEntry) are also only needed for this unused function.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2160a0b. Configure here.


pub fn summarize_builtins(&self) -> CairoPrimitiveCounterMap {
let mut builtin_counters = CairoPrimitiveCounterMap::new();
// Remove fee transfer builtins to avoid double-counting in `get_tx_weights`
Expand Down
Loading