diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index b9798381e4..b506d364e5 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -1,6 +1,5 @@ use std::collections::{HashMap, HashSet}; use std::sync::Arc; -use std::vec::IntoIter; use cairo_vm::vm::runners::builtin_runner::HASH_BUILTIN_NAME; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; @@ -8,10 +7,11 @@ use starknet_api::core::ClassHash; use thiserror::Error; use crate::blockifier::bouncer::BouncerInfo; +use crate::bouncer::calculate_message_l1_resources; use crate::context::BlockContext; -use crate::execution::call_info::{CallInfo, MessageL1CostInfo}; +use crate::execution::call_info::CallInfo; use crate::fee::actual_cost::ActualCost; -use crate::fee::gas_usage::{get_messages_gas_usage, get_onchain_data_segment_length}; +use crate::fee::gas_usage::get_onchain_data_segment_length; use crate::state::cached_state::{ CachedState, CommitmentStateDiff, StagedTransactionalState, StateChangesKeys, StorageEntry, TransactionalState, @@ -104,18 +104,10 @@ impl TransactionExecutor { let tx_execution_summary = tx_execution_info.summarize(); // Count message to L1 resources. - let call_infos: IntoIter<&CallInfo> = - [&tx_execution_info.validate_call_info, &tx_execution_info.execute_call_info] - .iter() - .filter_map(|&call_info| call_info.as_ref()) - .collect::>() - .into_iter(); - - let message_cost_info = - MessageL1CostInfo::calculate(call_infos, l1_handler_payload_size)?; - - let starknet_gas_usage = - get_messages_gas_usage(&message_cost_info, l1_handler_payload_size); + let (message_segment_length, gas_usage) = calculate_message_l1_resources( + &tx_execution_summary.l2_to_l1_payload_lengths, + l1_handler_payload_size, + ); // Count additional OS resources. let mut additional_os_resources = get_casm_hash_calculation_resources( @@ -142,9 +134,9 @@ impl TransactionExecutor { // Finalize counting logic. let bouncer_info = BouncerInfo::calculate( &tx_execution_info.bouncer_resources, - starknet_gas_usage, + gas_usage, additional_os_resources, - message_cost_info.message_segment_length, + message_segment_length, state_diff_size, tx_execution_summary.n_events, )?; @@ -189,7 +181,7 @@ impl TransactionExecutor { )?; let (actual_cost, _bouncer_resources) = account_tx - .to_actual_cost_builder(tx_context)? + .to_actual_cost_builder(tx_context) .with_validate_call_info(&validate_call_info) .try_add_state_changes(&mut self.state)? .build(&execution_resources)?; diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index d016f221c5..20d86be1a3 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -4,9 +4,11 @@ use serde::Deserialize; use starknet_api::core::ClassHash; use crate::blockifier::transaction_executor::TransactionExecutorResult; +use crate::execution::call_info::{ExecutionSummary, MessageL1CostInfo}; +use crate::fee::gas_usage::{get_message_segment_length, get_messages_gas_usage}; use crate::state::cached_state::{StateChangesKeys, StorageEntry, TransactionalState}; use crate::state::state_api::StateReader; -use crate::transaction::objects::TransactionExecutionInfo; +use crate::transaction::objects::GasVector; #[cfg(test)] #[path = "bouncer_test.rs"] @@ -112,14 +114,15 @@ impl TransactionalBouncer { pub fn update_auxiliary_info( &mut self, - tx_execution_info: &TransactionExecutionInfo, + tx_execution_summary: &ExecutionSummary, state: &mut TransactionalState<'_, S>, ) -> TransactionExecutorResult<()> { - let tx_execution_summary = tx_execution_info.summarize(); - self.transactional.executed_class_hashes.extend(tx_execution_summary.executed_class_hashes); + self.transactional + .executed_class_hashes + .extend(&tx_execution_summary.executed_class_hashes); self.transactional .visited_storage_entries - .extend(tx_execution_summary.visited_storage_entries); + .extend(&tx_execution_summary.visited_storage_entries); let tx_state_changes_keys = state.get_actual_state_changes()?.into_keys(); self.transactional.state_changes_keys = tx_state_changes_keys.difference(&self.bouncer.state_changes_keys); @@ -135,3 +138,21 @@ impl TransactionalBouncer { self.bouncer } } + +/// Calculates the L1 resources used by L1<>L2 messages. +/// Returns the total message segment length and the L1 gas usage. +pub fn calculate_message_l1_resources( + l2_to_l1_payload_lengths: &[usize], + l1_handler_payload_size: Option, +) -> (usize, GasVector) { + let message_segment_length = + get_message_segment_length(l2_to_l1_payload_lengths, l1_handler_payload_size); + let gas_usage = get_messages_gas_usage( + &MessageL1CostInfo { + l2_to_l1_payload_lengths: l2_to_l1_payload_lengths.to_owned(), + message_segment_length, + }, + l1_handler_payload_size, + ); + (message_segment_length, gas_usage) +} diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index 3ad8aea8a4..408dcb2ee8 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -13,8 +13,6 @@ use starknet_api::transaction::{EventContent, L2ToL1Payload}; use crate::execution::entry_point::CallEntryPoint; use crate::fee::gas_usage::get_message_segment_length; use crate::state::cached_state::StorageEntry; -use crate::transaction::errors::TransactionExecutionError; -use crate::transaction::objects::TransactionExecutionResult; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize)] pub struct Retdata(pub Vec); @@ -43,16 +41,16 @@ impl MessageL1CostInfo { pub fn calculate<'a>( call_infos: impl Iterator, l1_handler_payload_size: Option, - ) -> TransactionExecutionResult { + ) -> Self { let mut l2_to_l1_payload_lengths = Vec::new(); for call_info in call_infos { - l2_to_l1_payload_lengths.extend(call_info.get_sorted_l2_to_l1_payload_lengths()?); + l2_to_l1_payload_lengths.extend(call_info.get_l2_to_l1_payload_lengths()); } let message_segment_length = get_message_segment_length(&l2_to_l1_payload_lengths, l1_handler_payload_size); - Ok(Self { l2_to_l1_payload_lengths, message_segment_length }) + Self { l2_to_l1_payload_lengths, message_segment_length } } } @@ -70,6 +68,10 @@ pub struct OrderedL2ToL1Message { pub message: MessageToL1, } +pub fn get_payload_lengths(l2_to_l1_messages: &[OrderedL2ToL1Message]) -> Vec { + l2_to_l1_messages.iter().map(|message| message.message.payload.0.len()).collect() +} + /// Represents the effects of executing a single entry point. #[cfg_attr(test, derive(Clone))] #[derive(Debug, Default, Eq, PartialEq, Serialize)] @@ -94,6 +96,7 @@ struct ExecutionResourcesDef { pub struct ExecutionSummary { pub executed_class_hashes: HashSet, pub visited_storage_entries: HashSet, + pub l2_to_l1_payload_lengths: Vec, pub n_events: usize, } @@ -103,6 +106,7 @@ impl Add for ExecutionSummary { fn add(mut self, other: Self) -> Self { self.executed_class_hashes.extend(other.executed_class_hashes); self.visited_storage_entries.extend(other.visited_storage_entries); + self.l2_to_l1_payload_lengths.extend(other.l2_to_l1_payload_lengths); self.n_events += other.n_events; self } @@ -117,6 +121,7 @@ impl Sum for ExecutionSummary { #[derive(Debug, Default)] pub struct TestExecutionSummary { pub num_of_events: usize, + pub num_of_messages: usize, pub class_hash: ClassHash, pub storage_address: ContractAddress, pub storage_key: StorageKey, @@ -125,12 +130,14 @@ pub struct TestExecutionSummary { impl TestExecutionSummary { pub fn new( num_of_events: usize, + num_of_messages: usize, class_hash: ClassHash, storage_address: &str, storage_key: &str, ) -> Self { TestExecutionSummary { num_of_events, + num_of_messages, class_hash, storage_address: ContractAddress(patricia_key!(storage_address)), storage_key: StorageKey(patricia_key!(storage_key)), @@ -146,6 +153,15 @@ impl TestExecutionSummary { }, execution: CallExecution { events: (0..self.num_of_events).map(|_| OrderedEvent::default()).collect(), + l2_to_l1_messages: (0..self.num_of_messages) + .map(|i| OrderedL2ToL1Message { + order: i, + message: MessageToL1 { + to_address: EthAddress::default(), + payload: L2ToL1Payload(vec![StarkFelt::default()]), + }, + }) + .collect(), ..Default::default() }, accessed_storage_keys: vec![self.storage_key].into_iter().collect(), @@ -174,46 +190,18 @@ impl CallInfo { CallInfoIter { call_infos } } - /// Returns a list of Starknet L2ToL1Payload length collected during the execution, sorted - /// by the order in which they were sent. - pub fn get_sorted_l2_to_l1_payload_lengths(&self) -> TransactionExecutionResult> { - let n_messages = self.iter().map(|call| call.execution.l2_to_l1_messages.len()).sum(); - let mut starknet_l2_to_l1_payload_lengths: Vec> = vec![None; n_messages]; - - for call_info in self.iter() { - for ordered_message_content in &call_info.execution.l2_to_l1_messages { - let message_order = ordered_message_content.order; - if message_order >= n_messages { - return Err(TransactionExecutionError::InvalidOrder { - object: "L2-to-L1 message".to_string(), - order: message_order, - max_order: n_messages, - }); - } - starknet_l2_to_l1_payload_lengths[message_order] = - Some(ordered_message_content.message.payload.0.len()); - } - } - - starknet_l2_to_l1_payload_lengths.into_iter().enumerate().try_fold( - Vec::new(), - |mut acc, (i, option)| match option { - Some(value) => { - acc.push(value); - Ok(acc) - } - None => Err(TransactionExecutionError::UnexpectedHoles { - object: "L2-to-L1 message".to_string(), - order: i, - }), - }, - ) + pub fn get_l2_to_l1_payload_lengths(&self) -> Vec { + self.iter().fold(Vec::new(), |mut acc, call_info| { + acc.extend(get_payload_lengths(&call_info.execution.l2_to_l1_messages)); + acc + }) } pub fn summarize(&self) -> ExecutionSummary { let mut executed_class_hashes: HashSet = HashSet::new(); let mut visited_storage_entries: HashSet = HashSet::new(); let mut n_events: usize = 0; + let mut l2_to_l1_payload_lengths = Vec::new(); for call_info in self.iter() { let class_hash = @@ -227,9 +215,17 @@ impl CallInfo { visited_storage_entries.extend(call_storage_entries); n_events += call_info.execution.events.len(); + + l2_to_l1_payload_lengths + .extend(get_payload_lengths(&call_info.execution.l2_to_l1_messages)); } - ExecutionSummary { executed_class_hashes, visited_storage_entries, n_events } + ExecutionSummary { + executed_class_hashes, + visited_storage_entries, + l2_to_l1_payload_lengths, + n_events, + } } } diff --git a/crates/blockifier/src/fee/actual_cost.rs b/crates/blockifier/src/fee/actual_cost.rs index a1037351ef..4df3a5368e 100644 --- a/crates/blockifier/src/fee/actual_cost.rs +++ b/crates/blockifier/src/fee/actual_cost.rs @@ -34,16 +34,16 @@ impl ActualCost { pub fn builder_for_l1_handler<'a>( tx_context: Arc, l1_handler_payload_size: usize, - ) -> TransactionExecutionResult> { + ) -> ActualCostBuilder<'a> { let signature_length = 0; // Signature is validated on L1. - Ok(ActualCostBuilder::new( + ActualCostBuilder::new( tx_context, TransactionType::L1Handler, l1_handler_payload_size, signature_length, - )? + ) .without_sender_address() - .with_l1_payload_size(l1_handler_payload_size)) + .with_l1_payload_size(l1_handler_payload_size) } } @@ -67,8 +67,8 @@ impl<'a> ActualCostBuilder<'a> { tx_type: TransactionType, calldata_length: usize, signature_length: usize, - ) -> TransactionExecutionResult { - Ok(Self { + ) -> Self { + Self { starknet_resources: StarknetResources::new( calldata_length, signature_length, @@ -76,7 +76,7 @@ impl<'a> ActualCostBuilder<'a> { StateChangesCount::default(), None, iter::empty(), - )?, + ), sender_address: Some(tx_context.tx_info.sender_address()), tx_context, tx_type, @@ -84,7 +84,7 @@ impl<'a> ActualCostBuilder<'a> { execute_call_info: None, state_changes: StateChanges::default(), n_reverted_steps: 0, - }) + } } pub fn without_sender_address(mut self) -> Self { @@ -164,7 +164,7 @@ impl<'a> ActualCostBuilder<'a> { self.validate_call_info.into_iter().chain(self.execute_call_info); // Set the events and messages resources from the transaction's call infos. - self.starknet_resources.set_events_and_messages_resources(non_optional_call_infos)?; + self.starknet_resources.set_events_and_messages_resources(non_optional_call_infos); let mut actual_resources = calculate_tx_resources( &self.tx_context.block_context.versioned_constants, diff --git a/crates/blockifier/src/fee/actual_cost_test.rs b/crates/blockifier/src/fee/actual_cost_test.rs index ac9e3b1aa5..44f4a9bf76 100644 --- a/crates/blockifier/src/fee/actual_cost_test.rs +++ b/crates/blockifier/src/fee/actual_cost_test.rs @@ -60,8 +60,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool StateChangesCount::default(), None, std::iter::empty(), - ) - .unwrap(); + ); let code_gas_cost = versioned_constants.l2_resource_gas_costs.gas_per_code_byte * u128_from_usize( (class_info.bytecode_length() + class_info.sierra_program_length()) @@ -94,8 +93,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool deploy_account_state_changes_count, None, std::iter::empty(), - ) - .unwrap(); + ); let calldata_and_signature_gas_cost = versioned_constants.l2_resource_gas_costs.gas_per_data_felt * u128_from_usize(calldata_length + signature_length); @@ -117,8 +115,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool StateChangesCount::default(), Some(l1_handler_payload_size), std::iter::empty(), - ) - .unwrap(); + ); let l1_handler_gas_usage_vector = l1_handler_tx_starknet_resources.to_gas_vector(&versioned_constants, use_kzg_da); @@ -165,7 +162,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool let call_infos_iter = call_infos.iter(); let l2_to_l1_payload_lengths: Vec = call_infos_iter .clone() - .flat_map(|call_info| call_info.get_sorted_l2_to_l1_payload_lengths().unwrap()) + .flat_map(|call_info| call_info.get_l2_to_l1_payload_lengths()) .collect(); let l2_to_l1_state_changes_count = StateChangesCount { @@ -181,8 +178,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool l2_to_l1_state_changes_count, None, call_infos_iter.clone(), - ) - .unwrap(); + ); let l2_to_l1_messages_gas_usage_vector = l2_to_l1_starknet_resources.to_gas_vector(&versioned_constants, use_kzg_da); @@ -224,8 +220,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool storage_writes_state_changes_count, None, std::iter::empty(), - ) - .unwrap(); + ); let storage_writings_gas_usage_vector = storage_writes_starknet_resources.to_gas_vector(&versioned_constants, use_kzg_da); @@ -251,8 +246,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool combined_state_changes_count, Some(l1_handler_payload_size), call_infos_iter.clone(), - ) - .unwrap(); + ); let gas_usage_vector = combined_cases_starknet_resources.to_gas_vector(&versioned_constants, use_kzg_da); @@ -321,8 +315,7 @@ fn test_calculate_tx_gas_usage(#[values(false, true)] use_kzg_da: bool) { state_changes_count, None, std::iter::empty(), - ) - .unwrap(); + ); let gas_vector = starknet_resources.to_gas_vector(versioned_constants, use_kzg_da); @@ -374,8 +367,7 @@ fn test_calculate_tx_gas_usage(#[values(false, true)] use_kzg_da: bool) { state_changes_count, None, std::iter::empty(), - ) - .unwrap(); + ); let gas_vector = starknet_resources.to_gas_vector(versioned_constants, use_kzg_da); let GasVector { l1_gas: l1_gas_usage, l1_data_gas: l1_blob_gas_usage } = gas_vector; diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index 306689fd62..d399d15f86 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -27,8 +27,7 @@ fn test_get_event_gas_cost( let call_infos = vec![CallInfo::default(), CallInfo::default(), CallInfo::default()]; let call_infos_iter = call_infos.iter(); let starknet_resources = - StarknetResources::new(0, 0, None, StateChangesCount::default(), None, call_infos_iter) - .unwrap(); + StarknetResources::new(0, 0, None, StateChangesCount::default(), None, call_infos_iter); assert_eq!( GasVector::default(), starknet_resources.to_gas_vector(versioned_constants, use_kzg_da) @@ -70,8 +69,7 @@ fn test_get_event_gas_cost( (data_word_cost * (event_key_factor * 4_u128 + 6_u128)).to_integer(), ); let starknet_resources = - StarknetResources::new(0, 0, None, StateChangesCount::default(), None, call_infos_iter) - .unwrap(); + StarknetResources::new(0, 0, None, StateChangesCount::default(), None, call_infos_iter); let gas_vector = starknet_resources.to_gas_vector(versioned_constants, use_kzg_da); assert_eq!(expected, gas_vector); assert_ne!(GasVector::default(), gas_vector) diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index 8a9ab96ccd..21e16ef326 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -383,7 +383,7 @@ impl AccountTransaction { } let (actual_cost, bouncer_resources) = self - .to_actual_cost_builder(tx_context.clone())? + .to_actual_cost_builder(tx_context.clone()) .with_validate_call_info(&validate_call_info) .with_execute_call_info(&execute_call_info) .try_add_state_changes(state)? @@ -432,7 +432,7 @@ impl AccountTransaction { // Save the state changes resulting from running `validate_tx`, to be used later for // resource and fee calculation. let actual_cost_builder_with_validation_changes = self - .to_actual_cost_builder(tx_context.clone())? + .to_actual_cost_builder(tx_context.clone()) .with_validate_call_info(&validate_call_info) .try_add_state_changes(state)?; @@ -554,17 +554,17 @@ impl AccountTransaction { pub fn to_actual_cost_builder( &self, tx_context: Arc, - ) -> TransactionExecutionResult> { + ) -> ActualCostBuilder<'_> { let mut actual_cost_builder = ActualCostBuilder::new( tx_context, self.tx_type(), self.calldata_length(), self.signature_length(), - )?; + ); if let Self::Declare(tx) = self { actual_cost_builder = actual_cost_builder.with_class_info(tx.class_info.clone()); } - Ok(actual_cost_builder) + actual_cost_builder } } diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index 3965e43c2f..83ee24aa13 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -68,11 +68,6 @@ pub enum TransactionExecutionError { ExecutionError { error: EntryPointExecutionError, storage_address: ContractAddress }, #[error(transparent)] FeeCheckError(#[from] FeeCheckError), - #[error( - "Invalid order number for {object}. Order: {order} exceeds the maximum order limit: \ - {max_order}." - )] - InvalidOrder { object: String, order: usize, max_order: usize }, #[error("The `validate` entry point should return `VALID`. Got {actual:?}.")] InvalidValidateReturnData { actual: Retdata }, #[error( @@ -88,8 +83,6 @@ pub enum TransactionExecutionError { TransactionFeeError(#[from] TransactionFeeError), #[error(transparent)] TransactionPreValidationError(#[from] TransactionPreValidationError), - #[error("Unexpected holes in the {object} order. No object with the order: {order}.")] - UnexpectedHoles { object: String, order: usize }, #[error(transparent)] TryFromIntError(#[from] std::num::TryFromIntError), // TODO(Zuphit): add `gen_transaction_execution_error_trace` if needed. diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index b014db167a..b301bf45dc 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -226,7 +226,7 @@ impl TransactionExecutionInfo { } /// Returns a summary of transaction execution, including executed class hashes, visited storage - /// entries, and the number of emitted events. + /// entries, L2-to-L1_payload_lengths, and the number of emitted events. pub fn summarize(&self) -> ExecutionSummary { self.non_optional_call_infos().map(|call_info| call_info.summarize()).sum() } @@ -274,7 +274,7 @@ impl StarknetResources { state_changes_count: StateChangesCount, l1_handler_payload_size: Option, call_infos: impl Iterator + Clone, - ) -> TransactionExecutionResult { + ) -> Self { let mut new = Self { calldata_length, signature_length, @@ -283,8 +283,8 @@ impl StarknetResources { l1_handler_payload_size, ..Default::default() }; - new.set_events_and_messages_resources(call_infos)?; - Ok(new) + new.set_events_and_messages_resources(call_infos); + new } /// Returns the gas cost of the starknet resources, summing all components. @@ -311,7 +311,7 @@ impl StarknetResources { pub fn set_events_and_messages_resources<'a>( &mut self, call_infos: impl Iterator + Clone, - ) -> TransactionExecutionResult<()> { + ) { let tuple_add = |(a, b): (u128, u128), (c, d): (u128, u128)| (a + c, b + d); let (total_event_keys, total_event_data_size) = call_infos .clone() @@ -333,9 +333,7 @@ impl StarknetResources { self.total_event_data_size = total_event_data_size; self.message_cost_info = - MessageL1CostInfo::calculate(call_infos, self.l1_handler_payload_size)?; - - Ok(()) + MessageL1CostInfo::calculate(call_infos, self.l1_handler_payload_size); } // Returns the gas cost for transaction calldata and transaction signature. Each felt costs a diff --git a/crates/blockifier/src/transaction/objects_test.rs b/crates/blockifier/src/transaction/objects_test.rs index ca6533a720..67330bfbcc 100644 --- a/crates/blockifier/src/transaction/objects_test.rs +++ b/crates/blockifier/src/transaction/objects_test.rs @@ -114,9 +114,9 @@ fn test_events_counter_in_transaction_execution_info_with_inner_call_info( #[rstest] #[case( - TestExecutionSummary::new(1, ClassHash(stark_felt!("0x1")), "0x1", "0x1"), - TestExecutionSummary::new(2, ClassHash(stark_felt!("0x2")), "0x2", "0x2"), - TestExecutionSummary::new(3, ClassHash(stark_felt!("0x3")), "0x3", "0x3") + TestExecutionSummary::new(1, 2, ClassHash(stark_felt!("0x1")), "0x1", "0x1"), + TestExecutionSummary::new(2, 3, ClassHash(stark_felt!("0x2")), "0x2", "0x2"), + TestExecutionSummary::new(3, 4, ClassHash(stark_felt!("0x3")), "0x3", "0x3") )] fn test_summarize( #[case] validate_params: TestExecutionSummary, @@ -152,6 +152,12 @@ fn test_summarize( n_events: validate_params.num_of_events + execute_params.num_of_events + fee_transfer_params.num_of_events, + l2_to_l1_payload_lengths: vec![ + 1; + validate_params.num_of_messages + + execute_params.num_of_messages + + fee_transfer_params.num_of_messages + ], }; // Call the summarize method @@ -161,4 +167,5 @@ fn test_summarize( assert_eq!(actual_summary.executed_class_hashes, expected_summary.executed_class_hashes); assert_eq!(actual_summary.visited_storage_entries, expected_summary.visited_storage_entries); assert_eq!(actual_summary.n_events, expected_summary.n_events); + assert_eq!(actual_summary.l2_to_l1_payload_lengths, expected_summary.l2_to_l1_payload_lengths); } diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index 844cc4718e..2505488a6a 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -117,7 +117,7 @@ impl ExecutableTransaction for L1HandlerTransaction { let l1_handler_payload_size = self.payload_size(); let (ActualCost { actual_fee, da_gas, actual_resources }, _bouncer_resources) = - ActualCost::builder_for_l1_handler(tx_context, l1_handler_payload_size)? + ActualCost::builder_for_l1_handler(tx_context, l1_handler_payload_size) .with_execute_call_info(&execute_call_info) .try_add_state_changes(state)? .build(&execution_resources)?; diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 6bfde31470..633490f689 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -428,8 +428,7 @@ fn test_invoke_tx( }, None, std::iter::empty(), - ) - .unwrap(); + ); let sender_address = invoke_tx.sender_address(); let account_tx = AccountTransaction::Invoke(invoke_tx); @@ -1143,8 +1142,7 @@ fn test_declare_tx( declare_expected_state_changes_count(tx_version), None, std::iter::empty(), - ) - .unwrap(); + ); let account_tx = declare_tx( declare_tx_args! {