Skip to content

Commit

Permalink
feat(native_blockifier): support receiving L1 Data Gas
Browse files Browse the repository at this point in the history
  • Loading branch information
TzahiTaub committed Nov 28, 2024
1 parent 822f957 commit db02f22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/blockifier_reexecution/src/state_reader/serde_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions crates/native_blockifier/src/py_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ pub(crate) const PY_TX_PARSING_ERR: &str = "Failed parsing Py transaction.";
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
pub enum PyResource {
L1Gas,
L1DataGas,
L2Gas,
}

impl From<PyResource> for Resource {
fn from(py_resource: PyResource) -> Self {
match py_resource {
PyResource::L1Gas => Resource::L1Gas,
PyResource::L1DataGas => Resource::L1DataGas,
PyResource::L2Gas => Resource::L2Gas,
}
}
Expand All @@ -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}"))),
}
Expand Down

0 comments on commit db02f22

Please sign in to comment.