Skip to content

Commit

Permalink
chore(native_blockifier): remove unused resource from actual_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoni-Starkware committed Dec 9, 2024
1 parent 4a7a9fb commit 2bb999d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
2 changes: 0 additions & 2 deletions crates/blockifier/src/abi/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
23 changes: 1 addition & 22 deletions crates/native_blockifier/src/py_block_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,38 +91,17 @@ 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
.prover_builtins()
.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)
}
Expand Down

0 comments on commit 2bb999d

Please sign in to comment.