From e759d81548a2e122aec2cf5eb8b35e0aec5a6ae1 Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Tue, 12 Nov 2024 08:15:50 +0200 Subject: [PATCH] refactor(blockifier): remove WORD_WIDTH from blockifier, use starkn et_api instead --- crates/blockifier/src/fee/eth_gas_constants.rs | 4 ++-- crates/blockifier/src/fee/receipt_test.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/blockifier/src/fee/eth_gas_constants.rs b/crates/blockifier/src/fee/eth_gas_constants.rs index e01eb73132..0055c5d1f4 100644 --- a/crates/blockifier/src/fee/eth_gas_constants.rs +++ b/crates/blockifier/src/fee/eth_gas_constants.rs @@ -1,8 +1,8 @@ +use starknet_api::core::WORD_WIDTH; + // Calldata. pub const GAS_PER_MEMORY_ZERO_BYTE: usize = 4; pub const GAS_PER_MEMORY_BYTE: usize = 16; -// TODO(AvivG): use starknet_api::core::WORD_WIDTH instead. -pub const WORD_WIDTH: usize = 32; pub const GAS_PER_MEMORY_WORD: usize = GAS_PER_MEMORY_BYTE * WORD_WIDTH; // Blob Data. diff --git a/crates/blockifier/src/fee/receipt_test.rs b/crates/blockifier/src/fee/receipt_test.rs index 95c315918b..ac1a72e24d 100644 --- a/crates/blockifier/src/fee/receipt_test.rs +++ b/crates/blockifier/src/fee/receipt_test.rs @@ -1,4 +1,5 @@ use rstest::{fixture, rstest}; +use starknet_api::core::WORD_WIDTH; use starknet_api::execution_resources::GasVector; use starknet_api::transaction::fields::GasVectorComputationMode; use starknet_api::transaction::L2ToL1Payload; @@ -85,8 +86,7 @@ fn test_calculate_tx_gas_usage_basic<'a>( .gas_per_code_byte; let code_gas_cost = (gas_per_code_byte * u64_from_usize( - (class_info.bytecode_length() + class_info.sierra_program_length()) - * eth_gas_constants::WORD_WIDTH + (class_info.bytecode_length() + class_info.sierra_program_length()) * WORD_WIDTH + class_info.abi_length(), )) .to_integer()