diff --git a/crates/blockifier/src/fee/actual_cost_test.rs b/crates/blockifier/src/fee/actual_cost_test.rs index e9dcbd19b7..120bc8707c 100644 --- a/crates/blockifier/src/fee/actual_cost_test.rs +++ b/crates/blockifier/src/fee/actual_cost_test.rs @@ -201,6 +201,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool let manual_gas_computation = GasVector { l1_gas: u128_from_usize(manual_starknet_gas_usage + manual_sharp_gas_usage), l1_data_gas: manual_sharp_blob_gas_usage, + ..Default::default() }; assert_eq!(l2_to_l1_messages_gas_usage_vector, manual_gas_computation); @@ -272,6 +273,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool l1_data_gas: combined_cases_starknet_resources .get_state_changes_cost(use_kzg_da) .l1_data_gas, + ..Default::default() }; assert_eq!(expected_gas_vector, gas_usage_vector); diff --git a/crates/blockifier/src/fee/fee_test.rs b/crates/blockifier/src/fee/fee_test.rs index 9fa32a18cc..bcc791f723 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -137,6 +137,7 @@ fn test_discounted_gas_overdraft( gas: GasVector { l1_gas: u128_from_usize(l1_gas_used), l1_data_gas: u128_from_usize(l1_data_gas_used), + ..Default::default() }, ..Default::default() }; diff --git a/crates/blockifier/src/fee/gas_usage.rs b/crates/blockifier/src/fee/gas_usage.rs index 3bfa13064e..b5b2fc24c5 100644 --- a/crates/blockifier/src/fee/gas_usage.rs +++ b/crates/blockifier/src/fee/gas_usage.rs @@ -72,7 +72,7 @@ pub fn get_da_gas_cost(state_changes_count: &StateChangesCount, use_kzg_da: bool (u128_from_usize(gas), 0) }; - GasVector { l1_gas, l1_data_gas: blob_gas } + GasVector { l1_gas, l1_data_gas: blob_gas, ..Default::default() } } /// Returns the number of felts added to the output messages segment as a result of adding @@ -195,7 +195,7 @@ pub fn compute_discounted_gas_from_gas_vector( tx_context: &TransactionContext, ) -> u128 { let gas_prices = &tx_context.block_context.block_info.gas_prices; - let GasVector { l1_gas: gas_usage, l1_data_gas: blob_gas_usage } = gas_usage_vector; + let GasVector { l1_gas: gas_usage, l1_data_gas: blob_gas_usage, .. } = gas_usage_vector; let fee_type = tx_context.tx_info.fee_type(); let gas_price = gas_prices.get_gas_price_by_fee_type(&fee_type); let data_gas_price = gas_prices.get_data_gas_price_by_fee_type(&fee_type); diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index f9ccee395e..1d89c913db 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -207,7 +207,7 @@ fn test_get_message_segment_length( fn test_compute_discounted_gas_from_gas_vector() { let tx_context = BlockContext::create_for_testing().to_tx_context(&account_invoke_tx(invoke_tx_args! {})); - let gas_usage = GasVector { l1_gas: 100, l1_data_gas: 2 }; + let gas_usage = GasVector { l1_gas: 100, l1_data_gas: 2, ..Default::default() }; let actual_result = compute_discounted_gas_from_gas_vector(&gas_usage, &tx_context); let result_div_ceil = gas_usage.l1_gas diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index a08dbd5e8d..b323b754db 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -155,15 +155,16 @@ pub struct DeprecatedTransactionInfo { pub struct GasVector { pub l1_gas: u128, pub l1_data_gas: u128, + pub l2_gas: u128, } impl GasVector { pub fn from_l1_gas(l1_gas: u128) -> Self { - Self { l1_gas, l1_data_gas: 0 } + Self { l1_gas, ..Default::default() } } pub fn from_l1_data_gas(l1_data_gas: u128) -> Self { - Self { l1_gas: 0, l1_data_gas } + Self { l1_data_gas, ..Default::default() } } /// Computes the cost (in fee token units) of the gas vector (saturating on overflow). @@ -462,7 +463,7 @@ impl TransactionResources { use_kzg_da: bool, with_reverted_steps: bool, ) -> ResourcesMapping { - let GasVector { l1_gas, l1_data_gas } = + let GasVector { l1_gas, l1_data_gas, .. } = self.starknet_resources.to_gas_vector(versioned_constants, use_kzg_da); let mut resources = self.vm_resources.to_resources_mapping(); resources.0.extend(HashMap::from([ diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 6e7ef6058c..5ee3460148 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -1866,7 +1866,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { // TODO(Nimrod, 1/5/2024): Change these hard coded values to match to the transaction resources // (currently matches only starknet resources). let expected_gas = match use_kzg_da { - true => GasVector { l1_gas: 16023, l1_data_gas: 128 }, + true => GasVector { l1_gas: 16023, l1_data_gas: 128, l2_gas: 0 }, false => GasVector::from_l1_gas(17675), }; let expected_da_gas = match use_kzg_da { diff --git a/crates/papyrus_execution/src/objects.rs b/crates/papyrus_execution/src/objects.rs index 96d2e627a8..f10a890ea1 100644 --- a/crates/papyrus_execution/src/objects.rs +++ b/crates/papyrus_execution/src/objects.rs @@ -363,7 +363,7 @@ impl TryFrom<(CallInfo, GasVector)> for FunctionInvocation { // Can't implement `TryFrom` because both types are from external crates. fn vm_resources_to_execution_resources( vm_resources: VmExecutionResources, - GasVector { l1_gas, l1_data_gas }: GasVector, + GasVector { l1_gas, l1_data_gas, .. }: GasVector, ) -> ExecutionResult { let mut builtin_instance_counter = HashMap::new(); for (builtin_name, count) in vm_resources.builtin_instance_counter {