From 6953410759075e0d190b97666c0ca7c4471453b9 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 | 6 +++--- crates/native_blockifier/src/lib.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/blockifier/src/state/stateful_compression.rs b/crates/blockifier/src/state/stateful_compression.rs index adc1e3f6873..66394d86ee1 100644 --- a/crates/blockifier/src/state/stateful_compression.rs +++ b/crates/blockifier/src/state/stateful_compression.rs @@ -19,16 +19,16 @@ type AliasKey = StorageKey; const INITIAL_AVAILABLE_ALIAS: Felt = Felt::from_hex_unchecked("0x80"); // The storage key of the alias counter in the alias contract. -static ALIAS_COUNTER_STORAGE_KEY: LazyLock = +pub static ALIAS_COUNTER_STORAGE_KEY: LazyLock = LazyLock::new(|| StorageKey(PatriciaKey::try_from(Felt::ZERO).unwrap())); // 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 0524d52fa3e..5d18e3dafb4 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(()) }