From 34c98a06696a00fd766831e8089bdfd6b8e7d558 Mon Sep 17 00:00:00 2001 From: yoavGrs <97383386+yoavGrs@users.noreply.github.com> Date: Mon, 23 Dec 2024 16:46:08 +0200 Subject: [PATCH] test(native_blockifier): move alias constants to python (#2675) --- crates/blockifier/src/state/stateful_compression.rs | 8 ++++---- crates/native_blockifier/src/lib.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/blockifier/src/state/stateful_compression.rs b/crates/blockifier/src/state/stateful_compression.rs index 68b4f5b290..bc5380aea2 100644 --- a/crates/blockifier/src/state/stateful_compression.rs +++ b/crates/blockifier/src/state/stateful_compression.rs @@ -30,17 +30,17 @@ pub type CompressionResult = Result; // The initial alias available for allocation. const INITIAL_AVAILABLE_ALIAS_HEX: &str = "0x80"; -const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX); +pub const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX); // The storage key of the alias counter in the alias contract. -const ALIAS_COUNTER_STORAGE_KEY: StorageKey = StorageKey(PatriciaKey::ZERO); +pub const ALIAS_COUNTER_STORAGE_KEY: StorageKey = StorageKey(PatriciaKey::ZERO); // The maximal contract address for which aliases are not used and all keys are serialized as is, // without compression. -const MAX_NON_COMPRESSED_CONTRACT_ADDRESS: ContractAddress = +pub const MAX_NON_COMPRESSED_CONTRACT_ADDRESS: ContractAddress = ContractAddress(PatriciaKey::from_hex_unchecked("0xf")); // The minimal value for a key to be allocated an alias. Smaller keys are serialized as is (their // alias is identical to the key). -const MIN_VALUE_FOR_ALIAS_ALLOC: PatriciaKey = +pub const MIN_VALUE_FOR_ALIAS_ALLOC: PatriciaKey = PatriciaKey::from_hex_unchecked(INITIAL_AVAILABLE_ALIAS_HEX); /// Allocates aliases for the new addresses and storage keys in the alias contract. diff --git a/crates/native_blockifier/src/lib.rs b/crates/native_blockifier/src/lib.rs index 0524d52fa3..5d18e3dafb 100644 --- a/crates/native_blockifier/src/lib.rs +++ b/crates/native_blockifier/src/lib.rs @@ -20,6 +20,11 @@ pub mod state_readers; pub mod storage; pub mod test_utils; +use blockifier::state::stateful_compression::{ + ALIAS_COUNTER_STORAGE_KEY, + MAX_NON_COMPRESSED_CONTRACT_ADDRESS, + MIN_VALUE_FOR_ALIAS_ALLOC, +}; use errors::{add_py_exceptions, UndeclaredClassHashError}; use py_block_executor::PyBlockExecutor; use py_objects::PyExecutionResources; @@ -64,6 +69,12 @@ fn native_blockifier(py: Python<'_>, py_module: &PyModule) -> PyResult<()> { estimate_casm_hash_computation_resources_for_testing_single, py )?)?; + py_module.add("ALIAS_COUNTER_STORAGE_KEY", ALIAS_COUNTER_STORAGE_KEY.to_string())?; + py_module.add( + "MAX_NON_COMPRESSED_CONTRACT_ADDRESS", + MAX_NON_COMPRESSED_CONTRACT_ADDRESS.to_string(), + )?; + py_module.add("INITIAL_AVAILABLE_ALIAS", MIN_VALUE_FOR_ALIAS_ALLOC.to_string())?; Ok(()) }