diff --git a/crates/blockifier/src/blockifier/block.rs b/crates/blockifier/src/blockifier/block.rs index d8db444c018..ff8063e40be 100644 --- a/crates/blockifier/src/blockifier/block.rs +++ b/crates/blockifier/src/blockifier/block.rs @@ -9,7 +9,7 @@ use crate::abi::constants; use crate::state::errors::StateError; use crate::state::state_api::{State, StateResult}; use crate::transaction::objects::FeeType; -use crate::versioned_constants::VersionedConstants; +// use crate::versioned_constants::VersionedConstants; #[cfg(test)] #[path = "block_test.rs"] @@ -42,15 +42,22 @@ impl GasPrices { strk_l1_gas_price: NonZeroU128, eth_l1_data_gas_price: NonZeroU128, strk_l1_data_gas_price: NonZeroU128, + eth_l2_gas_price: NonZeroU128, + strk_l2_gas_price: NonZeroU128, ) -> Self { - let eth_l2_gas_price = NonZeroU128::new(VersionedConstants::l1_to_l2_gas_price_conversion( - eth_l1_gas_price.into(), - )) - .unwrap(); - let strk_l2_gas_price = NonZeroU128::new( - VersionedConstants::l1_to_l2_gas_price_conversion(strk_l1_gas_price.into()), - ) - .unwrap(); + // TODO(Aner, 13/08/24): remove these asserts + // assert_eq!( + // eth_l2_gas_price, + // VersionedConstants::l1_to_l2_gas_price_conversion(eth_l1_gas_price.into()) + // .try_into() + // .unwrap() + // ); + // assert_eq!( + // strk_l2_gas_price, + // VersionedConstants::l1_to_l2_gas_price_conversion(strk_l1_gas_price.into()) + // .try_into() + // .unwrap() + // ); GasPrices { eth_l1_gas_price, strk_l1_gas_price, diff --git a/crates/blockifier/src/fee/fee_test.rs b/crates/blockifier/src/fee/fee_test.rs index 52ce6922905..714c3d3a54c 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -133,6 +133,10 @@ fn test_discounted_gas_overdraft( gas_price.try_into().unwrap(), DEFAULT_ETH_L1_DATA_GAS_PRICE.try_into().unwrap(), data_gas_price.try_into().unwrap(), + VersionedConstants::l1_to_l2_gas_price_conversion(DEFAULT_ETH_L1_GAS_PRICE) + .try_into() + .unwrap(), + VersionedConstants::l1_to_l2_gas_price_conversion(gas_price).try_into().unwrap(), ); let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0); diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index 6b6e83b8593..4f4236efbfb 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -163,6 +163,12 @@ impl BlockInfo { DEFAULT_STRK_L1_GAS_PRICE.try_into().unwrap(), DEFAULT_ETH_L1_DATA_GAS_PRICE.try_into().unwrap(), DEFAULT_STRK_L1_DATA_GAS_PRICE.try_into().unwrap(), + VersionedConstants::l1_to_l2_gas_price_conversion(DEFAULT_ETH_L1_GAS_PRICE) + .try_into() + .unwrap(), + VersionedConstants::l1_to_l2_gas_price_conversion(DEFAULT_STRK_L1_GAS_PRICE) + .try_into() + .unwrap(), ), use_kzg_da: false, } diff --git a/crates/gateway/src/rpc_objects.rs b/crates/gateway/src/rpc_objects.rs index d6898d024f8..d5cdb3bf0ef 100644 --- a/crates/gateway/src/rpc_objects.rs +++ b/crates/gateway/src/rpc_objects.rs @@ -90,6 +90,8 @@ impl TryInto for BlockHeader { parse_gas_price(self.l1_gas_price.price_in_fri)?, parse_gas_price(self.l1_data_gas_price.price_in_wei)?, parse_gas_price(self.l1_data_gas_price.price_in_fri)?, + NonZeroU128::MIN, + NonZeroU128::MIN, ), use_kzg_da: matches!(self.l1_da_mode, L1DataAvailabilityMode::Blob), }) diff --git a/crates/native_blockifier/src/py_state_diff.rs b/crates/native_blockifier/src/py_state_diff.rs index 634f6baac0b..83df63412d6 100644 --- a/crates/native_blockifier/src/py_state_diff.rs +++ b/crates/native_blockifier/src/py_state_diff.rs @@ -9,6 +9,7 @@ use blockifier::test_utils::{ DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, }; +use blockifier::versioned_constants::VersionedConstants; use indexmap::IndexMap; use pyo3::prelude::*; use pyo3::FromPyObject; @@ -140,6 +141,7 @@ pub struct PyBlockInfo { pub block_timestamp: u64, pub l1_gas_price: PyResourcePrice, pub l1_data_gas_price: PyResourcePrice, + pub l2_gas_price: PyResourcePrice, pub sequencer_address: PyFelt, pub use_kzg_da: bool, } @@ -158,6 +160,14 @@ impl Default for PyBlockInfo { price_in_wei: DEFAULT_ETH_L1_DATA_GAS_PRICE, price_in_fri: DEFAULT_STRK_L1_DATA_GAS_PRICE, }, + l2_gas_price: PyResourcePrice { + price_in_wei: VersionedConstants::l1_to_l2_gas_price_conversion( + DEFAULT_ETH_L1_GAS_PRICE, + ), + price_in_fri: VersionedConstants::l1_to_l2_gas_price_conversion( + DEFAULT_STRK_L1_GAS_PRICE, + ), + }, sequencer_address: PyFelt::default(), use_kzg_da: bool::default(), } @@ -201,6 +211,20 @@ impl TryFrom for BlockInfo { ), ) })?, + block_info.l2_gas_price.price_in_wei.try_into().map_err(|_| { + NativeBlockifierInputError::InvalidNativeBlockifierInputError( + InvalidNativeBlockifierInputError::InvalidGasPriceWei( + block_info.l2_gas_price.price_in_wei, + ), + ) + })?, + block_info.l2_gas_price.price_in_fri.try_into().map_err(|_| { + NativeBlockifierInputError::InvalidNativeBlockifierInputError( + InvalidNativeBlockifierInputError::InvalidGasPriceFri( + block_info.l2_gas_price.price_in_fri, + ), + ) + })?, ), use_kzg_da: block_info.use_kzg_da, }) diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 3094f818206..15279db84b5 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -359,6 +359,8 @@ fn create_block_context( NonZeroU128::new(l1_gas_price.price_in_fri.0).unwrap_or(NonZeroU128::MIN), NonZeroU128::new(l1_data_gas_price.price_in_wei.0).unwrap_or(NonZeroU128::MIN), NonZeroU128::new(l1_data_gas_price.price_in_fri.0).unwrap_or(NonZeroU128::MIN), + NonZeroU128::MIN, + NonZeroU128::MIN, ), }; let chain_info = ChainInfo {