Skip to content

Commit

Permalink
avivg/blockifier/use_api_WORD_WIDTH_and_remove_blockifier_WORD_WIDTH
Browse files Browse the repository at this point in the history
  • Loading branch information
avivg-starkware committed Nov 12, 2024
1 parent 4276a78 commit cb06e92
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions crates/blockifier/src/execution/contract_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ use crate::execution::errors::{ContractClassError, PreExecutionError};
use crate::execution::execution_utils::{poseidon_hash_many_cost, sn_api_to_cairo_vm_program};
#[cfg(feature = "cairo_native")]
use crate::execution::native::contract_class::NativeContractClassV1;
use crate::fee::eth_gas_constants;
use crate::transaction::errors::TransactionExecutionError;
use crate::versioned_constants::CompilerVersion;

Expand Down Expand Up @@ -562,7 +561,7 @@ impl ClassInfo {
pub fn code_size(&self) -> usize {
(self.bytecode_length() + self.sierra_program_length())
// We assume each felt is a word.
* eth_gas_constants::WORD_WIDTH
* starknet_api::core::WORD_WIDTH
+ self.abi_length()
}

Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/fee/eth_gas_constants.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// 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;
use starknet_api::core::WORD_WIDTH;

pub const GAS_PER_MEMORY_WORD: usize = GAS_PER_MEMORY_BYTE * WORD_WIDTH;

// Blob Data.
Expand Down
2 changes: 1 addition & 1 deletion crates/blockifier/src/fee/receipt_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(
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
* starknet_api::core::WORD_WIDTH
+ class_info.abi_length(),
))
.to_integer()
Expand Down

0 comments on commit cb06e92

Please sign in to comment.