From 05d6ec51602c351ffca82b113ab847fac5015954 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 | 5 +++-- crates/native_blockifier/src/lib.rs | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/blockifier/src/state/stateful_compression.rs b/crates/blockifier/src/state/stateful_compression.rs index c4fdc8903b9..c6fb57fac2d 100644 --- a/crates/blockifier/src/state/stateful_compression.rs +++ b/crates/blockifier/src/state/stateful_compression.rs @@ -23,8 +23,9 @@ 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(|| ContractAddress(PatriciaKey::try_from(Felt::from_hex_unchecked("0xf")).unwrap())); +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 = diff --git a/crates/native_blockifier/src/lib.rs b/crates/native_blockifier/src/lib.rs index 0524d52fa3e..5c1533b2b5e 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", u16::from(*ALIAS_COUNTER_STORAGE_KEY))?; + py_module.add( + "MAX_NON_COMPRESSED_CONTRACT_ADDRESS", + u16::from(*MAX_NON_COMPRESSED_CONTRACT_ADDRESS), + )?; + py_module.add("INITIAL_AVAILABLE_ALIAS", u16::from(*MIN_VALUE_FOR_ALIAS_ALLOC))?; Ok(()) }