Skip to content

Commit

Permalink
build(fee): tx_resources depend on resource bounds signature
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrod-starkware committed Aug 14, 2024
1 parent 51be993 commit 338583b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
12 changes: 10 additions & 2 deletions crates/blockifier/src/transaction/account_transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,11 @@ fn test_max_fee_to_max_steps_conversion(
let gas_used_vector1 = tx_execution_info1
.receipt
.resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false,
)
.unwrap();

// Second invocation of `with_arg` gets twice the pre-calculated actual fee as max_fee.
Expand All @@ -957,7 +961,11 @@ fn test_max_fee_to_max_steps_conversion(
let gas_used_vector2 = tx_execution_info2
.receipt
.resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false,
)
.unwrap();

// Test that steps limit doubles as max_fee doubles, but actual consumed steps and fee remains.
Expand Down
6 changes: 5 additions & 1 deletion crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ fn check_gas_and_fee(
tx_execution_info
.receipt
.resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false
)
.unwrap()
.l1_gas,
expected_actual_gas.into()
Expand Down
10 changes: 9 additions & 1 deletion crates/blockifier/src/transaction/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ impl TransactionInfo {
TransactionInfo::Deprecated(context) => Ok(context.max_fee != Fee(0)),
}
}

pub fn has_l2_gas_bounds(&self) -> bool {
match self {
TransactionInfo::Current(context) => context.resource_bounds.0.len() == 3,
TransactionInfo::Deprecated(_) => false,
}
}
}

impl HasRelatedFeeType for TransactionInfo {
Expand Down Expand Up @@ -470,8 +477,9 @@ impl TransactionResources {
&self,
versioned_constants: &VersionedConstants,
use_kzg_da: bool,
include_l2_gas: bool,
) -> TransactionFeeResult<GasVector> {
Ok(self.starknet_resources.to_gas_vector(versioned_constants, use_kzg_da, false)
Ok(self.starknet_resources.to_gas_vector(versioned_constants, use_kzg_da, include_l2_gas)
+ calculate_l1_gas_by_vm_usage(
versioned_constants,
&self.vm_resources,
Expand Down
6 changes: 5 additions & 1 deletion crates/blockifier/src/transaction/post_execution_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,11 @@ fn test_revert_on_resource_overuse(
let actual_gas_usage: u64 = execution_info_measure
.receipt
.resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false,
)
.unwrap()
.l1_gas
.try_into()
Expand Down
16 changes: 12 additions & 4 deletions crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,11 @@ fn test_invoke_tx(
);

let total_gas = expected_actual_resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false,
)
.unwrap();

let expected_execution_info = TransactionExecutionInfo {
Expand Down Expand Up @@ -1224,7 +1228,7 @@ fn test_declare_tx(
);

let expected_total_gas =
expected_actual_resources.to_gas_vector(versioned_constants, use_kzg_da).unwrap();
expected_actual_resources.to_gas_vector(versioned_constants, use_kzg_da, false).unwrap();

let expected_execution_info = TransactionExecutionInfo {
validate_call_info: expected_validate_call_info,
Expand Down Expand Up @@ -1392,7 +1396,11 @@ fn test_deploy_account_tx(
);

let expected_total_gas = actual_resources
.to_gas_vector(&block_context.versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(
&block_context.versioned_constants,
block_context.block_info.use_kzg_da,
false,
)
.unwrap();

let expected_execution_info = TransactionExecutionInfo {
Expand Down Expand Up @@ -1907,7 +1915,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) {
);

let total_gas = expected_tx_resources
.to_gas_vector(versioned_constants, block_context.block_info.use_kzg_da)
.to_gas_vector(versioned_constants, block_context.block_info.use_kzg_da, false)
.unwrap();

// Build the expected execution info.
Expand Down

0 comments on commit 338583b

Please sign in to comment.