From ce7d6bcc909593102fdd63bddd50a5308f5c551b Mon Sep 17 00:00:00 2001 From: Tzahi Taub Date: Thu, 28 Nov 2024 14:51:20 +0200 Subject: [PATCH] feat(native_blockifier): support receiving L1 Data Gas --- crates/blockifier_reexecution/src/state_reader/serde_utils.rs | 4 ++++ crates/native_blockifier/src/py_transaction.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs index d57d95b1ef..95d5f4937a 100644 --- a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs @@ -27,6 +27,10 @@ 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 40e0f64f4e..10fc32a1d1 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -38,8 +38,8 @@ impl From for Resource { fn from(py_resource: PyResource) -> Self { match py_resource { PyResource::L1Gas => Resource::L1Gas, - PyResource::L2Gas => Resource::L2Gas, PyResource::L1DataGas => Resource::L1DataGas, + PyResource::L2Gas => Resource::L2Gas, } } } @@ -49,8 +49,8 @@ impl FromPyObject<'_> for PyResource { let resource_name: &str = resource.getattr("name")?.extract()?; match resource_name { "L1_GAS" => Ok(PyResource::L1Gas), - "L2_GAS" => Ok(PyResource::L2Gas), "L1_DATA_GAS" => Ok(PyResource::L1DataGas), + "L2_GAS" => Ok(PyResource::L2Gas), _ => Err(PyValueError::new_err(format!("Invalid resource: {resource_name}"))), } }