From ebcae8497c592c606b986da996b4d4937e56efe6 Mon Sep 17 00:00:00 2001 From: Yoav Gross Date: Tue, 10 Dec 2024 17:52:27 +0200 Subject: [PATCH] test(native_blockifier): move alias constants to python --- crates/blockifier/src/state/stateful_compression.rs | 4 ++-- crates/native_blockifier/src/lib.rs | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/blockifier/src/state/stateful_compression.rs b/crates/blockifier/src/state/stateful_compression.rs index fcfa10cbe9..a9af6aa41f 100644 --- a/crates/blockifier/src/state/stateful_compression.rs +++ b/crates/blockifier/src/state/stateful_compression.rs @@ -22,12 +22,12 @@ const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked("0x80"); 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. -static MAX_NON_COMPRESSED_CONTRACT_ADDRESS: LazyLock = LazyLock::new(|| { +pub static MAX_NON_COMPRESSED_CONTRACT_ADDRESS: LazyLock = LazyLock::new(|| { ContractAddress(PatriciaKey::try_from(Felt::from_hex_unchecked("0xf")).unwrap()) }); // The minimal value for a key to be allocated an alias. Smaller keys are serialized as is (their // alias is identical to the key). -static MIN_VALUE_FOR_ALIAS_ALLOC: LazyLock = +pub static MIN_VALUE_FOR_ALIAS_ALLOC: LazyLock = LazyLock::new(|| PatriciaKey::try_from(INITIAL_AVAILABLE_ALIAS).unwrap()); /// 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(()) }