From 70e441d84cb51db95217d45a5e431371269bec9b Mon Sep 17 00:00:00 2001 From: Tzahi Taub Date: Thu, 28 Nov 2024 14:51:20 +0200 Subject: [PATCH] feature(native_blockifier): support receiving L1 Data Gas --- crates/blockifier_reexecution/src/state_reader/serde_utils.rs | 3 +++ crates/native_blockifier/src/py_transaction.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs index d57d95b1ef..53be95d1dd 100644 --- a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs @@ -27,6 +27,9 @@ pub fn upper_case_resource_bounds_names(raw_transaction: &mut Value) { .expect("If tx contains l1_gas, it should contain l2_gas"); resource_bounds.insert("L2_GAS".to_string(), l2_gas_value); } + + if let Some(l1_data_gas_value) = resource_bounds.remove("l1_data_gas") { + resource_bounds.insert("L1_DATA_GAS".to_string(), l1_data_gas_value); } pub fn deserialize_transaction_json_to_starknet_api_tx( diff --git a/crates/native_blockifier/src/py_transaction.rs b/crates/native_blockifier/src/py_transaction.rs index bdf28426b0..e622c33133 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -30,6 +30,7 @@ pub(crate) const PY_TX_PARSING_ERR: &str = "Failed parsing Py transaction."; #[derive(Clone, Eq, Ord, PartialEq, PartialOrd)] pub enum PyResource { L1Gas, + L1DataGas, L2Gas, } @@ -37,6 +38,7 @@ impl From for Resource { fn from(py_resource: PyResource) -> Self { match py_resource { PyResource::L1Gas => Resource::L1Gas, + PyResource::L1DataGas => Resource::L1DataGas, PyResource::L2Gas => Resource::L2Gas, } } @@ -47,6 +49,7 @@ impl FromPyObject<'_> for PyResource { let resource_name: &str = resource.getattr("name")?.extract()?; match resource_name { "L1_GAS" => Ok(PyResource::L1Gas), + "L1_DATA_GAS" => Ok(PyResource::L1DataGas), "L2_GAS" => Ok(PyResource::L2Gas), _ => Err(PyValueError::new_err(format!("Invalid resource: {resource_name}"))), }