From 61ce6c4220079116f68056dd2f0306ca257bd1e7 Mon Sep 17 00:00:00 2001 From: Yonatan Iluz Date: Mon, 9 Dec 2024 15:21:46 +0200 Subject: [PATCH] chore(native_blockifier): remove unused resource from actual_resources --- Cargo.lock | 2 +- crates/blockifier/src/abi/constants.rs | 2 -- .../src/py_block_executor.rs | 24 +------------------ 3 files changed, 2 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 330f1220a1..2cfe64c74f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10560,9 +10560,9 @@ version = "0.0.0" dependencies = [ "axum", "hyper 0.14.30", + "infra_utils", "metrics 0.21.1", "metrics-exporter-prometheus", - "infra_utils", "papyrus_config", "pretty_assertions", "serde", diff --git a/crates/blockifier/src/abi/constants.rs b/crates/blockifier/src/abi/constants.rs index 45031271db..4671e7c350 100644 --- a/crates/blockifier/src/abi/constants.rs +++ b/crates/blockifier/src/abi/constants.rs @@ -27,8 +27,6 @@ pub const CONSUMED_MSG_TO_L2_ENCODED_DATA_SIZE: usize = // Transaction resource names. // TODO(Amos, 1/10/2024): Rename to l1_gas_weight. pub const L1_GAS_USAGE: &str = "gas_weight"; -pub const L2_GAS_USAGE: &str = "l2_gas_weight"; -pub const BLOB_GAS_USAGE: &str = "l1_blob_gas_usage"; pub const N_STEPS_RESOURCE: &str = "n_steps"; pub const N_EVENTS: &str = "n_events"; pub const MESSAGE_SEGMENT_LENGTH: &str = "message_segment_length"; diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index d515e3a2da..51a0a1b714 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -13,7 +13,6 @@ use blockifier::fee::receipt::TransactionReceipt; use blockifier::state::global_cache::GlobalContractCache; use blockifier::transaction::objects::{ExecutionResourcesTraits, TransactionExecutionInfo}; use blockifier::transaction::transaction_execution::Transaction; -use blockifier::utils::usize_from_u64; use blockifier::versioned_constants::VersionedConstants; use papyrus_state_reader::papyrus_state::PapyrusReader; use pyo3::prelude::*; @@ -91,11 +90,10 @@ impl ThinTransactionExecutionInfo { } pub fn receipt_to_resources_mapping(receipt: &TransactionReceipt) -> ResourcesMapping { - let GasVector { l1_gas, l1_data_gas, l2_gas } = receipt.gas; let vm_resources = &receipt.resources.computation.vm_resources; let mut resources = HashMap::from([( abi_constants::N_STEPS_RESOURCE.to_string(), - vm_resources.total_n_steps(), + vm_resources.total_n_steps() + receipt.resources.computation.n_reverted_steps, )]); resources.extend( vm_resources @@ -103,26 +101,6 @@ impl ThinTransactionExecutionInfo { .iter() .map(|(builtin, value)| (builtin.to_str_with_suffix().to_string(), *value)), ); - // TODO(Yoni) remove these since we pass the gas vector in separate. - resources.extend(HashMap::from([ - ( - abi_constants::L1_GAS_USAGE.to_string(), - usize_from_u64(l1_gas.0) - .expect("This conversion should not fail as the value is a converted usize."), - ), - ( - abi_constants::BLOB_GAS_USAGE.to_string(), - usize_from_u64(l1_data_gas.0) - .expect("This conversion should not fail as the value is a converted usize."), - ), - ( - abi_constants::L2_GAS_USAGE.to_string(), - usize_from_u64(l2_gas.0) - .expect("This conversion should not fail as the value is a converted usize."), - ), - ])); - *resources.get_mut(abi_constants::N_STEPS_RESOURCE).unwrap_or(&mut 0) += - receipt.resources.computation.n_reverted_steps; ResourcesMapping(resources) }