diff --git a/crates/blockifier/src/blockifier/stateful_validator.rs b/crates/blockifier/src/blockifier/stateful_validator.rs index 5dbba123a9..f7b3394411 100644 --- a/crates/blockifier/src/blockifier/stateful_validator.rs +++ b/crates/blockifier/src/blockifier/stateful_validator.rs @@ -134,7 +134,10 @@ impl StatefulValidator { .expect(BLOCK_STATE_ACCESS_ERR) .get_actual_state_changes()?, &execution_resources, - CallInfo::summarize_many(validate_call_info.iter()), + CallInfo::summarize_many( + validate_call_info.iter(), + &tx_context.block_context.versioned_constants, + ), 0, ); diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 224fb95387..16dcefb6b9 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -113,7 +113,7 @@ impl TransactionExecutor { self.bouncer.try_update( &transactional_state, &tx_state_changes_keys, - &tx_execution_info.summarize(), + &tx_execution_info.summarize(&self.block_context.versioned_constants), &tx_execution_info.receipt.resources, )?; transactional_state.commit(); diff --git a/crates/blockifier/src/concurrency/worker_logic.rs b/crates/blockifier/src/concurrency/worker_logic.rs index eb26f2a26e..2d8a00a339 100644 --- a/crates/blockifier/src/concurrency/worker_logic.rs +++ b/crates/blockifier/src/concurrency/worker_logic.rs @@ -250,7 +250,7 @@ impl<'a, S: StateReader> WorkerExecutor<'a, S> { let bouncer_result = self.bouncer.lock().expect("Bouncer lock failed.").try_update( &tx_versioned_state, &tx_state_changes_keys, - &tx_execution_info.summarize(), + &tx_execution_info.summarize(&self.block_context.versioned_constants), &tx_execution_info.receipt.resources, ); if let Err(error) = bouncer_result { diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index def7dcf476..e696c6c54b 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -14,6 +14,7 @@ use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::CallEntryPoint; use crate::state::cached_state::StorageEntry; use crate::utils::u64_from_usize; +use crate::versioned_constants::VersionedConstants; #[cfg_attr(feature = "transaction_serde", derive(serde::Deserialize))] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] @@ -146,7 +147,7 @@ impl CallInfo { event_summary } - pub fn summarize(&self) -> ExecutionSummary { + pub fn summarize(&self, _versioned_constants: &VersionedConstants) -> ExecutionSummary { let mut executed_class_hashes: HashSet = HashSet::new(); let mut visited_storage_entries: HashSet = HashSet::new(); let mut event_summary = EventSummary::default(); @@ -186,8 +187,11 @@ impl CallInfo { } } - pub fn summarize_many<'a>(call_infos: impl Iterator) -> ExecutionSummary { - call_infos.map(|call_info| call_info.summarize()).sum() + pub fn summarize_many<'a>( + call_infos: impl Iterator, + versioned_constants: &VersionedConstants, + ) -> ExecutionSummary { + call_infos.map(|call_info| call_info.summarize(versioned_constants)).sum() } } diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index 153062234f..4564dde2ce 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -69,7 +69,8 @@ fn starknet_resources() -> StarknetResources { .into_iter() .map(|call_info| call_info.with_some_class_hash()) .collect(); - let execution_summary = CallInfo::summarize_many(call_infos.iter()); + let execution_summary = + CallInfo::summarize_many(call_infos.iter(), &VersionedConstants::latest_constants()); let state_resources = StateResources::new_for_testing(StateChangesCount { n_storage_updates: 7, n_class_hash_updates: 11, @@ -95,7 +96,7 @@ fn test_get_event_gas_cost( .into_iter() .map(|call_info| call_info.with_some_class_hash()) .collect(); - let execution_summary = CallInfo::summarize_many(call_infos.iter()); + let execution_summary = CallInfo::summarize_many(call_infos.iter(), versioned_constants); let starknet_resources = StarknetResources::new(0, 0, 0, StateResources::default(), None, execution_summary); assert_eq!( @@ -142,7 +143,7 @@ fn test_get_event_gas_cost( .into_iter() .map(|call_info| call_info.with_some_class_hash()) .collect(); - let execution_summary = CallInfo::summarize_many(call_infos.iter()); + let execution_summary = CallInfo::summarize_many(call_infos.iter(), versioned_constants); // 8 keys and 11 data words overall. let expected_gas = (data_word_cost * (event_key_factor * 8_u64 + 11_u64)).to_integer().into(); let expected_gas_vector = match gas_vector_computation_mode { diff --git a/crates/blockifier/src/fee/receipt_test.rs b/crates/blockifier/src/fee/receipt_test.rs index 95c315918b..df732f6ace 100644 --- a/crates/blockifier/src/fee/receipt_test.rs +++ b/crates/blockifier/src/fee/receipt_test.rs @@ -217,7 +217,7 @@ fn test_calculate_tx_gas_usage_basic<'a>( call_infos.push(call_info); } - let execution_summary = CallInfo::summarize_many(call_infos.iter()); + let execution_summary = CallInfo::summarize_many(call_infos.iter(), &versioned_constants); let l2_to_l1_state_changes_count = StateChangesCount { n_storage_updates: 0, @@ -432,7 +432,8 @@ fn test_calculate_tx_gas_usage( }; let execution_call_info = &tx_execution_info.execute_call_info.expect("Execution call info should exist."); - let execution_summary = CallInfo::summarize_many(vec![execution_call_info].into_iter()); + let execution_summary = + CallInfo::summarize_many(vec![execution_call_info].into_iter(), &versioned_constants); let starknet_resources = StarknetResources::new( calldata_length, signature_length, diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index bc2ab3ecec..4ece95b78b 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -605,7 +605,10 @@ impl AccountTransaction { &tx_context, &state.get_actual_state_changes()?, &resources, - CallInfo::summarize_many(validate_call_info.iter().chain(execute_call_info.iter())), + CallInfo::summarize_many( + validate_call_info.iter().chain(execute_call_info.iter()), + &tx_context.block_context.versioned_constants, + ), 0, ); @@ -672,7 +675,10 @@ impl AccountTransaction { &tx_context, &validate_state_changes, &resources, - CallInfo::summarize_many(validate_call_info.iter()), + CallInfo::summarize_many( + validate_call_info.iter(), + &tx_context.block_context.versioned_constants, + ), execution_steps_consumed, ); @@ -690,6 +696,7 @@ impl AccountTransaction { &execution_resources, CallInfo::summarize_many( validate_call_info.iter().chain(execute_call_info.iter()), + &tx_context.block_context.versioned_constants, ), 0, ); diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index c1032eb7e3..06e0e89835 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -32,6 +32,7 @@ use crate::fee::fee_checks::FeeCheckError; use crate::fee::fee_utils::get_fee_by_gas_vector; use crate::fee::receipt::TransactionReceipt; use crate::transaction::errors::{TransactionExecutionError, TransactionPreValidationError}; +use crate::versioned_constants::VersionedConstants; #[cfg(test)] #[path = "objects_test.rs"] @@ -225,8 +226,8 @@ impl TransactionExecutionInfo { /// Returns a summary of transaction execution, including executed class hashes, visited storage /// entries, L2-to-L1_payload_lengths, and the number of emitted events. - pub fn summarize(&self) -> ExecutionSummary { - CallInfo::summarize_many(self.non_optional_call_infos()) + pub fn summarize(&self, versioned_constants: &VersionedConstants) -> ExecutionSummary { + CallInfo::summarize_many(self.non_optional_call_infos(), versioned_constants) } } pub trait ExecutionResourcesTraits { diff --git a/crates/blockifier/src/transaction/objects_test.rs b/crates/blockifier/src/transaction/objects_test.rs index 22a4d8643a..c1c339227c 100644 --- a/crates/blockifier/src/transaction/objects_test.rs +++ b/crates/blockifier/src/transaction/objects_test.rs @@ -16,6 +16,7 @@ use crate::execution::call_info::{ }; use crate::execution::entry_point::CallEntryPoint; use crate::transaction::objects::TransactionExecutionInfo; +use crate::versioned_constants::VersionedConstants; #[derive(Debug, Default)] pub struct TestExecutionSummary { @@ -129,7 +130,7 @@ fn test_events_counter_in_tx_execution_info( }; assert_eq!( - tx_execution_info.summarize().event_summary.n_events, + tx_execution_info.summarize(&VersionedConstants::latest_constants()).event_summary.n_events, n_validate_events + n_execute_events + n_fee_transfer_events + n_inner_calls ); } @@ -158,7 +159,7 @@ fn test_events_counter_in_tx_execution_info_with_inner_call_info(#[case] n_execu }; assert_eq!( - tx_execution_info.summarize().event_summary.n_events, + tx_execution_info.summarize(&VersionedConstants::latest_constants()).event_summary.n_events, n_execute_events + n_fee_transfer_events + n_execution_events @@ -220,7 +221,7 @@ fn test_summarize( }; // Call the summarize method - let actual_summary = tx_execution_info.summarize(); + let actual_summary = tx_execution_info.summarize(&VersionedConstants::latest_constants()); // Compare the actual result with the expected result assert_eq!(actual_summary.executed_class_hashes, expected_summary.executed_class_hashes); diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index e077370b86..11856201f3 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -162,7 +162,7 @@ impl ExecutableTransaction for L1HandlerTransaction { } = TransactionReceipt::from_l1_handler( &tx_context, l1_handler_payload_size, - CallInfo::summarize_many(execute_call_info.iter()), + CallInfo::summarize_many(execute_call_info.iter(), &block_context.versioned_constants), &state.get_actual_state_changes()?, &execution_resources, ); @@ -209,7 +209,7 @@ impl ExecutableTransaction for Transaction { // Check if the transaction is too large to fit any block. // TODO(Yoni, 1/8/2024): consider caching these two. - let tx_execution_summary = tx_execution_info.summarize(); + let tx_execution_summary = tx_execution_info.summarize(&block_context.versioned_constants); let mut tx_state_changes_keys = state.get_actual_state_changes()?.into_keys(); tx_state_changes_keys.update_sequencer_key_in_storage( &block_context.to_tx_context(self),