diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index 01f1c28c21..de1f579111 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -104,9 +104,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 + context.resource_bounds.max_possible_fee() > 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..500e73414f 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) -> Fee { + Fee(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 {