Skip to content

Commit

Permalink
test(native_blockifier): move alias constants to python
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavGrs committed Dec 17, 2024
1 parent 0f37c29 commit 05d6ec5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/blockifier/src/state/stateful_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ static ALIAS_COUNTER_STORAGE_KEY: LazyLock<StorageKey> =
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<ContractAddress> =
LazyLock::new(|| ContractAddress(PatriciaKey::try_from(Felt::from_hex_unchecked("0xf")).unwrap()));
static MAX_NON_COMPRESSED_CONTRACT_ADDRESS: LazyLock<ContractAddress> = 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<PatriciaKey> =
Expand Down
11 changes: 11 additions & 0 deletions crates/native_blockifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}
Expand Down

0 comments on commit 05d6ec5

Please sign in to comment.