diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index 01f1c28c21..c063e8f3ae 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -103,11 +103,7 @@ impl TransactionInfo { pub fn enforce_fee(&self) -> bool { match self { - TransactionInfo::Current(context) => { - let l1_bounds = context.l1_resource_bounds(); - let max_amount: u128 = l1_bounds.max_amount.into(); - max_amount * l1_bounds.max_price_per_unit > 0 - } + TransactionInfo::Current(context) => context.resource_bounds.max_possible_fee() > 0, TransactionInfo::Deprecated(context) => context.max_fee != Fee(0), } } diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index 376be1ce4d..a5c5c16ece 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -979,6 +979,24 @@ impl ValidResourceBounds { } } + pub fn max_possible_fee(&self) -> u128 { + match self { + ValidResourceBounds::L1Gas(l1_bounds) => { + let max_amount: u128 = l1_bounds.max_amount.into(); + max_amount * l1_bounds.max_price_per_unit + } + ValidResourceBounds::AllResources(AllResourceBounds { + l1_gas, + l2_gas, + l1_data_gas, + }) => { + u128::from(l1_gas.max_amount) * l1_gas.max_price_per_unit + + u128::from(l2_gas.max_amount) * l2_gas.max_price_per_unit + + u128::from(l1_data_gas.max_amount) * l1_data_gas.max_price_per_unit + } + } + } + // TODO(Nimrod): Default testing bounds should probably be AllResourceBounds variant. #[cfg(any(feature = "testing", test))] pub fn create_for_testing() -> Self {